func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = (1e9) + 7;   const long long C = (1 << (17));   vector<vector<long long> > up, sum;   vector<long long> cost, maxw, d;   long long LOG = 20;   void push(long long v, long long x) {     cost.push_back(x);     maxw.push_back(x);     d.push_back(0);     for (int i = 0; i < LOG; ++i) {       sum[i].push_back(x);       up[i].push_back(v);     }   }   void init() {     up.resize(20);     sum.resize(20);     push(0, 0);   }   void add(long long pr, long long w) {     long long v = up[0].size();     if (maxw[pr] < w) {       push(v, w);       return;     }     for (int i = LOG - 1; i >= 0; --i) {       if (cost[up[i][pr]] < w) pr = up[i][pr];     }     if (cost[pr] < w) {       pr = up[0][pr];       assert(cost[pr] >= w);     }     cost.push_back(w);     maxw.push_back(maxw[pr]);     d.push_back(d[pr] + 1);     up[0].push_back(pr);     sum[0].push_back(cost[pr]);     for (int i = 1; i < LOG; ++i) {       long long pp = up[i - 1][v];       up[i].push_back(up[i - 1][pp]);       if (pp != up[i - 1][pp]) {         sum[i].push_back(sum[i - 1][v] + sum[i - 1][pp]);       } else {         sum[i].push_back(sum[i - 1][v]);       }     }   }   long long req(long long v, long long first) {     if (cost[v] > first) return 0;     first -= cost[v];     long long ans = 1;     for (int i = LOG - 1; i >= 0; --i) {       if (sum[i][v] <= first) {         ans += d[v] - d[up[i][v]];         first -= sum[i][v];         v = up[i][v];       }     }     return ans;   }   int source() {     init();     long long Q;     cin >> Q;     long long last = 0;     for (long long q1 = 0; q1 < Q; ++q1) {       long long type, p, q;       cin >> type >> p >> q;       long long R = p ^ last;       --R;       long long W = q ^ last;       if (type == 1) {         add(R, W);       } else {         last = req(R, W);         cout << last <<   n ;       }     }     return 0;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     source();     return 0;   }   