You are given a tree with n nodes. Count the number of paths (u, v) such that the distance from u to v is exactly k edges. A path can start and end at any two nodes. The distance is the number of edges on the unique path between them in the tree.
There are up to , nodes and the path length k can be up to n. You need to count efficiently. Centroid decomposition is the standard technique for counting paths of a specific length in trees.