ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
       ll n;
       cin>>n;
       vector<int> v(n);

       int s0=0,s1=0,c1=0,c0=0;
       for(int  i = 0; i < n; i++){
        cin>>v[i];
        if(i%2==0){
            s0+=v[i];
            c0++;
        }
        else {
            s1+=v[i];
            c1++;
        }
       }

       if(s0*c1== s1*c0 && (s1+s0)%n==0){
         cout<<"YES"<<endl;
       }
       else cout<<"NO"<<endl;
    }
}
    


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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
       ll n;
       cin>>n;
       vector<int> v(n);

       int s0=0,s1=0,c1=0,c0=0;
       for(int  i = 0; i < n; i++){
        cin>>v[i];
        if(i%2==0){
            s0+=v[i];
            c0++;
        }
        else {
            s1+=v[i];
            c1++;
        }
       }

       if(s0*c1== s1*c0 && (s1+s0)%(c0+c1)==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;

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
       ll n;
       cin>>n;
       vector<int> v(n);

       int s0=0,s1=0,c1=0,c0=0;
       for(int  i = 0; i < n; i++){
        cin>>v[i];
        if(i%2==0){
            s0+=v[i];
            c0++;
        }
        else {
            s1+=v[i];
            c1++;
        }
       }

       if(s0*c1== s1*c0 && (s1+s0)%(c0+c1)==0){
         cout<<"YES"<<endl;
       }
       else cout<<"NO"<<endl;
    }
}
    


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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
       ll n;
       cin>>n;
       vector<ll> v(n);

       ll s0=0,s1=0,c1=0,c0=0;
       for(ll  i = 0; i < n; i++){
        cin>>v[i];
        if(i%2==0){
            s0+=v[i];
            c0++;
        }
        else {
            s1+=v[i];
            c1++;
        }
       }

       if(s0*c1== s1*c0 && (s1+s0)%(c0+c1)==0){
         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;

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
       ll n;
       cin>>n;
       vector<int> v(n);

       int s0=0,s1=0,c1=0,c0=0;
       for(int  i = 0; i < n; i++){
        cin>>v[i];
        if(i%2==0){
            s0+=v[i];
            c0++;
        }
        else {
            s1+=v[i];
            c1++;
        }
       }

       if(s0*c1== s1*c0 && (s1+s0)%n==0){
         cout<<"YES"<<endl;
       }
       else cout<<"NO"<<endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

using namespace std;



int main() {

	// your code goes here

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> v(n,0);

        int max = 0;

        int flag = 0;

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

            cin>>v[i];

            if(v[i]>max)

            max=v[i];

            

        }

        if(v[0]==max)

        cout<<"No"<<endl;

        else{

            

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

                if(v[i]<v[i-1]){

                    flag=1;

                    break;

                }

                v[i]-=v[i-1];

            }

            if(flag)

            cout<<"No"<<endl;

            else

            cout<<"Yes"<<endl;

        } 

    }

}



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

using namespace std;



int main() {

	// your code goes here

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> v(n,0);

        int max = 0;

        int flag = 0;

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

            cin>>v[i];

            if(v[i]>max)

            max=v[i];

            

        }

        {

            

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

                if(v[i]<v[i-1]){

                    flag=1;

                    break;

                }

                v[i]-=v[i-1];

            }

            if(flag)

            cout<<"No"<<endl;

            else

            cout<<"Yes"<<endl;

        } 

    }

}
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;



int main() {

	// your code goes here

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> v(n,0);

        int max = 0;

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

            cin>>v[i];

            if(v[i]>max)

            max=v[i];

        }

        if(v[n-1]==max)

        cout<<"Yes"<<endl;

        else if(v[0]==max)

        cout<<"No"<<endl;

        else{

            cout<<"Yes"<<endl;

        }

        

    }

}



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

using namespace std;



int main() {

	// your code goes here

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> v(n,0);

        int max = 0;

        int flag = 0;

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

            cin>>v[i];

            if(v[i]>max)

            max=v[i];

            

        }

        if(v[0]==max)

        cout<<"No"<<endl;

        else{

            

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

                if(v[i]<v[i-1]){

                    flag=1;

                    break;

                }

                v[i]-=v[i-1];

            }

            if(flag)

            cout<<"No"<<endl;

            else

            cout<<"Yes"<<endl;

        } 

    }

}
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;



int main() {

	// your code goes here

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> v(n,0);

        int max = 0;

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

            cin>>v[i];

            if(v[i]>max)

            max=v[i];

        }

        if(v[n-1]==max)

        cout<<"Yes"<<endl;

        else if(v[0]==max)

        cout<<"No"<<endl;

        else{

            cout<<"Yes"<<endl;

        }

        

    }

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


Submission (verdict: Wrong answer on test 1):
/******************************************************************************

Welcome to GDB Online.
  GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
  C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS
  Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

int main() {
    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        vector<pair<int, int>> v(n);

        for (int i = 0; i < n; i++) {
            cin >> v[i].ff >> v[i].ss;
        }

        unordered_map<int, int> mpp;
        vector<int> single_digits;

        for (int i = 0; i < n; i++) {
            if (v[i].ff - v[i].ss == 0 && mpp.find(v[i].ff) == mpp.end()) {
                single_digits.pb(v[i].ff);
            }
            if ((v[i].ff - v[i].ss) == 0) {
                mpp[v[i].ff]++;
            }
        }

        sort(single_digits.begin(), single_digits.end());
        int m = single_digits.size();
        string res = "";

        for (int i = 0; i < n; i++) {
            if (v[i].ss - v[i].ff >= 1) {
                int lower_bound = -1;
                int low = 0;
                int high = m - 1;
                
                while (low <= high) {
                    int mid = (low + high) / 2;
                    if (single_digits[mid] > v[i].ff) {
                        high = mid - 1;
                    } else {
                        lower_bound = mid;
                        low = mid + 1;
                    }
                }

                low = 0;
                high = m - 1;
                int upper_bound = -1;

                while (low <= high) {
                    int mid = (low + high) / 2;
                    if (single_digits[mid] <= v[i].ss) {
                        low = mid + 1;
                        upper_bound = mid;
                    } else {
                        high = mid - 1;
                    }
                }

                if (lower_bound == -1 || upper_bound == -1 ||
                    single_digits[lower_bound] != v[i].ff ||
                    single_digits[upper_bound] != v[i].ss ||
                    (upper_bound - lower_bound + 1) != (v[i].ss - v[i].ff + 1)) {
                    res.push_back('1');
                } 
                else {
                    res.push_back('0');
                }
            } 
            else {
                if (mpp[v[i].ff] > 1) {
                    res.push_back('0');
                } 
                else {
                    res.push_back('1');
                }
            }
        }

        cout << res << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 11):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
 
int main()
{
    int T;
    cin >> T;
    while (T--) {
        int n, k;
        cin>>n>>k;
        vector<int>a(n);
        for(int i =0  ; i < n ; i++){
            cin>>a[i];
        }
        unordered_map<long long , int>mpp;
        for(int i =0 ; i < n ; i++){
            mpp[a[i]]++;
        }
        vector<long long >freq;
        for(auto p : mpp){
            freq.push_back(p.second);
        }
        sort(freq.begin(), freq.end());
        long long min_req = 0 ;
        long long cnt = k;
        long long res = 0;
        long long m = freq.size();
        for(int i = 0 ; i < m ; i++){
            if(cnt>=freq[i]){
                cnt-=freq[i];
            }
            else{
                res++;
            }
        }
        if(res == 0 ){
            res =1 ;
        }
        cout<<res<<endl;
    }

    return 0;
}

Submission (verdict: Accepted):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);

int main()
{
    Code By
    int T;
    cin >> T;
    while (T--) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

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

        vector<int> freq;
        int cnt = 1;
        for (int i = 1; i < n; i++) {
            if (a[i - 1] == a[i]) {
                cnt++;
            } else {
                freq.push_back(cnt);
                cnt = 1;
            }
        }
        freq.push_back(cnt);

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

        int res = 0;
        for (int f : freq) {
            if (k >= f) {
                k -= f;
            } else {
                res++;
            }
        }
        if(res == 0 ){
            res =1 ;
        }
        cout << res << endl;
    }

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

Previous submission (verdict: Time limit exceeded on test 11):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
 
int main()
{
    int T;
    cin >> T;
    while (T--) {
        int n, k;
        cin>>n>>k;
        vector<int>a(n);
        for(int i =0  ; i < n ; i++){
            cin>>a[i];
        }
        unordered_map<int , int>mpp;
        for(int i =0 ; i < n ; i++){
            mpp[a[i]]++;
        }
        vector<int>freq;
        for(auto p : mpp){
            freq.push_back(p.second);
        }
        sort(freq.begin(), freq.end());
        int min_req = 0 ;
        int cnt = k;
        int res = 0;
        int m = freq.size();
        for(int i = 0 ; i < m ; i++){
            if(cnt>=freq[i]){
                cnt-=freq[i];
            }
            else{
                res++;
            }
        }
        if(res == 0 ){
            res =1 ;
        }
        cout<<res<<endl;
    }

    return 0;
}

Submission (verdict: Time limit exceeded on test 11):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
 
int main()
{
    int T;
    cin >> T;
    while (T--) {
        int n, k;
        cin>>n>>k;
        vector<int>a(n);
        for(int i =0  ; i < n ; i++){
            cin>>a[i];
        }
        unordered_map<long long , int>mpp;
        for(int i =0 ; i < n ; i++){
            mpp[a[i]]++;
        }
        vector<long long >freq;
        for(auto p : mpp){
            freq.push_back(p.second);
        }
        sort(freq.begin(), freq.end());
        long long min_req = 0 ;
        long long cnt = k;
        long long res = 0;
        long long m = freq.size();
        for(int i = 0 ; i < m ; i++){
            if(cnt>=freq[i]){
                cnt-=freq[i];
            }
            else{
                res++;
            }
        }
        if(res == 0 ){
            res =1 ;
        }
        cout<<res<<endl;
    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: GNU C11

Previous submission (verdict: Runtime error on test 1):
#include <stdio.h>
#include <stdlib.h>

int sort (const void* a, const void* b) {
    return (*(int*)a - *(int*)b);
}

int main() {
    int x;
    scanf("%d", &x);
    
    while (x--) {
        int n, k;
        scanf("%d %d", &n, &k);
        
        int b = 0;
        int* count = (int*)calloc(1000000010, sizeof(int));
        for (int i=0; i<n; i++) {
            int a;
            scanf("%d", &a);
            
            count[a]++;
            if (count[a] == 1) {
                b++;
            }
        }
        
        int c[n+1];
        int m = 0;
        for (int i=1; i<=n; i++) {
            if (count[i] > 0) {
                c[m++] = count[i];
            }
        }
        
        qsort(c, b, sizeof(int), sort);
        
        for (int i=0; i<m; i++) {
            if (c[i] <= k) {
                k = k - c[i];
                b--;
            }
            else {
                break;
            }
        }
        
        printf("%d \n", b);
    }
    
    return 0;
}

Submission (verdict: Runtime error on test 4):
#include <stdio.h>
#include <stdlib.h>

int sort (const void* a, const void* b) {
    return (*(int*)a - *(int*)b);
}

int main() {
    int x;
    scanf("%d", &x);
    
    while (x--) {
        int n, k;
        scanf("%d %d", &n, &k);
        
        int* a = (int*)malloc(n * sizeof(int));
        int max = 0;
        for (int i=0; i<n; i++) {
            scanf(" %d", &a[i]);
            
            if (a[i] > max) {
                max = a[i];
            }
        }
        
        int* count = (int*)calloc(max + 1, sizeof(int));
        for (int i=0; i<n; i++) {
            count[a[i]]++;
        }
        
        int b = 0;
        int* c = (int*)malloc(n * sizeof(int));
        for (int i=1; i<=max; i++) {
            if (count[i] > 0) {
                c[b++] = count[i];
            }
        }
        
        qsort(c, b, sizeof(int), sort);
        
        int ans = b;
        for (int i=0; i<b; i++) {
            if (c[i] <= k) {
                k = k - c[i];
                ans--;
            }
            else {
                break;
            }
        }
        
        if (ans == 0) {
            ans = 1;
        }
        printf("%d \n", ans);
    }
    
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: GNU C11

Previous submission (verdict: Runtime error on test 4):
#include <stdio.h>
#include <stdlib.h>

int sort (const void* a, const void* b) {
    return (*(int*)a - *(int*)b);
}

int main() {
    int x;
    scanf("%d", &x);
    
    while (x--) {
        int n, k;
        scanf("%d %d", &n, &k);
        
        int* a = (int*)malloc(n * sizeof(int));
        int max = 0;
        for (int i=0; i<n; i++) {
            scanf(" %d", &a[i]);
            
            if (a[i] > max) {
                max = a[i];
            }
        }
        
        int* count = (int*)calloc(max + 1, sizeof(int));
        for (int i=0; i<n; i++) {
            count[a[i]]++;
        }
        
        int b = 0;
        int* c = (int*)malloc(n * sizeof(int));
        for (int i=1; i<=max; i++) {
            if (count[i] > 0) {
                c[b++] = count[i];
            }
        }
        
        qsort(c, b, sizeof(int), sort);
        
        int ans = b;
        for (int i=0; i<b; i++) {
            if (c[i] <= k) {
                k = k - c[i];
                ans--;
            }
            else {
                break;
            }
        }
        
        if (ans == 0) {
            ans = 1;
        }
        printf("%d \n", ans);
    }
    
    return 0;
}

Submission (verdict: Accepted):
#include <stdio.h>
#include <stdlib.h>

int sort (const void* a, const void* b) {
    return (*(int*)a - *(int*)b);
}

int main() {
    int x;
    scanf("%d", &x);
    
    while (x--) {
        int n, k;
        scanf("%d %d", &n, &k);
        
        int* a = (int*)malloc(n * sizeof(int));
        int max = 0;
        for (int i=0; i<n; i++) {
            scanf(" %d", &a[i]);
        }
        
        qsort(a, n, sizeof(int), sort);
        
        int* count = (int*)malloc(n * sizeof(int));
        int c = 1;
        int m = 0;
        for (int i=0; i<n-1; i++) {
            if (a[i] == a[i+1]) {
                c++;
            }
            else {
                count[m++] = c;
                c = 1;
            }
        }
        
        count[m++] = c;
        
        qsort(count, m, sizeof(int), sort);
        
        int ans = m;
        for (int i=0; i<m; i++) {
            if (count[i] <= k) {
                k = k - count[i];
                ans--;
            }
            else {
                break;
            }
        }
        
        if (ans == 0) {
            ans = 1;
        }
        printf("%d \n", ans);
        
        free(a);
        free(count);
    }
    
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: GNU C11


Submission (verdict: Runtime error on test 1):
#include <stdio.h>
#include <stdlib.h>

int sort (const void* a, const void* b) {
    return (*(int*)a - *(int*)b);
}

int main() {
    int x;
    scanf("%d", &x);
    
    while (x--) {
        int n, k;
        scanf("%d %d", &n, &k);
        
        int b = 0;
        int* count = (int*)calloc(1000000010, sizeof(int));
        for (int i=0; i<n; i++) {
            int a;
            scanf("%d", &a);
            
            count[a]++;
            if (count[a] == 1) {
                b++;
            }
        }
        
        int c[n+1];
        int m = 0;
        for (int i=1; i<=n; i++) {
            if (count[i] > 0) {
                c[m++] = count[i];
            }
        }
        
        qsort(c, b, sizeof(int), sort);
        
        for (int i=0; i<m; i++) {
            if (c[i] <= k) {
                k = k - c[i];
                b--;
            }
            else {
                break;
            }
        }
        
        printf("%d \n", b);
    }
    
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long

#define vi vector<int>

#define rep(i,x,y) for(int i=x; i<y; i++)

bool in_range(int x,int y,int r,int c){

return (x>=0 && y>=0 && x<r && y<c);

}

int32_t main() {

ios_base::sync_with_stdio(false);

cin.tie(NULL); 

int t;

cin>>t;

while(t--){

    int n;

    cin>>n;

    int value=0;

    int temp=n;

    int twos=0;

    int threes=0;

    while(temp){

        value+=(temp%10);

        if((temp%10)== 2)twos++;

        if((temp%10)==3) threes++;

        temp/=10;

    }

    if((value%9)==0){cout<<"YES"<<endl;continue;}

    bool flag=0;

    // at max we can do upto 8 values of 2 and 3 ...more than that mod 9 will we same as 0

    rep(i,0,min(10ll,twos+1)){

        rep(j,0,min(10ll,threes+1)){

            if(((value+(2*i+6*j))%9) == 0){

                flag=1;

                break;

            }

        }

        if(flag)break;

    }

    if(flag)cout<<"YES";

    else cout<<"NO";

    cout<<endl;



}

return 0;

}

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

using namespace std;

#define int long long

#define vi vector<int>

#define rep(i,x,y) for(int i=x; i<y; i++)

bool in_range(int x,int y,int r,int c){

    return (x>=0 && y>=0 && x<r && y<c);

}

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL); 

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        int value = 0;

        int twos = 0, threes = 0;

        int temp = n;

        while(temp){

            int digit = temp % 10;

            value += digit;

            if(digit == 2) twos++;

            if(digit == 3) threes++;

            temp /= 10;

        }

        if(value % 9 == 0){

            cout << "YES" << endl;

            continue;

        }

        bool flag = false;

        rep(i, 0, min(10ll, twos + 1)){

            rep(j, 0, min(10ll, threes + 1)){

                if((value + 2*i + 6*j) % 9 == 0){

                    flag = true;

                    break;

                }

            }

            if(flag) break;

        }

        if(flag) cout << "YES" << endl;

        else cout << "NO" << endl;

    }

    return 0;

}