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

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


void solv() {
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto &i:v) cin>>i;
    int odd=0, even=0, sum = 0;
    for(int i=0;i<n; i++) {
        if(i%2) odd+=v[i];
        else even+=v[i];
        sum+=v[i];
    }
    if(sum % n != 0) {
        cout << "NO\n";
        return;
    }
    int avg = sum / n;
    if(n%2) {
        if(even / ((n+1)/2) == avg && odd / (n/2) == avg) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }else {
        if(even / (n/2) == avg && odd / (n/2) == avg) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}


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



void solv() {
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto &i:v) cin>>i;
    int odd=0, even=0, sum = 0;
    for(int i=0;i<n; i++) {
        if(i%2) odd+=v[i];
        else even+=v[i];
        sum+=v[i];
    }
    if(sum % n != 0) {
        cout << "NO\n";
        return;
    } // 6 2 1 4 2
    if(n%2) {
        if(even%((n+1)/2) == 0 && odd % (n/2) == 0) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }else {
        if(even%(n/2) == 0 && odd % (n/2) == 0) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}


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

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

#define ll long long

void solve()
{
    int n;
    cin >> n;
    ll a[2] = {0};
    for (int i = 0, tt; i < n; ++i)
    {
        cin >> tt;
        a[i % 2] += tt;
    }
    if (a[0] % (n + 1 >> 1) == 0 && a[1] % (n >> 1) == 0 && a[0] / (n + 1 >> 1) == a[1] / (n >> 1))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

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

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

void solve()
{
    int n;
    cin >> n;
    ll a[2] = {0};
    for (int i = 0, tt; i < n; ++i)
    {
        cin >> tt;
        a[i % 2] += tt;
    }
    if (a[0] % (n + 1 >> 1) == 0 && a[1] % (n >> 1) == 0 && a[0] / (n + 1 >> 1) == a[1] / (n >> 1))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

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

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

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

using namespace std;

typedef long long w;



int main(){

int t;

cin>>t;

while(t--){

    w n;

    cin>>n; w a[n];w sum=0;

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

        cin>>a[i];

        sum+=a[i];

    }

    int b=sum/n;

    if(sum%n==0){

        int r=1;

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



                if(a[i-1]>b){

                    w c=a[i-1]-b;

                    a[i-1]=b;

                    a[i+1]=a[i+1]+c;

                }

                else if(a[i-1]<b){

                    w c=b-a[i-1];

                    a[i-1]=b;

                    a[i+1]=a[i+1]-c;

                }

                

                if(a[i-1]<0 || a[i+1]<0){

                int r=0;

                break;}      

    }

        if(r==1 && a[n-1]==b && a[n-2]==b)

        cout<<"YES"<<endl;

        else

        cout<<"NO"<<endl;

}

    else{

        cout<<"NO"<<endl;

    }

}

}

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

using namespace std;

typedef long long w;



int main(){

int t;

cin>>t;

while(t--){

    w n;

    cin>>n; vector<w> a(n);w sum=0;

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

        cin>>a[i];

        sum+=a[i];

    }

    int b=sum/n;

    if(sum%n==0){

        int r=1;

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



                if(a[i-1]>b){

                    w c=a[i-1]-b;

                    a[i-1]=b;

                    a[i+1]=a[i+1]+c;

                }

                else if(a[i-1]<b){

                    w c=b-a[i-1];

                    a[i-1]=b;

                    a[i+1]=a[i+1]-c;

                }

                

                if(a[i-1]<0 || a[i+1]<0){

                int r=0;

                break;}      

    }

        if(r==1 && a[n-1]==b && a[n-2]==b)

        cout<<"YES"<<endl;

        else

        cout<<"NO"<<endl;

}

    else{

        cout<<"NO"<<endl;

    }

}

}

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

Code 1:
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")

Code 2:
t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[0*t for m in range(t)]
    count=0
    count2=0
    mean=2*sum(a)//n
    if sum(a)%n!=0:
        print("NO")
    else:
        for j in range(n-2):
            b.append(abs(a[j]+a[j+2]))
        for k in range(n-2):
            if b[k]%2==0:
                count+=2
            else:
                c[i]+=1
        if mean in b:
                if (count+c[i])%2==0:
                    print("YES")
                else:
                    print("NO")
        else:
            print("NO")

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

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define forr(i,x,n) for(int i = x; i < n ; i ++ ) 

int32_t main() {
    int t;
    cin>>t;
    while(t--){
        int n ;
        cin >> n;  
        int a[n] ; 
        int s=0;
        forr(i,0, n){ 
            cin >> a[i] ;  
            s+=a[i];
        } 
        bool ok = false ; 
        if(s%n==0){ok = true ;}
        else { ok = false ;} 
        
        if(ok) {
        int x = s/n; 
        forr(i,1,n-1) { 
            
            if(a[i-1] >= x && a[i+1] > x ) { 
                ok = false ; 
            }   
            else if(a[i-1] > x && a[i+1] >= x) ok = false ; 
            else if(a[i-1] <= x && a[i+1] < x ) { 
                ok = false; 
            }  
            
            else if(a[i-1] < x && a[i+1] <= x) ok = false ; 
            else { 
                if(a[i-1] > x && a[i+1] < x) { 
                    a[i+1]+= a[i-1] - x ; 
                } 
                else if(a[i-1] < x && a[i+1] > x ){ 
                    a[i-1]+= a[i+1] - x ; 
                    a[i+1] = x ; } 
            }
        }
        }
        
        
        if(ok) cout<< "YES" << endl ; 
        else cout << "NO" << endl ; 
     
    } 

}


Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define forr(i,x,n) for(int i = x; i < n ; i ++ ) 

int32_t main() {
    int t;
    cin>>t;
    while(t--){
        int n ;
        cin >> n;  
        int a[n] ; 
        int s=0;
        int pe=0 , le = 0 ; 
        int po=0 , lo = 0 ; 
        forr(i,0, n){ 
            cin >> a[i] ;  
            s+=a[i];
        } 
        bool ok = false ; 
        if(s%n==0){ok = true ;}
        else { ok = false ;} 
        
        if(ok) {
        int x = s/n; 
        forr(i,0,n) { 
            
            if(i%2==0) { 
                if (a[i] > x) { 
                    pe+= a[i] - x; 
                } 
                else le+= x - a[i]; 
            } 
            else { 
                if(a[i]>x) po+=  a[i] - x; 
                else lo+=  x - a[i];  
            } 
                
        }  
        } 
        if(ok && po == lo && pe == le  ) cout << "YES" << endl ; 
        else cout<< "NO" << endl ;  
        
        
        
        
       // if(ok) cout<< "YES" << endl ; 
      //  else cout << "NO" << endl ; 
     
    } 

}


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

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

using namespace std;

void solve(){

    int n;cin>>n;

    vector <int> vec(n+1);

    vec[0]=0;

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

        cin>>vec[i];

    }



    int odd=0,even=0;

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

        if(i&1) odd+=vec[i];

        else even+=vec[i];

    }

    if(n%2==0){

        if(even==odd && even%(n/2)==0){

            cout<<"YES"<<endl;

        }

        else {

            cout<<"NO"<<endl;

        }

    }

    else{

        if(odd%((n+1)/2)==0 && even%(n/2)==0 && odd/((n+1)/2)==even/(n/2)){

            cout<<"YES"<<endl;

        }

        else{

            cout<<"NO"<<endl;

        }

    }



}

int main(){

int t;cin>>t;

    while(t--){

        solve();

    };

}

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

using namespace std;

void solve(){

    int n;cin>>n;

    vector <int> vec(n+1);

    vec[0]=0;

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

        cin>>vec[i];

    }



    long long int odd=0,even=0;

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

        if(i&1) odd+=vec[i];

        else even+=vec[i];

    }

    if(n%2==0){

        if(even==odd && even%(n/2)==0){

            cout<<"YES"<<endl;

        }

        else {

            cout<<"NO"<<endl;

        }

    }

    else{

        if(odd%((n+1)/2)==0 && even%(n/2)==0 && odd/((n+1)/2)==even/(n/2)){

            cout<<"YES"<<endl;

        }

        else{

            cout<<"NO"<<endl;

        }

    }



}

int main(){

int t;cin>>t;

    while(t--){

        solve();

    };

}

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

Code 1:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t,num;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[2]{};
        for(int i=0;i<n;++i){
            cin>>num;
            a[i&1]+=num;
        }
        if((a[0]+a[1])%n==0&&(a[0]%(n/2))==0&&(a[1]%(n/2-(n%2)))==0&&(a[0]/(n/2))==(a[1]/(n/2-(n%2)))){
            cout<<"yes"<<endl;        
        }else{
            cout<<"no"<<endl;
        }
    }
}

Code 2:

#include<bits/stdc++.h>
using namespace std;
int main(){
    int t,num;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        long long a[2]{};
        for(int i=0;i<n;++i){
            cin>>num;
            a[i&1]+=num;
        }
        if((a[0]+a[1])%n==0&&(a[0]%((n+1)/2))==0&&(a[1]%(n/2))==0&&(a[0]/((n+1)/2))==((a[0]+a[1])/n)){
            cout<<"yes"<<endl;        
        }else{
            cout<<"no"<<endl;
        }
    }
}

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

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

void solve(){
    int n;
    cin>>n;
    int sum_odd = 0;
    int sum_even = 0;
    int cnt_odd = 0;
    int cnt_even = 0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(i%2==0){
            sum_even+=x;
            cnt_even++;
        }else{
            sum_odd+=x;
            cnt_odd++;
        }
    }
    
    if(sum_even%cnt_even==0 && sum_odd%cnt_odd==0 && sum_even/cnt_even == sum_odd/cnt_odd){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
}

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

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

void solve(){
    int n;
    cin>>n;
    int sum_odd = 0;
    int sum_even = 0;
    int cnt_odd = 0;
    int cnt_even = 0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(i%2==0){
            sum_even+=x;
            cnt_even++;
        }else{
            sum_odd+=x;
            cnt_odd++;
        }
    }
    
    if(sum_even%cnt_even==0 && sum_odd%cnt_odd==0 && sum_even/cnt_even == sum_odd/cnt_odd){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
}

signed main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

Code 1:
def process_array():
    _size = int(input())
    a =list(map(int, input().split()))
    sum1 = 0 
    odd= (_size+1)/2
    sum2 = 0 
    even = _size-odd
    for i in range(_size):
        if i%2==0 :
           sum1+=a[i]
        else :
           sum2+=a[i] 
    if (sum1+sum2)%_size==0 :
       if sum1 == odd*((sum1+sum2)/_size) and sum2== even*((sum1+sum2)/_size):
          print("YES")
          return
       else:
         print("NO")
         return   
    else:
      print("NO")

t = int(input())    
for _ in range(t): 
       process_array()


Code 2:
def process_array():
    _size = int(input())
    a =list(map(int, input().split()))
    sum1 = 0 
    odd= (_size+1)//2
    sum2 = 0 
    even = _size-odd
    for i in range(_size):
        if i%2==0 :
           sum1+=a[i]
           
        else :
           sum2+=a[i] 
   # print(sum1, sum2, odd ,even)
    if (sum1+sum2)%_size==0 :
       if sum1 == odd*((sum1+sum2)/_size) and sum2== even*((sum1+sum2)/_size):
          print("YES")
          return
       else:
          print("NO")
          return   
    else:
      print("NO")

t = int(input())    
for _ in range(t): 
       process_array()


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+1)) {

                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;

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

            }

        }

        

    }

}

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--){

        long long int n;

        cin>>n;

        vector<int>ritik(n);

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

        cin>>ritik[i];

        long long int sum_o=0,sum_e=0;

        long long int c1=0,c2=0;

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

            if(i%2==0){

              sum_e+=ritik[i];  

              c1++;

            }

            else{

                sum_o+=ritik[i];

                c2++;

            }

        }

        if(sum_e/c1==sum_o/c2 && sum_e%c1==0&& sum_o%c2==0){

            cout<<"YES"<<endl;

        }

        else

            cout<<"NO"<<endl;

    }

}





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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int>ritik(n);

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

        cin>>ritik[i];

        int sum_o=0,sum_e=0;

        int c1=0,c2=0;

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

            if(i%2==0){

              sum_e+=ritik[i];  

              c1++;

            }

            else{

                sum_o+=ritik[i];

                c2++;

            }

        }

        if(sum_e/c1==sum_o/c2 && sum_e%c1==0&& sum_o%c2==0){

            cout<<"YES"<<endl;

        }

        else

            cout<<"NO"<<endl;

    }

}





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

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int even= (n+1)/2;
        int odd= n/2;
        int x,y;
        x=0;
        y=0;
        for(int i=0;i<n;i++){
            if(i%2==0){
                x+=a[i];
            }
            else{
                y+=a[i];
            }
        }
        if(y%odd==0 && x%even==0 && x/even==y/odd ){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }

    return 0;
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int even= (n+1)/2;
        int odd= n/2;
        long long x,y;
        x=0;
        y=0;
        for(int i=0;i<n;i++){
            if(i%2==0){
                x+=a[i];
            }
            else{
                y+=a[i];
            }
        }
        if(y%odd==0 && x%even==0 && x/even==y/odd ){
            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 int long long

void helper()
{
    int n;
    cin >> n;
    
    int odd = 0, even = 0;
    for(int i =0; i<n ; i++){
        int x ; cin>>x;
        if(i%2) odd += x;
        else even += x;
    }
    int odc = n/2 , evc = n/2 ;
    if(n&1) evc +=1 ;

    if(odd%odc != 0 || even%evc != 0 || odd/odc != even/evc){
        cout<<"NO"<<endl;
    }else {
        cout<<"YES"<<endl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

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


Code 2:
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
#define int long long

void helper()
{
    int n;
    cin >> n;
    vector<long long> v(n);

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

    for (int i = 1; i < n-1; i += 1)
    {
        long long sum = v[i - 1];
        sum += v[i + 1];
        long long div = sum /2 ;
        if(sum%2 == 0){
        v[i - 1] = div;
        v[i + 1] = div;
        }else {
        v[i - 1] = div;
        v[i + 1] = div+1;
        }
    }

    for (int i = 1; i < n; i++)
    {
        
        if (v[i - 1] != v[i])
        {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

signed main()
{
    if (1)
    {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
    }
    int t;
    cin >> t;
    while (t--)
    {
        helper();
    }
}

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

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

using namespace std;

const int N = 2e5 + 5;

typedef long long ll;

vector<ll> num(N);

void solve()

{

    int n;

    cin >> n;

    ll sum = 0;

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

    {

        cin >> num[i];

        sum += num[i];

    }

    if ((sum % n) != 0)

    {

        cout << "NO" << endl;

        return;

    }

    ll p = sum / n;

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

    {

        if (num[i] < p)

        {

            num[i + 2] -= (p - num[i]);

        }

        else

        {

            num[i + 2] += (num[i] - p);

        }

        num[i] = p;

    }

    if (num[n] == p && num[n - 1] == p)

        cout << "YES" << endl;

    else

        cout << "NO" << endl;

}

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

}



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

using namespace std;

const int N = 2e5 + 5;

typedef long long ll;

vector<ll> num(N);

void solve()

{

    int n;

    cin >> n;

    ll sum = 0;

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

    {

        cin >> num[i];

        sum += num[i];

    }

    if ((sum % n) != 0)

    {

        cout << "NO" << endl;

        return;

    }

    ll p = sum / n;

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

    {

        if (num[i] < p)

        {

            num[i + 2] -= (p - num[i]);

        }

        else

        {

            num[i + 2] += (num[i] - p);

        }

        if(num[i+2] < 0)

        {

            cout << "NO" << endl;

            return;

        }

    }

    if (num[n] == p && num[n - 1] == p)

        cout << "YES" << endl;

    else

        cout << "NO" << endl;

}

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

}



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

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

using namespace std;



int main() {

    int t;

    cin>>t;

    

    while(t--)

    {

        long long int n;

        cin>>n;

        

        long long int a[n];

        

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

        {

            cin>>a[i];

        }

        

        long long int sum=0;

        

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

        {

            sum+=a[i];

        }

        

  

        

        if(sum%n==0)

        {

            long long int value = sum/n;

            long long int cnt1=0;

            long long int cnt2=0;

            

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

            {

                if(i%2==0)

                {

                   

                   cnt1+=a[i]-value; 

                }

                else

                {

                    cnt2+=a[i]-value;

                }

            }

            

            if(cnt1==0&&cnt2==0)

            {

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

            }

            else

            {

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

            }

        }

        else

        {

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

        }

    }

}



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

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)

        {

            int value = sum/n;

            int cnt1=0;

            int cnt2=0;

            

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

            {

                if(i%2==0)

                {

                   

                   cnt1+=a[i]-value; 

                }

                else

                {

                    cnt2+=a[i]-value;

                }

            }

            

            if(cnt1==0&&cnt2==0)

            {

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

            }

            else

            {

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

            }

        }

        else

        {

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

        }

    }

}



Answer: 1