Using the same code, if I use the long long data type it shows TLE and if the data type ONLY is changed to int then it gets AC. Moreover, the constraints’ values are not in the int range…
Which problem are you discussing, please share problem link.and your solution link to check the issue.(Provided that the problem should not be of any ongoing contest.)
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
#define int long long in the contest to save time
I have almost never encountered such issues (except during some practice problems on spoj, though the problems were intentionally designed so).
added the required links
Sometimes using operation like % on long long takes more time than on int numbers, because long long is 64 bit ,while int is 32 bit.
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