Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#define mod 1000000007
#define ull unsigned long long
#define ll long long
#define cy cout<<''YES''<<endl
#define cn cout<<''NO''<<endl
#define hai cout<<-1<<endl
#define pb push_back
#define ff first
#define ss second
bool isprime(ll n){if (n <= 1)  return 0; if (n <= 3)  return 1; if (n%2 == 0 || n%3 == 0) return 0; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return 0; return 1;}
#include<bits/stdc++.h>
using namespace std;
void fun(vector<ll>& num1,vector<ll>& num2){
  while(num1.size()!=num2.size()){
    num2.pb(0);
  }
}
void solve()
{
  ll l,r;
  cin>>l>>r;
  vector<ll> num1,num2;
  ll x=l;
  ll x1=r;
  while(x){
    num1.pb(x&1);
    x=x>>1;
  }
  while(x1){
    num2.pb(x1&1);
    x1=x1>>1;
  }
  // reverse(num1.begin(),num1.end());
  // reverse(num2.begin(),num2.end());
  // for(auto it : num1){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  // for(auto it : num2){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  if(num1.size()>num2.size()){
    fun(num1,num2);
  }else{
    fun(num2,num1);
  }
  reverse(num1.begin(),num1.end());
  reverse(num2.begin(),num2.end());
  // for(auto it : num1){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  // for(auto it : num2){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  ll idx=0;
  for(ll i=0;i<num1.size();i++){
    if(num1[i]!=num2[i]){
      idx=i;
      break;
    }
  }
  vector<ll> num3(num1.size(),0);
  bool ff=false;
  if(num1[idx+1]==0 && num2[idx]==1){
    ff=true;
    num3[idx]=1;
    num3[idx+1]=0;
  }else if(num1[idx+1]==1 && num2[idx+1]==1){
    ff=true;
    num3[idx]=1;
    num3[idx+1]=0;
  }else if(num1[idx+1]==0 && num2[idx+1]==0){
    ff=true;
    num3[idx]=0;
    num3[idx+1]=1;
  }
  if(ff){
    for(ll i=idx+2;i<num1.size();i++){
      ll ww=num1[i] | num2[i];
      if(ww){
        num3[i]=0;
      }else{
        num3[i]=1;
      }
    }
  }else{
    ll ww=idx+1;
    while(ww<num3.size() && (num1[ww]==1 && num2[ww]==0)){
      ww++;
    }
    if(num1[ww]==0 && num2[ww]==0){
      num3[idx]=0;
      for(ll i=idx+1;i<ww;i++){
        num3[i]=1;
      }
      num3[ww]=1;
    }else if((num1[ww]==0 && num2[ww]==1) || (num1[ww]==1 && num2[ww]==1)){
      num3[idx]=1;
      for(ll i=idx+1;i<=ww;i++){
        num3[i]=0;
      }
    }
    for(ll i=ww+1;i<num1.size();i++){
      ll ww=num1[i] | num2[i];
      if(ww){
        num3[i]=0;
      }else{
        num3[i]=1;
      }
    }
  }
  // for(auto it : num1){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  // for(auto it : num2){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  // for(auto it :  num3){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  ll ww=1;
  ll value=0;
  for(ll i=num3.size()-1;i>=0;i--){
    value+=ww*num3[i];
    ww=2*ww;
  }
  cout<<l<<" "<<value<<" "<<r<<endl;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
cin>>t;
while(t--){
solve();
}
  return 0;
}

Submission (verdict: Wrong answer on test 1):
#define mod 1000000007
#define ull unsigned long long
#define ll long long
#define cy cout<<''YES''<<endl
#define cn cout<<''NO''<<endl
#define hai cout<<-1<<endl
#define pb push_back
#define ff first
#define ss second
bool isprime(ll n){if (n <= 1)  return 0; if (n <= 3)  return 1; if (n%2 == 0 || n%3 == 0) return 0; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return 0; return 1;}
#include<bits/stdc++.h>
using namespace std;
void fun(vector<ll>& num1,vector<ll>& num2){
  while(num1.size()!=num2.size()){
    num2.pb(0);
  }
}
void solve()
{
  ll l,r;
  cin>>l>>r;
  vector<ll> num1,num2;
  ll x=l;
  ll x1=r;
  while(x){
    num1.pb(x&1);
    x=x>>1;
  }
  while(x1){
    num2.pb(x1&1);
    x1=x1>>1;
  }
  // reverse(num1.begin(),num1.end());
  // reverse(num2.begin(),num2.end());
  // for(auto it : num1){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  // for(auto it : num2){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  if(num1.size()>num2.size()){
    fun(num1,num2);
  }else{
    fun(num2,num1);
  }
  reverse(num1.begin(),num1.end());
  reverse(num2.begin(),num2.end());
  // for(auto it : num1){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  // for(auto it : num2){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  ll idx=0;
  for(ll i=0;i<num1.size();i++){
    if(num1[i]!=num2[i]){
      idx=i;
      break;
    }
  }
  // cout<<idx<<endl;
  vector<ll> num3(num1.size(),0);
  bool ff=false;
  if(num1[idx+1]==0 && num2[idx+1]==1){
    ff=true;
    num3[idx]=1;
    num3[idx+1]=0;
  }else if(num1[idx+1]==1 && num2[idx+1]==1){
    ff=true;
    num3[idx]=1;
    num3[idx+1]=0;
  }else if(num1[idx+1]==0 && num2[idx+1]==0){
    ff=true;
    num3[idx]=0;
    num3[idx+1]=1;
  }
  if(ff){
    for(ll i=idx+2;i<num1.size();i++){
      ll ww=num1[i] | num2[i];
      if(ww){
        num3[i]=0;
      }else{
        num3[i]=1;
      }
    }
  }else{
    ll ww=idx+1;
    while(ww<num3.size() && (num1[ww]==1 && num2[ww]==0)){
      ww++;
    }
    if(num1[ww]==0 && num2[ww]==0){
      num3[idx]=0;
      for(ll i=idx+1;i<ww;i++){
        num3[i]=1;
      }
      num3[ww]=1;
    }else if((num1[ww]==0 && num2[ww]==1) || (num1[ww]==1 && num2[ww]==1)){
      num3[idx]=1;
      for(ll i=idx+1;i<=ww;i++){
        num3[i]=0;
      }
    }
    for(ll i=ww+1;i<num1.size();i++){
      ll ww=num1[i] | num2[i];
      if(ww){
        num3[i]=0;
      }else{
        num3[i]=1;
      }
    }
  }
  // for(auto it : num1){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  // for(auto it : num2){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  // for(auto it :  num3){
  //   cout<<it<<" ";
  // }
  // cout<<endl;
  ll ww=1;
  ll value=0;
  for(ll i=num3.size()-1;i>=0;i--){
    value+=ww*num3[i];
    ww=2*ww;
  }
  cout<<l<<" "<<value<<" "<<r<<endl;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
cin>>t;
while(t--){
solve();
}
  return 0;
}