  The exoplanet population characterized by relatively short orbital periods
($P<100$ d) around solar-type stars is dominated by super-Earths and
sub-Neptunes. However, these planets are missing in our Solar System and the
reason behind this absence is still unknown. Two theoretical scenarios invoke
the role of Jupiter as the possible culprit: Jupiter may have acted as a
dynamical barrier to the inward migration of sub-Neptunes from beyond the water
iceline; alternatively, Jupiter may have reduced considerably the inward flux
of material (pebbles) required to form super-Earths inside that iceline. Both
scenarios predict an anti-correlation between the presence of small planets
(SPs) and that of cold Jupiters (CJs) in exoplanetary systems. To test that
prediction, we homogeneously analyzed the radial-velocity (RV) measurements of
38 Kepler and K2 transiting SP systems gathered over almost 10 years with the
HARPS-N spectrograph, as well as publicly available RVs collected with other
facilities. We detected five CJs in three systems, two in Kepler-68, two in
Kepler-454, and a very eccentric one in K2-312. We derived an occurrence rate
of $9.3^{+7.7}_{-2.9}\%$ for CJs with $0.3-13~M_{Jup}$ and 1-10 AU, which is
lower but still compatible at $1.3\sigma$ with that measured from RV surveys
for solar-type stars, regardless of the presence or absence of SPs. The sample
is not large enough to draw a firm conclusion about the predicted
anti-correlation between SPs and CJs; nevertheless, we found no evidence of
previous claims of an excess of CJs in SP systems. As an important by-product
of our analyses, we homogeneously determined the masses of 64 Kepler and K2
small planets, reaching a precision better than 5, 7.5 and 10$\sigma$ for 25,
13 and 8 planets, respectively. Finally, we release the 3661 HARPS-N radial
velocities used in this work to the scientific community. [Abridged]
