Runtime error in fenwick tree (BIT)

hi everyone,
I try the below question using Fenwick tree but I get a runtime error…

question screenshot:

my solution: https://github.com/prafull-vrsh/SPOJ-Solution/blob/main/Curious%20Robin%20Hood.txt

question link: http://www.lightoj.com/volume_showproblem.php?problem=1112

It will be a great help if anyone tells me the reason for the runtime error.
Thank you in advance.