Help:Weird Successful Submission in RBTREE

I submitted the solution for rbtree: CodeChef: Practical coding for everyone
It shows Partially accepted but i cannot understand how can first and last sub-tasks can show wrong for just 1 task each.(I mean which test cases i have missed).

(The code is big but its just repetition of a segment with minor changes for different cases.Just 126 lines are the main essence which are repeated again.)
Please Help with the wrong test cases.

Hello @hitman_o_o

I just had a look on your code and find that it is too long … Please look at this simple implementation of my logic … I have also added comments for better understanding of the solution …

Hope this help you…

Hey @hitman_o_o look at my code : CodeChef: Practical coding for everyone I am sure that you will understand it. If you didn’t understand, try to solve this problem : CodeChef: Practical coding for everyone and look at my code once again.If you have any doubts comment below.