ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>

using namespace std;

#define int long long

#define endl '\n'

#define optimize() ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()

{

	optimize();

	int t;

	cin>>t;

	while(t--){

		int n,l,r;

		cin>>n>>l>>r;

		vector<int>v(n);

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

			cin>>v[i];

		} 

		vector<int>v1=v;

		sort(v1.begin(),v1.begin()+r);

		int sum1=accumulate(v1.begin(),v1.begin()+r-l+1,0LL);

		vector<int>v2=v;

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

		int sum2=accumulate(v2.begin()+l-1,v2.begin()+r,0LL);

		cout<<min(0LL,sum1,sum2)<<endl;

	}

}

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

using namespace std;

#define int long long

#define endl '\n'

#define optimize() ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()

{

	optimize();

	int t;

	cin>>t;

	while(t--){

		int n,l,r;

		cin>>n>>l>>r;

		vector<int>v(n);

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

			cin>>v[i];

		} 

		vector<int>v1=v;

		sort(v1.begin(),v1.begin()+r);

		int sum1=accumulate(v1.begin(),v1.begin()+r-l+1,0LL);

		vector<int>v2=v;

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

		int sum2=accumulate(v2.begin()+l-1,v2.begin()+r,0LL);

		cout<<min({sum1,sum2})<<endl;

	}

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

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

using namespace std;

#define int long long

#define endl '\n'

#define optimize() ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()

{

	optimize();

	int t;

	cin>>t;

	while(t--){

		int n,l,r;

		cin>>n>>l>>r;

		vector<int>v(n);

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

			cin>>v[i];

		} 

		vector<int>v1=v;

		sort(v1.begin(),v1.begin()+r);

		int sum1=accumulate(v1.begin(),v1.begin()+r-l+1,0);

		vector<int>v2=v;

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

		int sum2=accumulate(v2.begin()+l-1,v2.begin()+r,0);

		cout<<min(sum1,sum2)<<endl;

	}

}

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

using namespace std;

#define int long long

#define endl '\n'

#define optimize() ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()

{

	optimize();

	int t;

	cin>>t;

	while(t--){

		int n,l,r;

		cin>>n>>l>>r;

		vector<int>v(n);

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

			cin>>v[i];

		} 

		vector<int>v1=v;

		sort(v1.begin(),v1.begin()+r);

		int sum1=accumulate(v1.begin(),v1.begin()+r-l+1,0LL);

		vector<int>v2=v;

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

		int sum2=accumulate(v2.begin()+l-1,v2.begin()+r,0LL);

		cout<<min(0LL,sum1,sum2)<<endl;

	}

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	int t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		vector<int> a;
		if(s.length() < 9){
			for(int i=0; i<s.length(); i++){
				a.push_back(s[i]-'0');
			}
		}
		else{
			for(int i=0; i<s.length(); i++){
				a.push_back(s[i]-'0');
			}
		}
	//	vector<int> a = {9, 8, 7, 6, 5, 4 ,3, 2, 1};
		vector<int> result;
		int size = a.size();
		for(int j=0; j<size; j++){
			int max = a[0];
			int track = 0;
			for(int i=0; i<a.size(); i++){
				if(max < a[i] - i){
					max = a[i] - i;
					track = i;
				}
			}
			result.push_back(max);
			a.erase(a.begin() + track);

		}
		for(int i=0; i<result.size(); i++){
			cout<<result[i];
		}
		if(s.length() > 9){
			for(int i=10; i<s.length(); i++){
				cout<<s[i];
			}
		}
		cout<<endl;	
	}
	
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	int t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		vector<int> a;
		if(s.length() < 9){
			for(int i=0; i<s.length(); i++){
				a.push_back(s[i]-'0');
			}
		}
		else{
			for(int i=0; i<s.length(); i++){
				a.push_back(s[i]-'0');
			}
		}
	//	vector<int> a = {9, 8, 7, 6, 5, 4 ,3, 2, 1};
		vector<int> result;
		int size = a.size();
		for(int j=0; j<size; j++){
			int max = a[0];
			int track = 0;
			for(int i=0; i<a.size(); i++){
				if(max < a[i] - i){
					max = a[i] - i;
					track = i;
				}
			}
			result.push_back(max);
			a.erase(a.begin() + track);

		}
		for(int i=0; i<result.size(); i++){
			cout<<result[i];
		}
		if(s.length() > 9){
			for(int i=10; i<s.length(); i++){
				cout<<s[i];
			}
		}
		cout<<endl;	
	}
	
}

Submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	int t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		vector<int> a;
		if(s.length() < 9){
			for(int i=0; i<s.length(); i++){
				a.push_back(s[i]-'0');
			}
		}
		else{
			for(int i=0; i<s.length(); i++){
				a.push_back(s[i]-'0');
			}
		}
	//	vector<int> a = {9, 8, 7, 6, 5, 4 ,3, 2, 1};
		vector<int> result;
		int size = a.size();
		for(int j=0; j<size; j++){
			int max = a[0];
			int track = 0;
			for(int i=0; i<a.size(); i++){
				if(max < a[i] - i){
					max = a[i] - i;
					track = i;
				}
			}
			result.push_back(max);
			a.erase(a.begin() + track);

		}
		for(int i=0; i<result.size(); i++){
			cout<<result[i];
		}
//		if(s.length() > 9){
//			for(int i=10; i<s.length(); i++){
//				cout<<s[i];
//			}
//		}
		cout<<endl;	
	}
	
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	int t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		vector<int> a;
		if(s.length() < 9){
			for(int i=0; i<s.length(); i++){
				a.push_back(s[i]-'0');
			}
		}
		else{
			for(int i=0; i<s.length(); i++){
				a.push_back(s[i]-'0');
			}
		}
	//	vector<int> a = {9, 8, 7, 6, 5, 4 ,3, 2, 1};
		vector<int> result;
		int size = a.size();
		for(int j=0; j<size; j++){
			int max = a[0];
			int track = 0;
			for(int i=0; i<a.size(); i++){
				if(max < a[i] - i){
					max = a[i] - i;
					track = i;
				}
			}
			result.push_back(max);
			a.erase(a.begin() + track);

		}
		for(int i=0; i<result.size(); i++){
			cout<<result[i];
		}
//		if(s.length() > 9){
//			for(int i=10; i<s.length(); i++){
//				cout<<s[i];
//			}
//		}
		cout<<endl;	
	}
	
}

Submission (verdict: Accepted):
#include<iostream>
using namespace std;
int main() {
	int t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		for(int i=0; i<s.length(); i++){
			if(s[i] < s[i+1]-1){
				swap(s[i], s[i+1]);
				s[i]--;
				if(i>=1){
					i-=2;
				}
			}
		}
		cout<<s<<endl;
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
int main(){
    
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
    int testcase;
    cin>>testcase;
    while(testcase--){
            int n;
            cin>>n;
            vector<int>v(n,0);
            for(int &x:v)cin>>x;
            //    for(int x: v)cout<<x<<" ";
                int pi=max_element(v.begin(),v.end())-v.begin();
            if(pi==0)no
                else{
                    int ptr=0;
                    for(int i=0;i+1<n;i++){
                            if(v[i]>v[i+1]){
                                ptr=i+1;
                                break;
                            }
                        }
                            if(ptr==n-1){
                                yes
                                break;
                            }
                            int temp=max_element(v.begin()+ptr,v.end())-v.begin()+ptr;
                            if(temp==0)no
                                else yes
                    
                }
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
int main(){
    
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
    int testcase;
    cin>>testcase;
    while(testcase--){
            int n;
            cin>>n;
            vector<int>v(n,0);
            for(int &x:v)cin>>x;
            //    for(int x: v)cout<<x<<" ";
                int pi=max_element(v.begin(),v.end())-v.begin();
            if(pi==0)no
                else{
                    int ptr=0;
                    for(int i=0;i+1<n;i++){
                            if(v[i]>v[i+1]){
                                ptr=i+1;
                                break;
                            }
                        }
                            if(ptr==n-1){
                                yes
                                break;
                            }
                            int temp=max_element(v.begin()+ptr,v.end())-v.begin()+ptr;
                            if(temp==0)no
                                else yes
                    
                }
    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
int main(){
    
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
    int testcase;
    cin>>testcase;
    while(testcase--){
            int n;
            cin>>n;
            vector<int>v(n,0);
            for(int &x:v)cin>>x;
            //    for(int x: v)cout<<x<<" ";
                int pi=max_element(v.begin(),v.end())-v.begin();
          int ans=INT_MIN;
            int interval=0;
            if(pi==0)no
                else{
                   for(int i=0;i<n-1;i++){
                    if(v[i]>v[i+1])interval++;
                    else {
                        ans=max(ans,interval);
                        interval=0;
                    }
                   }
                   if(ans>1)no
                    else yes
                }
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
int main(){
    
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
    int testcase;
    cin>>testcase;
    while(testcase--){
            int n;
            cin>>n;
            vector<int>v(n,0);
            for(int &x:v)cin>>x;
            //    for(int x: v)cout<<x<<" ";
                int pi=max_element(v.begin(),v.end())-v.begin();
          int ans=INT_MIN;
            int interval=0;
            if(pi==0)no
                else{
                   for(int i=0;i<n-1;i++){
                    if(v[i]>v[i+1])interval++;
                    else {
                        ans=max(ans,interval);
                        interval=0;
                    }
                   }
                   if(ans>1)no
                    else yes
                }
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
int main(){
    
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
    int testcase;
    cin>>testcase;
    while(testcase--){
            int n;
            cin>>n;
            vector<int>v(n,0);
            for(int &x:v)cin>>x;
            //    for(int x: v)cout<<x<<" ";
                for(int i=0;i<n-1;i++){
                    int ct=min(v[i],v[i+1]);
                    v[i]-=ct;
                    v[i+1]-=ct;
                }
                // for(int x: v)cout<<x<<" ";
                //     cout<<endl;
                if(is_sorted(v.begin(),v.end()))yes
                    else no;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using ll=long long;
using namespace __gnu_pbds;
template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;


int mod=1e9+7;
struct mint {
    ll x;
    mint(ll _x) {
        x=_x%mod;
        if (x<0)x+=mod;
    }
    mint operator +(mint y) {
        return x+y.x;
    }
    mint operator - (mint y) {
        return x-y.x;
    }
    mint operator * (mint y) {
        return x*y.x;
    }
};

mint power(mint a,ll b) {
    mint res=1;
    while (b) {
        if (b&1) {
            res=res*a;
        }
        a = a*a;
        b/=2;
    }
    return res;
}
mint inverse(mint a) {
    return power(a,mod-2);
}
//------------------------------------------------------------------------------------------------------------------------

void solve() {
    int n;
    cin>>n;
    vector<int>a(n);
    for (int &x:a)cin>>x;
    ll ans=-1e18;
    int limit=n;
    for (int i=0;i<n;i++) {
        ll sum=0;
        for (int j=0;j<limit;j++)sum+=a[j];
        if (i==0)ans=max(ans,sum);
        else ans=max(ans,max(sum,-sum));

        for (int j=0;j<limit-1;j++)a[j]=a[j+1]-a[j];
        limit--;
    }
    cout<<ans<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int t=1;
    cin>>t;
    while (t--)solve();
    return 0;
}

Submission (verdict: Compilation error):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using ll=long long;
using namespace __gnu_pbds;
template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;


int mod=1e9+7;
struct mint {
    ll x;
    mint(ll _x) {
        x=_x%mod;
        if (x<0)x+=mod;
    }
    mint operator +(mint y) {
        return x+y.x;
    }
    mint operator - (mint y) {
        return x-y.x;
    }
    mint operator * (mint y) {
        return x*y.x;
    }
};

mint power(mint a,ll b) {
    mint res=1;
    while (b) {
        if (b&1) {
            res=res*a;
        }
        a = a*a;
        b/=2;
    }
    return res;
}
mint inverse(mint a) {
    return power(a,mod-2);
}
//------------------------------------------------------------------------------------------------------------------------

void solve() {
    int n;
    cin>>n;
    vector<ll>a(n);
    for (int &x:a)cin>>x;
    ll ans=-1e18;
    int limit=n;
    for (int i=0;i<n;i++) {
        ll sum=0;
        for (int j=0;j<limit;j++)sum+=a[j];
        if (i==0)ans=max(ans,sum);
        else ans=max(ans,max(sum,-sum));

        for (int j=0;j<limit-1;j++)a[j]=a[j+1]-a[j];
        limit--;
    }
    cout<<ans<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int t=1;
    cin>>t;
    while (t--)solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using ll=long long;
using namespace __gnu_pbds;
template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;


int mod=1e9+7;
struct mint {
    ll x;
    mint(ll _x) {
        x=_x%mod;
        if (x<0)x+=mod;
    }
    mint operator +(mint y) {
        return x+y.x;
    }
    mint operator - (mint y) {
        return x-y.x;
    }
    mint operator * (mint y) {
        return x*y.x;
    }
};

mint power(mint a,ll b) {
    mint res=1;
    while (b) {
        if (b&1) {
            res=res*a;
        }
        a = a*a;
        b/=2;
    }
    return res;
}
mint inverse(mint a) {
    return power(a,mod-2);
}
//------------------------------------------------------------------------------------------------------------------------

void solve() {
    int n;
    cin>>n;
    vector<int>a(n);
    for (int &x:a)cin>>x;
    ll ans=-1e18;
    int limit=n;
    for (int i=0;i<n;i++) {
        ll sum=0;
        for (int j=0;j<limit;j++)sum+=a[j];
        if (i==0)ans=max(ans,sum);
        else ans=max(ans,max(sum,-sum));

        for (int j=0;j<limit-1;j++)a[j]=a[j+1]-a[j];
        limit--;
    }
    cout<<ans<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int t=1;
    cin>>t;
    while (t--)solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using ll=long long;
using namespace __gnu_pbds;
template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;


int mod=1e9+7;
struct mint {
    ll x;
    mint(ll _x) {
        x=_x%mod;
        if (x<0)x+=mod;
    }
    mint operator +(mint y) {
        return x+y.x;
    }
    mint operator - (mint y) {
        return x-y.x;
    }
    mint operator * (mint y) {
        return x*y.x;
    }
};

mint power(mint a,ll b) {
    mint res=1;
    while (b) {
        if (b&1) {
            res=res*a;
        }
        a = a*a;
        b/=2;
    }
    return res;
}
mint inverse(mint a) {
    return power(a,mod-2);
}
//------------------------------------------------------------------------------------------------------------------------

void solve() {
    int n;
    cin>>n;
    vector<ll>a(n);
    for (int &x:a)cin>>x;
    ll ans=-1e18;
    int limit=n;
    for (int i=0;i<n;i++) {
        ll sum=0;
        for (int j=0;j<limit;j++)sum+=a[j];
        if (i==0)ans=max(ans,sum);
        else ans=max(ans,max(sum,-sum));

        for (int j=0;j<limit-1;j++)a[j]=a[j+1]-a[j];
        limit--;
    }
    cout<<ans<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int t=1;
    cin>>t;
    while (t--)solve();
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using ll=long long;
using namespace __gnu_pbds;
template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;


int mod=1e9+7;
struct mint {
    ll x;
    mint(ll _x) {
        x=_x%mod;
        if (x<0)x+=mod;
    }
    mint operator +(mint y) {
        return x+y.x;
    }
    mint operator - (mint y) {
        return x-y.x;
    }
    mint operator * (mint y) {
        return x*y.x;
    }
};

mint power(mint a,ll b) {
    mint res=1;
    while (b) {
        if (b&1) {
            res=res*a;
        }
        a = a*a;
        b/=2;
    }
    return res;
}
mint inverse(mint a) {
    return power(a,mod-2);
}
//------------------------------------------------------------------------------------------------------------------------

void solve() {
    int n;
    cin>>n;
    vector<ll>a(n);
    for (ll &x:a)cin>>x;
    ll ans=-1e18;
    int limit=n;
    for (int i=0;i<n;i++) {
        ll sum=0;
        for (int j=0;j<limit;j++)sum+=a[j];
        if (i==0)ans=max(ans,sum);
        else ans=max(ans,max(sum,-sum));

        for (int j=0;j<limit-1;j++)a[j]=a[j+1]-a[j];
        limit--;
    }
    cout<<ans<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int t=1;
    cin>>t;
    while (t--)solve();
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
template <typename _Tp> bool minimize(_Tp &__a, const _Tp &__b) { if (__a > __b) { __a = __b; return true; } return false; }
template <typename _Tp> bool maximize(_Tp &__a, const _Tp &__b) { if (__a < __b) { __a = __b; return true; } return false; }
#define int long long
#define pb push_back
#define fi first
#define vi vector<int>
#define se second
#define pii pair<int,int>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define allof(a,n) a + 1, a + 1 + n
#define fo(i,a,b) for(int i = a; i <= b; i++)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define file "ship"
#define I ios_base :: sync_with_stdio(0);
#define wish cin.tie(0);
#define have cout.tie(0);
#define tomorrow if(fopen(file".inp","r")) {freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);}
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
const int single_test = 1;
const int base = 31;
namespace memaybeobachlong
{
    void solve()
    {
        int n;
        cin >> n;
        int a[n + 1];
        fo(i, 1, n) cin >> a[i];
        for(int i = n; i >= 1; i--)
            if(a[i] > a[i - 1])
            {
                id = i;
                break;
            }
        if(!id) return cout << "YES\n", void();
        fo(i, 2, id - 1)
        {
            if(a[i - 1] > a[i])
                return cout << "NO\n", void();
            a[i] -= a[i - 1];
        }
        if(a[id - 1] <= a[id] && a[id] - a[id - 1] <= a[id + 1])
            cout << "YES\n";
        else cout << "NO\n";
    }
}
int32_t main()
{
    I wish have tomorrow
    int t = 1;
    if(single_test)
        cin >> t;
    while(t--)
        memaybeobachlong :: solve();
}
Problem: 2050B - Transfusion
Language: C++23 (GCC 14-64, msys2)

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;
        cin >> n;
        vector<int> a(n);
        float sum_even = 0, sum_odd = 0, count_even = 0, count_odd = 0;

        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            if (i % 2 == 0)
            {
                sum_even += a[i];
                count_even++;
            }
            else
            {
                sum_odd += a[i];
                count_odd++;
            }
        }
        
        float avg_even = sum_even / count_even;
        float avg_odd = sum_odd / count_odd;
        
        if (fmod(avg_even, 2) != 0 || fmod(avg_odd, 2) != 0)
        {
            cout << "NO" << endl;
        }
        else if (count_even == 0 || count_odd == 0 || avg_even != avg_odd)
        {
            cout << "NO" << endl;
        }
        else
        {
            cout << "YES" << endl;
        }
    }

    return 0;
}


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

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

    while (t--) {
        int n;
        cin >> n;
        vector<float> a(n);
        double sum_even = 0, sum_odd = 0;
        int count_even = 0, count_odd = 0;

        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            if (i % 2 == 0) { // Even index
                sum_even += a[i];
                count_even++;
            } else { // Odd index
                sum_odd += a[i];
                count_odd++;
            }
        }

        double avg_even = (count_even > 0) ? sum_even / count_even : 0;
        double avg_odd = (count_odd > 0) ? sum_odd / count_odd : 0;

        // Check if both averages are even
        if (static_cast<int>(avg_even) % 2 != 0 || static_cast<int>(avg_odd) % 2 != 0) {
            cout << "NO" << endl;
        } else if (count_even == 0 || count_odd == 0 || avg_even != avg_odd) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }

    return 0;
}