func_code_string: #include <bits/stdc++.h>   using namespace std;   long long dist[200001] = {0};   int n, ans[200001], Val[200001], lg, tree[200001][20];   vector<vector<pair<int, long long> > > G(200001);   void Build(int v, int par = 0) {     tree[v][0] = par;     for (int i = 1; i <= lg; i++) tree[v][i] = tree[tree[v][i - 1]][i - 1];     for (int i = 0; i < G[v].size(); i++) {       dist[G[v][i].first] = dist[v] + G[v][i].second;       Build(G[v][i].first, v);     }   }   int FinalDfs(int v) {     for (int i = 0; i < G[v].size(); i++) ans[v] += FinalDfs(G[v][i].first) + 1;     return ans[v];   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &Val[i]);     while ((1 << lg) <= n) lg++;     lg--;     for (int i = 2; i <= n; i++) {       long long dis;       int par;       scanf( %d%I64d , &par, &dis);       G[par].push_back(make_pair(i, dis));     }     Build(1);     for (int i = 1; i <= n; i++) {       if (dist[i] <= Val[i]) continue;       int Pos = i;       int Value = Val[i];       for (int j = lg; j >= 0; j--)         if (dist[Pos] - dist[tree[Pos][j]] <= Value && tree[Pos][j] != 0) {           Value -= dist[Pos] - dist[tree[Pos][j]];           Pos = tree[Pos][j];         }       ans[tree[Pos][0]]--;     }     FinalDfs(1);     for (int i = 1; i <= n; i++) printf( %d  , ans[i]);     return 0;   }   