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

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
#define vi vector<int>
#define inp for(int i=0;i<n;i++) cin>>arr[i]
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vpii vector<pii >
#define mp make_pair
#define f first
#define s second

const int MOD = 1e9 + 7;
const int INF = 1e9;

// Function to print a vector
template <typename T>
void printVector(const vector<T>& v) {
    for (const auto& element : v) {
        cout << element << ' ';
    }
    cout << endl;
}

// Function to print a set
template <typename T>
void printSet(const set<T>& s) {
    for (const auto& element : s) {
        cout << element << ' ';
    }
    cout << endl;
}

// Function to print a map
template <typename K, typename V>
void printMap(const map<K, V>& m) {
    for (const auto& [key, value] : m) {
        cout << key << " -> " << value << endl;
    }
}
void func(int a,int b,int c){
    cout<<(a^b)+(b^c)+(c^a)<<endl;
}
void solve() {
    // Write your code here
    int l,r;
    cin>>l>>r;
    int msd = log2(r);
    vector<int> a1,a2;
    for(int i=msd ;i>=0;i--){
        if(l & (1LL << i)){
            a1.pb(1);
        }
        else a1.pb(0);
        if(r & (1LL << i)){
            a2.pb(1);
        }
        else a2.pb(0);
    }
    int num = 0;
    reverse(all(a1));
    reverse(all(a2));
    bool flag = true,flag2 = true;
    for(int i=msd;i>=0;i--){
        if(a1[i] == a2[i] && flag){
            num += (1LL << i)*a1[i];
        }
        else{
            if(flag){
                // num += (1LL << i);
                flag = false;
            }
            else{
                // if(a1[i] == 0 && flag2){
                //     num += (1LL << i);
                //     flag2 = false;
                //     continue;
                // }
                if(flag2){
                    num += (1LL << i);
                    if(a1[i] == 0) flag2 = false;
                }
                else{
                    if(a1[i] != a2[i] || a1[i] == 0 && a2[i] == 0) 
                    num += (1LL << i);
                }
               
            }
        }
        // if(i == msd && a1[i] == a2[i] && a1[i] == 1){
        //     num = l;
        //     break;
        // }
        // else if(a1[i] == a2[i] && a1[i] == 0) num += (1LL << i);
        // else if(a1[i] != a2[i]) num += (1LL << i);
        // cout<<i<<" - "<<num<<" ";
    }
    // cout<<endl;
    // printVector(a1);
    // printVector(a2);
    // cout<<msd<<"->";
    cout<<l<<" "<<r<<" "<<num<<endl;
    // func(0,8,7);
    // func(8,7,1);
}

signed main() {
    fastio;
    int t = 1;
    cin >> t; // Uncomment if multiple test cases
    while (t--) {
        solve();
    }
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
#define vi vector<int>
#define inp for(int i=0;i<n;i++) cin>>arr[i]
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vpii vector<pii >
#define mp make_pair
#define f first
#define s second

const int MOD = 1e9 + 7;
const int INF = 1e9;

// Function to print a vector
template <typename T>
void printVector(const vector<T>& v) {
    for (const auto& element : v) {
        cout << element << ' ';
    }
    cout << endl;
}

// Function to print a set
template <typename T>
void printSet(const set<T>& s) {
    for (const auto& element : s) {
        cout << element << ' ';
    }
    cout << endl;
}

// Function to print a map
template <typename K, typename V>
void printMap(const map<K, V>& m) {
    for (const auto& [key, value] : m) {
        cout << key << " -> " << value << endl;
    }
}
void func(int a,int b,int c){
    cout<<(a^b)+(b^c)+(c^a)<<endl;
}
void solve() {
    // Write your code here
    int l,r;
    cin>>l>>r;
    int msd = log2(r);
    vector<int> a1,a2;
    for(int i=msd ;i>=0;i--){
        if(l & (1LL << i)){
            a1.pb(1);
        }
        else a1.pb(0);
        if(r & (1LL << i)){
            a2.pb(1);
        }
        else a2.pb(0);
    }
    int num = 0;
    reverse(all(a1));
    reverse(all(a2));
    int a = 0,b = 0,c = 0;
    bool flag = true;
    for(int i=msd;i>=0;i--){
        if(a1[i] == a2[i] && flag){
            a += a1[i]*(1LL << i);
            b += a1[i]*(1LL << i);
            c += a1[i]*(1LL << i);
        }
        else{
            if(flag){
                a += (1LL<<i);
                flag = false;
            }
            else b += (1LL << i);
        }
    }
    cout<<a<<" "<<b<<" "<<a+1<<endl;
}
signed main() {
    fastio;
    int t = 1;
    cin >> t; // Uncomment if multiple test cases
    while (t--) {
        solve();
    }
    return 0;
}