func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> eg[400005];   long long dep[400005];   int dfn[400005], sz[400005];   int a[400005];   int p[400005], w[400005];   int dfcnt = 0;   int fa[400005][20];   void dfs(int a) {     sz[a] = 1, dfn[a] = ++dfcnt;     for (auto v : eg[a]) {       if (v == p[a]) continue;       fa[v][0] = a;       for (int i = 1; i < 20; i++) fa[v][i] = fa[fa[v][i - 1]][i - 1];       dep[v] = dep[a] + w[v];       dfs(v);       sz[a] += sz[v];     }   }   long long ud[400005];   vector<int> qs[400005];   int d[400005];   int lb(int x) { return x & -x; }   void upd(int pl, int x) {     while (pl < 400005) d[pl] += x, pl += lb(pl);   }   int q(int pl) {     int ans = 0;     while (pl) ans += d[pl], pl -= lb(pl);     return ans;   }   int ans[400005];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 2; i <= n; i++) {       scanf( %d%d , &p[i], &w[i]);       eg[p[i]].push_back(i);     }     dfs(1);     dep[0] = -1e18;     for (int i = 1; i <= n; i++) {       int v = i;       for (int j = 19; j >= 0; j--) {         int t = fa[v][j];         if (dep[t] >= dep[i] - a[i]) v = t;       }       if (p[v]) upd(dfn[p[v]], -1);       upd(dfn[i], 1);     }     for (int i = 1; i <= n; i++) ans[i] = q(dfn[i] + sz[i] - 1) - q(dfn[i] - 1);     for (int i = 1; i <= n; i++) printf( %d  , ans[i] - 1);     return 0;   }   