func_code_string: #include <bits/stdc++.h>   using namespace std;   int head[2 * 200005], nex[2 * 200005], from[2 * 200005], to[2 * 200005], cnt, n;   int sn[200005], num[200005];   long long d[200005], ans;   void add(int u, int v) {     nex[++cnt] = head[u];     from[cnt] = u;     to[cnt] = v;     head[u] = cnt;     nex[++cnt] = head[v];     from[cnt] = v;     to[cnt] = u;     head[v] = cnt;   }   void dfs(int x, int p) {     sn[x] = 1;     for (int i = head[x]; i; i = nex[i]) {       int u = to[i];       if (u == p) continue;       dfs(u, x);       for (int j = head[u]; j; j = nex[j]) {         int v = to[j];         if (v == x) continue;         d[x] += d[v] + sn[v];       }       d[x]++;       sn[x] += sn[u];     }   }   void dfs2(int x, int p) {     ans += d[x];     for (int i = head[x]; i; i = nex[i]) {       int u = to[i];       if (u == p) continue;       for (int j = head[u]; j; j = nex[j]) {         int v = to[j];         if (v == x) continue;         d[v] = d[x] - sn[v] + n - sn[u];         dfs2(v, u);       }       if (p == 0) {         d[u]++;         dfs2(u, x);       }     }   }   int main() {     cin >> n;     int u, v;     for (int i = 1; i < n; i++) {       scanf( %d%d , &u, &v);       add(u, v);       num[u]++;       num[v]++;     }     int root;     for (int i = 1; i <= n; i++)       if (num[i] == 1) {         root = i;         break;       }     dfs(root, 0);     dfs2(root, 0);     cout << ans / 2 << endl;   }   