func_code_string: #include <bits/stdc++.h>   using namespace std;   int tot[100100];   int maxd = 0;   vector<vector<int> > g;   void dfs(int v, int d, int p) {     maxd = ((maxd < d) ? (d) : (maxd));     tot[d]++;     for (int i = (0); i < (g[v].size()); ++i) {       int to = g[v][i];       if (to != p) {         dfs(to, d + 1, v);       }     }   }   int use[100100];   inline bool check(int k, int w) {     int l = 1, r = 1;     int sum = tot[l];     while (sum < k) {       r++;       sum += tot[r];     }     long long price = 0;     int need = k;     for (int i = r; i >= l; --i) {       int v = ((need < tot[i]) ? (need) : (tot[i]));       use[i] = v;       price += v * 1ll * (r - i);       need -= v;     }     if (price <= w) return true;     while (1) {       if (r == maxd) break;       sum += tot[r + 1];       while (1) {         if (l == r) break;         if (sum - tot[l] >= k) {           price -= (r - l) * 1ll * use[l];           sum -= tot[l];           l++;         } else {           int v = k - (sum - tot[l]);           price -= (r - l) * 1ll * (use[l] - v);           use[l] = v;           break;         }       }       r++;       use[r] = ((tot[r] < k) ? (tot[r]) : (k));       price += k - use[r];       if (price <= w) return true;     }     return false;   }   int main() {     int n, k, p;     scanf( %d%d%d , &n, &k, &p);     g.resize(n);     for (int i = (0); i < (n - 1); ++i) {       int v1, v2;       scanf( %d%d , &v1, &v2);       v1--;       v2--;       g[v1].push_back(v2);       g[v2].push_back(v1);     }     dfs(0, 0, -1);     int res = 0;     int le = 1, ri = ((n - 1 < k) ? (n - 1) : (k));     while (le <= ri) {       int m = (le + ri) / 2;       if (check(m, p)) {         res = m;         le = m + 1;       } else {         ri = m - 1;       }     }     cout << res << endl;   }   