Atomic and molecular correlation energies with explicitly correlated Gaussian geminals. III. Coupled cluster treatment for He, Be, H2, and LiH