Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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


void solution() {
    int l, r;
    cin >> l >> r;
    int x = (l ^ r);
    int ind = 0;
    while(pow(2, ind) <= x)ind++; // 16 8 4 2 0
    // cout << ind << endl;
    --ind;
    int y = pow(2, ind);
    int a = (l | (y - 1) );
    int b = a + 1;
    int c = l;
    if(a == l)c = r;
    cout << a << " " << b << " " << c << endl;

    
}


int main() {

    int t;
    cin >> t;
    while(t--) {
        solution();
    }
}

Submission (verdict: Accepted):
#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(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(134, 132, 137);
    // func(128, 137, 135);
}

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