Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5, MOD=1e9+7;
void precompute() {
}
string s;

void turn_to_binary(long long x, vector <long long> &v){
    while (x>0){
        v.push_back(x%2);
        x/=2;
    }
    while (v.size()<30){
        v.push_back(0);
    }
    reverse(v.begin(), v.end());
}

void turn_to_decimal(vector <long long> &v, long long &x){
    x=0;
    for (int i=0;i<v.size();i++){
        x=x*2+v[i];
    }
}

long long l, r;
void solve() {
    cin>>l>>r;
    vector <long long> lb, rb, midb;
    turn_to_binary(l, lb);
    turn_to_binary(r, rb);
    int i=0;
    while (lb[i]==rb[i]){
        midb.push_back(lb[i]);
        i++;
    } 
    if (lb[i+1]==0 and rb[i+1]==1){
        midb.push_back(0);
        midb.push_back(1);
        i+=2;
    } else if (lb[i+1]==rb[i+1]) {
        if (lb[i+1]==0){
            midb.push_back(0);
            midb.push_back(1);
            i+=2;
        }
        else {
            midb.push_back(1);
            midb.push_back(0);
            i+=2;
        }
    } else {
        int j = i+1;
        while (j<30 && lb[j]==0 && rb[j]==0){
            j++;
        } 
        if (rb[j]==0) {
            midb.push_back(0);
            i++;
            while (i<j){
                midb.push_back(1);
                i++;
            }
        } else {
            midb.push_back(1);
            i++;
            while (i<j){
                midb.push_back(0);
                i++;
            }
        }
    }
    while (i<30){
        midb.push_back(1-lb[i]);
        i++;
    }
    long long a, b, c;
    turn_to_decimal(lb, a);
    turn_to_decimal(rb, b);
    turn_to_decimal(midb, c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}

int main() {
    int t;
    precompute();
    cin>>t;
    while (t--){
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5, MOD=1e9+7;
void precompute() {
}
string s;

void turn_to_binary(long long x, vector <long long> &v){
    while (x>0){
        v.push_back(x%2);
        x/=2;
    }
    while (v.size()<30){
        v.push_back(0);
    }
    reverse(v.begin(), v.end());
}

void turn_to_decimal(vector <long long> &v, long long &x){
    x=0;
    for (int i=0;i<v.size();i++){
        x=x*2+v[i];
    }
}

long long l, r;
void solve() {
    cin>>l>>r;
    vector <long long> lb, rb, midb;
    turn_to_binary(l, lb);
    turn_to_binary(r, rb);
    int i=0;
    while (lb[i]==rb[i]){
        midb.push_back(lb[i]);
        i++;
    } 
    if (lb[i+1]==0 && rb[i+1]==1){
        midb.push_back(0);
        midb.push_back(1);
        i+=2;
    } else if (lb[i+1]==rb[i+1]) {
        if (lb[i+1]==0){
            midb.push_back(0);
            midb.push_back(1);
            i+=2;
        }
        else {
            midb.push_back(1);
            midb.push_back(0);
            i+=2;
        }
    } else {
        //cout<<"here"<<endl;
        int j = i+1;
        while (j<30 && lb[j]==1 && rb[j]==0){
            j++;
        } 
        if (rb[j]==0) {
            midb.push_back(0);
            i++;
            while (i<j){
                midb.push_back(1);
                i++;
            }
        } else {
            midb.push_back(1);
            i++;
            while (i<j){
                midb.push_back(0);
                i++;
            }
        }
    }
    //while (i<30){
    //    midb.push_back(1-lb[i]);
    //    i++;
    //}
    //for (int i=0; i<30; i++){
    //    cout<<lb[i];
    //}
    //cout<<endl;
    //for (int i=0; i<30; i++){
    //    cout<<midb[i];
    //}
    //cout<<endl;
    //for (int i=0; i<30; i++){
    //    cout<<rb[i];
    //}
    //cout<<endl;


    long long c;
    turn_to_decimal(midb, c);
    cout<<l<<" "<<r<<" "<<c<<endl;
}

int main() {
    int t;
    precompute();
    cin>>t;
    while (t--){
        solve();
    }
    return 0;
}