Project Euler 537 - Counting Tuples

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

Note: My code took 702 seconds to run, ~30s with pypy