can anybody who uses #define int long long or #define int int64_t or doesnt uses int and only uses 64 bit integers please tell if through out the career due to MLE/TLE they have ever needed to switch to 32 bit and if it made a difference in verdict or not?









Auto comment: topic has been updated by Ahmed-Nawaz (previous revision, new revision, compare).
no da den
I have had to switch to 32bit int only once or twice (never on codeforces). One of the times it was for some cses dp problem with very tight limits
I have done problems where using long long everywhere will lead to TLE (specifically: https://usaco.org/index.php?page=viewproblem2&cpid=1207)
Just use 32bit numbers unless the problem statement shows you that values would be large or you are computing products of large numbers.
Personally I use 32bit integers and 64bit integers specifically on what they are storing, not 64bit all the time.
MLE is situational, just check if (array size) * 8 bytes instead of 4 comfortably fits in the limit. Most problems do not care too much about memory.
For time, I ran some benchmarks for you. This is on GCC with -O2 on my i7-10700k.
Basically there's no difference in 32 vs 64 bits because they all probably execute exactly the same in the ALU.
(Bad) code: https://github.com/greatericontop/CompetitiveProgrammingStash/blob/main/random/benchmark.cpp
I tested again with a small loop written fully in assembly, 1 billion additions run in 0.20-0.21s vs 0.20-0.21s again.
Code: https://github.com/greatericontop/CompetitiveProgrammingStash/blob/main/random/benchmark_assembly.s (revised version to reduce the effect of pipelining)
https://codeforces.me/blog/entry/153170?#comment-1361875
Yeah everything you said there is correct. I also did not think of vectorization. I think I wasn't able to see the slower div instructions because my random numbers were too large.
I have encountered a similar situation before. There was a problem where I use long long in a dp array that did not require long long, resulting in TLE. After changing it to int, it passed.
It was a question in Luogu. The evaluation machine of luogu is very slow. I don't know the situation in Codeforces.
I think the evalution machine of Luogu is not very slow.Like this.Well,I usually use long long except the problems of Ynoi.
I hit this trouble every now and then. Changing
long longtointsometimes makes no difference, so I have to change the method — such as this.Personally, I use
#define int long longmost of the time. In ordinary problems, there is no need to worry too much about time and memory limits.i solved one questions i dont really remember the rating and problem statment ,as much i remember it was 1400 rated problem where i came up with almost 1e7 time compexity solution ,it was getting TLE repeatedly and as mush as i can think it was a solution which cant be optimized further , i just thought why not switch from long long to int and surprisingly it passed the all test cases , from that day i get so scared to use long long . if i find the problem , i will update.
I mostly use int64_t in my codes. TLE/MLE often occur in problems with strict constraints. Sometimes I put #define int64_t int32_t at the start of my codes.
I use #define int long long in most of my code, and it's really effective as I rarely see Wrong Answers due to overflow. However, it's not harmful; if possible, I still recommend thinking carefully before setting a variable to int64 or int32, as they have their own advantages.
Happened to me couple of times with some DP problems , got MLE using ll = long long; then changed it to int and passed peacefully.
many times, especially in Macedonian national contests where the TL and ML limits are tight due to limitations of the judging system