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;

// Yash Raj 2112047
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second

// Fast Input/Output
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

// Debugging (for personal use during development)
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
template <typename T> void _print(T x) { cerr << x; }
template <typename T, typename V> void _print(pair<T, V> p) { cerr << "{" << p.F << "," << p.S << "}"; }
template <typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

int main() {
    fast_io(); // Ensures fast input/output
    
    int t;
    cin >> t; // Multiple test cases
    while (t--) {
        
        int n;
        cin >> n;
        vector<int> arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }

        int j=0;
        for(int i=0; i<n-1; i++){
            if(arr[i]>arr[i+1]){
                j = i;
            }
        }

        if(j==0){
            cout<<"YES\n";
        }else{
            for(int i=0; i<j; i++){
                int minN = min(arr[i], arr[i+1]);
                arr[i]-=minN;
                arr[i+1]-=minN;
            }
            cout<<(is_sorted(arr.begin(), arr.end())?"YES":"NO")<<'\n';
        }
    }

    return 0;
}

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

// Yash Raj 2112047
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second

// Fast Input/Output
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

// Debugging (for personal use during development)
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
template <typename T> void _print(T x) { cerr << x; }
template <typename T, typename V> void _print(pair<T, V> p) { cerr << "{" << p.F << "," << p.S << "}"; }
template <typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

int main() {
    fast_io(); // Ensures fast input/output
    
    int t;
    cin >> t; // Multiple test cases
    while (t--) {
        
        int n;
        cin >> n;
        vector<int> arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }

        int j=0;
        for(int i=0; i<n-1; i++){
            if(arr[i]>arr[i+1]){
                j = i;
            }
        }

        if(j==0){
            cout<<"YES\n";
            continue;
        }
        for(int i=0; i<j; i++){
            int minN = min(arr[i], arr[i+1]);
            arr[i]-=minN;
            arr[i+1]-=minN;
        }
        cout<<(is_sorted(arr.begin(), arr.end())?"YES":"NO")<<'\n';
        
    }

    return 0;
}