HackerEarth Monk's School problem solution - TheCScience