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 pb push_back

typedef long long ll;

ll arr[30];

void solve(){
    ll a,b,c,l,r;
    cin>>l>>r;
    
    if(r-l==2){
    cout<<l<<" "<<l+1<<" "<<r<<endl;
    }
    
    else{
    ll sum=0;
    
    ll lo,hi;
    lo=log2(l+1);
    hi=log2(r);
    
    if(pow(2,hi)==r){
     a=r-2;
     b=r;
     c=r-1;
    }
    
    else if(hi-lo>0){
        a=pow(2,hi)-1;
        b=pow(2,hi);
        c=pow(2,hi)+1;
    }
    
    else{
        for(int i=29;i>=0;i--){
            if(arr[i]<=l){
                // cout<<i<<endl;
                sum+=arr[i];
                l-=arr[i];
                r-=arr[i];
                
                lo=log2(l+1);
                hi=log2(r);
                
                // cout<<l<<" "<<r<<" "<<lo<<" "<<hi<<endl;
                
                if(pow(2,hi)==r){
                    a=r-2+sum;
                    b=r;
                    c=r-1+sum;
                    break;
                }
                
                if(hi-lo>0){
                    a=sum+pow(2,hi)-1;
                    b=sum+pow(2,hi);
                    c=sum+pow(2,hi)+1;
                    break;
                }
            }
        }
    }
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    }
}

int main() {
    arr[0]=1;
    for(int i=1;i<30;i++)
    arr[i]=arr[i-1]*2;
    
    // for(int i=29;i>=0;i--)
    // cout<<arr[i]<<" ";
    // cout<<endl;
    
    ll t;
    cin>>t;
    while(t--)
    solve();
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

typedef long long ll;

ll arr[30];

void solve(){
    ll a,b,c,l,r;
    cin>>l>>r;
    
    if(r-l==2){
    cout<<l<<" "<<l+1<<" "<<r<<endl;
    }
    
    else{
    ll sum=0;
    
    ll lo,hi;
    if(l>0)
    lo=log2(l);
    else
    lo=0;
    hi=log2(r);
    
    // cout<<lo<<" "<<hi<<endl;
    
    if(pow(2,hi)==r){
     a=r-2;
     b=r;
     c=r-1;
    }
    
    else if(hi-lo>0){
        a=pow(2,hi)-1;
        b=pow(2,hi);
        c=pow(2,hi)+1;
    }
    
    else{
        for(int i=29;i>=0;i--){
            if(arr[i]<=l){
                // cout<<i<<endl;
                sum+=arr[i];
                l-=arr[i];
                r-=arr[i];
                
                if(l>0)
                lo=log2(l);
                else
                lo=0;
                hi=log2(r);
                
                // cout<<l<<" "<<r<<" "<<lo<<" "<<hi<<endl;
                
                if(pow(2,hi)==r){
                    a=r-2+sum;
                    b=r;
                    c=r-1+sum;
                    break;
                }
                
                if(hi-lo>0){
                    a=sum+pow(2,hi)-1;
                    b=sum+pow(2,hi);
                    c=sum+pow(2,hi)+1;
                    break;
                }
            }
        }
    }
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    }
}

int main() {
    arr[0]=1;
    for(int i=1;i<30;i++)
    arr[i]=arr[i-1]*2;
    
    // for(int i=29;i>=0;i--)
    // cout<<arr[i]<<" ";
    // cout<<endl;
    
    ll t;
    cin>>t;
    while(t--)
    solve();
}