func_code_string: #include <bits/stdc++.h>   using namespace std;   int a, b, c, d, e, f, g, h, i, j, k;   int father[100005][20];   vector<int> tree[100005];   int deep[100005];   int que[100005], num[100005];   int K;   int an;   void soso(int x) {     int ii, jj, kk;     que[++que[0]] = x;     deep[x] = deep[father[x][0]] + 1;     for (ii = 0; ii < tree[x].size(); ii++) {       jj = tree[x][ii];       if (jj == father[x][0]) continue;       father[jj][0] = x;       soso(jj);     }   }   void Build_LCA() {     int ii, jj, kk;     for (jj = 1; jj <= 19; jj++)       for (ii = 1; ii <= a; ii++)         father[ii][jj] = father[father[ii][jj - 1]][jj - 1];   }   int LCA(int x, int y) {     int ii, jj, kk;     if (deep[x] < deep[y]) swap(x, y);     for (ii = 18; ii >= 0; ii--)       if (deep[father[x][ii]] >= deep[y]) x = father[x][ii];     if (x == y) return x;     for (ii = 18; ii >= 0; ii--)       if (father[x][ii] != father[y][ii]) x = father[x][ii], y = father[y][ii];     return father[x][0];   }   int Dis(int x, int y) {     int u = LCA(x, y);     return deep[x] + deep[y] - 2 * deep[u];   }   int Add(set<pair<int, int> >& E, int x, int vv) {     int R = 0;     set<pair<int, int> >::iterator now;     if (vv == 1) E.insert(make_pair(num[x], x));     now = E.find(make_pair(num[x], x));     set<pair<int, int> >::iterator now1 = now;     set<pair<int, int> >::iterator pre, next;     if (now != E.begin()) {       pre = --now;       R += Dis((*pre).second, x);     }     now = now1;     next = ++now;     if (next != E.end()) {       R += Dis((*next).second, x);     }     now = now1;     if (now != E.begin() && next != E.end())       R -= Dis((*pre).second, (*next).second);     if (vv == -1) E.erase(now);     return R * vv;   }   bool Check(int x) {     int ii, jj, kk;     int now = 0;     set<pair<int, int> > GG;     for (ii = 1; ii <= x - 1; ii++) now += Add(GG, ii, 1);     for (ii = x; ii <= a; ii++) {       now += Add(GG, ii, 1);       set<pair<int, int> >::iterator in = GG.end();       in--;       int tmp = Dis((*GG.begin()).second, (*in).second);       if (now + tmp <= (K << 1)) return true;       now += Add(GG, ii - x + 1, -1);     }     return false;   }   int main() {     cin >> a >> K;     K--;     for (i = 1; i < a; i++) {       cin >> c >> d;       tree[c].push_back(d);       tree[d].push_back(c);     }     soso(1);     Build_LCA();     for (i = 1; i <= a; i++) num[que[i]] = i;     int low = 1, high = a, mid;     while (low <= high) {       mid = (low + high) >> 1;       if (Check(mid)) {         an = max(an, mid);         low = mid + 1;       } else         high = mid - 1;     }     cout << an << endl;     return 0;   }   