H2 and CO emission from disks around T Tauri and Herbig Ae pre-main sequence stars and from debris disks around young stars: warm and cold circumstellar gas