Shalane Flanagan became the first American woman to win the New York City Marathon in 40 years, while Geoffrey Kipsang Kamworor won the men's race.