func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   using uint = unsigned int;   using rl = double;   using pii = pair<int, int>;   const int MAXN = 3 * 100009;   int n, m;   struct Vert {     vector<int> to;     vector<pair<int, int>> qlist;     int depth;     ll vsum;   } v[MAXN];   ll psum[2 * MAXN];   void dfs(int it, int p, ll sum) {     v[it].depth = v[p].depth + 1;     for (auto q : v[it].qlist) {       psum[v[it].depth] += q.first;       psum[v[it].depth + q.second + 1] -= q.first;     }     sum += psum[v[it].depth];     v[it].vsum = sum;     for (auto t : v[it].to) {       if (t == p) continue;       dfs(t, it, sum);     }     for (auto q : v[it].qlist) {       psum[v[it].depth] -= q.first;       psum[v[it].depth + q.second + 1] += q.first;     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int a, b;       scanf( %d %d , &a, &b);       v[a].to.push_back(b);       v[b].to.push_back(a);     }     scanf( %d , &m);     for (int i = 0; i < m; i++) {       int it, d, x;       scanf( %d %d %d , &it, &d, &x);       v[it].qlist.push_back({x, min(d, n - 1)});     }     dfs(1, 0, 0);     for (int i = 1; i <= n; i++) {       printf( %lld  , v[i].vsum);     }     printf(  n );   }   