Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 92 ms):
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

typedef long long LL;

void solve() {
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for (int i = 29; ~i; i--) {
        if ((l ^ r) >> i & 1) {
            a |= 1 << i;
            b |= (1 << i) - 1;
            break;
        } else {
            a |= l & (1 << i);
            b |= l & (1 << i);
        }
    }

    c = l;
    while (c == b || c == a) c++;
    cout << a << " " << b << " " << c << '\n'; 
}

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


Solution 2 (runtime: 93 ms):
#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;
}