ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;
void solve(vector<long long> finder, long long n){
    long long sum_even = 0; 
    long long count_even = 0; 
    long long sum_odd = 0; 
    long long count_odd = 0; 
    for(long long i = 0; i<n; i++){
        if(i%2 == 0){
            sum_even+=finder[i];
            count_even++;
        }
        else{
            sum_odd+=finder[i];
            count_odd++; 
        }
    }
    if(sum_odd%count_odd!=0 || sum_even%count_even!=0){
        cout<<"NO"<<endl; 
        return; 
    }
    else if(sum_odd/count_odd!=sum_even/count_even){
        cout<<"NO"<<endl; 
        return; 
    }
    else {
        cout<<"YES"<<endl; 
        return ; 
    }
}
int main() {
    long long t; 
    cin>>t; 
    while(t--){
        long long n; 
        cin>>n; 
        vector<long long> finder(n);
        for(long long i = 0; i<n; i++){
            cin>>finder[i];
        }
        solve(finder,n);
    }
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
void solve(vector<int>finder, int n){
    int sum_even = 0; 
    int count_even = 0; 
    int sum_odd = 0; 
    int count_odd = 0; 
    for(int i = 0; i<n; i++){
        if(i%2 == 0){
            sum_even+=finder[i];
            count_even++;
        }
        else{
            sum_odd+=finder[i];
            count_odd++; 
        }
    }
    if(sum_odd%count_odd!=0 || sum_even%count_even!=0){
        cout<<"NO"<<endl; 
        return; 
    }
    else if(sum_odd/count_odd!=sum_even/count_even){
        cout<<"NO"<<endl; 
        return; 
    }
    else {
        cout<<"YES"<<endl; 
        return ; 
    }
    
}
int main() {
	int t; 
	cin>>t; 
	while(t--){
	    int n; 
	    cin>>n; 
	    vector<int>finder(n);
	    for(int i = 0; i<n; i++){
	        cin>>finder[i];
	    }
	    solve(finder,n);
	}

}


Answer: 1
Problem: 2050B - Transfusion
Language: c++17 

Code 1:
#include <bits/stdc++.h>

#define fast                     \

    ios::sync_with_stdio(false); \

    cin.tie(nullptr)

using namespace std;

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

        int k, d, n, sum = 0;

        bool flag = true;

        cin >> n;

        vector<int> A(n);

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

            cin >> A[i];



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

            sum += A[i];



        if (sum % n != 0)

            flag = false;

        else

        {

            d = sum / n;

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

            {

                if (A[i - 1] > d && A[i - 1] > 0)

                {

                    k = A[i - 1] - d;

                    A[i + 1] = A[i + 1] + k;

                    A[i - 1] = d;

                }

                else

                {

                    k = d - A[i - 1];

                    A[i + 1] = A[i + 1] - k;

                    A[i - 1] = d;

                }

            }

        }

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

            if (A[j] != d)

                flag = false;

        cout << (flag ? "YES" : "NO") << endl;

    }



    return 0;

}

Code 2:
#include <bits/stdc++.h>

#define fast                     \

    ios::sync_with_stdio(false); \

    cin.tie(nullptr)

#define ll long long

using namespace std;

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

        ll k = 0, d, n, sum = 0;

        bool flag = true;

        cin >> n;

        vector<int> A(n);

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

            cin >> A[i];

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

            sum += A[i];



        if (sum % n != 0)

            flag = false;

        else

        {

            d = sum / n;

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

            {

                if (A[i - 1] < d && A[i - 1] > 0)

                {

                    k = d - A[i - 1];

                    A[i + 1] = A[i + 1] - k;

                    A[i - 1] = d;

                }

                else

                {

                    k = A[i - 1] - d;

                    A[i + 1] = A[i + 1] + k;

                    A[i - 1] = d;

                }

            }

        }

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

            if (A[j] != d)

                flag = false;

        cout << (flag ? "YES" : "NO") << endl;

    }



    return 0;

}

Answer: 2
Problem: 2050B - Transfusion
Language: c++17 

Code 1:
#include <bits/stdc++.h>

using namespace std;

int main() {

    int t;

    cin>>t;

    while(t--){

        int n,oddsm=0,evensm=0,oddcnt=0,evencnt=0;

        cin>>n;

        int arr[n];

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

            cin>>arr[i];

            if(i%2==0){

                evensm+=arr[i];

                evencnt++;

            }

            else{

                oddsm+=arr[i];

                oddcnt++;

            }

        }

        if(evensm%evencnt!=0 || oddsm%oddcnt !=0 || evensm/evencnt!=oddsm/oddcnt)

            cout<<"NO\n";

        else cout<<"YES\n";

    }

    return 0;

}

Code 2:
#include <bits/stdc++.h>

using namespace std;

int main() {

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        int arr[n];

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

            cin>>arr[i];

        }

        long long oddsm=0,evensm=0,oddcnt=0,evencnt=0;

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

            if(i%2==0){

                evensm+=arr[i];

                evencnt++;

            }

            else{

                oddsm+=arr[i];

                oddcnt++;

            }

        }

        if (oddsm%oddcnt == 0 && evensm%evencnt == 0 && oddsm * evencnt == evensm * oddcnt)

            cout << "YES" << endl;

        else

            cout << "NO" << endl;

    }

    return 0;

}

Answer: 2
Problem: 2050B - Transfusion
Language: c++20 

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define nl "\n"
#define INF 1e18

void mainCode(){
    ll n=0,k;
    cin >> n ;
    vector<ll> v(n);
    ll sum=0;
    for(ll i=0;i<n;i++) {
        cin >> v[i];
        sum+=v[i];
    }
    if(sum%3==0) cout << "YES\n";
    else cout << "NO\n";

}

int main()
{
    int tc=0;
    cin >> tc;
    while(tc--)
    {
        mainCode();
    }
    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define nl "\n"
#define INF 1e18

void mainCode(){
    ll n=0,k;
    cin >> n ;
    vector<ll> v(n);
    ll odd=0,even=0;
    for(ll i=0;i<n;i++) {
        cin >> v[i];
        if(i &1) odd+=v[i];
        else even+=v[i];
    }
    ll nodd=n/2,neven=n/2;
    if(n&1) neven++;

    if(odd % nodd != 0 || even % neven != 0 || odd / nodd != even / neven){
        cout << "NO\n";
    }
    else cout << "YES\n";

}

int main()
{
    int tc=0;
    cin >> tc;
    while(tc--)
    {
        mainCode();
    }
    return 0;
}


Answer: 2
Problem: 2050B - Transfusion
Language: python

Code 1:
a=int(input())
for _ in range(a):
    b=int(input())
    c=list(map(int,input().split()))
    if sum(c)%b!=0:
        print('NO')
    else:
        t=sum(c)//b
        w=[]
        l=[]
        for i in range(b):
            if i%2==0:
                w.append(c[i])
            else:
                l.append(c[i])
        if sum(l)//len(l)==t==sum(w)//len(w):
            print('YES')
        else:
            print('NO')

Code 2:
a=int(input())
for _ in range(a):
    b=int(input())
    c=list(map(int,input().split()))
    if sum(c)%b!=0:
        print('NO')
        exit()
    t=sum(c)//b
    w=[]
    l=[]
    for i in range(b):
        if i%2==0:
            w.append(c[i])
        else:
            l.append(c[i])
    if sum(l)//len(l)==t==sum(w)//len(w):
        print('YES')
    else:
        print('NO')

Answer: 1
Problem: 2050B - Transfusion
Language: c++17 

Code 1:
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector <ll> v(n);
        set <ll> st;
        for (int i=0; i<n; i++) {
            cin >> v[i];
            st.insert(v[i]);
        }
        if (st.size() == 1) {
            cout << "yes\n";
            continue;
        }
        ll mn = INT_MAX;
        int pos = -1;
        for (int i=2; i<n; i ++) {
            ll diff = abs(v[i] - v[i-2]);
            if (diff > 0 && diff % 2 == 0 && diff < mn) {
                mn = diff;
                pos = i;
            }
        }
        if (pos == -1) {
            cout << "no\n";
            continue;
        }
        //cout << pos << " ";
        ll target;
        if (v[pos] > v[pos - 2]) target = v[pos] - mn/2;
        else target = v[pos] + mn/2;
        ll tot = 0;
        for (ll num: v) {
            tot += num - target;
        }
        if (tot == 0) cout << "yes\n";
        else cout << "no\n";
    }
}

Code 2:
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        ll od = 0, ev = 0;
        for (int i=0; i<n; i++) {
            int x;
            cin >> x;
            if (i%2 == 0) ev += x;
            else od += x;
        }
        ll eve = n / 2, ode = n / 2;
        if (n%2 != 0) eve ++;
        if (ev % eve == 0 && od % ode == 0 && ev / eve == od / ode) cout << "yes\n";
        else cout << "no\n";
    }
}

Answer: 2
Problem: 2050B - Transfusion
Language: c++17 

Code 1:
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5+5;
int t,n,a[N],d[N];
int main(){
	cin >> t; while(t--){
		cin >> n; 
		for(int i=1;i<=n;i++){
			cin >> a[i];
			d[i] = a[i] - a[i-1];
//			printf("%d ",d[i]);
		}
//		cout << endl;
		for(int i=2;i<n;i++){
			if(i!=n-1){
				int b = d[i] - (d[i] - d[i+1])/2;
				d[i-1] += b;
				d[i] -= b;
				d[i+1] -= b;
				d[i+2] += b;				
			}else{
				int b = d[i];
				d[i-1] += b;
				d[i] -= b;
				d[i+1] -= b;
			}
		}
		int ans = 0;
		for(int i=2;i<=n;i++){
			ans += d[i]==0;
//			printf("%d ",d[i]);
		}
//		cout << endl;
			
		if(ans==n-1)cout<<"Yes\n";
		else cout<<"No\n";
	}	
	
	return 0;
}


Code 2:
#include "bits/stdc++.h"
using namespace std;
int t,n,a;
int main(){
	cin >> t; while(t--){
		cin >> n;
		long long dan=0,dann=0,shuang=0,shuangn=0;
		for(int i=1;i<=n;i++){
			cin >> a;
			if(i%2){
				dan += a;
				dann++;
			}else{
				shuang += a;
				shuangn++;
			}
		}
		if(dan%dann==0 and shuang%shuangn==0 and dan/dann == shuang/shuangn) cout<<"yes\n";
		else cout<<"no\n";
		
	}
	
}

Answer: 2
Problem: 2050B - Transfusion
Language: other

Code 1:
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let inputStrings;
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputStrings = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    main();    
});

function readline() {
    return inputStrings[currentLine++];
}

function main() {
    const arr = readline().split(' ').map(x => parseInt(x));
    let odds = 0;
    let evens = 0;
    let count_odd_idx = arr.length / 2 + arr.length % 2;
    let count_even_idx = arr.length / 2;
    for (var i = 0; i < arr.length; ++i) {
        odds += i % 0 === 0 ? arr[i] : 0; 
        evens += i % 0 === 1 ? arr[i] : 0; 
    }

    if (odds % count_odd_idx !== 0
       || evens % count_even_idx !== 0) {
        console.log("NO");
        return;
    }

    if (odds / count_odd_idx !== evens / count_even_idx) {
        console.log("NO");
        return;
    }

    console.log("YES");
    return 
}


Code 2:
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let inputStrings;
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputStrings = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    main();    
});

function readline() {
    return inputStrings[currentLine++];
}

function main() {
    const runs = readline();
    for (var j = 0; j < runs; ++j) {
        const len = parseInt(readline());
        const arr = readline().split(' ').map(x => parseInt(x));
        let odds = 0;
        let evens = 0;
        let count_odd_idx = Math.floor(arr.length / 2) + arr.length % 2;
        let count_even_idx = Math.floor(arr.length / 2);
        for (var i = 0; i < arr.length; ++i) {
            odds += i % 2 == 0 ? arr[i] : 0; 
            evens += i % 2 == 1 ? arr[i] : 0; 
        }

        if (odds % count_odd_idx != 0
            || evens % count_even_idx != 0) {
                console.log("NO");
                continue;
            }

            if (Math.floor(odds / count_odd_idx) !== Math.floor(evens / count_even_idx)) {
                console.log("NO");
                continue;
            }

            console.log("YES");
            continue; 
    }

    return;
}


Answer: 2
Problem: 2050B - Transfusion
Language: c++17 

Code 1:
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;



int main () {
    int t, n;

    cin >> t;
    while (t--) {
        cin >> n;
        unsigned long long even_sum=0, odd_sum=0, even_count=0, odd_count=0;
        for (int i=0; i<n; i++) {
            int a;
            cin >> a;
            if (i%2==0) { even_sum += a; even_count++; }
            else { odd_sum += a; odd_count++; }
        }
        if (even_sum%even_count==0 && odd_sum%odd_count==0 && even_sum/even_count==odd_sum/odd_count) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

Code 2:
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;



int main () {
    int t, n;

    cin >> t;
    while (t--) {
        cin >> n;
        int even_sum=0, odd_sum=0, even_count=0, odd_count=0;
        for (int i=0; i<n; i++) {
            int a;
            cin >> a;
            if (i%2==0) { even_sum += a; even_count++; }
            else { odd_sum += a; odd_count++; }
        }
        if (even_sum%even_count==0 && odd_sum%odd_count==0 && even_sum/even_count==odd_sum/odd_count) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

Answer: 1
Problem: 2050B - Transfusion
Language: c++20 

Code 1:
#include<bits/stdc++.h>
using namespace std;

void solve(){
    int n ; cin >> n;
    vector<int>v;
    v.push_back(0);
    for(int i=1 ; i<n+1; i++){
        int a ; cin >> a;
        v.push_back(a);
    }
    // for(auto u : v) cout<<u<<" ";
    // cout<<endl;
    int odd=0,even=0,OddSum=0,EvenSum=0;
    for(int i=1; i<n+1; i++){
        if(i%2==0){
            EvenSum += v[i];
            even++;
        }
        else{
            OddSum += v[i];
            odd++;
        }
    }
    // cout<<OddSum<<" "<<odd<<endl;
    if(OddSum % odd == 0 and EvenSum % even == 0){
        if(OddSum / odd == EvenSum / even){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    else{
        cout<<"NO"<<endl;
    }
}
int main(){
    int tc ; cin >> tc;
    while(tc--){
        solve();
    }
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
#define ll long long

void solve(){
    int n ; cin >> n;
    vector<ll>v;
    v.push_back(0);
    for(int i=1 ; i<n+1; i++){
        ll a ; cin >> a;
        v.push_back(a);
    }
    // for(auto u : v) cout<<u<<" ";
    // cout<<endl;
    ll odd=0,even=0,OddSum=0,EvenSum=0;
    for(int i=1; i<n+1; i++){
        if(i%2==0){
            EvenSum += v[i];
            even++;
        }
        else{
            OddSum += v[i];
            odd++;
        }
    }
    // cout<<OddSum<<" "<<odd<<endl;
    if(OddSum % odd == 0 and EvenSum % even == 0){
        if(OddSum / odd == EvenSum / even){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    else{
        cout<<"NO"<<endl;
    }
}
int main(){
    int tc ; cin >> tc;
    while(tc--){
        solve();
    }
}

Answer: 2
Problem: 2050B - Transfusion
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;

#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Rikie cout.tie(NULL);
#define ll long long

void solve(){
    ll n;
    cin >> n;
    ll arr[n];
    for(int i = 0 ; i < n; i++){
        cin >> arr[i];
    }
    int cEven , cOdd;
    if(n%2==0){
        cOdd = n/2;
        cEven = n/2;
    }
    else{
        cEven = (n/2) + 1;
        cOdd = n/2;
    }
    int sumOdd = 0 , sumEven = 0 ;
    for(int i = 0;i < n; i ++){
        if (i%2==0){
            sumEven+=arr[i];
        }
        else{
            sumOdd+=arr[i];
        }
    }

    if( sumEven%cEven==0 && sumOdd%cOdd==0&&sumEven/cEven == sumOdd/cOdd ){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

int main(){

    Code By Rikie

    int t;
    cin >> t;
    while(t--){
    
        solve();
        
    }

    return 0;
}

Code 2:
#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &x : a) cin >> x;
    
    long long ods = 0, evs = 0;
    for (int i = 0; i < n; i++) {
        if (i & 1) ods += a[i];
        else evs += a[i];
    }
    int odc = n / 2, evc = n / 2;
    if (n & 1) evc++;

    if (ods % odc != 0 || evs % evc != 0 || ods / odc != evs / evc) {
        cout << "NO";
        return;
    }
    cout << "YES";
}

int main() {
    int TESTS; cin >> TESTS;
    while (TESTS --> 0) {
        solve();
        cout << '\n';
    }
    return 0;
}

Answer: 2
Problem: 2050B - Transfusion
Language: c++23 

Code 1:
#include <bits/stdc++.h>

void solve() {
    int n; std::cin >> n;
    std::vector<int> odd, even;
    for (int i = 0, x; i < n; i++) {
        std::cin >> x;
        if (i & 1) odd.push_back(x);
        else even.push_back(x);
    }
    int oddSum = 0, evenSum = 0;
    for (auto x : odd) oddSum += x;
    for (auto x : even) evenSum += x;
    bool oddPart = oddSum % odd.size() == 0;
    bool evenPart = evenSum % even.size() == 0;
    if (oddPart && evenPart && oddSum / odd.size() == evenSum / even.size()) {
        std::cout << "YES\n";
    } else {
        std::cout << "NO\n";
    }
}

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    int tt; std::cin >> tt;
    while (tt--) solve();

    return 0;
}

Code 2:
#include <bits/stdc++.h>
using i64 = long long;

void solve() {
    int n; std::cin >> n;
    i64 oddSum = 0, evenSum = 0, oddCnt = 0, evenCnt = 0;
    for (int i = 0, x; i < n; i++) {
        std::cin >> x;
        if (i & 1) {
            oddSum += x; oddCnt++;
        } else {
            evenSum += x; evenCnt++;
        }
    }
    bool oddPart = oddSum % oddCnt == 0;
    bool evenPart = evenSum % evenCnt == 0;
    bool connected = oddSum / oddCnt == evenSum / evenCnt;
    std::cout << (oddPart && evenPart && connected ? "YES\n" : "NO\n");
}

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    int tt; std::cin >> tt;
    while (tt--) solve();

    return 0;
}

Answer: 2
Problem: 2050B - Transfusion
Language: c++20 

Code 1:
#include <bits/stdc++.h>

using namespace std; 

int main () {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t; cin >> t;

    while(t--) {

        int n; cin >> n;

        long long x, suma = 0, sumb=0;

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

            cin >> x;

            if(i%2==0) {

                sumb += x;

            } else {

                suma += x;

            }

        }

        

        if(n%2==0) {

            int f = n/2;

            if(sumb%f==0 and suma%f==0 and sumb/f==suma/(f)) {

                cout << "YES" << '\n';

            } else {

                cout << "NO" << '\n';

            }

        } else {

            int f = n/2;

            if(sumb%(f)==0 and suma%(f+1)==0 and sumb/f==suma/(f+1)) {

                cout << "YES" << '\n';

            } else {

                cout << "NO" << '\n';

            }

        }

        

    }

}

Code 2:
#include <bits/stdc++.h>

using namespace std; 

int main () {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t; cin >> t;

    while(t--) {

        int n; cin >> n;

        int x, suma = 0, sumb=0;

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

            cin >> x;

            if(i%2==0) {

                sumb += x;

            } else {

                suma += x;

            }

        }

        

        if(n%2==0) {

            int f = n/2;

            if(sumb%f==0 and suma%f==0 and sumb/f==suma/(f)) {

                cout << "YES" << '\n';

            } else {

                cout << "NO" << '\n';

            }

        } else {

            int f = n/2;

            if(sumb%(f)==0 and suma%(f+1)==0 and sumb/f==suma/(f+1)) {

                cout << "YES" << '\n';

            } else {

                cout << "NO" << '\n';

            }

        }

        

    }

}

Answer: 1
Problem: 2050B - Transfusion
Language: c++23 

Code 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") 
   
// }

// }
#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &x : a) cin >> x;
    
    long long ods = 0, evs = 0;
    for (int i = 0; i < n; i++) {
        if (i & 1) ods += a[i];
        else evs += a[i];
    }
    int odc = n / 2, evc = n / 2;
    if (n & 1) evc++;

    if (ods % odc != 0 || evs % evc != 0 || ods / odc != evs / evc) {
        cout << "NO";
        return;
    }
    cout << "YES";
}

int main() {
    int TESTS; cin >> TESTS;
    while (TESTS --> 0) {
        solve();
        cout << '\n';
    }
    return 0;
}

Code 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))) && (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") 
   
}

}

Answer: 1