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

Solution 1 (runtime: 77 ms):
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <utility>
#include <limits.h>
#include <climits>
#include <numeric>
#include <map>
#include <unordered_map>
#include <cfloat>
#define ll long long
#define int long long
#define DEBUG false
using namespace std;


void debug(string s) {
    if (DEBUG) cout << s << endl;
}

void debug(int s) {
    if (DEBUG) cout << s << endl;
}

void debug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

//flat debug of vector of vectors
void fdebug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j];
            if (j != v[i].size() - 1) {
                cout << " ";
            }
        }
        cout << "; ";
    }
    cout << endl;
}


void debug(vector<int> & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        cout << v[i] << " ";
    }
    cout << endl;
}


class Solution {
    int l, r;
public:
    void init() {
        cin >> l >> r;
    }

    ll solve() {
        init();
        int a = 0;
        int b = 0;
        int c = 0;

        for (int i = 30; i >= 0; --i) {
            int li = (l >> i) & 1;
            int ri = (r >> i) & 1;
            if (li != ri) {
                if (r > (1 << i)) {
                    a += (1 << i) + 1;
                    b += (1 << i);
                    c += (1 << i) - 1;
                } else {
                    a += (1 << i);
                    b += (1 << i) - 1;
                    c += (1 << i) - 2;
                }
                break;
            } else if (li == 1) {
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
                l -= (1 << i);
                r -= (1 << i);
            }
        }
        
        cout << a << " " << b << " " << c << endl;
        return 0;
    }

};


signed main()
{
    std::ios_base::sync_with_stdio (false);
    std::cin.tie(NULL);
    int n;
    cin >> n;
    Solution sol;
    for(int i = 1; i != n + 1; ++i) {
        //cout << fixed << setprecision(0) << sol.solve() << "\n";
        sol.solve();
    }

    return 0;
}


Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int total, l, r;
    cin>>total;
    for (int cap = 0; cap < total; ++cap) {
        cin>>l>>r;
        int diff = 0, inv = 0;
        for (int i = 30; i >= 0; --i) {
            //cout<<'-'<<i<<' '<<(r & (1<<i))<<' '<<(l & (1<<i))<<'\n';
            if ((r & (1<<i)) != (l & (1<<i))) {
                diff = i;
                break;
            }
        }  
        for (int j = diff - 1; j >= 0; --j) {
            //cout<<j<<' '<<(r & (1<<j))<<(l & (1<<j))<<'\n';
            if ((r & (1<<j)) >= (l & (1<<j))) {
                inv = j;
                break;
            }
        }
        // inv += 1;
        int bind = r & (1<<inv), ret;
        if (bind) {
            ret = r;
        } else {
            ret = l;
        }
        //cout<<diff<<'\n';
        int oink = ret % (1<<inv+1);
        //cout<<oink<<'\n';
        ret -= oink;
        ret += (1<<(inv+1)) - 1 - oink;
        if (ret < l) {
            ret += (1<<diff);
        }
        cout<<l<<' '<<ret<<' '<<r<<'\n';
    }
}