--Was solved long back with bad runtime of over a sec. So recoded with much better runtime of 0.082s/0.086s.
Another AC.
Reduced the length of the second loop (to check twin primes) by saving the twin primes (less than the root) in the sieve loop.
Replaced Sieve of Eratosthenes with Sieve of Atkin for better runtime.
Runtime improvements made:
--Replaced bool with bitset (although this will likely improve performance less).
--Changed unnecessary multiple mod calculations.
--Sieve of Atkin improved by seperating the 4x^2 + y^2 loop and running it half the root number of times instead of root times.