func_code_string: /*    * author: zhaoyiping    * time: 2021-06-04 23:08:02    */   #include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 5;   // vector<int> g[MAXN];   long long a[MAXN];   long long c[MAXN];   int fa[MAXN][20];   int deep[MAXN];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int q;     cin >> q >> a[0] >> c[0];     for (int i = 1; i <= q; i++) {       int op;       cin >> op;       if (op == 1) {         int p, aa, cc;         cin >> p >> aa >> cc;         a[i] = aa;         c[i] = cc;         fa[i][0] = p;         deep[i] = deep[p] + 1;         for (int j = 1; j < 20; j++) {           fa[i][j] = fa[fa[i][j - 1]][j - 1];         }       } else {         int v;         long long w;         cin >> v >> w;         int beg = v;         for (int i = 19; i >= 0; i--)           if (a[fa[beg][i]])             beg = fa[beg][i];         long long tt = 0;         long long ans = 0;         for (int i = deep[v] - deep[beg]; i >= 0; i--) {           int now = v;           for (int j = 0; j < 20; j++) {             if ((1 << j) & i)               now = fa[now][j];           }           if (a[now] >= w) {             tt += w;             ans += c[now] * w;             a[now] -= w;             w = 0;             break;           } else {             tt += a[now];             ans += c[now] * a[now];             w -= a[now];             a[now] = 0;           }         }         cout << tt <<     << ans << endl;       }     }     return 0;   }   