Codeforces R1::Theater Square. Ruby