First (and silly, brute force) solution for the enormous input i python
better solution in python for enormous input test
slightly better python solution, but still takes 35s (should take 8 at most)