Two Squares — Solution & Editorial
By Fermat's two-squares theorem, N works iff every prime factor of the form 4k+3 appears to an EVEN power. Factor by trial division to √N (or rho) and check the 4k+3 exponents.
Complexity: O(√N)
Watch out: 0 = 0²+0² is YES; and the leftover prime after the loop needs its own 4k+3 check.