Python code gives AC but C++ code gives WA in CERSOL

In CERSOL, my Python solution gave AC, but when I “translated” it verbatim to an equivalent C++ solution, I got WA.

I haven’t been able to figure out why this is happening. Possibly some concept which I have been assuming to work the same in Python and C++, shows different behaviour in them; but I have been unable to pin-point which.
Any help is appreciated. Thanks in advance.