func_code_string: #include <bits/stdc++.h>   using namespace std;   struct vertex {     long long inside, edge;     int size = 1;     vector<int> child;   };   int ans = 0;   multiset<long long> st;   vertex g[100009];   void dfs(int v, bool flag, long long deep) {     if (flag) {       for (int i = 0; i < g[v].child.size(); i++) {         dfs(g[v].child[i], 1, 0);         g[v].size += g[g[v].child[i]].size;       }       return;     }     if (deep - g[v].inside > *st.begin()) flag = 1;     st.insert(deep);     for (int i = 0; i < g[v].child.size(); i++) {       dfs(g[v].child[i], flag, deep + g[g[v].child[i]].edge);       g[v].size += g[g[v].child[i]].size;     }     if (flag) ans += g[v].size;     flag = 0;     st.erase(deep);   }   int main() {     ios_base::sync_with_stdio(0);     int n;     st.insert(100000000000000000);     cin >> n;     for (int i = 1; i <= n; i++) cin >> g[i].inside;     for (int i = 2, c; i <= n; i++) {       cin >> c >> g[i].edge;       g[c].child.push_back(i);     }     dfs(1, 0, 0);     cout << ans;     return 0;   }   