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

Solution 1 (runtime: 93 ms):

#include <bits/stdc++.h>
using namespace std;

#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define pb push_back
#define ppb pop_back
#define ff first
#define ss second
#define sz(x) ((int)(x).size())
#define pf pop_front
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define vin(v) for (int i = 0; i < v.size(); i++) cin >> v[i];
#define vout(v) for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
#define nl cout << '\n';
#define yes cout << "YES\n";
#define no cout << "NO\n";

const long long M = 1e9 + 7;
const int N = 1e5 + 10;

// For modular inverse, use pow(a, M - 2)
int pow(int a, int b) {int ans = 1;a = a % M;while (b) {if (b & 1) {ans = (ans * a) % M;}a = (a * a) % M;b >>= 1;   }return ans;}
int gcd(int a, int b) {if (a == 0) {return b;}return gcd(b % a, a);}

void solve() {
    int l, r;
    cin >> l >> r;

    int a = 0, b = 0;
    bool change = false;

    for (int i = 30; i >= 0; i--) {
        if (!change) {
            if ((l & (1LL << i)) != (r & (1LL << i))) {
                change = true;
                a += 1LL << i;
            } else {
                if (l & (1LL << i)) {
                    a += 1LL << i;
                    b += 1LL << i;
                }
            }
        } else {
            b += 1LL << i; 
        }
    }

    cout << a << " " << b << " ";

    for (int i = l; i <= r; i++) {
        if (i != a && i != b) {
            cout << i << endl;
            break;
        }
    }
}


signed main() {
    fastio();
    
    #ifndef ONLINE_JUDGE
        freopen("input1.txt", "r", stdin);
        freopen("output1.txt", "w", stdout);
    #endif
    
    int t=1;
    cin >> t;  
    while (t--) {
        solve();
    }
    return 0;
}



Solution 2 (runtime: 92 ms):
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
using namespace std;

// Type definitions
typedef long long ll;
typedef long long lli;
typedef long double lld;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<lli> vll;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;

// Constants
const lli mod = 1e9 + 7;
const lli MAXN = 1e6;
const double eps = 1e-10;
const lli LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};
const string ny[] = {"NO", "YES"};
const string nys[] = {"No", "Yes"};

// Macros
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rev(x) reverse(all(x))
#define srt(x) sort(all(x))
#define maxx (lli) fmax
#define minn (lli) fmin
#define pb push_back
#define F first
#define S second
#define pi acos(-1.0)
#define sq(x) ((x) * (x))
#define issq(x) (((lli)(sqrt((x)))) * ((lli)(sqrt((x)))) == (x))
#define lg(r, n) (int)((lli)log2(n) / (lli)log2(r))
#define setpre(n) fixed << setprecision(n)
#define UNIQUE(a) (a).erase(unique(all(a)), (a).end())
#define debug(x)              \
    cerr << #x << " = [ ";    \
    for (const auto &val : x) \
        cerr << val << " ";   \
    cerr << "]\n"; // woeks fine for now
#define take(p, n, T) \
    vector<T> p(n);   \
    for (auto &i : p) \
        cin >> i;
#define input(x)      \
    for (auto &i : x) \
    cin >> i
#define print(x)          \
    for (auto &i : x)     \
        cout <<(lli) i << " "; \
    cout <<(lli) "\n"

#define arrsum(arr) std::accumulate(arr.begin(), arr.end(), 0LL)
#define error(args...)                           \
    {                                            \
        string _s = #args;                       \
        replace(_s.begin(), _s.end(), ',', ' '); \
        stringstream _ss(_s);                    \
        istream_iterator<string> _it(_ss);       \
        err(_it, args);                          \
    }

void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
// Loop macros
#define loop(i, n) for (int i = 0; i < (n); ++i)
#define rloop(i, n) for (int i = (n) - 1; i >= 0; --i)
#define sloop(i, s, t) for (int i = s; i < t; ++i)

// Utility macros
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) <= (r))
#define pcnt __builtin_popcountll
#define snuke srand((unsigned)clock() + (unsigned)time(NULL))
#define show_var(x) cout <<(lli) #x << " = " << x << endl
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define bn(x) ((1 << (x)) - 1)
#define dup(x, y) (((x) + (y) - 1) / (y))
#define drnd(x, y) (((x) + (y) / 2) / (y))
#define newline puts("")
#define YES puts("YES")
#define NO puts("NO")
#define tc    \
    int t;    \
    cin >> t; \
    for (int ii = 1; ii <= t; ++ii)
#define tc0    \
    int t = 1; \
    for (int ii = 1; ii <= t; ++ii)
#define nl cout <<(lli) "\n";
#define gp " "
#define case(ii) cout <<(lli) "Case " << ii << ": "
#define freopen                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
// Graph input macro
#define readgraph(arr, edges)         \
    for (int i = 0; i < (edges); i++) \
    {                                 \
        int a, b;                     \
        cin >> a >> b;                \
        arr[a].pb(b);                 \
        arr[b].pb(a);                 \
    }
#define by(x) [](const auto &a, const auto &b) { return a.x < b.x; }
#define tolower_str(s) transform(all(s), s.begin(), ::tolower)
#define toupper_str(s) transform(all(s), s.begin(), ::toupper)
#define cng_str(s) transform(all(s), s.begin(), [](char c) { return c ^ ' '; })
#define clr(arr, val) memset(arr, val, sizeof(arr))

// Utility functions
inline lli gcd(lli a, lli b) { return b == 0 ? a : gcd(b, a % b); }
#define lcm(a, b) ((a) * (b)) / gcd(a, b)

inline lli madd(lli a, lli b, lli m = mod) { return (a + b) % m; }
inline lli msub(lli a, lli b, lli m = mod) { return (a - b + m) % m; }
inline lli mmul(lli a, lli b, lli m = mod) { return (a * b) % m; }
inline lli mpow(lli base, lli exp, lli m = mod)
{
    lli res = 1;
    while (exp > 0)
    {
        if (exp & 1)
            res = mmul(res, base, m);
        base = mmul(base, base, m);
        exp >>= 1;
    }
    return res;
}
inline lli minv(lli a, lli m = mod) { return mpow(a, m - 2, m); }

// *****************************************************
// ------------------- CODE STARTS HERE ----------------
// *****************************************************

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    tc
    {
        lli l, r;
        cin >> l >> r;
        lli x = (l ? (lli)log2(l) : 0);
        lli y = (lli)log2(r);

        if (y > x)
        {
            cout <<(lli) pow(2, y) << gp << (lli)pow(2, y) - 1 << gp;
            if (isin(pow(2, y) + 1, l, r))
                cout <<(lli) pow(2, y) + 1 << endl;
            else
                cout <<(lli) pow(2, y) - 2 << endl;
            continue;
        }
        lli baad = 0;
        while ((lli)log2(l) == (lli)log2(r))
        {
            baad += pow(2, (lli)log2(r));
            //error(baad);
            l -= pow(2, (lli)log2(r));
            r -= pow(2, (lli)log2(r));
            l+=(l == 0);
            
        }
        y=(lli)log2(r);
        cout <<(lli) pow(2, y)+baad << gp << (lli)pow(2, y) - 1 +baad<< gp;
        if (isin(pow(2, y) + 1, l, r))
            cout <<(lli) pow(2, y) + 1+baad << endl;
        else
            cout <<(lli) pow(2, y) - 2+baad << endl;
    }
}