Please help me identify the error(topic -trees)

Here is the link to my code : https://www.codechef.com/viewsolution/25411024
I am getting wrong answer for this solution.The output is correct if I run it on DEVC++.