func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MAXN = 300010;   vector<long long> arr[MAXN];   vector<pair<long long, long long>> holdqs[MAXN];   bool visited[MAXN];   long long answer[MAXN];   long long temp[MAXN];   long long n;   void dfs(long long curr, long long par, long long level, long long ans) {     for (auto x : holdqs[curr]) {       long long lb = level;       long long rb = level + 1 + x.first;       temp[lb] += x.second;       if (rb <= n) {         temp[rb] -= x.second;       }     }     ans += temp[level];     answer[curr] = ans;     for (auto x : arr[curr]) {       if (x != par) {         dfs(x, curr, level + 1, ans);       }     }     for (auto x : holdqs[curr]) {       long long lb = level;       long long rb = level + 1 + x.first;       temp[lb] -= x.second;       if (rb <= n) {         temp[rb] += x.second;       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (long long i = 1; i < n; i++) {       long long x, y;       cin >> x >> y;       arr[x].push_back(y);       arr[y].push_back(x);     }     long long q;     cin >> q;     while (q--) {       long long v, d, x;       cin >> v >> d >> x;       holdqs[v].push_back(make_pair(d, x));     }     dfs(1, 1, 1, 0);     for (long long i = 1; i <= n; i++) {       std::cout << answer[i] << endl;     }   }   