ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include <bits/stdc++.h>



using namespace std;



#define endl "\n"

#define int long long



void s1() {

    int n; cin >> n;

    vector<int> a(n);



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

        cin >> a[i];

    }



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

        cout << "NO" << endl;

        return;

    }



    bool flag = true;

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

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

            flag = false;

            break;

        }

    }



    if (flag) {

        cout << "YES" << endl;

        return;

    }



    int sdd = 0, dup = a[0];

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

        if (a[i] != dup) {

            sdd = i - 1;

            break;

        }

    }



    // if (sdd != 0 && a[sdd] > a[sdd + 1]) {

    //     sdd++;

    // }



    // cerr << sdd << endl;



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

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

            // cout << i << endl;

            cout << "NO" << endl;

            return;

        }



        int temp = min(a[i], a[i + 1]);

        a[i] -= temp;

        a[i + 1] -= temp;

        // cout << a[i] << " " << a[i + 1] << endl;

    }



    cout << "YES" << endl;

    return;

}



signed main() {

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t; cin >> t;

    while (t--) {

        s1();

    }



    // s1();



    return 0;

}

Code 2:
#include <bits/stdc++.h>



using namespace std;



#define endl "\n"

#define int long long



void s1() {

    int n; cin >> n;

    vector<int> a(n);



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

        cin >> a[i];

    }



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

        cout << "NO" << endl;

        return;

    }



    bool flag = true;

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

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

            flag = false;

            break;

        }

    }



    if (flag) {

        cout << "YES" << endl;

        return;

    }



    int sdd = 0, dup = a[0];

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

        if (a[i] != dup) {

            sdd = i - 1;

            break;

        }

    }



    if (sdd > 0 && sdd % 2 == 1) sdd--;

    

    // if (sdd != 0 && a[sdd] > a[sdd + 1]) {

    //     sdd++;

    // }



    // cerr << sdd << endl;



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

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

            // cout << i << endl;

            cout << "NO" << endl;

            return;

        }



        int temp = min(a[i], a[i + 1]);

        a[i] -= temp;

        a[i + 1] -= temp;

        // cout << a[i] << " " << a[i + 1] << endl;

    }



    cout << "YES" << endl;

    return;

}



signed main() {

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t; cin >> t;

    while (t--) {

        s1();

    }



    // s1();



    return 0;

}

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++20 

Code 1:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll int
#define lli long long int
#define vi vector<int>
#define vll vector<long long>
#define rev(all) reverse(v.begin(),v.end())
#define pb push_back

void solve()
{
    ll n;
    cin >> n;
    vll v(n);
    for(int i = 0; i<n; i++) cin >> v[i];

    ll f = 0,c = 0;
    for(int i = n-1; i>0; i--)
    {
        if(v[i] < v[i-1] && v[i-1] - v[i] == 1)
        {

        }
        else
        {
            c = 1;
            break;
        }
    }
    
    if(c == 0)
    {
        cout << "NO\n";
        return;
    }
    for(int i = 0; i<n-1; i++)
    {
        if(v[i] == v[i+1])
        {
            if(v[i+2] < v[i])
            {
                f = 1;
                break;
            }
        }
    }
    if(f) cout << "NO\n";
    else cout << "YES\n";
}
int32_t main()
{
    ll t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll int
#define lli long long int
#define vi vector<int>
#define vll vector<long long>
#define rev(all) reverse(v.begin(),v.end())
#define pb push_back

void solve()
{
    ll n;
    cin >> n;
    vll ve(n);
    for (ll &i : ve) cin >> i;
    ll j = 0;
    for (ll i = 1; i < n; i++) {
        if (ve[i-1] > ve[i]) j = i;
    }
    if (j == 0) { 
        cout << "YES\n";
        return;
    }
    auto fop = [&](ll i) {
        ll minN = min(ve[i], ve[i+1]);
        ve[i] -= minN;
        ve[i+1] -= minN;
    };
    for (ll i = 0; i < j; i++) {
        fop(i);
    }
    cout << (is_sorted(ve.begin(), ve.end()) ? "YES" : "NO") << '\n';
}
int32_t main()
{
    ll t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
}

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include<bits/stdc++.h>

#define ll long long

using namespace std;



void solve(){

int n;

cin>>n;



vector<int>temp(n);

for(int i=0;i<n;i++) cin>>temp[i];



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

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

cout<<"NO"<<endl;

return;

}

}



for(int i=n-1;i>0;i-=2){

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

cout<<"NO"<<endl;

return;

}

}



cout<<"YES"<<endl;

return;

}



int main(){

int t;

cin >> t;



while(t--)

solve();



return 0;

}

Code 2:
#include<bits/stdc++.h>

#define ll long long

using namespace std;



void solve(){

int n;

cin>>n;



vector<int>temp(n);

for(int i=0;i<n;i++) cin>>temp[i];



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

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

if(temp[i+1]<0){

cout<<"NO"<<endl;

return;

}

}



cout<<"YES"<<endl;

return;

}



int main(){

int t;

cin >> t;



while(t--)

solve();



return 0;

}

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++20 

Code 1:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define beoli ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int t,n;int a[1000069];int x;
int main(){
	beoli
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		for(int i=0;i<n;i++){
			int temp=a[i];
			a[i]-=min(temp,a[i+1]);
			a[i+1]-=min(temp,a[i+1]);
		}
		for(int i=0;i<n-1;i++){
			if(a[i]>0){
				cout<<"NO"<<endl;
				break;
			}
			if(i==n-2) cout<<"YES"<<endl;
		}
	}
}


Code 2:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define beoli ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int t,n;int a[1000069];int x;
int main(){
	beoli
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		for(int i=1;i<n;i++){
			if(a[i]>a[i-1]){
				cout<<"YES"<<endl;
				break;
			}else if(a[i]<a[i-1]){
				cout<<"NO"<<endl;
				break;
			}
		}
	}
}


Answer: 1
Problem: 2060D - Subtract Min Sort
Language: c++23 

Code 1:
#include<bits/stdc++.h>

using namespace std;

using ll = long long;



int main(){

    int t; cin >> t;

    while(t--){

        int n; cin >> n;

        ll a[n];

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

            cin >> a[i];

        }

        ll k = a[1] - a[0]; 

        ll sum=0;

        if(k < 0) cout << "NO" << endl;

        else{

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

                if(a[i] >= k){

                    sum += 1;

                    k = a[i] - k;

                }

        }

            if(sum == n-2){

                cout << "YES" << endl;

        }

            else cout << "NO" << endl; 

        }



      

    }

}

Code 2:
#include<bits/stdc++.h>

using namespace std;

using ll = long long;



int main(){

    int t; cin >> t;

    while(t--){

        int n; cin >> n;

        ll a[n];

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

            cin >> a[i];

        }

        ll k = a[1] - a[0]; 

        ll sum=0;

        if(k < 0) cout << "NO" << endl;

        else{

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

                if(a[i] > k){

                    sum += 1;

                    k = a[i] - k;

                }

        }

            if(sum == n-2){

                cout << "YES" << endl;

        }

            else cout << "NO" << endl; 

        }



      

    }

}

Answer: 1
Problem: 2060D - Subtract Min Sort
Language: c++20 

Code 1:
#include<bits/stdc++.h>

using namespace std;

void solve(){

	int n,t=0;

	cin>>n;

	int a[n];

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

		cin>>a[i];

	}

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

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

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

			t=1;

			break;

		}

		a[i]-=mi;

		a[i+1]-=mi;

	}

	if (t==1){

		cout<<"NO"<<endl;

	}

	if (t==0){

		cout<<"YES"<<endl;

	}

}

int main(){

	int T;

	cin>>T;

	while (T--){

		solve();

	}

	return 0;

}

Code 2:
#include<bits/stdc++.h>

using namespace std;

void solve(){

	int n,t=0;

	cin>>n;

	int a[n];

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

		cin>>a[i];

	}

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

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

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

			t=1;

			break;

		}

		if (a[i+2]<=a[i+1]){

			a[i]-=mi;

			a[i+1]-=mi;

		}

	}

	if (t==1){

		cout<<"NO"<<endl;

	}

	if (t==0){

		cout<<"YES"<<endl;

	}

}

int main(){

	int T;

	cin>>T;

	while (T--){

		solve();

	}

	return 0;

}

Answer: 1
Problem: 2060D - Subtract Min Sort
Language: python

Code 1:
t = int(input())
for i in range(t):
    n = int(input())
    nums = list(map(int, input().split()))
    left = 0
    right = 2
    check = True
    while right < n:
        if nums[left] > nums[left+1]:
            check = False
            break
        elif nums[right] < nums[left+1]:
            nums[left+1] -= nums[left]
            nums[left] = 0
            left += 1
            right += 1
        else:
            left += 1
            right += 1

    if check:
        print('Yes')
    else:
        print('No')

        






Code 2:
t = int(input())
for i in range(t):
    n = int(input())
    nums = list(map(int, input().split()))
    left = 0
    check = True
    while left < n-1:
        if nums[left] > nums[left+1]:
            check = False
            break
        else:
            nums[left+1] -= nums[left]
            nums[left] = 0
            left += 1


    if check:
        print('Yes')
    else:
        print('No')

        






Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++23 

Code 1:
#include<iostream>

#include<vector>

#include<string>

using namespace std;



int main(){

    int t; cin >> t;



    while(t--){

        int n; cin >> n;

        int arr[n+1]; arr[0]=0;

        string answer = "YES";

        for(int i = 1; i <= n; i++) cin >> arr[i];

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

            if(arr[i] < abs(arr[i-1] - arr[i-2])) {

                answer = "NO"; break;

            } else arr[i-1] = abs(arr[i-1] - arr[i-2]);

        }



        cout << answer << "\n";





    }

}

Code 2:
#include<iostream>

#include<vector>

#include<string>

using namespace std;



int main(){

    int t; cin >> t;



    while(t--){

        int n; cin >> n;

        int arr[n+1]; arr[0]=0;

        string answer = "YES";

        for(int i = 1; i <= n; i++) cin >> arr[i];

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

            if(arr[i] < abs(arr[i-1] - arr[i-2])) {

                answer = "NO"; break;

            }

        }



        cout << answer << "\n";





    }

}

Answer: 1
Problem: 2060D - Subtract Min Sort
Language: c++20 

Code 1:
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    int n;
    cin>>n;
    vector<int>a(n+1);
    for(int i=1;i<=n;i++)\
    {
        cin>>a[i];
    }
    for(int i=1;i<n;i++)
    {
        int k=min(a[i],a[i+1]);
        a[i]=a[i]-k;
        a[i+1]=a[i+1]-k;
        if(a[i]>0){
            cout<<"NO"<<endl;
            return;
        }
    }
    if(a[n]>=0)cout<<"YES"<<endl;
     else cout<<"NO"<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    int n;
    cin>>n;
    vector<int>a(n+1);
    for(int i=1;i<=n;i++)\
    {
        cin>>a[i];
    }
    for(int i=1;i<n;i++)
    {
        int k=min(a[i],a[i+1]);
        a[i]=a[i]-k;
        a[i+1]=a[i+1]-k;
        if(a[i]>0){
            cout<<"NO"<<endl;
            return;
        }
    }
    if(a[n]>0)cout<<"YES"<<endl;
     else cout<<"NO"<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Answer: 1
Problem: 2060D - Subtract Min Sort
Language: c++23 

Code 1:
#include<bits/stdc++.h>

using namespace std;

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

#define allr(a) a.rbegin(),a.rend()

#define ll long long

const ll mod = 1000000007;



void solve()

{

    int n;

    cin>>n;

    vector<int> v(n);

    for(auto &it:v) cin>>it;



    if(v[0] >= v[1]){

        cout << "NO" << endl;

        return ;

    }



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

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

        v[i]-=sub;

        v[i+1]-=sub;

    }



    int f = 1;

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

        if(v[i] > v[i+1]) f = 0;

    }

    if(f) cout << "YES" << endl;

    else cout << "NO" << endl;     

}



int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    

    int t = 1;

    cin>>t;

    while(t--){

        solve();

    }

    return 0;

}

Code 2:
#include<bits/stdc++.h>

using namespace std;

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

#define allr(a) a.rbegin(),a.rend()

#define ll long long

const ll mod = 1000000007;



void solve()

{

    int n;

    cin>>n;

    vector<int> v(n);

    for(auto &it:v) cin>>it;



    if(v[0] > v[1]){

        cout << "NO" << endl;

        return ;

    }



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

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

        v[i]-=sub;

        v[i+1]-=sub;

    }



    int f = 1;

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

        if(v[i] > v[i+1]) f = 0;

    }

    if(f) cout << "YES" << endl;

    else cout << "NO" << endl;     

}



int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    

    int t = 1;

    cin>>t;

    while(t--){

        solve();

    }

    return 0;

}

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include <bits/stdc++.h>

using namespace std;



void solve()

{

    int n; cin >> n;

    vector<int> a(n);

    for(int i = 0 ; i < n; i++) cin >> a[i];

    for(int i = n-2; i >= 1; i--) {

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

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

            a[i] -= jar;

            if(a[i-1] - jar < 0) {

                cout << "no\n"; return;

            } 

            a[i-1] -= jar;

            i--;

        }

    }

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

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

            cout << "no\n"; return;

        }

    }

    cout << "yes\n";

}



int main()

{

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

    int t; cin >> t;

    while(t--) solve();

    return 0;

}

Code 2:
#include <bits/stdc++.h>

using namespace std;



void solve()

{

    int n; cin >> n;

    vector<int> a(n);

    for(int i = 0 ; i < n; i++) cin >> a[i];

    for(int i = n-2; i >= 1; i--) {

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

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

            a[i] -= jar;

            if(a[i-1] - jar < 0) {

                cout << "no\n"; return;

            } 

            a[i-1] -= jar;

        }

    }

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

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

            cout << "no\n"; return;

        }

    }

    cout << "yes\n";

}



int main()

{

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

    int t; cin >> t;

    while(t--) solve();

    return 0;

}

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++23 

Code 1:
#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define vi vector<int>

#define vll vector<long long>



int main()

{

ios_base::sync_with_stdio(false);

cin.tie(nullptr);

cout.tie(nullptr);



int t;

cin>>t;

while(t--)

{

int n,diff;

string ans="YES";

cin>>n;

int arr[n];

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

{

cin>>arr[i];

}



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

{

diff=min(arr[i],arr[i+1]);

arr[i] = arr[i]-diff;

arr[i+1]= arr[i+1] - diff;



if ((arr[i]>0) || (arr[i+1] == 0))

{

ans="NO";

break;

}

}



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

//  {

//     cout<<arr[i]<<' ';

//  }

//  cout<<endl;

cout<<ans<<endl;



}



return 0;

}

Code 2:
#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define vi vector<int>

#define vll vector<long long>



int main()

{

ios_base::sync_with_stdio(false);

cin.tie(nullptr);

cout.tie(nullptr);



int t;

cin>>t;

while(t--)

{

int n,diff;

string ans="YES";

cin>>n;

int arr[n];

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

{

cin>>arr[i];

}



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

{

diff=min(arr[i],arr[i+1]);

arr[i] = arr[i]-diff;

arr[i+1]= arr[i+1] - diff;



if ((arr[i]>0) && (arr[i+1] == 0))

{

ans="NO";

break;

}

}



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

//  {

//     cout<<arr[i]<<' ';

//  }

//  cout<<endl;

cout<<ans<<endl;



}



return 0;

}

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include <bits/stdc++.h>

using namespace std;



int main() {

int t;

cin >> t;

while (t--) {

int n;

cin>>n;

vector<int>v(n);

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

cin>>v[i];

}

bool valid = true;

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

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

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

v[i] = 0;

}else {

valid = false;

break;

}

}

if (valid) {

cout<<"YES"<<endl;

}else {

cout<<"NO"<<endl;

}

}

return 0;

}



Code 2:
#include <bits/stdc++.h>

using namespace std;



int main() {

int t;

cin >> t;

while (t--) {

int n;

cin>>n;

vector<int>v(n);

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

cin>>v[i];

}

bool valid = true;

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

if (v[i]<=v[i+1]) {

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

v[i] = 0;

}else {

valid = false;

break;

}

}

if (valid) {

cout<<"YES"<<endl;

}else {

cout<<"NO"<<endl;

}

}

return 0;

}



Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;
ll n,a[N];
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int flag=0;
    for(int i=1;i<n;i++){
        ll t=min(a[i],a[i+1]);
        a[i]-=t,a[i+1]-=t;
        if(a[i+1]==0){
            cout<<"NO"<<endl;
            return ;
        }
    }
    cout<<"YES"<<endl;
    return ;
}

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

Code 2:
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;
ll n,a[N];
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n;i++){
        if(a[i]>a[i+1]){
            cout<<"NO"<<endl;
            return ;
        }
        ll t=min(a[i],a[i+1]);
        a[i]-=t,a[i+1]-=t;
        
    }
    cout<<"YES"<<endl;
    return ;
}

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

Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
const int mod=1e9+7;
int dx[8]={-1,0,0,1,-1,-1,1,1};
int dy[8]={0,-1,1,0,-1,1,-1,1};

void nishant2526(){
  int n;
  cin>>n;
  vector<int> arr(n);
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  for(int i=0;i<n;i+=2){
    if((arr[i+1]-arr[i])<1){
       cout<<"NO"<<endl;
       return;
    }
  }
  cout<<"YES"<<endl;
    
   
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  int tt;
  cin >> tt;
  while (tt--)
  {
    nishant2526();
  }

  return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
const int mod=1e9+7;
int dx[8]={-1,0,0,1,-1,-1,1,1};
int dy[8]={0,-1,1,0,-1,1,-1,1};

void nishant2526(){
  int n;
  cin>>n;
  vector<int> arr(n);
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  for(int i=1;i<n;i++){
    if(arr[i-1]>arr[i]){
      cout<<"NO"<<endl;
      return;
    }
    else{
      arr[i]-=arr[i-1];
      arr[i-1]=0;
    }
  }
  cout<<"YES"<<endl;
    
   
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  int tt;
  cin >> tt;
  while (tt--)
  {
    nishant2526();
  }

  return 0;
}


Answer: 2
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i += 1)
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    label:
    while(t--)
    {
        int n;
        cin >> n;
        vector<int> arr(n);
        loop(i,0,n) cin >> arr[i];
        int dif = arr[1]-arr[0];
        if(dif < 0)
            {
                cout << "NO" << endl;
                goto label;
            }
        loop(i,2,n)
        {
            dif = arr[i]-dif;
            if(dif < 0)
            {
                cout << "NO" << endl;
                goto label;
            }
        }
        cout << "YES"<< endl;
    }
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i += 1)
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    label:
    while(t--)
    {
        int n;
        cin >> n;
        vector<int> arr(n);
        loop(i,0,n) cin >> arr[i];
        int dif = arr[1]-arr[0];
        loop(i,2,n)
        {
            dif = arr[i]-dif;
            if(dif < 0)
            {
                cout << "NO" << endl;
                goto label;
            }
        }
        cout << "YES"<< endl;
    }
}

Answer: 1
Problem: 2060D - Subtract Min Sort
Language: c++17 

Code 1:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a;
        int flag=0;
        for(int i=0;i<n;++i){
            int x;
            cin >> x;
            a.push_back(x);
        }
        if(a[0]>a[1]) {
            cout<<"NO"<<endl;
            flag=1;
        }
        else{
            for(int i=0;i<n-1;++i){
                int x = min(a[i],a[i+1]);
                a[i]-=x;
                a[i+1]-=x;  
                if(a[i]>a[i+1]){
                    cout<<"NO"<<endl;
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0)cout<<"YES"<<endl;
    }
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a;
        int flag=0;
        for(int i=0;i<n;++i){
            int x;
            cin >> x;
            a.push_back(x);
        }
        if(a[0]>a[1]) {
            cout<<"NO"<<endl;
            flag=1;
        }
        else{
            for(int i=1;i<n-1;++i){
                if(a[i]>a[i+1]){
                    int x = min(a[i],a[i-1]);
                    if((a[i]-x)>a[i+1]){
                        cout<<"NO"<<endl;
                        flag=1;
                        break;
                    }
                    else{
                        a[i]-=x;
                        a[i-1]-=x;
                    }
                }
            }
        }
        if(flag==0)cout<<"YES"<<endl;
    }
}

Answer: 1