func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<vector<int> > adjl(500000);   int s[500000] = {0};   long long int a[500000] = {0};   map<pair<int, int>, long long int> mp;   int vis[500000] = {0};   void dfs(int n, vector<pair<int, int> > &ans, int p, long long int sum,            long long int mini) {     if (sum - mini > a[n]) {       ans.push_back(make_pair(n, p));     }     for (int i = 0; i < adjl[n].size(); i++) {       int ch = adjl[n][i];       if (ch != p) {         dfs(ch, ans, n, sum + mp[make_pair(ch, n)],             min(mini, sum + mp[make_pair(ch, n)]));       }     }   }   void dfs1(int n, int p, int &count) {     vis[n] = 1;     count++;     for (int i = 0; i < adjl[n].size(); i++) {       int ch = adjl[n][i];       if (ch != p) {         dfs1(ch, n, count);       }     }   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i + 1];     }     for (int i = 0; i < (n - 1); i++) {       int a, c;       cin >> a >> c;       adjl[a].push_back(i + 2);       adjl[i + 2].push_back(a);       mp[make_pair(a, i + 2)] = c;       mp[make_pair(i + 2, a)] = c;     }     vector<pair<int, int> > ans;     dfs(1, ans, -1, 0, 0);     long long int ans1 = 0;     for (int i = 0; i < ans.size(); i++) {       if (!vis[ans[i].first]) {         int count = 0;         dfs1(ans[i].first, ans[i].second, count);         ans1 += count;       }     }     cout << ans1 << endl;   }   