func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 10010;   vector<int> v[MAXN];   int childcnt[MAXN] = {0};   int main() {     int n;     cin >> n;     for (int i = 1; i < n; i++) {       int a, b;       scanf( %d%d , &a, &b);       v[a].push_back(b);       v[b].push_back(a);     }     int root = 0;     for (int i = 1; i <= n; i++) {       if (v[i].size() == 1) {         root = i;         break;       }     }     bool vis[MAXN];     memset(vis, false, sizeof(vis));     queue<int> q;     q.push(root);     vis[root] = true;     int deep = 0;     long long ans = 0;     while (!q.empty()) {       childcnt[deep++] = q.size();       queue<int> p;       while (!q.empty()) {         int cur = q.front();         q.pop();         int len = v[cur].size();         int cnt = 0;         for (int i = 0; i < len; i++) {           if (!vis[v[cur][i]]) {             vis[v[cur][i]] = true;             p.push(v[cur][i]);             cnt++;           }         }         ans += (cnt - 1) * cnt / 2;       }       q = p;     }     for (int i = 2; i < deep; i++) {       ans += childcnt[i];     }     cout << ans << endl;     return 0;   }   