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:-STICNOT Problem - CodeChef
code link:-CodeChef: Practical coding for everyone

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…