ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x) cerr << endl << (#x) << " is " << (x) << endl
#define mod  1000000007
#define INF 0x3F3F3F3F
#define ll long long
#define noo { cout<<"NO"<<endl; return; }
#define pprint(a,b) {cout<<"("<<a<<","<<b<<")"<<endl;}
#define pb push_back
#define MAXN 3005
#define ff first
#define ss second
typedef  pair<int,int>  pii;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
const int N = (int)5e5+5;


void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    vector<int>arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
        // cout<<arr[i]<<" ";
    }
    l--, r--;
    vector<int>arr1, arr2;
    for(int i=0;i<=r;i++){
        // cout<<arr[i]<<" ";
        arr1.push_back(arr[i]);
    }
    for(int i=l;i<n;i++){
        arr2.push_back(arr[i]);
    }
    sort(arr1.begin(), arr1.end());
    sort(arr2.begin(), arr2.end());
    int ans1 = 0;
    for(int i=0;i<r-l+1;i++){
        // cout<<arr1[i]<<" ";
        ans1 += arr1[i]; 
    }
    // cout<<"\n";
    int ans2 = 0;
    for(int i=l;i<r-l+l+1;i++){
        // cout<<arr2[i]<<" ";
        ans2 += arr2[i];
    }
    // cout<<"\n";
    int ans = 0;
    if(ans1!=0 && ans2!=0) ans = min(ans1,ans2);
    else if(ans1==0) ans = ans2;
    else ans = ans1;
    cout<<ans<<"\n";


}

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

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 8):
#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x) cerr << endl << (#x) << " is " << (x) << endl
#define mod  1000000007
#define INF 0x3F3F3F3F
#define ll long long
#define noo { cout<<"NO"<<endl; return; }
#define pprint(a,b) {cout<<"("<<a<<","<<b<<")"<<endl;}
#define pb push_back
#define MAXN 3005
#define ff first
#define ss second
typedef  pair<int,int>  pii;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
const int N = (int)5e5+5;


void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    vector<int>arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
        // cout<<arr[i]<<" ";
    }
    l--, r--;
    vector<int>arr1, arr2;
    for(int i=0;i<=r;i++){
        // cout<<arr[i]<<" ";
        arr1.push_back(arr[i]);
    }
    for(int i=l;i<n;i++){
        arr2.push_back(arr[i]);
    }
    sort(arr1.begin(), arr1.end());
    sort(arr2.begin(), arr2.end());
    int ans1 = 0;
    for(int i=0;i<r-l+1;i++){
        // cout<<arr1[i]<<" ";
        ans1 += arr1[i]; 
    }
    // cout<<"\n";
    int ans2 = 0;
    for(int i=0;i<r-l+1;i++){
        // cout<<arr2[i]<<" ";
        ans2 += arr2[i];
    }
    // cout<<"\n";
    int ans = 0;
    if(ans1!=0 && ans2!=0) ans = min(ans1,ans2);
    else if(ans1==0) ans = ans2;
    else ans = ans1;
    cout<<ans<<"\n";


}

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

    return 0;
}

Submission (verdict: Accepted):
#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x) cerr << endl << (#x) << " is " << (x) << endl
#define mod  1000000007
#define INF 0x3F3F3F3F
#define ll long long
#define noo { cout<<"NO"<<endl; return; }
#define pprint(a,b) {cout<<"("<<a<<","<<b<<")"<<endl;}
#define pb push_back
#define MAXN 3005
#define ff first
#define ss second
typedef  pair<int,int>  pii;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
const int N = (int)5e5+5;


void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    vector<int>arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
        // cout<<arr[i]<<" ";
    }
    l--, r--;
    vector<int>arr1, arr2;
    for(int i=0;i<=r;i++){
        // cout<<arr[i]<<" ";
        arr1.push_back(arr[i]);
    }
    for(int i=l;i<n;i++){
        arr2.push_back(arr[i]);
    }
    sort(arr1.begin(), arr1.end());
    sort(arr2.begin(), arr2.end());
    ll ans1 = 0;
    for(int i=0;i<r-l+1;i++){
        // cout<<arr1[i]<<" ";
        ans1 += arr1[i]; 
    }
    // cout<<"\n";
    ll ans2 = 0;
    for(int i=0;i<r-l+1;i++){
        // cout<<arr2[i]<<" ";
        ans2 += arr2[i];
    }
    // cout<<"\n";
    ll ans = 0;
    if(ans1!=0 && ans2!=0) ans = min(ans1,ans2);
    else if(ans1==0) ans = ans2;
    else ans = ans1;
    cout<<ans<<"\n";


}

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

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x) cerr << endl << (#x) << " is " << (x) << endl
#define mod  1000000007
#define INF 0x3F3F3F3F
#define ll long long
#define noo { cout<<"NO"<<endl; return; }
#define pprint(a,b) {cout<<"("<<a<<","<<b<<")"<<endl;}
#define pb push_back
#define MAXN 3005
#define ff first
#define ss second
typedef  pair<int,int>  pii;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
const int N = (int)5e5+5;


void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    vector<int>arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
        // cout<<arr[i]<<" ";
    }
    l--, r--;
    vector<int>arr1, arr2;
    for(int i=0;i<=r;i++){
        // cout<<arr[i]<<" ";
        arr1.push_back(arr[i]);
    }
    for(int i=l;i<n;i++){
        arr2.push_back(arr[i]);
    }
    sort(arr1.begin(), arr1.end());
    sort(arr2.begin(), arr2.end());
    int ans1 = 0;
    for(int i=0;i<r-l+1;i++){
        // cout<<arr1[i]<<" ";
        ans1 += arr1[i]; 
    }
    // cout<<"\n";
    int ans2 = 0;
    for(int i=l;i<r-l+l+1;i++){
        // cout<<arr2[i]<<" ";
        ans2 += arr2[i];
    }
    // cout<<"\n";
    int ans = 0;
    if(ans1!=0 && ans2!=0) ans = min(ans1,ans2);
    else if(ans1==0) ans = ans2;
    else ans = ans1;
    cout<<ans<<"\n";


}

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

    return 0;
}

Submission (verdict: Wrong answer on test 8):
#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x) cerr << endl << (#x) << " is " << (x) << endl
#define mod  1000000007
#define INF 0x3F3F3F3F
#define ll long long
#define noo { cout<<"NO"<<endl; return; }
#define pprint(a,b) {cout<<"("<<a<<","<<b<<")"<<endl;}
#define pb push_back
#define MAXN 3005
#define ff first
#define ss second
typedef  pair<int,int>  pii;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
const int N = (int)5e5+5;


void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    vector<int>arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
        // cout<<arr[i]<<" ";
    }
    l--, r--;
    vector<int>arr1, arr2;
    for(int i=0;i<=r;i++){
        // cout<<arr[i]<<" ";
        arr1.push_back(arr[i]);
    }
    for(int i=l;i<n;i++){
        arr2.push_back(arr[i]);
    }
    sort(arr1.begin(), arr1.end());
    sort(arr2.begin(), arr2.end());
    int ans1 = 0;
    for(int i=0;i<r-l+1;i++){
        // cout<<arr1[i]<<" ";
        ans1 += arr1[i]; 
    }
    // cout<<"\n";
    int ans2 = 0;
    for(int i=0;i<r-l+1;i++){
        // cout<<arr2[i]<<" ";
        ans2 += arr2[i];
    }
    // cout<<"\n";
    int ans = 0;
    if(ans1!=0 && ans2!=0) ans = min(ans1,ans2);
    else if(ans1==0) ans = ans2;
    else ans = ans1;
    cout<<ans<<"\n";


}

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

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define rep(i, k, n) for (ll i = k; i < n; i++)
#define pb push_back
using namespace std;
void solve()
{
    ll l, r;
    cin >> l >> r;
    ll a, b, c;
    ll temp = r;
    ll bit = 1;
    ll val = 0;
    while (temp)
    {
        if ((temp & 1) == 1)
        {
            val = bit;
        }
        temp = temp >> 1;
        bit++;
    }
    a=(1<<(val-1));
    // cout<<val-2<<endl;
    for(int i=val-2;i>=0;i--){
        if(a>l and a<=r){
            break;
        }
        a=a+(1<<i);
        if(a>r){
            a=a-(1<<i);
            continue;
        }
    }
    if(a==r){
        cout<<a<<" "<<a-1<<" "<<r-2<<endl;
    }
    else{
        cout<<a<<" "<<a-1<<" "<<r<<endl;
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define ll long long
#define db double
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
using namespace std;
ll read(){
	ll sum=0,f=1;char st=getchar();
	while(st<'0'||st>'9'){
		if(st=='-')f=-1;
		st=getchar();
	}
	while('0'<=st&&st<='9'){
		sum=(sum<<3)+(sum<<1)+st-'0';
		st=getchar();
	}
	return sum*f;
}
const int maxn=100010,mod=998244353;
map<int,int> p;
int cnt[maxn];
int main(){
	int TT=read();
	while(TT--){
		int l=read(),r=read(),a=0,b=0,c=0;
		for(int i=30;i>=0;--i){
			int op1=(l>>i)&1,op2=(r>>i)&1;
			if(!op1&&op2){
				c=1<<i;
				for(int j=i-1;j>=0;--j)
					a|=(1<<j);
				break;
			}
		}
		if(c+1<=r)b=c+1;
		if(a-1>=l)b=a-1;
		printf("%d %d %d\n",a,b,c);
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
#define int long long
#define pb push_back

void solveStupid() {
    int l, r;
    cin >> l >> r;
    int n = l ^ r;
    int cnt = 31 - __builtin_clz(n);
    int z = (1 << cnt) - 1;
    int rz = l | z;
    if(l == rz) cout << rz << ' ' << rz + 1 << ' ' << r << '\n';
    else cout << rz << ' ' << rz + 1 << ' ' << l << '\n';
}

signed main() {
    //freopen("input.txt", "r", stdin);
    //freopen("sum.in", "r", stdin);
    //freopen("sum.out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        solveStupid();
    }
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define rep(i, k, n) for (ll i = k; i < n; i++)
#define pb push_back
using namespace std;
void solve()
{
    ll l, r;
    cin >> l >> r;
    ll a, b, c;
    ll temp = r;
    ll bit = 1;
    ll val = 0;
    while (temp)
    {
        if ((temp & 1) == 1)
        {
            val = bit;
        }
        temp = temp >> 1;
        bit++;
    }
    a=(1<<(val-1));
    // cout<<val-2<<endl;
    for(int i=val-2;i>=0;i--){
        if(a>l and a<=r){
            break;
        }
        a=a+(1<<i);
        if(a>r){
            a=a-(1<<i);
            continue;
        }
    }
    if(a==r){
        cout<<a<<" "<<a-1<<" "<<r-2<<endl;
    }
    else{
        cout<<a<<" "<<a-1<<" "<<r<<endl;
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
#define int long long
#define pb push_back

void solveStupid() {
    int l, r;
    cin >> l >> r;
    int n = l ^ r;
    int cnt = 31 - __builtin_clz(n);
    int z = (1 << cnt) - 1;
    int rz = l | z;
    if(l == rz) cout << rz << ' ' << rz + 1 << ' ' << r << '\n';
    else cout << rz << ' ' << rz + 1 << ' ' << l << '\n';
}

signed main() {
    //freopen("input.txt", "r", stdin);
    //freopen("sum.in", "r", stdin);
    //freopen("sum.out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        solveStupid();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
       int n;
       cin>>n;
       vector<int>ans(n);
       for(int i=0;i<n;i++) cin>>ans[i];
       
       if(is_sorted(ans.begin(),ans.end())) cout<<"YES\n";
       else
       {
           bool flag=1;
           for(int i=0;i<n-1;i+=2)
           {
               if(ans[i]>=ans[i+1])
               {
                   flag=0;
                   cout<<"NO\n";
                   break;
               }
           }
           if(flag) cout<<"YES\n";
       }
    }

    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
       int n;
       cin>>n;
       vector<int>ans(n);
       for(int i=0;i<n;i++) cin>>ans[i];
       
       if(is_sorted(ans.begin(),ans.end())) cout<<"YES\n";
       else
       {
           bool flag=1;
           for(int i=0;i<n-1;i+=1)
           {
               if(ans[i]>ans[i+1])
               {
                   flag=0;
                   cout<<"NO\n";
                   break;
               }
               else
               {
                   ans[i]-=ans[i];
                   ans[i+1]-=ans[i];
               }
           }
           if(flag) cout<<"YES\n";
       }
    }

    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
       int n;
       cin>>n;
       vector<int>ans(n);
       for(int i=0;i<n;i++) cin>>ans[i];
       
       if(is_sorted(ans.begin(),ans.end())) cout<<"YES\n";
       else
       {
           bool flag=1;
           for(int i=0;i<n-1;i+=1)
           {
               if(ans[i]>ans[i+1])
               {
                   flag=0;
                   cout<<"NO\n";
                   break;
               }
               else
               {
                   int sub=ans[i];
                   ans[i]-=sub;
                   ans[i+1]-=sub;
               }
           }
           if(flag) cout<<"YES\n";
       }
    }

    return 0;
}
Problem: 2060D - Subtract Min Sort
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--) {
       int n;
       cin>>n;
       vector<int>ans(n);
       for(int i=0;i<n;i++) cin>>ans[i];
       
       if(is_sorted(ans.begin(),ans.end())) cout<<"YES\n";
       else
       {
           bool flag=1;
           for(int i=0;i<n-1;i+=2)
           {
               if(ans[i]>=ans[i+1])
               {
                   flag=0;
                   cout<<"NO\n";
                   break;
               }
           }
           if(flag) cout<<"YES\n";
       }
    }

    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
       int n;
       cin>>n;
       vector<int>ans(n);
       for(int i=0;i<n;i++) cin>>ans[i];
       
       if(is_sorted(ans.begin(),ans.end())) cout<<"YES\n";
       else
       {
           bool flag=1;
           for(int i=0;i<n-1;i+=1)
           {
               if(ans[i]>ans[i+1])
               {
                   flag=0;
                   cout<<"NO\n";
                   break;
               }
               else
               {
                   ans[i]-=ans[i];
                   ans[i+1]-=ans[i];
               }
           }
           if(flag) cout<<"YES\n";
       }
    }

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

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include<bits/stdc++.h>
using namespace std;

void solve(){
    int n;;cin>>n;int arr[n],sum=0;
    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{
        check=check/n;
        for(int i=0;i<n;i++){
            sum+=(arr[i]-check);
        }
        if(sum!=0){
            cout<<"NO"<<endl;
        }
        else{
            for(int i=0;i<n;i++){
                if((arr[i]-check)==0){
                    if(((arr[i-1]-check)+(arr[i+1]-check))!=0){
                        cout<<"NO"<<endl;
                        check=-1;
                        break;
                    }
                }
            }
            if(check!=-1){
                cout<<"YES"<<endl;
            }
        }
    }
}

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


Submission (verdict: Wrong answer on test 3):
#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;
}
Problem: 2050B - Transfusion
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#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;
}


Submission (verdict: Accepted):
#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;
}
Problem: 2050B - Transfusion
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include<bits/stdc++.h>
using namespace std;

void solve(){
    int n;;cin>>n;int arr[n],sum=0;
    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{
        check=check/n;
        for(int i=0;i<n;i++){
            sum+=(arr[i]-check);
        }
        if(sum!=0){
            cout<<"NO"<<endl;
        }
        else{
            for(int i=0;i<n;i++){
                if((arr[i]-check)==0){
                    if(((arr[i-1]-check)+(arr[i+1]-check))!=0){
                        cout<<"NO"<<endl;
                        check=-1;
                        break;
                    }
                }
            }
            if(check!=-1){
                cout<<"YES"<<endl;
            }
        }
    }
}

int main(){
int t;cin>>t;
while(t-->0){
solve();
}
return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
    int n; cin>>n;
    vector<int> vi;
    ll ans=0;
    for(int i=0;i<n;i++){
        int x; cin>>x;
        vi.push_back(x);
        ans+=x;
    }
    if(n==1){
        cout<<vi[0];
        return;
    }
    else if(n>2){
        for(int i=1;i<=n-2;i++){
            for(auto it=vi.begin();it!=vi.end()-1;it++){
                ll sum=0;
                *it=*(it+1)-*it;
                sum+=(*it);
                if(sum<0){
                    sum=0-sum;
                }
                ans=max(ans,sum);
            }
            vi.pop_back();
        }
    }
    auto it=vi.begin();
    ll a=*(it+1)+*it; ll b=(*it)-*(it+1); ll c=*(it+1)-(*it);
    ans=max(ans,max(a,max(b,c)));
    cout<<ans;
}

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


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
    int n; cin>>n;
    vector<ll> vi;
    ll ans=0;
    for(int i=0;i<n;i++){
        int x; cin>>x;
        vi.push_back(x);
        ans+=x;
    }
    if(n==1){
        cout<<vi[0];
        return;
    }
    else if(n>2){
        for(int i=1;i<=n-2;i++){
            for(auto it=vi.begin();it!=vi.end()-1;it++){
                ll sum=0;
                *it=*(it)-*(it+1);
                sum+=(*it);
                sum=abs(sum);
                ans=max(ans,sum);
            }
            vi.pop_back();
        }
    }
    auto it=vi.begin();
    ll a=*(it+1)+*it; ll b=(*it)-*(it+1); ll c=*(it+1)-(*it);
    ans=max(ans,max(a,max(b,c)));
    cout<<ans;
}

int main() {
    int t; cin >> t;
    while (t-- > 0) {
        solve();
        cout << "\n";
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
    int n; cin>>n;
    vector<int> vi;
    ll ans=0;
    for(int i=0;i<n;i++){
        int x; cin>>x;
        vi.push_back(x);
        ans+=x;
    }
    if(n==1){
        cout<<vi[0];
        return;
    }
    else if(n>2){
        for(int i=1;i<=n-2;i++){
            for(auto it=vi.begin();it!=vi.end()-1;it++){
                ll sum=0;
                *it=*(it+1)-*it;
                sum+=(*it);
                if(sum<0){
                    sum=0-sum;
                }
                ans=max(ans,sum);
            }
            vi.pop_back();
        }
    }
    auto it=vi.begin();
    ll a=*(it+1)+*it; ll b=(*it)-*(it+1); ll c=*(it+1)-(*it);
    ans=max(ans,max(a,max(b,c)));
    cout<<ans;
}

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