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

Previous submission (verdict: Wrong answer on test 2):
/*

 *  - Dhiraj Yadav

 *  - Progress is slow, but quitting guarantees failure

 *  - Stay consistent, stay disciplined, and success will follow!

 */

 

#include <bits/stdc++.h>

using namespace std;



#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define yy cout << "YES" << endl

#define nn cout << "NO" << endl

#define ll long long

#define v vector<int>

#define inp(v) for (auto &x : v) cin >> x;

#define pb push_back

#define po pop_back

#define f2(v) for (int i = 0; i < (v).size(); i++) cout << (v)[i] << " ";

#define vvi vector<vector<int>>

#define vll vector<long long>

#define mapii map<int, int>

#define mapci map<char, int>

#define SORT(v) sort(v.begin(), v.end())

#define REV(v) reverse(v.begin(), v.end())

const int MOD = 1e9 + 7;

vector<bool> sieve(int maxNum) {

    vector<bool> isPrime(maxNum + 1, true);

    isPrime[0] = isPrime[1] = false; // 0 and 1 are not prime numbers



    for (int i = 2; i * i <= maxNum; i++) {

        if (isPrime[i]) {

            for (int j = i * i; j <= maxNum; j += i) {

                isPrime[j] = false;

            }

        }

    }

    return isPrime;

}



bool isPrime(int x) {

    if (x <= 1)

        return false;

    for (int i = 2; i * i <= x; i++) {

        if (x % i == 0) {

            return false;

        }

    }

    return true;

}



int gcd(int a, int b) {

    if (b == 0)

        return a;

    return gcd(b, a % b);

}

int main() {

    fastio;

    int t;

    cin >> t;

    while (t--)

    {

        int n;

        cin>>n;

        v a(n);

        inp(a);

        int left=0;

        int right=0;

        if(is_sorted(a.begin(),a.end()))

        {

            cout<<"YES"<<endl;

            continue;

        }

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

        {2060

            if(a[i]>a[i-1])

            {

                left++;

            }

        }

         for(int i=n-1;i>=0;i--)

        {

            if(a[i]>a[i+1])

            {

                right++;

            }

        }

      //  cout<<left<<" "<<right<<endl;

        if(abs(left-right)<=1)

        {

            cout<<"YES"<<endl;

        }

        else

        {

            cout<<"NO"<<endl;

        }

    }

}

Submission (verdict: Wrong answer on test 2):
/*

 *  - Dhiraj Yadav

 *  - Progress is slow, but quitting guarantees failure

 *  - Stay consistent, stay disciplined, and success will follow!

 */



#include <bits/stdc++.h>

using namespace std;



#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define yy cout << "YES\n"

#define nn cout << "NO\n"

#define ll long long

#define v vector<int>

#define inp(v) for (auto &x : v) cin >> x;



int main() {

    fastio;

    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

        v a(n);

        inp(a);



        int left = 0, right = 0;

        

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

            if (a[i] > a[i - 1]) left++;

            else if (a[i] < a[i - 1]) right++;

        }

        if (right > left) {

            nn;

        } else {

            yy;

        }

    }

    return 0;

}