Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

void solve(){
    int l; int r;
    cin >> l;
    cin >> r;
    int len = floor(log2(r)) + 1;
    string a;
    if (r > 0){
        a = bitset<32>(r).to_string().substr(32-len, len);
    }
    else{
        a = "0";
    }
    
    string c = bitset<32>(l).to_string().substr(32-len, len);
    //string c = "00";
    string b = "";
    int bval = 0;
    for (int i = 0; i < len; i++){
        if ((bval + (pow(2, (len-i-1)))-1)<l){
            b+="1";
            bval += pow(2, (len-i-1));
            continue;
        }
        /*
        else if ((bval + (pow(2, (len-i-1)))-1)==l){
            b += "0";
            for (int j = i+1; j < len; j++){
                b+="1";
                bval += pow(2, (len-j-1));
            }
            break;
        }
        */
        else{
            if (c[i] == '1' && a[i] == '1'){
                b+="0";
                continue;
            }
            else if ((c[i] == '0' && a[i] == '0')&&(bval + pow(2, (len-i-1))<r)){
                b+="1";
                bval += pow(2, (len-i-1));
                continue;
            }
            else {
                if ((c[i] == '0' && a[i] == '1')&&(bval + pow(2, (len-i-1))<r)){
                    b+="1";
                    bval += pow(2, (len-i-1));
                    continue;
                }
                b+="0";
                continue;
            }
        }
    }
    cout << l << " " << bval << " " << r << endl;
}

int main(){
    int t;
    cin >> t;
    for (int i = 0; i < t; i++){
        solve();
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
/*
void solve(){
    int l; int r;
    cin >> l;
    cin >> r;
    int len = floor(log2(r)) + 1;
    string a;
    if (r > 0){
        a = bitset<32>(r).to_string().substr(32-len, len);
    }
    else{
        a = "0";
    }
    
    string c = bitset<32>(l).to_string().substr(32-len, len);
    //string c = "00";
    string b = "";
    int bval = 0;
    for (int i = 0; i < len; i++){
        if ((bval + (pow(2, (len-i-1)))-1)<l){
            b+="1";
            bval += pow(2, (len-i-1));
            continue;
        }
        /*
        else if ((bval + (pow(2, (len-i-1)))-1)==l){
            b += "0";
            for (int j = i+1; j < len; j++){
                b+="1";
                bval += pow(2, (len-j-1));
            }
            break;
        }
        else{
            if (c[i] == '1' && a[i] == '1'){
                b+="0";
                continue;
            }
            else if ((c[i] == '0' && a[i] == '0')&&(bval + pow(2, (len-i-1))<r)){
                b+="1";
                bval += pow(2, (len-i-1));
                continue;
            }
            else {
                
                if ((c[i] == '0' && a[i] == '1')&&(bval + pow(2, (len-i-1))<r)){
                    b+="1";
                    bval += pow(2, (len-i-1));
                    continue;
                }
                    
                b+="0";
                continue;
            }
        }
    }
    if (bval == l){
        for (int i = len-1; i > 0; i--){
            if ((a[i]=='1' && c[i]=='0')&&(bval + pow(2, i)<r)){
                bval += pow(2, i);
                break;
            }
        }
    }
    if (bval == 1){
        for (int i = len-1; i > 0; i--){
            if ((a[i]=='1' && c[i]=='0')&&(bval + pow(2, i)<r)){
                bval += pow(2, i);
                break;
            }
        }
    }
    cout << l << " " << bval << " " << r << endl;
}
*/
void solve() {
    int l, r;
    std::cin >> l >> r;
    int k = 31 - __builtin_clz(l ^ r);
    int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
    std::cout << a << " " << b << " " << c << "\n";
}

int main(){
    int t;
    cin >> t;
    for (int i = 0; i < t; i++){
        solve();
    }
}