ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

int main(){

int t ;

cin >> t ;

while (t--)

{

int n ;

cin >> n ;

vector<int> v(n) ;

for (int i = 0; i < n; i++)

{

cin >> v[i] ;

}

if(v[0]>v[1]){

cout << "NO" << endl;

continue;

}

int num = min(v[0],v[1]);

v[1] = v[1]-num ;

int j = 1 ;

while(v[j+1]>v[j]){

v[j+1]=v[j+1]-v[j];

j++;

}

if(j!=n-1){

cout << "NO" << endl;

}

else{

cout << "YES" << endl;

}

}



}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

int main(){

int t ;

cin >> t ;

while (t--)

{

int n ;

cin >> n ;

vector<int> v(n) ;

for (int i = 0; i < n; i++)

{

cin >> v[i] ;

}

if(v[0]>v[1]){

cout << "NO" << endl;

continue;

}

int num = min(v[0],v[1]);

v[1] = v[1]-num ;

int j = 1 ;

while(v[j+1]>v[j]){

v[j+1]=v[j+1]-v[j];

j++;

}

if(j!=n-1){

cout << "NO" << endl;

}

else{

cout << "YES" << endl;

}

}



}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

int main(){

int t ;

cin >> t ;

while (t--)

{

int n ;

cin >> n ;

vector<int> v(n) ;

for (int i = 0; i < n; i++)

{

cin >> v[i] ;

}

if(v[0]>v[1]){

cout << "NO" << endl;

continue;

}

int num = min(v[0],v[1]);

v[1] = v[1]-num ;

int j = 1 ;

while(v[j+1]>v[j] && j<=n-2 ){

v[j+1]=v[j+1]-v[j];

j++;

}

if(j!=n-1){

cout << "NO" << endl;

}

else{

cout << "YES" << endl;

}

}



}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

int main(){

int t ;

cin >> t ;

while (t--)

{

int n ;

cin >> n ;

vector<int> v(n) ;

for (int i = 0; i < n; i++)

{

cin >> v[i] ;

}

if(v[0]>v[1]){

cout << "NO" << endl;

continue;

}

int num = min(v[0],v[1]);

v[1] = v[1]-num ;

int j = 1 ;

while(v[j+1]>v[j] && j<=n-2 ){

v[j+1]=v[j+1]-v[j];

j++;

}

if(j!=n-1){

cout << "NO" << endl;

}

else{

cout << "YES" << endl;

}

}



}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

int main(){

int t;

cin >> t;

while(t--){

int n;

cin >> n;

if(n < 2){

int dummy;

if(n == 1)

cin >> dummy;

cout << "YES" << endl;

continue;

}

vector<int> v(n);

for (int i = 0; i < n; i++){

cin >> v[i];

}

if(v[0] > v[1]){

cout << "NO" << endl;

continue;

}

int num = min(v[0], v[1]);

v[1] -= num;

int j = 1;

while(j + 1 < n && v[j+1] > v[j]){

v[j+1] -= v[j];

j++;

}

if(j != n - 1){

cout << "NO" << endl;

}

else{

cout << "YES" << endl;

}

}

return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;



void solve(){

    string num;

    cin >> num;

    int cnt2 = 0,cnt3=0;

    long long sum = 0;

    for(int i = 0;i<num.size();i++){

        if(num[i]=='2') cnt2++;

        if(num[i]=='3') cnt3++;

        sum+=num[i]-'0';

    }

    /*

    for(int i = 0;i<digit.size();i++){

        cout << digit[i] << endl;

    }

    */

   if(sum%9==0){

    cout << "YES" << endl;

    return;

   }

   while(cnt2--){

        sum+=2;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   while(cnt3--){

        sum+=6;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   cout << "NO" <<endl;



}





int main(){

    int t;

    cin >> t;

    while(t--){

        solve();

    }

}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;



void solve(){

    string num;

    cin >> num;

    int cnt2 = 0,cnt3=0;

    unsigned long long sum = 0;

    for(int i = 0;i<num.size();i++){

        if(num[i]=='2') cnt2++;

        if(num[i]=='3') cnt3++;

        sum+=num[i]-'0';

    }

    /*

    for(int i = 0;i<digit.size();i++){

        cout << digit[i] << endl;

    }

    */

   if(sum%9==0){

    cout << "YES" << endl;

    return;

   }

   while(cnt2--){

        sum+=2;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   while(cnt3--){

        sum+=6;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   cout << "NO" <<endl;



}





int main(){

    int t;

    cin >> t;

    while(t--){

        solve();

    }

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;



void solve(){

    string num;

    cin >> num;

    int cnt2 = 0,cnt3=0;

    long long sum = 0;

    for(int i = 0;i<num.size();i++){

        if(num[i]=='2') cnt2++;

        if(num[i]=='3') cnt3++;

        sum+=num[i]-'0';

    }

    /*

    for(int i = 0;i<digit.size();i++){

        cout << digit[i] << endl;

    }

    */

   if(sum%9==0){

    cout <<"YES" << endl;

    return;

   }

   while(cnt2--){

        sum+=2;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   while(cnt3--){

        sum+=6;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   cout << "N0" <<endl;



}





int main(){

    int t;

    cin >> t;

    while(t--){

        solve();

    }

}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;



void solve(){

    string num;

    cin >> num;

    int cnt2 = 0,cnt3=0;

    long long sum = 0;

    for(int i = 0;i<num.size();i++){

        if(num[i]=='2') cnt2++;

        if(num[i]=='3') cnt3++;

        sum+=num[i]-'0';

    }

    /*

    for(int i = 0;i<digit.size();i++){

        cout << digit[i] << endl;

    }

    */

   if(sum%9==0){

    cout << "YES" << endl;

    return;

   }

   while(cnt2--){

        sum+=2;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   while(cnt3--){

        sum+=6;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   cout << "NO" <<endl;



}





int main(){

    int t;

    cin >> t;

    while(t--){

        solve();

    }

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;



void solve(){

    string num;

    cin >> num;

    int cnt2 = 0,cnt3=0;

    unsigned long long sum = 0;

    for(int i = 0;i<num.size();i++){

        if(num[i]=='2') cnt2++;

        if(num[i]=='3') cnt3++;

        sum+=num[i]-'0';

    }

    /*

    for(int i = 0;i<digit.size();i++){

        cout << digit[i] << endl;

    }

    */

   if(sum%9==0){

    cout << "YES" << endl;

    return;

   }

   while(cnt2--){

        sum+=2;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   while(cnt3--){

        sum+=6;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   cout << "NO" <<endl;



}





int main(){

    int t;

    cin >> t;

    while(t--){

        solve();

    }

}

Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;



void solve(){

    string num;

    cin >> num;

    int cnt2 = 0,cnt3=0;

    long long sum = 0,ans=0;

    for(int i = 0;i<num.size();i++){

        if(num[i]=='2') cnt2++;

        if(num[i]=='3') cnt3++;

        sum+=num[i]-'0';

    }

    ans=sum;

    /*

    for(int i = 0;i<digit.size();i++){

        cout << digit[i] << endl;

    }

    */

   for(int i = 0;i<=cnt2;i++){

    for(int j =0;j<=cnt3;j++){

        sum=ans+i*2+j*6;

        if(sum%9==0){

            cout << "YES" << endl;

            return;

        }

    }

   }

   cout << "NO" <<endl;



}





int main(){

    int t;

    cin >> t;

    while(t--){

        solve();

    }

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;



void solve(){

    string num;

    cin >> num;

    int cnt2 = 0,cnt3=0;

    long long sum = 0;

    for(int i = 0;i<num.size();i++){

        if(num[i]=='2') cnt2++;

        if(num[i]=='3') cnt3++;

        sum+=num[i]-'0';

    }

    /*

    for(int i = 0;i<digit.size();i++){

        cout << digit[i] << endl;

    }

    */

   if(sum%9==0){

    cout <<"YES" << endl;

    return;

   }

   while(cnt2--){

        sum+=2;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   while(cnt3--){

        sum+=6;

        if(sum%9==0){

            cout << "YES" << endl;

            return ;

        }

   }

   cout << "N0" <<endl;



}





int main(){

    int t;

    cin >> t;

    while(t--){

        solve();

    }

}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int t,n,u,v,d[200055],maxx,id,ans,vis[200055];
vector<int> to[200055];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>t;
    while(t--){
        maxx=0,ans=0;
        for(int i=1;i<=n;i++) vis[i]=0,to[i].clear(),d[i]=0;
        cin>>n;
        for(int i=1;i<n;i++){
            cin>>u>>v;
            to[u].push_back(v);
            to[v].push_back(u);
            d[u]++,d[v]++;
        }
        vector<int> m1;
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
            }
        }
        for(int i=1;i<n;i++){
            if(d[i]==maxx){
                m1.push_back(i);
                vis[i]=1;
            }
        }
        for(int i=0;i<m1.size();i++){
            int x=m1[i];
            int tmp=0;
            for(int j=0;j<to[x].size();j++){
                int y=to[x][j];
                tmp+=vis[y];
            }
            if(tmp<=1){
                id=x;
                break;
            }
        }
        ans+=d[id];
        for(int i=0;i<to[id].size();i++){
            int y=to[id][i];
            d[y]--;
        }
        d[id]=0;
        maxx=0;
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
                id=i;
            }
        }
        ans+=d[id];
        cout<<ans-1<<endl;
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int t,n,u,v,d[200055],maxx,id,ans,vis[200055];
vector<int> to[200055];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>t;
    while(t--){
        maxx=0,ans=0;
        for(int i=1;i<=n;i++) vis[i]=0,to[i].clear(),d[i]=0;
        cin>>n;
        for(int i=1;i<n;i++){
            cin>>u>>v;
            to[u].push_back(v);
            to[v].push_back(u);
            d[u]++,d[v]++;
        }
        vector<int> m1;
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
            }
        }
        for(int i=1;i<n;i++){
            if(d[i]==maxx){
                m1.push_back(i);
                vis[i]=1;
            }
        }
        for(int i=0;i<m1.size();i++){
            int x=m1[i];
            int tmp=0;
            for(int j=0;j<to[x].size();j++){
                int y=to[x][j];
                tmp+=vis[y];
            }
            if(tmp<=1){
                id=x;
                break;
            }
        }
        ans+=d[id];
        for(int i=0;i<to[id].size();i++){
            int y=to[id][i];
            d[y]--;
        }
        d[id]=0;
        maxx=0;
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
                id=i;
            }
        }
        ans+=d[id];
        cout<<ans-1<<endl;
    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int t,n,u,v,d[200055],maxx,id,ans,vis[200055];
vector<int> to[200055];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>t;
    while(t--){
        maxx=0,ans=0;
        cin>>n;
        for(int i=1;i<=n;i++) vis[i]=0,to[i].clear(),d[i]=0;
        for(int i=1;i<n;i++){
            cin>>u>>v;
            to[u].push_back(v);
            to[v].push_back(u);
            d[u]++,d[v]++;
        }
        vector<int> m1;
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
            }
        }
        for(int i=1;i<n;i++){
            if(d[i]==maxx){
                m1.push_back(i);
                vis[i]=1;
            }
        }
        for(int i=0;i<m1.size();i++){
            int x=m1[i];
            int tmp=0;
            for(int j=0;j<to[x].size();j++){
                int y=to[x][j];
                tmp+=vis[y];
            }
            if(tmp<=1){
                id=x;
                break;
            }
        }
        ans+=d[id];
        for(int i=0;i<to[id].size();i++){
            int y=to[id][i];
            d[y]--;
        }
        d[id]=0;
        maxx=0;
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
                id=i;
            }
        }
        ans+=d[id];
        cout<<ans-1<<endl;
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int t,n,u,v,d[200055],maxx,id,ans,vis[200055];
vector<int> to[200055];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>t;
    while(t--){
        maxx=0,ans=0;
        cin>>n;
        for(int i=1;i<=n;i++) vis[i]=0,to[i].clear(),d[i]=0;
        for(int i=1;i<n;i++){
            cin>>u>>v;
            to[u].push_back(v);
            to[v].push_back(u);
            d[u]++,d[v]++;
        }
        vector<int> m1;
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
            }
        }
        for(int i=1;i<n;i++){
            if(d[i]==maxx){
                m1.push_back(i);
                vis[i]=1;
            }
        }
        for(int i=0;i<m1.size();i++){
            int x=m1[i];
            int tmp=0;
            for(int j=0;j<to[x].size();j++){
                int y=to[x][j];
                tmp+=vis[y];
            }
            if(tmp<=1){
                id=x;
                break;
            }
        }
        ans+=d[id];
        for(int i=0;i<to[id].size();i++){
            int y=to[id][i];
            d[y]--;
        }
        d[id]=0;
        maxx=0;
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
                id=i;
            }
        }
        ans+=d[id];
        cout<<ans-1<<endl;
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int t,n,u,v,d[200055],maxx,id,ans,vis[200055];
vector<int> to[200055];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>t;
    while(t--){
        maxx=0,ans=0;
        cin>>n;
        for(int i=1;i<=n;i++) vis[i]=0,to[i].clear(),d[i]=0;
        for(int i=1;i<n;i++){
            cin>>u>>v;
            to[u].push_back(v);
            to[v].push_back(u);
            d[u]++,d[v]++;
        }
        maxx=*max_element(d+1,d+n+1); 
        vector<int> m1;
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
            }
        }
        for(int i=1;i<n;i++){
            if(d[i]==maxx){
                m1.push_back(i);
                vis[i]=1;
            }
        }
        for(int i=0;i<m1.size();i++){
            int x=m1[i];
            int tmp=0;
            for(int j=0;j<to[x].size();j++){
                int y=to[x][j];
                tmp+=vis[y];
            }
            if(tmp<=1){
                id=x;
                break;
            }
        }
        ans+=d[id];
        for(int i=0;i<to[id].size();i++){
            int y=to[id][i];
            d[y]--;
        }
        d[id]=0;
        maxx=*max_element(d+1,d+n+1); 
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
                id=i;
            }
        }
        ans+=d[id];
        cout<<ans-1<<endl;
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int t,n,u,v,d[200055],maxx,id,ans,vis[200055];
vector<int> to[200055];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>t;
    while(t--){
        maxx=0,ans=0;
        cin>>n;
        for(int i=1;i<=n;i++) vis[i]=0,to[i].clear(),d[i]=0;
        for(int i=1;i<n;i++){
            cin>>u>>v;
            to[u].push_back(v);
            to[v].push_back(u);
            d[u]++,d[v]++;
        }
        maxx=*max_element(d+1,d+n+1); 
        vector<int> m1;
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
            }
        }
        for(int i=1;i<n;i++){
            if(d[i]==maxx){
                m1.push_back(i);
                vis[i]=1;
            }
        }
        for(int i=0;i<m1.size();i++){
            int x=m1[i];
            int tmp=0;
            for(int j=0;j<to[x].size();j++){
                int y=to[x][j];
                tmp+=vis[y];
            }
            if(tmp<=1){
                id=x;
                break;
            }
        }
        ans+=d[id];
        for(int i=0;i<to[id].size();i++){
            int y=to[id][i];
            d[y]--;
        }
        d[id]=0;
        maxx=*max_element(d+1,d+n+1); 
        for(int i=1;i<=n;i++){
            if(d[i]>maxx){
                maxx=d[i];
                id=i;
            }
        }
        ans+=d[id];
        cout<<ans-1<<endl;
    }
    return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int t,n,u,v,d[200055],maxx,id,ans,vis[200055];
vector<int> to[200055];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin>>t;
    while(t--){
        maxx=0;
        ans=0;
        cin>>n;
        for(int i=1;i<=n;i++) vis[i]=0,to[i].clear(),d[i]=0;
        for(int i=1;i<n;i++){
            cin>>u>>v;
            to[u].push_back(v);
            to[v].push_back(u);
            d[u]++, d[v]++;
        }
        maxx=*max_element(d+1,d+n+1); 
        vector<int> m1;
        for(int i=1;i<=n;i++){
            if(d[i]==maxx){
                m1.push_back(i);
                vis[i]=1;
            }
        }
        for(int i=0;i<m1.size();i++){
            int x=m1[i];
            int tmp=0;
            for(int j=0;j<to[x].size();j++){
                int y=to[x][j];
                tmp+=vis[y];
            }
            if(tmp<=1){
                id=x;
                break;
            }
        }
        ans+=d[id];
        for(int i=0;i<to[id].size();i++){
            int y=to[id][i];
            d[y]--;
        }
        d[id]=0;
        maxx=*max_element(d+1,d+n+1);
        
        for(int i=1;i<=n;i++){
            if(d[i]==maxx){
                id=i;
                break;
            }
        }
        ans+=d[id];
        cout<<ans-1<<endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define vint vector<int>
#define df double
#define pb push_back
#define fs first
#define sc second
#define pii pair<int,int>
#define vll vector<long long>
#define fr(k,i,n) for(int i=k;i<n;i++)
#define f0(i,n) for(int i=0;i<n;i++)
#define M 1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int _;
    cin>>_;
    f0(__,_){
        int32_t l,r,m=0,h;
        cin>>l>>r;
        for(int i=31;i>=0;i--){
            if((r>>i)&1){h=i;break;}
        }
        f0(i,h+1){
            bool a=((l>>i)&1),b=((r>>i)&1);
            if(a==0&&b==0){m=m|(1<<i);}
        }
        cout<<l<<' '<<r<<' '<<m<<'\n';
    }
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define ll long long
#define vint vector<int>
#define df double
#define pb push_back
#define fs first
#define sc second
#define pii pair<int,int>
#define vll vector<long long>
#define fr(k,i,n) for(int i=k;i<n;i++)
#define f0(i,n) for(int i=0;i<n;i++)
#define M 1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int _;
    cin>>_;
    f0(__,_){
        int32_t l,r,h,x,y,z;
        cin>>l>>r;
        for(int i=31;i>=0;i--){
            bool a=(l>>i)&1,b=(r>>i)&1;
            if(a!=b){h=i;break;}
        }
        x=l|((1<<h)-1),y=x+1,z=(x==l?r:l);
        cout<<y<<' '<<x<<' '<<z<<'\n';
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define vint vector<int>
#define df double
#define pb push_back
#define fs first
#define sc second
#define pii pair<int,int>
#define vll vector<long long>
#define fr(k,i,n) for(int i=k;i<n;i++)
#define f0(i,n) for(int i=0;i<n;i++)
#define M 1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int _;
    cin>>_;
    f0(__,_){
        int32_t l,r,m=0,h;
        cin>>l>>r;
        for(int i=31;i>=0;i--){
            if((r>>i)&1){h=i;break;}
        }
        f0(i,h+1){
            bool a=((l>>i)&1),b=((r>>i)&1);
            if(!(a&b)){m=m|(1<<i);}
        }
        cout<<m<<'\n';
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define vint vector<int>
#define df double
#define pb push_back
#define fs first
#define sc second
#define pii pair<int,int>
#define vll vector<long long>
#define fr(k,i,n) for(int i=k;i<n;i++)
#define f0(i,n) for(int i=0;i<n;i++)
#define M 1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int _;
    cin>>_;
    f0(__,_){
        int32_t l,r,m=0,h;
        cin>>l>>r;
        for(int i=31;i>=0;i--){
            if((r>>i)&1){h=i;break;}
        }
        f0(i,h+1){
            bool a=((l>>i)&1),b=((r>>i)&1);
            if(!(a&b)){m=m|(1<<i);}
        }
        if(!l){m=r-1;}
        cout<<l<<' '<<r<<' '<<m<<'\n';
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define vint vector<int>
#define df double
#define pb push_back
#define fs first
#define sc second
#define pii pair<int,int>
#define vll vector<long long>
#define fr(k,i,n) for(int i=k;i<n;i++)
#define f0(i,n) for(int i=0;i<n;i++)
#define M 1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int _;
    cin>>_;
    f0(__,_){
        int32_t l,r,m=0,h;
        cin>>l>>r;
        for(int i=31;i>=0;i--){
            if((r>>i)&1){h=i;break;}
        }
        f0(i,h+1){
            bool a=((l>>i)&1),b=((r>>i)&1);
            if(a==0&&b==0){m=m|(1<<i);}
        }
        cout<<l<<' '<<r<<' '<<m<<'\n';
    }
    return 0;
}