func_code_string: #include <bits/stdc++.h>   using namespace std;   int const N = 2e5 + 5;   vector<vector<int> > adj(N);   long long a[N];   pair<pair<long long, long long>, long long> dfs(int u, int prt = 0) {     if (adj[u].empty()) return {{1, a[u]}, a[u]};     pair<pair<long long, long long>, long long> ret = {{0, 0}, 0};     for (int v : adj[u]) {       if (v == prt) continue;       auto ch = dfs(v, u);       ret.first.first += ch.first.first, ret.first.second += ch.first.second;       ret.second = max(ret.second, ch.second);     }     long long k = ret.second * ret.first.first - ret.first.second;     long long rem = a[u] - min(a[u], k);     ret.second += rem / ret.first.first + (rem % ret.first.first != 0);     ret.first.second += a[u];     return ret;   }   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n;     cin >> n;     for (int i = 2; i <= n; i++) {       int p;       cin >> p;       adj[p].push_back(i);     }     for (int i = 1; i <= n; i++) cin >> a[i];     cout << dfs(1).second << endl;   }   