func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int read() {     int res = 0;     int neg;     while (true) {       char ch = getchar();       if (ch >=  0  && ch <=  9  || ch ==  - ) {         if (ch ==  - )           neg = -1;         else           neg = 1, res = ch -  0 ;         break;       }     }     while (true) {       char ch = getchar();       if (ch >=  0  && ch <=  9 )         res *= 10, res += ch -  0 ;       else         break;     }     return res * neg;   }   const int maxn = 100020;   const int MOd = 1e7;   int a, L, R, st[maxn], at;   bool flag, used[maxn];   vector<pair<int, pair<int, int> > > w[maxn];   vector<pair<int, int> > w2[maxn];   int dfs(int n, int back, int sz) {     int ret = 1;     st[++at] = n;     for (int i = 0; i < w[n].size(); i++)       if (w[n][i].first != back && !used[w[n][i].first]) {         int t = dfs(w[n][i].first, n, sz);         w[n][i].second.second = t;         ret += t;       }     for (int i = 0; i < w[n].size(); i++)       if (w[n][i].first == back) w[n][i].second.second = sz - ret;     return ret;   }   vector<int> Cw[maxn];   int ans1, ans2, sz[maxn];   void center(int n, int back, int szz) {     at = 0;     dfs(n, 0, szz);     int C = n;     for (int i = 1; i <= at; i++) {       int t = st[i];       int c = 0;       for (int j = 0; j < w[t].size(); j++)         if (w[t][j].second.second > szz / 2) {           c = 1;           break;         }       if (!c) C = t;     }     Cw[back].push_back(C);     sz[C] = szz;     used[C] = 1;     for (int i = 0; i < w[C].size(); i++)       if (!used[w[C][i].first]) center(w[C][i].first, C, w[C][i].second.second);   }   int N, T;   pair<int, int> segment[maxn * 3];   pair<int, pair<int, int> > st2[maxn];   void dfss(int &n, int &back, int der, int s) {     st2[++at].first = n;     st2[at].second.first = der;     st2[at].second.second = s + s - der;     pair<int, int> t;     t.first = -1e9;     t.second = 0;     int l = L - der, r = R - der;     if (l < N && 0 <= l) {       if (r > N - 1) r = N - 1;       for (l += N, r += N; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {         if (l & 1) t = max(t, (segment[l]));         if (~r & 1) t = max(t, (segment[r]));       }     }     if (t.first + s + s - der >= 0) {       ans1 = n;       ans2 = t.second;       flag = 1;       return;     }     for (int i = 0; i < w2[n].size() && !flag; i++)       if (w2[n][i].first != back && !used[w2[n][i].first])         dfss(w2[n][i].first, n, der + 1, s + w2[n][i].second);   }   void calc(int &C) {     N = 1;     while (N < sz[C]) N <<= 1;     for (int i = 1; i < N + N; i++) segment[i] = pair<int, int>(-1e9, 0);     for (int k = N; k; k >>= 1) segment[k] = pair<int, int>(0, C);     for (int i = 0; i < w2[C].size(); i++)       if (!used[w2[C][i].first]) {         at = 0;         dfss(w2[C][i].first, C, 1, w2[C][i].second);         if (flag) return;         for (int i = 1; i <= at; i++) {           pair<int, pair<int, int> > &t = st2[i];           int k = t.second.first + N;           if (segment[k].first < t.second.second) {             segment[k] = pair<int, int>(t.second.second, t.first);             for (k >>= 1; k; k >>= 1)               segment[k] = max(segment[k + k], segment[k + k + 1]);           }         }       }     used[C] = 1;     for (int i = 0; i < Cw[C].size(); i++) {       calc(Cw[C][i]);       if (flag) return;     }   }   bool f(int n) {     for (int i = 1; i <= a; i++)       for (int j = 0; j < w[i].size(); j++)         w2[i][j].second = (w[i][j].second.first >= n);     flag = 0;     memset(used, 0, sizeof(used));     calc(Cw[0][0]);     return flag;   }   int main() {     scanf( %d %d %d , &a, &L, &R);     for (int i = 1, j, k, t; i < a; i++) {       scanf( %d %d %d , &j, &k, &t);       w[j].push_back(pair<int, pair<int, int> >(k, pair<int, int>(t, 0)));       w[k].push_back(pair<int, pair<int, int> >(j, pair<int, int>(t, 0)));       w2[j].push_back(pair<int, int>(k, 0));       w2[k].push_back(pair<int, int>(j, 0));     }     center(1, 0, a);     int t = -1;     for (int k = 29; k >= 0; k--)       if (f(t + (1 << k))) t += 1 << k;     printf( %d %d n , ans1, ans2);     return 0;   }   