Why the sample test case has output = 10 instead of 12

i also read editorial
but there are runtime erroe in my code

#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector
#define vl vector
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl ‘\n’
#define mp make_pair
#define debug1(x) cout <<#x<<" “<<x<<’\n’;
#define debug2(x,y) cout <<#x<<” “<<x <<” “<<#y<<” “<<y <<’\n’;
#define debug3(x,y,z) cout<<#x<<” “<<x<<” “<<#y<<” “<<y<<” “<<#z<<” "<<z<<’\n’;
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

class TrieNode{
public:
TrieNode *left;
TrieNode *right;
vector *index;

TrieNode() {
	this->index = new vector<int>;
}

};

void insert(int n, TrieNode *head, int idx) {
TrieNode *curr = head;
for(int i=31;i>=0;i–) {
int bit = (n>>i)&1;
if(bit == 0) {
if(curr->left==NULL) {
curr->left = new TrieNode();
}
curr->index->pb(idx);
curr = curr->left;
}
else{
if(curr->right==NULL) {
curr->right = new TrieNode();
}
curr->index->pb(idx);
curr = curr->right;
}
}
// curr->index->pb(idx);
}

int binarySearchRange(vector* v, int l ,int r) {
int s=0, e=v->size()-1;
while(s<=e){
int mid = (l+r)/2;
int val = (*v)[mid];
if(val>=l && val<=r)
return true;
else if(val<l) {
s=mid+1;
}
else if(val>r){
e=mid-1;
}
}
return false;
}

int findMaxXorPair(TrieNode *head, int value, int l, int r) {
TrieNode *curr = head;
int curr_xor = 0;
for(int i=31;i>=0;i–) {
int b= (value>>i)&1;

	if(b==0) {
		if(curr->right!=NULL && binarySearchRange(curr->right->index,l ,r)) {
			curr = curr->right;
			curr_xor += (int)pow(2,i);
		}
		else{
			curr = curr->left;
		}
	}
	else{
		if(curr->left!=NULL && binarySearchRange(curr->left->index, l, r)) {
			curr = curr->left;
			
			
		}
		else{
			curr = curr->right;
			curr_xor += (int)pow(2,i);
			
		}
	}
}

return curr_xor;

}

void solve() {
int q;
cin >> q;

TrieNode *head = new TrieNode();
int count = 0;
	
while(q--) {
	int x;
	cin >> x;
	if(x==0) {
		int y;
		cin >> y;
		count++;
		insert(y,head,count);
	}
	else {
		int l,r,y;
		cin >> l >> r >>y;
		cout <<findMaxXorPair(head,y, l-1,r-1) <<endl;
	}
}

}

signed main() {
boost;
solve();
}

@code_dynamo Provide code in Coding IDE

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.