ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)


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

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define ll long long

#define forl(i,a,b)  for(ll i=a;i<=b;i++)

#define forlr(i,a,b)  for(ll i=a;i>=b;i--)

#define pb push_back

#define popb pop_back

#define gcd(x,y) __gcd(x,y)

#define all(x) x.begin(), x.end()

#define mp make_pair

#define srt(x,i,j) sort(x.begin()+i, x.begin()+j+1)

#define rev(x,i,j) reverse(x.begin()+i, x.begin()+j+1)

#define vec(v,n) vector<ll> v(n)

#define vecx(v,n,x) vector<ll> v(n,x)

#define M 1000000007

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;





//Important functions---------------

// 1. power function

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;

}

 

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

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



vector<ll> findDivisors(ll n) {

    std::vector<ll> divisors;

    ll sqrtN = sqrt(n);

 

    for (ll i = 1; i <= sqrtN; ++i) {

        if (n % i == 0) {

            divisors.push_back(i);

            if (i != n / i) {

                divisors.push_back(n / i);

            }

        }

    }

    return divisors;

}



ll ceill(ll num, ll div){

    if(num%div==0){

        return num/div;

    }



    ll val=num/div;

    return val+1;

}



ll mex(set<ll> b){

    if(b.find(0)==b.end()) return 0;

    else if(b.find(1)==b.end()) return 1;

    return 2;



}



int main() {

std::ios::sync_with_stdio(false);

std::cin.tie(nullptr);

#ifndef ONLINE_JUDGE

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

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

#endif

ll t;

cin >> t;

while (t--) {

    ll n,x,y;

    cin>>n>>x>>y;

    vec(a,n);

    if(n&1){

        forl(i,0,n-1){

            if(i==n-1){

                a[i]=2;

            }

            else if(i&1) a[i]=0;

            else a[i]=1;

        }

    }

    else{

        forl(i,0,n-1){

            if(i&1) a[i]=0;

            else a[i]=1;

        }

    }



    x--;

    y--;

    if(a[x]==a[y]){

        set<ll> b;

        b.insert(a[(x-1)%n]);

        b.insert(a[(x+1)%n]);

        b.insert(a[y%n]);

        a[x]=mex(b);

        b.clear();

        b.insert(a[(y-1)%n]);

        b.insert(a[(y+1)%n]);

        b.insert(a[x%n]);

        a[y]=mex(b);

    }

    forl(i,0,n-1) cout<<a[i]<<" ";

    cout<<"\n";

}

return 0;

}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int tt;
    cin >> tt;
    while(tt--){
        int n, k;
        cin >> n >> k;
        vector<int>a(n);
        unordered_map<int, int>auxMap;
        auxMap.reserve(1<<20);
        for(int i = 0; i <n; i++){
            cin >> a[i];
            auxMap[a[i]]++;
        }
        
        vector<int>cantidades;
        for(auto it: auxMap){
            cantidades.push_back(it.second);
        }
        int ans = 1;
        sort(cantidades.begin(), cantidades.end());
        cantidades.pop_back();
        int eliminados = 0;
        for(int i = 0; i < int(cantidades.size()); i++){
            int resto = k - cantidades[i];
            cantidades[i] -= k;
            if(cantidades[i]<=0) eliminados++;
            else break;

            k = resto;
            if(k <= 0) break;
        }

        ans += int(cantidades.size()) - eliminados;
        cout << ans << "\n";
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int tt;
    cin >> tt;
    while(tt--){
        int n, k;
        cin >> n >> k;
        vector<int>a(n);
        unordered_map<int, int>auxMap;
        auxMap.reserve(1<<20);
        for(int i = 0; i <n; i++){
            cin >> a[i];
            auxMap[a[i]]++;
        }
        
        vector<int>cantidades;
        for(auto it: auxMap){
            cantidades.push_back(it.second);
        }
        int ans = 1;
        sort(cantidades.begin(), cantidades.end());
        cantidades.pop_back();
        int eliminados = 0;
        for(int i = 0; i < int(cantidades.size()); i++){
            if(k >= cantidades[i]) eliminados++;
            else break;

            k = k - cantidades[i];
        }

        ans += int(cantidades.size()) - eliminados;
        cout << ans << "\n";
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int tt;
    cin >> tt;
    while(tt--){
        int n, k;
        cin >> n >> k;
        vector<int>a(n);
        for(int i = 0; i <n; i++){
            cin >> a[i];
        }
        
        sort(a.begin(), a.end());
        vector<int>cantidades = {1};
        for(int i = 1; i < n; i++){
            if(a[i] == a[i - 1]) cantidades.back()++;
            else{
                cantidades.push_back(1);
            }
        }
        int ans = 1;
        sort(cantidades.begin(), cantidades.end());
        cantidades.pop_back();
        int eliminados = 0;
        for(int i = 0; i < int(cantidades.size()); i++){
            if(k >= cantidades[i]) eliminados++;
            else break;

            k = k - cantidades[i];
        }

        ans += int(cantidades.size()) - eliminados;
        cout << ans << "\n";
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int tt;
    cin >> tt;
    while(tt--){
        int n, k;
        cin >> n >> k;
        vector<int>a(n);
        unordered_map<int, int>auxMap;
        auxMap.reserve(1<<20);
        for(int i = 0; i <n; i++){
            cin >> a[i];
            auxMap[a[i]]++;
        }
        
        vector<int>cantidades;
        for(auto it: auxMap){
            cantidades.push_back(it.second);
        }
        int ans = 1;
        sort(cantidades.begin(), cantidades.end());
        cantidades.pop_back();
        int eliminados = 0;
        for(int i = 0; i < int(cantidades.size()); i++){
            int resto = k - cantidades[i];
            cantidades[i] -= k;
            if(cantidades[i]<=0) eliminados++;
            else break;

            k = resto;
            if(k <= 0) break;
        }

        ans += int(cantidades.size()) - eliminados;
        cout << ans << "\n";
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int tt;
    cin >> tt;
    while(tt--){
        int n, k;
        cin >> n >> k;
        vector<int>a(n);
        unordered_map<int, int>auxMap;
        auxMap.reserve(1<<20);
        for(int i = 0; i <n; i++){
            cin >> a[i];
            auxMap[a[i]]++;
        }
        
        vector<int>cantidades;
        for(auto it: auxMap){
            cantidades.push_back(it.second);
        }
        int ans = 1;
        sort(cantidades.begin(), cantidades.end());
        cantidades.pop_back();
        int eliminados = 0;
        for(int i = 0; i < int(cantidades.size()); i++){
            if(k >= cantidades[i]) eliminados++;
            else break;

            k = k - cantidades[i];
        }

        ans += int(cantidades.size()) - eliminados;
        cout << ans << "\n";
    }
    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


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

using namespace std;



typedef long long  ll;



// constants...

const double pi = acos(-1);

const int    mod = 1e9+7;

const int   MAX = 1e9+5;

const ll     inf = 2e18;

const int Mx=200005;





// defines...

#define MP             make_pair

#define PB             push_back

#define fi             first

#define se             second

#define sz(x)          (int)x.size()

#define all(x)         x.begin(),x.end()

#define yes            cout<<"YES"<<endl;

#define no             cout<<"NO"<<endl;





void fast() {

ios::sync_with_stdio(false);

cin.tie(NULL); cout.tie(NULL);

}



ll modpow(ll a,ll p) {ll ans=1;while(p){if(p%2)ans=(ans*a)%mod;a=(a*a)%mod;p/=2;} return ans;}

ll inverse_mod(ll n) {return modpow(n,mod-2);}

ll gcd(ll a,ll b) {

    if(b==0)

    return a;

    else

    gcd(b,a%b);

}

bool f(ll a,ll b) {

    return a>b;

}

ll max_sum_subarrays(ll ara[],ll n) {

    ll ans=0,sum=0;

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

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

        ans=max(ans,sum);

    }

    return ans;

}

ll comb(ll m, ll n) {

    ll x=max(m-n,n),ans = 1,i=1;

    for(ll j=m;j>=x+1;j--) {

        ans*=j;

        ans/=i;

        i++;

    }

    return ans;

}



bool compare(const pair<int,int>& a,const pair<int,int>& b) {

    return a.fi>b.fi;

}



bool comparepairs(const pair<pair<int,int>,int>& a,const pair<pair<int,int>,int>& b) {

    return a.fi.se<b.fi.se; 

}



void JUI() {

    int n,a,b;

    cin>>n>>a>>b;

    vector<int>jui;

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

        // if(i==n-1 && i&1!=1) jui.PB(2);

        if(i&1) jui.PB(1);

        else jui.PB(0);

    }

    if(n&1) jui[n-1]=2;

    if(b==a+1 || (a==1 && b==n) || (a%2==0 && b%2==1) || (a%2==1 && b%2==0)) {

        for(auto &i : jui) {

            cout<<i<<" ";

        }

        cout<<"\n";

        return;

    }

    if(a%2==1){

        if(n%2==0) jui[0]=2;

        jui[a]=2;

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

            if(i%2==0) jui[i]=1;

            else jui[i]=0;

        }

    }

    else{

        jui[a-1]=2;

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

            if(i&1) jui[i]=0;

            else jui[i]=1;

        }

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

            if(i&1) jui[i]=0;

            else jui[i]=1;

        }

    }

    for(auto &i : jui){

        cout<<i<<" ";

    }

    cout<<"\n";

    

}



int main() {

    int t; 

    cin>>t;

    while(t--) {

        JUI();

    }

    // JUI();

    // return 0;

}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <string>
using namespace std;

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int n;
    cin >> n;
    int odd = 0, even = 0;
    for (int w = 0; w < n; ++w) {
      int x;
      cin >> x;
      if (w % 2 == 0) {
        even += x;
      } else {
        odd += x;
      }
    }
    int ec = (n + 1) / 2, oc = n / 2;
    bool res = (odd % oc == 0) && (even % ec == 0) && (odd / oc == even / ec);
    if (res) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}


Submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <string>
using namespace std;

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int n;
    cin >> n;
    int odd = 0, even = 0, oc = 0, ec = 0;
    for (int w = 0; w < n; ++w) {
      int x;
      cin >> x;
      if (w % 2 == 0) {
        even += x;
        ec += 1;
      } else {
        odd += x;
        oc += 1;
      }
    }
    bool res = (odd % oc == 0) && (even % ec == 0) && (odd / oc == even / ec);
    res |= n < 2;
    if (res) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <string>
using namespace std;

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int n;
    cin >> n;
    int odd = 0, even = 0;
    for (int w = 0; w < n; ++w) {
      int x;
      cin >> x;
      if (w % 2 == 0) {
        even += x;
      } else {
        odd += x;
      }
    }
    int ec = (n + 1) / 2, oc = n / 2;
    bool res = (odd % oc == 0) && (even % ec == 0) && (odd / oc == even / ec);
    if (res) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <string>
using namespace std;

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int n;
    cin >> n;
    int odd = 0, even = 0, oc = 0, ec = 0;
    for (int w = 0; w < n; ++w) {
      int x;
      cin >> x;
      if (w % 2 == 0) {
        even += x;
        ec += 1;
      } else {
        odd += x;
        oc += 1;
      }
    }
    bool res = (odd % oc == 0) && (even % ec == 0) && (odd / oc == even / ec);
    res |= n < 2;
    if (res) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}


Submission (verdict: Accepted):
#include <iostream>
#include <string>
using namespace std;

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int n;
    cin >> n;
    long long odd = 0, even = 0, oc = 0, ec = 0;
    for (int w = 0; w < n; ++w) {
      long long x;
      cin >> x;
      if (w % 2 == 0) {
        even += x;
        ec += 1;
      } else {
        odd += x;
        oc += 1;
      }
    }
    bool res = (odd % oc == 0) && (even % ec == 0) && ((odd / oc) == (even / ec));
    res |= n < 2;
    if (res) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


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

#define pb push_back
#define __lg(x) (int)log2(x)
#define ep emplace
#define x first
#define y second
#define lowbit(x) (x & (-x))
#define T_T 0
#define endl "\n"
#define Endl "\n"
#define ls u << 1
#define rs u << 1 | 1
#define i128 __int128
#define nmsl cout << "输出：\t"; // 农贸税率
#define retrun return
typedef long long ll;
typedef double db;
typedef ll LL;
typedef unsigned long long ull;
typedef pair<string, int> PSI;
typedef pair<double, double> PDD;
// mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 rng(time(0));
int T = 1;

namespace DBG {
    template <class T>
    ostream& operator<<(ostream& os, const vector<T>& v) {
        os << "[ ";
        for (const auto& x : v)
            os << x << ", ";
        os << "]";
        return os;
    }

    template <class A, class B>
    ostream& operator<<(ostream& os, const map<A, B>& mp) {
        os << "{ ";
        for (const auto& [k, v] : mp)
            os << k << ":" << v << ", ";
        os << "}";
        return os;
    }

    template <class T>
    void _dbg(const char* f, T t) {
        cerr << f << " = " << t << '\n';
    }

    template <class A, class... B>
    void _dbg(const char* f, A a, B... b) {
        while (*f != ',')
            cerr << *f++;
        cerr << " = " << a << ", ";
        _dbg(f + 1, b...);
    }
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
}
using namespace DBG;

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int N = 2e5 + 5, M = 2e3 + 5;
const ll mod = 1e9 + 7;

#define int ll
#define double long double
typedef pair<int, int> PII;
ll n, m, x, y, k, l, r;
int a[N], b[N];

void jiangly()
{
    cin >> n >> m;
    int a = n, b = n ^ 1, c = n ^ 2;
    priority_queue<int>q;
    q.push(n);
    q.push(n^1);
    q.push(n^2);
    for (int i = 2; i <= 30; i++)
        if (!(n & (1 << i)))
        {
            int t = q.top();
            q.pop();
            if (t + (1 << i) <= m)t += (1 << i);
            q.push(t);
        }
    while (q.size())cout << q.top() << " ", q.pop();
    cout << endl;

//0011 1001 1000 1001 1010 0100 1000 1001
//0001 0110 0110 0010 0101 1001 0001 0110
//          1011 1111 1000 0110 0111 0010

//0011 1001 0011 0110 0010 0010 1111 1011
}
/*

*/

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //cout << fixed << setprecision(3);
    cin >> T;
    while (T--)jiangly();
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Memory limit exceeded on test 4):
//jai hanuman

#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 nline "\n"

#define pb push_back

#define ppb pop_back

#define mp make_pair

#define ff first

#define ss second

#define PI 3.141592653589793238462

#define set_bits __builtin_popcountll

#define sz(x) ((int)(x).size())

#define all(x) (x).begin(), (x).end()

 

typedef long long ll;

typedef unsigned long long ull;

typedef long double lld;

// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

 

#ifndef ONLINE_JUDGE

#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;

#else

#define debug(x)

#endif

 

void _print(ll t) {cerr << t;}

void _print(int t) {cerr << t;}

void _print(string t) {cerr << t;}

void _print(char t) {cerr << t;}

void _print(lld t) {cerr << t;}

void _print(double t) {cerr << t;}

void _print(ull t) {cerr << t;}

 

template <class T, class V> void _print(pair <T, V> p);

template <class T> void _print(vector <T> v);

template <class T> void _print(set <T> v);

template <class T, class V> void _print(map <T, V> v);

template <class T> void _print(multiset <T> v);

template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}

template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

 

ll n;

vector<vector<int>> dp; 



bool solve(ll i, string s, ll sum) {

    if (i == n) {

        return (sum % 9 == 0);

    }



    if (dp[i][sum] != -1) {

        return dp[i][sum];  

    }



    bool op1 = solve(i + 1, s, (sum + (s[i] - '0')) % 9); 



    bool op2 = false;

    if (s[i] == '2') {

        op2 = solve(i + 1, s, (sum + 4) % 9);

    } else if (s[i] == '3') {

        op2 = solve(i + 1, s, (sum + 9) % 9);

    }



    return dp[i][sum] = (op1 || op2);  

}



int main() {

#ifndef ONLINE_JUDGE

    freopen("error.txt", "w", stderr);

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

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

#endif

    fastio();

    ll t;

    cin >> t;

    while (t--) {

        string s;

        cin >> s;

        n = s.size();



        dp.assign(n, vector<int>(10, -1));



        if (solve(0, s, 0)) {

            cout << "YES" << endl;

        } else {

            cout << "NO" << endl;

        }

    }

    return 0;

}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <stdio.h>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <climits>
#include <cstdio>
#include <cmath>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void flash(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

#define all(a)   a.begin(),a.end()
#define all_r(a)   a.rbegin(),a.rend()

// bool is_suffix(string a, string b)
// {
//     reverse(a.begin(), a.end());
//     reverse(b.begin(), b.end());

//     for(int i = 0; i < b.size(); i++)
//     {
//         if(a[i] != b[i])
//             return false;
//     }

//     return true;
// }

// bool ispalin(vector<int>& v)
// {
//     for(int i = 0; i < v.size() / 2; i++)
//     {
//         if(v[i] != v[v.size() - i - 1])
//             return false;
//     }

//     return true;
// }



int main(void)
{
    flash();

    int t;
    cin>>t;

    while(t--)
    {
        int n, k;
        cin>>n>>k;

        vector<ll> v(n);
        for(int i = 0; i < n; i++)
            cin>>v[i];

        sort(all(v));

        int mx = 0;
        int cnt = 1;
        for(int i = 1; i < n; i++)
        {
            if(v[i] == v[i-1])
                cnt++;
            else
            {
                mx = max(cnt, mx);
                cnt = 1;
            }
        }

        for(int i = 0; i < n && k > 0; i++)
        {
            if(v[i] != mx)
            {
                v[i] = mx;
                k--;
            }
        }

        unordered_set<ll> s;
        for(int i = 0; i < n; i++)
        {
            s.insert(v[i]);
        }

        cout<<s.size()<<'\n';
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n ;i++){
            int x=min(a[i],a[i+1]);
            if(i!=n-1){
                a[i]=a[i]-x;
                a[i+1]=a[i+1]-x;
            }
        }
        bool check=0;
        for(int i=0;i<n;i++){
           if(a[i]<=a[i+1]){
            check=1;
           }
          else{
            check =0 ;
            break;
          }
        }
        if(check){
            cout<<"YES";
        }
        else cout <<"NO";
        if(t>0)
        cout <<"\n";
    }
    return 0;

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

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n ;i++){
            if(i!=n-1){
                int x=min(a[i],a[i+1]);

                a[i]=a[i]-x;
                a[i+1]=a[i+1]-x;
            }

        }
        bool check=0;
        for(int i=0;i<n;i++){
           if(a[i]<=a[i+1]){
            check=1;
           }
          else{
            check =0 ;
            break;
          }
        }
        if(check){
            cout<<"YES";
        }
        else cout <<"NO";
        if(t>0)
        cout <<"\n";
    }
    return 0;

}

Submission (verdict: Accepted):
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n ;i++){
            if(i!=n-1){
                int x=min(a[i],a[i+1]);

                a[i]=a[i]-x;
                a[i+1]=a[i+1]-x;
            }

        }
        bool check=0;
        for(int i=0;i<n;i++){
           if(i!=n-1){
            if(a[i]<=a[i+1]){
            check=1;
           }
          else{
            check =0 ;
            break;
          }
           }
        }
        if(check){
            cout<<"YES";
        }
        else cout <<"NO";
        if(t>0)
        cout <<"\n";
    }
    return 0;

}