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

Code 1:
#include <bits/stdc++.h>
#define al(c) c.begin(),c.end()
#define sz(c) ll(c.size())
#define ll long long
#define tr(a,it) for(auto it=a.begin(); it!=a.end(); it++)
#define present(c, x)(c.find(x) != c.end())
#define cpresent(c, x)(find(al(c), x) != c.end())
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vpll>
#define pll pair<ll,ll>
#define inf 1e18
#define MOD 1000000007
#define moda 998244353
#define MAXN 1
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define revloop(i,s,e) for(ll i=s; i>=e; i--)
#define newl cout << endl

using namespace std;

/////////////////////////////////////////////////////////////////////////////////////

// DEBUG GG

#define debug(x)     \
  cout << #x << " "; \
  _print(x);         \
  cout << endl;

void _print(int x) {
	cout << x;
}

void _print(char x) {
	cout << x;
}

void _print(string s) {
	cout << s;
}

void _print(ll x) {
	cout << x;
}

void _print(bool a) {
	cout << a;
}

template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
	cout << "{";
	_print(p.first);
	cout << ",";
	_print(p.second);
	cout << "}";
}
template <class T>
void _print(vector<T> v) {
	cout << "[ ";
	for (T i : v) {
		_print(i);
		cout << " ";
	}
	cout << "]";
}

template <class T>
void _print(set<T> st) {
	cout << "[ ";
	for (T i : st) {
		_print(i);
		cout << " ";
	}
	cout << "]";
}

template <class T>
void _print(multiset<T> v) {
	cout << "[ ";
	for (T i : v) {
		_print(i);
		cout << " ";
	}
	cout << "]";
}

template <class T, class V>
void _print(map<T, V> v) {
	cout << "[ ";
	for (auto i : v) {
		_print(i);
		cout << " ";
	}
	cout << "]";
}

/////////////////////////////////////////////////////////////////////////////////////

ll cyclen(ll i, ll n) {
	return (i % n + (i % n == 0) * n);
}

ll power(ll a, ll b, ll mod) {
	ll p = 1;
	while(b > 0) {
		if(b & 1)
			p = (p * a) % mod;
		a = (a * a) % mod;
		b = b >> 1;
	}
	return p;
}

ll gcd(ll a, ll b) {
	if(!(a % b)) return b;
	return gcd(b, a % b);
}

ll inv_mod(ll n, ll mod) {
	ll pow = mod - 2;
	return power(n, pow, mod);
}

ll MSB(ll n)
{
	ll b = 0;
	while (n) {
		b++;
		n /= 2;
	}
	return b;
}

void solve(int tc) {
    ll n;
    cin>>n;
    vll a(n);
    loop(i,0,n){
        cin>>a[i];
    }
    loop(i,0,n-1){
        if(a[i] < a[i+1]){
            a[i+1] = a[i+1] - a[i];
            a[i] = 0;
        }
    }
    loop(i,0,n-1){
        if(a[i] > a[i+1]){
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;
    
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	cin >> t;
	int tc = 0;
	while (t--) {
		tc++;
		solve(tc);
	}

	return 0;
}


Code 2:
#include <bits/stdc++.h>
#define al(c) c.begin(),c.end()
#define sz(c) ll(c.size())
#define ll long long
#define tr(a,it) for(auto it=a.begin(); it!=a.end(); it++)
#define present(c, x)(c.find(x) != c.end())
#define cpresent(c, x)(find(al(c), x) != c.end())
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vpll>
#define pll pair<ll,ll>
#define inf 1e18
#define MOD 1000000007
#define moda 998244353
#define MAXN 1
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define revloop(i,s,e) for(ll i=s; i>=e; i--)
#define newl cout << endl

using namespace std;

/////////////////////////////////////////////////////////////////////////////////////

// DEBUG GG

#define debug(x)     \
  cout << #x << " "; \
  _print(x);         \
  cout << endl;

void _print(int x) {
	cout << x;
}

void _print(char x) {
	cout << x;
}

void _print(string s) {
	cout << s;
}

void _print(ll x) {
	cout << x;
}

void _print(bool a) {
	cout << a;
}

template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
	cout << "{";
	_print(p.first);
	cout << ",";
	_print(p.second);
	cout << "}";
}
template <class T>
void _print(vector<T> v) {
	cout << "[ ";
	for (T i : v) {
		_print(i);
		cout << " ";
	}
	cout << "]";
}

template <class T>
void _print(set<T> st) {
	cout << "[ ";
	for (T i : st) {
		_print(i);
		cout << " ";
	}
	cout << "]";
}

template <class T>
void _print(multiset<T> v) {
	cout << "[ ";
	for (T i : v) {
		_print(i);
		cout << " ";
	}
	cout << "]";
}

template <class T, class V>
void _print(map<T, V> v) {
	cout << "[ ";
	for (auto i : v) {
		_print(i);
		cout << " ";
	}
	cout << "]";
}

/////////////////////////////////////////////////////////////////////////////////////

ll cyclen(ll i, ll n) {
	return (i % n + (i % n == 0) * n);
}

ll power(ll a, ll b, ll mod) {
	ll p = 1;
	while(b > 0) {
		if(b & 1)
			p = (p * a) % mod;
		a = (a * a) % mod;
		b = b >> 1;
	}
	return p;
}

ll gcd(ll a, ll b) {
	if(!(a % b)) return b;
	return gcd(b, a % b);
}

ll inv_mod(ll n, ll mod) {
	ll pow = mod - 2;
	return power(n, pow, mod);
}

ll MSB(ll n)
{
	ll b = 0;
	while (n) {
		b++;
		n /= 2;
	}
	return b;
}

void solve(int tc) {
    ll n;
    cin>>n;
    vll a(n);
    loop(i,0,n){
        cin>>a[i];
    }
    loop(i,0,n-1){
        if(a[i] < a[i+1]){
            a[i+1] = a[i+1] - a[i];
            a[i] = 0;
        }
        else{
            a[i] = a[i] - a[i+1];
            a[i+1] = 0;
        }
    }
    loop(i,0,n-1){
        if(a[i] > a[i+1]){
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;
    
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	cin >> t;
	int tc = 0;
	while (t--) {
		tc++;
		solve(tc);
	}

	return 0;
}


Answer: 2