RAM's submission of Mahasena | CodeChef