Problem: 2050B - Transfusion
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while (t--)
    {
        long long int n;
        long long int sum1;
        long long int sum2;
        long long int sum3;
        long long int sum4;
        cin>>n;
        vector<long long int> arr(n);
        bool answer = true;
        for (long long int i = 0; i < n; i++)
        {
            cin>>arr[i];
        }
        long long int even;
        long long int odd;
        if (n==3)
        {
            if (((arr[0] +1 ==arr[1])&&(arr[1]+1==arr[2])) || ((arr[0]-1 == arr[1]) && (arr[1]-1 == arr[2])))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (n ==4)
        {
            if ((arr[0]+arr[2] == arr[1] + arr[3]) && ((arr[0]+arr[2])%2 == 0))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (n==5)
        {
            if (((arr[1]+arr[3])%2 == 0) && ((arr[0]+arr[2]+arr[4])%3 == 0)&& ((arr[0] +arr[2]+arr[4])/3 == (arr[1]+arr[3])/2))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (n==6)
        {
            if ((arr[0] +arr[2]+arr[4] == arr[1]+arr[3]+arr[5]) && ((arr[1]+arr[3]+arr[5])%3 == 0))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
        }
        else if (n==7)
        {
            if ((arr[0] +arr[2]+arr[4] == arr[1]+arr[3]+arr[5]) && (arr[0] +arr[2]+arr[4] == arr[2]+arr[4]+arr[6])&&((arr[1]+arr[3]+arr[5])%3 == 0))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
        }
                
        else{
        if (n%2 == 0)
        {
            even = n;
            odd= n-1;
        }
        else
        {
            even=n-1;
            odd=n;
        }
        for (int i = 0; i <=even-6 ; i=i+2)
        {
            sum1 = arr[i] + arr[i+2] + arr[i+4];
            sum2 = arr[i+2] + arr[i+6] + arr[i+4];
            if (sum1 != sum2)
            {
                answer=false;
                break;
            }
            
        }
        if (answer==true)
        {
            for (int i = 1; i <=odd-6 ; i=i+2)
            {
            sum3 = arr[i] + arr[i+2] + arr[i+4];
            sum4 = arr[i+2] + arr[i+6] + arr[i+4];
            if (sum3 != sum4)
            {
                answer=false;
                break;
            }
            }
        }
        
        if ((answer==true) && (sum1 == sum3))
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }}
    }
    
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while (t--)
    {
        long long int n;
        long long int sum1;
        long long int sum2;
        long long int sum3;
        long long int sum4;
        cin>>n;
        vector<long long int> arr(n);
        bool answer = true;
        for (long long int i = 0; i < n; i++)
        {
            cin>>arr[i];
        }
        long long int even;
        long long int odd;
        if (n==3)
        {
            if (((arr[0]+arr[2])%2 == 0) && (arr[1] == (arr[0]+arr[2])/2))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (n ==4)
        {
            if ((arr[0]+arr[2] == arr[1] + arr[3]) && ((arr[0]+arr[2])%2 == 0))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (n==5)
        {
            if (((arr[1]+arr[3])%2 == 0) && ((arr[0]+arr[2]+arr[4])%3 == 0)&& ((arr[0] +arr[2]+arr[4])/3 == (arr[1]+arr[3])/2))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (n==6)
        {
            if ((arr[0] +arr[2]+arr[4] == arr[1]+arr[3]+arr[5]) && ((arr[1]+arr[3]+arr[5])%3 == 0))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
        }
        else if (n==7)
        {
            if ((arr[0] +arr[2]+arr[4] == arr[1]+arr[3]+arr[5]) && (arr[0] +arr[2]+arr[4] == arr[2]+arr[4]+arr[6])&&((arr[1]+arr[3]+arr[5])%3 == 0))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
        }
                
        else{
        if (n%2 == 0)
        {
            even = n;
            odd= n-1;
        }
        else
        {
            even=n-1;
            odd=n;
        }
        for (int i = 0; i <=even-6 ; i=i+2)
        {
            sum1 = arr[i] + arr[i+2] + arr[i+4];
            sum2 = arr[i+2] + arr[i+6] + arr[i+4];
            if (sum1 != sum2)
            {
                answer=false;
                break;
            }
            
        }
        if (answer==true)
        {
            for (int i = 1; i <=odd-6 ; i=i+2)
            {
            sum3 = arr[i] + arr[i+2] + arr[i+4];
            sum4 = arr[i+2] + arr[i+6] + arr[i+4];
            if (sum3 != sum4)
            {
                answer=false;
                break;
            }
            }
        }
        
        if ((answer==true) && (sum1 == sum3))
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }}
    }
    
    return 0;
}