ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

#define fir first
#define sec second
#define endl "\n"   

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int N = 1e5, M = N * 2, mod = 1e9 + 7, inf = 0x3f3f3f3f, P = 131;

void solve()
{
    int n;
    cin >> n;
    vector<int>a(n + 1);
    ll ans = 0;
    for(int i = 1;i <= n;i ++){
        cin >> a[i];
        ans += a[i];
    }
    if(n == 1){
        cout << a[1] << endl;
        return;
    }
    // int ans = -inf;
    for(int i = n - 1;i >= 1;i --){
        ll sum = 0;
        for(int j = 1; j <= i ;j ++){
            a[j] = a[j + 1] - a[j];
        }
        for(int j = 1;j <= i;j ++)
            sum += a[j];
        ans = max(ans,abs(sum));
    }
    cout << ans << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

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

    return 0;
}

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

#define fir first
#define sec second
#define endl "\n"   

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int N = 1e5, M = N * 2, mod = 1e9 + 7, inf = 0x3f3f3f3f, P = 131;

void solve()
{
    int n;
    cin >> n;
    vector<ll>a(n + 1);
    ll ans = 0;
    for(int i = 1;i <= n;i ++){
        cin >> a[i];
        ans += a[i];
    }
    if(n == 1){
        cout << a[1] << endl;
        return;
    }
    // int ans = -inf;
    for(int i = n - 1;i >= 1;i --){
        ll sum = 0;
        for(int j = 1; j <= i ;j ++){
            a[j] = a[j + 1] - a[j];
        }
        for(int j = 1;j <= i;j ++)
            sum += a[j];
        ans = max(ans,abs(sum));
    }
    cout << ans << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

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

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main()
{
    int t, n;
    cin >> t;

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

        int n2 = 0, n3 = 0, sum = 0;

        while (n > 0)
        {
            if (n % 10 == 2)
                n2++;
            if (n % 10 == 3)
                n3++;

            sum += n % 10;
            n /= 10;
        }

        int rem = sum % 9;

        bool ans = false;
        for (int i = 0; i <= n2; i++)
            for (int j = 0; j <= n3; j++)
                if ((rem + i * 2 + j * 6) % 9 == 0)
                {
                    ans = true;
                    break;
                }

        if (ans)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main()
{
    int t, n;
    cin >> t;

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

        int n2 = 0, n3 = 0, sum = 0;

        while (n > 0)
        {
            if (n % 10 == 2)
                n2++;
            if (n % 10 == 3)
                n3++;

            sum += n % 10;
            n /= 10;
        }

        int rem = sum % 9;

        bool ans = false;
        for (int i = 0; i <= n2; i++)
            for (int j = 0; j <= n3; j++)
                if ((sum + i * 2 + j * 6) % 9 == 0)
                {
                    ans = true;
                    break;
                }

        if (ans)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main()
{
    int t, n;
    cin >> t;

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

        int n2 = 0, n3 = 0, sum = 0;

        while (n > 0)
        {
            if (n % 10 == 2)
                n2++;
            if (n % 10 == 3)
                n3++;

            sum += n % 10;
            n /= 10;
        }

        int rem = sum % 9;

        bool ans = false;
        for (int i = 0; i <= n2; i++)
            for (int j = 0; j <= n3; j++)
                if ((rem + i * 2 + j * 6) % 9 == 0)
                {
                    ans = true;
                    break;
                }

        if (ans)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main()
{
    int t, n;
    cin >> t;

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

        int n2 = 0, n3 = 0, sum = 0;

        while (n > 0)
        {
            if (n % 10 == 2)
                n2++;
            if (n % 10 == 3)
                n3++;

            sum += n % 10;
            n /= 10;
        }

        int rem = sum % 9;

        bool ans = false;
        for (int i = 0; i <= n2; i++)
            for (int j = 0; j <= n3; j++)
                if ((sum + i * 2 + j * 6) % 9 == 0)
                {
                    ans = true;
                    break;
                }

        if (ans)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main()
{
    int t, n;
    cin >> t;

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

        int n2 = 0, n3 = 0, sum = 0;

        while (n > 0)
        {
            if (n % 10 == 2)
                n2++;
            if (n % 10 == 3)
                n3++;

            sum += n % 10;
            n /= 10;
        }

        int rem = sum % 9;

        bool ans = false;
        for (int i = 0; i <= min(n2, 8ll); i++)
            for (int j = 0; j <= min(n3, 8ll); j++)
                if ((sum + i * 2 + j * 6) % 9 == 0)
                {
                    ans = true;
                    break;
                }

        if (ans)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main()
{
    int t, n;
    cin >> t;

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

        int n2 = 0, n3 = 0, sum = 0;

        while (n > 0)
        {
            if (n % 10 == 2)
                n2++;
            if (n % 10 == 3)
                n3++;

            sum += n % 10;
            n /= 10;
        }

        int rem = sum % 9;

        bool ans = false;
        for (int i = 0; i <= min(n2, 8ll); i++)
            for (int j = 0; j <= min(n3, 8ll); j++)
                if ((sum + i * 2 + j * 6) % 9 == 0)
                {
                    ans = true;
                    break;
                }

        if (ans)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define int long long

using namespace std;

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

    while (t--)
    {
        string s;
        cin >> s;

        int n2 = 0, n3 = 0, sum = 0;

        for (auto i : s)
        {
            if (i == '2')
                n2++;

            if (i == '3')
                n3++;

            sum += (int)i - 48;
        }

        int rem = sum % 9;

        bool ans = false;
        for (int i = 0; i <= min(n2, 8ll); i++)
            for (int j = 0; j <= min(n3, 8ll); j++)
                if ((rem + i * 2 + j * 6) % 9 == 0)
                {
                    ans = true;
                    break;
                }

        if (ans)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 6):
#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> arr(n);
        for (int i = 0; i < n; i++) cin >> arr[i];
        
        int ans = accumulate(arr.begin(), arr.end(), 0LL);
        
        while (--n)
        {
            if (arr[arr.size() - 2] > arr[1]) reverse(arr.begin(), arr.end());
            vector<int> temp;
            for (int i = 1; i < arr.size(); i++)
            {
                temp.push_back(arr[i] - arr[i - 1]);
            }
            
            int res = accumulate(temp.begin(), temp.end(), 0LL);
            ans = max(ans, res);
            arr = temp;
        }
        
        cout << ans << endl;
    }
}

Submission (verdict: Accepted):
#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> arr(n);
        for (int i = 0; i < n; i++) cin >> arr[i];
        
        int ans = accumulate(arr.begin(), arr.end(), 0LL);
        
        while (--n)
        {
            // if (arr[arr.size() - 2] > arr[1]) reverse(arr.begin(), arr.end());
            if(arr.back()<arr[0])reverse(arr.begin(),arr.end());
            vector<int> temp;
            for (int i = 1; i < arr.size(); i++)
            {
                temp.push_back(arr[i] - arr[i - 1]);
            }
            
            int res = accumulate(temp.begin(), temp.end(), 0LL);
            ans = max(ans, res);
            arr = temp;
        }
        
        cout << ans << endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() 
{
    int t;cin>>t;
    while(t--)
    {
        int n;cin>>n;
        vector<int>arr(n);
        for(int i=0;i<n;i++)cin>>arr[i];
        int ans=accumulate(arr.begin(),arr.end(),0);
        while(--n)
        {
            if(arr[arr.size()-2]>arr[1])reverse(arr.begin(),arr.end());
            vector<int>temp;
            for(int i=1;i<arr.size();i++)
            {
                temp.push_back(arr[i]-arr[i-1]);
            }
            int res=accumulate(temp.begin(),temp.end(),0);
            ans=max(ans,res);
            arr=temp;
        }
        cout<<ans<<endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() 
{
    int t;cin>>t;
    while(t--)
    {
        int n;cin>>n;
        vector<int>arr(n);
        for(int i=0;i<n;i++)cin>>arr[i];
        int ans=accumulate(arr.begin(),arr.end(),0);
        while(--n)
        {
            if(arr[arr.size()-2]>arr[1])reverse(arr.begin(),arr.end());
            vector<int>temp;
            for(int i=1;i<arr.size();i++)
            {
                temp.push_back(arr[i]-arr[i-1]);
            }
            int res=accumulate(temp.begin(),temp.end(),0);
            ans=max(ans,res);
            arr=temp;
        }
        cout<<ans<<endl;
    }
}


Submission (verdict: Wrong answer on test 6):
#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> arr(n);
        for (int i = 0; i < n; i++) cin >> arr[i];
        
        int ans = accumulate(arr.begin(), arr.end(), 0LL);
        
        while (--n)
        {
            if (arr[arr.size() - 2] > arr[1]) reverse(arr.begin(), arr.end());
            vector<int> temp;
            for (int i = 1; i < arr.size(); i++)
            {
                temp.push_back(arr[i] - arr[i - 1]);
            }
            
            int res = accumulate(temp.begin(), temp.end(), 0LL);
            ans = max(ans, res);
            arr = temp;
        }
        
        cout << ans << endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+10;
int a[N];
void solve(){
	int n,l,r,ans(0);
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=r-l+1;i++)ans+=a[i];
	cout<<ans<<endl;
}
signed main(){	
	int T;
	cin>>T;
	while(T--)solve(); 
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+10;
int a[N];
void solve(){
	int n,l,r,ans(0);
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=r-l+1;i++)ans+=a[i];
	if(l==r&&n>1){
		if(a[l]==a[1]){
			cout<<a[2]<<endl;
			return ;
		}
	}
	cout<<ans<<endl;
}
signed main(){	
	int T;
	cin>>T;
	while(T--)solve(); 
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+10;
int a[N];
void solve(){
	int n,l,r,ans(0);
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=r-l+1;i++)ans+=a[i];
	if(l==r&&n>1){
		if(a[l]==a[1]){
			cout<<a[2]<<endl;
			return ;
		}
	}
	cout<<ans<<endl;
}
signed main(){	
	int T;
	cin>>T;
	while(T--)solve(); 
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+10;
int a[N],b[N];
void solve(){
	int n,l,r,ans(0);
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a+1,a+l+1);
	sort(b+l,b+n+1);
	int sum1(0),sum2(0);
	for(int i=1;i<=r-l+1;i++)sum1+=a[i];
	
	for(int i=l;i<=r;i++)sum2+=b[i];
	cout<<min(sum1,sum2)<<endl;
}
signed main(){	
	int T;
	cin>>T;
	while(T--)solve(); 
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+10;
int a[N],b[N];
void solve(){
	int n,l,r,ans(0);
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a+1,a+l+1);
	sort(b+l,b+n+1);
	int sum1(0),sum2(0);
	for(int i=1;i<=r-l+1;i++)sum1+=a[i];
	
	for(int i=l;i<=r;i++)sum2+=b[i];
	cout<<min(sum1,sum2)<<endl;
}
signed main(){	
	int T;
	cin>>T;
	while(T--)solve(); 
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+10;
int a[N],b[N];
void solve(){
	int n,l,r,ans(0);
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a+1,a+r+1);
	sort(b+l,b+n+1);
	int sum1(0),sum2(0);
	for(int i=1;i<=r-l+1;i++)sum1+=a[i];
	
	for(int i=l;i<=r;i++)sum2+=b[i];
	cout<<min(sum1,sum2)<<endl;
}
signed main(){	
	int T;
	cin>>T;
	while(T--)solve(); 
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+10;
int a[N];
void solve(){
	int n,l,r,ans(0);
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=r-l+1;i++)ans+=a[i];
	cout<<ans<<endl;
}
signed main(){	
	int T;
	cin>>T;
	while(T--)solve(); 
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;typedef long double ld;typedef pair<int,int> pii;
#define F first
#define S second
#define PB push_back
#define MP make_pair
const ll mod = 1e9+7, N = 2e6+7, M = 2e6+7, INF = INT_MAX/10;
ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}




void solve() {
	int n,m;
    cin >> n >> m;
    map<int,int>a,b;
    for(int i=0,x;i<n;i++)
        cin >> x,a[x]++;
    for(int j=0,x;j<m;j++)
        cin >> x,b[x]++;
    for(auto &pp:b) {
        int times = pp.second;
        while (times--) {
            int num = pp.first;
            while(a[num]==0) {
                if (num%2==0) {
                    if (a[num/2]>0) {
                        a[num/2]--;
                        num/=2;
                    } else {
                        cout << "NO\n";
                        return;
                    }
                } else {
                    int t1 = (num-1)/2;
                    int t2 = t1+1;
                    if (a[t1]>0) {
                        a[t1]--;
                        num-=t1;
                    } else if (a[t2]>0) {
                        a[t2]--;
                        num-=t2;
                    } else {
                        cout << "NO\n";
                        return;
                    }
                }
            }
            a[num]--;
        }
    }
    int remaining = 0;
    for(auto &pp:a)
        remaining+=pp.second;
    if (remaining>0)
        cout << "NO\n";
    else
        cout << "YES\n";
}




signed main() {
    fast;
    int t = 1;
    cin >> t;
    while(t--){
    	solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>

using namespace std;

int t, n, a, b;

int main() {
	ios_base::sync_with_stdio(0); 
	
	cin >> t;
	for (; t >= 0; --t) {
		n = a = b = 0;
		cin >> n;
		cin >> a;
		--n;
		for (; n >= 0; --n) {
			cin >> b;
			if (a > b) goto NO;
			a = b - a;
		}
		
		cout << "YES" <<"\n";
		continue;
		NO:
			cout << "NO" << "\n";
	}
	return 0;
}


Submission (verdict: Accepted):
#include<iostream>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0); 
	int t;
	cin >> t;
	for (; t > 0; --t) {
		int n, a, b;
		cin >> n;
		cin >> a;
		--n;
		for (; n > 0; --n) {
			cin >> b;
			if (a > b) {
				--n;
				while (n > 0) {
					cin >> b;
					--n;
				};
				goto NO;	
			};
			a = b - a;
		}
		
		cout << "YES" <<"\n";
		continue;
		NO:
			cout << "NO" << "\n";
	}
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<iostream>

using namespace std;

int t, n, a, b;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> t;
	for (; t > 0; --t) {
		cin >> n;
		cin >> a;
		--n;
		for (; n > 0; --n) {
			cin >> b;
			if (a > b) goto NO;
			
			a = b - a;
		}
		
		cout << "YES";
		continue;
		NO:
			cout << "NO" << "\n";
	}
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>

using namespace std;

int t, n, a, b;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> t;
	for (; t > 0; --t) {
		cin >> n;
		cin >> a;
		--n;
		for (; n > 0; --n) {
			cin >> b;
			if (a > b) goto NO;
			
			a = b - a;
		}
		
		cout << "YES";
		continue;
		NO:
			cout << "NO" << "\n";
	}
	return 0;
}


Submission (verdict: Wrong answer on test 1):
#include<iostream>

using namespace std;

int t, n, a, b;

int main() {
	ios_base::sync_with_stdio(0); 
	
	cin >> t;
	for (; t >= 0; --t) {
		n = a = b = 0;
		cin >> n;
		cin >> a;
		--n;
		for (; n >= 0; --n) {
			cin >> b;
			if (a > b) goto NO;
			a = b - a;
		}
		
		cout << "YES" <<"\n";
		continue;
		NO:
			cout << "NO" << "\n";
	}
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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



using namespace std;



#define f first

#define s second

#define pb push_back

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

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

#define mp make_pair

typedef long long ll;

typedef pair<int, int> ii;

typedef vector<int> vi;

typedef vector<ii> vii;

const int MAX = 1e5 + 5;

const int MOD = 1e9 + 7;

const int INF = 1e9;

const ll LLINF = 1e18;

const double EPS = 1e-9;



ll n, m, k, t;

string s1, s2;

vi v;

int gcd(int a, int b) { return b == 0? a: gcd(b, a % b); }





int main() {

    ios::sync_with_stdio(false); cin.tie(NULL);



    int t; cin >> t;

    while(t--) {

      cin >> n;

      vi a(n);

      for (int& c: a) cin >> c;

      // v.resize(n);

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

        if (a[i] > a[i + 1]) {

          if (i == 0) {

            cout << "NO";

            goto next;

          } else {

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

            a[i] -= m;

            a[i - 1] -= m;

            if (a[i] > a[i + 1] || (i - 1 > 0 && a[i - 1] > a[i])) {

              cout << "NO";

              goto next;

            }

          }

        }

      }

      cout << "YES";

      next:;

      cout << "\n";

    }



    return 0;

}

Submission (verdict: Accepted):
#include <iostream>

#include <vector>

using namespace std;



int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    

    int t; 

    cin >> t;

    while(t--){

        int n; 

        cin >> n;

        vector<long long> a(n);

        for(auto &x : a) {

            cin >> x;

        }

        

        bool possible = true;

        // Process from left to right.

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

            // if current element is greater than the next one, we cannot fix this inversion.

            if(a[i] > a[i+1]){

                possible = false;

                break;

            }

            // otherwise, we can use the allowed operation on (a[i], a[i+1])

            // operation: subtract a[i] (which is the min) from both:

            a[i+1] -= a[i];

            a[i] = 0; // not really needed since we never use a[i] again, but kept for clarity.

        }

        cout << (possible ? "YES" : "NO") << "\n";

    }

    

    return 0;

}