question = https://hack.codingblocks.com/contests/c/452/1103
solution = https://ide.codingblocks.com/#/s/20822
BOSTON NUMBERS 2 run error
As the constraints are too large , you cannot find primes upto the given constraints thats why you are getting runerror . Use the idea of calculating factors and then solve this .
You can take a look on this code
https://ide.codingblocks.com/#/s/21090