func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, x, y, son[100005], q;   int fir[100005], nxt[200005], to[200005], cnt;   long long wi[200005], z, dp[100005][2], f[100005];   struct node {     int id;     long long val;   } c[100005];   int size[100005], fa[100005], Fa[100005];   long long read() {     long long x = 0;     char ch = getchar();     while (!isdigit(ch)) ch = getchar();     while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();     return x;   }   void dfs(int x, int fa) {     for (int i = fir[x]; i; i = nxt[i]) {       if (to[i] == fa) continue;       dfs(to[i], x);       if (dp[x][0] < dp[to[i]][0] + wi[i])         dp[x][1] = dp[x][0], dp[x][0] = dp[to[i]][0] + wi[i], son[x] = to[i];       else if (dp[x][1] < dp[to[i]][0] + wi[i])         dp[x][1] = dp[to[i]][0] + wi[i];     }   }   void Dfs(int x, int fa, long long W) {     f[x] = max(dp[x][0], W);     for (int i = fir[x]; i; i = nxt[i]) {       if (to[i] == fa) continue;       if (to[i] == son[x])         Dfs(to[i], x, max(W, dp[x][1]) + wi[i]);       else         Dfs(to[i], x, max(W, dp[x][0]) + wi[i]);     }   }   int cmp(node u, node v) { return u.val < v.val; }   void DFS(int x, int f) {     Fa[x] = f;     for (int i = fir[x]; i; i = nxt[i]) {       if (to[i] == f) continue;       DFS(to[i], x);     }   }   int find(int x) {     if (x == fa[x]) return x;     return fa[x] = find(fa[x]);   }   int main() {     n = read();     for (int i = 1; i < n; i++) {       x = read(), y = read(), z = read();       to[++cnt] = y, nxt[cnt] = fir[x], fir[x] = cnt, wi[cnt] = z;       to[++cnt] = x, nxt[cnt] = fir[y], fir[y] = cnt, wi[cnt] = z;     }     dfs(1, 0);     Dfs(1, 0, 0);     for (int i = 1; i <= n; i++) c[i] = (node){i, f[i]};     sort(c + 1, c + n + 1, cmp);     DFS(c[1].id, 0);     q = read();     for (int i = 1; i <= q; i++) {       z = read();       for (int i = 1; i <= n; i++) fa[i] = i;       for (int i = 1; i <= n; i++) size[i] = 1;       int r = n, ans = 0;       for (int j = n; j >= 1; j--) {         while (r && c[r].val - c[j].val > z) size[find(c[r].id)]--, r--;         ans = max(ans, size[find(c[j].id)]);         int u = find(c[j].id), v = find(Fa[c[j].id]);         if (u != v) fa[u] = v, size[v] += size[u];       }       printf( %d n , ans);     }     return 0;   }   