Runtime error NZEC Ruby

This code is correct,isn’t it?

http://www.codechef.com/viewsolution/6438039

Trying it on this test
it gives NZEC error,while it runs fine on other ruby interpreters

Am I doing anything wrong?
Thanks for any help.