math's submission of Efficient Painting | CodeChef