Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=200001;

int main(){
    ll T;
    cin>>T;
    while(T--){
        ll l,r;
        cin>>l>>r;
        ll left=l;
        ll right=r;
        ll count1=0;
        ll x=0,y=0;
        ll count2=0,count3=0;
        ll a=0,b=0,c=0;
        while(left>0){
            if(left%2==1) count2++;
            else count2=0;
            left=left/2;
            x++;
        }
        while(right>0){
            if(right%2==1) count3++;
            else count3=0;
            right=right/2;
            y++;
        }
        ll zz=0;
        ll mm=1;
        for(ll i=0;i<y;i++){
            if((l&mm)>0 && (r&mm)>0) zz+=mm;
            else if((l&mm)==0 && (r&mm)==0);
            else zz=0;
            mm=mm*2;
        }
        if(y>x){
            a=1<<(y-1);
            b=1<<(y-1);
            ll pp=1;
            c=0;
            for(ll i=0;i<(y-1);i++){
                c+=pp;
                pp=pp*2;
            }
            ll over=r-a;
            if(over>0) a=r;
            else{
                while(b==a || b==c) b=b-1;
            }
        }
        else{
            ll gg=min(count2,count3);
            ll hh=1<<(x-1);
            ll ans=0;
            while(gg--){
                ans+=hh;
                hh=hh/2;
                x--;
            }
            l=l-zz;
            r=r-zz;
            x=0,y=0;
            left=l,right=r;
        while(left>0){
            left=left/2;
            x++;
        }
        while(right>0){
            right=right/2;
            y++;
        }
            a=1<<(y-1);
            b=1<<(y-1);
            ll pp=1;
            c=0;
            for(ll i=0;i<(y-1);i++){
                c+=pp;
                pp=pp*2;
            }
            // cout<<a<<" "<<b<<" "<<c<<endl;
            ll over=r-a;
            if(over>0) a=r;
            else{
                while(b==a || b==c) b=b-1;
            }
            a+=zz;
            b+=zz;
            c+=zz;
        }
        
        cout<<a<<" "<<b<<" "<<c<<endl;
    }
    return 0;
}

Solution 2 (runtime: 93 ms):
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long l,r;
        cin >> l >> r;
        long long l1 = l;
        if(r-l == 2){
          cout << r << " " << r-1 << " " << r-2 << endl;
          continue;
        }
        vector<long long> y;
        long long n = 0;
        while(r>0){
            y.push_back(r%2);
            r /= 2;
            n += 1;
        }
        reverse(y.begin(), y.end());
        long long t = n-1;
        vector<long long> x(n,0);
        while(l>0){
            x[t] = (l%2);
            l /= 2;
            t -= 1;
        }
        long long a = 0;
        t = n-1;
        for(long long i = 0; i<n; i++){
            if(x[i] == y[i]){
                a += pow(2, t)*x[i];
                t--;
            }
            else{
              a += pow(2,t);
              break;
            }
        }
        if(a-2 < l1){
          cout << a << " " << a-1 << " " << a+1 << endl;
          continue;
        }
        cout << a << " " << a-1 << " " << a-2 << endl;
    }
}