ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 8):

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#define Int long long
using namespace std;
void solve(){
     int n; cin>>n;
     vector<int> a(n);
     bool flag=false;

     for(int i=0;i<n;i++)
      cin>>a[i];

      for(int i=0;i<n-1;i++){
       
        if(!is_sorted(a.begin(),a.end())) {
            int ele= min(a[i],a[i+1]);
              a[i]-=ele;
              a[i+1]-=ele;

              
        }

        if(is_sorted(a.begin(),a.end())){
                cout<<"YES"<<endl;
                return;
              }

      }
      
    cout<<"NO"<<endl;
}
 int main(){
      int t; cin>>t;
      while(t--){
            
            solve();
            }
 
            return 0;
}
 


Submission (verdict: Time limit exceeded on test 8):

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#define Int long long
using namespace std;
void solve(){
     int n; cin>>n;
     vector<int> a(n);
     bool flag=false;

     for(int i=0;i<n;i++)
      cin>>a[i];

      for(int i=0;i<n-1;i++){
       
        if(!is_sorted(a.begin(),a.end())) {
            int ele= min(a[i],a[i+1]);
              a[i]-=ele;
              a[i+1]-=ele;

              
        }
        else{
                cout<<"YES"<<endl;
                return;
              }

      }
      
    cout<<"NO"<<endl;
}
 int main(){
      int t; cin>>t;
      while(t--){
            
            solve();
            }
 
            return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 8):

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#define Int long long
using namespace std;
void solve(){
     int n; cin>>n;
     vector<int> a(n);
     bool flag=false;

     for(int i=0;i<n;i++)
      cin>>a[i];

      for(int i=0;i<n-1;i++){
       
        if(!is_sorted(a.begin(),a.end())) {
            int ele= min(a[i],a[i+1]);
              a[i]-=ele;
              a[i+1]-=ele;

              
        }

        if(is_sorted(a.begin(),a.end())){
                cout<<"YES"<<endl;
                return;
              }

      }
      
    cout<<"NO"<<endl;
}
 int main(){
      int t; cin>>t;
      while(t--){
            
            solve();
            }
 
            return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 8):

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#define Int long long
using namespace std;
void solve(){
     int n; cin>>n;
     vector<int> a(n);
     bool flag=false;

     for(int i=0;i<n;i++)
      cin>>a[i];

      for(int i=0;i<n-1;i++){
       
        if(!is_sorted(a.begin(),a.end())) {
            int ele= min(a[i],a[i+1]);
              a[i]-=ele;
              a[i+1]-=ele;

              
        }
        else{
                cout<<"YES"<<endl;
                return;
              }

      }
      
    cout<<"NO"<<endl;
}
 int main(){
      int t; cin>>t;
      while(t--){
            
            solve();
            }
 
            return 0;
}
 


Submission (verdict: Accepted):
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#define Int long long
using namespace std;
void solve(){
     int n; cin>>n;
     vector<int> a(n);
     bool flag=false;

     for(int i=0;i<n;i++)
      cin>>a[i];

      for(int i=0;i<n-1;i++){
       
     
            int ele= min(a[i],a[i+1]);
              a[i]-=ele;
              a[i+1]-=ele;

              
        }

        if(is_sorted(a.begin(),a.end())){
                cout<<"YES"<<endl;
                return;
              }

      
      
    cout<<"NO"<<endl;
}
 int main(){
      int t; cin>>t;
      while(t--){
            
            solve();
            }
 
            return 0;
}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


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

using namespace std;

 

typedef long long ll;

typedef unsigned long long ull; 

typedef pair<int, int> pii;

typedef pair<double, double> pdd;

typedef pair<long long, long long> pll;

typedef vector<int> vi;

typedef vector<long long> vll;

typedef map<int, int> mii;

typedef vector<vector<int>> vvi;

typedef vector<vector<long long>> vvll;

#define f(i, a, b, j) for(int i = int(a); i < int(b); i = i + int(j))

#define M map

#define V vector

#define P pair

#define all(a) a.begin(), a.end() 

#define rall(a) a.rbegin(), a.rend() 

#define nl "\n"

#define pb push_back

#define mp make_pair

#define reset(a, b) memset(a, int(b), sizeof(a))

#define MOD1 (ll)1000000007

#define MOD2 (ll)998244353



ll mod = MOD1;

ll power(ll a,ll b){

    ll res = 1;

    while(b){

        if(b & 1){

            res *= a;

            res %= mod;

        }

        a *= a;

        a %= mod;

         b >>= 1;

    }

    return res;

}

ll inverse(ll a){

    return power(a,mod - 2);

}



void solve(){

    ll n, x, y;

    cin >> n >> x >> y;

    x--;

    y--;

    if(abs(x - y) == 1 or abs(x - y) == n-1){

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

            cout << (i % 2) << " ";

        }

        if(n % 2){

            cout << 2 << " ";

        }

        cout << nl;

        return;

    }

    if(n % 2){

        ll curr = 0;

        vll val(n);

        val[x] = 2;

        for(int i = (x + 1) % n; i != x;){

            val[i] = curr;

            curr = (1 - curr);

            i++;

            i %= n;

        }

        for(auto e : val){

            cout << e << " ";

        }

        cout << nl;

        return;

    }

    // n even

    vll val(n);

    val[x] = 1;

    val[(x + 1) % n] = 2;

    val[(x + n - 1) % n] = 2;

    ll curr = ((ll)abs(x - y) % 2);

    for(int i = (x + 2) % n; i != (x + n - 1) % n; ){

        val[i] = curr;

        curr = (1 - curr);

        i++;

        i %= n;

    }

    for(auto e : val){

        cout << e << " ";

    }

    cout << nl;

    return;

}

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t;

    cin >> t;

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

        solve();

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

#include <unordered_set>



using namespace std;



int min (int a, int b) {return a<b ? a : b;}

int max (int a, int b) {return a>b ? a : b;}



int main () {

    int t;



    cin >> t;

    while (t--) {

        unsigned long long n;

        cin >> n;

        int sum=0;

        int sum_two=0, sum_six=0;

        while (n>0) {

            int digit = n%10;

            //cout << digit << endl;

            sum += digit;

            if (digit==2) {sum_two++;}

            if (digit==3) {sum_six++;}

            n /= 10;

        }

        unordered_set<int> possible_remainders;

        //cout << sum_two << ' ' << sum_six << endl;



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

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

                //cout << i << ' ' << j << endl;

                int sum = 2*(i) + 6*(j);

                //cout << sum << endl;

                possible_remainders.insert(sum%9);

            }

        }



        

        int found=0;

        for (auto &x: possible_remainders) {

            //cout << x << endl;

            if (((sum%9)+x)%9==0) {

                //cout << x << ' ' << sum << endl;

                cout << "YES" << endl;

                found=1;

                break;

            }

        }

        if (!found) cout << "NO" << endl;

    }

}

Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>

#include <unordered_set>



using namespace std;



int min (int a, int b) {return a<b ? a : b;}

int max (int a, int b) {return a>b ? a : b;}



int main () {

    int t;



    cin >> t;

    while (t--) {

        string n;

        cin >> n;

        int sum=0;

        int sum_two=0, sum_six=0;

        //cout << n;

        for (int i=n.length()-1; i>=0; i--) {

            int digit = n[i] - '0';

            //cout << digit << endl;

            sum += digit;

            if (digit==2) {sum_two++;}

            if (digit==3) {sum_six++;}

        }

        unordered_set<int> possible_remainders;

        //cout << sum_two << ' ' << sum_six << endl;



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

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

                //cout << i << ' ' << j << endl;

                int sum = 2*(i) + 6*(j);

                //cout << sum << endl;

                possible_remainders.insert(sum%9);

            }

        }



        

        int found=0;

        for (auto &x: possible_remainders) {

            //cout << x << endl;

            if (((sum%9)+x)%9==0) {

                //cout << x << ' ' << sum << endl;

                cout << "YES" << endl;

                found=1;

                break;

            }

        }

        if (!found) cout << "NO" << endl;

    }

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

#include <unordered_set>



using namespace std;



int min (int a, int b) {return a<b ? a : b;}

int max (int a, int b) {return a>b ? a : b;}



int main () {

    int t;



    cin >> t;

    while (t--) {

        long long n;

        cin >> n;

        int sum=0;

        int sum_two=0, sum_six=0;

        while (n>0) {

            int digit = n%10;

            //cout << digit << endl;

            sum += digit;

            if (digit==2) {sum_two++;}

            if (digit==3) {sum_six++;}

            n /= 10;

        }

        unordered_set<int> possible_remainders;

        //cout << sum_two << ' ' << sum_six << endl;



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

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

                //cout << i << ' ' << j << endl;

                int sum = 2*(i) + 6*(j);

                //cout << sum << endl;

                possible_remainders.insert(sum%9);

            }

        }



        

        int found=0;

        for (auto &x: possible_remainders) {

            //cout << x << endl;

            if (((sum%9)+x)%9==0) {

                //cout << x << ' ' << sum << endl;

                cout << "YES" << endl;

                found=1;

                break;

            }

        }

        if (!found) cout << "NO" << endl;

    }

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

#include <unordered_set>



using namespace std;



int min (int a, int b) {return a<b ? a : b;}

int max (int a, int b) {return a>b ? a : b;}



int main () {

    int t;



    cin >> t;

    while (t--) {

        long long n;

        cin >> n;

        int sum=0;

        int sum_two=0, sum_six=0;

        while (n>0) {

            int digit = n%10;

            //cout << digit << endl;

            sum += digit;

            if (digit==2) {sum_two++;}

            if (digit==3) {sum_six++;}

            n /= 10;

        }

        unordered_set<int> possible_remainders;

        //cout << sum_two << ' ' << sum_six << endl;



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

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

                //cout << i << ' ' << j << endl;

                int sum = 2*(i) + 6*(j);

                //cout << sum << endl;

                possible_remainders.insert(sum%9);

            }

        }



        

        int found=0;

        for (auto &x: possible_remainders) {

            //cout << x << endl;

            if (((sum%9)+x)%9==0) {

                //cout << x << ' ' << sum << endl;

                cout << "YES" << endl;

                found=1;

                break;

            }

        }

        if (!found) cout << "NO" << endl;

    }

}

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

#include <unordered_set>



using namespace std;



int min (int a, int b) {return a<b ? a : b;}

int max (int a, int b) {return a>b ? a : b;}



int main () {

    int t;



    cin >> t;

    while (t--) {

        unsigned long long n;

        cin >> n;

        int sum=0;

        int sum_two=0, sum_six=0;

        while (n>0) {

            int digit = n%10;

            //cout << digit << endl;

            sum += digit;

            if (digit==2) {sum_two++;}

            if (digit==3) {sum_six++;}

            n /= 10;

        }

        unordered_set<int> possible_remainders;

        //cout << sum_two << ' ' << sum_six << endl;



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

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

                //cout << i << ' ' << j << endl;

                int sum = 2*(i) + 6*(j);

                //cout << sum << endl;

                possible_remainders.insert(sum%9);

            }

        }



        

        int found=0;

        for (auto &x: possible_remainders) {

            //cout << x << endl;

            if (((sum%9)+x)%9==0) {

                //cout << x << ' ' << sum << endl;

                cout << "YES" << endl;

                found=1;

                break;

            }

        }

        if (!found) cout << "NO" << endl;

    }

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>

#include <unordered_set>



using namespace std;



int min (int a, int b) {return a<b ? a : b;}

int max (int a, int b) {return a>b ? a : b;}



int main () {

    int t;



    cin >> t;

    while (t--) {

        string n;

        cin >> n;

        int sum=0;

        int sum_two=0, sum_six=0;

        //cout << n;

        for (int i=n.length()-1; i>=0; i--) {

            int digit = n[i] - '0';

            //cout << digit << endl;

            sum += digit;

            if (digit==2) {sum_two++;}

            if (digit==3) {sum_six++;}

        }

        unordered_set<int> possible_remainders;

        //cout << sum_two << ' ' << sum_six << endl;



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

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

                //cout << i << ' ' << j << endl;

                int sum = 2*(i) + 6*(j);

                //cout << sum << endl;

                possible_remainders.insert(sum%9);

            }

        }



        

        int found=0;

        for (auto &x: possible_remainders) {

            //cout << x << endl;

            if (((sum%9)+x)%9==0) {

                //cout << x << ' ' << sum << endl;

                cout << "YES" << endl;

                found=1;

                break;

            }

        }

        if (!found) cout << "NO" << endl;

    }

}

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

#include <unordered_set>



using namespace std;



int min (int a, int b) {return a<b ? a : b;}

int max (int a, int b) {return a>b ? a : b;}



int main () {

    int t;



    cin >> t;

    while (t--) {

        string n;

        cin >> n;

        int sum=0;

        int sum_two=0, sum_six=0;

        //cout << n;

        for (int i=n.length()-1; i>=0; i--) {

            int digit = n[i] - '0';

            //cout << digit << endl;

            sum += digit;

            if (digit==2) {sum_two++;}

            if (digit==3) {sum_six++;}

        }

        unordered_set<int> possible_remainders;

        //cout << sum_two << ' ' << sum_six << endl;



        for (int i=0; i<=min(sum_two, 9); i++) {

            for (int j=0; j<=min(sum_six, 9); j++) {

                //cout << i << ' ' << j << endl;

                int sum = 2*(i) + 6*(j);

                //cout << sum << endl;

                possible_remainders.insert(sum%9);

            }

        }



        

        int found=0;

        for (auto &x: possible_remainders) {

            //cout << x << endl;

            if (((sum%9)+x)%9==0) {

                //cout << x << ' ' << sum << endl;

                cout << "YES" << endl;

                found=1;

                break;

            }

        }

        if (!found) cout << "NO" << endl;

    }

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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <set>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll  long long
// const ll MOD = 998244353 ;
// inline ll mul(ll a1, ll a2) { return ((a1 * a2) % MOD); }
// inline ll sum(ll a1, ll a2) { return ((a1 + a2) % MOD); }
// inline ll sub(ll a1, ll a2) { return  ((a1 - a2 + MOD) % MOD); }
int main() {
    IOS
    int test ;
    cin>>test;
    while(test--) {
        ll l , r ;
        cin>>l>>r;
        ll z = 1 ,  x = l ^ r ;
        while( x % z == 0 ) {
            z *= 2 ;
        }
        z /= 2 ;
        x = z ;
        z *= (r/z) ;
        if(z<=l) {
            z +=x ;
        }
        ll a1 = z , a2 = z - 1 , a3;
        ll max = -1  ;
        for( int i = l ; i <= r ; i++ ) {
            if ((i==a1)or(i==a2)) {
                continue ;
            }
            if ((i^a1)+(i^a2)>max) {
                max = i^a1 + i^a2 ;
                a3 = i ;
            }
        }
        cout<<a1<<" "<<a2<<" "<<a3<<endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <set>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll  long long
// const ll MOD = 998244353 ;
// inline ll mul(ll a1, ll a2) { return ((a1 * a2) % MOD); }
// inline ll sum(ll a1, ll a2) { return ((a1 + a2) % MOD); }
// inline ll sub(ll a1, ll a2) { return  ((a1 - a2 + MOD) % MOD); }
int main() {
    IOS
    int test ;
    cin>>test;
    while(test--) {
        ll l , r ;
        cin>>l>>r;
        ll z = 1 ,  x = l ^ r ;
        while( x % z == 0 ) {
            z *= 2 ;
        }
        z /= 2 ;
        ll a1 = l | (z-1) , a2 = a1 + 1 , a3;
        ll max = -1  ;
        for( int i = l ; i <= r ; i++ ) {
            if ((i==a1)or(i==a2)) {
                continue ;
            }
            if ((i^a1)+(i^a2)>max) {
                max = i^a1 + i^a2 ;
                a3 = i ;
            }
        }
        cout<<a1<<" "<<a2<<" "<<a3<<endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <set>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll  long long
const ll MOD = 998244353 ;
inline ll mul(ll a1, ll a2) { return ((a1 * a2) % MOD); }
inline ll sum(ll a1, ll a2) { return ((a1 + a2) % MOD); }
// inline ll sub(ll a1, ll a2) { return  ((a1 - a2 + MOD) % MOD); }
int main() {
    IOS
    int test ;
    cin>>test;
    while(test--) {
        ll l , r ;
        cin>>l>>r;
        ll z = 1 ;
        while (z<=r) {
            z *= 2 ;
        }
        z /= 2 ;
        ll a1 , a2 , a3 ;
        if (z > l) {
            a1 = z ;
            a2 = z-1 ;
        }else {
            a1 = l ;
            a2 = l + 1 ;
        }
        ll max = 0 ;
        for (ll i = l ; i <= r ; i++) {
            if((i == a2)or(i==a1)) {
                continue ;
            }
            if ( ((a1^a2)+(a2^i)+(a1^i)) >= max) {
                max = (a1^a2)+(a2^i)+(a1^i) ;
                a3 = i ;
            }
        }
        cout<<a1<<" "<<a2<<" "<<a3<<endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <set>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll  long long
// const ll MOD = 998244353 ;
// inline ll mul(ll a1, ll a2) { return ((a1 * a2) % MOD); }
// inline ll sum(ll a1, ll a2) { return ((a1 + a2) % MOD); }
// inline ll sub(ll a1, ll a2) { return  ((a1 - a2 + MOD) % MOD); }
int main() {
    IOS
    int test ;
    cin>>test;
    while(test--) {
        ll l , r ;
        cin>>l>>r;
        ll z = 1 ,  x = l ^ r ;
        while( x % z == 0 ) {
            z *= 2 ;
        }
        z /= 2 ;
        ll a1 = l | (z-1) , a2 = a1 + 1 , a3;
        ll max = -1  ;
        for( int i = l ; i <= r ; i++ ) {
            if ((i==a1)or(i==a2)) {
                continue ;
            }
            if ((i^a1)+(i^a2)>max) {
                max = i^a1 + i^a2 ;
                a3 = i ;
            }
        }
        cout<<a1<<" "<<a2<<" "<<a3<<endl;
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 3):
#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <set>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll  long long
// const ll MOD = 998244353 ;
// inline ll mul(ll a1, ll a2) { return ((a1 * a2) % MOD); }
// inline ll sum(ll a1, ll a2) { return ((a1 + a2) % MOD); }
// inline ll sub(ll a1, ll a2) { return  ((a1 - a2 + MOD) % MOD); }
int main() {
    IOS
    int test ;
    cin>>test;
    while(test--) {
        ll l , r ;
        cin>>l>>r;
        ll z = 1 ,  x = l ^ r ;
        int k = 31 - __builtin_clz(l ^ r);
        z = 1 << k ;
        ll a1 = l | (z-1) , a2 = a1 + 1 , a3;
        ll max = -1  ;
        for( int i = l ; i <= r ; i++ ) {
            if ((i==a1)or(i==a2)) {
                continue ;
            }
            if ((i^a1)+(i^a2)>max) {
                max = i^a1 + i^a2 ;
                a3 = i ;
            }
        }
        cout<<a1<<" "<<a2<<" "<<a3<<endl;
    }
    return 0;
}