So I was solving this problem https://mirror.codeforces.com/gym/105723/problem/F
and wrote this solution https://ideone.com/SNfGJ6
It works fine in my laptop and ideone C++ 14 but when I submitted it in C++17 (GCC 7-32) I got WA on test 1. It did not make sense to me how I got a vastly different result on the test case in my laptop and CF. I suspected some type of RTE but I could not find any. Then I just submitted in C++23 (GCC 14-64, msys2) and got AC even though I did not change anything in the code.
Anyone knows why this happened. I feel like knowing it would kind of help me avoid it in contests. idk -_-








