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

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <numeric>
#include <cstring>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <climits>
#include <random>

using namespace std;

const long long int inf = LLONG_MAX-10000000000ll;
const long long mod = 1e9+7;
const long long mod2 = 998244353;

#define inp(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define inp1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define out(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define out1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<" ";}
#define loop(n) for(int i=0;i<n;i++)
#define loop1(n) for(int i=1;i<=n;i++)
#define rloop(n) for(int i=n-1;i>=0;i--)
#define loop2(n) for(int j=0;j<n;j++)
#define nl cout<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ll long long
#define F first
#define S second

typedef vector<ll> vi;
typedef pair<ll,ll> pi;

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t = 1;
    cin>>t;
    while(t--){
        
        int l,r;
        cin>>l>>r;

        int fl = 1,ind = -1;
        ll ans = 0;
        for(int i=30;i>=0;i--){
            bool x = l&(1ll<<i);
            bool y = r&(1ll<<i);

            if(x==y){
                if(x==1 && fl)ans|=(1ll<<i);
                if(x==0 && fl==0)ans|=(1ll<<i);
            }
            else{
                if(fl){fl=0;ind=i;continue;}
                else ans|=(1ll<<i);
            }
        }
        if(ans<=l)ans|=(1ll<<ind);

        cout<<l<<" "<<r<<" "<<ans<<endl;

    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <numeric>
#include <cstring>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <climits>
#include <random>

using namespace std;

const long long int inf = LLONG_MAX-10000000000ll;
const long long mod = 1e9+7;
const long long mod2 = 998244353;

#define inp(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define inp1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define out(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define out1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<" ";}
#define loop(n) for(int i=0;i<n;i++)
#define loop1(n) for(int i=1;i<=n;i++)
#define rloop(n) for(int i=n-1;i>=0;i--)
#define loop2(n) for(int j=0;j<n;j++)
#define nl cout<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ll long long
#define F first
#define S second

typedef vector<ll> vi;
typedef pair<ll,ll> pi;

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t = 1;
    cin>>t;
    while(t--){
        
        int l,r;
        cin>>l>>r;

        int fl = 1,ind = -1;
        ll ans = 0;
        if(r == l+2){ans=l+1;goto pass;}
        for(int i=30;i>=0;i--){
            bool x = l&(1ll<<i);
            bool y = r&(1ll<<i);

            if(x==y){
                if(x==1 && fl)ans|=(1ll<<i);
                if(x==0 && fl==0)ans|=(1ll<<i);
            }
            else{
                if(fl){
                    ind = i;
                    fl=0;
                    continue;
                }
                ans |= (1ll<<i);
            }
        }
        if(ans<=l)ans|=(1ll<<ind);

    pass:
        cout<<l<<" "<<r<<" "<<ans<<endl;

    }
    return 0;
}