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://codeforces.me/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.









Auto comment: topic has been updated by acmbucc (previous revision, new revision, compare).
People here in CF need to be held accountable for downvoting without stating the reason. This is saddening to see people not saying anything but downvoting.
I don't know exact reason of such behaviour, but all last java submits (at least on this problem) crashed with next result:
Java 8: Error occurred during initialization of VM java.lang.OutOfMemoryError: unable to create new native thread
Java 11: [0.025s][warning][os,thread] Failed to start thread — beginthreadex failed (ENOMEM) for attributes: stacksize: 65536k, flags: CREATE_SUSPENDED STACK_SIZE_PARAM_IS. Error occurred during initialization of VM java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
So it is not problem of your code, but some problem with running JVM for this problem or whole gym (i looked status of CF Archive — Java works there).
Thank you for confirming that this isn't happening because of my mistake. I appreciate this.
Although I'd like to know the reason behind this. Anyone having knowledge about this please leave a comment below.