ShaysXIA/CodeInsightBench huggingface dataset:
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 _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = []
    count = 0
    mean = 2 * sum(a) // n

    if sum(a) % n != 0:
        print("NO")
    else:
        for j in range(n - 2):
            b.append(a[j] + a[j + 2])

        for value in b:
            if value % 2 == 0:
                count += 2

        if mean in b and count % 2 == 0:
            print("YES")
        else:
            print("NO")


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

Code 1:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vpll = vector<pair<long long, long long>>;
using vpii = vector<pair<int, int>>;
using vvll = vector<vector<long long>>;
using vbl = vector<bool>;
using pll = pair<ll, ll>;

#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define F                first
#define S                second 
#define pb               push_back
#define endl             '\n'
//------------------------------------
int ar[1001000];
void solve(){
    int n;
    cin>>n;
    ll sum = 0;
    ll sum1 = 0;
    int ct1 = 0;
    int ct2 = 0;
    ll sum2 = 0;
    for(int i = 0;i<n;i++){
        cin>>ar[i];
        if(i%2==0){
            sum1+=ar[i];
            ct1++;
        }
        else{
            sum2+=ar[i];
            ct2++;
        }
        sum+=ar[i];
    }
    if(sum%n!=0){
        cout<<"NO"<<endl;
    }
    else{
        if(sum1%ct1==0&&sum2%ct2==0&&sum1/ct1==sum/n&&sum2/ct2==sum/n){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }



    }







}




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

Code 2:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vpll = vector<pair<long long, long long>>;
using vpii = vector<pair<int, int>>;
using vvll = vector<vector<long long>>;
using vbl = vector<bool>;
using pll = pair<ll, ll>;

#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define F                first
#define S                second 
#define pb               push_back
#define endl             '\n'
//------------------------------------
int ar[100100];
void solve(){
    int n;
    cin>>n;
    int sum = 0;
    int sum1 = 0;
    int ct1 = 0;
    int ct2 = 0;
    int sum2 = 0;
    for(int i = 0;i<n;i++){
        cin>>ar[i];
        if(i%2==0){
            sum1+=ar[i];
            ct1++;
        }
        else{
            sum2+=ar[i];
            ct2++;
        }
        sum+=ar[i];
    }
    if(sum%n!=0){
        cout<<"NO"<<endl;
    }
    else{
        if(sum1%ct1==0&&sum2%ct2==0&&sum1/ct1==sum/n&&sum2/ct2==sum/n){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }



    }







}




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

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

Code 1:
// **************** MBRAHUL *************** 
#include<bits/stdc++.h>
#define ll long long
#define pn cout<<"NO"<<endl
#define py cout<<"YES"<<endl
#define vll vector<long long>
#define vi vector<int>
#define vb vector<bool>
#define u_map unordered_map
#define pll pair<long long,long long>
#define pii pair<int,int>
#define inf INT_MAX
#define pb push_back
#define mod 998244353
#define MOD 1000000007
#define ld long double
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define loop(i,n) for(int i=0;i<n;i++)
#define rloop(i, n) for(int i=n-1;i>=0;i--)
using namespace std;

void input(vector<ll>&arr,ll n){
for(ll i =0;i<n;i++)cin>>arr[i];
}

void printArr(vector<ll>&arr, ll i,ll j){
for(ll k = i;k<=j;k++)cout<<arr[k]<<" ";
cout<<endl; 
}

void find(){
  int n;
  cin>>n;
  vll arr(n);
  ll sum = 0;
  loop(i,n){
    cin>>arr[i];
    sum+=arr[i];
  }
  if(sum%n){
    pn;
    return;
  }
  ll target = sum/n;
  for(int i = 0;i<n-2;i++){
    if(arr[i]<0){
      pn;
      return;
    }
    if(arr[i]==target)continue;
    else{
      arr[i+2]-=target-arr[i];
    }
  }
  if(arr[n-2]==target && arr[n-1]==target)py;
  else pn;
}

int main(){
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
ll test;
cin>>test;
while(test--){
find();
}
return 0;
}

Code 2:
// **************** MBRAHUL *************** 
#include<bits/stdc++.h>
#define ll long long
#define pn cout<<"NO"<<endl
#define py cout<<"YES"<<endl
#define vll vector<long long>
#define vi vector<int>
#define vb vector<bool>
#define u_map unordered_map
#define pll pair<long long,long long>
#define pii pair<int,int>
#define inf INT_MAX
#define pb push_back
#define mod 998244353
#define MOD 1000000007
#define ld long double
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define loop(i,n) for(int i=0;i<n;i++)
#define rloop(i, n) for(int i=n-1;i>=0;i--)
using namespace std;

void input(vector<ll>&arr,ll n){
for(ll i =0;i<n;i++)cin>>arr[i];
}

void printArr(vector<ll>&arr, ll i,ll j){
for(ll k = i;k<=j;k++)cout<<arr[k]<<" ";
cout<<endl; 
}

void find(){
  int n;
  cin>>n;
  vll arr(n);
  ll sum = 0;
  loop(i,n){
    cin>>arr[i];
    sum+=arr[i];
  }
  if(sum%n){
    pn;
    return;
  }
  ll target = sum/n;
  for(int i = 0;i<n-2;i++){
    if(arr[i]==target)continue;
    else{
      arr[i+2]-=target-arr[i];
    }
  }
  if(arr[n-2]==target && arr[n-1]==target)py;
  else pn;
}

int main(){
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
ll test;
cin>>test;
while(test--){
find();
}
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--) {

        long long n;cin >> n;

        vector<int>v(n);

        vector<int>v2(n);

        long long count = 0;

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

        for (int i = 0;i < v.size();i++)v2[i] = v[i];

        if (count % n){cout << "NO" << endl;continue;}

        long long sum = count / n;

        for (int i = 1;i < v.size() - 1;i++) {

            long long j1,j2;

            if (v[i - 1] < sum && v[i + 1] > sum) {

                j1 = sum - v[i - 1];

                v[i - 1] += j1;

                v[i + 1] -= j1;

            }else if (v[i - 1] > sum && v[i + 1] < sum){

                j1 = v[i - 1] - sum;

                v[i - 1] -= j1;

                v[i + 1] += j1;

            }

            else {

                j1 = v[i - 1] - sum;

                v[i - 1] -= j1;

                v[i + 1] += j1;

            }

        }

        bool f = true;

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

            if (v[i] != sum){f = false;break;}

        }

        for (int i = 1;i < v.size() - 1;i++) {

            int j1,j2;

            if (v[i - 1] < sum && v[i + 1] > sum) {

                j1 = sum - v[i - 1];

                v[i - 1] += j1;

                v[i + 1] -= j1;

            }else if (v[i - 1] > sum && v[i + 1] < sum){

                j1 = v[i - 1] - sum;

                v[i - 1] -= j1;

                v[i + 1] += j1;

            }

            else {

                j1 = sum - v[i - 1];

                v[i - 1] += j1;

                v[i + 1] -= j1;

            }

        }

        bool t = true;

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

            if (v2[i] != sum){t = false;break;}

        }

        if (f || t)cout << "YES" << endl;else cout << "NO" << endl;

        v.clear();v2.clear();

    }

}

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

using  namespace std;

int main() {

    int t;cin >> t;

    while (t--) {

        int n;cin >> n;

        vector<int>v(n);

        int count = 0;

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

        if (count % n){cout << "NO" << endl;continue;}

        int sum = count / n;

        for (int i = 1;i < v.size() - 1;i++) {

            while (v[i - 1] != sum) {

                if (v[i - 1] < sum) {

                    v[i - 1]++;v[i + 1]--;

                }else {

                    v[i - 1]--;v[i + 1]++;

                }

            }

        }

        bool f = true;

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

            if (v[i] != sum){f = false;break;}

        }

        if (f)cout << "YES" << endl;else cout << "NO" << endl;

        v.clear();

    }

}

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

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

using namespace std;

typedef long long ll;



int

main(void)

{

        ios::sync_with_stdio(0);

        cin.tie(0);

        

        ll t; cin >> t;

        for (ll i = 0; i < t; i++) {

                ll n; cin >> n;

                ll arr[n];

                ll flag = 0;

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

                        cin >> arr[j];



                ll target = (arr[0] + arr[2]) / 2;



                for (ll j = 1; j < n - 1; j++) {

                        ll *m1 = &arr[j - 1], *m2 = &arr[j + 1];



                        while (*m1 < target) {

                                *m1 += 1;

                                *m2 -= 1;

                        }

                        while (*m1 > target) {

                                *m1 -= 1;

                                *m2 += 1;

                        }

                }



        if (arr[n - 2] != arr[n - 1] || arr[n - 3] != arr[n - 1])

                flag = 1;



        if (flag)

                cout << "NO" << endl;

        else

                cout << "YES" << endl;

        }



        return 0;

}





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

using namespace std;

typedef long long ll;



int

main(void)

{

        ios::sync_with_stdio(0);

        cin.tie(0);

        

        ll t; cin >> t;

        for (ll i = 0; i < t; i++) {

                ll n; cin >> n;

                ll arr[n];

                ll flag = 0;

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

                        cin >> arr[j];



                ll target = (arr[0] + arr[2]) / 2;



                for (ll j = 1; j < n - 1; j++) {

                        ll *m1 = &arr[j - 1], *m2 = &arr[j + 1];



                        while (*m1 < target) {

                                *m1 += 1;

                                *m2 -= 1;

                        }

                        while (*m1 > target) {

                                *m1 -= 1;

                                *m2 += 1;

                        }

                        

                        if (*m1 < 0 || *m2 < 0) {

                                flag = 1;

                                break;

                        }



                }



        if (arr[n - 2] != arr[n - 1] || arr[n - 3] != arr[n - 1])

                flag = 1;



        if (flag)

                cout << "NO" << endl;

        else

                cout << "YES" << endl;

        }



        return 0;

}





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

Code 1:
t = int(input())

for i in range(t):

    n = int(input())

    inputs = list(map(int, input().split()))

    even_sum = 0

    odd_sum = 0

    for i in range(n):

        if i%2 == 0:

            even_sum += inputs[i]

        else:

            odd_sum += inputs[i]

    if n%2 == 1:

        if even_sum/(n//2+1) == odd_sum*(n-n//2-1):

            print("YES")

        else:

            print("NO")

    else:

        if even_sum == odd_sum:

            print("YES")

        else:

            print("NO")

Code 2:
t = int(input())

for i in range(t):

    n = int(input())

    inputs = list(map(int, input().split()))

    even_sum = 0

    odd_sum = 0

    for i in range(n):

        if i%2 == 0:

            even_sum += inputs[i]

        else:

            odd_sum += inputs[i]

    if n%2 == 0:

        even = odd = n/2

    else:

        even = n//2+1

        odd = n - even

    if even_sum/even == int(even_sum/even) and odd_sum/odd == int(odd_sum/odd):

        if even_sum/even == odd_sum/odd:

            print("YES")

        else:

            print("NO")

    else:

        print("NO")

    

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

Code 1:
import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.util.*;



public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int t = Integer.parseInt(br.readLine());



        while (t-->0)

        {

            

            int n=Integer.parseInt(br.readLine());

            StringTokenizer st=new StringTokenizer(br.readLine());

            int k=0;

            int[] a=new int[n];

            // Set<Integer> set=new HashSet<>();

            long evensum=0,oddsum=0;

            while(st.hasMoreTokens())

            {

                a[k]=Integer.parseInt(st.nextToken());



                if(k%2==0)

                    evensum+=a[k];

                else

                    oddsum+=a[k];

                k++;

            }



            if(evensum%((n+1)/2)!=0 || oddsum%(n/2)!=0 || (evensum+oddsum)%n!=0)

                System.out.println("No");

            else

                System.out.println("Yes");

            



            



        }

    }

}



// class ListComparator implements Comparator<List<Integer>>

// {

//     int index=0;

//     public ListComparator(int i)

//     {

//         index=i;

//     }



//     @Override

//     public int compare(List<Integer> o1,List<Integer> o2)

//     {

//         return Integer.compare(o1.get(index), o2.get(index));

//     }



// }

Code 2:
import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.util.*;



public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int t = Integer.parseInt(br.readLine());



        while (t-->0)

        {

            

            int n=Integer.parseInt(br.readLine());

            StringTokenizer st=new StringTokenizer(br.readLine());

            int k=0;

            int[] a=new int[n];

            // Set<Integer> set=new HashSet<>();

            long evensum=0,oddsum=0;

            while(st.hasMoreTokens())

            {

                a[k]=Integer.parseInt(st.nextToken());



                if(k%2==0)

                    evensum+=a[k];

                else

                    oddsum+=a[k];

                k++;

            }



            if(evensum%((n+1)/2)!=0 || oddsum%(n/2)!=0 || evensum/((n+1)/2)!=oddsum/(n/2))

                System.out.println("No");

            else

                System.out.println("Yes");

            



            



        }

    }

}



// class ListComparator implements Comparator<List<Integer>>

// {

//     int index=0;

//     public ListComparator(int i)

//     {

//         index=i;

//     }



//     @Override

//     public int compare(List<Integer> o1,List<Integer> o2)

//     {

//         return Integer.compare(o1.get(index), o2.get(index));

//     }



// }

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

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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
       ll n;
       cin>>n;
       vector<ll> v(n);

       ll s0=0,s1=0,c1=0,c0=0;
       for(ll  i = 0; i < n; i++){
        cin>>v[i];
        if(i%2==0){
            s0+=v[i];
            c0++;
        }
        else {
            s1+=v[i];
            c1++;
        }
       }

       if(s0*c1== s1*c0 && (s1+s0)%(c0+c1)==0){
         cout<<"YES"<<endl;
       }
       else cout<<"NO"<<endl;
    }
}
    


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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
       ll n;
       cin>>n;
       vector<int> v(n);

       int s0=0,s1=0,c1=0,c0=0;
       for(int  i = 0; i < n; i++){
        cin>>v[i];
        if(i%2==0){
            s0+=v[i];
            c0++;
        }
        else {
            s1+=v[i];
            c1++;
        }
       }

       if(s0*c1== s1*c0 && (s1+s0)%n==0){
         cout<<"YES"<<endl;
       }
       else cout<<"NO"<<endl;
    }
}
    


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

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

using namespace std;

 

int main()

{

   int t;

   cin>>t;

   while(t--){

       int n;

       cin>>n;

       

      long long a[n];

      int sumodd=0;

       int sumeve=0;

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

          cin>>a[i];

          if(i%2)sumodd+=a[i];

          else sumeve+=a[i];

      }

      int eve=n/2,odd=n/2;

      if(n%2)eve++;

      if(sumodd%odd!=0 || sumeve%eve!=0 || sumodd/odd!=sumeve/eve){

          cout<<"NO"<<endl;

          

      }

     

         else cout<<"Yes"<<endl;

    

  

       

    

   }

    return 0;

}

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

using namespace std;



int main()

{

    int tt;

    cin >> tt;

    while (tt--)

    {

        int n;

        cin >> n;

        vector<long long> nums(n);

        long long sum=0;

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

        {

            cin >> nums[i];

            sum+=nums[i];

        }

        if (n >= 3)

        {

            if(n==3)

            {

                long long num=nums[1];

                long long diff1=num-nums[0];

                long long diff2=num-nums[2];

                if((diff1>0&&diff2>0)||(diff1<0&&diff2<0)||abs(diff1)!=abs(diff2))cout<<"NO"<<endl;

                else cout<<"YES"<<endl;

            }

            else

            {

                long long sumodd = 0;

                long long sumeven = 0;

                int count = 0;

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

                {

                    sumeven += nums[i];

                    count++;

                }

                sumodd=sum-sumeven;

                int count2 = n - count;

                if (sumeven % count == 0 && sumodd % count2 == 0)

                    cout << "YES" << endl;

                else

                    cout << "NO" << endl;



            }

        }

    }

    return 0;

}

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

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

void solve(){
    int n;;cin>>n;int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int check=0;
    for(int i=0;i<n;i++){
        check+=arr[i];
    }
    if(check%n!=0){
        cout<<"NO"<<endl;
    }
    else{
        int ceven=0,codd=0;
        check=check/n;
        for(int i=0;i<n;i++){
            if(i%2==0){
                ceven+=(arr[i]-check);
            }
            else{
                codd+=(arr[i]-check);
            }
        }
        if(ceven==0 && codd==0){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    
}

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


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

void solve(){
    long long int n;;cin>>n;int arr[n];
    for(long long int i=0;i<n;i++){
        cin>>arr[i];
    }
    long long int check=0;
    for(long long int i=0;i<n;i++){
        check+=arr[i];
    }
    if(check%n!=0){
        cout<<"NO"<<endl;
    }
    else{
        long long int ceven=0,codd=0;
        check=check/n;
        for(long long int i=0;i<n;i++){
            if(i%2==0){
                ceven+=(arr[i]-check);
            }
            else{
                codd+=(arr[i]-check);
            }
        }
        if(ceven==0 && codd==0){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    
}

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


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

Code 1:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ranges>
#include <set>
#include <vector>
using namespace std;

template<class Fun> class y_combinator_result {
    Fun fun_;
public:
    template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}
    template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); }
};
template<class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); }


template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename... Args> ostream& operator<<(ostream& os, const tuple<Args...>& t) { os << '('; apply([&os](const Args&... args) { size_t n = 0; ((os << args << (++n != sizeof...(Args) ? ", " : "")), ...); }, t); return os << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifdef NEAL_DEBUG
#define dbg(...) cerr << '[' << __FILE__ << ':' << __LINE__ << "] (" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


void run_case() {
    int N;
    cin >> N;
    array<int64_t, 2> sums = {};

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        sums[i % 2] += a;
    }

    bool ans = (sums[0] + sums[1]) % N == 0;
    int64_t avg = (sums[0] + sums[1]) / N;
    ans &= sums[0] == avg * ((N + 1) / 2);
    cout << (ans ? "YES" : "NO") << '\n';
}

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int tests;
    cin >> tests;

    while (tests-- > 0)
        run_case();
}


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

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    vector<int> a(n);
    array<int64_t, 2> sum = {0, 0};
    array<int64_t, 2> cnt = {0, 0};
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum[i % 2] += a[i];
      cnt[i % 2] += 1;
    }
    if (sum[0] % cnt[0] == 0 && sum[1] % cnt[1] == 0 && sum[0] / cnt[0] == sum[1] / cnt[1]) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }
  }
  return 0;
}


Answer: 2