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

Code 1:
//    بسم الله الرحمن الرحيم  //



//    ███╗   ███╗ █████╗  ██████╗████████╗███████╗██████╗ ███╗   ███╗██╗███╗  ██╗██████╗

//    ████╗ ████║██╔══██╗██╔════╝╚══██╔══╝██╔════╝██╔══██╗████╗ ████║██║████╗ ██║██╔══██╗

//    ██╔████╔██║███████║╚█████╗    ██║   █████╗  ██████╔╝██╔████╔██║██║██╔██╗██║██║  ██║

//    ██║╚██╔╝██║██╔══██║ ╚═══██╗   ██║   ██╔══╝  ██╔══██╗██║╚██╔╝██║██║██║╚████║██║  ██║

//    ██║ ╚═╝ ██║██║  ██║██████╔╝   ██║   ███████╗██║  ██║██  ╚═╝ ██║██║██║ ╚███║██████╔╝

//    ╚═╝     ╚═╝╚═╝  ╚═╝╚═════╝    ╚═╝   ╚══════╝╚═╝  ╚═╝╚═╝     ╚═╝╚═╝╚═╝  ╚══╝╚═════╝

#include <iostream>

#include <vector>

#include <algorithm>

#include <cmath>

#include <string>

#include <map>

#include <set>

#include <queue>

#include <stack>

#include <deque>

#include <list>

#include <iomanip>

#include <functional>

#include <numeric>

#include <bitset>

#include <sstream>

#include <tuple>

#include <cassert>

#include <iterator>



using namespace std;

#define ll long long

#define ull unsigned long long

#define MOD 1000000007

#define PI 3.14159265

// #define ceil(a, b) ((a / b) + (a % b ? 1 : 0))

#define nl '\n'

#define pb push_back

#define tc \

    int t; \

    cin >> t;

#define fast std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);

#define cy cout << "YES\n"

#define cn cout << "NO\n"

#define sz size()

#define all(v) v.begin(), v.end()

void Mastermind()

{

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

    freopen("error.txt", "w", stderr);

#endif

}

bool checkBit(int x, int idx)

{

    return x & (1 << idx);

}

bool checkBit2(int x, int idx)

{

    return (x >> idx) & 1;

}

bool setBitToOne(int x, int idx)

{

    return x | (1 << idx);

}

bool setBitToZero(int x, int idx)

{

    return x & ~(1 << idx);

}

bool flipIdx(int x, int idx)

{

    // bit ^ 1

    // 0^1 (bit= 1)

    // 1^1 (bit= 0)

    return x ^ (1 << idx);

}

int countOns(int x) // or bult in function -> __builtin_popcount(x)

{

    int cnt = 0;

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

        cnt += checkBit(x, i);

}

// ll gcd(ll a, ll b)

// {

//    if(b==0)return a;

//      return gcd(b,b%a);

// }

// ll lcm(ll a, ll b)

// {

//     return a / gcd(a, b) * b;

// }



// // <------------------------------------------------>



ll gcd(ll a, ll b)

{

    if (b == 0)

        return a;

    return gcd(b, b % a);

}

ll lcm(ll a, ll b)

{

    return a / gcd(a, b) * b;

}



// <------------------------------------------------>



int FAST_POWER(int x, int n)

{

    int result = 1;

    while (n > 0)

    {

        if (n % 2 == 1)

            result = result * x;

        x = x * x;

        n = n / 2;

    }

    return result;

}



// fast power { time : log {n}}

// <------------------------------------------------>



bool isPerfectSquare(int x)

{

    if (x < 0)

        return false;

    int s = sqrt(x);

    return (s * s == x);

}



// <------------------------------------------------>



vector<int> prime_factorization(int n)

{

    vector<int> v;

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

    {

        while (n % i == 0)

        {

            v.push_back(i);

            n /= i;

        }

    }

    if (n > 1)

        v.push_back(n);

    return v;

}



bool comp(const pair<string, int> &a, const pair<string, int> &b)

{

    if (a.second == b.second)

    {

        return a.first > b.first;

    }

    else

    {

        return a.second > b.second;

    }

}

// _____________________________________ Solve. ______________________________________________________

int Ones(vector<int> v)

{

    int c = 0;

    for (auto &i : v)

    {

        if (i == 1)

            c++;

    }

    return c;

}

int main()

{

    // Mastermind();

    fast;



    tc;

    while (t--)

    {

        int n;

        cin >> n;

        vector<int> v(n);

        ll sum = 0;

        for (auto &i : v)

        {

            cin >> i;

            sum += i;

        }

        ll sum_odd = 0, sum_even = 0, c_odd = 0;



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

        {

            if (i & 1)

            {

                sum_odd += v[i];

                c_odd++;

            }

            else

                sum_even += v[i];

        }

        if (!(sum % n) && sum_odd / c_odd == sum_even / (n - c_odd))

        {

            cy;

        }

        else

            cn;

    }



    return 0;

}

Code 2:
//    بسم الله الرحمن الرحيم  //



//    ███╗   ███╗ █████╗  ██████╗████████╗███████╗██████╗ ███╗   ███╗██╗███╗  ██╗██████╗

//    ████╗ ████║██╔══██╗██╔════╝╚══██╔══╝██╔════╝██╔══██╗████╗ ████║██║████╗ ██║██╔══██╗

//    ██╔████╔██║███████║╚█████╗    ██║   █████╗  ██████╔╝██╔████╔██║██║██╔██╗██║██║  ██║

//    ██║╚██╔╝██║██╔══██║ ╚═══██╗   ██║   ██╔══╝  ██╔══██╗██║╚██╔╝██║██║██║╚████║██║  ██║

//    ██║ ╚═╝ ██║██║  ██║██████╔╝   ██║   ███████╗██║  ██║██  ╚═╝ ██║██║██║ ╚███║██████╔╝

//    ╚═╝     ╚═╝╚═╝  ╚═╝╚═════╝    ╚═╝   ╚══════╝╚═╝  ╚═╝╚═╝     ╚═╝╚═╝╚═╝  ╚══╝╚═════╝

#include <iostream>

#include <vector>

#include <algorithm>

#include <cmath>

#include <string>

#include <map>

#include <set>

#include <queue>

#include <stack>

#include <deque>

#include <list>

#include <iomanip>

#include <functional>

#include <numeric>

#include <bitset>

#include <sstream>

#include <tuple>

#include <cassert>

#include <iterator>



using namespace std;

#define ll long long

#define ull unsigned long long

#define MOD 1000000007

#define PI 3.14159265

// #define ceil(a, b) ((a / b) + (a % b ? 1 : 0))

#define nl '\n'

#define pb push_back

#define tc \

    int t; \

    cin >> t;

#define fast std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);

#define cy cout << "YES\n"

#define cn cout << "NO\n"

#define sz size()

#define all(v) v.begin(), v.end()

void Mastermind()

{

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

    freopen("error.txt", "w", stderr);

#endif

}

bool checkBit(int x, int idx)

{

    return x & (1 << idx);

}

bool checkBit2(int x, int idx)

{

    return (x >> idx) & 1;

}

bool setBitToOne(int x, int idx)

{

    return x | (1 << idx);

}

bool setBitToZero(int x, int idx)

{

    return x & ~(1 << idx);

}

bool flipIdx(int x, int idx)

{

    // bit ^ 1

    // 0^1 (bit= 1)

    // 1^1 (bit= 0)

    return x ^ (1 << idx);

}

int countOns(int x) // or bult in function -> __builtin_popcount(x)

{

    int cnt = 0;

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

        cnt += checkBit(x, i);

}

// ll gcd(ll a, ll b)

// {

//    if(b==0)return a;

//      return gcd(b,b%a);

// }

// ll lcm(ll a, ll b)

// {

//     return a / gcd(a, b) * b;

// }



// // <------------------------------------------------>



ll gcd(ll a, ll b)

{

    if (b == 0)

        return a;

    return gcd(b, b % a);

}

ll lcm(ll a, ll b)

{

    return a / gcd(a, b) * b;

}



// <------------------------------------------------>



int FAST_POWER(int x, int n)

{

    int result = 1;

    while (n > 0)

    {

        if (n % 2 == 1)

            result = result * x;

        x = x * x;

        n = n / 2;

    }

    return result;

}



// fast power { time : log {n}}

// <------------------------------------------------>



bool isPerfectSquare(int x)

{

    if (x < 0)

        return false;

    int s = sqrt(x);

    return (s * s == x);

}



// <------------------------------------------------>



vector<int> prime_factorization(int n)

{

    vector<int> v;

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

    {

        while (n % i == 0)

        {

            v.push_back(i);

            n /= i;

        }

    }

    if (n > 1)

        v.push_back(n);

    return v;

}



bool comp(const pair<string, int> &a, const pair<string, int> &b)

{

    if (a.second == b.second)

    {

        return a.first > b.first;

    }

    else

    {

        return a.second > b.second;

    }

}

// _____________________________________ Solve. ______________________________________________________

int Ones(vector<int> v)

{

    int c = 0;

    for (auto &i : v)

    {

        if (i == 1)

            c++;

    }

    return c;

}

int main()

{

    // Mastermind();

    fast;



    tc;

    while (t--)

    {

        int n;

        cin >> n;

        vector<int> v(n);

        ll sum = 0;

        for (auto &i : v)

        {

            cin >> i;

            sum += i;

        }

        // cerr << Ones(v) << " ";

        if (!(sum % n) && Ones(v) < 2)

        {

            cy;

        }

        else

            cn;

    }



    return 0;

}

Answer: 1