ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    int t = 1;
    std::cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        for (int i = 0; i < n; ++i)
        {
            int value = s[i] - '0';
            int mx = value;
            int j = i;
            int biggest = j;
            for (j; j < (i + 8) && j < n; ++j)
            {
                if ((s[j] - '0' - (j - i)) > mx)
                {
                    mx = s[j] - '0' - (j - i);
                    biggest = j;
                }
            }
            reverse(s.begin() + i, s.begin() + biggest + 1);
            reverse(s.begin() + i + 1, s.begin() + biggest + 1);
            s[i] = mx + '0';
        }
        cout << s << '\n';
    }
    return 0;
}

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

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    int t = 1;
    std::cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        for (int i = 0; i < n; ++i)
        {
            int value = s[i] - '0';
            int mx = value;
            int j = i;
            int biggest = j;
            for (j; j < (i + 9) && j < n; ++j)
            {
                if ((s[j] - '0' - (j - i)) > mx)
                {
                    mx = s[j] - '0' - (j - i);
                    biggest = j;
                }
            }
            reverse(s.begin() + i, s.begin() + biggest + 1);
            reverse(s.begin() + i + 1, s.begin() + biggest + 1);
            s[i] = mx + '0';
        }
        cout << s << '\n';
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    int t = 1;
    std::cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        for (int i = 0; i < n; ++i)
        {
            int value = s[i] - '0';
            int mx = value;
            int j = i;
            int biggest = j;
            for (j; j < (i + 8); ++j)
            {
                if (s[j] - '0' - (j - i) > mx)
                {
                    mx = s[j] - '0' - (j - i);
                    biggest = j;
                }
            }
            reverse(s.begin() + i, s.begin() + biggest + 1);
            if (biggest != i)
                reverse(s.begin() + i + 1, s.begin() + biggest + 1);
            s[i] = mx + '0';
        }
        cout << s << '\n';
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    int t = 1;
    std::cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        for (int i = 0; i < n; ++i)
        {
            int value = s[i] - '0';
            int mx = value;
            int j = i;
            int biggest = j;
            for (j; j < (i + 8); ++j)
            {
                if ((s[j] - '0' - (j - i)) > mx)
                {
                    mx = s[j] - '0' - (j - i);
                    biggest = j;
                }
            }
            reverse(s.begin() + i, s.begin() + biggest + 1);
            reverse(s.begin() + i + 1, s.begin() + biggest + 1);
            s[i] = mx + '0';
        }
        cout << s << '\n';
    }
    return 0;
}

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

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    int t = 1;
    std::cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        for (int i = 0; i < n; ++i)
        {
            int value = s[i] - '0';
            int mx = value;
            int j = i;
            int biggest = j;
            for (j; j < (i + 8) && j < n; ++j)
            {
                if ((s[j] - '0' - (j - i)) > mx)
                {
                    mx = s[j] - '0' - (j - i);
                    biggest = j;
                }
            }
            reverse(s.begin() + i, s.begin() + biggest + 1);
            reverse(s.begin() + i + 1, s.begin() + biggest + 1);
            s[i] = mx + '0';
        }
        cout << s << '\n';
    }
    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")

#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")

//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx")

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

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

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

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

#define pb emplace_back

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

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



int rnd(int a, int b) {

	return rng() % (b - a + 1) + a;

}



string to_string(string s) { return s; }

template <typename T> string to_string(T v) {

  bool first = true;

  string res = "[";

  for (const auto &x : v) {

    if (!first)

      res += ", ";

    first = false;

    res += to_string(x);

  }

  res += "]";

  return res;

}



void dbg_out() { cerr << endl; }

template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {

  cerr << ' ' << to_string(H);

  dbg_out(T...);

}



#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)



template<class T> inline void chkmin(T& x, T y) { if (y < x) x = y; }

template<class T> inline void chkmax(T& x, T y) { if (y > x) x = y; }



using i64 = long long;

using u64 = unsigned long long;

using u32 = unsigned;

typedef long long ll;



const i64 INF = 1e18;

const int oo = 1e9;

const int mod = 1e9 + 7;

const int MX = 200005;



void solve() {

	int n, x, y;

	cin >> n >> x >> y;

	x --;

	y --;

	vector<int> a(n);

	if (abs(x - y) == 1) {

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

			a[i] = (i + 1) % 2;

		}

	} else {

		a[x] = 1, a[y] = 2;

		int flg = 0;

		for (int i = (y + 1) % n; i != x; i = (i + 1) % n) {

			a[i] = flg;

			flg ^= 1;

		}

		flg = 0;

		for (int i = (x + 1) % n; i != y; i = (i + 1) % n) {

			a[i] = flg;

			flg ^= 1;

		}

	}

	for (auto v: a) {

		cout << v << ' ';

	}

	cout << endl;

}



int main() {

#ifndef ONLINE_JUDGE

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

//	freopen("out.txt", "w", stdout);

#endif



	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);



	int Tc = 1;

	cin >> Tc;

	while (Tc --) {

		solve();

	}

	return 0;

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


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second>b.second;
}
void solve(ll tc)
{
    ll n,i,x,y,s=0,qq,ww,s2=0,ee;
    cin>>n;
    vector<pair<ll,ll>>p(n+3);
    for(i=1;i<=n;i++) p[i].first=i,p[i].second=0;
    vector<set<ll>> ps(n+3);
    for(i=1;i<n;i++){
        cin>>x>>y;
        p[x].second++;
        p[y].second++;
        ps[x].insert(y);
        ps[y].insert(x);
    }
    sort(p.begin(),p.end(),cmp);

    s=p[0].second;
    qq=p[0].first;
    for(i=1;i<n;i++){
        ww=p[i].second;
        ee=p[i].first;
        if(ps[ee].count(qq)) ww--;
        s2=max(s2,ww);

    }
    cout<<s+s2-1<<endl;






}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1;
    cin>>tc;
    for(ll i=1; i<=tc; i++)
    {
        solve(i);
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second>b.second;
}
void solve(ll tc)
{
    ll n,i,x,y,s=0,qq,ww,s2=0,ee;
    cin>>n;
    vector<pair<ll,ll>>p(n+3);
    for(i=1;i<=n;i++) p[i].first=i,p[i].second=0;
    vector<set<ll>> ps(n+3);
    for(i=1;i<n;i++){
        cin>>x>>y;
        p[x].second++;
        p[y].second++;
        ps[x].insert(y);
        ps[y].insert(x);
    }
    sort(p.begin(),p.end(),cmp);

    s=p[0].second;
    qq=p[0].first;
    for(i=1;i<n;i++){
        ww=p[i].second;
        ee=p[i].first;
        if(ps[ee].count(qq)) ww--;
        s2=max(s2,ww);

    }
    cout<<s+s2-1<<endl;






}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1;
    cin>>tc;
    for(ll i=1; i<=tc; i++)
    {
        solve(i);
    }
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second>b.second;
}
void solve(ll tc)
{
    ll n,i,x,y,s=0,qq,ww,s2=0,ee,m;
    cin>>n;
    vector<pair<ll,ll>>p(n+9);
    for(i=1;i<=n;i++) p[i].first=i,p[i].second=0;
    vector<set<ll>> ps(n+3);
    for(i=1;i<n;i++){
        cin>>x>>y;
        p[x].second++;
        p[y].second++;
        ps[x].insert(y);
        ps[y].insert(x);
    }
    sort(p.begin(),p.end(),cmp);

    s=p[0].second;
    qq=p[0].first;
    m=min(n,s+2);
    for(i=1;i<m;i++){
        ww=p[i].second;
        ee=p[i].first;
        if(ps[ee].count(qq)) ww--;
        s2=max(s2,ww);

    }
    ll ans=s+s2-1;
    s=p[1].second;
    qq=p[1].first;
    m=min(n,s+2);
    for(i=2;i<m;i++){
        ww=p[i].second;
        ee=p[i].first;
        if(ps[ee].count(qq)) ww--;
        s2=max(s2,ww);

    }
    ans=max(ans,s+s2-1);
    cout<<s+s2-1<<endl;






}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1;
    cin>>tc;
    for(ll i=1; i<=tc; i++)
    {
        solve(i);
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second>b.second;
}
void solve(ll tc)
{
    ll n,i,x,y,s=0,qq,ww,s2=0,ee,m;
    cin>>n;
    vector<pair<ll,ll>>p(n+9);
    for(i=1;i<=n;i++) p[i].first=i,p[i].second=0;
    vector<set<ll>> ps(n+3);
    for(i=1;i<n;i++){
        cin>>x>>y;
        p[x].second++;
        p[y].second++;
        ps[x].insert(y);
        ps[y].insert(x);
    }
    sort(p.begin(),p.end(),cmp);

    s=p[0].second;
    qq=p[0].first;
    m=min(n,s+2);
    for(i=1;i<m;i++){
        ww=p[i].second;
        ee=p[i].first;
        if(ps[ee].count(qq)) ww--;
        s2=max(s2,ww);

    }
    ll ans=s+s2-1;
    s=p[1].second;
    qq=p[1].first;
    m=min(n,s+2);
    for(i=2;i<m;i++){
        ww=p[i].second;
        ee=p[i].first;
        if(ps[ee].count(qq)) ww--;
        s2=max(s2,ww);

    }
    ans=max(ans,s+s2-1);
    cout<<s+s2-1<<endl;






}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1;
    cin>>tc;
    for(ll i=1; i<=tc; i++)
    {
        solve(i);
    }
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second>b.second;
}
void solve(ll tc)
{
    ll n,i,x,y,s=0,qq,ww,s2=0,ee,m;
    cin>>n;
    vector<pair<ll,ll>>p(n+9);
    for(i=1;i<=n;i++) p[i].first=i,p[i].second=0;
    vector<set<ll>> ps(n+3);
    for(i=1;i<n;i++){
        cin>>x>>y;
        p[x].second++;
        p[y].second++;
        ps[x].insert(y);
        ps[y].insert(x);
    }
    sort(p.begin(),p.end(),cmp);

    s=p[0].second;
    qq=p[0].first;
    m=min(n,s+2);
    for(i=1;i<m;i++){
        ww=p[i].second;
        ee=p[i].first;
        if(ps[ee].count(qq)) ww--;
        s2=max(s2,ww);

    }
    ll ans=s+s2-1;
    s=p[1].second;
    qq=p[1].first;
    m=min(n,s+2);
    for(i=2;i<m;i++){
        ww=p[i].second;
        ee=p[i].first;
        if(ps[ee].count(qq)) ww--;
        s2=max(s2,ww);

    }
    ans=max(ans,s+s2-1);
    cout<<ans<<endl;






}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1;
    cin>>tc;
    for(ll i=1; i<=tc; i++)
    {
        solve(i);
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


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

string toBinary(long long num) {
    bitset<64> bin(num); 
    return bin.to_string();  
}

long long toLongLong(const string& bin) {
    bitset<64> b(bin);
    return b.to_ullong();  
}

void solve() {
    int l, r;
    cin >> l >> r;
    
    string s1 = toBinary(l);
    string s2 = toBinary(r);
    
    string s3 = "", s4 = "", s5 = "";
    int cnt = 0;
    if(l==r){
        cout<<0
<<endl;    }
    
    for (int i = 0; i < 64; i++) {
        if (s1[i] == s2[i]) {
           
            s4 += s1[i];
            s5 += s2[i];
            cnt++;
        } else {
            break;
        }
    }

    
     
     s4+='1';
     s5+='0';
     

    for (int i = cnt+1; i < 64; i++) {
        
        s4 += '0';
        s5 += '1';
    }
     

    s4[s4.length()-1]='0';
    long long res2 = toLongLong(s4);
    long long res3 = toLongLong(s5);
    s3=s5;
    s3[s3.length()-1]='0';
    long long res1 = toLongLong(s3);
    cout << res1 << " " << res2 << " " << res3 << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

string toBinary(long long num) {
    bitset<64> bin(num); 
    return bin.to_string();  
}

long long toLongLong(const string& bin) {
    bitset<64> b(bin);
    return b.to_ullong();  
}

void solve() {
    int l, r;
    cin >> l >> r;
    
    string s1 = toBinary(l);
    string s2 = toBinary(r);
    
    string s3 = "", s4 = "", s5 = "";
    int cnt = 0;
    if(l==r){
        cout<<0
<<endl;    }
    
    for (int i = 0; i < 64; i++) {
        if (s1[i] == s2[i]) {
           
            s4 += s1[i];
            s5 += s2[i];
            cnt++;
        } else {
            break;
        }
    }

    
     
     s4+='1';
     s5+='0';
     

    for (int i = cnt+1; i < 64; i++) {
        
        s4 += '0';
        s5 += '1';
    }
     

    s4[s4.length()-1]='0';
    long long res2 = toLongLong(s4);
    long long res3 = toLongLong(s5);
    s3=s5;
    s3[s3.length()-1]='0';
    long long res1 = toLongLong(s3);
    cout << res1 << " " << res2 << " " << res3 << endl;
}

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


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

string toBinary(long long num) {
    bitset<64> bin(num); 
    return bin.to_string();  
}

long long toLongLong(const string& bin) {
    bitset<64> b(bin);
    return b.to_ullong();  
}

void solve() {
    int l, r;
    cin >> l >> r;
    
    string s1 = toBinary(l);
    string s2 = toBinary(r);
    
    string s3 = "", s4 = "", s5 = "";
    int cnt = 0;
    if(l==r){
        cout<<0
<<endl;    }
    
    for (int i = 0; i < 64; i++) {
        if (s1[i] == s2[i]) {
           
            s4 += s1[i];
            s5 += s2[i];
            cnt++;
        } else {
            break;
        }
    }

    
     
     s4+='1';
     s5+='0';
     

    for (int i = cnt+1; i < 64; i++) {
        
        s4 += '0';
        s5 += '1';
    }
     

    s4[s4.length()-1]='0';
    long long res2 = toLongLong(s4);
    long long res3 = toLongLong(s5);
    s3=s5;
    s3[s3.length()-1]='0';
    long long res1 = toLongLong(s3);
    if(res1==0 && l>0){
        res1=r;
    }
    cout << res1 << " " << res2 << " " << res3 << endl;

   
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

string toBinary(long long num) {
    bitset<64> bin(num); 
    return bin.to_string();  
}

long long toLongLong(const string& bin) {
    bitset<64> b(bin);
    return b.to_ullong();  
}

void solve() {
    int l, r;
    cin >> l >> r;
    
    string s1 = toBinary(l);
    string s2 = toBinary(r);
    
    string s3 = "", s4 = "", s5 = "";
    int cnt = 0;
    if(l==r){
        cout<<0
<<endl;    }
    
    for (int i = 0; i < 64; i++) {
        if (s1[i] == s2[i]) {
           
            s4 += s1[i];
            s5 += s2[i];
            cnt++;
        } else {
            break;
        }
    }

    
     
     s4+='1';
     s5+='0';
     

    for (int i = cnt+1; i < 64; i++) {
        
        s4 += '0';
        s5 += '1';
    }
     

    s4[s4.length()-1]='0';
    long long res2 = toLongLong(s4);
    long long res3 = toLongLong(s5);
    s3=s5;
    s3[s3.length()-1]='0';
    long long res1 = toLongLong(s3);
    if(res1==0 && l>0){
        res1=r;
    }
    cout << res1 << " " << res2 << " " << res3 << endl;

   
}

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


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

string toBinary(long long num) {
    bitset<64> bin(num); 
    return bin.to_string();  
}

long long toLongLong(const string& bin) {
    bitset<64> b(bin);
    return b.to_ullong();  
}

void solve() {
    int l, r;
    cin >> l >> r;
    
    string s1 = toBinary(l);
    string s2 = toBinary(r);
    
    string s3 = "", s4 = "", s5 = "";
    int cnt = 0;
    if(l==r){
        cout<<0
<<endl;    }
    
    for (int i = 0; i < 64; i++) {
        if (s1[i] == s2[i]) {
           
            s4 += s1[i];
            s5 += s2[i];
            cnt++;
        } else {
            break;
        }
    }

    
     
     s4+='1';
     s5+='0';
     

    for (int i = cnt+1; i < 64; i++) {
        
        s4 += '0';
        s5 += '1';
    }
     

    s4[s4.length()-1]='0';
    long long res2 = toLongLong(s4);
    long long res3 = toLongLong(s5);
    s3=s5;
    s3[s3.length()-1]='0';
    long long res1 = toLongLong(s3);
    if(res1<l){
        res1=r;
    }
     if(res1==0 && l>0){
        res1=r;
    }

    cout << res1 << " " << res2 << " " << res3 << endl;

   
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
const int MAX_N = 2e5 + 9;

int t , n , a[MAX_N];


int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n;
        for(int i = 1; i <= n; i++)
            cin >> a[i];
        if(a[1] > a[2])
        {
            cout << "NO" << endl;
            continue;
        }

        bool check = true;
        int cha = a[2] - a[1];
        for(int i = 3; i <= n; i++)
        {
            if(cha <= a[3] && cha)
                cha = a[3] - cha;
            else
                check = false;
        }
        if(!check)
            cout << "NO" << endl;
        else
            cout << "YES" << endl;
    }
    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>
#include <algorithm>
using namespace std;
const int MAX_N = 2e5 + 9;

int t , n , a[MAX_N];


int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n;
        for(int i = 1; i <= n; i++)
            cin >> a[i];
        if(a[1] > a[2])
        {
            cout << "NO" << endl;
            continue;
        }

        bool check = true;
        int cha = a[2] - a[1];
        for(int i = 3; i <= n; i++)
        {
            if(cha <= a[3] && cha)
                cha = a[3] - cha;
            else
                check = false;
        }
        if(!check)
            cout << "NO" << endl;
        else
            cout << "YES" << endl;
    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
const int MAX_N = 2e5 + 9;

int t , n , a[MAX_N];


int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n;
        for(int i = 1; i <= n; i++)
            cin >> a[i];
        if(a[1] > a[2])
        {
            cout << "no" << endl;
            continue;
        }

        bool check = true;
        for(int i = 2; i <= n; i++)
        {
            if(a[i - 1] < a[i])
                a[i] -= a[i - 1];
            else
                check = false;
        }
        cout << (check == true ? "yes" : "no") << endl;
    }
    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>
#include <algorithm>
using namespace std;
const int MAX_N = 2e5 + 9;

int t , n , a[MAX_N];


int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n;
        for(int i = 1; i <= n; i++)
            cin >> a[i];
        if(a[1] > a[2])
        {
            cout << "no" << endl;
            continue;
        }

        bool check = true;
        for(int i = 2; i <= n; i++)
        {
            if(a[i - 1] < a[i])
                a[i] -= a[i - 1];
            else
                check = false;
        }
        cout << (check == true ? "yes" : "no") << endl;
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
const int MAX_N = 2e5 + 9;

int t , n , a[MAX_N];


int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n;
        for(int i = 1; i <= n; i++)
            cin >> a[i];

        bool check = true;
        for(int i = 2; i <= n; i++)
        {
            if(a[i - 1] <= a[i])
                a[i] -= a[i - 1];
            else
                check = false;
        }
        cout << (check == true ? "yes" : "no") << endl;
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

#define debug(...)

void solve(){
    //input
    int n;
    cin >> n;
    vector<int> a(n,0);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    //computation
    for(int i = 0; i < n-2; i++){
        if(a[i] > a[i+1]){
            cout<<"NO\n";
            return;
        }
        else{
            int sub = min(a[i],a[i+1]);
            a[i] -= sub;
            a[i+1] -= sub;
        }
    }
    cout << "YES\n";
}

int main() {
    int t = 1;
    cin >> t;

    for (int tc = 1; tc <= t; tc++) {
        debug("Testcase", tc);
        solve();
        debug();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

#define debug(...)

void solve(){
    //input
    int n;
    cin >> n;
    vector<int> a(n,0);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    //computation
    for(int i = 0; i < n-1; i++){
        if(a[i] > a[i+1]){
            cout<<"NO\n";
            return;
        }
        else{
            int sub = min(a[i],a[i+1]);
            a[i] -= sub;
            a[i+1] -= sub;
        }
    }
    cout << "YES\n";
}

int main() {
    int t = 1;
    cin >> t;

    for (int tc = 1; tc <= t; tc++) {
        debug("Testcase", tc);
        solve();
        debug();
    }
    return 0;
}