func_code_string: #include <bits/stdc++.h>   using namespace std;   void read(long long &x) {     char ch = getchar();     x = 0;     while (!isdigit(ch)) ch = getchar();     while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();   }   const long long N = 2e5 + 10;   long long n, mx, rt, tmp, sum, f[N], fr[N], tot, st[N], fl[N], p[N];   long long cnt, h[N], to[N << 1], nxt[N << 1], len[N << 1], d[N], vis[N];   void add(long long u, long long v, long long l) {     to[++cnt] = v, len[cnt] = l, nxt[cnt] = h[u], h[u] = cnt;     to[++cnt] = u, len[cnt] = l, nxt[cnt] = h[v], h[v] = cnt;   }   void dfs(long long u, long long la) {     if (d[u] > d[mx]) mx = u;     fr[u] = la;     for (long long i = h[u], v; i; i = nxt[i]) {       if ((v = to[i]) == la) continue;       fl[v] = len[i], d[v] = d[u] + len[i], dfs(v, u);     }   }   void get_dis(long long u, long long deep) {     f[u] = deep;     vis[u] = 1;     for (long long i = h[u]; i; i = nxt[i])       if (!vis[to[i]]) get_dis(to[i], deep + len[i]);   }   long long ff[N], dp[N];   void get_fa(long long u, long long deep) {     dp[u] = deep;     for (long long i = h[u], v; i; i = nxt[i])       if ((v = to[i]) != ff[u]) ff[v] = u, get_fa(v, deep + 1);   }   bool cmp(long long x, long long y) {     return f[x] == f[y] ? dp[x] < dp[y] : f[x] < f[y];   }   long long fa[N], sz[N];   long long find(long long x) { return fa[x] == x ? x : (fa[x] = find(fa[x])); }   void work(long long l) {     long long res = 0;     for (long long i = 1; i <= n; ++i) fa[i] = i, sz[i] = 1;     for (long long i = n, j = n; i >= 1; --i) {       while (f[p[j]] > f[p[i]] + l) --sz[find(p[j--])];       res = max(res, sz[p[i]]);       fa[p[i]] = find(ff[p[i]]);       sz[find(ff[p[i]])] += sz[p[i]];     }     printf( %lld n , res);   }   signed main() {     read(n);     for (long long i = 1, u, v, l; i < n; ++i)       read(u), read(v), read(l), add(u, v, l);     dfs(1, 0);     d[mx] = fl[mx] = 0, dfs(mx, 0);     while (mx) sum += fl[mx], st[++tot] = mx, vis[mx] = 1, mx = fr[mx];     long long now = 0, mn = 1e15;     for (long long i = 1; i <= tot; ++i) {       get_dis(st[i], max(now, sum - now));       if (max(now, sum - now) < mn) mn = max(now, sum - now), rt = st[i];       now += fl[st[i]];     }     get_fa(rt, 0);     for (long long i = 1; i <= n; ++i) p[i] = i;     sort(p + 1, p + n + 1, cmp);     long long m, x;     read(m);     while (m--) read(x), work(x);     return 0;   }   