Project Euler 310 - Nim Square

Official link: https://projecteuler.net/problem=310

Note: My code took ~took 77s with pypy, but I'm happy with my understanding of the problem.