ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9;
#define intt int
#define pll pair<long long, long long>
#define vpll vector<pair<long long, long long>>
#define vll vector<long long>
#define mll map<ll, ll>
#define sll set<ll>
#define sc set<char>
#define ff first
#define se second
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define f(i, s, e) for (long long int i = s; i < e; i++)
#define cf(i, s, e) for (long long int i = s; i <= e; i++)
#define rf(i, e, s) for (long long int i = e - 1; i >= s; i--)
#define pb push_back
#define eb emplace_back
#define M 1000000007
#define PI 3.1415926535897932384626433832795
#define read(type) readInt<type>()
#define take(n, a) vll a(n); f(i, 0, n) cin >> a[i];
ll min(ll a, ll b) { if (a < b) return a; return b; }
ll max(ll a, ll b) { if (a > b) return a; return b; }
ll gcd(ll a, ll b) { if (b > a) return gcd(b, a); if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
string to_upper(string a) { for (int i = 0; i < (int)a.size(); ++i) if (a[i] >= 'a' && a[i] <= 'z') a[i] -= 'a' - 'A'; return a; }
string to_lower(string a) { for (int i = 0; i < (int)a.size(); ++i) if (a[i] >= 'A' && a[i] <= 'Z') a[i] += 'a' - 'A'; return a; }
bool prime(int a) { if (a == 1) return 0; for (int i = 2; i <= round(sqrt(a)); ++i) if (a % i == 0) return 0; return 1; }
void yes() { cout << "YES\n"; }
void no() { cout << "NO\n"; }


class DisjointSet {
    vector<int> rank, parent, size;
public:
    DisjointSet(int n) {
        rank.resize(n + 1, 0);
        parent.resize(n + 1);
        size.resize(n + 1);
        for (int i = 0; i <= n; i++) {
            parent[i] = i;
            size[i] = 1;
        }
    }

    int findUPar(int node) {
        if (node == parent[node])
            return node;
        return parent[node] = findUPar(parent[node]);
    }

    void unionBySize(int u, int v) {
        int ulp_u = findUPar(u);
        int ulp_v = findUPar(v);
        if (ulp_u == ulp_v) return;
        if (size[ulp_u] < size[ulp_v]) {
            parent[ulp_u] = ulp_v;
            size[ulp_v] += size[ulp_u];
        }
        else {
            parent[ulp_v] = ulp_u;
            size[ulp_u] += size[ulp_v];
        }
    }
};
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
int main() {
	ll t;
	cin>>t;
	while(t--)
	{
	    string s;
	    cin>>s;
	    int n=s.size();
	    for(int i=n-2;i>=0;i--)
	    {
	        for(int j=i;j<n-1;j++)
	        {
	            if(s[j+1]-s[j]>=2)
	            {
	                s[j+1]=(s[j+1]-'0'-1)+'0';
	                swap(s[j],s[j+1]);
	            }
	            
	        }
	    }
	    cout<<s<<endl;
	}

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <cmath>

#include <vector>

#include <algorithm>

#include <map>

using namespace std;



const int N = 100010;





void solve(){

    int n, arr[200010];

    cin >> n;

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

        cin >> arr[i];

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

        int mini = min(arr[i],arr[i+1]);

        arr[i] -= mini;

        arr[i+1] -= mini;

        if(arr[i] >= arr[i+1]){

            cout << "NO" << endl;

            return;

        }

    }

    cout << "YES" << endl;

    

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    #ifndef ONLINE_JUDGE

        freopen("input.txt", "r", stdin);

        freopen("output.txt", "w", stdout);

    #endif

    int t = 1;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <cmath>

#include <vector>

#include <algorithm>

#include <map>

using namespace std;



const int N = 100010;





void solve(){

    int n, arr[200010];

    cin >> n;

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

        cin >> arr[i];

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

        int mini = min(arr[i],arr[i+1]);

        arr[i] -= mini;

        arr[i+1] -= mini;

        if(arr[i] >= arr[i+1]){

            cout << "NO" << endl;

            return;

        }

        if(arr[i] == arr[i+1] && !is_sorted(arr, arr + n)){

            cout << "NO" << endl;

            return;

        }

    }

    cout << "YES" << endl;

    

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    #ifndef ONLINE_JUDGE

        freopen("input.txt", "r", stdin);

        freopen("output.txt", "w", stdout);

    #endif

    int t = 1;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <cmath>

#include <vector>

#include <algorithm>

#include <map>

using namespace std;



const int N = 100010;





void solve(){

    int n, arr[200010];

    cin >> n;

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

        cin >> arr[i];

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

        int mini = min(arr[i],arr[i+1]);

        arr[i] -= mini;

        arr[i+1] -= mini;

        if(arr[i] >= arr[i+1]){

            cout << "NO" << endl;

            return;

        }

    }

    cout << "YES" << endl;

    

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    #ifndef ONLINE_JUDGE

        freopen("input.txt", "r", stdin);

        freopen("output.txt", "w", stdout);

    #endif

    int t = 1;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <cmath>

#include <vector>

#include <algorithm>

#include <map>

using namespace std;



const int N = 100010;





void solve(){

    int n, arr[200010];

    cin >> n;

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

        cin >> arr[i];

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

        int mini = min(arr[i],arr[i+1]);

        arr[i] -= mini;

        arr[i+1] -= mini;

        if(arr[i] >= arr[i+1]){

            cout << "NO" << endl;

            return;

        }

        if(arr[i] == arr[i+1] && !is_sorted(arr, arr + n)){

            cout << "NO" << endl;

            return;

        }

    }

    cout << "YES" << endl;

    

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    #ifndef ONLINE_JUDGE

        freopen("input.txt", "r", stdin);

        freopen("output.txt", "w", stdout);

    #endif

    int t = 1;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <cmath>

#include <vector>

#include <algorithm>

#include <map>

using namespace std;



const int N = 100010;





void solve(){

    int n, arr[200010];

    cin >> n;

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

        cin >> arr[i];

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

        int mini = min(arr[i],arr[i+1]);

        arr[i] -= mini;

        arr[i+1] -= mini;

        if(arr[i] > arr[i+1]){

            cout << "NO" << endl;

            return;

        }

        if(arr[i] == arr[i+1] && !is_sorted(arr, arr + n)){

            cout << "NO" << endl;

            return;

        }

    }

    cout << "YES" << endl;

    

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    #ifndef ONLINE_JUDGE

        freopen("input.txt", "r", stdin);

        freopen("output.txt", "w", stdout);

    #endif

    int t = 1;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <cmath>

#include <vector>

#include <algorithm>

#include <map>

using namespace std;



const int N = 100010;





void solve(){

    int n, arr[200010];

    cin >> n;

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

        cin >> arr[i];

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

        int mini = min(arr[i],arr[i+1]);

        arr[i] -= mini;

        arr[i+1] -= mini;

        if(arr[i] > arr[i+1]){

            cout << "NO" << endl;

            return;

        }

        if(arr[i] == arr[i+1] && !is_sorted(arr, arr + n)){

            cout << "NO" << endl;

            return;

        }

    }

    cout << "YES" << endl;

    

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    #ifndef ONLINE_JUDGE

        freopen("input.txt", "r", stdin);

        freopen("output.txt", "w", stdout);

    #endif

    int t = 1;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

Submission (verdict: Accepted):
#include <iostream>

#include <cmath>

#include <vector>

#include <algorithm>

#include <map>

using namespace std;



const int N = 100010;





void solve(){

    int n, arr[200010];

    cin >> n;

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

        cin >> arr[i];

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

        int mini = min(arr[i],arr[i+1]);

        arr[i] -= mini;

        arr[i+1] -= mini;

    }

    if(is_sorted(arr, arr + n))

        cout << "YES" << endl;

    else

        cout << "NO" << endl;

    

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    #ifndef ONLINE_JUDGE

        freopen("input.txt", "r", stdin);

        freopen("output.txt", "w", stdout);

    #endif

    int t = 1;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


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

typedef long long ll;
const ll mod = 1e9 + 7;
const ll MX = 2e5 + 5;
inline void norm(ll &a)
{
    a %= mod;
    (a < 0) && (a += mod);
} // positive mod value
inline ll modAdd(ll a, ll b)
{
    a %= mod, b %= mod;
    norm(a), norm(b);
    return (a + b) % mod;
} // modular addition
inline ll modSub(ll a, ll b)
{
    a %= mod, b %= mod;
    norm(a), norm(b);
    return (a - b) % mod;
} // modular subtraction
inline ll modMul(ll a, ll b)
{
    a %= mod, b %= mod;
    norm(a), norm(b);
    return (a * b) % mod;
} // modular multiplication
inline ll bigMod(ll b, ll p)
{
    ll r = 1;
    while (p)
    {
        if (p & 1LL)
            r = modMul(r, b);
        b = modMul(b, b);
        p >>= 1LL;
    }
    return r;
}
inline ll modInverse(ll a) { return bigMod(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

void dfs(ll node, vector<vector<ll>> &adj, vector<ll> &vis)
{
    vis[node] = 1;
    for(auto child: adj[node])
    {
        if(!vis[child])
            dfs(child, adj, vis);
    }
}

void solve()
{
    ll n;
    cin >> n;
    vector<vector<ll>> adj(n+1, vector<ll>());
    vector<ll> vis(n+1, 0); 

    map<ll, ll> mp;
    vector<ll> u(n), v(n);
    for (int i = 0; i < n - 1; i++)
    {
        cin >> u[i] >> v[i];
        mp[u[i]]++, mp[v[i]]++;
    }

    vector<pair<ll, ll>> vp;
    for (int i = 1; i <= n; i++)
        vp.push_back({mp[i], i});
    sort(vp.rbegin(), vp.rend());

    // for(auto i: vp) cout << i.first << ' ' << i.second <<endl;
    ll c1 = vp[0].second;
    // cout << c1 << endl;
    mp.clear();

    for (int i = 0; i < n - 1; i++)
    {
        if (u[i] == c1 or v[i] == c1)
            continue;
        mp[u[i]]++;
        mp[v[i]]++;
    }

    vp.clear();
    for (int i = 1; i <= n; i++)
    {
        if (i == c1)
            continue;
        vp.push_back({mp[i], i});
    }

    sort(vp.rbegin(), vp.rend());
    // for(auto i: vp) cout << i.first << ' ' << i.second << endl;
    ll c2 = vp[0].second;
    // cout << c2 << endl;

    for (int i = 0; i < n - 1; i++)
    {
        if (u[i] == c1 or u[i] == c2 or v[i] == c1 or v[i] == c2)
            continue;
        adj[u[i]].push_back(v[i]); 
        adj[v[i]].push_back(u[i]); 
    }

    ll ans = 0; 
    for(int i=1;i<=n; i++)
    {
        if(i==c1 or i==c2) continue;
        if(!vis[i])
        {
            dfs(i, adj, vis); 
            ans++; 
        }

    }
    cout << ans << endl; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll tc = 1;
    cin >> tc;
    for (ll t = 1; t <= tc; t++)
    {
        solve();
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
typedef long long llt;
#define mod 998244353

bool check(llt &num, map<llt, llt> &mp)
{
    map<llt, llt> mp2;
    mp2[num]=1;
    
    while (true)
    {
        map<llt, llt> mp3;
        mp3 = mp2;
        if (mp2.size() == 0)
            break;
        for (auto i : mp3)
        {
            if (mp[i.first] >= i.second)
            {
                mp[i.first] -= i.second;
                mp2.erase(i.first);
                continue;
            }
            else if (mp[i.first] < i.second)
            {
                mp2[i.first] -= i.second;
                mp.erase(i.first);
            }
            if (i.first != 1)
                {
                    if (i.first % 2 == 1)
                    {
                        mp2[i.first / 2] = i.second;
                        mp2[i.first / 2 + 1] = i.second;
                    }
                    else if (i.first % 2 == 0)
                    {
                        mp2[i.first / 2] = i.second * 2;
                    }
                    mp2.erase(i.first);
                }
        }
        for (auto i : mp2)
        {
            if (i.first == 1 && mp[1] < i.second)
            {
                return false;
            }
        }
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    llt t;
    cin >> t;
    while (t--)
    {
        llt n, m;
        cin >> n >> m;
        vector<llt> a(n), b(m);
        llt suma=0,sumb=0;

        for (int i = 0; i < n; i++){
            cin >> a[i];suma+=a[i];}
        for (int i = 0; i < m; i++){
            cin >> b[i];sumb+=b[i];}
        map<llt, llt> mp;
        if(suma!=sumb){
            cout<<"NO"<<endl;continue;
        }
        for (int i = 0; i < n; i++)
        {
            mp[a[i]]++;
        }
        string ans = "YES";
        for (int i = 0; i < m; i++)
        {
            if (check(b[i], mp))
            {
                continue;
            }
            else
            {
                ans = "NO";
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <iostream> 
#include <bits/stdc++.h> 
#include <vector> 
typedef long long ll;
ll mod=1e9+7;
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long

void decToBinary(int n){
    // array to store binary number
    int binaryNum[32];

    // counter for binary array
    int i = 0;
    while (n > 0) {

        // storing remainder in binary array
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }

    // printing binary array in reverse order
    for (int j = i - 1; j >= 0; j--)
        cout << binaryNum[j];
}
int32_t main(){
    #ifndef ONLINE_JUDGE
        ifstream input("input.txt");
        ofstream output("output.txt");
        cin.rdbuf(input.rdbuf());
        cout.rdbuf(output.rdbuf());
    #endif
    fastIO

    int t;
    cin >> t;
    while(t--){
        int l, r;
        cin >> l >> r;

        int a = 0, b = 0, c=0;
        for (int i = 30; i >= 0;i--){
            int b1 = ((1 << i) & l);
            int b2 = ((1 << i) & r);
            if(b1==b2){
                a += (b1 * (1 << i));
                b += (b1 * (1 << i));
            }else{
                a += (1 << i);
                b += ((1 << i) - 1);
                break;
            }
        }

        for (int i = l; i <= r;i++){
            if(i!=a and i!=b){
                c = i;
                break;
            }
        }

        cout << a << " " << b << " " << c << endl;
    }



    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream> 
#include <bits/stdc++.h> 
#include <vector> 
typedef long long ll;
ll mod=1e9+7;
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long

void decToBinary(int n){
    // array to store binary number
    int binaryNum[32];

    // counter for binary array
    int i = 0;
    while (n > 0) {

        // storing remainder in binary array
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }

    // printing binary array in reverse order
    for (int j = i - 1; j >= 0; j--)
        cout << binaryNum[j];
}
int32_t main(){
    #ifndef ONLINE_JUDGE
        ifstream input("input.txt");
        ofstream output("output.txt");
        cin.rdbuf(input.rdbuf());
        cout.rdbuf(output.rdbuf());
    #endif
    fastIO

    int t;
    cin >> t;
    while(t--){
        int l, r;
        cin >> l >> r;

        int a = 0, b = 0, c=0;
        for (int i = 30; i >= 0;i--){
            int b1 = ((1 << i) & l);
            int b2 = ((1 << i) & r);
            if(b1==b2){
                a += (b1 * (1 << i));
                b += (b1 * (1 << i));
            }else{
                a += (1 << i);
                // b += ((1 << i) - 1);
                b = a - 1;
                break;
            }
        }

        for (int i = l; i <= r;i++){
            if(i!=a and i!=b){
                c = i;
                break;
            }
        }

        cout << a << " " << b << " " << c << endl;
    }



    return 0;
}


Submission (verdict: Accepted):
#include <iostream> 
#include <bits/stdc++.h> 
#include <vector> 
typedef long long ll;
ll mod=1e9+7;
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long

void decToBinary(int n){
    // array to store binary number
    int binaryNum[32];

    // counter for binary array
    int i = 0;
    while (n > 0) {

        // storing remainder in binary array
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }

    // printing binary array in reverse order
    for (int j = i - 1; j >= 0; j--)
        cout << binaryNum[j];
}
int32_t main(){
    #ifndef ONLINE_JUDGE
        ifstream input("input.txt");
        ofstream output("output.txt");
        cin.rdbuf(input.rdbuf());
        cout.rdbuf(output.rdbuf());
    #endif
    fastIO

    int t;
    cin >> t;
    while(t--){
        int l, r;
        cin >> l >> r;

        int a = 0, b = 0, c=0;
        for (int i = 30; i >= 0;i--){
            int b1 = 0;
            if((1 << i) & l) b1=1;
            int b2 = 0;
            if((1 << i) & r) b2=1;

            if(b1==b2){
                a += (b1 * (1 << i));
                b += (b1 * (1 << i));
            }else{
                a += (1 << i);
                b += ((1 << i) - 1);
                break;
            }
        }

        for (int i = l; i <= r;i++){
            if(i!=a and i!=b){
                c = i;
                break;
            }
        }

        cout << a << " " << b << " " << c << endl;
    }



    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream> 
#include <bits/stdc++.h> 
#include <vector> 
typedef long long ll;
ll mod=1e9+7;
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long

void decToBinary(int n){
    // array to store binary number
    int binaryNum[32];

    // counter for binary array
    int i = 0;
    while (n > 0) {

        // storing remainder in binary array
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }

    // printing binary array in reverse order
    for (int j = i - 1; j >= 0; j--)
        cout << binaryNum[j];
}
int32_t main(){
    #ifndef ONLINE_JUDGE
        ifstream input("input.txt");
        ofstream output("output.txt");
        cin.rdbuf(input.rdbuf());
        cout.rdbuf(output.rdbuf());
    #endif
    fastIO

    int t;
    cin >> t;
    while(t--){
        int l, r;
        cin >> l >> r;

        int a = 0, b = 0, c=0;
        for (int i = 30; i >= 0;i--){
            int b1 = ((1 << i) & l);
            int b2 = ((1 << i) & r);
            if(b1==b2){
                a += (b1 * (1 << i));
                b += (b1 * (1 << i));
            }else{
                a += (1 << i);
                b += ((1 << i) - 1);
                break;
            }
        }

        for (int i = l; i <= r;i++){
            if(i!=a and i!=b){
                c = i;
                break;
            }
        }

        cout << a << " " << b << " " << c << endl;
    }



    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <iostream> 
#include <bits/stdc++.h> 
#include <vector> 
typedef long long ll;
ll mod=1e9+7;
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long

void decToBinary(int n){
    // array to store binary number
    int binaryNum[32];

    // counter for binary array
    int i = 0;
    while (n > 0) {

        // storing remainder in binary array
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }

    // printing binary array in reverse order
    for (int j = i - 1; j >= 0; j--)
        cout << binaryNum[j];
}
int32_t main(){
    #ifndef ONLINE_JUDGE
        ifstream input("input.txt");
        ofstream output("output.txt");
        cin.rdbuf(input.rdbuf());
        cout.rdbuf(output.rdbuf());
    #endif
    fastIO

    int t;
    cin >> t;
    while(t--){
        int l, r;
        cin >> l >> r;

        int a = 0, b = 0, c=0;
        for (int i = 30; i >= 0;i--){
            int b1 = ((1 << i) & l);
            int b2 = ((1 << i) & r);
            if(b1==b2){
                a += (b1 * (1 << i));
                b += (b1 * (1 << i));
            }else{
                a += (1 << i);
                // b += ((1 << i) - 1);
                b = a - 1;
                break;
            }
        }

        for (int i = l; i <= r;i++){
            if(i!=a and i!=b){
                c = i;
                break;
            }
        }

        cout << a << " " << b << " " << c << endl;
    }



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


Submission (verdict: Wrong answer on test 1):
#include<iostream>

#include<vector>



using namespace std;



void solve()

{

    int n;

    

    cin>>n;

    

    vector<int> a(n);

    

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

    {

        cin >> a[i];

    }

    

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

    {

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

        {

            cout << "NO"<<endl;

            return;

        }

    }

    

    cout << "YES"<<endl;

}



int main()

{

    int t;

    

    cin>>t;

    

    while(t--)

    {

        solve();

    }

    

    return 0;

}