Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#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 long long ll;
#define int long long
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#ifndef ONLINE_JUDGE
#include "ciphertxt.cpp"
#else
#define dff(...)
#define dfa(...)
#endif

vector<int> bin(int x){
    vector<int> arr;
    while(x){arr.push_back(x%2);x/=2;}
    while(arr.size()!=30){arr.push_back(0);}
    return arr;
}

void solve(){
    int l,r;cin>>l>>r;
    int i,j;    
    // int a,b,c;cin>>a>>b>>c;
    // cout<<(a ^ b) + (b ^ c) + (c ^ a)<<" ";cout<<endl;
    // bin(a);bin(b);bin(c);cout<<endl;
    auto la=bin(l);auto ra=bin(r);
    
    for(i=29;i>=0;i--){if(la[i]!=ra[i]){break;}}
    int a=0;
    int b=0;
    int id=i;int t=1;
    dff(la,ra);

    for(i=0;i<id;i++){a+=t;t*=2;}
    t*=2;
    for(i=id+1;i<30;i++){if(la[i]){a+=t;}t*=2;}

    t=1;
    for(i=0;i<id;i++){t*=2;}
    b+=t;
    t*=2;
    for(i=id+1;i<30;i++){if(ra[i]){b+=t;}t*=2;}
    int c=(a+b)/2;
    if(c==a || c==b){if(l>=(min(a,b)-1)){c=min(a,b)-1;}else if(r<=max(a,b)+1){c=max(a,b)+1;}}
    cout<<a<<" "<<b<<" "<<c<<endl;
   // cout<<(a ^ b)+(b ^ c) + (c ^ a) <<endl;
    }
    
 
signed main(){
    
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    #ifndef ONLINE_JUDGE
    freopen("rr.txt", "w", stderr);
    #endif

    int t;cin>>t;while(t--){
        solve();
        }
    return 0;
    }
    
 

Submission (verdict: Accepted):
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#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 long long ll;
#define int long long
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#ifndef ONLINE_JUDGE
#include "ciphertxt.cpp"
#else
#define dff(...)
#define dfa(...)
#endif

vector<int> bin(int x){
    vector<int> arr;
    while(x){arr.push_back(x%2);x/=2;}
    while(arr.size()!=30){arr.push_back(0);}
    return arr;
}

void solve(){
    int l,r;cin>>l>>r;
    int i,j;    
    // int a,b,c;cin>>a>>b>>c;
    // cout<<(a ^ b) + (b ^ c) + (c ^ a)<<" ";cout<<endl;
    // bin(a);bin(b);bin(c);cout<<endl;
    auto la=bin(l);auto ra=bin(r);
    
    for(i=29;i>=0;i--){if(la[i]!=ra[i]){break;}}
    int a=0;
    int b=0;
    int id=i;int t=1;
    dff(la,ra);

    for(i=0;i<id;i++){a+=t;t*=2;}
    t*=2;
    for(i=id+1;i<30;i++){if(la[i]){a+=t;}t*=2;}

    t=1;
    for(i=0;i<id;i++){t*=2;}
    b+=t;
    t*=2;
    for(i=id+1;i<30;i++){if(ra[i]){b+=t;}t*=2;}
    int c=(a+b)/2;
    if(c==a || c==b){if(l<=(min(a,b)-1)){c=min(a,b)-1;}else if(r>=max(a,b)+1){c=max(a,b)+1;}}
    cout<<a<<" "<<b<<" "<<c<<endl;
   // cout<<(a ^ b)+(b ^ c) + (c ^ a) <<endl;
    }
    
 
signed main(){
    
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    #ifndef ONLINE_JUDGE
    freopen("rr.txt", "w", stderr);
    #endif

    int t;cin>>t;while(t--){
        solve();
        }
    return 0;
    }