func_code_string: #include <bits/stdc++.h>   using namespace std;   mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());   const long long maxn = 3e5 + 10;   struct E {     long long to, nxt;   } e[maxn * 2];   long long tot, head[maxn];   long long Add[maxn << 2], lz[maxn << 2];   void adde(long long u, long long v) {     tot++;     e[tot] = {v, head[u]};     head[u] = tot;   }   vector<pair<long long, long long> > v[maxn];   long long n;   long long ans[maxn];   void dfs(int u, int fa, int dep) {     int len = v[u].size();     for (int i = 0; i < len; i++) {       int d = min(n + 1, dep + v[u][i].first + 1);       Add[dep] += v[u][i].second;       Add[d] -= v[u][i].second;     }     Add[dep] += Add[dep - 1];     ans[u] = Add[dep];     for (int i = head[u]; i; i = e[i].nxt) {       int to = e[i].to;       if (to == fa) continue;       dfs(to, u, dep + 1);     }     for (int i = 0; i < len; i++) {       int d = min(n + 1, dep + v[u][i].first + 1);       Add[dep] -= v[u][i].second;       Add[d] += v[u][i].second;     }     Add[dep] -= Add[dep - 1];   }   int main() {     cin >> n;     long long t1, t2;     for (long long i = 1; i < n; i++) {       scanf( %lld%lld , &t1, &t2);       adde(t1, t2);       adde(t2, t1);     }     long long m, t3;     cin >> m;     for (long long i = 1; i <= m; i++) {       scanf( %lld%lld%lld , &t1, &t2, &t3);       v[t1].push_back(make_pair(t2, t3));     }     dfs(1, 1, 1);     for (int i = 1; i <= n; i++) printf( %lld  , ans[i]);     return 0;   }   