Difficulty in solving CNTTREE from SPOJ.

I was looking attempting the problem CNTTREE from SPOJ, but I am completely clueless on how to solve such problems. I don’t even understood the sample test case.

This problem is also there on codechef, I looked at the editorial but appeared very overwhelming.

Can anyone please explain how to solve this problem, with the background of such problems.

// I don’t even understood the sample test case.
Make sure you know the definition of Diameter of a tree, as well the meaning of a subtree.

@sorb1997

Can you please explain.

@vivek_1998299 @vijju123

Can you please check this out?