Massachusetts finished first among U.S. states in a study comparing the academic performance of American students with others around the globe.