func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> L[200005], W[200005];   vector<pair<long long, int> > path;   int a[200005], add[200005], rmv[200005];   int res[200005];   void DFS(int u, long long dis) {     int v, w, rem1 = 0, rem2 = 0;     path.push_back(make_pair(dis, u));     for (int i = 0; i < L[u].size(); i++) {       v = L[u][i];       w = W[u][i];       DFS(v, dis + W[u][i]);       rem1 += add[v];       rem2 += rmv[v];     }     int pos = lower_bound(path.begin(), path.end(), make_pair(dis - a[u], -1)) -               path.begin();     if (pos != path.size() && path[pos].first >= dis - a[u]) {       v = path[pos].second;       rmv[v]--;       add[u]++;     }     path.pop_back();     res[u] = rem1 + rem2;     add[u] += rem1;     rmv[u] += rem2;   }   int main() {     int n, u, v, w;     cin >> n;     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n - 1; i++) {       u = i;       scanf( %d%d , &v, &w);       v--;       L[v].push_back(u);       W[v].push_back(w);     }     DFS(0, 0);     for (int i = 0; i < n; i++) {       if (i) printf(   );       printf( %d , res[i]);     }     puts(  );   }   