Interesting Triplets (Easy)

Limits: 1s, 512 MB

Niko just learned about tree. Not those give us oxygen but tree from graph theory. After a while, he figured out that if he takes three distinct nodes A, B, C from a tree, sometimes it may occur that sum of the shortest distance from A to B and from B to C is equal to the shortest distance from A to C. This breathtaking discovery excites Niko a lot. He named such triplet as an interesting triplet. Out of curiosity, Niko tried to count down the number of such interesting triplets in a given tree. But alas, he is a newbie in graph theory and messed around the calculation. Niko heard that you are one of the best programmers from NSU and you are going to participate in “Intra NSU Programming Contest 2018”. So he came to you and ask for your help. Help Niko to solve his problem.

This is a companion discussion topic for the original entry at