func_code_string: #include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1);   int ans, pos[120000], fa[21][120000], tim, dep[120000], K, n, x, y;   vector<int> E[120000];   struct wph {     bool operator()(const int x, const int y) { return pos[x] < pos[y]; }   };   set<int, wph> S;   void prep(int x, int ff) {     fa[0][x] = ff;     for (int i = 1; i <= 20; ++i) fa[i][x] = fa[i - 1][fa[i - 1][x]];   }   void dfs(int x, int ff) {     pos[x] = ++tim;     prep(x, ff);     for (int i = 0; i < E[x].size(); ++i)       if (E[x][i] != ff) {         dep[E[x][i]] = dep[x] + 1;         dfs(E[x][i], x);       }   }   int pathlen(int x, int y) {     int ans = dep[x] + dep[y];     if (dep[x] < dep[y]) swap(x, y);     for (int i = 20; i >= 0; --i)       if ((dep[x] - dep[y]) >= 1 << i) x = fa[i][x];     if (x == y) return ans - 2 * dep[x];     for (int i = 20; i >= 0; --i)       if (fa[i][x] != fa[i][y]) x = fa[i][x], y = fa[i][y];     return ans - 2 * dep[fa[0][x]];   }   int calc(set<int>::iterator it) {     int len = 0;     auto p1 = it, p2 = it;     if (p1 == S.begin()) p1 = S.end();     p1--;     len += pathlen(*p1, *it);     p2++;     if (p2 == S.end()) p2 = S.begin();     len += pathlen(*p2, *it);     len -= pathlen(*p2, *p1);     return len;   }   int main() {     scanf( %d%d , &n, &K);     for (int i = 1; i <= n - 1; ++i) {       scanf( %d%d , &x, &y);       E[x].push_back(y);       E[y].push_back(x);     }     dfs(1, 0);     ans = 1;     S.insert(1);     int j = 1, size = 0;     for (int i = 2; i <= n; ++i) {       auto p = S.insert(i).first;       size += calc(p);       while (size / 2 + 1 > K) {         p = S.find(j);         size -= calc(p);         S.erase(p);         j++;       }       ans = max(ans, i - j + 1);     }     printf( %d n , ans);   }   