ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 156 ms):
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define int long long int
#define sr(x) sort((x).begin(),(x).end())
#define rsr(x) sort((x).rbegin(),(x).rend())
#define pii pair<int, int>
#define mii map<int, int> 
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define ff first
#define ss second
#define setbits(x) __builtin_popcountll(x)
#define msb(x) (63-__builtin_clzll(x))
#define lsb(x) __builtin_ctzll(x)
#define fill(a,b) memset(a, b, sizeof(a))
#define all(x) (x).begin(),(x).end()
#define ld long double
#define rep(i,x,y) for(int i=x; i<y; i++)
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
// rnd() -> generates a random number
const long long M = 1000000007;
const int MAX_A = 1e6 + 1;


string a,b,c; 

int solve(int i, int j, vvi & dp){

    if(i+j== c.length()) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    int ans, ans1=c.length(),ans2 = c.length();
    if(i!=a.length()) ans1 = 1+solve(i+1, j,dp);
    if(j!=b.length()) ans2 = 1+solve(i, j+1,dp);
    ans = min(ans1,ans2);
    if( i!=a.length() && a[i]==c[i+j] )
    ans = min(ans, ans1-1);
    if( j!=b.length() && b[j]==c[i+j] )
    ans = min(ans, ans2-1);
    return dp[i][j] = ans;
}

int32_t main(){
    IOS;
    int t;cin>>t;
    while(t--)
    {
        cin>>a; cin>>b; cin>>c;
        vvi dp(a.length()+1, vi (b.length()+1,-1));
        cout<<solve(0,0,dp)<<endl;
    }
    
    return 0;
}

Solution 2 (runtime: 1312 ms):
#include<bits/stdc++.h>
using namespace std;
# define int long long
using ll = long long ;
string a,b,c;
int n,m,p; 
int dp[1001][2001];
int f( int i ,int k){
    //base case 
    if(k==p) return 0;
    if(dp[i][k]!=-1) return dp[i][k];
    int left=1e9,right=1e9;
    int j=k-i;
    if(i<n){
        left=f(i+1,k+1) + (a[i]!=c[k]);
    }
    if(j<m){
        right=f(i,k+1) + (b[j]!=c[k]);
    }
    return dp[i][k]=min(left,right);
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;cin>>t;
    while(t--){
        cin>>a>>b>>c;
        n=a.length();
        m=b.length();
        p=c.length();
        memset(dp,-1,sizeof(dp));
        int ans=f(0,0);
        cout<<ans<<endl;
    }
    return 0;
}
Problem: 2049C - MEX Cycle
Language: c++17 

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

using namespace std;

int a[200005];

int main() {



	int T;

	cin >> T;

	while (T--) {

		int n, x, y;

		cin >> n >> x >> y;

		int f = 0;

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

			a[i] = f;

			f = (!f);

		}

		if (n & 1) {

			a[n] = 2;

			if(a[x]==a[y]){

				if (x == 1 || x == n - 1) {

					a[y] = 2;

				} else {

					a[x] = 2;

				}			

			}

		} else {

			if(a[x]==a[y]){

				a[x] = 2;

			}

		}

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

			cout << a[i] << " ";

		}

		cout << "\n";

	}



	return 0;

}

Solution 2 (runtime: 62 ms):
#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast")

#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const ll mod = 1e9 + 7;



void solve() {

    int n, x, y;

    cin >> n >> x >> y;

    x -= 1, y -= 1;

    if (x > y) swap(x, y);

    if (y - x == 1 || (x == 0 && y == n - 1)) {

        if (n % 2) {

            for (int i = 0; i < n - 1; i++) cout << i % 2 << " ";

            cout << "2\n";

        } else {

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

            cout << "\n";

        }

        return;

    }

    vector<int> ans(n);

    if (n % 2) {

        for (int i = 0; i < n - 1; i++) ans[i] = i % 2;

        ans[n - 1] = 2;

        if (ans[x] == ans[y]) {

            ans[x] = 2;

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

                ans[(x + 1 + i) % n] = i % 2;

            }

        }

    } else {

        for (int i = 0; i < n; i++) ans[i] = i % 2;

        if (ans[x] == ans[y]) ans[x] = 2;

    }

    for (auto& ansi : ans) cout << ansi << " ";

    cout << "\n";

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    int T = 1;

    cin >> T;

    while (T--) solve();

    return 0;

}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 93 ms):
#include<iostream>
#include<cstring>
using namespace std; static const int inf = 1e9;
int main()
{
	int t;
    cin >> t;
	while(t--)
	{
        string a, b, res;
        cin >> a >> b >> res;
        int n = (int)a.size(), m = (int)b.size();
        int dp[3010][3010];
        std::fill(&dp[0][0], &dp[0][0] + (n + 1) * (m + 1), inf);
        dp[0][0] = 0;
        for (int i = 0; i < n; i++) {
            dp[i + 1][0] = dp[i][0] + (a[i] != res[i]);
        }
        for (int j = 0; j < m; j++) {
            dp[0][j + 1] = dp[0][j] + (b[j] != res[j]);
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != res[i + j - 1]),
                    dp[i][j - 1] + (b[j - 1] != res[i + j - 1]));
            }
        }
        cout << dp[n][m] << endl;
	}
}

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

#define ull unsigned long long
#define ll long long
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int,int>
typedef vector<ll> vll;
#define pii pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define allr(v) v.rbegin(),v.rend()
#define MOD 1000000007
#define sz(x) (int((x).size()))
#define rep(i , a , b) for(int i = a; i < b ; i++)
#define per(i , a , b) for(int i = a; i >= b; i--)
#define ff first
#define ss second
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define read(v) for(int i=0;i<v.size();++i) cin>>v[i]
#define print(x) for(auto it:x) cout<<it<<" "; cout<<"\n";

int fun(string &a, string &b, string &c, int i, int j, vector<vector<int>>&dp){
    int ans=0;
    if(i==a.size()){
        for(int k=i+j; k<a.size()+b.size(); k++){
            if(c[k]!=b[j++]) ans++;
        }
        return ans;
    }
    if(j==b.size()){
        for(int k=i+j; k<a.size()+b.size(); k++){
            if(c[k]!=a[i++]) ans++;
        }
        return ans;
    }
    if(dp[i][j]!=-1) return dp[i][j];
    int x=0,y=0;
    if(c[i+j]!=a[i]) x=1;
    if(c[i+j]!=b[j]) y=1;
    x += fun(a,b,c,i+1,j,dp);
    y += fun(a,b,c,i,j+1,dp);
    return dp[i][j]=min(x,y);
}

void solve() {
    string a,b,c;
    cin>>a>>b>>c;
    vector<vector<int>>dp(a.size(),vector<int>(b.size(),-1));
    int ans = fun(a,b,c,0,0,dp);
    cout<<ans<<endl;
    
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

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

Solution 1 (runtime: 78 ms):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define tr(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define w(a) while(a--)
#define cint(n) ll n; cin >> n;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;

int main() {
    cint(t);
    w(t) {
        string a;
        cin >> a;
        rep(i, 0, sz(a)) {
            rep(j, 1, 10) {
                if (i - j >= 0 && a[i - j] < a[i - j + 1] - 1) {
                    swap(a[i-j], a[i-j+1]);
                    a[i-j]--;
                }
            }
        }
        cout << a << endl;
    }
}


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

using namespace std;

#define ll long long

const int maxn=2e5+7;

char s[maxn];



void solve()

{

	scanf("%s",s+1);

	int n=strlen(s+1);

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

	{

		int res=-1;int now=s[i]-'0';

		for(int j=1;j<=9;j++)

		{

			if(i+j>n) continue;

			int num=s[i+j]-'0';

			if(num-j>now)

			{

				res=j;now=num-j;

			}

		}

		if(res!=-1)

		{

			s[res+i]=s[res+i]-res;

			for(int j=res;j>=1;j--) swap(s[j+i],s[j+i-1]);

		}

	}

	cout<<s+1<<endl;

	return ;

}

signed main()

{

	int t;cin>>t;

	while(t--) solve();

	return 0;

}
Problem: 2049B - pspspsps
Language: c++17 

Solution 1 (runtime: 46 ms):
// **************** 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;

  string str;

  cin>>n>>str;

  set<char>st;

  for(auto c:str)if(c!='.')st.insert(c);

  if(st.size()<=1){

    py;

    return;

  }

  int s=0,p=0;

  for(auto c:str){

    if(c=='s')s++;

    else if(c=='p')p++;

  }

  if(s==1 || p==1){

    if(s==1 && p==1){

      if(str.back()=='p' || str[0]=='s')py;

      else pn;

    }

    else if(s==1){

      if(str[0]=='s')py;

      else pn;

    }

    else{

      if(str.back()=='p')py;

      else pn;

    }

  }

  else pn;

}



int main(){

ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

ll test=1;

cin>>test;

while(test--){

find();

}

return 0;

}

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

using namespace std;



int main()

{

    int t;

    cin >> t;



    while(t --)

    {

        int n;

        string str;

        cin >> n >> str;

        int p = n, s = -1;

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

        {

            if(str[i] == 'p') p = min(p, i);

            if(str[i] == 's') s = max(s, i); 

        }

        if(p < s) cout << "NO" << "\n";

    else if(s == 0 || s == -1 || p == n - 1 || p == n) cout << "YES" << "\n";

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



    }

}
Problem: 2049C - MEX Cycle
Language: c++17 

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

#define u32 unsigned int

#define ll long long

#define ull unsigned ll



const int N = 2e5+5, mod = 998244353;

int ans[N];

void solve() {

    

    int n,x,y;

    std::cin>>n>>x>>y;

    if(x>y) std::swap(x,y);

    ans[1]=0;

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

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

    }

    ans[n]=(n&1)+1;

    if(ans[x]!=ans[y]) {

        //nothing happened nya~

    } else {

        //ans[x]=ans[y];

        if(x==1&&n&1) std::swap(ans[x],ans[n]);

        else ans[x]=2;

    }

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

        std::cout<<ans[i]<<" ";

    }

    std::cout<<"\n";



    return;

}



int main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);

    std::cout.tie(nullptr);

    int t = 1;

    std::cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}

Solution 2 (runtime: 61 ms):
#include <algorithm>

#include <bitset>

#include <cassert>

#include <cmath>

#include <iomanip>

#include <iostream>

#include <limits.h>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <string>

#include <vector>



#define  DBG(x         ) cerr<<#x<<" = "<<(x)<<endl;

#define DBG2(x, y      ) cerr<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<endl;

#define DBG3(x, y, z   ) cerr<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<", "<<#z<<" = "<<(z)<<endl;

#define DBG4(x, y, z, w) cerr<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<", "<<#z<<" = "<<(z)<<", "<<#w<<" = "<<(w)<<endl;

#define SEPA cerr<<" ============ "<<endl;



#define forn(i, n) for(int i = 0; i < int(n); i++)

#define fort(i, a, b) for(int i = int(a); i <= int(b); i++)



#define sz(s) int(s.size())

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

#define rall(s) s.rbegin(), s.rend()

#define pb push_back

#define endl '\n'

#define fst first

#define snd second

#define pii pair<int, int>

#define pll pair<long long, long long>

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;



using namespace std;



void run_case(){

    int n, x, y; cin>>n>>x>>y;

    x--, y--;

    vector<int> ans(n);

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

        ans[i] = (i % 2 == 1);

    

    //for(int x : ans) cout<<x<<' '; cout<<endl;

    

    auto mex = [&](int a, int b, int c = 1e5){

        int res = 0;

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

            if(i != a && i != b && i != c){

                res = i; 

                break;

            }

        return res;

    };

    ans[x] = mex(ans[((x - 1) + n) % n], ans[(x + 1) % n]);

    ans[y] = mex(ans[((y - 1) + n) % n], ans[(y + 1) % n], ans[x]);

    if(x != 0)

        ans[0] = mex(ans.back(), ans[1]);

    for(int x : ans) cout<<x<<' '; cout<<endl;

}



int main(){

    fast_io

    //freopen("input.in", "r", stdin);

    bool mtc = true;

    int tc = 1; if(mtc) cin>>tc;

    for(int i = 0; i < tc; i++) run_case();

    return 0;

}
Problem: 2049C - MEX Cycle
Language: c++17 

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

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,x,y,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m>>x>>y;

      x--; y--;

      vector<ll>v(m);

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

      v[(x+i)%m]=i%2;

      if(m%2 || (x-y)%2==0)

      v[x]=2;

      for(auto k : v)

      cout<<k<<' ';

      cout<<endl;

    }

}

Solution 2 (runtime: 109 ms):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;





void DFS(int index, vector<int> &ans, int &n, vector<vector<int>> &friends) {

    if (index == n) return;

    if (ans[index] != -1) DFS(index+1, ans, n, friends);

    else {

        int first = min(ans[friends[index][0]], ans[friends[index][1]]);

        int second = max(ans[friends[index][0]], ans[friends[index][1]]);

        if (first == -1 && second == -1) ans[index] = 0;

        else if (first == -1 && second == 0) ans[index] = 1;

        else if (first == -1 && second == 1) ans[index] = 0;

        else if (first == -1 && second == 2) ans[index] = 0;

        else if (first == 0 && second == 0) ans[index] = 1;

        else if (first == 0 && second == 1) ans[index] = 2;

        else if (first == 0 && second == 2) ans[index] = 1;

        else ans[index] = 0;

        DFS(index+1, ans, n, friends);

    }

    return;

}



void solve() {

    int n, x, y;

    cin >> n >> x >> y;

    vector<vector<int>> friends(n);

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

        friends[i].push_back((i-1+n)%n);

        friends[i].push_back((i+1)%n);

    }

    if (abs(x-y) != 1) {

        friends[x-1].push_back(y-1);

        friends[y-1].push_back(x-1);

    }

    vector<int> ans(n, -1);

    ans[x-1] = 0;

    ans[y-1] = 1;

    DFS(0, ans, n,  friends);

    for (int i : ans) cout << i << " ";

    cout << "\n";

}



int main() {

    cin.tie(0)->sync_with_stdio(0);

    int t;

    cin >> t;

    while (t--) solve();

    return 0;

}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

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

void solve(){
    ll l, r; cin >> l >> r;
    int cnt=0;

    // if(r-l==2){
    //     cout<<r<<" "<<r-1<<" "<<r-2<<'\n';
    //     return;
    // }
    for(int i=0; i<=30; i++){
        ll potencia=pow(2, i);
        if(r&potencia){
            cnt=i;
        }
    }

    ll min=l, max=r;
    for(int i=0; i<=cnt; i++){
        ll potencia=pow(2, i);
        if((min&potencia) == (max&potencia) && (min&potencia)){
            if(min-potencia>=l){
                min-=potencia;
            }
            else if(max-potencia>=l){
                max-=potencia;
            }
        }
        else if((min&potencia) == (max&potencia) && !(min&potencia)){
            if(min+potencia<=r){
                min+=potencia;
            }
            else if(max+potencia<=r){
                max+=potencia;
            }
        }   
    }
    ll mid;
    if(min==l || max==l){
        for(ll i=l; i<=r; i++){
            if(i!=min && i!=max){
                mid=i;
                break;
            }
        }
    }
    else{
        mid=l;
    }

    cout<<mid<<" "<<min<<" "<<max<<'\n';
    
    
}




int main() {
    fastIo();
    int t; cin >> t;
    while(t--) solve();

    return 0;
}

Solution 2 (runtime: 62 ms):
/*
    auther:Wangzyy
    url:https://www.topscoding.com/d/examination/contest/678621122e0ba7bf6663a54c
*/
 
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target ("avx")
#pragma GCC optimize ("inline")
 
#include <bits/stdc++.h>
 
#define ios_close std::ios::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr)
 
using i64 = long long;
using u64 = unsigned long long;
using ld = long double;
 
#define Pi  acos(-1.0)
#define rep(i, a, n) for(int i = a; i <= n; i ++ )
#define per(i, a, n) for(int i = a; i >= n; i -- )
#define pb push_back
#define eb emplace_back
#define mp std::make_pair
#define all0(x) (x).begin(), (x).end()
#define all1(x) (x).begin() + 1, (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define pii std::pair<int, int>
#define pil std::pair<int, i64>
#define pli std::pair<i64, int>
#define pll std::pair<i64, i64>

void solve(){
    int l, r;
    std::cin >> l >> r;

    int a = 0, b = 0, p = 0;
    for(int i = 30; i >= 0; i -- ){
        if(((l >> i) & 1) != ((r >> i) & 1)){
            p = i;
            b += 1 << i;
            break;
        } else {
            if((l >> i) & 1){
                a += 1 << i;
                b += 1 << i;
            }
        }
    }

    for(int i = p - 1; i >= 0; i -- ){
        a += 1 << i;
    }

    int c = a == l ? r : l;

    std::cout << a << " " << b << " " << c << '\n';
}
 
int main(){
#if 1
    ios_close;
#endif
#if 0
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif
    int T = 1;
#if 1
    std::cin >> T;
#endif
#if 0
    scanf("%d", &T);
#endif
    while(T -- ){
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

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

using namespace std;

int main(){

	int n;

	cin >>n;

	while(n--){

		int m;

		cin >>m;

		vector<int> v;

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

			int num;

			cin >>num;

			v.push_back(num);

		}

		int flag=1;

		int shu=min(v[0],v[1]);

		v[0]-=shu;

		v[1]-=shu;

		int i;

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

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

			flag=0;

			break;

		 }	

			int tem=v[i]-min(v[i],v[i+1]);

			if(tem>=v[i-1]){

				v[i+1]-=min(v[i],v[i+1]);

				v[i]=tem;

			}

		}

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

			flag=0;

		}

		if(flag){

			cout <<"YES"<<endl;

		}else{

			cout <<"NO" <<endl;

		}

	}

}

Solution 2 (runtime: 343 ms):
#include<iostream>

#include<algorithm>



using namespace std;



const int N = 2e5 + 10;



int a[N];

int n;



void solve(){

cin >> n;



// 只要相减必然会出现0



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

cin >> a[i];

}

if(a[1] > a[2]){

cout << "NO" << endl;

return ;

}

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

if(a[i] - min(a[i],a[i - 1]) > a[i + 1]){

cout << "NO" << endl;

return ;

}else{

int mi = min(a[i],a[i - 1]);

a[i] -= mi;

a[i - 1] -= mi;

}

}

cout << "YES" << endl;

}



int main(){

int t = 1;

cin >> t;



while(t --) solve();



return 0;

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

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

#define int long long

int32_t main() {
 
 int t;
 cin>>t;
 
 while(t--)
 {
    int n;
    cin>>n;
    
    vector<int>v(n+1);
    
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    
    int odd_s=0;
    
    int even_s=0;
    
    
    for(int i=1;i<=n;i++)
    {
        if(i%2==0)
        {
          even_s+=v[i];
        }else{
            odd_s+=v[i];
        }
    }
    
    int z,t;
    
    if(n%2==0)
    {
        z=n/2;
        t=n/2;
    }else{
        z=n/2;
        t=n/2+1;
    }
 
    if(even_s%z==0 and odd_s%t==0 and even_s/z==odd_s/t)
    {
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
  
    
 
}
    

    return 0;
}


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

using namespace std;



int main () {
    int t, n;

    cin >> t;
    while (t--) {
        cin >> n;
        unsigned long long even_sum=0, odd_sum=0, even_count=0, odd_count=0;
        for (int i=0; i<n; i++) {
            int a;
            cin >> a;
            if (i%2==0) { even_sum += a; even_count++; }
            else { odd_sum += a; odd_count++; }
        }
        if (even_sum%even_count==0 && odd_sum%odd_count==0 && even_sum/even_count==odd_sum/odd_count) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 77 ms):
#include<iostream>

using namespace std;
bool dp[100050][9];
void solve()
{
	string str;
	cin >> str;
	int two=0, one=0, three = 0;
	int n = str.size();
	for (int i = 0; i < n; i++)
	{
		one += str[i] - '0';
		 if (str[i] == '2')
			two++;
		else if(str[i]=='3')
			three++;
	}
	for (int i = 0; i <= min(10, two); ++i)
	{
		for (int j = 0; j <= min(10, three); ++j)
		{
			if ((one + i * 2 + j * 6) % 9 == 0)
			{
				cout << "YES" << endl;
				return;
			}
		}
}
	cout << "NO" << endl;
}


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

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

using namespace std;



typedef long long ll;

typedef vector<ll> vi;

typedef vector<vi> vvi;

typedef vector<char> vc;

typedef vector<vc> vvc;

typedef vector<pair<ll,ll>> vii;

typedef pair<ll,ll> ii;



#define M 1000000007

#define pb push_back

const ll N = 1e5;



#define f(i, a, b) for (ll i = a; i < b; i++)

#define lb(a,b) lower_bound(a.begin(),a.end(),b)

#define ub(a,b) upper_bound(a.begin(),a.end(),b)



// Binary Exponentiation Function

ll be(ll a, ll b, ll m) {

    ll ans = 1;

    while (b > 0) {

        if (b & 1) {

            ans = (ans * 1LL * a) % m;

        }

        a = (a * 1LL * a) % m;

        b >>= 1;

    }

    return ans;

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t;

    cin >> t;

    f(i, 0, t) {

        // Put all effort in your logic

      string sp;

      cin>>sp;

      ll s=0;

      ll to=0,th=0;

      for(char ch:sp){

        ll num=ch-'0';

        s+=num;

        if(num==2) to++;

        if(num==3) th++; 

      }

        bool cond=true;

        for(ll i=0;i<=min(to,(ll)10);i++){

            for(ll j=0;j<=min(th,(ll)10);j++){

                if((s+(i*2)+(j*6))%9==0){

                    cond=false;

                    break;

                }

            }

        }

        if(!cond) cout<<"YES"<<endl;

        else{

            cout<<"NO"<<endl;

        }

    }

}