Long long is faster than int?

Правка en1, от kunzaZa183, 2025-12-08 14:54:24

Hi Codeforces, I was trying to solve this problem, and I was struggling to see why my code TLEs when other people's code (you can search up cses hamming distance solution for this) passes with similar logic.

Turns out when I add #define int long long, my code magically passes and became quite a bit faster. I am dumbfounded by this phenomenon, and the only explanation that was somewhat reasonable was this (which is crazy to me).

To me, it is crazy that sometimes declaring a bigger datatype can be faster than a smaller one, but I guess this is computer science, and anything can happen.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en5 Английский kunzaZa183 2025-12-08 17:06:43 16 I replaced it with the correct link.
en4 Английский kunzaZa183 2025-12-08 14:56:07 0 (published)
en3 Английский kunzaZa183 2025-12-08 14:55:41 64
en2 Английский kunzaZa183 2025-12-08 14:55:00 165
en1 Английский kunzaZa183 2025-12-08 14:54:24 901 Initial revision (saved to drafts)