Editorial is giving a run error

Sir, when submitting this problem’s editorial then in test case 2 its giving run error, i can’t figure out the fault, please help ?

I have written the code .
Check this out, you will get AC.

Try to dry run the code if you face any issue in understanding the code.