func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int n;   long long int a[100001];   vector<pair<long long int, long long int> > g[100001];   long long int dis[100001];   long long int rem[100001];   long long int dp[100001];   long long int child[100001];   long long int ct = 1;   void simpledfs(long long int x) {     rem[x] = 1;     for (long long int i = 0; i < g[x].size(); i++) {       simpledfs(g[x][i].first);     }   }   void dfs1(long long int x, long long int distance) {     dis[x] = distance;     long long int temp = 0;     long long int mi = 1e9;     long long int pos = -1;     for (long long int i = 0; i < g[x].size(); i++) {       dfs1(g[x][i].first, distance + g[x][i].second);       temp = temp + child[g[x][i].first] + 1;       if (dis[g[x][i].first] < mi) {         mi = dis[g[x][i].first];         pos = g[x][i].first;       }     }     dp[x] = pos;     child[x] = temp;   }   void dfs2(long long int x, long long int minv) {     for (long long int i = 0; i < g[x].size(); i++) {       long long int cur = g[x][i].first;       if ((dis[cur] - minv) > a[cur])         continue;       else {         ct++;         dfs2(cur, min(minv, dis[cur]));       }     }   }   int main() {     cin >> n;     for (long long int i = 1; i <= n; i++) cin >> a[i];     for (long long int i = 2; i <= n; i++) {       long long int p, c;       cin >> p >> c;       g[p].push_back(make_pair(i, c));     }     dfs1(1, 0);     dfs2(1, 0);     cout << n - ct;   }   