Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace chrono;

// Aliases
using ll = long long;
using ull = unsigned long long;
using ld = long double;

// Constants
constexpr ll INF = 4e18;
constexpr ld EPS = 1e-9;
constexpr ll MOD = 998244353;

// Macros
#define F first
#define S second
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
#define pb push_back
#define MP make_pair
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)

// Modular arithmetic functions
ll inv(ll i) {
    if (i == 1) return 1;
    return (MOD - (MOD / i) * inv(MOD % i) % MOD) % MOD;
}

ll mod_mul(ll a, ll b) {
    return (a % MOD * b % MOD) % MOD;
}

ll mod_add(ll a, ll b) {
    return (a % MOD + b % MOD) % MOD;
}

ll mod_sub(ll a, ll b) {
    return (a % MOD - b % MOD + MOD) % MOD;
}

ll pwr(ll a, ll b) {
    ll res = 1;
    a %= MOD;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

// Fast I/O
istream& operator>>(istream &is, vector<ll> &v) {
    for (auto &x : v) is >> x;
    return is;
}

ostream& operator<<(ostream &os, const vector<ll> &v) {
    for (auto &x : v) os << x << " ";
    return os;
}

// Main logic
void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    for (int i = 0; i < n - 1; i++)
    {
        int mini = min(a[i], a[i + 1]);
        a[i] -= mini;
        a[i + 1] -= mini;
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] > 0)
        {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
    return;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int T;
    cin >> T;

    auto start = high_resolution_clock::now();
    while (T--) {
        solve();
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr << "Time: " << duration.count() / 1000 << " ms" << endl;

    return 0;
}


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

// Aliases
using ll = long long;
using ull = unsigned long long;
using ld = long double;

// Constants
constexpr ll INF = 4e18;
constexpr ld EPS = 1e-9;
constexpr ll MOD = 998244353;

// Macros
#define F first
#define S second
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
#define pb push_back
#define MP make_pair
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)

// Modular arithmetic functions
ll inv(ll i) {
    if (i == 1) return 1;
    return (MOD - (MOD / i) * inv(MOD % i) % MOD) % MOD;
}

ll mod_mul(ll a, ll b) {
    return (a % MOD * b % MOD) % MOD;
}

ll mod_add(ll a, ll b) {
    return (a % MOD + b % MOD) % MOD;
}

ll mod_sub(ll a, ll b) {
    return (a % MOD - b % MOD + MOD) % MOD;
}

ll pwr(ll a, ll b) {
    ll res = 1;
    a %= MOD;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

// Fast I/O
istream& operator>>(istream &is, vector<ll> &v) {
    for (auto &x : v) is >> x;
    return is;
}

ostream& operator<<(ostream &os, const vector<ll> &v) {
    for (auto &x : v) os << x << " ";
    return os;
}

// Main logic
void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n - 1; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        int mini = min(a[i], a[i + 1]);
        a[i] -= mini;
        a[i + 1] -= mini;
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] > 0)
        {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
    return;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int T;
    cin >> T;

    auto start = high_resolution_clock::now();
    while (T--) {
        solve();
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr << "Time: " << duration.count() / 1000 << " ms" << endl;

    return 0;
}