func_code_string: #include <bits/stdc++.h>   using namespace std;   long long a[1000001];   int nodeNumber[1000001], nodeStart[1000001], nodeEnd[1000001],       leftStart[1000001], leftEnd[1000001], rightStart[1000001],       rightEnd[1000001];   void Initialise(int n) {     sort(a + 1, a + n + 1);     for (int i = 0; i <= n; ++i) {       nodeStart[i] = 0;       nodeEnd[i] = -1;       nodeNumber[i] = 1;     }     nodeStart[1] = 1;     nodeEnd[1] = n;   }   void FixStartEnd(int &i, int &j) {     if (i > j) {       i = 0, j = -1;     }   }   void FillChildNumbers(int n, int k) {     for (int i = 0; i <= n; ++i) {       int j = nodeStart[i];       for (; j <= nodeEnd[i] && (a[j] & (1ll << k)) == 0; ++j)         ;       leftStart[i] = nodeStart[i], leftEnd[i] = j - 1;       rightStart[i] = j, rightEnd[i] = nodeEnd[i];       FixStartEnd(leftStart[i], leftEnd[i]);       FixStartEnd(rightStart[i], rightEnd[i]);       j = (nodeStart[i] > 0) ? nodeEnd[i] : i;       nodeStart[i] = 0;       nodeEnd[i] = -1;       i = j;     }   }   long long ZeroBitCount(int n, int k) {     long long ans = 0;     for (int i = 1; i <= n; ++i) {       int targetBit = ((a[i] & (1ll << k)) > 0), j = nodeNumber[i];       ans += ((targetBit == 1) ? (rightEnd[j] - rightStart[j] + 1)                                : (leftEnd[j] - leftStart[j] + 1));     }     return ans;   }   void TakeZeroBit(int n, int k) {     for (int i = 1; i <= n; ++i) {       int targetBit = ((a[i] & (1ll << k)) > 0), j = nodeNumber[i], x, start, end;       if (targetBit) {         x = rightStart[j], start = rightStart[j], end = rightEnd[j];       } else {         x = leftStart[j], start = leftStart[j], end = leftEnd[j];       }       nodeNumber[i] = x, nodeStart[x] = start, nodeEnd[x] = end;     }   }   void TakeOneBit(int n, int k) {     for (int i = 1; i <= n; ++i) {       int targetBit = 1 - ((a[i] & (1ll << k)) > 0), j = nodeNumber[i], x, start,           end;       if (targetBit) {         x = rightStart[j], start = rightStart[j], end = rightEnd[j];       } else {         x = leftStart[j], start = leftStart[j], end = leftEnd[j];       }       nodeNumber[i] = x, nodeStart[x] = start, nodeEnd[x] = end;     }   }   int main() {     int n;     long long m;     scanf( %d%lld , &n, &m);     for (int j = 2; j <= n; ++j) {       int i;       long long w;       scanf( %d%lld , &i, &w);       a[j] = (w ^ a[i]);     }     Initialise(n);     long long ans = 0;     for (int k = 61; k > -1; --k) {       FillChildNumbers(n, k);       long long cnt = ZeroBitCount(n, k);       if (cnt >= m) {         TakeZeroBit(n, k);       } else {         ans += (1ll << k);         m -= cnt;         TakeOneBit(n, k);       }     }     printf( %lld n , ans);     return 0;   }   