Hi, I'm trying to solve this problem in Ruby: http://mirror.codeforces.com/contest/580/problem/C but I got RUNTIME ERROR on test number 35: http://mirror.codeforces.com/contest/580/submission/25929179
Here is my code: http://ideone.com/B0XtIg
Thank you in advance for your help