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

Previous submission (verdict: Wrong answer on test 2):

#include "bits/stdc++.h"
#define int long long
#define uint unsigned long long
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define fr(i,n) for(int i=0; i<(n); i++)
#define fr1(i,n) for(int i=1;i<=n;i++)
#define rep(i,a,n) for(int i=(a); i<=(n); i++)
#define nl cout<<"\n"
#define dbg(var) cout<<#var<<"="<<var<<" "
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define srt(v)  sort(v.begin(),v.end())
#define mxe(v)  *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define unq(v)  v.resize(distance(v.begin(), unique(v.begin(), v.end())));
// make sure to sort before applying unique // else only consecutive duplicates would be removed
#define bin(x,y)  bitset<y>(x)
using namespace std;
int MOD=1e9+7;      // Hardcoded, directly change from here for functions!
const int mod2=998244353;
void modadd(int &a , int b) {a=((a%MOD)+(b%MOD))%MOD;}
void modsub(int &a , int b) {a=((a%MOD)-(b%MOD)+MOD)%MOD;}
void modmul(int &a , int b) {a=((a%MOD)*(b%MOD))%MOD;}
// ================================== take ip/op lik1000

template<typename typC,typename typD> istream &operator>>(istream &cin,pair<typC,typD> &a) { return cin>>a.first>>a.second; }
template<typename typC> istream &operator>>(istream &cin,vector<typC> &a) { for (auto &x:a) cin>>x; return cin; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const pair<typC,typD> &a) { return cout<<a.first<<' '<<a.second; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const vector<pair<typC,typD>> &a) { for (auto &x:a) cout<<x<<'\n'; return cout; }
template<typename typC> ostream &operator<<(ostream &cout,const vector<typC> &a) { int n=a.size(); if (!n) return cout; cout<<a[0]; for (int i=1; i<n; i++) cout<<' '<<a[i]; return cout; }
// ===================================END Of the input module ==========================================

int flipnumber(int d)
{
    if(d==0)
    {
        return 1;
    }
    //we create a mask of all bits set to 1 
    //eg a=10110(22)-> mask=11111 
    //then a^mask =01001-> which is 9(flpped number)
    int mask=0;
    int temp=d;
    while(temp)
    {
        mask=(mask<<1)|1;
        temp>>=1;
    }
    return mask^d;
}
void solve()
{
   int l,r;cin>>l>>r;
   int len=r-l+1;
   if(len==3)
   {
       cout<<l<<" "<<l+1<<" "<<r<<endl;
       return;
   }
   
   int xori=l^r;
   int k=31-__builtin_clz(xori);
   
   int a=(1<<k)-1;
   int first=a|l;
   int c=l;
   
   cout<<first<<" "<<first+1<<" "<<c<<endl; // this is giving wrong ans on case 5 
   
}
  
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    int t;cin>>t;
    while(t--)
    {
      solve();
    }
     
    
     
    
   
    return 0;
}

Submission (verdict: Accepted):

#include "bits/stdc++.h"
#define int long long
#define uint unsigned long long
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define fr(i,n) for(int i=0; i<(n); i++)
#define fr1(i,n) for(int i=1;i<=n;i++)
#define rep(i,a,n) for(int i=(a); i<=(n); i++)
#define nl cout<<"\n"
#define dbg(var) cout<<#var<<"="<<var<<" "
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define srt(v)  sort(v.begin(),v.end())
#define mxe(v)  *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define unq(v)  v.resize(distance(v.begin(), unique(v.begin(), v.end())));
// make sure to sort before applying unique // else only consecutive duplicates would be removed
#define bin(x,y)  bitset<y>(x)
using namespace std;
int MOD=1e9+7;      // Hardcoded, directly change from here for functions!
const int mod2=998244353;
void modadd(int &a , int b) {a=((a%MOD)+(b%MOD))%MOD;}
void modsub(int &a , int b) {a=((a%MOD)-(b%MOD)+MOD)%MOD;}
void modmul(int &a , int b) {a=((a%MOD)*(b%MOD))%MOD;}
// ================================== take ip/op lik1000

template<typename typC,typename typD> istream &operator>>(istream &cin,pair<typC,typD> &a) { return cin>>a.first>>a.second; }
template<typename typC> istream &operator>>(istream &cin,vector<typC> &a) { for (auto &x:a) cin>>x; return cin; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const pair<typC,typD> &a) { return cout<<a.first<<' '<<a.second; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const vector<pair<typC,typD>> &a) { for (auto &x:a) cout<<x<<'\n'; return cout; }
template<typename typC> ostream &operator<<(ostream &cout,const vector<typC> &a) { int n=a.size(); if (!n) return cout; cout<<a[0]; for (int i=1; i<n; i++) cout<<' '<<a[i]; return cout; }
// ===================================END Of the input module ==========================================

int flipnumber(int d)
{
    if(d==0)
    {
        return 1;
    }
    //we create a mask of all bits set to 1 
    //eg a=10110(22)-> mask=11111 
    //then a^mask =01001-> which is 9(flpped number)
    int mask=0;
    int temp=d;
    while(temp)
    {
        mask=(mask<<1)|1;
        temp>>=1;
    }
    return mask^d;
}
void solve()
{
   int l,r;cin>>l>>r;
   int len=r-l+1;
   if(len==3)
   {
       cout<<l<<" "<<l+1<<" "<<r<<endl;
       return;
   }
   
   int xori=l^r;
   int k=31-__builtin_clz(xori);
   
   int a=(1<<k)-1;
   int first=a|l;
   int c=l;
   if(c==first)
   {
       c=r;
   }
   
   
   cout<<first<<" "<<first+1<<" "<<c<<endl; // this is giving wrong ans on case 5 
   
}
  
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    int t;cin>>t;
    while(t--)
    {
      solve();
    }
     
    
     
    
   
    return 0;
}