Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
//**Template_begin**//
#include<bits/stdc++.h>

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
 
#define ll long long
#define int long long
#define ld long double
#define inf 1000000000000000005
#define mod 1000000007
typedef pair<int, int> pii;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
#define pb push_back
#define ppb pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sz(x) (ll)x.size()
#define HAR_HAR_MAHADEV ios_base::sync_with_stdio(false);cin.tie(NULL);
const int N = 1e6 + 10;
 
// std::cout << std::fixed;
// std::cout << std::setprecision(12);
// floor(2.3)
// ceil(2.3)

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
}; // unordered_map<ll , ll , custom_hash> mp;
 
//******//
//**Template_end***//

ll expo(ll a, ll b, ll mod1) {ll res = 1; while (b > 0) {if (b & 1ll)res = (res * a) % mod1; a = (a * a) % mod1; b = b >> 1ll;} return res;}

void solve(){
    int l , r; cin >> l >> r;
    int a = 0 , b = 0 , c = 0;
    
    for(int i = 0; i < 31; ++i) {
        if((r & ((int)1 << i)) and (l & ((int)1 << i))) {
            a |= (r & ((int)1 << i));
            b |= (r & ((int)1 << i));
            c |= (r & ((int)1 << i));
        } else {
            if(i >= 2){
                a |= (r & ((int)1 << i));
                
                if((l & ((int)1 << (i + 1)))) {
                    b = a - 1;
                    
                    if(a + 1 >= l and a + 1 <= r) {
                        cout << a << " " << b << " " << a + 1 << "\n";
                    } else {
                        cout << a << " " << b << " " << b - 1 << "\n";
                    }
                } else {
                    int p = ((int)1 << (i - 1));
                    b += p;
                    --p;
                    c += p;                    
                    
                    cout << a << " " << b << c << "\n";
                }
            } else {
                if(r - l + 1 == 3) { 
                   cout << r << " " << r - 1 << " " << r - 2 << "\n";
                } else {
                    vector<int> v = { r , r - 1 , r - 2 , r - 3};
                    int ans = -1;
                    
                    vector<int> fans;
                    
                    for(int mask = 0; mask < ((int)1 << 4); ++mask) {
                        int cnt = __builtin_popcountll(mask);
                        
                        if(cnt == (int)3) {
                            int currAns = 0;
                            
                            vector<int> _fans;
                            
                            for(int j = 0; j < 4; ++j) {
                                if(mask & ((int)1 << j)) {
                                    currAns ^= v[j];
                                    _fans.pb(v[j]);
                                }
                            }
                            
                            if(currAns > ans) {
                                swap(_fans , fans);
                            }
                            
                            ans = max(ans , currAns);
                        }
                    }
                    
                    cout << fans[0] << " " << fans[1] << " " << fans[2] << "\n";
                }
            }
            
            break;
        }
    }
    
    // 10111011110
    // 1001
}  
 
int32_t main(){
 
    HAR_HAR_MAHADEV
 
    ll t = 1;
    cin >> t;
 
    while(t--){
        solve();
    } 


 /*
   Think of the edge case (n == 1 ?).
   Don't get stuck on a single approach for a long time.
   Also don't get stuck on a single problem for a long time :).
 */   
 
    return 0;
}

/*

*/
 

Submission (verdict: Wrong answer on test 2):
//**Template_begin**//
#include<bits/stdc++.h>

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
 
#define ll long long
#define int long long
#define ld long double
#define inf 1000000000000000005
#define mod 1000000007
typedef pair<int, int> pii;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
#define pb push_back
#define ppb pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sz(x) (ll)x.size()
#define HAR_HAR_MAHADEV ios_base::sync_with_stdio(false);cin.tie(NULL);
const int N = 1e6 + 10;
 
// std::cout << std::fixed;
// std::cout << std::setprecision(12);
// floor(2.3)
// ceil(2.3)

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
}; // unordered_map<ll , ll , custom_hash> mp;
 
//******//
//**Template_end***//

ll expo(ll a, ll b, ll mod1) {ll res = 1; while (b > 0) {if (b & 1ll)res = (res * a) % mod1; a = (a * a) % mod1; b = b >> 1ll;} return res;}

void solve(){
    int l , r; cin >> l >> r;
    int a = 0 , b = 0 , c = 0;
    
    for(int i = 31; i >= 0; --i) {
        if((r & ((int)1 << i)) == (l & ((int)1 << i))) {
            a |= (r & ((int)1 << i));
            b |= (r & ((int)1 << i));
            c |= (r & ((int)1 << i));
        } else {
            if(i >= 2){
                a |= (r & ((int)1 << i));
                
                if((l & ((int)1 << (i + 1)))) {
                    b = a - 1;
                    
                    if(a + 1 >= l and a + 1 <= r) {
                        cout << a << " " << b << " " << a + 1 << "\n";
                    } else {
                        cout << a << " " << b << " " << b - 1 << "\n";
                    }
                } else {
                    int p = ((int)1 << (i - 1));
                    b += p;
                    --p;
                    c += p;                    
                    
                    cout << a << " " << b << " " << c << "\n";
                }
            } else {
                if(r - l + 1 == 3) { 
                   cout << r << " " << r - 1 << " " << r - 2 << "\n";
                } else {
                    vector<int> v = { r , r - 1 , r - 2 , r - 3};
                    int ans = -1;
                    
                    vector<int> fans;
                    
                    for(int mask = 0; mask < ((int)1 << 4); ++mask) {
                        int cnt = __builtin_popcountll(mask);
                        
                        if(cnt == (int)3) {
                            int currAns = 0;
                            
                            vector<int> _fans;
                            
                            for(int j = 0; j < 4; ++j) {
                                if(mask & ((int)1 << j)) {
                                    currAns ^= v[j];
                                    _fans.pb(v[j]);
                                }
                            }
                            
                            if(currAns > ans) {
                                swap(_fans , fans);
                            }
                            
                            ans = max(ans , currAns);
                        }
                    }
                    
                    cout << fans[0] << " " << fans[1] << " " << fans[2] << "\n";
                    // cout << ans << "\n";
                }
            }
            
            break;
        }
    }
    
    // 10111011110
    // 1001
}  
 
int32_t main(){
 
    HAR_HAR_MAHADEV
 
    ll t = 1;
    cin >> t;
 
    while(t--){
        solve();
    } 


 /*
   Think of the edge case (n == 1 ?).
   Don't get stuck on a single approach for a long time.
   Also don't get stuck on a single problem for a long time :).
 */   
 
    return 0;
}

/*

*/