#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for(ll i=0; i < (n); i++) #define rrep(i, n) for(ll i=(n)-1; i >=0; i--) #define ALL(v) v.begin(),v.end() #define rALL(v) v.rbegin(),v.rend() #define FOR(i, j, k) for(ll i=j;i llvec; typedef vector dvec; typedef pair P; typedef long double ld; struct edge{ll x, c;}; ll N; vector e; llvec a; vector v; void dfs(ll from, ll to, ll c){ a.push_back(c); ll old = a.size(); for(auto ie: e[to]){ if(ie==from)continue; dfs(to, ie, c+1); ll n = a.size(); v[to].push_back(n-old); old=n; //a.push_back(c); } return; } /************************************** ** A main function starts from here ** ***************************************/ int main(){ cin >> N; e = vector(N); v = vector(N); rep(i, N-1){ ll u, w; cin >> u >> w; u--;w--; e[u].push_back(w); e[w].push_back(u); } dfs(-1, 0, 0); rep(i, N){ ll s = 0; for(auto ie: v[i]){ s += ie; } ll ans = 2*s+1; for(auto ie:v[i]){ ans = ans + ie * (s-ie); //cerr << ie << " " << s-ie<