graph g; ll n,z; int a[1d5],b[1d5]; ll f(int i,int p){ ll r=1; REP[g.edge[i]](j,g.es[i]){ ll t=(j!=p?f(j,i):0); z+=t*(n-t); r+=t; } return r; } { rd(n); rd((a,b)(n-1)); g.setEdge(n+1,n-1,a,b); f(1,1); wt(z*2+n*n); }