Total Sum of Interaction Cost in Tree Groups II
Each tree edge is charged once for every same-group pair it separates; counting group sizes below each node adds those charges up.
Each tree edge is charged once for every same-group pair it separates; counting group sizes below each node adds those charges up.