Why would these people be on those tracks to begin with? And wouldn't they be intelligent enough to move from the tracks when they saw the trolley approaching?
What if these people on the tracks were planting bombs on the tracks that could kill hundreds of other innocent civilians and by killing them, not only would I be getting rid of some criminals but perhaps saving these innocent lives?
You know that scene in Spiderman, when Peter Parker lets the thief get away with all the money and ends up killing his uncle? How do we know that by trying to "save" these people, we also end up being an accomplice of a more large-scale murder?
So maybe I would probably run over the five people, come back with the trolley, and run over the other person on the other side just to be safe.