Possible solution for x upto 10^12

Code :- https://ide.codingblocks.com/s/233607

Evidently, squares of prime numbers are T-prime and hence I have used sieve for multiple test cases. But as sieve(vector) can be for max 10^9 size. Is there any other solution for values greater than 10^9 upto 10^12 ?

Hi @raikunal251297,
For this particular question rather than creating a vector of size 10^12, you can use a better approach. Check this out for your reference
https://ide.codingblocks.com/s/234185.
I encourage you to write your own code with the same approach.