Annoying bug in Equal LIS Start22

Any one knows what’s wrong with this code CodeChef: Practical coding for everyone (only 1 failed)

After contest, I figured out the issue is the case when n == 4, so i use a next_permutation for this. and AC CodeChef: Practical coding for everyone

But really don’t know why the first version failed in n == 4?