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 IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define openFiles freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define openFiles2 freopen("teamwork.in", "r", stdin); freopen("teamwork.out", "w", stdout);
#define ll long long
#define endl "\n"
#define uint unsigned int
#define bigint  unsigned long long int
ll maxll=9223372036854775807;
ll mod=1e9+7.;
#define pb push_back
#define rep(i, st, endex) for (ll i = st; i < (ll)endex; ++i)
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define vb vector<bool>
#define vii vector<pair<int, int>>
#define vvii vector<vector<pair<int, int>>>
#define viii vector<tuple<int, int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define tiii tuple<int, int, int>
#define tll tuple<ll, ll, ll>
#define LSOne(S) ((S) & -(S))
#define fi first

///////////////////////////////code/////////////////////////////////////////////////////
const long long MOD = 1e9 + 7; // chose any MOD
long long binpow(long long a, long long b) {
    a %= MOD;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    IOS
    int t;
    cin >> t;
    while (t--) {
       int n;
        cin >> n;
        vector<int> v(n);
        for (int i = 0; i < n; i++)
            cin >> v[i];
        int x=v[1]-v[0];
        int i=2;
        while (v[i]>=x and i<n and x>=0) {
            x=v[i]-x;
            i++;
        }
        if (i==n) cout << "YES" << endl;
        else cout << "NO" << endl;


    }
    return 0;
}


Submission (verdict: Accepted):
//                              بسم الله الرحمان الرحيم

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define openFiles freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define openFiles2 freopen("teamwork.in", "r", stdin); freopen("teamwork.out", "w", stdout);
#define ll long long
#define endl "\n"
#define uint unsigned int
#define bigint  unsigned long long int
ll maxll=9223372036854775807;
ll mod=1e9+7.;
#define pb push_back
#define rep(i, st, endex) for (ll i = st; i < (ll)endex; ++i)
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define vb vector<bool>
#define vii vector<pair<int, int>>
#define vvii vector<vector<pair<int, int>>>
#define viii vector<tuple<int, int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define tiii tuple<int, int, int>
#define tll tuple<ll, ll, ll>
#define LSOne(S) ((S) & -(S))
#define fi first

///////////////////////////////code/////////////////////////////////////////////////////
const long long MOD = 1e9 + 7; // chose any MOD
long long binpow(long long a, long long b) {
    a %= MOD;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    IOS
    int t;
    cin >> t;
    while (t--) {
       int n;
        cin >> n;
        vector<int> v(n);
        for (int i = 0; i < n; i++)
            cin >> v[i];
        if (n==2) {
            if (v[1]>v[0])cout << "YES" << endl;
            else cout << "NO" << endl;
            continue;
        }
        int x=v[1]-v[0];
        int i=2;
        while (  i<n and x>=0 and v[i]>=x) {
            x=v[i]-x;
            i++;
        }
        if (i==n) cout << "YES" << endl;
        else cout << "NO" << endl;


    }
    return 0;
}