func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10, M = 1e6 + 5;   long long T, l[N], dp[N], fen[M][2];   vector<int> adj[N];   int n, x[N], t[N];   void add(int p, int x) {     for (long long y = 1LL * x * p; p < M; p += p & -p)       fen[p][0] += x, fen[p][1] += y;   }   long long get(int p, int id) {     long long ans = 0;     for (; p; p -= p & -p) ans += fen[p][id];     return ans;   }   void dfs(int u) {     add(t[u], x[u]);     int L = 0, R = M;     while (L + 1 < R) {       int mid = L + R >> 1;       (T < 2 * l[u] + get(mid, 1) ? R : L) = mid;     }     long long mx[2] = {};     for (int v : adj[u]) {       l[v] += l[u], dfs(v);       dp[v] > mx[1] ? mx[0] = mx[1], mx[1] = dp[v] : mx[0] = max(mx[0], dp[v]);     }     dp[u] =         max(get(L, 0) + (R < M && T > 2 * l[u]) * (T - 2 * l[u] - get(L, 1)) / R,             mx[!u]);     add(t[u], -x[u]);   }   int main() {     cin >> n >> T;     for (int u = 0; u < n; u++) cin >> x[u];     for (int u = 0; u < n; u++) cin >> t[u];     for (int u = 1, v; u < n; u++) {       cin >> v >> l[u];       adj[--v].push_back(u);     }     dfs(0), cout << dp[0];   }   