Need help with code for SUBPRNJL-March Challenge

Can someone help me with this code, i am unable to figure out what type of test cases i am missing or if the logic is incorrect somehow, https://www.codechef.com/viewsolution/23551342
Thanks in advance

Read this solution. The approaches are similar even if the languages are different. You should be able to figure out your error.
https://www.codechef.com/viewsolution/23441441

Thanks for the help, i understood my mistake.