Is using int faster than long long int?

Is using int faster than long long int? I noticed that when I got AC in all subtasks in one problem and when I changed everything to long long int I got TLE in last few subtasks where n was bigger, which doesn’t make sense to me because the time complexity of the program is same so for same value of n, shouldn’t it take the same amount of time? I faced this problem in an ongoing contest so I wont link the problem.

While processing int you process 4 bytes per operation while in case of long long int you process 8 bytes for same operation. That’s why long long int is little bit slower.

1 Like

long long int takes 2x time in I/O operations than simple int.

1 Like

thanks, by processing int do you mean changing the value and assigning values to the variable, or do you mean input output?

so only in input output right? and not when you are assigning the value or doing operations like modulo on 2 long long ints rather than int?

I mean everywhere