ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: c++17 

Solution 1 (runtime: 1031 ms):
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int testcases;
    cin >> testcases;
    while (testcases--)
    {
        int n;
        cin >> n;
        map<pair<int, int>, int> mp;
        int degree[n + 1] = {0};
        for (int i = 0; i < n - 1; i++)
        {
            int u, v;
            cin >> u >> v;
            mp[{u, v}] = mp[{v, u}] = 1;
            degree[u] += 1;
            degree[v] += 1;
        }
        priority_queue<pair<int, int>> pq;
        for (int i = 1; i <= n; i++)
            pq.push({degree[i], i});
        vector<int> ab;
        for (int i = 0; i < 3; i++)
        {
            ab.push_back(pq.top().second);
            cerr << ab[i] << " " << degree[ab[i]] << "\n";
            pq.pop();
        }
        cerr << endl;

        int ans = 0;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                if (j != ab[i])
                    ans = max(ans, degree[ab[i]] + degree[j] - 1 - mp[{ab[i], j}]);
            }
        }
        cout << ans << "\n";
    }

    return 0;
}

Solution 2 (runtime: 515 ms):
//the template
#include <iostream>
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for (int i = a; (i) < (b); (i)++)
#define revrange(i, a, b) for (int i = a; (i) >= (b); (i)--)
using namespace std;
vector<int> *adj;
void solve(){
	int n;
	cin>>n;
	adj = new vector<int>[n];
	
	range(i,0,n-1){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	vector<pair<int,int>> p(n);
	range(i,0,n)
	p[i] = make_pair(i,adj[i].size());
	/*range(i,0,n)
	cout<<p[i].second<<" ";*/
	int mx1_node = -1;
	int mx1 = -1;
	range(i,0,n){
		if(p[i].second>mx1){
		mx1 = p[i].second;
		mx1_node = p[i].first;
	}
	}
	int alt = -1;
	range(i,0,n){
	if(p[i].second == mx1 && p[i].first!=mx1_node)
	alt = i;
	}
	for(int i : adj[mx1_node])
	p[i].second--;
	
	int mx2 = -1;
	
	range(i,0,n){
		if(i!=mx1_node){
		if(p[i].second>mx2)
		mx2 = p[i].second;}
	}
	for(int i : adj[mx1_node])
	p[i].second++;
	if(alt!=-1){
	for(int i : adj[alt])
	p[i].second--;}
	
	int alt2 = -1;
	if(alt!=-1){
	range(i,0,n){
		if(i!=alt){
		if(p[i].second>alt2)
		alt2 = p[i].second;}
	}
	}
    if(alt == -1)
    cout<<mx1+mx2-1<<endl;
	else
	cout<<max(mx1 + mx2 - 1, mx1 + alt2 - 1)<<endl;
	
}
int32_t main(){
	int t;
	cin>>t;
	while(t--)
	solve();
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 61 ms):
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define debug(a) cout<<#a<<' '<<a<<endl;
#define cut cout<<endl <<"-------------------"<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int N = 2e5+10;
const ll mod=1e9 + 7, inf = 0x3f3f3f3f;
mt19937 mrand(time(0));     
int rnd(int x) { return mrand() % x;}
ll qmi(ll a,ll b,ll p) {ll res=1;a%=p; assert(b>=0); for(;b;b/=2){if(b&1)res=res*a%p;a=a*a%p;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void init()
{
    int l, r;
    cin >> l >> r;
    int x, y, z;
    x = y = z = 0;
    for(int i = 29; i >= 0; i --)
    {
        if((l >> i & 1) != (r >> i & 1))
        {
            // x = x * 2 + 1;
            // y = y * 2 + 0;
            x |= (1 << i);
            y |= (1 << i) - 1;
            for(int j = l; j <= r; j ++)
            if(j != x && j != y)
            {
                z = j;
                cout << x << " " << y << " " << z << endl;
                // break;
                return;
            }

            // break;
        }
        else
        {
            // x |= (1 << i);
            x |= (l >> i & 1) << i;
            y |= (l >> i & 1) << i;
            z |= (l >> i & 1) << i;
            // x = x * 2 + (l >> i & 1);
            // y = y * 2 + (l >> i & 1);
            // z = z * 2 + (l >> i & 1);
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin.tie(0);
    
    int _;
    cin>>_;
    // _ = 1; 
    while(_--)
    {
        init();
    }

    return 0;
}

Solution 2 (runtime: 109 ms):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll N = 2e5 + 10, LG = 20, mod = 1e9 + 7;

void burn()
{
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for(int i = 29; i >= 0; i--)
    {
        if((a | (1 << i)) <= r)
            a |= (1 << i);
        else if((b | (1 << i)) <= r)
            b |= (1 << i);
        if((b | ((1 << i) - 1)) < l) {
            b |= (1 << i);
            a ^= (1 << i);
            if((((1 << i) - 1) | a) >= l)
                a ^= (1 << i);
            else
                a ^= (1 << i);
        }
    }
    if(b - 1 >= l && b - 1 != a)
        c = b - 1;
    else if(b + 1 <= r && b + 1 != a)
        c = b + 1;
    else if(a - 1 >= l && a - 1 != b)
        c = a - 1;
    else if(a + 1 <= r && a + 1 != b)
        c = a + 1;
    cout << a << ' ' << b << ' ' << c << '\n';
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
      cin >> t;
    while (t--)
        burn();
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 62 ms):
#include<bits/stdc++.h>
using namespace std;
#define ll long long


void solve() {
    ll l, r; cin >> l >> r; 
    ll a=0, b=0, c=0, temp=0;
    bool first = true;
    for(int i=31; i>=0; i--) {  
        ll b1 = (((1ll<<i)&l)!=0), b2 = (((1ll<<i)&r)!=0);
        if(b1==b2) {
            temp |= (1ll<<i)*b1;    
        } else {
            a = temp + (1ll<<i);
            b = a-1;
            break;
        }
    }
    for(int i=l; i<=r; i++) {
        if(i!=a && i!=b) {
            c = i;
            break;
        }
    }
    cout << a << " " << b << " " << c << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifndef ONLINE_JUDGE 
        freopen("input1.txt", "r", stdin);
        freopen("output1.txt", "w", stdout);
    #endif

    int t=1; 
    cin >> t;
    for(int T=1; T<=t; T++) {
        solve();
    } 
}


Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>
 
using i64 = long long;
 
void solve() {
    int l, r;
    std::cin >> l >> r;
    int k = 31 - __builtin_clz(l ^ r);
    int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
    std::cout << a << " " << b << " " << c << "\n";
}
 
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    int t = 1;
    std::cin >> t;
 
    while (t--) {
        solve();
    }
}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 2452 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n1,n2,n3;
string a,b,c;
int dp[2020][2020];
int rec(int i,int j){
    if(i>=n1&&j>=n2){
        return 0;
    }
    if(dp[i][j]!=-1)return dp[i][j];
    int ans=1e9;
    if(i<n1&&a[i]==c[i+j])ans=min(ans,rec(i+1,j));
    else if(i<n1)ans=min(ans,rec(i+1,j)+1);
    if(j<n2&&b[j]==c[i+j])ans=min(ans,rec(i,j+1));
    else if(j<n2)ans=min(ans,rec(i,j+1)+1);
    dp[i][j]=ans;
    return ans;
    
}
void solve(){
    cin>>a>>b>>c;
    n1=a.size();
    n2=b.size();
    n3=c.size();
    memset(dp,-1,sizeof(dp));
    cout<<rec(0,0)<<'\n';
    
   
}


signed main() {
	// your code goes here
	int t=1;
	cin>>t;
	
	while(t--){
	    solve();
	}

}


Solution 2 (runtime: 78 ms):
#include <bits/stdc++.h>

using namespace std;

#define int long long



void add(vector<int> &arr, vector<int> &segtree, vector<int> &lazy,int v,int l, int r,int l1,int r1,int value)

{

    if(r<l1|| l>r1)

        return ;

    if(l>=l1 && r<=r1)

    {

        lazy[v]=value;

        return ;

    }

    if(lazy[v]!=0)

    {

    lazy[2*v]=lazy[v];

    lazy[2*v+1]=lazy[v];

    lazy[v]=0;

   }

    int mid=(l+r)/2;

    add(arr,segtree,lazy,2*v,l,mid,l1,r1,value);

    add(arr,segtree,lazy,2*v+1,mid+1,r,l1,r1,value);

}



int query(vector<int> &arr, vector<int> &segtree, vector<int> &lazy,int v,int l, int r,int index)

{

    if(index<l || index>r) return 0;

    // if(l==r && l==index && lazy[v]!=0) return lazy[v];

    int mid=(l+r)/2;

    if(l==r && l==index ) return lazy[v];

    if(index>=l && index<=r && lazy[v]!=0) return lazy[v];

    return max(query(arr,segtree,lazy,2*v,l,mid,index),query(arr,segtree,lazy,2*v+1,mid+1,r,index));

}



int find(string &a, string &b, string &c, int i,int j,int k,vector<vector<int>> &dp)

{



    if(k==c.size())

        return 0;

    else if(dp[i][j]!=-1) return dp[i][j];

    else

    {

        int x,y,z;

        x=y=INT_MAX;



        if(i<a.size())

        {

        x=find(a,b,c,i+1,j,k+1,dp);

        if(a[i]!=c[k])

             x+=1;

        }

        if(j<b.size())

        {

         y=find(a,b,c,i,j+1,k+1,dp);

        

        if(b[j]!=c[k])

            y+=1;

        }

        return min(x,y);

    }

}

int32_t main() {

     





    int t;

    cin>>t;

    while(t--)

    {

        string a,b,c;

        cin>>a>>b>>c;



        vector<vector<int>> dp(c.size(),vector<int>(c.size(),-1));



        cout<<find(a,b,c,0,0,0,dp)<<endl;;



    }



     return 0;

}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 62 ms):


    #include <bits/stdc++.h> // include all standard headers
    using namespace std;
     
    #define ll long long
    #define ld long double
    #define pii pair<int, int>
    #define mp make_pair
    #define pb push_back
    #define eb emplace_back
    #define fi first
    #define se second
     
    const int INF = 1e9;
    const ll INFLL = 1e18;
    const int MOD = 1e9 + 7;

    char rect(vector<char> &s){
        int n=s.size();
     
    
     char max=s[0];
     int ind=0;
        for(int i=1; i<min(n,10); i++){
          if(s[i]-i>max){
          max=s[i]-i;
          ind=i;
        }}
        s.erase(s.begin()+ind);
        return max;
    
    }
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        // Declare any additional variables here
        
        int t; // number of test cases
        cin >> t;
        
        while (t--) {
          string s;
          cin >> s;
          ll n;
          n=s.size();
          vector<char> v;
          if(n>9){
          for(int i=0; i<10;i++)
           v.pb(s[i]);
           cout<<rect(v);
           for(int i=10;i<n;i++){
            v.pb(s[i]);
           cout<<rect(v);}
           for(int i=0;i<9;i++){
               cout<<rect(v);
           }
          
          }
          else{
        for(int i=0;i<n;i++){
        v.pb(s[i]);
        }
        int size=v.size();
        for(int i=0;i<size;i++)
        cout<<rect(v);
          }
        cout<<"\n";
         
        }
       
        
        return 0;
    }




Solution 2 (runtime: 718 ms):
#include <bits/stdc++.h>
using namespace std;
void solve();

int main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
        cout << "\n";
    }
}

bool swapOrNot(int a, int b)
{
    int num1 = (b - 1) * 10 + a;
    int num2 = (a * 10) + b;
    return num1 > num2;
}

void solve()
{
    string num;
    cin >> num;

    int n = num.length();

    if (n == 1)
    {
        cout << num;
        return;
    }

    string ans = "";
    ans += num[n - 1];

    for (int i = n - 2; i >= 0; i--)
    {
        ans = num[i] + ans;
        if (ans[0] < ans[1])
        {
            for (int j = 0; j < ans.length() - 1; j++)
            {
                if (ans[j] < ans[j + 1])
                {
                    if (swapOrNot(ans[j] - '0', ans[j + 1] - '0'))
                    {
                        char modifiedChar = ans[j + 1] - 1;
                        swap(ans[j], modifiedChar);
                        ans[j + 1] = modifiedChar;
                    }
                }
                else
                {
                    break;
                }
            }
        }
    }

    cout << ans;
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 452 ms):
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int t,n;
	
	cin>>t;
	for(int i=0;i<t;i++)
	{
		cin>>n;
	vector<int>arr(n);
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
		}
		
                for(int i=0;i<n-1;i++)
		{
			if(arr[i]<arr[i+1])
			{
				int temp=arr[i];
				arr[i]=0;
				arr[i+1]=arr[i+1]-temp;
				
			}
			else{
				int temp=arr[i+1];
				arr[i+1]=0;
				arr[i]=arr[i]-temp;
			}

		}
		string t;
		for(int i=0;i<n-1;i++)
		{
			if(arr[i]>arr[i+1])
			{
				t="NO";
				cout<<"NO"<<endl;
				break;
			}
		}
		if(t=="NO")
		{
			continue;
		}
		cout<<"YES"<<endl;
		
			
		
	}
}


Solution 2 (runtime: 343 ms):
#include<bits/stdc++.h>

using namespace std;



void solve(){

    int n;

    cin >> n;

    vector<int> ans;

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

        int num;

        cin >> num;

        ans.push_back(num);

    }

    bool isTrue = true;

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

      if(ans[i-1] > ans[i]){

        isTrue = false;

        break;

      }

      else{

        ans[i] -= ans[i-1];

        ans[i-1] = 0;

      }

    }

    if(isTrue){

      cout << "YES" << endl;

    }

    else{

      cout << "NO" << endl;

    }

}



int main(){

    int t;

    cin >> t;

    while(t-- > 0){

        solve();

    }

}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace chrono;

// Aliases
using ll = long long;
using ull = unsigned long long;
using ld = long double;

// Constants
constexpr ll INF = 4e18;
constexpr ld EPS = 1e-9;
constexpr ll MOD = 998244353;

// Macros
#define F first
#define S second
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
#define pb push_back
#define MP make_pair
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)

// Modular arithmetic functions
ll inv(ll i) {
    if (i == 1) return 1;
    return (MOD - (MOD / i) * inv(MOD % i) % MOD) % MOD;
}

ll mod_mul(ll a, ll b) {
    return (a % MOD * b % MOD) % MOD;
}

ll mod_add(ll a, ll b) {
    return (a % MOD + b % MOD) % MOD;
}

ll mod_sub(ll a, ll b) {
    return (a % MOD - b % MOD + MOD) % MOD;
}

ll pwr(ll a, ll b) {
    ll res = 1;
    a %= MOD;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

// Fast I/O
istream& operator>>(istream &is, vector<ll> &v) {
    for (auto &x : v) is >> x;
    return is;
}

ostream& operator<<(ostream &os, const vector<ll> &v) {
    for (auto &x : v) os << x << " ";
    return os;
}

// Main logic
void solve() {
    int n;
    cin >> n;

    if (n < 1){
        cout<<-1<<endl;
        return;
    }

    vector<ll> a(n);
    for (auto &x : a) cin >> x;  // Read vector

    ll res = max(LLONG_MIN, accumulate(a.begin(), a.end(), 0LL));

    int till = n - 1;

    for (int j = 0; j < n; j++) {
        ll temp = 0;
        for (int i = 0; i <= till; i++) {  // Include 'till'
            temp += a[i];
        }

        if (j == 0)
            res = max(res, temp);
        else
            res = max({res, temp, -temp});

        for (int i = 0; i < till; i++) {
            a[i] = a[i + 1] - a[i];
        }
        till--;
    }
    cout << res << endl;
    return ;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int T;
    cin >> T;

    auto start = high_resolution_clock::now();
    while (T--) {
        solve();
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr << "Time: " << duration.count() / 1000 << " ms" << endl;

    return 0;
}


Solution 2 (runtime: 62 ms):
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std; 

int main(){
    int test, number, current; 
    cin >> test;
    for(int i = 0; i<test; ++i){
        cin >> number; 
        vector<long long> v;
        long long sum = 0; 
        for(int n = 0; n< number; ++n){
            cin >> current; 
            v.push_back(current); 
            sum += current; 
        } 
        long long maxnum = sum; 
        for(int j = number-1; j>0; --j){
            maxnum = max(maxnum, abs(v[j] - v[0])); 
            for(int k = 0; k< j; ++k) v[k] = v[k + 1] - v[k]; 
        }
        cout << maxnum << endl; 
    }
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std;

void solve(){
    int n;
    cin >> n;
    vector<int> vec(n);

    for(int& x : vec) cin >> x;
    for(int i = 0;i < n-1;i++){
        int x = min(vec[i],vec[i+1]);
        vec[i] -= x;
        vec[i+1] -= x;
    }

    for(int i = 0;i < n - 1;i++){
        if(vec[i] > vec[i + 1]) {
            cout << "NO\n";
            return;
        }
    }

    cout << "YES\n";
    return;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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


    return 0;
}


Solution 2 (runtime: 343 ms):
#include<bits/stdc++.h>
using namespace std;
void output(){
   long long int n;
    cin>>n;
    deque <long long int> d;
    for(int i=0;i<n;i++){
        long long int k;
        cin>>k;
        d.push_back(k);
    }
    while(d.size()>1){
        if(d[0]>d[1]){
            cout<<"NO";
            return;
        }
        else if(d[0]<d[1]){
            d[1]-=d[0];
            d.pop_front();
        }
        else{
            d.pop_front();
            d.pop_front();
        }
    }
    cout<<"YES";
    
}

int main(){
    int t;
    cin>>t;
    while(t!=0){
        output();
        cout<<'\n';
        t--;
    }
    return 0;
  }
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 78 ms):
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
const int mod =1e9+7;


void vg(){
    
    int l,r;cin>>l>>r;
    
    int a=0;
    for(int i=30;i>=0;i--){
        
        if(r&(1ll<<i))a|=1ll<<i;
        
        if((l&(1ll<<i))<(r&(1ll<<i))){
            break;
        }
    }
    
    if(a==r){
        cout<<a<<" "<<a-1<<" "<<a-2<<endl;
        return;
    }
    
    cout<<a<<" "<<a-1<<" "<<a+1<<endl;
    
}

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t=1;
    cin>>t;
    while(t--){
        vg();
    }
}

Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;


int MST(int a, int b) {
    
    int highest_bit = max(log2(a), log2(b)) + 1;

    
    for (int i = highest_bit-1; i >= 0; --i) {
        int bitA = (a>>i) & 1; 
        int bitB = (b >> i) & 1; 
        
        if(bitA!=bitB){
           return i;
        }
        
        
    }

    return -1;
}



void solve() {
   ll l,r;
   cin>>l>>r;

   ll check= log2(r);
   if(l<=(1<<check)-1 && r>=(1<<check)){
     cout<<(1<<check)<<" "<<(1<<check)-1<<" ";
     if((1<<check)-1 !=l) cout<<l<<'\n';
     else if ((1<<check) != r) cout<<r<<'\n';
     else cout<<l+1<<'\n';
   }else{
       int result = MST(l,r);
        int cnt=0;
        for(int i=0;i<=result;i++){
         cnt+=pow(2,i);
        }
        int le=(cnt^l);
        int ri=(cnt^r);

        if(l<le && le<r){
            cout<<l<<" "<<le<<" "<<r<<'\n';
        }else if(l<ri && ri<r){
            cout<<l<<" "<<ri<<" "<<r<<'\n';
        }else{
            cout<<l<<" "<<r-1<<" "<<r<<'\n';
        }

    
   }
}

int main() {
    fast;

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

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 78 ms):
#include <bits/stdc++.h>
using namespace std;
void solve(){
    string s;
    cin>>s;
    int sum=0;
    int two=0,three=0;
    for(int i=0;i<s.length();i++){
        sum=(sum+(s[i]-'0'))%9;
        if((s[i]-'0')==2){
            two++;
        }
        else if((s[i]-'0')==3){
            three++;
        }
    }
    for(int i=0;i<=two;i++){
        for(int j=0;j<=three;j++){
            if((sum+2*i+6*j)%9==0){
                cout<<"YES"<<endl;
                return;
            }
        }
    }
    cout<<"NO"<<endl;
}

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    solve();
	}

}


Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;

void solve(int sum, int cnt2, int cnt3)
{
    for (int x = 0; x < min(9, cnt2 + 1); x++)
        for (int y = 0; y < min(9, cnt3 + 1); y++)
        {
            if ((sum + 2 * x + 6 * y) % 9 == 0)
            {
                cout << "YES\n";
                return;
            }
        }
    cout << "NO\n";
}

int main()
{
    int n, sum, cnt2, cnt3;
    string str;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        sum = 0, cnt2 = 0, cnt3 = 0;
        cin >> str;
        for (int j = 0; j < str.length(); j++)
        {
            sum += (str[j] - '0');
            if (str[j] - '0' == 2)
                cnt2++;
            if (str[j] - '0' == 3)
                cnt3++;
        }
        solve(sum, cnt2, cnt3);
    }
    return 0;
}
Problem: 2050B - Transfusion
Language: c++17 

Solution 1 (runtime: 343 ms):
#include<iostream>
using namespace std;

int main()
{
    int t;
    cin>>t;

    while(t--)
    {
        int n;
        cin>>n;

        int arr[n];
        long long evesum = 0, oddsum = 0;
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];

            if(i%2==0)
                oddsum += arr[i];
            else
                evesum += arr[i];
        }
        long long sum = evesum + oddsum;
        if(sum%n != 0)
        {
            cout<<"No"<<endl;
            continue;
        }
        int ele = sum/n;

        if( oddsum/((n+1)/2) == ele && evesum/(n/2) == ele )
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

Solution 2 (runtime: 374 ms):
#include <bits/stdc++.h>

using namespace std;



void solve() {

    int n;cin >> n;

    vector<int> v1, v2; 

    long long sum1 = 0, sum2 = 0;

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

        int x;

        cin >> x;

        if (i % 2 == 0) { 

            v1.push_back(x);

            sum1 += x;

        } else { 

            v2.push_back(x);

            sum2 += x;

        }

    }

    if((sum1*v2.size())==(sum2*v1.size())&&(sum1+sum2)%(n)==0){

        cout<<"YES\n";

    }

    else{

        cout<<"NO\n";

    }

}

int main() {

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

}