func_code_string: #include <bits/stdc++.h>   using namespace std;   struct segTree {     long long* data;     int n;     segTree(int n) : n(n) { data = new long long[n * 2](); }     void add(int i, long long v) {       for (i += n; i; i >>= 1) data[i] += v;     }     int find(long long v) {       int i = 1;       while (i < n) {         i *= 2;         if (v >= data[i]) v -= data[i++];       }       return i - n;     }     long long sum(int i) {       long long r = data[i + n];       for (i += n; i > 1; i >>= 1) {         if (i & 1) r += data[i - 1];       }       return r;     }   };   segTree count_tree(1 << 17), sum_tree(1 << 17);   long long x[100000], t[100000];   vector<pair<int, long long>> child[100000];   map<int, int> ti_map;   int ti_list[100000];   long long dp[100000], dp2[100000];   void dfs(int p, long long T) {     if (T <= 0) return;     count_tree.add(ti_map[t[p]], x[p]);     sum_tree.add(ti_map[t[p]], x[p] * t[p]);     int i = sum_tree.find(T);     dp[p] = count_tree.sum(i - 1);     assert(sum_tree.sum(i - 1) <= T);     assert(i >= 1e5 + 10 || sum_tree.sum(i) > T);     if (i < 1e5 + 10) dp[p] += (T - sum_tree.sum(i - 1)) / ti_list[i];     vector<long long> child_vals;     for (auto e : child[p]) {       dfs(e.first, T - e.second * 2);       child_vals.push_back(dp2[e.first]);     }     sort(child_vals.rbegin(), child_vals.rend());     dp2[p] = dp[p];     if (child_vals.size() >= 2) dp2[p] = max(dp2[p], child_vals[1]);     if (p == 0) dp2[p] = max(dp2[p], child_vals[0]);     count_tree.add(ti_map[t[p]], -x[p]);     sum_tree.add(ti_map[t[p]], -x[p] * t[p]);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n, T;     cin >> n >> T;     for (int i = 0; i < n; i++) cin >> x[i];     for (int i = 0; i < n; i++) {       cin >> t[i];       ti_map[t[i]];     }     int c = 1;     for (auto& p : ti_map) {       ti_list[c] = p.first;       p.second = c++;     }     for (int i = 1; i < n; i++) {       long long p, l;       cin >> p >> l;       child[p - 1].push_back({i, l});     }     dfs(0, T);     cout << dp2[0] << endl;   }   