This doesn't usually happen, but only when the time limits are too strict and constraints quite high. There's higher chance of getting into such a problem when your code involves a lot of modulo operations and data structures (like sets) that involve operations of long integers in the comparator function, though the chance of running into TLE is low even then. I usually use this I have almost never encountered such issues (except during some practice problems on spoj, though the problems were intentionally designed so). answered 08 Jan, 01:06

the intended solution is segmented sieve. Using long long/int will not matter if you use that logic. Your brute solution with int just passed luckily :P