Solution for 372 based on some lattice counting algorithm for right triangles (runs in 1m30).