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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define int long long
const int MOD = 1e9 + 7;
const int INF = LONG_MAX >> 1;
typedef pair<char, int> pchar;
typedef pair<int, int> pint;
typedef vector<int> v;
typedef vector<pint> vpint;
typedef vector<string> vs;
typedef unordered_map<int, int> ump;
typedef map<int, int> mp;
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define fl(i,n) for(int i=0;i<n;i++)
#define rl(i,m,n) for(int i=n;i>=m;i--)
#define py cout << "YES\n";
#define pn cout << "NO\n";
#define pimp cout << "IMPOSSIBLE\n";
#define vr(v) v.begin(), v.end()
#define rv(v) v.end(), v.begin()
#define debug(x) cerr << #x << " "; cerr << x << " "; cerr << endl;
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); }
int lcm(int a, int b) { return (a / gcd(a, b) * b); }
int moduloMultiplication(int a, int b, int mod) { int res = 0; a %= mod; while (b) { if (b & 1) res = (res + a) % mod; b >>= 1; a = (a * 2) % mod; } return res; }
int powermod(int x, int y, int p) { int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }

// Utility functions
void pv(const vector<int>& v) { for(auto x: v) cout << x << " "; cout << "\n"; }
void pap(const pair<int,int> ap[],int n) { for(int i=0; i<n; i++) cout << ap[i].first << "->" << ap[i].second << "\n"; }
void pm(const map<int,int>& m) { for(auto x: m) cout << x.first << "->" << x.second << "\n"; }
void pa(const int a[], int n) { for (int i = 0; i < n; ++i) cout << a[i] << " "; cout << "\n"; }
bool sorta(const pair<int,int>& a, const pair<int,int>& b) { return (a.second < b.second); }
bool sortd(const pair<int,int>& a, const pair<int,int>& b) { return (a.second > b.second); }

// Bits
string decToBinary(int n) { string s=""; while (n > 0) { s = to_string(n % 2) + s; n = n / 2; } return s; }
int binaryToDecimal(const string& n) { int dec_value = 0; int base = 1; int len = n.length(); for(int i = len - 1; i >= 0; i--) { if (n[i] == '1') dec_value += base; base = base * 2; } return dec_value; }

// Check functions
bool isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for(int i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
bool isPowerOfTwo(int n) { if (n == 0) return false; return (ceil(log2(n)) == floor(log2(n))); }
bool isPerfectSquare(int x) { if (x >= 0) { int sr = sqrt(x); return (sr * sr == x); } return false; }
void nl() { cout << "\n"; }
void yn(int x) { if (x == 1) cout << "YES" << "\n"; else cout << "NO" << "\n"; }
void yes() { cout << "YES" << "\n"; }
void no() { cout << "NO" << "\n"; }
void print(int x) { cout << x << "\n"; }
bool sortbysec(const pair<int,int>& a, const pair<int,int>& b) { return (a.second < b.second); }



int kade(const int a[], int n) {
    int mx = LLONG_MIN, cs = 0;
    for (int i = 0; i < n; ++i) {   
        cs = (cs + a[i]);
        if (cs >= mx) {
            mx = cs;
        }
        if (cs < 0) {
            cs = 0;
        }
    }
    return mx;
}
vector<int> getFactorization(int x,int spf[])
{
    vector<int> ret;
    set<int> st;
    st.insert(1);
    int temp=x;
    while (x != 1) {
        st.insert(spf[x]);
        x = x / spf[x];
    }
    for(auto y: st){
        ret.push_back(y);
    }
    return ret;
}

double sinDegrees(double angleInDegrees) {
    // Convert degrees to radians
    double angleInRadians = angleInDegrees * (M_PI / 180.0);
    double result = sin(angleInRadians);
    // Set result to 0 if it's very close to zero to handle floating-point precision issues
    return (std::abs(result) < 1e-10) ? 0 : result;
}

double cosDegrees(double angleInDegrees) {
    // Convert degrees to radians
    double angleInRadians = angleInDegrees * (M_PI / 180.0);
    double result = cos(angleInRadians);
    // Set result to 0 if it's very close to zero to handle floating-point precision issues
    return (std::abs(result) < 1e-10) ? 0 : result;
}
double distanceBetweenPoints(double x1, double y1, double x2, double y2) {
    // Calculate the distance using the distance formula
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}
bool comp(pair<int,int> &a,pair<int,int> &b){
    if(max(a.first,a.second)==max(b.first,b.second)) return min(a.first,a.second)<min(b.first,b.second);
    else return max(a.first,a.second)<max(b.first,b.second);
}

int dfs(vector<int> adj[],int node,int dp[]){
     if(dp[node]!=0) return dp[node];
     
     for(auto child: adj[node]){    
         dp[node]=max(1+dfs(adj,child,dp),dp[node]);
     }
     return dp[node];
}
// int n,m;
// int dp[10][1001][1001];
// int f(int i,int a,int b){
//     if(i==m) return 1;
//     if(a>b||b<1||a>n) return 0;
//     if(dp[i][a][b]!=-1) return dp[i][a][b];
//     return dp[i][a][b]=(f(i+1,a,b)+f(i,a+1,b)+f(i,a,b-1)-f(i,a+1,b-1)+MOD)%MOD;
// }

int kade1(vector<int> a) {
    int n=a.size();
    int mx = LLONG_MIN, cs = 0;
    for (int i = 0; i < n; ++i) {   
        cs = (cs + a[i]);
        if (cs >= mx) {
            mx = cs;
        }
        if (cs < 0) {
            cs = 0;
        }
    }
    return mx;
}
int smallestSumSubarr(vector<int> arr)
{
    // to store the minimum value that is ending
    // up to the current index
    int n=arr.size();
    int min_ending_here = INT_MAX;
     
    // to store the minimum value encountered so far
    int min_so_far = INT_MAX;
     
    // traverse the array elements
    for (int i=0; i<n; i++)
    {
        // if min_ending_here > 0, then it could not possibly
        // contribute to the minimum sum further
        if (min_ending_here > 0)
            min_ending_here = arr[i];
         
        // else add the value arr[i] to min_ending_here    
        else
            min_ending_here += arr[i];
         
        // update min_so_far
        min_so_far = min(min_so_far, min_ending_here);            
    }
     
    // required smallest sum contiguous subarray value
    return min_so_far;
}
int xorsum(int a,int b,int c){
    return (a^b)+(b^c)+(c^a);
}
signed main()
 { 
ios::sync_with_stdio(false); 
cin.tie(NULL);
  int tc;
  cin>>tc;
   // cout<<xorsum(98,85,76)<<"\n";
  while(tc--){
   int l,r;
   cin>>l>>r;
   if(r-l==2){
      cout<<l<<" "<<l+1<<" "<<r<<"\n";
      continue;
   }
   int lmsb=0,rmsb=0;
   int amx[32]{},b[32]{},cmn[32]{};
   for (int i = 0; i <=31; ++i)
   {
       if((r & (1<<i))&&!(l & (1<<i))){
         rmsb=i;
       }
   }
   for (int i = 0; i <=rmsb; ++i)
   {
       if(l & (1<<i)){
         b[i]=1;
       }
   }
   amx[rmsb]=1;
   for (int i = 0; i <rmsb; ++i) 
   {
       cmn[i]=1;
   }
   int ind=-1;
   for (int i = 31; i>=rmsb; i--)
   {
        if((r & (1<<i))&&(l & (1<<i))){
         ind=i;
         break;
       }   
   }
   if(ind!=-1){
     amx[ind]=1;
     b[ind]=1;
     cmn[ind]=1;
   }

   int a=0,bb=0,c=0;
   for (int i = 0; i <=31; ++i)
   {
       a+=((1<<i)*amx[i]);
       bb+=((1<<i)*b[i]);
       c+=((1<<i)*cmn[i]);
   }
   cout<<a<<" "<<bb<<" "<<c<<"\n";
   // pa(amx,10);
   // pa(b,10);
   // pa(cmn,10);
   // nl();
  
}

}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define int long long
const int MOD = 1e9 + 7;
const int INF = LONG_MAX >> 1;
typedef pair<char, int> pchar;
typedef pair<int, int> pint;
typedef vector<int> v;
typedef vector<pint> vpint;
typedef vector<string> vs;
typedef unordered_map<int, int> ump;
typedef map<int, int> mp;
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define fl(i,n) for(int i=0;i<n;i++)
#define rl(i,m,n) for(int i=n;i>=m;i--)
#define py cout << "YES\n";
#define pn cout << "NO\n";
#define pimp cout << "IMPOSSIBLE\n";
#define vr(v) v.begin(), v.end()
#define rv(v) v.end(), v.begin()
#define debug(x) cerr << #x << " "; cerr << x << " "; cerr << endl;
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); }
int lcm(int a, int b) { return (a / gcd(a, b) * b); }
int moduloMultiplication(int a, int b, int mod) { int res = 0; a %= mod; while (b) { if (b & 1) res = (res + a) % mod; b >>= 1; a = (a * 2) % mod; } return res; }
int powermod(int x, int y, int p) { int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }

// Utility functions
void pv(const vector<int>& v) { for(auto x: v) cout << x << " "; cout << "\n"; }
void pap(const pair<int,int> ap[],int n) { for(int i=0; i<n; i++) cout << ap[i].first << "->" << ap[i].second << "\n"; }
void pm(const map<int,int>& m) { for(auto x: m) cout << x.first << "->" << x.second << "\n"; }
void pa(const int a[], int n) { for (int i = 0; i < n; ++i) cout << a[i] << " "; cout << "\n"; }
bool sorta(const pair<int,int>& a, const pair<int,int>& b) { return (a.second < b.second); }
bool sortd(const pair<int,int>& a, const pair<int,int>& b) { return (a.second > b.second); }

// Bits
string decToBinary(int n) { string s=""; while (n > 0) { s = to_string(n % 2) + s; n = n / 2; } return s; }
int binaryToDecimal(const string& n) { int dec_value = 0; int base = 1; int len = n.length(); for(int i = len - 1; i >= 0; i--) { if (n[i] == '1') dec_value += base; base = base * 2; } return dec_value; }

// Check functions
bool isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for(int i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
bool isPowerOfTwo(int n) { if (n == 0) return false; return (ceil(log2(n)) == floor(log2(n))); }
bool isPerfectSquare(int x) { if (x >= 0) { int sr = sqrt(x); return (sr * sr == x); } return false; }
void nl() { cout << "\n"; }
void yn(int x) { if (x == 1) cout << "YES" << "\n"; else cout << "NO" << "\n"; }
void yes() { cout << "YES" << "\n"; }
void no() { cout << "NO" << "\n"; }
void print(int x) { cout << x << "\n"; }
bool sortbysec(const pair<int,int>& a, const pair<int,int>& b) { return (a.second < b.second); }



int kade(const int a[], int n) {
    int mx = LLONG_MIN, cs = 0;
    for (int i = 0; i < n; ++i) {   
        cs = (cs + a[i]);
        if (cs >= mx) {
            mx = cs;
        }
        if (cs < 0) {
            cs = 0;
        }
    }
    return mx;
}
vector<int> getFactorization(int x,int spf[])
{
    vector<int> ret;
    set<int> st;
    st.insert(1);
    int temp=x;
    while (x != 1) {
        st.insert(spf[x]);
        x = x / spf[x];
    }
    for(auto y: st){
        ret.push_back(y);
    }
    return ret;
}

double sinDegrees(double angleInDegrees) {
    // Convert degrees to radians
    double angleInRadians = angleInDegrees * (M_PI / 180.0);
    double result = sin(angleInRadians);
    // Set result to 0 if it's very close to zero to handle floating-point precision issues
    return (std::abs(result) < 1e-10) ? 0 : result;
}

double cosDegrees(double angleInDegrees) {
    // Convert degrees to radians
    double angleInRadians = angleInDegrees * (M_PI / 180.0);
    double result = cos(angleInRadians);
    // Set result to 0 if it's very close to zero to handle floating-point precision issues
    return (std::abs(result) < 1e-10) ? 0 : result;
}
double distanceBetweenPoints(double x1, double y1, double x2, double y2) {
    // Calculate the distance using the distance formula
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}
bool comp(pair<int,int> &a,pair<int,int> &b){
    if(max(a.first,a.second)==max(b.first,b.second)) return min(a.first,a.second)<min(b.first,b.second);
    else return max(a.first,a.second)<max(b.first,b.second);
}

int dfs(vector<int> adj[],int node,int dp[]){
     if(dp[node]!=0) return dp[node];
     
     for(auto child: adj[node]){    
         dp[node]=max(1+dfs(adj,child,dp),dp[node]);
     }
     return dp[node];
}
// int n,m;
// int dp[10][1001][1001];
// int f(int i,int a,int b){
//     if(i==m) return 1;
//     if(a>b||b<1||a>n) return 0;
//     if(dp[i][a][b]!=-1) return dp[i][a][b];
//     return dp[i][a][b]=(f(i+1,a,b)+f(i,a+1,b)+f(i,a,b-1)-f(i,a+1,b-1)+MOD)%MOD;
// }

int kade1(vector<int> a) {
    int n=a.size();
    int mx = LLONG_MIN, cs = 0;
    for (int i = 0; i < n; ++i) {   
        cs = (cs + a[i]);
        if (cs >= mx) {
            mx = cs;
        }
        if (cs < 0) {
            cs = 0;
        }
    }
    return mx;
}
int smallestSumSubarr(vector<int> arr)
{
    // to store the minimum value that is ending
    // up to the current index
    int n=arr.size();
    int min_ending_here = INT_MAX;
     
    // to store the minimum value encountered so far
    int min_so_far = INT_MAX;
     
    // traverse the array elements
    for (int i=0; i<n; i++)
    {
        // if min_ending_here > 0, then it could not possibly
        // contribute to the minimum sum further
        if (min_ending_here > 0)
            min_ending_here = arr[i];
         
        // else add the value arr[i] to min_ending_here    
        else
            min_ending_here += arr[i];
         
        // update min_so_far
        min_so_far = min(min_so_far, min_ending_here);            
    }
     
    // required smallest sum contiguous subarray value
    return min_so_far;
}
int xorsum(int a,int b,int c){
    return (a^b)+(b^c)+(c^a);
}
signed main()
 { 
ios::sync_with_stdio(false); 
cin.tie(NULL);
  int tc;
  cin>>tc;
   // cout<<xorsum(98,85,76)<<"\n";
  while(tc--){
   int l,r;
   cin>>l>>r;
   if(r-l==2){
      cout<<l<<" "<<l+1<<" "<<r<<"\n";
      continue;
   }
   int lmsb=0,rmsb=0;
   int amx[32]{},b[32]{},cmn[32]{};
   for (int i = 0; i <=31; ++i)
   {
       if((r & (1<<i))&&!(l & (1<<i))){
         rmsb=i;
       }
   }
   for (int i = 0; i <=rmsb; ++i)
   {
       if(l & (1<<i)){
         b[i]=1;
       }
   }
   amx[rmsb]=1;
   for (int i = 0; i <rmsb; ++i) 
   {
       cmn[i]=1;
   }
     int ans=0;
   for (int i = 31; i>=rmsb; i--)
   {
        if((r & (1<<i))&&(l & (1<<i))){
         ans+=(1<<i);
       }   
   }
   int a=0,bb=0,c=0;
   for (int i = 0; i <=31; ++i)
   {
       a+=((1<<i)*amx[i]);
       bb+=((1<<i)*b[i]);
       c+=((1<<i)*cmn[i]);
   }
   cout<<a+ans<<" "<<bb+ans<<" "<<c+ans<<"\n";
   // pa(amx,10);
   // pa(b,10);
   // pa(cmn,10);
   // nl();
  
}

}