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

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
template <typename _Tp> bool minimize(_Tp &__a, const _Tp &__b) { if (__a > __b) { __a = __b; return true; } return false; }
template <typename _Tp> bool maximize(_Tp &__a, const _Tp &__b) { if (__a < __b) { __a = __b; return true; } return false; }
#define int long long
#define pb push_back
#define fi first
#define vi vector<int>
#define se second
#define pii pair<int,int>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define allof(a,n) a + 1, a + 1 + n
#define fo(i,a,b) for(int i = a; i <= b; i++)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define file "ship"
#define I ios_base :: sync_with_stdio(0);
#define wish cin.tie(0);
#define have cout.tie(0);
#define tomorrow if(fopen(file".inp","r")) {freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);}
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
const int single_test = 1;
const int base = 31;
namespace memaybeobachlong
{
    void solve()
    {
        int n;
        cin >> n;
        int a[n + 1];
        fo(i, 1, n) cin >> a[i];
        for(int i = n; i >= 1; i--)
            if(a[i] > a[i - 1])
            {
                id = i;
                break;
            }
        if(!id) return cout << "YES\n", void();
        fo(i, 2, id - 1)
        {
            if(a[i - 1] > a[i])
                return cout << "NO\n", void();
            a[i] -= a[i - 1];
        }
        if(a[id - 1] <= a[id] && a[id] - a[id - 1] <= a[id + 1])
            cout << "YES\n";
        else cout << "NO\n";
    }
}
int32_t main()
{
    I wish have tomorrow
    int t = 1;
    if(single_test)
        cin >> t;
    while(t--)
        memaybeobachlong :: solve();
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
template <typename _Tp> bool minimize(_Tp &__a, const _Tp &__b) { if (__a > __b) { __a = __b; return true; } return false; }
template <typename _Tp> bool maximize(_Tp &__a, const _Tp &__b) { if (__a < __b) { __a = __b; return true; } return false; }
#define int long long
#define pb push_back
#define fi first
#define vi vector<int>
#define se second
#define pii pair<int,int>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define allof(a,n) a + 1, a + 1 + n
#define fo(i,a,b) for(int i = a; i <= b; i++)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define file "ship"
#define I ios_base :: sync_with_stdio(0);
#define wish cin.tie(0);
#define have cout.tie(0);
#define tomorrow if(fopen(file".inp","r")) {freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);}
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
const int single_test = 1;
const int base = 31;
namespace memaybeobachlong
{
    void solve()
    {
        int n;
        cin >> n;
        int a[n + 1];
        fo(i, 1, n) cin >> a[i];
        int id = 0;
        for(int i = n; i >= 1; i--)
            if(a[i] > a[i - 1])
            {
                id = i;
                break;
            }
        if(!id) return cout << "YES\n", void();
        fo(i, 2, id - 1)
        {
            if(a[i - 1] > a[i])
                return cout << "NO\n", void();
            a[i] -= a[i - 1];
        }
        if(a[id - 1] <= a[id] && a[id] - a[id - 1] <= a[id + 1])
            cout << "YES\n";
        else cout << "NO\n";
    }
}
int32_t main()
{
    I wish have tomorrow
    int t = 1;
    if(single_test)
        cin >> t;
    while(t--)
        memaybeobachlong :: solve();
}