It is milking time on the farm, but all the cows have run away! To round them up you first need to work out how far each cow could possibly have gone.
The farm has $N$ pastures ($1 \le N \le 200{,}000$) numbered $1 \dots N$, connected by $N - 1$ bidirectional paths. The barn is at pasture $1$, and every pasture is reachable from the barn, so the pastures form a tree rooted at the barn.
Every cow starts the morning in its own pasture. A cow only runs away from the barn (it never moves back toward it), and it is too lazy to travel a total distance greater than $L$. For every pasture, determine how many distinct pastures a cow starting there could end up in (including its starting pasture).
Because the distances can be large, store them in 64-bit integers.
In the example, cows from pasture $1$ can hide in pastures $1$, $2$, and $4$. Cows from pasture $2$ can hide in pastures $2$ and $3$. Pastures $3$ and $4$ are the farthest from the barn, so a cow there can only stay put.