AUSAG-Getting TLE (KMP algorithm)

Problem Link- https://www.codechef.com/problems/AUSAG

It is a question based on KMP-algorithm.
My solution matches exactly what is told in it’s editorial, but still getting TLE.

My solution: https://www.codechef.com/viewsolution/10444053