Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
//template owner:professor
#include <iostream>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,n) for(long long int  i=0;i<n;i++)
#define vi std::vector<int> 
const long long int MOD=1e9+7;
#define vli std::vector<long long int>
#define si std::set<int> 
#define sli std::set<long long int > 
#define qi std::queue<int > 
#define qli std::queue<long long int >
#define mli std::map<long long int ,long long int> 
#define mc std::map<char, long long int> 
#define umli std::unordered_map<long long int,long long int>
#define umc std::unordered_map<char,long long int>
#define gap ' '
#define ff first
#define ss second	
#include<cmath>
#include<bits/stdc++.h>
void solve()
{
//  1 5 6 2 3
//  0 4 6 2 3
//  0 0 2 2 3
 
 // odd size pair should 
int n; 
cin>> n;
 int val =1;
 int a[n];
for(int i = 0; i< n; ++i)
{
    cin>>a[i];
}

for(int i = 1; i< n; ++i)
{

    if(a[i] >=a[i-1]) val ++;
    else {
        val++;
        if(((val &1) ^1) ){
            cout<<"NO"<<endl;
            return;
        }
        if(i !=n-1 && a[i] > a[i+1]) {
            cout<<"NO"<<endl;
            return;
        }
        val =0;
    }
        a[i] -=a[i-1];
}  
for(int i = 1; i< n; ++i) {
    if(a[i] <a[i-1]){ cout<<"NO"<<endl;
            return;}
    
}
cout<<"YES"<<endl;
  
  
}
 
int main() {
         ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
ll t;
cin>>t;
while(t--)
{
solve();
}
 
	// your code goes here
	return 0;
}

Submission (verdict: Wrong answer on test 2):
//template owner:professor
#include <iostream>

using namespace std;
#define ll long long
#define pb push_back
#define rep(i, n) for (long long int i = 0; i < n; i++)
    #define vi std::vector < int >
    const long long int MOD = 1e9 + 7;
#define vli std::vector < long long int >
    #define si std::set < int >
    #define sli std::set < long long int >
    #define qi std::queue < int >
    #define qli std::queue < long long int >
    #define mli std::map < long long int, long long int >
    #define mc std::map < char, long long int >
    #define umli std::unordered_map < long long int, long long int >
    #define umc std::unordered_map < char, long long int >
    #define gap ' '
#define ff first
#define ss second#include<cmath>

#include<bits/stdc++.h>

void solve()
{
    //  1 5 6 2 3
    //  0 4 6 2 3
    //  0 0 2 2 3

    // odd size pair should 
    int n;
    cin >> n;
    int val = 1;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }

    for (int i = 1; i < n; ++i)
    {

        if (a[i] >= a[i - 1]) val++;
        else {
            
            val++;
            if (((val & 1) ^ 1)) {
                cout << "NO" << endl;
                return;
            }
            if (i != n - 1 && a[i] < a[i + 1]) {
                cout << "NO" << endl;
                return;
            }
            val = 0;
        }
        a[i] -= a[i - 1];
    }
    // for (int i = 1; i < n; ++i) {
    //     if (a[i] < a[i - 1]) {
    //         cout << "NO" << endl;
    //         return;
    //     }

    // }
    cout << "YES" << endl;


}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    // your code goes here
    return 0;
}