Runtime error

While I was trying to submit answer for this problem I got runtime error even if my solution is correct. Then I checked submissions of others and found that every 1 in 3 submissions using python3 faced the same issue. Out of 3478 submissions 1216 submissions resulted in runtime error.

My solution

cc

There is nothing wrong with the system. Probably you are exiting the loop early before taking in complete input for the previous test case.

Thank you so much. I figured it out now