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 ll = long long;
using namespace std;
 
ll t;
 
void printArr(vector<int> &a){
    for(int i=0; i<a.size(); i++){
        cout<<a[i]<<" ";
    }
    cout<<'\n';
}


void solve(){

    int l, r;
    cin>>l>>r;

    bool flag = false;

    int a=0, b=0, c=0;

    vector<int> av, bv, cv;
    if(r-l+1 == 3){
        cout<<l<<" "<<l+1<<" "<<r<<"\n";
        return;
    }

    int bits = (r > 0) ? (int)(log2(r)) : -1;
    // cout<<bits<<endl;

    while(bits >= 0 && l!=0) {

        int lbit = ((1 << bits) & l) && 1;
        int rbit = ((1 << bits) & r) && 1;

        if(!(rbit ^ lbit)){
            if(rbit==1){
                a |= (1 << bits);
                b |= (1 << bits);
                c |= (1 << bits);
            }
        }else{
            break;
        }
        bits--;
    }

    // cout<<bits<<'\n';
    // cout<<a<<endl;
    a |= (1 << bits);
    bits--;

    while(bits >= 0 && ((( 1 << bits ) & l) == 0)){
        b |= (1 << bits);
        bits--;
    }

    while(bits >= 0){
        c |= (1 << bits);
        bits--;
    }

    if(b == 0){
        if(r == a){
            b = l;
        }else{
            b = r;
        }
    }


    cout<< a <<" "<< b << " "<< c <<endl;

    // R  1 0 1 1 1 0 0 => 
    // L  1 0 1 0 0 1 1

    // 1 0 1 1 0
    // 0 0 1 1 0

    // 1 0
    // 0 0

    // 0 1 1 1 1 1 1 1
    // 0 1 1 1 0 0 1 1

    // 0 1 1 1 1 0 0 0
    // 0 1 1 1 0 1 0 0
    // 0 1 1 1 0 0 1 1

    // 0 1 0 0 1 0 0 1
    // 0 1 0 0 0 0 0 0

    // 1 0 0
    // 0 1 1

    // 1 0 1
    // 0 1 0

    // 


}
 
int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    cin>>t;
    while(t--){
        solve();
    }
 
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
 
ll t;
 
void printArr(vector<int> &a){
    for(int i=0; i<a.size(); i++){
        cout<<a[i]<<" ";
    }
    cout<<'\n';
}


void solve(){

    int l, r;
    cin>>l>>r;

    bool flag = false;

    int a=0, b=0, c=0;

    vector<int> av, bv, cv;
    if(r-l+1 == 3){
        cout<<l<<" "<<l+1<<" "<<r<<"\n";
        return;
    }

    int bits = (r > 0) ? (int)(log2(r)) : -1;

    int currB  = 0;
    // cout<<bits<<endl;

    while(bits >= 0 && l!=0) {

        int lbit = ((1 << bits) & l) && 1;
        int rbit = ((1 << bits) & r) && 1;

        if(!(rbit ^ lbit)){
            if(rbit==1){
                a |= (1 << bits);
                b |= (1 << bits);
                c |= (1 << bits);
            }
        }else{
            currB = b;
            break;
        }
        bits--;
    }

    // cout<<bits<<'\n';
    // cout<<a<<endl;
    a |= (1 << bits);
    bits--;

    while(bits >= 0 && ((( 1 << bits ) & l) == 0)){
        b |= (1 << bits);
        bits--;
    }

    while(bits >= 0){
        c |= (1 << bits);
        bits--;
    }

    if(b == currB){
        if(r == a){
            b = l;
        }else{
            b = r;
        }
    }


    cout<< a <<" "<< b << " "<< c <<endl;

    // R  1 0 1 1 1 0 0 => 
    // L  1 0 1 0 0 1 1

    // 1 0 1 1 0
    // 0 0 1 1 0

    // 1 0
    // 0 0

    // 0 1 1 1 1 1 1 1
    // 0 1 1 1 0 0 1 1

    // 0 1 1 1 1 0 0 0
    // 0 1 1 1 0 1 0 0
    // 0 1 1 1 0 0 1 1

    // 0 1 0 0 1 0 0 1
    // 0 1 0 0 0 0 0 0

    // 1 0 0
    // 0 1 1

    // 1 0 1
    // 0 1 0

    // 1 1 0 1
    // 1 0 1 0




}
 
int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    cin>>t;
    while(t--){
        solve();
    }
 
    return 0;
}