Cuevas lines 2-run single in 8th, Rockies beat Giants 9-8