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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define inp(v,n) vector <int> v(n) ; for (int i = 0; i < n; ++i){cin >> v[i];}
#define otp(v,n) for (int i = 0; i < n; ++i){cout << v[i]<<" ";}
#define ndl cout << endl;
#define ys cout << "YES" << endl
#define no cout << "NO" << endl
#define zer cout << 0 << endl
#define onee cout << 1 << endl
#define outp(a) cout << a << endl;
#define ret return 0;
#define pb push_back
#define all(arr) arr.begin(), arr.end()
#define rall(arr) arr.rbegin(), arr.rend()
#define min1 cout<<-1<<endl
#define f first
#define s second
#define int long long 
#define _test   int _TEST; cin>>_TEST; while(_TEST--)
#define M 1000000007
#define fir cout<<"first"<<endl;
#define sec cout<<"sec"<<endl;
#define ll long long 
string itos(int n ){vector<char>a;string s="" ;while(n){int b = n%10;a.insert(a.begin(),(char)b+48);n/=10;}for(auto x:a)s+=x;return s ;}

// set<string> storage;
// // vector<string> storage;
// void subs(int i , string s,string &x)
// {
//     if(i==x.size())storage.insert(s);
//     // if(i==x.size())storage.pb(s);
//     else{
//     string picked=s+x[i];
//     string skipped=s;

//     subs(i+1,picked,x);
//     subs(i+1,skipped,x);
//     }   
// }

// int lcs(string &s1, string &s2, int m, int n, vector<vector<int>> &memo) {

//         if(m==0 || n==0)return 0;

//         if(memo[m][n]!=-1)return memo[m][n];

//         if (s1[m - 1] == s2[n - 1])
            
//         return memo[m][n] = 1 + lcs(s1, s2, m - 1, n - 1, memo);

//         else {

//             return memo[m][n] = max(lcs(s1, s2, m - 1, n, memo),lcs(s1, s2, m, n-1, memo));

//         }

// }
// void solve()
// {
//     int    n ,  m ;
//     cin >> n >> m ; 
    
//     inp(v,n)      ;

//     vector<vector<int>>dp(n+1,vector<int>(m+1,0));
//     for (int i = 0; i < n; ++i)
//     {   
//         if(v[i]==0)
//         for (int j = 0; j <=m; ++j)
//         {
//             if(i==0 || i==n-1){if(abs(v[i]-j)<=1){dp[i][j]++;}}
//             else {
//                 if(abs(v[i-1]-j)<=1 &&abs(v[i+1]-j)<=1){dp[i][j]++;}
//             }
//         }
//     }

//     int cnt = 0 ;
//     for (int i = 0; i < dp.size(); ++i)
//     {
//         for (int j = 0; j <dp[i].size() ; ++j)
//         {
//             // cout << dp[i][j]<<" ";
//             cnt+=dp[i][j];
//         }
//         // ndl;
//     }

//     vector<vector<int>>cp=dp;


//     cout << x << endl;

// }   


void solve2()
{
    int lr , ur ; cin >> lr >> ur ;

    int x = 0 ;
    int y = 0 ;
    int z = 0 ;

    int l = 0 ;
    for (int i = 31; i >=0; --i)
    {
        if(((1<<i)&lr )&&(1<<i)&ur ){
            // cout << i << " ";
        x|=(1<<i);y|=(1<<i);}

        if(((1<<i)&ur) &&(((1<<i)&lr)==0)){l=i;y|=(1<<i);break;}
    }

    for (int i = l-1; i >=0 ; --i)
    {
        x|=(1<<i);
    }

    if(x-1!=y && x-1>=lr){z=x-1;}
    if(x+1!=y && x+1<=ur){z=x+1;}
    // ndl;
    cout << x <<" "<<y <<" "<<z<< endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
#ifndef ONLINE_JUDGE
 
    freopen("input.in", "r", stdin );
 
    freopen("output1.txt", "w", stdout);
 
    freopen("error.in", "w", stderr);
#endif
    _test
    solve2();   

}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define inp(v,n) vector <int> v(n) ; for (int i = 0; i < n; ++i){cin >> v[i];}
#define otp(v,n) for (int i = 0; i < n; ++i){cout << v[i]<<" ";}
#define ndl cout << endl;
#define ys cout << "YES" << endl
#define no cout << "NO" << endl
#define zer cout << 0 << endl
#define onee cout << 1 << endl
#define outp(a) cout << a << endl;
#define ret return 0;
#define pb push_back
#define all(arr) arr.begin(), arr.end()
#define rall(arr) arr.rbegin(), arr.rend()
#define min1 cout<<-1<<endl
#define f first
#define s second
#define int long long 
#define _test   int _TEST; cin>>_TEST; while(_TEST--)
#define M 1000000007
#define fir cout<<"first"<<endl;
#define sec cout<<"sec"<<endl;
#define ll long long 
string itos(int n ){vector<char>a;string s="" ;while(n){int b = n%10;a.insert(a.begin(),(char)b+48);n/=10;}for(auto x:a)s+=x;return s ;}

// set<string> storage;
// // vector<string> storage;
// void subs(int i , string s,string &x)
// {
//     if(i==x.size())storage.insert(s);
//     // if(i==x.size())storage.pb(s);
//     else{
//     string picked=s+x[i];
//     string skipped=s;

//     subs(i+1,picked,x);
//     subs(i+1,skipped,x);
//     }   
// }

// int lcs(string &s1, string &s2, int m, int n, vector<vector<int>> &memo) {

//         if(m==0 || n==0)return 0;

//         if(memo[m][n]!=-1)return memo[m][n];

//         if (s1[m - 1] == s2[n - 1])
            
//         return memo[m][n] = 1 + lcs(s1, s2, m - 1, n - 1, memo);

//         else {

//             return memo[m][n] = max(lcs(s1, s2, m - 1, n, memo),lcs(s1, s2, m, n-1, memo));

//         }

// }
// void solve()
// {
//     int    n ,  m ;
//     cin >> n >> m ; 
    
//     inp(v,n)      ;

//     vector<vector<int>>dp(n+1,vector<int>(m+1,0));
//     for (int i = 0; i < n; ++i)
//     {   
//         if(v[i]==0)
//         for (int j = 0; j <=m; ++j)
//         {
//             if(i==0 || i==n-1){if(abs(v[i]-j)<=1){dp[i][j]++;}}
//             else {
//                 if(abs(v[i-1]-j)<=1 &&abs(v[i+1]-j)<=1){dp[i][j]++;}
//             }
//         }
//     }

//     int cnt = 0 ;
//     for (int i = 0; i < dp.size(); ++i)
//     {
//         for (int j = 0; j <dp[i].size() ; ++j)
//         {
//             // cout << dp[i][j]<<" ";
//             cnt+=dp[i][j];
//         }
//         // ndl;
//     }

//     vector<vector<int>>cp=dp;


//     cout << x << endl;

// }   


void solve2()
{
    int lr , ur ; cin >> lr >> ur ;

    int x = 0 ;
    int y = 0 ;
    int z = 0 ;

    int l = 0 ;
    for (int i = 31; i >=0; --i)
    {
        if(((1<<i)&lr )&&(1<<i)&ur ){
            // cout << i << " ";
        x|=(1<<i);y|=(1<<i);}

        if(((1<<i)&ur) &&(((1<<i)&lr)==0)){l=i;y|=(1<<i);break;}
    }

    for (int i = l-1; i >=0 ; --i)
    {
        x|=(1<<i);
    }

    if(x-1!=y && x-1>=lr){z=x-1;}
    if(x+1!=y && x+1<=ur){z=x+1;}
    if(y-1!=y && y-1>=lr){z=y-1;}
    if(y+1!=y && y+1<=ur){z=y+1;}

    // ndl;
    cout << x <<" "<<y <<" "<<z<< endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
#ifndef ONLINE_JUDGE
 
    freopen("input.in", "r", stdin );
 
    freopen("output1.txt", "w", stdout);
 
    freopen("error.in", "w", stderr);
#endif
    _test
    solve2();   

}