func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 123456;   int n, d[N], h[N];   bool vis[N];   vector<int> G[N];   struct Node {     int u, h;     bool operator<(const Node& rhs) const { return h < rhs.h; }     Node(int u, int h) : u(u), h(h) {}   };   priority_queue<Node> pq;   int bfs() {     memset(d, -1, sizeof(d));     d[1] = 0;     queue<int> q;     q.push(1);     while (!q.empty()) {       int u = q.front();       q.pop();       for (int v : G[u])         if (d[v] == -1) {           d[v] = d[u] + 1;           q.push(v);         }     }     int ans = 1, maxm = 0;     for (int i = 2; i <= n; i++)       if (d[i] > maxm) {         maxm = d[i];         ans = i;       }     return ans;   }   int dfs(int u, int fa) {     for (int v : G[u])       if (v != fa) h[u] = max(h[u], dfs(v, u) + 1);     if (fa) pq.push(Node(u, h[u]));     return h[u];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       G[u].push_back(v);       G[v].push_back(u);     }     int root = bfs();     dfs(root, 0);     cout << 1;     int cnt = 1;     for (int i = 2; i <= n; i++) {       if (cnt == n) {         cout <<     << n;         continue;       }       int cur = 0;       while (!pq.empty()) {         Node u = pq.top();         pq.pop();         if (!vis[u.u]) {           cur = u.u;           break;         }       }       for (;;) {         cnt++;         vis[cur] = true;         if (!h[cur]) break;         for (int v : G[cur])           if (h[v] == h[cur] - 1) {             cur = v;             break;           }       }       cout <<     << cnt;     }     return 0;   }   