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

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define ys                                                                                                                         cout<<"YES"<<endl
#define no                                                                                                                         cout<<"NO"<<endl
#define nl                                                                                                                         cout<<endl
#define fi(i,n)                                                                                                                    for(int i=0;i<n;i++)
#define fj(j,n)                                                                                                                    for(int j=0;j<n;j++)
#define fii(i,n)                                                                                                                   for(int i=1;i<=n;i++)
#define fjj(j,n)                                                                                                                   for(int j=1;j<=n;j++)
#define fir(i,n)                                                                                                                   for(int i=n;i>0;i--)
#define fjr(j,n)                                                                                                                   for(int j=n;j>0;j--)
#define vi                                                                                                                         vector<int>
#define vii                                                                                                                        vector<long long>
#define vs                                                                                                                         vector<string>
#define pi                                                                                                                         pair<int,int>
#define pii                                                                                                                        pair<ll,ll>
#define pb                                                                                                                         push_back
#define pp                                                                                                                         pop_back

void solve(){
                                                                                                                                                                                                                           int n;
                                                                                                                                                                                                                           cin>>n;
                                                                                                                                                                                                                          vi v(n);
                                                                                                                                                                                                                          fi(i,n)cin>>v[i];
                                                                                                                                                                                                                           int c=1;
                                                                                                                                                                                                                           int x=n-1;
                                                                                                                                                                                                                           fi(i,x){
                                                                                                                                                                                                                            if(v[i]<v[i+1])c++;
                                                                                                                                                                                                                           }
                                                                                                                                                                                                                           if(c==n)ys;
                                                                                                                                                                                                                           else if(n==2&&c!=2)no;
                                                                                                                                                                                                                           else {
                                                                                                                                                                                                                            bool tr=true;
                                                                                                                                                                                                                             for(int i=2;i<n;i++){
                                                                                                                                                                                                                              if(v[i-2]>v[i-1]&&v[i-1]>v[i])tr=false;
                                                                                                                                                                                                                             }
                                                                                                                                                                                                                             if(tr)ys;
                                                                                                                                                                                                                             else no;
                                                                                                                                                                                                                           }



}


 int main() {
   ios::sync_with_stdio(false);
   cin.tie(nullptr);
  ll t;
  //t=1;
  cin>>t;
  while(t--){
    solve();
  }
   return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define ys cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define nl cout<<endl
#define fi(i,n) for(int i=0;i<n;i++)
#define fj(j,n) for(int j=0;j<n;j++)
#define fii(i,n) for(int i=1;i<=n;i++)
#define fjj(j,n) for(int j=1;j<=n;j++)
#define fir(i,n) for(int i=n;i>0;i--)
#define fjr(j,n) for(int j=n;j>0;j--)
#define vi vector<int>
#define vii vector<long long>
#define vs vector<string>
#define pi pair<int,int>
#define pii pair<ll,ll>
#define pb push_back
#define pp pop_back

void solve(){
                                                                                                                                                                                               int n;
                                                                                                                                                                                               cin>>n;
                                                                                                                                                                                               vi v(n);
                                                                                                                                                                                               fi(i,n)cin>>v[i];
                                                                                                                                                                                               int c=0;
                                                                                                                                                                                               int i=0;
                                                                                                                                                                                               while(i<n-1){
                                                                                                                                                                                                if(v[i]>v[i+1]){
                                                                                                                                                                                                  c++;
                                                                                                                                                                                                  break;

                                                                                                                                                                                                }
                                                                                                                                                                                                else{
                                                                                                                                                                                                   v[i+1]-=v[i];
                                                                                                                                                                                                   v[i]=0;
                                                                                                                                                                                                                                                                                                                                                                                          }
                                                                                                                                                                                                i++;
                                                                                                                                                                                               }
                                                                                                                                                                                               if(c)no;
                                                                                                                                                                                               else ys;
    



}


 int main() {
   ios::sync_with_stdio(false);
   cin.tie(nullptr);
  ll t;
  //t=1;
  cin>>t;
  while(t--){
    solve();
  }
   return 0;
}