Project Euler 540 - Counting Primitive Pythagorean Triples

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

Note: My code takes ~500 seconds to run, ~15s with pypy