ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

#define int long long

using namespace std;

const int N = 2e5 + 10,INF=0x3f3f3f3f,mod= 1e9 + 7;

/*int prime[N];bool st[N];int cnt=0;

void getprime(long long  n)

{

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

    {

        if(!st[i])prime[cnt++]=i;

        for(int j=0;prime[j]<=n/i;j++)

        {

            st[prime[j]*i]=true;

            if(prime[j]%i==0)break;

        }

        

    }

}*/

int qsm(int n,int m)/*n^m*/

{

    int res=1;

    while(m)

    {

        if(m&1) 

        res=res*n%mod;

        n=n*n%mod;

        m>>=1;

    }

    return res;

}

map<string,int>mp,mpp; 

void solve()

{

    string s;

    cin>>s;

    for(int i=0;i<s.size();i++)

    {

        int mx=-1;

        int pos=-1;

        for(int j=i+1;j<s.size();j++)

        {

            

            int a=s[i]-'0';

            int b=s[j]-'0';

            if(b-j+i>a)

            {

                if(b-j+i>mx)

                {

                    mx=b-j+i;

                    pos=j;

                }

            }

        }

        if(mx!=-1)

        {

            s[pos]=mx+'0';

            swap(s[i],s[pos]);

        }

        

    }

    cout<<s<<endl;

}

signed main() 

{

	cin.tie(0),cout.tie(0);

  	int T=1;

  	cin>>T;

  	while(T--)

  	{

  		solve();

	}

    return 0;

}

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

#define int long long

using namespace std;

const int N = 2e5 + 10,INF=0x3f3f3f3f,mod= 1e9 + 7;

/*int prime[N];bool st[N];int cnt=0;

void getprime(long long  n)

{

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

    {

        if(!st[i])prime[cnt++]=i;

        for(int j=0;prime[j]<=n/i;j++)

        {

            st[prime[j]*i]=true;

            if(prime[j]%i==0)break;

        }

        

    }

}*/

int qsm(int n,int m)/*n^m*/

{

    int res=1;

    while(m)

    {

        if(m&1) 

        res=res*n%mod;

        n=n*n%mod;

        m>>=1;

    }

    return res;

}

map<string,int>mp,mpp; 

void solve()

{

    string s;

    cin>>s;

	int n=s.size();

    vector<int>a(n);

    s=' '+s;

    if(n==1){

		cout<<s[1]<<'\n';

		return ;

	}

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

		a[i]=s[i]-'0';

	}

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

		int j=i;

		while(a[j+1]>a[j]+1&&j>=1){

			int t=a[j];

			a[j]=a[j+1]-1;

			a[j+1]=t;

			j--;

		}

	}

	for(int i=1;i<=n;i++) cout<<a[i];

			cout<<'\n';

}

signed main() 

{

	cin.tie(0),cout.tie(0);

  	int T=1;

  	cin>>T;

  	while(T--)

  	{

  		solve();

	}

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

#define int long long

using namespace std;

const int N = 2e5 + 10,INF=0x3f3f3f3f,mod= 1e9 + 7;

/*int prime[N];bool st[N];int cnt=0;

void getprime(long long  n)

{

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

    {

        if(!st[i])prime[cnt++]=i;

        for(int j=0;prime[j]<=n/i;j++)

        {

            st[prime[j]*i]=true;

            if(prime[j]%i==0)break;

        }

        

    }

}*/

int qsm(int n,int m)/*n^m*/

{

    int res=1;

    while(m)

    {

        if(m&1) 

        res=res*n%mod;

        n=n*n%mod;

        m>>=1;

    }

    return res;

}

map<string,int>mp,mpp; 

void solve()

{

    string s;

    cin>>s;

	int n=s.size();

    vector<int>a(n);

    s=' '+s;

    if(n==1){

		cout<<s[1]<<'\n';

		return ;

	}

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

		a[i]=s[i]-'0';

	}

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

		int j=i;

		while(a[j+1]>a[j]+1&&j>=1){

			int t=a[j];

			a[j]=a[j+1]-1;

			a[j+1]=t;

			j--;

		}

	}

	for(int i=1;i<=n;i++) cout<<a[i];

			cout<<'\n';

}

signed main() 

{

	cin.tie(0),cout.tie(0);

  	int T=1;

  	cin>>T;

  	while(T--)

  	{

  		solve();

	}

    return 0;

}

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

#define int long long

using namespace std;

const int N = 2e5 + 10,INF=0x3f3f3f3f,mod= 1e9 + 7;

/*int prime[N];bool st[N];int cnt=0;

void getprime(long long  n)

{

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

    {

        if(!st[i])prime[cnt++]=i;

        for(int j=0;prime[j]<=n/i;j++)

        {

            st[prime[j]*i]=true;

            if(prime[j]%i==0)break;

        }

        

    }

}*/

int qsm(int n,int m)/*n^m*/

{

    int res=1;

    while(m)

    {

        if(m&1) 

        res=res*n%mod;

        n=n*n%mod;

        m>>=1;

    }

    return res;

}

map<string,int>mp,mpp; 

void solve()

{

    string s;

    cin>>s;

	int n=s.size();

    int a[N]={0};

    s=' '+s;

    if(n==1){

		cout<<s[1]<<'\n';

		return ;

	}

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

		a[i]=s[i]-'0';

	}

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

		int j=i;

		while(a[j+1]>a[j]+1&&j>=1){

			int t=a[j];

			a[j]=a[j+1]-1;

			a[j+1]=t;

			j--;

		}

	}

	for(int i=1;i<=n;i++) cout<<a[i];

			cout<<'\n';

}

signed main() 

{

	cin.tie(0),cout.tie(0);

  	int T=1;

  	cin>>T;

  	while(T--)

  	{

  		solve();

	}

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while(t--)

    {

        int n, l, r;

        cin>>n>>l>>r;

        vector<int> a(n);

        vector<int> b(n);

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

        {

            cin>>a[i];

            b[i] = a[i];

        }



        sort(a.begin(), a.begin()+r, std::greater<int>());

        sort(b.begin()+l-1, b.end());

        int ans1 = 0;

        int ans2 = 0;

        for (int i = l-1; i < r;++i)

        {

            ans1+=a[i];

            ans2+=b[i];

        }

        cout<<min(ans1,ans2)<<endl;

    }

    return 0;

}

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

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while(t--)

    {

        int n, l, r;

        cin>>n>>l>>r;

        vector<int> a(n);

        vector<int> b(n);

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

        {

            cin>>a[i];

            b[i] = a[i];

        }



        sort(a.begin(), a.begin()+r, std::greater<int>());

        sort(b.begin()+l-1, b.end());

        long long ans1 = 0;

        long long ans2 = 0;

        for (int i = l-1; i < r;++i)

        {

            ans1+=a[i];

            ans2+=b[i];

        }

        cout<<min(ans1,ans2)<<endl;

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while(t--)

    {

        int n, l, r;

        cin>>n>>l>>r;

        vector<int> a(n);

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

        {

            cin>>a[i];

        }

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

        int ans = 0;

        int k = r-l+1;

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

        {

            ans+=a[i];

        }

        cout<<ans<<endl;

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while(t--)

    {

        int n, l, r;

        cin>>n>>l>>r;

        vector<int> a(n);

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

        {

            cin>>a[i];

        }

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

        int ans = 0;

        int k = r-l+1;

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

        {

            ans+=a[i];

        }

        cout<<ans<<endl;

    }

    return 0;

}

Submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while(t--)

    {

        int n, l, r;

        cin>>n>>l>>r;

        vector<int> a(n);

        vector<int> b(n);

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

        {

            cin>>a[i];

            b[i] = a[i];

        }



        sort(a.begin(), a.begin()+r, std::greater<int>());

        sort(b.begin()+l-1, b.end());

        int ans1 = 0;

        int ans2 = 0;

        for (int i = l-1; i < r;++i)

        {

            ans1+=a[i];

            ans2+=b[i];

        }

        cout<<min(ans1,ans2)<<endl;

    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


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

using namespace std;

#define ll long long int

#define all(x) x.begin(),x.end() //is_sorted(all(x))

#define pb push_back(x)

#define yes cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define gcd(a, b) __gcd(a, b)

#define lcm(a, b) (a / gcd(a, b)) * b



int main(){

  int t; 

  cin>>t;

  while(t--)

  {

    ll n; cin>>n;

    string st; cin>>st;

    ll p=-1,s=-1;

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

        if(p==-1 && st[i]=='p')p=i;

        if(st[i]=='s')s=i;

    }

    if((p!=-1 and s!=0 ) and ((st[0]!='s' and st[n-1]!='p') || s>p))no

    else yes

  }

  return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll long long int

#define all(x) x.begin(),x.end() //is_sorted(all(x))

#define pb push_back(x)

#define yes cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define gcd(a, b) __gcd(a, b)

#define lcm(a, b) (a / gcd(a, b)) * b



int main(){

  int t; 

  cin>>t;

  while(t--)

  {

    ll n; cin>>n;

    string st; cin>>st;

    ll p=-1,s=-1;

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

        if(p==-1 && st[i]=='p')p=i;

        if(st[i]=='s')s=i;

    }

    if((p!=-1 and s!=0 ) and ((st[0]!='s' and st[n-1]!='p') || s>p))no

    else yes

  }

  return 0;

}

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

using namespace std;

#define ll long long int

#define all(x) x.begin(),x.end() //is_sorted(all(x))

#define pb push_back(x)

#define yes cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define gcd(a, b) __gcd(a, b)

#define lcm(a, b) (a / gcd(a, b)) * b



int main(){

  int t; 

  cin>>t;

  while(t--)

  {

    ll n; cin>>n;

    string st; cin>>st;

    ll p=-1,s=-1;

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

        if(p==-1 && st[i]=='p')p=i;

        if(st[i]=='s')s=i;

    }

    if((p!=-1 and s!=-1 ) and ((st[0]!='s' and st[n-1]!='p') || s>p))no

    else yes

  }

  return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll long long int

#define all(x) x.begin(),x.end() //is_sorted(all(x))

#define pb push_back(x)

#define yes cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define gcd(a, b) __gcd(a, b)

#define lcm(a, b) (a / gcd(a, b)) * b



int main(){

  int t; 

  cin>>t;

  while(t--)

  {

    ll n; cin>>n;

    string st; cin>>st;

    ll p=-1,s=-1;

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

        if(p==-1 && st[i]=='p')p=i;

        if(st[i]=='s')s=i;

    }

    if((p!=-1 and s!=-1 ) and ((st[0]!='s' and st[n-1]!='p') || s>p))no

    else yes

  }

  return 0;

}

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

using namespace std;

#define ll long long int

#define all(x) x.begin(),x.end() //is_sorted(all(x))

#define pb push_back(x)

#define yes cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define gcd(a, b) __gcd(a, b)

#define lcm(a, b) (a / gcd(a, b)) * b



int main(){

  int t; 

  cin>>t;

  while(t--)

  {

    ll n; cin>>n;

    string st; cin>>st;

    if(st[0]=='s')st[0]='.';

    if(st[n-1]=='p')st[n-1]='.';

    ll p=-1,s=-1;

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

        if(p==-1 && st[i]=='p')p=i;

        if(st[i]=='s')s=i;

    }

  

    if(p!=-1 and s!=-1 )no

    else yes

  }

  return 0;

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

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

using namespace std;

int main()
{
    int t; cin >> t;
    while(t)
    {
        int n; cin >> n;
        int a[n];
        for(int i = 0; i < n; i++) cin >> a[i];
        int sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum % n != 0)
        {
            cout << "NO" << endl;
            continue;
        }
        
        int unit = sum / n;
        int req_sum = 0; int test_sum = 0;
        for(int i = 0; i < n; i += 2)
        {
            req_sum += unit;
            test_sum += a[i];
        }
        if(test_sum != req_sum)
        {
            cout << "NO" << endl;
            continue;
        }
        cout << "YES" << endl;
        t--;
    }
}

Submission (verdict: Wrong answer on test 3):
#include <iostream>

using namespace std;

int main()
{
    int t; cin >> t;
    while(t)
    {
        int n; cin >> n;
        int a[n];
        for(int i = 0; i < n; i++) cin >> a[i];
        int sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum % n != 0)
        {
            cout << "NO" << endl;
            t--;
            continue;
        }
        
        int unit = sum / n;
        int req_sum = 0; int test_sum = 0;
        for(int i = 0; i < n; i += 2)
        {
            req_sum += unit;
            test_sum += a[i];
        }
        if(test_sum != req_sum)
        {
            cout << "NO" << endl;
            t--;
            continue;
        }
        cout << "YES" << endl;
        t--;
    }
}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>

using namespace std;

int main()
{
    int t; cin >> t;
    while(t)
    {
        int n; cin >> n;
        int a[n];
        for(int i = 0; i < n; i++) cin >> a[i];
        int sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum % n != 0)
        {
            cout << "NO" << endl;
            t--;
            continue;
        }
        
        int unit = sum / n;
        int req_sum = 0; int test_sum = 0;
        for(int i = 0; i < n; i += 2)
        {
            req_sum += unit;
            test_sum += a[i];
        }
        if(test_sum != req_sum)
        {
            cout << "NO" << endl;
            t--;
            continue;
        }
        cout << "YES" << endl;
        t--;
    }
}

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

using namespace std;

int main()
{
    int t; cin >> t;
    while(t)
    {
        int n; cin >> n;
        int a[n];
        for(int i = 0; i < n; i++) cin >> a[i];
        unsigned long long sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum % n != 0)
        {
            cout << "NO" << endl;
            t--;
            continue;
        }
        
        unsigned long long unit = sum / n;
        unsigned long long req_sum = 0, test_sum = 0;
        for(int i = 0; i < n; i += 2)
        {
            req_sum += unit;
            test_sum += a[i];
        }
        if(test_sum != req_sum)
        {
            cout << "NO" << endl;
            t--;
            continue;
        }
        cout << "YES" << endl;
        t--;
    }
}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)


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

using namespace std;

int main()
{
    int t; cin >> t;
    while(t)
    {
        int n; cin >> n;
        int a[n];
        for(int i = 0; i < n; i++) cin >> a[i];
        int sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum % n != 0)
        {
            cout << "NO" << endl;
            continue;
        }
        
        int unit = sum / n;
        int req_sum = 0; int test_sum = 0;
        for(int i = 0; i < n; i += 2)
        {
            req_sum += unit;
            test_sum += a[i];
        }
        if(test_sum != req_sum)
        {
            cout << "NO" << endl;
            continue;
        }
        cout << "YES" << endl;
        t--;
    }
}
Problem: 2050B - Transfusion
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;
		cin >> n;
		vector<int> a(n);
		int sum = 0;
		for(int i = 0; i < n; i++)
		{
			cin >> a[i];
			sum += a[i];
		}

		if(sum % 3 == 0)
			cout << "YES\n";
		else
			cout << "NO\n";
	}
	return 0;
}

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;
        vector<int> a(n);

        int sum1 = 0, sum2 = 0, ctr1 = 0, ctr2 = 0;

        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            if (i % 2 == 0)
            {
                sum1 += a[i];
                ctr1++;
            }
            else
            {
                sum2 += a[i];
                ctr2++;
            }
        }

        if ((sum1 * ctr2) == (sum2 * ctr1) && (sum1 + sum2) % n == 0)
        {
            cout << "YES\n";
        }
        else
        {
            cout << "NO\n";
        }
    }

    return 0;
}
Problem: 2050B - Transfusion
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;
		cin >> n;
		vector<int> a(n);
		int sum = 0;
		for(int i = 0; i < n; i++)
		{
			cin >> a[i];
			sum += a[i];
		}

		if(sum % 3 == 0)
			cout << "YES\n";
		else
			cout << "NO\n";
	}
	return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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;
        vector<int> a(n);

        int sum1 = 0, sum2 = 0, ctr1 = 0, ctr2 = 0;

        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            if (i % 2 == 0)
            {
                sum1 += a[i];
                ctr1++;
            }
            else
            {
                sum2 += a[i];
                ctr2++;
            }
        }

        if ((sum1 * ctr2) == (sum2 * ctr1) && (sum1 + sum2) % n == 0)
        {
            cout << "YES\n";
        }
        else
        {
            cout << "NO\n";
        }
    }

    return 0;
}


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;
        vector<int> a(n);

        int sum1 = 0, sum2 = 0, ctr1 = 0, ctr2 = 0;

        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            if (i % 2 == 0)
            {
                sum1 += a[i];
                ctr1++;
            }
            else
            {
                sum2 += a[i];
                ctr2++;
            }
        }

        if ((sum1 * ctr2) == (sum2 * ctr1) && (sum1 + sum2) % (ctr1 + ctr2) == 0)
        {
            cout << "YES\n";
        }
        else
        {
            cout << "NO\n";
        }
    }

    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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;
        vector<int> a(n);

        int sum1 = 0, sum2 = 0, ctr1 = 0, ctr2 = 0;

        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            if (i % 2 == 0)
            {
                sum1 += a[i];
                ctr1++;
            }
            else
            {
                sum2 += a[i];
                ctr2++;
            }
        }

        if ((sum1 * ctr2) == (sum2 * ctr1) && (sum1 + sum2) % (ctr1 + ctr2) == 0)
        {
            cout << "YES\n";
        }
        else
        {
            cout << "NO\n";
        }
    }

    return 0;
}


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

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

    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);

        long long sum1 = 0, sum2 = 0, ctr1 = 0, ctr2 = 0;

        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            if (i % 2 == 0)
            {
                sum1 += a[i];
                ctr1++;
            }
            else
            {
                sum2 += a[i];
                ctr2++;
            }
        }

        if ((sum1 * ctr2) == (sum2 * ctr1) && (sum1 + sum2) % (ctr1 + ctr2) == 0)
        {
            cout << "YES\n";
        }
        else
        {
            cout << "NO\n";
        }
    }

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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define f(i,a,b) for(int i=a; i<b; i++)
#define fr(i,a,b) for(int i=a; i>=b; i--)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define w(t) int t; cin>>t; while(t--)
#define ll long long


int main(){
w(t){
    int n ; cin>>n;
    vector<int> arr(n);
    long long even=0,odd=0;
    f(i,0,n) {
        int x; cin>>x;
        if(i%2) odd+=x;
        else even+=x;
    }
    bool z=false;
    if(n%2 ) {
        if(odd/(n/2) == even/(n/2 + 1) && (odd/(n/2) == ceil((double) odd/(n/2)))) z=true;
        }

    else {
            if(odd/(n/2) == even/(n/2) && (odd/(n/2) == ceil((double) odd/(n/2)))) z=true;
            }
    if(z) print("YES")
    else print("NO") 
   
}

}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define f(i,a,b) for(int i=a; i<b; i++)
#define fr(i,a,b) for(int i=a; i>=b; i--)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define w(t) int t; cin>>t; while(t--)
#define ll long long


int main(){
w(t){
    int n ; cin>>n;
    vector<int> arr(n);
    long long even=0,odd=0;
    f(i,0,n) {
        int x; cin>>x;
        if(i%2) odd+=x;
        else even+=x;
    }
    bool z=false;
    if(n%2 ) {
        if(odd/(n/2) == even/(n/2 + 1) && (odd/(n/2) == ceil((double) odd/(n/2))) && (even/(n/2) == ceil((double) even/(n/2 + 1)))) z=true;
        }

    else {
            if(odd/(n/2) == even/(n/2) && (odd/(n/2) == ceil((double) odd/(n/2))) &&(even/(n/2) == ceil((double) even/(n/2)))) 
            z=true;
            }
    if(z) print("YES")
    else print("NO") 
   
}

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


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define f(i,a,b) for(int i=a; i<b; i++)
#define fr(i,a,b) for(int i=a; i>=b; i--)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define w(t) int t; cin>>t; while(t--)
#define ll long long


int main(){
w(t){
    int n ; cin>>n;
    vector<int> arr(n);
    long long even=0,odd=0;
    f(i,0,n) {
        int x; cin>>x;
        if(i%2) odd+=x;
        else even+=x;
    }
    bool z=false;
    if(n%2 ) {
        if(odd/(n/2) == even/(n/2 + 1) && (odd/(n/2) == ceil((double) odd/(n/2)))) z=true;
        }

    else {
            if(odd/(n/2) == even/(n/2) && (odd/(n/2) == ceil((double) odd/(n/2)))) z=true;
            }
    if(z) print("YES")
    else print("NO") 
   
}

}