Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
//Varun 2212144

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//s.find_by_order(2) -> iterator to 3rd element, s.order_of_key(6) -> count of elements strictly less than 6 
const int mod=1e9+7;
#define ll long long
#define gcd __gcd
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define mii map<int,int>
#define mll map<ll,ll>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vpll vector<pair<long long, long long>>
#define vpii vector<pair<int, int>>
#define ff first
#define ss second
#define pb push_back
#define maxe(v) (*max_element(v.begin(),v.end()))
#define mine(v) (*min_element(v.begin(),v.end()))
#define el "\n"
#define sz(x) ((int)(x).size())
#define cc continue
#define all(v) v.begin(), v.end()
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define revall(v) (v).rbegin(),(v).rend()
#define outt(a) for(ll i =0; i<sz(a); i++) cout << a[i] << " "; cout << endl;
#define inn(a) for(ll i =0; i<sz(a); i++) cin >> a[i];

//--------------------------------FUNCTIONS---------------------------------------------------------

ll sum(ll n) { return (n * (n + 1)) / 2; }
ll ceil(ll a,ll b){return (a+b-1)/b;}
bool isprime(ll n){if(n==1)return 0;for(ll i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
ll binexp(ll a,ll b,ll m){ ll ans=1; while(b>0){ if(b&1) ans=(ans*a)%m; a=(a*a)%m; b>>=1; }return ans; }
long long lcm(ll a, ll b){return (a / gcd(a, b)) * b;}
ll mod_add(ll a, ll b, ll m) { a = a % m; b = b % m; return (((a + b) % m) + m) % m; }
ll mod_mul(ll a, ll b, ll m) { a = a % m; b = b % m; return (((a * b) % m) + m) % m; }
ll mod_sub(ll a, ll b, ll m) { a = a % m; b = b % m; return (((a - b) % m) + m) % m; }
ll mminvprime(ll a, ll b) {return binexp(a, b - 2, b);}
ll mod_div(ll a, ll b, ll m) { a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m; }
long long binpow(long long a, long long b) {long long res = 1;while (b > 0) {if (b & 1)res = res * a;a = a * a;b >>= 1;}return res;}
ll ncr(ll n, ll r, ll m, ll *fact, ll *ifact) {if(n<r)return 0;ll val1 = fact[n]; ll val2 = ifact[n - r]; ll val3 = ifact[r];if(n < r) return 0;if(n == r || r == 0) return 1;if(r<0) return 0; return (((val1 * val2) % m) * val3) % m;}
const int N=100005;
ll fact[N],ifact[N];
void PreComp(){
fact[0]=1;for(int i = 1; i < N; i++){fact[i]=(fact[i-1]*i)%mod;}
ifact[N-1]=mminvprime(fact[N-1],mod);for(int i = N-1; i>=0; i--){ifact[i-1]=(ifact[i]*i)%mod;}}
ll C(ll n,ll r){return ncr(n,r,mod,fact,ifact);}

//--------------------------------------------------------------------------------------------------------

#define int long long
int get(int x, int y, int z)
{
    int yo = (x ^ y) + (y ^ z) + (x ^ z);
    return yo;
}
int chk(int at)
{
    int ans = 0;
    for(int i = 0; i < at; i++)
    {
        ans += (1<<i);
    }
    ans *= 2;
    return ans;
}
void solve()
{
    int l, r; cin>>l>>r;
    int num = 1;
    while(num*2 <= r)
    {
        num *=2;
    }
    while(num < l)
    {
        num += (num/2);
    }
    int y = 0;
    int mx = 0;
    int t = num;
    while(t)
    {
        mx++;
        t>>= 1;
    }
    for(int i = 0; i < mx; i++)
    {
        if((1 & (num >>i)) == 0)
        {
            y += (1 << i);
        }
    }
    cout << num << " " << y << " "<< y - 1 << el;
    // cout << " chlk :"<< get(num, y, y-1) << " "<<chk(mx)<<el;

}


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

    int T = 1;
    cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 3):
//Varun 2212144

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//s.find_by_order(2) -> iterator to 3rd element, s.order_of_key(6) -> count of elements strictly less than 6 
const int mod=1e9+7;
#define ll long long
#define gcd __gcd
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define mii map<int,int>
#define mll map<ll,ll>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vpll vector<pair<long long, long long>>
#define vpii vector<pair<int, int>>
#define ff first
#define ss second
#define pb push_back
#define maxe(v) (*max_element(v.begin(),v.end()))
#define mine(v) (*min_element(v.begin(),v.end()))
#define el "\n"
#define sz(x) ((int)(x).size())
#define cc continue
#define all(v) v.begin(), v.end()
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define revall(v) (v).rbegin(),(v).rend()
#define outt(a) for(ll i =0; i<sz(a); i++) cout << a[i] << " "; cout << endl;
#define inn(a) for(ll i =0; i<sz(a); i++) cin >> a[i];

//--------------------------------FUNCTIONS---------------------------------------------------------

ll sum(ll n) { return (n * (n + 1)) / 2; }
ll ceil(ll a,ll b){return (a+b-1)/b;}
bool isprime(ll n){if(n==1)return 0;for(ll i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
ll binexp(ll a,ll b,ll m){ ll ans=1; while(b>0){ if(b&1) ans=(ans*a)%m; a=(a*a)%m; b>>=1; }return ans; }
long long lcm(ll a, ll b){return (a / gcd(a, b)) * b;}
ll mod_add(ll a, ll b, ll m) { a = a % m; b = b % m; return (((a + b) % m) + m) % m; }
ll mod_mul(ll a, ll b, ll m) { a = a % m; b = b % m; return (((a * b) % m) + m) % m; }
ll mod_sub(ll a, ll b, ll m) { a = a % m; b = b % m; return (((a - b) % m) + m) % m; }
ll mminvprime(ll a, ll b) {return binexp(a, b - 2, b);}
ll mod_div(ll a, ll b, ll m) { a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m; }
long long binpow(long long a, long long b) {long long res = 1;while (b > 0) {if (b & 1)res = res * a;a = a * a;b >>= 1;}return res;}
ll ncr(ll n, ll r, ll m, ll *fact, ll *ifact) {if(n<r)return 0;ll val1 = fact[n]; ll val2 = ifact[n - r]; ll val3 = ifact[r];if(n < r) return 0;if(n == r || r == 0) return 1;if(r<0) return 0; return (((val1 * val2) % m) * val3) % m;}
const int N=100005;
ll fact[N],ifact[N];
void PreComp(){
fact[0]=1;for(int i = 1; i < N; i++){fact[i]=(fact[i-1]*i)%mod;}
ifact[N-1]=mminvprime(fact[N-1],mod);for(int i = N-1; i>=0; i--){ifact[i-1]=(ifact[i]*i)%mod;}}
ll C(ll n,ll r){return ncr(n,r,mod,fact,ifact);}

//--------------------------------------------------------------------------------------------------------

#define int long long
int get(int x, int y, int z)
{
    int yo = (x ^ y) + (y ^ z) + (x ^ z);
    return yo;
}
int chk(int at)
{
    int ans = 0;
    for(int i = 0; i < at; i++)
    {
        ans += (1 << i);
    }
    ans *= 2;
    return ans;
}
void solve()
{
    int l, r; cin>>l>>r;
    int at = -1;
    int a = 0, b =0, c = 0;
    int mx =0;
    int t = r;
    while(t > 0)
    {
        mx++;
        t >>= 1;
    }
    for(int i = 29; i>= 0; i--)
    {
        if((l^r) >> i & 1)
        {
            a |= (1 << i);
            at = i;
            break;
        }
        else 
        {
            if(l >> i & 1)
            {
                a |= (1 << i);
                b |= (1 << i);
                c |= (1 << i);
            }
        }
    }
    b += (1 << at) - 1;
    while(c == a || c == b || c < l) c++;
    cout << a << " "<<b<<" "<<c<<el;
    // cout << "chl : "<<get(a, b, c) << " "<<chk(mx)<<el;
   

}


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

    int T = 1;
    cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}