ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--){
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++) cin >> a[i];
        ll ans = LLONG_MIN;
        int sz = n;
        for (int i = 0; i < n; i++){
            ll cur = accumulate(a, a + sz, 0LL);
            if (i > 0) cur = abs(cur);
            ans = max(ans, cur);
            for (int j = 0; j < sz - 1; j++) a[j] = a[j + 1] - a[j];
            --sz;
        }
        cout << ans << endl;
    }
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--){
        int n;
        cin >> n;
        ll a[n];
        for (int i = 0; i < n; i++) cin >> a[i];
        ll ans = LLONG_MIN;
        int sz = n;
        for (int i = 0; i < n; i++){
            ll cur = accumulate(a, a + sz, 0LL);
            if (i > 0) cur = abs(cur);
            ans = max(ans, cur);
            for (int j = 0; j < sz - 1; j++) a[j] = a[j + 1] - a[j];
            --sz;
        }
        cout << ans << endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--){
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++) cin >> a[i];
        if (n == 1){
            cout << a[0] << endl;
            continue;
        }
        ll ans = LLONG_MIN;
        int sz = n;
        for (int i = 0; i < n; i++){
            ll cur = abs(accumulate(a, a + sz, 0LL));
            ans = max(ans, cur);
            for (int j = 0; j < sz - 1; j++) a[j] = a[j + 1] - a[j];
            --sz;
        }
        cout << ans << endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--){
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++) cin >> a[i];
        if (n == 1){
            cout << a[0] << endl;
            continue;
        }
        ll ans = LLONG_MIN;
        int sz = n;
        for (int i = 0; i < n; i++){
            ll cur = abs(accumulate(a, a + sz, 0LL));
            ans = max(ans, cur);
            for (int j = 0; j < sz - 1; j++) a[j] = a[j + 1] - a[j];
            --sz;
        }
        cout << ans << endl;
    }
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--){
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++) cin >> a[i];
        ll ans = LLONG_MIN;
        int sz = n;
        for (int i = 0; i < n; i++){
            ll cur = accumulate(a, a + sz, 0LL);
            if (i > 0) cur = abs(cur);
            ans = max(ans, cur);
            for (int j = 0; j < sz - 1; j++) a[j] = a[j + 1] - a[j];
            --sz;
        }
        cout << ans << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

using namespace std;

int find(string &s, int r)
{
    int l = r;
    while (l >= 0)
    {
        if (s[r] - s[l] > 1)
        {
            return l;
        }
        else
        {
            l--;
        }
    }
    return l;
}

void change(string &s, int r)
{
    int l = r;
    while (l < s.length() - 1)
    {
        if (s[l + 1] - s[l] > 1)
        {
            char temp = s[l + 1];
            s[l + 1] = s[l];
            s[l] = temp - 1;
            l++;
            // cout << s << " s from change" << endl;
        }
        else
        {
            return;
        }
    }
    return;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int r = s.size() - 1;
        while (r >= 0)
        {
            if (s[r] == '0')
            {
                r--;
            }
            else
            {
                r = find(s, r);
                // cout << r << endl;
                if (r >= 0)
                {
                    change(s, r);
                }
                // cout << r << "next" << " st " << s << endl;
            }
        }
        cout << s << endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

using namespace std;

int find(string &s, int r)
{
    int l = r;
    while (l >= 0)
    {
        if (s[r] - s[l] > 1 || s[l] - s[r] > 1)
        {
            return l;
        }
        else
        {
            l--;
        }
    }
    return l;
}

void change(string &s, int r)
{
    int l = r;
    while (l < s.length() - 1)
    {
        if (s[l + 1] - s[l] > 1)
        {
            char temp = s[l + 1];
            s[l + 1] = s[l];
            s[l] = temp - 1;
            l++;
            // cout << s << " s from change" << endl;
        }
        else
        {
            return;
        }
    }
    return;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int r = s.size() - 1;
        while (r >= 0)
        {
            if (s[r] == '0')
            {
                r--;
            }
            else
            {
                int k;
                k = find(s, r);
                // cout << k << endl;
                if (r >= 0)
                {
                    change(s, k);
                }
                r = k;
                // cout << r << "next" << " st " << s << endl;
            }
        }
        cout << s << endl;
    }
    return 0;
}

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

using namespace std;

int find(string &s, int r)
{
    int l = r-1;
    // cout << l << endl;
    while (l >= 0)
    {
        if (s[r] - s[l] > 1 || s[l] - s[r] > 1)
        {
            return l;
        }
        else
        {
            l--;
            r--;
        }
    }
    return l;
}

void change(string &s, int r)
{
    int l = r;
    while (l < s.length() - 1)
    {
        if (s[l + 1] - s[l] > 1)
        {
            char temp = s[l + 1];
            s[l + 1] = s[l];
            s[l] = temp - 1;
            l++;
            // cout << s << " s from change" << endl;
        }
        else
        {
            return;
        }
    }
    return;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int r = s.size() - 1;
        while (r >= 0)
        {
            if (s[r] == '0')
            {
                r--;
            }
            else
            {
                int k;
                k = find(s, r);
                // cout << k << endl;
                if (k >= 0)
                {
                    change(s, k);
                }
                r = k;
                // cout << r << "next" << " st " << s << endl;
            }
        }
        cout << s << endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

using namespace std;

int find(string &s, int r)
{
    int l = r;
    while (l >= 0)
    {
        if (s[r] - s[l] > 1)
        {
            return l;
        }
        else
        {
            l--;
        }
    }
    return l;
}

void change(string &s, int r)
{
    int l = r;
    while (l < s.length() - 1)
    {
        if (s[l + 1] - s[l] > 1)
        {
            char temp = s[l + 1];
            s[l + 1] = s[l];
            s[l] = temp - 1;
            l++;
            // cout << s << " s from change" << endl;
        }
        else
        {
            return;
        }
    }
    return;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int r = s.size() - 1;
        while (r >= 0)
        {
            if (s[r] == '0')
            {
                r--;
            }
            else
            {
                r = find(s, r);
                // cout << r << endl;
                if (r >= 0)
                {
                    change(s, r);
                }
                // cout << r << "next" << " st " << s << endl;
            }
        }
        cout << s << endl;
    }
    return 0;
}

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

using namespace std;

int find(string &s, int r)
{
    int l = r;
    while (l >= 0)
    {
        if (s[r] - s[l] > 1 || s[l] - s[r] > 1)
        {
            return l;
        }
        else
        {
            l--;
        }
    }
    return l;
}

void change(string &s, int r)
{
    int l = r;
    while (l < s.length() - 1)
    {
        if (s[l + 1] - s[l] > 1)
        {
            char temp = s[l + 1];
            s[l + 1] = s[l];
            s[l] = temp - 1;
            l++;
            // cout << s << " s from change" << endl;
        }
        else
        {
            return;
        }
    }
    return;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int r = s.size() - 1;
        while (r >= 0)
        {
            if (s[r] == '0')
            {
                r--;
            }
            else
            {
                int k;
                k = find(s, r);
                // cout << k << endl;
                if (r >= 0)
                {
                    change(s, k);
                }
                r = k;
                // cout << r << "next" << " st " << s << endl;
            }
        }
        cout << s << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 5):
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	int t;
	cin>>t;
	vector<long long>arr(1010);
	long long sum=0;
	long long ans=-1e18;
	while(t--)
	{
		ans=-1e18;
		cin>>n;
		for(int i=1;i<=n;i++)cin>>arr[i];
		int temp=n;
		for(int g=1;g<=n;g++)
		{
			sum=0;
			if(g!=1)
			{
				for(int i=1;i<=temp;i++)
				{
					if(i+1<=temp)
					arr[i]=arr[i+1]-arr[i];
				}
				temp--;
			}
		
			
		
		for(int i=1;i<=temp;i++)
				{
					sum+=arr[i];
				}
				if(sum>ans)ans=sum;
				else if(-sum>ans)ans=-sum;
			
			
		}
		
		cout<<ans<<endl;
		
		
		
	}
	//1 -4  5
	//
	//-5 9      5 -9
	//         -4
	//-14
	
	return 0;
}


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	int t;
	cin>>t;
	vector<long long>arr(1010);
	long long sum=0;
	long long ans=-1e18;
	while(t--)
	{
		ans=-1e18;
		cin>>n;
		for(int i=1;i<=n;i++)cin>>arr[i];
		int temp=n;
		for(int g=1;g<=n;g++)
		{
			sum=0;
			if(g!=1)
			{
				for(int i=1;i<=temp;i++)
				{
					if(i+1<=temp)
					arr[i]=arr[i+1]-arr[i];
				}
				temp--;
			}
		
			
		
		for(int i=1;i<=temp;i++)
				{
					sum+=arr[i];
				}
				if(sum>ans)ans=sum;
				if(-sum>ans)ans=-sum;
			
			
		}
		
		cout<<ans<<endl;
		
		
		
	}
	//1 -4  5
	//
	//-5 9      5 -9
	//         -4
	//-14
	
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	int t;
	cin>>t;
	vector<long long>arr(1010);
	long long sum=0;
	long long ans=-1e18;
	while(t--)
	{
		ans=-1e18;
		cin>>n;
		for(int i=1;i<=n;i++)cin>>arr[i];
		int temp=n;
		for(int g=1;g<=n;g++)
		{
			sum=0;
			if(g!=1)
			{
				for(int i=1;i<=temp;i++)
				{
					if(i+1<=temp)
					arr[i]=arr[i+1]-arr[i];
				}
				temp--;
			}
		
			
		
		for(int i=1;i<=temp;i++)
				{
					sum+=arr[i];
				}
				if(sum>ans)ans=sum;
				if(-sum>ans)ans=-sum;
			
			
		}
		
		cout<<ans<<endl;
		
		
		
	}
	//1 -4  5
	//
	//-5 9      5 -9
	//         -4
	//-14
	
	return 0;
}


Submission (verdict: Accepted):
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	int t;
	cin>>t;
	vector<long long>arr(1010);
	long long sum=0;
	long long ans=-1e18;
	while(t--)
	{
		ans=-1e18;
		cin>>n;
		for(int i=1;i<=n;i++)cin>>arr[i];
		
		int temp=n;
		for(int g=1;g<=n;g++)
		{
			sum=0;
			if(g!=1)
			{
				for(int i=1;i<=temp;i++)
				{
					if(i+1<=temp)
					arr[i]=arr[i+1]-arr[i];
				}
				temp--;
			}
		
		for(int i=1;i<=temp;i++)
				{
					sum+=arr[i];
				}
				if(g==1)ans=max(ans,sum);
				else
				ans = max(ans,max(sum,-sum));
				
			
		}
		
		cout<<ans<<endl;
		
		
		
	}
	//1 -4  5
	//
	//-5 9      5 -9
	//         -4
	//-14
	
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 5):
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	int t;
	cin>>t;
	vector<long long>arr(1010);
	long long sum=0;
	long long ans=-1e18;
	while(t--)
	{
		ans=-1e18;
		cin>>n;
		for(int i=1;i<=n;i++)cin>>arr[i];
		int temp=n;
		for(int g=1;g<=n;g++)
		{
			sum=0;
			if(g!=1)
			{
				for(int i=1;i<=temp;i++)
				{
					if(i+1<=temp)
					arr[i]=arr[i+1]-arr[i];
				}
				temp--;
			}
		
			
		
		for(int i=1;i<=temp;i++)
				{
					sum+=arr[i];
				}
				if(sum>ans)ans=sum;
				else if(-sum>ans)ans=-sum;
			
			
		}
		
		cout<<ans<<endl;
		
		
		
	}
	//1 -4  5
	//
	//-5 9      5 -9
	//         -4
	//-14
	
	return 0;
}
Problem: 2057B - Gorilla and the Exam
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,k;
        cin>>n>>k;
        map<int,int>mapping;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            mapping[x]++;
        }
        int maxi=INT_MIN;
        int key=-1;
        for(auto i:mapping){
         if(i.second>maxi){
            maxi=i.second;
            key=i.first;
         }
        }
        int count=0;
        for(auto &i:mapping){
         if(i.first!=key&&i.second<=k){
            int x=i.second;
            i.second=0;
            k=k-x;

            
         }else if(i.first!=key&&i.second>k){
            i.second=i.second-k;
            k=0;
            break;
         }
        }
        for(auto i:mapping){
            if(i.second!=0){
                count++;
            }
        }
       cout<<count<<endl;
    }
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        map<int,int>mapping;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            mapping[x]++;
        }
        int maxi=INT_MIN;
        int key=-1;
        for(auto i:mapping){
         if(i.second>maxi){
            maxi=i.second;
            key=i.first;
         }
        }
        int count=0;
        for(auto &i:mapping){
         if(i.first!=key){
            if(i.second<=k){
            int x=i.second;
            i.second=0;
            k=k-x;
            }else{
            i.second=i.second-k;
            k=0;
            break;
         }
        }
        if(k==0){
            break;
        }
        }
        for(auto i:mapping){
            if(i.second!=0){
                count++;
            }
        }
       cout<<count<<endl;
    }
}
Problem: 2057B - Gorilla and the Exam
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,k;
        cin>>n>>k;
        map<int,int>mapping;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            mapping[x]++;
        }
        int maxi=INT_MIN;
        int key=-1;
        for(auto i:mapping){
         if(i.second>maxi){
            maxi=i.second;
            key=i.first;
         }
        }
        int count=0;
        for(auto &i:mapping){
         if(i.first!=key&&i.second<=k){
            int x=i.second;
            i.second=0;
            k=k-x;
            mapping[key]+=x;
            
         }else if(i.first!=key&&i.second>k){
            mapping[key]+=k;
            i.second=i.second-k;
            k=0;
         }
         if(k==0){
            break;
         }
        }
        for(auto i:mapping){
            if(i.second!=0){
                count++;
            }
        }
       cout<<count<<endl;
    }
}
Problem: 2057B - Gorilla and the Exam
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,k;
        cin>>n>>k;
        map<int,int>mapping;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            mapping[x]++;
        }
        int maxi=INT_MIN;
        int key=-1;
        for(auto i:mapping){
         if(i.second>maxi){
            maxi=i.second;
            key=i.first;
         }
        }
        int count=0;
        for(auto &i:mapping){
         if(i.first!=key&&i.second<=k){
            int x=i.second;
            i.second=0;
            k=k-x;

            
         }else if(i.first!=key&&i.second>k){
            i.second=i.second-k;
            k=0;
         }
         if(k==0){
            break;
         }
        }
        for(auto i:mapping){
            if(i.second!=0){
                count++;
            }
        }
       cout<<count<<endl;
    }
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        map<int,int>mapping;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            mapping[x]++;
        }
        int maxi=INT_MIN;
        int key=-1;
        for(auto i:mapping){
         if(i.second>maxi){
            maxi=i.second;
            key=i.first;
         }
        }
        int count=0;
        for(auto &i:mapping){
         if(i.first!=key&&i.second<=k){
            int x=i.second;
            i.second=0;
            k=k-x;

            
         }else if(i.first!=key&&i.second>k){
            i.second=i.second-k;
            k=0;
            break;
         }
        }
        for(auto i:mapping){
            if(i.second!=0){
                count++;
            }
        }
       cout<<count<<endl;
    }
}
Problem: 2057B - Gorilla and the Exam
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,k;
        cin>>n>>k;
        map<int,int>mapping;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            mapping[x]++;
        }
        int maxi=INT_MIN;
        int key=-1;
        for(auto i:mapping){
         if(i.second>maxi){
            maxi=i.second;
            key=i.first;
         }
        }
        int count=0;
        for(auto &i:mapping){
         if(i.first!=key&&i.second<=k){
            int x=i.second;
            i.second=0;
            k=k-x;
            mapping[key]+=x;
            
         }else if(i.first!=key&&i.second>k){
            mapping[key]+=k;
            i.second=i.second-k;
            k=0;
         }
         if(k==0){
            break;
         }
        }
        for(auto i:mapping){
            if(i.second!=0){
                count++;
            }
        }
       cout<<count<<endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        map<int,int>mapping;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            mapping[x]++;
        }
        int maxi=INT_MIN;
        int key=-1;
        for(auto i:mapping){
         if(i.second>maxi){
            maxi=i.second;
            key=i.first;
         }
        }
        int count=0;
        for(auto &i:mapping){
         if(i.first!=key&&i.second<=k){
            int x=i.second;
            i.second=0;
            k=k-x;

            
         }else if(i.first!=key&&i.second>k){
            i.second=i.second-k;
            k=0;
         }
         if(k==0){
            break;
         }
        }
        for(auto i:mapping){
            if(i.second!=0){
                count++;
            }
        }
       cout<<count<<endl;
    }
}
Problem: 2057B - Gorilla and the Exam
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,k;
        cin>>n>>k;
        map<int,int>mapping;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            mapping[x]++;
        }
        int maxi=INT_MIN;
        int key=-1;
        for(auto i:mapping){
         if(i.second>maxi){
            maxi=i.second;
            key=i.first;
         }
        }
        int count=0;
        for(auto &i:mapping){
         if(i.first!=key){
            if(i.second<=k){
            int x=i.second;
            i.second=0;
            k=k-x;
            }else{
            i.second=i.second-k;
            k=0;
            break;
         }
        }
        if(k==0){
            break;
        }
        }
        for(auto i:mapping){
            if(i.second!=0){
                count++;
            }
        }
       cout<<count<<endl;
    }
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int>a(n);
        map<int,int>mapping;
        for(int i=0;i<n;i++){
            cin>>a[i];
            mapping[a[i]]++;
        }
        vector<int>freq;
        for(auto i:mapping){
            freq.push_back(i.second);
        }
        
        sort(freq.begin(),freq.end());
        for(int i=0;i<n;i++){
            if(freq[i]<=k){
              k=k-freq[i];
              freq[i]=0;
            }else{
                freq[i]=freq[i]-k;
                k=0;
                break;
            }
        }
        int count=0;
        for(auto i:freq){
            if(i!=0){
                count++;
            }
        }
        if(count==0){
            count=count+1;
        }
       cout<<count<<endl;
    }
}