Bug in executing program


#1

When selecting custom input and running the code, answer is correct. Not when submitting.


#2

here too, python code…


#3

Custom input test runs a single test. Test and Submit run multiple tests, so if you don’t reinitialize any global variables at the start of every test, it can give incorrect answers. This is not intuitively obvious; I wouldn’t know it if someone hadn’t mentioned it in comments.