ShaysXIA/CodeInsightBench huggingface dataset:
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;
#define int long long
#define endl '\n'
#define pb push_back
#define cl clear()
#define N 200100
#define inf 0x3f3f3f3f
int t, n, m, k, a[N];
int b[N];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n >> m;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        map<int, int> mp;
        for (int i = 1; i <= m; i++)
            cin >> b[i], mp[b[i]]++;
        sort(a + 1, a + 1 + n);
        bool v = 1;
        for (int i = 1; i <= n; i++)
        {
            if (mp.count(a[i]) && mp[a[i]])
                mp[a[i]]--;
            else
            {
                if (a[i + 1] - a[i] <= 1)
                    a[i + 1] += a[i], a[i] = inf;
                else
                    v = 0;
            }
        }
        for (auto i = mp.begin(); i != mp.end(); i++)
            if (i->second)
                v = 0;
        if (v)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define cl clear()
#define N 200100
#define inf 0x3f3f3f3f
int t, n, m, k, a[N];
int b[N];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n >> m;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        map<int, int> mp;
        for (int i = 1; i <= m; i++)
            cin >> b[i], mp[b[i]]++;
        sort(a + 1, a + 1 + n);
        bool v = 1;
        for (int i = 1; i <= n; i++)
        {
            if (mp.count(a[i]) && mp[a[i]])
                mp[a[i]]--;
            else
            {
                if (a[i + 1] - a[i] <= 1)
                    a[i + 1] += a[i], a[i] = inf;
                else
                    v = 0;
            }
        }
        for (auto i = mp.begin(); i != mp.end(); i++)
            if (i->second)
                v = 0;
        if (v)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define cl clear()
#define N 200100
#define inf 0x3f3f3f3f
int t, n, m, k, a[N];
int b[N];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n >> m;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        map<int, int> mp;
        for (int i = 1; i <= m; i++)
            cin >> b[i], mp[b[i]]++;
        sort(a + 1, a + 1 + n);
        bool v = 1;
        for (int i = 1; i <= n; i++)
        {
            if (mp.count(a[i]) && mp[a[i]] != 0)
                mp[a[i]]--;
            else
            {
                if (a[i + 1] - a[i] <= 1 && i < n)
                    a[i + 1] += a[i], a[i] = inf;
                else
                    v = 0;
            }
        }
        for (auto i = mp.begin(); i != mp.end(); i++)
            if (i->second != 0)
                v = 0;
        if (v)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define cl clear()
#define N 200
#define inf 0x3f3f3f3f
int t, n, m, k, a[N];
int b[N];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n >> m;
        map<int, int> mp;
        for (int i = 1; i <= n; i++)
            cin >> a[i], mp[a[i]]++;
        for (int i = 1; i <= m; i++)
            cin >> b[i];
        sort(b + 1, b + 1 + m);
        bool v = 1;
        for (int i = 1; i <= m; i++)
        {
            if (mp.count(b[i]) && mp[b[i]] != 0)
                mp[b[i]]--;
            else
            {
                if (b[i] == 0)
                {
                    v = 0;
                    break;
                }
                int p = b[i];
                b[i] = p / 2;
                b[m + 1] = p - p / 2;
                i--, m++;
                continue;
            }
        }
        for (auto i = mp.begin(); i != mp.end(); i++)
            if (i->second != 0)
                v = 0;
        if (v)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define cl clear()
#define N 1000100
#define inf 0x3f3f3f3f
int t, n, m, k, a[N];
int b[N];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n >> m;
        map<int, int> mp;
        for (int i = 1; i <= n; i++)
            cin >> a[i], mp[a[i]]++;
        for (int i = 1; i <= m; i++)
            cin >> b[i];
        sort(b + 1, b + 1 + m);
        bool v = 1;
        for (int i = 1; i <= m; i++)
        {
            if (mp.count(b[i]) && mp[b[i]] != 0)
                mp[b[i]]--;
            else
            {
                if (b[i] == 0)
                {
                    v = 0;
                    break;
                }
                int p = b[i];
                b[i] = p / 2;
                b[m + 1] = p - p / 2;
                i--, m++;
                continue;
            }
        }
        for (auto i = mp.begin(); i != mp.end(); i++)
            if (i->second != 0)
                v = 0;
        if (v)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define cl clear()
#define N 200100
#define inf 0x3f3f3f3f
int t, n, m, k, a[N];
int b[N];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n >> m;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        map<int, int> mp;
        for (int i = 1; i <= m; i++)
            cin >> b[i], mp[b[i]]++;
        sort(a + 1, a + 1 + n);
        bool v = 1;
        for (int i = 1; i <= n; i++)
        {
            if (mp.count(a[i]) && mp[a[i]] != 0)
                mp[a[i]]--;
            else
            {
                if (a[i + 1] - a[i] <= 1 && i < n)
                    a[i + 1] += a[i], a[i] = inf;
                else
                    v = 0;
            }
        }
        for (auto i = mp.begin(); i != mp.end(); i++)
            if (i->second != 0)
                v = 0;
        if (v)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define cl clear()
#define N 200
#define inf 0x3f3f3f3f
int t, n, m, k, a[N];
int b[N];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n >> m;
        map<int, int> mp;
        for (int i = 1; i <= n; i++)
            cin >> a[i], mp[a[i]]++;
        for (int i = 1; i <= m; i++)
            cin >> b[i];
        sort(b + 1, b + 1 + m);
        bool v = 1;
        for (int i = 1; i <= m; i++)
        {
            if (mp.count(b[i]) && mp[b[i]] != 0)
                mp[b[i]]--;
            else
            {
                if (b[i] == 0)
                {
                    v = 0;
                    break;
                }
                int p = b[i];
                b[i] = p / 2;
                b[m + 1] = p - p / 2;
                i--, m++;
                continue;
            }
        }
        for (auto i = mp.begin(); i != mp.end(); i++)
            if (i->second != 0)
                v = 0;
        if (v)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pnl cout << "\n"
#ifndef ONLINE_JUDGE
#define dbg(x) cerr << (#x) << " " << (x) << "\n"
#else
#define dbg(x) 42
#endif

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using vi = vector<int>;
using vvi = vector<vi>;
using ii = array<int, 2>;
using vii = vector<ii>;

template <typename T>
istream &operator>>(istream &in, vector<T> &a) {
    for (auto &x : a) in >> x;
    return in;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &a) {
    for (auto &x : a) out << x << " ";
    return out;
}

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(int testcase) {
    int n; cin >> n;
    vi c(n); cin >> c;
    vi pos(n);
    for (int i = 0; i < n; i++) {
        pos[c[i] - 1] = i;
    }
    vii ans;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (pos[j] < pos[i]) {
                ans.push_back({j, i});
            } else {
                ans.push_back({j, i});
                ans.push_back({i, j});
            }
        }
    }
    cout << sz(ans) << "\n";
    for (auto [f, s] : ans) {
        cout << f + 1 << " " << s + 1 << "\n";
    }
}

int32_t main() {
    using namespace chrono;
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    auto start = high_resolution_clock::now();
    int T = 1; // cin >> T;
    for (int t = 1; t <= T; t++) {
        solve(t);
    }
    auto end = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(end - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() << " ms\n";
#endif
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

#define int long long

#define sp ' '

#define PI 3.14159265358979323846



int32_t main(){

    cin.tie(0)->sync_with_stdio(0);

    int t;cin>>t;

    while(t--)

    {

        string s;cin>>s;

        int c2 =count(s.begin(),s.end(),'2'),c3 = count(s.begin(),s.end(),'3');

        int sum=0;

        for(int i = 0;i<s.size();i++)

        {

            sum+=s[i]-'0';

        }

        bool ok = false;

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

        {

            for(int j = 0;j<=c3;j++)

            {

             if((sum + 2*i + 6*j)%9 ==0)

             {

                 ok = true;

                 break;

             }

            }

        }

        if(ok)

            cout<<"YES"<<nl;

        else cout<<"NO"<<nl;

    }

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

#define int long long

#define sp ' '

#define PI 3.14159265358979323846



int32_t main(){

    cin.tie(0)->sync_with_stdio(0);

    int t;cin>>t;

    while(t--)

    {

        string s;cin>>s;

        int c2 =count(s.begin(),s.end(),'2'),c3 = count(s.begin(),s.end(),'3');

        int sum=0;

        for(int i = 0;i<s.size();i++)

        {

            sum+=s[i]-'0';

        }

        bool ok = false;

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

        {

            for(int j = 0;j<=c3;j++)

            {

             if((sum + 2*i + 6*j)%9 ==0)

             {

                 ok = true;

                 break;

             }

            }

        }

        if(ok)

            cout<<"YES"<<nl;

        else cout<<"NO"<<nl;

    }

}



Submission (verdict: Compilation error):
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

#define int long long

#define sp ' '

#define PI 3.14159265358979323846



int32_t main(){

    cin.tie(0)->sync_with_stdio(0);

    int t;cin>>t;

    while(t--)

    {

        string s;cin>>s;

        int c2 =count(s.begin(),s.end(),'2'),c3 = count(s.begin(),s.end(),'3');

        int sum=0;

        for(int i = 0;i<s.size();i++)

        {

            sum+=s[i]-'0';

        }

        bool ok = false;

        for(int i = 0;i<=min(10,c2);i++)

        {

            for(int j = 0;j<=min(10,c3);j++)

            {

             if((sum + 2*i + 6*j)%9 ==0)

             {

                 ok = true;

                 break;

             }

            }

        }

        if(ok)

            cout<<"YES"<<nl;

        else cout<<"NO"<<nl;

    }

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

#define int long long

#define sp ' '

#define PI 3.14159265358979323846



int32_t main(){

    cin.tie(0)->sync_with_stdio(0);

    int t;cin>>t;

    while(t--)

    {

        string s;cin>>s;

        int c2 =count(s.begin(),s.end(),'2'),c3 = count(s.begin(),s.end(),'3');

        int sum=0;

        for(int i = 0;i<s.size();i++)

        {

            sum+=s[i]-'0';

        }

        bool ok = false;

        for(int i = 0;i<=min(10,c2);i++)

        {

            for(int j = 0;j<=min(10,c3);j++)

            {

             if((sum + 2*i + 6*j)%9 ==0)

             {

                 ok = true;

                 break;

             }

            }

        }

        if(ok)

            cout<<"YES"<<nl;

        else cout<<"NO"<<nl;

    }

}



Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

#define int long long

#define sp ' '

#define PI 3.14159265358979323846



int32_t main(){

    cin.tie(0)->sync_with_stdio(0);

    int t;cin>>t;

    while(t--)

    {

        string s;cin>>s;

        int c2 =count(s.begin(),s.end(),'2'),c3 = count(s.begin(),s.end(),'3');

        int sum=0;

        for(int i = 0;i<s.size();i++)

        {

            sum+=s[i]-'0';

        }

        bool ok = false;

        for(int i = 0;i<=min(10ll,c2);i++)

        {

            for(int j = 0;j<=min(10ll,c3);j++)

            {

             if((sum + 2*i + 6*j)%9 ==0)

             {

                 ok = true;

                 break;

             }

            }

        }

        if(ok)

            cout<<"YES"<<nl;

        else cout<<"NO"<<nl;

    }

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
/* int best = 0, sum = 0;
for (int k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
cout << best << "\n";*/
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main(){
    int t;
    cin>>t;
    while(t--) {
        int n,l,r;
        cin>>n>>l>>r;
        int arr[n];
        for(int i=0;i<n;i++) {
            cin>>arr[i];
        }
        sort(arr,arr+n);
        long long sum=0;
        for(int i=0;i<=r-l;i++) {
            sum+=arr[i];
        }
        cout<<sum<<endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 8):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
/* int best = 0, sum = 0;
for (int k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
cout << best << "\n";*/
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main(){
    int t;
    cin>>t;
    while(t--) {
        int n,l,r;
        cin>>n>>l>>r;
        vector<int> v,v1;
        for(int i=1;i<=n;i++) {
            int x;
            cin>>x;
            if(i<=r) {
                v.push_back(x);
            }
            if(i>=l) {
                v1.push_back(x);
            }
        }
        sort(v1.begin(),v1.end());
        sort(v.begin(),v.end());
        int sum1=0,sum2=0;
        for(int i=0;i<=r-l;i++) {
            sum1+=v[i];
        }
        for(int i=0;i<=r-l;i++) {
            sum2+=v1[i];
        }
        cout<<min(sum1,sum2)<<endl;
    }
}



Submission (verdict: Accepted):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

/* int best = 0, sum = 0;

for (int k = 0; k < n; k++) {

sum = max(array[k],sum+array[k]);

best = max(best,sum);

}

cout << best << "\n";*/

long long binpow(long long a, long long b) {

    if (b == 0)

        return 1;

    long long res = binpow(a, b / 2);

    if (b % 2)

        return res * res * a;

    else

        return res * res;

}

int main(){

    int t;

    cin>>t;

    while(t--) {

        int n,l,r;

        cin>>n>>l>>r;

        vector<ll> v,v1;

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

            int x;

            cin>>x;

            if(i<=r) {

                v.push_back(x);

            }

            if(i>=l) {

                v1.push_back(x);

            }

        }

        sort(v1.begin(),v1.end());

        sort(v.begin(),v.end());

        ll sum1=0,sum2=0;

        for(int i=0;i<=r-l;i++) {

            sum1+=v[i];

        }

        for(int i=0;i<=r-l;i++) {

            sum2+=v1[i];

        }

        cout<<min(sum1,sum2)<<endl;

    }

}
Problem: 2063B - Subsequence Update
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;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
/* int best = 0, sum = 0;
for (int k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
cout << best << "\n";*/
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main(){
    int t;
    cin>>t;
    while(t--) {
        int n,l,r;
        cin>>n>>l>>r;
        int arr[n];
        for(int i=0;i<n;i++) {
            cin>>arr[i];
        }
        sort(arr,arr+n);
        long long sum=0;
        for(int i=0;i<=r-l;i++) {
            sum+=arr[i];
        }
        cout<<sum<<endl;
    }
}



Submission (verdict: Wrong answer on test 8):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
/* int best = 0, sum = 0;
for (int k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
cout << best << "\n";*/
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main(){
    int t;
    cin>>t;
    while(t--) {
        int n,l,r;
        cin>>n>>l>>r;
        vector<int> v,v1;
        for(int i=1;i<=n;i++) {
            int x;
            cin>>x;
            if(i<=r) {
                v.push_back(x);
            }
            if(i>=l) {
                v1.push_back(x);
            }
        }
        sort(v1.begin(),v1.end());
        sort(v.begin(),v.end());
        int sum1=0,sum2=0;
        for(int i=0;i<=r-l;i++) {
            sum1+=v[i];
        }
        for(int i=0;i<=r-l;i++) {
            sum2+=v1[i];
        }
        cout<<min(sum1,sum2)<<endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define dbl double
#define yes cout << "YES\n"
#define no cout << "NO\n"
constexpr dbl PI = 3.14159265359;
constexpr ll mod = 1e9 + 7;

using namespace std;

void solve() {
    int n;
    cin >> n;

    vector<int> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> vec[i];
    }

    bool chk = true;
    for (int i = 0; i < n - 2; ++i) {
        if (vec[i] > vec[i + 1] && vec[i + 1] > vec[i + 2]) {
            chk = false;
        }
    }
    (chk) ? cout << "YES\n" : cout << "NO\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;  // Use int instead of ll for t
    cin >> t;
    while (t--) {
        solve();
    }

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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define dbl double
#define yes cout << "YES\n"
#define no cout << "NO\n"
constexpr dbl PI = 3.14159265359;
constexpr ll mod = 1e9 + 7;

using namespace std;

void solve() {
    int n;
    cin >> n;

    vector<int> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> vec[i];
    }

    bool chk = true;
    for (int i = 0; i < n - 2; ++i) {
        if (vec[i] > vec[i + 1] && vec[i + 1] > vec[i + 2]) {
            chk = false;
        }
    }
    (chk) ? cout << "YES\n" : cout << "NO\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;  // Use int instead of ll for t
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define dbl double
#define yes cout << "YES\n"
#define no cout << "NO\n"
constexpr dbl PI = 3.14159265359;
constexpr ll mod = 1e9 + 7;

using namespace std;

void solve() {
    int n;
    cin >> n;

    vector<int> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> vec[i];
    }

    if (vec[0] > vec[1]) {
        cout << "NO\n";
        return;
    }
    if (vec[n - 2] > vec[n - 1]) {
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}