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

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long int ll;
typedef unsigned long long ull;
const ll INF = (1ll << 61);
const ll inf = 1e9;
const ll MOD=1e9 + 7;
const ll M=998244353;
 
 
 
ll gcd(ll a, ll b) {
    return b ? gcd (b, a % b) : a;
}
 
ll lcm(ll a,ll b){
  return ((a*b)/gcd(a,b));
}

ll fact[2000001];

void factfun(){
  fact[0] = fact[1] = 1;
  for(ll i=2;i<=2000000;i++){
    fact[i] = (fact[i-1]%MOD * i%MOD)%MOD;
  }
}

ll expo(ll a,ll n){
   ll ans = 1;
   while(n > 0){
    if(n & 1ll){
      ans = ans * a % MOD;
    }
    a = a * a % MOD;
    n >>= 1;
   }
   return ans;
}

ll fermatNCr(ll a,ll b){
   return ((fact[a]%MOD * expo(fact[b],MOD - 2)%MOD * expo(fact[a - b],MOD - 2)%MOD)%MOD);
}



void solve(){
   ll l,r;
   cin>>l>>r;
   if(r == l + 2){
    cout<<l<<" "<<l + 1<<" "<<l + 2<<endl;
    return;
   }

   ll a = 0,b = 0,c = 0;
   ll flg = 0,fset = 0;
   for(ll i=30;i>=0;i--){
     if(flg == 0){
      ll b1 = ((l >> i) & 1ll);
      ll b2 = ((r >> i) & 1ll);
       if(b1 == b2){
        a += (b1 << i);
        b += (b1 << i);
        c += (b1 << i);
       }
       else{
        flg = 1;
        a += (b1 << i);
        b += (b1 << i);
        c += (b2 << i);
       }
     }
     else{
       ll b1 = ((l >> i) & 1ll);
       ll b2 = ((r >> i) & 1ll);
       if(b1 == 1 && fset == 0){
          fset = 1;
          a += (1 << i);
          b += (1 << i);
          c += (0 << i);
       }
       else{
         a += (b1 << i);
         b += (1 << i);
         c += (0 << i);
       }
     }
   }

   cout<<a<<" "<<b<<" "<<c<<endl;
}
 
 
 
 
 
int main(){
 
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif*/
    

      ll testcase;
      //testcase = 1;
      cin>>testcase;
     
      while(testcase--){       
        solve();
      }
 
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long int ll;
typedef unsigned long long ull;
const ll INF = (1ll << 61);
const ll inf = 1e9;
const ll MOD=1e9 + 7;
const ll M=998244353;
 
 
 
ll gcd(ll a, ll b) {
    return b ? gcd (b, a % b) : a;
}
 
ll lcm(ll a,ll b){
  return ((a*b)/gcd(a,b));
}

ll fact[2000001];

void factfun(){
  fact[0] = fact[1] = 1;
  for(ll i=2;i<=2000000;i++){
    fact[i] = (fact[i-1]%MOD * i%MOD)%MOD;
  }
}

ll expo(ll a,ll n){
   ll ans = 1;
   while(n > 0){
    if(n & 1ll){
      ans = ans * a % MOD;
    }
    a = a * a % MOD;
    n >>= 1;
   }
   return ans;
}

ll fermatNCr(ll a,ll b){
   return ((fact[a]%MOD * expo(fact[b],MOD - 2)%MOD * expo(fact[a - b],MOD - 2)%MOD)%MOD);
}



void solve(){
   ll l,r;
   cin>>l>>r;
   /*if(r == l + 2){
    cout<<l<<" "<<l + 1<<" "<<l + 2<<endl;
    return;
   }*/

   ll a = 0,b = 0,c = 0;
   ll flg = 0,fset = 0;
   for(ll i=30;i>=0;i--){
     if(flg == 0){
      ll b1 = ((l >> i) & 1ll);
      ll b2 = ((r >> i) & 1ll);
       if(b1 == b2){
        a += (b1 << i);
        b += (b1 << i);
        c += (b1 << i);
       }
       else{
        flg = 1;
        a += (b1 << i);
        b += (b1 << i);
        c += (b2 << i);
       }
     }
     else{
       ll b1 = ((l >> i) & 1ll);
       ll b2 = ((r >> i) & 1ll);
       if(b1 == 1 && fset == 0){
          fset = 1;
          a += (1 << i);
          b += (1 << i);
          c += (0 << i);
       }
       else{
         a += (b1 << i);
         b += (1 << i);
         c += (0 << i);
       }
     }
   }
   
   if(a == b){
    b = a + 1;
    c = r;
   }
   
   cout<<a<<" "<<b<<" "<<c<<endl;
}
 
 
 
 
 
int main(){
 
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif*/
    

      ll testcase;
      //testcase = 1;
      cin>>testcase;
     
      while(testcase--){       
        solve();
      }
 
}