[X] Use
www.quantumcoinflip.com to flip a coin. If heads, pull the lever diverting the trolley to the portal. If tails, don't pull the lever.
If those same 5 people will be murdered in the alternate universe if we pull the lever, it's possible this other universe has another us with another lever deciding how to direct another trolley and that other us would in theory do the same thing as us either diverting the trolley or standing by in synchronicity (If we let the people get hit, our double would also let their five people get hit. If we divert our trolley to kill their five people then they will divert their trolley, thus sending their trolley to our universe and killing our five people as well).
Thus, by the nature of deterministic alternate universes, those five people infront of us and their otherworldly counterparts are doomed to be hit by a trolley regardless of our choice. The only way to cheat fate in this situation is to let pure random chance (via quantum mechanics) determine their fate!
If both us and our (hypothetical) alternate dimension counterpart make our choice purely randomly then there's a chance we will break synchronicity and divert both trolleys to hit the same five people! Thus causing the two trolleys to collide and destory eachother, possibly saving at least half of the potential trolley victims involved.
Basically, if there's another us in the other dimension and we both flip quantum coins then there's a 2 out of 4 chance that we may crash the trolleys.
If both of us do nothing, the trolleys will both run into the five people, killing them.
Is both of us flip the switch, both trolleys get diverted through portals and kill the five people in the opposite dimension.
If one of us flips the switch while the other does nothing, then one trolley will keep going forward while another gets diverted to the same track. Potentially causing both trolleys to collide and derail. This ensures at least one set of the five people survives.
Of course, most of this relies on hypothetical and unfounded conjecture on the nature of parallel worlds. But it's the only forseeable way to avoid having to kill anyone (and possibly crash two inter-dimensional trolleys together).