Need Assistance with USACO Problem - Stuck on Test Case 5

I’m currently working on the USACO problem and I’ve run into a roadblock. After several attempts, my code is failing on test case 5, and I can’t seem to figure out why. Has anyone has encountered a similar problem?

Can anyone please suggest me?

You need to tell us what the problem name is if you need help.