Kirk Cousins threw for 276 yards and three touchdowns to lead the 12th-ranked Spartans to a 35-31 victory over the Boilermakers.