Good permutations

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

Can someone please help me in finding the error?
I am getting correct ans for test cases but getting wrong ans on submitting.

You are getting correct answer for the test cases in test case bank under editorial? Are you sure? Because those are all the TC in that problem afaik (if setter didnt add more in practice)