ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

#include <iostream>

using namespace std;

#define ll long long



bool solve(ll twos,ll threes,ll sum){

    if(sum==0){

        return true;

    }

    if(twos==0 && threes==0){

        return false;

    }

    //either add two or six

    bool way1 = false;

    if(twos>0){

        way1 =solve(twos-1,threes,(sum+2)%9);

    }

    bool way2 = false;

    if(threes>0)

        way2 = solve(twos,threes-1,(sum+6)%9);

    return max(way1,way2);

}



int main()

{

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        ll sum = 0;

        ll twos = 0, threes = 0;

        for(auto it:s){

            sum += it-'0';

            if(it-'0'==2){

                twos++;

            }else if(it-'0'==3){

                threes++;

            }

        }

        if(sum%9==0){

            cout<<"YES"<<endl;

            continue;

        }

        bool ans = solve(twos,threes,sum%9);

        if(ans){

            cout<<"YES"<<endl;

        }else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}

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

#include <iostream>

using namespace std;

#define ll long long



bool solve(ll twos,ll threes,ll sum,vector<vector<int>> &dp){

    if(sum==0){

        return true;

    }

    if(twos==0 && threes==0){

        return false;

    }

    if(dp[twos][threes]!=-1) return dp[twos][threes];

    //either add two or six

    bool way1 = false;

    if(twos>0){

        way1 =solve(twos-1,threes,(sum+2)%9,dp);

    }

    bool way2 = false;

    if(threes>0)

        way2 = solve(twos,threes-1,(sum+6)%9,dp);

    return dp[twos][threes]=max(way1,way2);

}



int main()

{

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        ll sum = 0;

        ll twos = 0, threes = 0;

        for(auto it:s){

            sum += it-'0';

            if(it-'0'==2){

                twos++;

            }else if(it-'0'==3){

                threes++;

            }

        }

        if(sum%9==0){

            cout<<"YES"<<endl;

            continue;

        }

        vector<vector<int>> dp(twos+1,vector<int>(threes+1,-1));

        bool ans = solve(twos,threes,sum%9,dp);

        if(ans){

            cout<<"YES"<<endl;

        }else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

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

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

#include <iostream>

using namespace std;

#define ll long long



bool solve(ll twos,ll threes,ll sum,map<pair<int,int>,int> &dp){

    if(sum==0){

        return true;

    }

    if(twos==0 && threes==0){

        return false;

    }

    if(dp.count({twos,threes})) return dp[{twos,threes}];

    //either add two or six

    bool way1 = false;

    if(twos>0){

        way1 = solve(twos-1,threes,(sum+2)%9,dp);

    }

    bool way2 = false;

    if(threes>0)

        way2 = solve(twos,threes-1,(sum+6)%9,dp);

    return dp[{twos,threes}]=max(way1,way2);

}



int main()

{

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        ll sum = 0;

        ll twos = 0, threes = 0;

        for(auto it:s){

            sum += it-'0';

            if(it-'0'==2){

                twos++;

            }else if(it-'0'==3){

                threes++;

            }

        }

        if(sum%9==0){

            cout<<"YES"<<endl;

            continue;

        }

        map<pair<int,int>,int> dp;

        bool ans = solve(twos,threes,sum%9,dp);

        if(ans){

            cout<<"YES"<<endl;

        }else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}

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

#include <iostream>

using namespace std;

#define ll long long



bool solve(ll twos,ll threes,ll sum,map<pair<int,int>,int> &dp){

    if(sum==0){

        return true;

    }

    if(twos==0 && threes==0){

        return false;

    }

    if(dp.count({twos,threes})) return dp[{twos,threes}];

    //either add two or six

    bool way1 = false;

    if(twos>0){

        way1 = solve(twos-1,threes,(sum+2)%9,dp);

        if(way1) return dp[{twos,threes}] = true;

    }

    bool way2 = false;

    if(threes>0)

        way2 = solve(twos,threes-1,(sum+6)%9,dp);

        if(way2) return dp[{twos,threes}] = true;

    return dp[{twos,threes}]=max(way1,way2);

}



int main()

{

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        ll sum = 0;

        ll twos = 0, threes = 0;

        for(auto it:s){

            sum += it-'0';

            if(it-'0'==2){

                twos++;

            }else if(it-'0'==3){

                threes++;

            }

        }

        if(sum%9==0){

            cout<<"YES"<<endl;

            continue;

        }

        map<pair<int,int>,int> dp;

        bool ans = solve(twos,threes,sum%9,dp);

        if(ans){

            cout<<"YES"<<endl;

        }else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

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


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

#include <iostream>

using namespace std;

#define ll long long



bool solve(ll twos,ll threes,ll sum){

    if(sum==0){

        return true;

    }

    if(twos==0 && threes==0){

        return false;

    }

    //either add two or six

    bool way1 = false;

    if(twos>0){

        way1 =solve(twos-1,threes,(sum+2)%9);

    }

    bool way2 = false;

    if(threes>0)

        way2 = solve(twos,threes-1,(sum+6)%9);

    return max(way1,way2);

}



int main()

{

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        ll sum = 0;

        ll twos = 0, threes = 0;

        for(auto it:s){

            sum += it-'0';

            if(it-'0'==2){

                twos++;

            }else if(it-'0'==3){

                threes++;

            }

        }

        if(sum%9==0){

            cout<<"YES"<<endl;

            continue;

        }

        bool ans = solve(twos,threes,sum%9);

        if(ans){

            cout<<"YES"<<endl;

        }else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

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

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

#include <iostream>

using namespace std;

#define ll long long



bool solve(ll twos,ll threes,ll sum,vector<vector<int>> &dp){

    if(sum==0){

        return true;

    }

    if(twos==0 && threes==0){

        return false;

    }

    if(dp[twos][threes]!=-1) return dp[twos][threes];

    //either add two or six

    bool way1 = false;

    if(twos>0){

        way1 =solve(twos-1,threes,(sum+2)%9,dp);

    }

    bool way2 = false;

    if(threes>0)

        way2 = solve(twos,threes-1,(sum+6)%9,dp);

    return dp[twos][threes]=max(way1,way2);

}



int main()

{

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        ll sum = 0;

        ll twos = 0, threes = 0;

        for(auto it:s){

            sum += it-'0';

            if(it-'0'==2){

                twos++;

            }else if(it-'0'==3){

                threes++;

            }

        }

        if(sum%9==0){

            cout<<"YES"<<endl;

            continue;

        }

        vector<vector<int>> dp(twos+1,vector<int>(threes+1,-1));

        bool ans = solve(twos,threes,sum%9,dp);

        if(ans){

            cout<<"YES"<<endl;

        }else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}

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

#include <iostream>

using namespace std;

#define ll long long



bool solve(ll twos,ll threes,ll sum,map<pair<int,int>,int> &dp){

    if(sum==0){

        return true;

    }

    if(twos==0 && threes==0){

        return false;

    }

    if(dp.count({twos,threes})) return dp[{twos,threes}];

    //either add two or six

    bool way1 = false;

    if(twos>0){

        way1 = solve(twos-1,threes,(sum+2)%9,dp);

    }

    bool way2 = false;

    if(threes>0)

        way2 = solve(twos,threes-1,(sum+6)%9,dp);

    return dp[{twos,threes}]=max(way1,way2);

}



int main()

{

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        ll sum = 0;

        ll twos = 0, threes = 0;

        for(auto it:s){

            sum += it-'0';

            if(it-'0'==2){

                twos++;

            }else if(it-'0'==3){

                threes++;

            }

        }

        if(sum%9==0){

            cout<<"YES"<<endl;

            continue;

        }

        map<pair<int,int>,int> dp;

        bool ans = solve(twos,threes,sum%9,dp);

        if(ans){

            cout<<"YES"<<endl;

        }else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while (t--)

    {

        int n;

        cin>>n;

        int even=0,odd=0;

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

        {

            int data;

            cin>>data;

            if(i%2)

            odd+=data;

            else

                even+=data;

        }

        int e=(n+1)/2,o=n-e;

        if((even%e==0&&odd%o==0)&&(even/e==odd/o))

            cout<<"YES"<<endl;

        else

            cout<<"NO"<<endl; 

    }

}

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while (t--)

    {

        int n;

        cin>>n;

        int even=0,odd=0;

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

        {

            int data;

            cin>>data;

            if(i%2)

            odd+=data;

            else

                even+=data;

        }

        int e=(n+1)/2,o=n-e;

        if((even%e==0&&odd%o==0)&&(even/e==odd/o)&&((even+odd)%n==0))

            cout<<"YES"<<endl;

        else

            cout<<"NO"<<endl; 

    }

}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while (t--)

    {

        int n;

        cin>>n;

        int even=0,odd=0;

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

        {

            int data;

            cin>>data;

            if(i%2)

            odd+=data;

            else

                even+=data;

        }

        int e=(n+1)/2,o=n-e;

        if((even%e==0&&odd%o==0)&&(even/e==odd/o)&&((even+odd)%n==0))

            cout<<"YES"<<endl;

        else

            cout<<"NO"<<endl; 

    }

}

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while (t--)

    {

        int n;

        cin>>n;

        long long even=0,odd=0;

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

        {

            int data;

            cin>>data;

            if(i%2)

            odd+=data;

            else

                even+=data;

        }

        int e=(n+1)/2,o=n-e;

        if((even%e==0&&odd%o==0)&&(even/e==odd/o))

            cout<<"YES"<<endl;

        else

            cout<<"NO"<<endl; 

    }

}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)


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

using namespace std;

int main(){

    int t;

    cin>>t;

    while (t--)

    {

        int n;

        cin>>n;

        int even=0,odd=0;

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

        {

            int data;

            cin>>data;

            if(i%2)

            odd+=data;

            else

                even+=data;

        }

        int e=(n+1)/2,o=n-e;

        if((even%e==0&&odd%o==0)&&(even/e==odd/o))

            cout<<"YES"<<endl;

        else

            cout<<"NO"<<endl; 

    }

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;



int main(){

    int t;

    cin>>t;

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int> a(n+1);

        vector<int> set1;

        vector<int> set2;

        int sum = 0;

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

            cin>>a[i];

            if(i<=r){set1.push_back(a[i]);}

            if(i>=l){set2.push_back(a[i]);}

        }

        int req_ele=r-l+1;

        sort(set1.begin(),set1.end());

        int sum1=0;

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

            sum1 += set1[i];

        }

        sort(set2.begin(),set2.end());

        int sum2=0;

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

            sum2 += set2[i];

        }

        cout<<min(sum1,sum2);

    }

}

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

using namespace std;



int main(){

    int t;

    cin>>t;

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int> a(n+1);

        vector<int> set1;

        vector<int> set2;

        int sum = 0;

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

            cin>>a[i];

            if(i<=r){set1.push_back(a[i]);}

            if(i>=l){set2.push_back(a[i]);}

        }

        int req_ele=r-l+1;

        sort(set1.begin(),set1.end());

        int sum1=0;

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

            sum1 += set1[i];

        }

        sort(set2.begin(),set2.end());

        int sum2=0;

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

            sum2 += set2[i];

        }

        cout<<min(sum1,sum2)<<"\n";

    }

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

using namespace std;



int main(){

    int t;

    cin>>t;

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int> a(n+1);

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

            cin>>a[i];

        }

        int ans=0;

        int req = r-l+1;

        sort(a.begin(),a.end());

        for(int i=1;i<=req;i++){

            if(i>n){break;}

            ans+=a[i];

        }

        cout<<ans<<"\n";

    }

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;



int main(){

    int t;

    cin>>t;

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int> a(n+1);

        vector<int> set1;

        vector<int> set2;

        int sum = 0;

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

            cin>>a[i];

            if(i<=r){set1.push_back(a[i]);}

            if(i>=l){set2.push_back(a[i]);}

        }

        int req_ele=r-l+1;

        sort(set1.begin(),set1.end());

        int sum1=0;

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

            sum1 += set1[i];

        }

        sort(set2.begin(),set2.end());

        int sum2=0;

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

            sum2 += set2[i];

        }

        cout<<min(sum1,sum2)<<"\n";

    }

}

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

using namespace std;



int main(){

    long long int t;

    cin>>t;

    while(t--){

        long long int n,l,r;

        cin>>n>>l>>r;

        vector<long long int> a(n+1);

        vector<long long int> set1;

        vector<long long int> set2;

        long long int sum = 0;

        for(long long int i=1;i<=n;i++){

            cin>>a[i];

            if(i<=r){set1.push_back(a[i]);}

            if(i>=l){set2.push_back(a[i]);}

        }

        long long int req_ele=r-l+1;

        sort(set1.begin(),set1.end());

        long long int sum1=0;

        for(long long int i=0;i<req_ele;i++){

            sum1 += set1[i];

        }

        sort(set2.begin(),set2.end());

        long long int sum2=0;

        for(long long int i=0;i<req_ele;i++){

            sum2 += set2[i];

        }

        cout<<min(sum1,sum2)<<"\n";

    }

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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,l,r;

        cin>>n>>l>>r;

        vector<int> a(n+1);

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

            cin>>a[i];

        }

        int ans=0;

        int req = r-l+1;

        sort(a.begin(),a.end());

        for(int i=1;i<=req;i++){

            if(i>n){break;}

            ans+=a[i];

        }

        cout<<ans<<"\n";

    }

}

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

using namespace std;



int main(){

    int t;

    cin>>t;

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int> a(n+1);

        vector<int> set1;

        vector<int> set2;

        int sum = 0;

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

            cin>>a[i];

            if(i<=r){set1.push_back(a[i]);}

            if(i>=l){set2.push_back(a[i]);}

        }

        int req_ele=r-l+1;

        sort(set1.begin(),set1.end());

        int sum1=0;

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

            sum1 += set1[i];

        }

        sort(set2.begin(),set2.end());

        int sum2=0;

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

            sum2 += set2[i];

        }

        cout<<min(sum1,sum2);

    }

}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


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


struct Compare {
    bool operator()(pair<int, int>& a, pair<int, int>& b) {
        return a.second > b.second; 
    }
};

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

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

 
        priority_queue<pair<int, int>, vector<pair<int, int>>, Compare> pq;
        for (auto& it : freq) {
            pq.push(it); 
        }
        if(pq.size() == 1){
            cout<<1<<endl;
            continue;
        }

        while(k > 0 && pq.size()>1){
          auto top = pq.top();
          pq.pop();
          if(top.second>k) break;
          k -= top.second;
        }
        cout<<pq.size()<<endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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


struct Compare {
    bool operator()(pair<int, int>& a, pair<int, int>& b) {
        return a.second > b.second; 
    }
};

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

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

 
        priority_queue<pair<int, int>, vector<pair<int, int>>, Compare> pq;
        for (auto& it : freq) {
            pq.push(it); 
        }
        if(pq.size() == 1){
            cout<<1<<endl;
            continue;
        }

        while(k > 0 && pq.size()>1){
          auto top = pq.top();
          pq.pop();
          if(top.second>k) break;
          k -= top.second;
        }
        cout<<pq.size()<<endl;
    }
    return 0;
}


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


struct Compare {
    bool operator()(pair<int, int>& a, pair<int, int>& b) {
        return a.second > b.second; 
    }
};

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

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

 
        priority_queue<pair<int, int>, vector<pair<int, int>>, Compare> pq;
        for (auto& it : freq) {
            pq.push(it); 
        }
        if(pq.size() <= 1){
            cout<<pq.size()<<endl;
            continue;
        }

        while(k >= 0 && pq.size()>1){
          auto top = pq.top();
          pq.pop();
          if(top.second>k) break;
          k -= top.second;
        }
        cout<<pq.size()<<endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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


struct Compare {
    bool operator()(pair<int, int>& a, pair<int, int>& b) {
        return a.second > b.second; 
    }
};

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

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

 
        priority_queue<pair<int, int>, vector<pair<int, int>>, Compare> pq;
        for (auto& it : freq) {
            pq.push(it); 
        }
        if(pq.size() <= 1){
            cout<<pq.size()<<endl;
            continue;
        }

        while(k >= 0 && pq.size()>1){
          auto top = pq.top();
          pq.pop();
          if(top.second>k) break;
          k -= top.second;
        }
        cout<<pq.size()<<endl;
    }
    return 0;
}


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


struct Compare {
    bool operator()(pair<int, int>& a, pair<int, int>& b) {
        return a.second > b.second; 
    }
};

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

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

 
        priority_queue<pair<int, int>, vector<pair<int, int>>, Compare> pq;
        for (auto& it : freq) {
            pq.push(it); 
        }
        if(pq.size() <= 1){
            cout<<pq.size()<<endl;
            continue;
        }

        while(k > 0 && pq.size()>1){
          auto top = pq.top();
          if(top.second>k) break;
          k -= top.second;
          pq.pop();
        }
        cout<<pq.size()<<endl;
    }
    return 0;
}