Hostel Visit , Competetive Programming

My test case 2 is not getting accepted, What is wrong in the code?