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

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

#define int long long
#define vi vector<int>
#define f(i, a, n) for (int i = a; i < n; i++)
#define pb push_back


int32_t main() {
    int t;
    cin >> t;
    while (t--) {
      int n;
      cin>>n;
      vi v(n);
      f(i,0,n)cin>>v[i];
      if(v[0]>v[1]){
        cout<<"NO\n";
        continue;
      }
      int flg=0;
      f(i,1,n){
        if(i==n-1 && v[i]<v[i-1]){
            cout<<"NO\n";
            flg++;
            break;
        }
        else if(v[i]-v[i-1]>v[i+1]){
            cout<<"NO\n";
            flg++;
            break;
        }
        v[i]=v[i]-v[i-1];
      }
      if(flg==0)cout<<"YES\n";
    }
    return 0;
}


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

#define int long long
#define vi vector<int>
#define f(i, a, n) for (int i = a; i < n; i++)
#define pb push_back


int32_t main() {
    int t;
    cin >> t;
    while (t--) {
      int n;
      cin>>n;
      vi v(n);
      f(i,0,n)cin>>v[i];
      if(v[0]>v[1]){
        cout<<"NO\n";
        continue;
      }
      int flg=0;
      f(i,1,n){
        if(i==n-1 ){
            if(v[i]<v[i-1]){
                cout<<"NO\n";
                flg++;
                break;
            }
            
        }
        else if(v[i]-v[i-1]>v[i+1]){
            cout<<"NO\n";
            flg++;
            break;
        }
        v[i]=v[i]-v[i-1];
      }
      if(flg==0)cout<<"YES\n";
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

#define int long long
#define vi vector<int>
#define f(i, a, n) for (int i = a; i < n; i++)
#define pb push_back


int32_t main() {
    int t;
    cin >> t;
    while (t--) {
      int n;
      cin>>n;
      vi v(n);
      f(i,0,n)cin>>v[i];
      if(v[0]>v[1]){
        cout<<"NO\n";
        continue;
      }
      int flg=0;
      f(i,1,n){
        if(v[i]-v[i-1]>v[i+1]){
            cout<<"NO\n";
            flg++;
            break;
        }
        v[i]=v[i]-v[i-1];
      }
      if(flg==0)cout<<"YES\n";
    }
    return 0;
}


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

#define int long long
#define vi vector<int>
#define f(i, a, n) for (int i = a; i < n; i++)
#define pb push_back


int32_t main() {
    int t;
    cin >> t;
    while (t--) {
      int n;
      cin>>n;
      vi v(n);
      f(i,0,n)cin>>v[i];
      if(v[0]>v[1]){
        cout<<"NO\n";
        continue;
      }
      int flg=0;
      f(i,1,n){
        if(i==n-1 && v[i]<v[i-1]){
            cout<<"NO\n";
            flg++;
            break;
        }
        else if(v[i]-v[i-1]>v[i+1]){
            cout<<"NO\n";
            flg++;
            break;
        }
        v[i]=v[i]-v[i-1];
      }
      if(flg==0)cout<<"YES\n";
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

#define int long long
#define vi vector<int>
#define f(i, a, n) for (int i = a; i < n; i++)
#define pb push_back


int32_t main() {
    int t;
    cin >> t;
    while (t--) {
      int n;
      cin>>n;
      vi v(n);
      f(i,0,n)cin>>v[i];
      if(v[0]>v[1]){
        cout<<"NO\n";
        continue;
      }
      int flg=0;
      f(i,1,n){
        if(v[i]-v[i-1]>v[i+1]){
            cout<<"NO\n";
            flg++;
            break;
        }
        v[i]=v[i]-v[i-1];
      }
      if(flg==0)cout<<"YES\n";
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#include<bits/stdc++.h>
using namespace std;


int main() {
     int t;
     cin>>t;
     while(t--){
        int n,m;
        cin>>n>>m;
        vector<int>a(n);
        vector<int>b(m);

         map<int,int>have;

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

         map<int,int>req;

        for(int i=0;i<m;i++){
             cin>>b[i];

             req[b[i]]++;

        }

        bool f=1;

        bool g=1;


        for(auto it=req.rbegin();it!=req.rend();it++){
            
           
           int x=it->first;
           int freq=(it->second)-have[x];

           if(x<=0) break;

           if(freq<0) {
            f=0;
            break;
           }
             g=1;
           if(freq>0) g=0;

           if(x%2==0){
             req[x/2]+=freq*2;
           }else{
            req[x/2]+=freq;
            req[x/2+1]+=freq;
           }

        }

        if(!g || !f){
            cout<<"no"<<endl;
        }else{
            cout<<"yes"<<endl;
        }


     }
    return 0;
}

Submission (verdict: Time limit exceeded on test 14):
#include<bits/stdc++.h>
using namespace std;


int main() {
     int t;
     cin>>t;
     while(t--){
        int n,m;
        cin>>n>>m;

        vector<int>a(n);
        vector<int>b(m);

         map<int,int>have;

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

         map<int,int>req;

        for(int i=0;i<m;i++){
             cin>>b[i];

             req[b[i]]++;

        }

        bool f=1;

        bool g=1;

        int x,freq;
        for(auto it=req.rbegin();it!=req.rend();it++){
        
           x=it->first;
           freq=(it->second)-have[x];

           if(x<=0) break;

           if(freq<0) {
            f=0;
            break;
           }
             g=1;
           if(freq>0) g=0;

           if(x%2==0){
             req[x/2]+=freq*2;
           }else{
            req[x/2]+=freq;
            req[x/2+1]+=freq;
           }

        }

        if(!g || !f){
            cout<<"no"<<endl;
        }else{
            cout<<"yes"<<endl;
        }


     }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#include<bits/stdc++.h>
using namespace std;


int main() {
     int t;
     cin>>t;
     while(t--){
        int n,m;
        cin>>n>>m;

        vector<int>a(n);
        vector<int>b(m);

         map<int,int>have;

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

         map<int,int>req;

        for(int i=0;i<m;i++){
             cin>>b[i];

             req[b[i]]++;

        }

        bool f=1;

        bool g=1;

        int x,freq;
        for(auto it=req.rbegin();it!=req.rend();it++){
        
           x=it->first;
           freq=(it->second)-have[x];

           if(x<=0) break;

           if(freq<0) {
            f=0;
            break;
           }
             g=1;
           if(freq>0) g=0;

           if(x%2==0){
             req[x/2]+=freq*2;
           }else{
            req[x/2]+=freq;
            req[x/2+1]+=freq;
           }

        }

        if(!g || !f){
            cout<<"no"<<endl;
        }else{
            cout<<"yes"<<endl;
        }


     }
    return 0;
}

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


int main() {
     int t;
     cin>>t;
     while(t--){
        int n,m;
        cin>>n>>m;

        vector<int>a(n);
        vector<int>b(m);

         map<int,int>req;

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

        for(int i=0;i<m;i++){
             cin>>b[i];

             req[b[i]]++;

        }

        bool f=1;

        bool g=1;

        int x,freq;
        for(auto it=req.rbegin();it!=req.rend();it++){
        
           x=it->first;
           freq=it->second;

           if(x<=0) break;

           if(freq<0) {
            f=0;
            break;
           }
             g=1;
           if(freq>0) g=0;

           if(x%2==0){
             req[x/2]+=freq*2;
           }else{
            req[x/2]+=freq;
            req[x/2+1]+=freq;
           }

        }

        if(!g || !f){
            cout<<"no"<<endl;
        }else{
            cout<<"yes"<<endl;
        }


     }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 14):
#include<bits/stdc++.h>
using namespace std;


int main() {
     int t;
     cin>>t;
     while(t--){
        int n,m;
        cin>>n>>m;
        vector<int>a(n);
        vector<int>b(m);

         map<int,int>have;

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

         map<int,int>req;

        for(int i=0;i<m;i++){
             cin>>b[i];

             req[b[i]]++;

        }

        bool f=1;

        bool g=1;


        for(auto it=req.rbegin();it!=req.rend();it++){
            
           
           int x=it->first;
           int freq=(it->second)-have[x];

           if(x<=0) break;

           if(freq<0) {
            f=0;
            break;
           }
             g=1;
           if(freq>0) g=0;

           if(x%2==0){
             req[x/2]+=freq*2;
           }else{
            req[x/2]+=freq;
            req[x/2+1]+=freq;
           }

        }

        if(!g || !f){
            cout<<"no"<<endl;
        }else{
            cout<<"yes"<<endl;
        }


     }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef ONLINE_JUDGE
#include "debugg.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// used to create indexed set where we can declare a indexed set as indexed_set
// s.find_by_order(2) returns an iterator pointing to the element with index 2 in the set based on 0-based indexing like arrays
// s.order_of_key(7) return the index of the element 7 in the set and if not there it returns what position it would be at
// order_of_key(x) returns essentially the number of elements less than x in the set
// find_by_order(x) returns the xth largest element in set
#define endl "\n"
#define set_bits __builtin_popcountll
#define pb push_back
#define fast() ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll>>
#define my_sort(v) sort(v.begin(),v.end())
#define my_reverse_sort(v) sort(v.rbegin(),v.rend())
#define print(v) for(auto it:v)cout<<it<<" "
#define int ll
#define all(a) a.begin(),a.end()


signed main()
{
    fast();
    ll n;cin>>n;
    ll ans=0;
    for(int i=0;i<n;i++) ans+=i;
    vll order(n+1);
    map<ll,ll>mp;
    for(int i=0;i<n;i++){
        ll a;cin>>a;
        order[i+1]=a;
        mp[a]=i+1;
    }
    for(int i=1;i<=n;i++){
        ans+=max(0LL,(n-i+1)-mp[i]);
    }
    map<ll,ll>pos;
    for(int i=1;i<=n;i++) pos[i]=n-i+1;
    for(int i=2;i<=n;i++){
        for(int j=1;j<i;j++){
            cout<<i<<" "<<j<<endl;
        }
    }
    debug(order);
    for(int i=1;i<=n;i++){
        ll go=order[i];
        for(int j=go+1;j<=n;j++){
            if(pos[j]<pos[go] && pos[go]>mp[go]){
                cout<<go<<" "<<j<<endl;
                pos[go]--;
                pos[j]++;
            }
        }
    }
    cout<<ans<<endl;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

using namespace std;

#define int long long



int32_t main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    

    int t;

    cin >> t;

    while(t--){

        int n, m;

        cin >> n >> m;

        vector<int> a(n), b(m);

        unordered_map<int, int> mp;

        int suma = 0, sumb = 0;

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

            cin >> a[i];

            mp[a[i]]++;

            suma += a[i];

        }

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

            cin >> b[i];

            sumb += b[i];

        }

        if(suma != sumb){

            cout << "No" << "\n";

            continue;

        }

        map<int, int, greater<int>> curr;

        for(auto x : b) curr[x]++;

        bool possible = true;

        while(!curr.empty()){

            auto it = curr.begin();

            int x = it->first, cnt = it->second;

            curr.erase(it);

            if(mp.count(x)){

                int use = min(mp[x], cnt);

                mp[x] -= use;

                cnt -= use;

                if(mp[x] == 0)

                    mp.erase(x);

            }

            if(cnt == 0)

                continue;

            if(x == 1){

                possible = false;

                break;

            }

            int left = x / 2, right = (x + 1) / 2;

            curr[left] += cnt;

            curr[right] += cnt;

        }

        if(!mp.empty())

            possible = false;

        cout << (possible ? "Yes" : "No") << "\n";

    }

    return 0;

}



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

using namespace std;

#define int long long



int32_t main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);



    int t = 1;

    cin >> t;

    while(t--){

        int n, m;

        cin >> n >> m;

        vector<int> a(n), b(m);

        multiset<int>sa,sb;

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

            cin>>a[i];

            sa.insert(a[i]);

        }

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

            cin>>b[i];

            sb.insert(b[i]);

        }

        bool flag=true;

        while(!sa.empty()&&!sb.empty()&&flag){

            int x=*sb.begin();

            if(sa.find(x)!=sa.end()){

                sa.erase(sa.find(x));

                sb.erase(sb.begin());

                continue;

            }

            else{

                if(x==1||x==0){

                    flag=false;

                    break;

                }

                if(x%2==0){

                sb.insert(x/2);

                  sb.insert(x/2);

                }

                else{

                    sb.insert(x/2);

                    sb.insert(x/2+1);

                }

                sb.erase(sb.find(x));

            }

        }

          if(flag&&sb.empty()&&sa.empty())cout<<"Yes"<<endl;

           else cout<<"No"<<endl;

    }

 



    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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

using namespace std;

#define int long long



bool fun(unordered_map<int, int>& mp, int x) {

    if (x < 1) {

        return false;

    }

    

    if (mp.find(x) != mp.end() && mp[x] > 0) {

        mp[x]--;

        return true;

    }

    if(x==1){

        return false;

    }



    

    int left = 0, right = 0;

    if (x % 2 == 0) {

        left = x / 2;

        right = x / 2;

    } else {

        left = x / 2;

        right = (x / 2) + 1;

    }

    

    if(fun(mp, left)&&fun(mp,right)){

        return true;

    }    

    return false;

}



int32_t main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);



    int t = 1;

    cin >> t;

    while(t--){

        int n, m;

        cin >> n >> m;

        vector<int> a(n), b(m);

        unordered_map<int, int> mp;

        

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

            cin >> a[i];

            mp[a[i]]++;

        }

        

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

            cin >> b[i];

        }

        

        bool flag = true;

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

            bool f = fun(mp, b[i]);

            if (!f) {

                flag = false;

                break;

            }

        }

        bool allUsed = true;

        for (auto &p : mp) {

            if (p.second != 0) {

                allUsed = false;

                break;

            }

        }

        

        if (!allUsed) {

            flag = false;

        }

        

        

        if (flag) {

            cout << "Yes" << endl;

        } else {

            cout << "No" << endl;

        }

    }

    

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 8):
#include<iostream>

#include<bits/stdc++.h>

#define int long long

using namespace std;

signed main(){

    cin.tie(0);

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        int l=s.length();

        int h=1;

        while(h){

            h=0;

            for(int i=l-1;i>0;i--){

                if(s[i]-s[i-1]>1){

                    int temp=s[i];

                    s[i]=s[i-1];

                    s[i-1]=temp-1;

                }

            }

            for(int i=l-1;i>0;i--){

                if(s[i]-s[i-1]>1){

                    h++;

                }

            }

        }

        cout<<s<<endl;

    }

}

Submission (verdict: Accepted):
#include<iostream>

#include<bits/stdc++.h>

#define int long long

using namespace std;

signed main(){

    cin.tie(0);

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        int l=s.length();

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

            int best=s[i];int pos=i;

            for(int j=i;j<min(i+10,(int)l);j++){

                if(s[j]-j+i>best){

                    best=s[j]-j+i;

                    pos=j;

                }

            }

            while(pos>i){

                swap(s[pos],s[pos-1]);

                pos--;

            }

            s[i]=(char)best;

        }

        cout<<s<<endl;

    }

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 8):
#include<iostream>

#include<bits/stdc++.h>

#define int long long

using namespace std;

signed main(){

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        int l=s.length();

        int h=1;

        while(h){

            h=0;

            for(int i=l-1;i>0;i--){

                if(s[i]-s[i-1]>1){

                    int temp=s[i];

                    s[i]=s[i-1];

                    s[i-1]=temp-1;

                }

            }

            for(int i=l-1;i>0;i--){

                if(s[i]-s[i-1]>1){

                    h++;

                }

            }

        }

        cout<<s<<endl;

    }

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 8):
#include<iostream>

#include<bits/stdc++.h>

#define int long long

using namespace std;

signed main(){

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        int l=s.length();

        int h=1;

        while(h){

            h=0;

            for(int i=l-1;i>0;i--){

                if(s[i]-s[i-1]>1){

                    int temp=s[i];

                    s[i]=s[i-1];

                    s[i-1]=temp-1;

                }

            }

            for(int i=l-1;i>0;i--){

                if(s[i]-s[i-1]>1){

                    h++;

                }

            }

        }

        cout<<s<<endl;

    }

}

Submission (verdict: Time limit exceeded on test 8):
#include<iostream>

#include<bits/stdc++.h>

#define int long long

using namespace std;

signed main(){

    cin.tie(0);

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        int l=s.length();

        int h=1;

        while(h){

            h=0;

            for(int i=l-1;i>0;i--){

                if(s[i]-s[i-1]>1){

                    int temp=s[i];

                    s[i]=s[i-1];

                    s[i-1]=temp-1;

                }

            }

            for(int i=l-1;i>0;i--){

                if(s[i]-s[i-1]>1){

                    h++;

                }

            }

        }

        cout<<s<<endl;

    }

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

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define e endl
#define int long long
#define all(a) a.begin(), a.end()
#define ip(s) int s; cin >> s;
#define ipp(arr,n) vector<int> arr(n); for (auto &it : arr) cin >> it;
#define f(n) for(int i = 0; i < n; i++)

int32_t main() {
    int t; cin >> t;
    while (t--) {
        ip(n);
        string s = to_string(n);
        int sum=0;
        int two=0;
        int three=0;
        for(int i=0;i<s.length();i++) {
            sum+=s[i]-'0';
            if(s[i]=='2') two++;
            else if(s[i]=='3') three++;
        }
        bool found=false;
        for(int i=0;i<=min(two,9LL);i++){
            for(int j=0;j<=min(three,9LL);j++){
                if((sum+2*i+6*j)%9==0){
                    found=true;
                    break;
                }
            }
            if(found) break;
 
        }
        if(found) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;


    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define e endl
#define int long long
#define all(a) a.begin(), a.end()
#define ip(s) int s; cin >> s;
#define ipp(arr,n) vector<int> arr(n); for (auto &it : arr) cin >> it;
#define f(n) for(int i = 0; i < n; i++)

int32_t main() {
    int t; cin >> t;
    while (t--) {
        ip(n);
        string s = to_string(n);
        int sum=0;
        int two=0;
        int three=0;
        for(int i=0;i<s.length();i++) {
            sum+=s[i]-'0';
            if(s[i]=='2') two++;
            else if(s[i]=='3') three++;
        }
        bool found=false;
        for(int i=0;i<=min(two,8LL);i++){
            for(int j=0;j<=min(three,8LL);j++){
                if((sum+2*i+6*j)%9==0){
                    found=true;
                    break;
                }
            }
            if(found) break;
 
        }
        if(found) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;


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


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define e endl
#define int long long
#define all(a) a.begin(), a.end()
#define ip(s) int s; cin >> s;
#define ipp(arr,n) vector<int> arr(n); for (auto &it : arr) cin >> it;
#define f(n) for(int i = 0; i < n; i++)

int32_t main() {
    int t; cin >> t;
    while (t--) {
        ip(n);
        string s = to_string(n);
        int sum=0;
        int two=0;
        int three=0;
        for(int i=0;i<s.length();i++) {
            sum+=s[i]-'0';
            if(s[i]=='2') two++;
            else if(s[i]=='3') three++;
        }
        bool found=false;
        for(int i=0;i<=min(two,9LL);i++){
            for(int j=0;j<=min(three,9LL);j++){
                if((sum+2*i+6*j)%9==0){
                    found=true;
                    break;
                }
            }
            if(found) break;
 
        }
        if(found) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;


    }
    return 0;
}