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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define fastio()                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define PI 3.141592653589793238462
#define int long long
int pri[1000100];

vector<int> getdiv(int n)
{
    vector<int> ans;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (pri[i] == 1)
                ans.push_back(i);
            if (i != n / i && pri[n / i] == 1)
                ans.push_back(n / i);
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    return ans;
}
void sieve()
{
    fill(pri + 2, pri + 1000100, 1);
    for (int i = 2; i * i <= 1e6; i++)
    {
        if (pri[i] == 1)
        {
            for (int j = i * i; j <= 1e6; j += i)
            {
                pri[j] = 0;
            }
        }
    }
}
signed solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (n <= 2)
    {
        if (a[0] > a[1])
        {
            cout << "NO" << endl;
            return 0;
        }
        cout << "YES" << endl;
        return 0;
    }
    if (a[0] > a[1])
    {
        cout << "NO" << endl;
        return 0;
    }
    for (int i = 1; i < n; i++)
    {
        if (a[i] > a[i + 1] && a[i] < a[i - 1])
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

signed main()
{
    fastio();
    int testcase;
    cin >> testcase;
    while (testcase--)
    {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define fastio()                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define PI 3.141592653589793238462
#define int long long
int pri[1000100];

vector<int> getdiv(int n)
{
    vector<int> ans;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (pri[i] == 1)
                ans.push_back(i);
            if (i != n / i && pri[n / i] == 1)
                ans.push_back(n / i);
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    return ans;
}
void sieve()
{
    fill(pri + 2, pri + 1000100, 1);
    for (int i = 2; i * i <= 1e6; i++)
    {
        if (pri[i] == 1)
        {
            for (int j = i * i; j <= 1e6; j += i)
            {
                pri[j] = 0;
            }
        }
    }
}
signed solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (n <= 2)
    {
        if (a[0] > a[1])
        {
            cout << "NO" << endl;
            return 0;
        }
        cout << "YES" << endl;
        return 0;
    }
    if (a[0] > a[1])
    {
        cout << "NO" << endl;
        return 0;
    }
    for (int i = 1; i < n - 1; i++)
    {
        if (a[i] > a[i + 1] && a[i] < a[i - 1])
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

signed main()
{
    fastio();
    int testcase;
    cin >> testcase;
    while (testcase--)
    {
        solve();
    }
    return 0;
}