SKMP getting a wrong answer

Problem statement:
https://www.codechef.com/AUG20B/problems/SKMP

Can anyone tell me what’s wrong with my code I got a wrong answer during the
competition…

https://www.codechef.com/viewsolution/36354531