Hello Codeforces!
Can anybody please explain why this code is giving run-time error on codeforces? This solution is accepted in the actual OJ where the contest took place.
Here is the contest link- https://mirror.codeforces.com/gym/102141 Problem no is G.
Here is my code- https://ideone.com/xEqXuc
Could it be a reason that the testcases are not given as standard input output rather as a file? Although there seems to be no problem when using C++. So I can't be sure of what's going on here! Someone please shed some light here.







