Unable to find error in my code of problem:- STICNOT(Sticky Notes)

i am not able to find why i am getting TLE in subtask -4 of this problem.

problem link:-https://www.codechef.com/problems/STICNOT
code link:-https://www.codechef.com/viewsolution/28374238

Please help me out with this issue.

Add fast IO at the start of main:
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

thanks for the help!

I want to refer you to this answer:

and…