Xor Profit problem

Only one test case is accepted… acn u help me with this
code:

#include<bits/stdc++.h>
using namespace std;

int ClearIthBit(int n, int pos)
{
return (n & (~(1 << pos)) );
}

int setBit(int x,int pos){
int mask = 1<<pos;
return x|mask;
}

int getIBit(int n,int i){
n = n>>i;
return n&1;
}

int main(){
int x,y,j=0,temp1=0;
cin>>x>>y;
int i=0;

if(x>y)
{
    int swap = x;
    y=x;
    y=swap;
}

int temp=y;
while(temp>0){
    int x_lstbit = getIBit(x,i);
    int y_lstbit = getIBit(y,i);

    if( !(x_lstbit ^ y_lstbit) ){
        if(x_lstbit==0)
            x = setBit(x,i);
        else
            y = ClearIthBit(y,i);
    }
    i++;
    temp = temp>>1;
}

y = setBit(y,i-1);
cout<<(x^y);
return 0;

}

You might have left some cases.
Have a look at the constraints for the problem.
We can solve the problem in O(n^2) by making all pairs and getting maximum answer.

You can solve it in this way as well, which is very efficient to do.
Please have a look. You will understand it just by looking.

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.