Two- and three-nucleon contact interactions and ground-state energies of light- and medium-mass nuclei