  ALMA observations of the long wavelength dust continuum are used to estimate
the interstellar medium (ISM) masses in a sample of 708 galaxies at z = 0.3 to
4.5 in the COSMOS field. The galaxy sample has known far-infrared luminosities
and, hence, star formation rates (SFRs), and stellar masses (M$_{\rm *}$) from
the optical-infrared spectrum fitting. The galaxies sample SFRs from the main
sequence (MS) to 50 times above the MS. The derived ISM masses are used to
determine the dependence of gas mass on redshift, M$_{\rm *}$, and specific SFR
(sSFR) relative to the MS. The ISM masses increase approximately 0.63 power of
the rate of increase in SFRs with redshift and the 0.32 power of the
sSFR/sSFR$_MS$. The SF efficiencies also increase as the 0.36 power of the SFR
redshift evolutionary and the 0.7 power of the elevation above the MS; thus the
increased activities at early epochs are driven by both increased ISM masses
and SF efficiency. Using the derived ISM mass function we estimate the
accretion rates of gas required to maintain continuity of the MS evolution
($>100$ \msun yr$^{-1}$ at z $>$ 2.5). Simple power-law dependences are
similarly derived for the gas accretion rates. We argue that the overall
evolution of galaxies is driven by the rates of gas accretion. The cosmic
evolution of total ISM mass is estimated and linked to the evolution of SF and
AGN activity at early epochs.
