Molecular gas in intermediate-redshift ultraluminous infrared galaxies