CHEFDAV problem, TestCases Issue

I am getting correct output for Subtask#2 but not getting correct output for subtask #1. Subtask#2 is a timeout testcase and Subtask#1 has constraints less than 100.

Can anyone tell me for which test case my solution fails ? I had verified with all possible testcases I could get.

Here is the question and here is my solution. Please help me figure out the testcase for which i am getting the wrong output.