ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define nl "\n"
#define INF 1e18

void mainCode(){
    ll n=0,k;
    cin >> n;
    ll a2=0,a3=0,sum=0;
    while(n>0){
        sum+=n%10;
        if(n%10 == 2) a2++;
        if(n%10 == 3) a3++;
        n=n/10;
    }
    for(ll i=0;i<=a2;i++){
        for(ll j=0;j<=a3;j++){
            if((sum+i*2+j*6) % 9 == 0){
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
    
}
int main()
{
    int tc=0;
    cin >> tc;
    while(tc--)
    {
        mainCode();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define nl "\n"
#define INF 1e18

void mainCode(){
    ll n=0,k;
    cin >> n;
    ll a2=0,a3=0,sum=0;
    while(n>0){
        sum+=n%10;
        if(n%10 == 2) a2++;
        if(n%10 == 3) a3++;
        n=n/10;
    }
    ll z=9;
    for(ll i=0;i<=min(z,a2);i++){
        for(ll j=0;j<=min(z,a3);j++){
            if((sum+i*2+j*6) % 9 == 0){
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
    
}
int main()
{
    int tc=0;
    cin >> tc;
    while(tc--)
    {
        mainCode();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define nl "\n"
#define INF 1e18

void mainCode(){
    ll n=0,k;
    cin >> n;
    ll a2=0,a3=0,sum=0;
    while(n>0){
        sum+=n%10;
        if(n%10 == 2) a2++;
        if(n%10 == 3) a3++;
        n=n/10;
    }
    ll z=9;
    for(ll i=0;i<=min(z,a2);i++){
        for(ll j=0;j<=min(z,a3);j++){
            if((sum+i*2+j*6) % 9 == 0){
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
    
}
int main()
{
    int tc=0;
    cin >> tc;
    while(tc--)
    {
        mainCode();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define nl "\n"
#define INF 1e18

void mainCode(){
    string s; 
    cin>>s; 
    ll sum=0,a2=0,a3=0;
    for(auto k:s){
      int q=k-'0';
      sum+=q;
      if(q==2) a2++;
      else if(q==3) a3++;
    }
    ll z=9;
    for(ll i=0;i<=min(z,a2);i++){
        for(ll j=0;j<=min(z,a3);j++){
            if((sum+i*2+j*6) % 9 == 0){
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
    
}
int main()
{
    int tc=0;
    cin >> tc;
    while(tc--)
    {
        mainCode();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define nl "\n"
#define INF 1e18

void mainCode(){
    ll n=0,k;
    cin >> n;
    ll a2=0,a3=0,sum=0;
    while(n>0){
        sum+=n%10;
        if(n%10 == 2) a2++;
        if(n%10 == 3) a3++;
        n=n/10;
    }
    ll req= sum%9;
    for(ll i=0;i<=a2;i++){
        for(ll j=0;j<=a3;j++){
            if((req+(i*2+j*6)) % 9 ==0){
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
    
}
int main()
{
    int tc=0;
    cin >> tc;
    while(tc--)
    {
        mainCode();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define nl "\n"
#define INF 1e18

void mainCode(){
    ll n=0,k;
    cin >> n;
    ll a2=0,a3=0,sum=0;
    while(n>0){
        sum+=n%10;
        if(n%10 == 2) a2++;
        if(n%10 == 3) a3++;
        n=n/10;
    }
    ll req= sum%9;
    for(ll i=0;i<=a2;i++){
        for(ll j=0;j<=a3;j++){
            if((req+(i*2+j*6)) % 9 ==0){
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
    
}
int main()
{
    int tc=0;
    cin >> tc;
    while(tc--)
    {
        mainCode();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define nl "\n"
#define INF 1e18

void mainCode(){
    ll n=0,k;
    cin >> n;
    ll a2=0,a3=0,sum=0;
    while(n>0){
        sum+=n%10;
        if(n%10 == 2) a2++;
        if(n%10 == 3) a3++;
        n=n/10;
    }
    for(ll i=0;i<=a2;i++){
        for(ll j=0;j<=a3;j++){
            if((sum+i*2+j*6) % 9 == 0){
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
    
}
int main()
{
    int tc=0;
    cin >> tc;
    while(tc--)
    {
        mainCode();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

using namespace std;

int n, t;

void solve() {
    scanf("%d", &n);
    int a[n], ans = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        ans += a[i];
    }

    for (int i = 1; i < n; i++) {
        int curr = 0;
        for (int j = n - 1; j >= i; j--) {
            a[j] -= a[j - 1];
            curr += a[j];
        }
        ans = max(ans, abs(curr));
    }

    printf("%d\n", ans);
}

int main() {
    scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

using namespace std;

int n, t;

void solve() {
    scanf("%d", &n);
    int a[n], ans = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        ans += a[i];
    }

    for (int i = 1; i < n; i++) {
        int curr = 0;
        for (int j = n - 1; j >= i; j--) {
            a[j] -= a[j - 1];
            curr += a[j];
        }
        ans = max(ans, abs(curr));
    }

    printf("%d\n", ans);
}

int main() {
    scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}


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

using namespace std;

int n, t;

void solve() {
    scanf("%d", &n);
    int a[n];

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        ans += a[i];
    }

    for (int i = 1; i < n; i++) {
        long long curr = 0;
        for (int j = n - 1; j >= i; j--) {
            a[j] -= a[j - 1];
            curr += a[j];
        }
        ans = max(ans, abs(curr));
    }

    printf("%lli\n", ans);
}

int main() {
    scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

using namespace std;

int n, t;

void solve() {
    scanf("%d", &n);
    int a[n];

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        ans += a[i];
    }

    for (int i = 1; i < n; i++) {
        long long curr = 0;
        for (int j = n - 1; j >= i; j--) {
            a[j] -= a[j - 1];
            curr += a[j];
        }
        ans = max(ans, abs(curr));
    }

    printf("%lli\n", ans);
}

int main() {
    scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}


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

using namespace std;

int n, t;

void solve() {
    scanf("%d", &n);
    long long a[n];

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lli", a + i);
        ans += a[i];
    }

    for (int i = 1; i < n; i++) {
        long long curr = 0;
        for (int j = n - 1; j >= i; j--) {
            a[j] -= a[j - 1];
            curr += a[j];
        }
        ans = max(ans, abs(curr));
    }

    printf("%lli\n", ans);
}

int main() {
    scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


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

using namespace std;



namespace {

#define L(i, j, k) for(int i = (j), _e = (k); i <= _e; ++i)

#define R(i, j, k) for(int i = (j), _e = (k); i >= _e; --i)

#define gc cin.get

#define pc cout.put

#define inl static inline

#define pr(x) (cerr << (x))

#define db(...) fprintf(stderr, __VA_ARGS__)

#define _assume(x) { if (!(x)) __builtin_unreachable(); }

	typedef long long ll; typedef unsigned un; typedef unsigned long long ull; typedef pair<int, int> pii;

	template<typename T = int> inl T read() { char c; while ((c = gc()) <= ' '); int f = (c != '-' ? 1 : (c = gc(), -1)); T a = c - '0'; while ((c = gc()) >= '0') a = a * 10 + c - '0'; return a * f; } template<typename T> inl void read(T & a) { a = read<T>(); } inl void read(char & c) { while ((c = gc()) <= ' '); } inl int rstr(char * s) { char * t = s; while ((*t = gc()) <= ' '); while ((*++t = gc()) > ' '); *t = '\0'; return t - s; } template<typename T, typename ... A> inl void read(T & a, A & ... args) { read(a), read(args...); } template<typename T> inl void putz(T x) { _assume(x >= 0); static char b[40]; int p = 0; do b[p++] = x % 10 + '0'; while (x /= 10); do pc(b[--p]); while (p); } template<typename T> inl void put(T x) { putz(x < 0 ? (pc('-'), -x) : x); } template<typename T, typename ... A> inl void put(T x, A ... args) { put(x), pc(' '), put(args...); } inl void putln() { pc('\n'); } template<typename ... A> inl void putln(A ... args) { put(args...), pc('\n'); } template<typename T> inl void out(const T & x) { pr(x); } template<typename T> inl void out(T b, T e) { T i = b; pr(*i); while (++i != e) pr(' '), pr(*i); } template<typename T_, typename T> inl void out(const T_ & s, T b, T e) { out(s), out(b, e); } inl void outln() { pr('\n'); } template<typename ... A> inl void outln(A ... args) { out(args...), pr('\n'); } inl	void ps(const char * s) { while (*s != '\0') pc(*s++); } inl void ps(const string & s) { ps(s.c_str()); } inl void yes() { ps("yes\n"); } inl void Yes() { ps("Yes\n"); } inl void YES() { ps("YES\n"); } inl void no() { ps("no\n"); } inl void No() { ps("No\n"); } inl void NO() { ps("NO\n"); }

}



constexpr int N = 2e5 + 5;

int n, m;

int a[N], b[N];



void solve() {

	read(n, m); ll s1 = 0, s2 = 0;

	 L(i, 1, n) read(a[i]), s1 += a[i];

	a[n + 1] = 0; sort(a + 1, a + n + 1);

	L(i, 1, m) read(b[i]), s2 += b[i];

	if (s1 != s2) return No();

	b[m + 1] = 0; sort(b + 1, b + m + 1);



	L(i, 1, m) {

		int p = lower_bound(a + 1, a + n + 1, b[i]) - a;

		if (a[p] == b[i]) a[p] = b[i] = 0;

	}



	int k = 1;

	L(i, 1, m) {

		if (b[i] == 0) continue;

		if (a[k] > b[i]) return No();

		ll s = a[k];

		while (k < n && (a[k + 1] == 0 || abs(a[k + 1] - s) < 2)) {

			s += a[++k];

			if (s == b[i]) break;

		}

		if (s == b[i]) ++k;

		else return No();

	}

	Yes();

}



int main() {

	ios::sync_with_stdio(false); cin.tie(0);

	int t = read(); while (t--) solve();

}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string a,b,c;
    cin >> a >> b >> c;
    int n,m;
    n=a.size();m=b.size();
    int dp[n+1][m+1];
    dp[0][0]=0;
    for(int i=0;i<n;i++)
    {
        dp[i+1][0]=dp[i][0]+(a[i]!=c[i]);
    }
    for(int j=0;j<n;j++)
    {
        dp[0][j+1]=dp[0][j]+(b[j]!=c[j]);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            dp[i][j]=min(dp[i-1][j]+(a[i-1]!=c[i+j-1]),dp[i][j-1]+(b[j-1]!=c[i+j-1]));
        }
    }
    cout << dp[n][m] << endl;
}
signed main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--)
    solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string a,b,c;
    cin >> a >> b >> c;
    int n,m;
    n=a.size();m=b.size();
    int dp[n+1][m+1];
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) dp[i][j]=1e9;
    for(int i=0;i<n;i++)
    {
        dp[i+1][0]=dp[i][0]+(a[i]!=c[i]);
    }
    for(int j=0;j<n;j++)
    {
        dp[0][j+1]=dp[0][j]+(b[j]!=c[j]);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            dp[i][j]=min(dp[i-1][j]+(a[i-1]!=c[i+j-1]),dp[i][j-1]+(b[j-1]!=c[i+j-1]));
        }
    }
    cout << dp[n][m] << endl;
}
signed main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--)
    solve();
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string a,b,c;
    cin >> a >> b >> c;
    int n,m;
    n=a.size();m=b.size();
    int dp[n+1][m+1];
    dp[0][0]=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(!i&&!j) continue;
            dp[i][j]=min(dp[i-1][j]+(a[i-1]!=c[i+j-1]),dp[i][j-1]+(b[j-1]!=c[i+j-1]));
        }
    }
    cout << dp[n][m] << endl;
}
signed main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--)
    solve();
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string a,b,c;
    cin >> a >> b >> c;
    int n=a.size(),m=b.size();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)for(int j=0;j<=m;j++) dp[i][j]=1e9;
    dp[0][0]=0;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++)
        {
            if(!i&&!j) continue;
            if(i) dp[i][j]=dp[i-1][j]+(a[i-1]!=c[i+j-1]);
            if(j) dp[i][j]=min(dp[i][j],dp[i][j-1]+(b[j-1]!=c[i+j-1]));
        }
    cout << dp[n][m] << endl;
}
signed main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--)
    solve();
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string a,b,c;
    cin >> a >> b >> c;
    int n,m;
    n=a.size();m=b.size();
    int dp[n+1][m+1];
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) dp[i][j]=1e9;
    for(int i=0;i<n;i++)
    {
        dp[i+1][0]=dp[i][0]+(a[i]!=c[i]);
    }
    for(int j=0;j<n;j++)
    {
        dp[0][j+1]=dp[0][j]+(b[j]!=c[j]);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            dp[i][j]=min(dp[i-1][j]+(a[i-1]!=c[i+j-1]),dp[i][j-1]+(b[j-1]!=c[i+j-1]));
        }
    }
    cout << dp[n][m] << endl;
}
signed main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--)
    solve();
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string a,b,c;
    cin >> a >> b >> c;
    int n,m;
    n=a.size();m=b.size();
    int dp[n+1][m+1];
    dp[0][0]=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(!i&&!j) continue;
            dp[i][j]=min(dp[i-1][j]+(a[i-1]!=c[i+j-1]),dp[i][j-1]+(b[j-1]!=c[i+j-1]));
        }
    }
    cout << dp[n][m] << endl;
}
signed main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--)
    solve();
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string a,b,c;
    cin >> a >> b >> c;
    int n,m;
    n=a.size();m=b.size();
    int dp[n+1][m+1];
    dp[0][0]=0;
    for(int i=0;i<n;i++)
    {
        dp[i+1][0]=dp[i][0]+(a[i]!=c[i]);
    }
    for(int j=0;j<n;j++)
    {
        dp[0][j+1]=dp[0][j]+(b[j]!=c[j]);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            dp[i][j]=min(dp[i-1][j]+(a[i-1]!=c[i+j-1]),dp[i][j-1]+(b[j-1]!=c[i+j-1]));
        }
    }
    cout << dp[n][m] << endl;
}
signed main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--)
    solve();
    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 <vector>

#include <queue>

#include <iomanip>

#include <algorithm>

#include <numeric>

#include <unordered_map>

#include <map>

using namespace std;



typedef long long ll;



void solve() {

    int n;

    cin >> n;

    vector<int> a(n);

    for (int& x : a) cin >> x;

    

    vector<bool> dp(n, false);

    dp[0] = true;

    int prev = a[0];



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

        if (prev > a[i]) {

            cout << "NO\n";

            return;

        }

        dp[i] = true;

        prev = min(prev, a[i]);

    }

    cout << "YES\n";

}





int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    

    int t;

    cin >> t;

    while (t--) solve();

}



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

#include <vector>

#include <queue>

#include <iomanip>

#include <algorithm>

#include <numeric>

#include <unordered_map>

#include <map>

using namespace std;



typedef long long ll;



void solve() {

    int n;

    cin >> n;

    vector<int> a(n);

    for (int& x : a) cin >> x;



    int next_min = a[n - 1];

    for (int i = n - 2; i >= 0; i--) {

        int curr_min = min(a[i], a[i + 1]);

        if (curr_min > next_min) {

            cout << "NO\n";

            return;

        }

        next_min = curr_min;

    }

    cout << "YES\n";

}





int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    

    int t;

    cin >> t;

    while (t--) solve();

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


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

#include <vector>

#include <queue>

#include <iomanip>

#include <algorithm>

#include <numeric>

#include <unordered_map>

#include <map>

using namespace std;



typedef long long ll;



void solve() {

    int n;

    cin >> n;

    vector<int> a(n);

    

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

        cin >> a[i];

    }

    for (int i = n - 2; i >= 0; --i) {

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

            int diff = a[i] - a[i + 1];

            a[i] -= diff;

            a[i + 1] -= diff;



            if (a[i] < 0 || a[i + 1] < 0) {

                cout << "NO\n";

                return;

            }

        }

    }



    cout << "YES\n";

}





int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    

    int t;

    cin >> t;

    while (t--) solve();

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

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

#include <vector>

#include <queue>

#include <iomanip>

#include <algorithm>

#include <numeric>

#include <unordered_map>

#include <map>

using namespace std;



typedef long long ll;



void solve() {

    int n;

    cin >> n;

    vector<int> a(n);

    for (int& x : a) cin >> x;



    int next_min = a[n - 1];

    for (int i = n - 2; i >= 0; i--) {

        int curr_min = min(a[i], a[i + 1]);

        if (curr_min > next_min) {

            cout << "NO\n";

            return;

        }

        next_min = curr_min;

    }

    cout << "YES\n";

}





int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    

    int t;

    cin >> t;

    while (t--) solve();

}



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

#include <vector>

#include <queue>

#include <iomanip>

#include <algorithm>

#include <numeric>

#include <unordered_map>

#include <map>

using namespace std;



typedef long long ll;



void solve() {

    int n; cin >> n;

    bool chk = 1;

    deque<int> a(n);

    for(auto &x: a) cin >> x;

    

    while(a.size() > 1) {

        if(a[0] > a[1]) {

            chk = 0;

            break;

        }

        else if (a[0] < a[1]) {

            a[1] -= a[0];

            a.pop_front();

        }

        else {

            a.pop_front();

            a.pop_front();

        }

    }

    cout << (chk?"YES":"NO") << '\n';

}







int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    

    int t;

    cin >> t;

    while (t--) solve();

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

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

#include <vector>

#include <queue>

#include <iomanip>

#include <algorithm>

#include <numeric>

#include <unordered_map>

#include <map>

using namespace std;



typedef long long ll;



void solve() {

    int n;

    cin >> n;

    vector<int> a(n);

    

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

        cin >> a[i];

    }

    for (int i = n - 2; i >= 0; --i) {

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

            int diff = a[i] - a[i + 1];

            a[i] -= diff;

            a[i + 1] -= diff;



            if (a[i] < 0 || a[i + 1] < 0) {

                cout << "NO\n";

                return;

            }

        }

    }



    cout << "YES\n";

}





int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    

    int t;

    cin >> t;

    while (t--) solve();

}



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

#include <vector>

#include <queue>

#include <iomanip>

#include <algorithm>

#include <numeric>

#include <unordered_map>

#include <map>

using namespace std;



typedef long long ll;



void solve() {

    int n;

    cin >> n;

    vector<int> a(n);

    for (int& x : a) cin >> x;

    

    vector<bool> dp(n, false);

    dp[0] = true;

    int prev = a[0];



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

        if (prev > a[i]) {

            cout << "NO\n";

            return;

        }

        dp[i] = true;

        prev = min(prev, a[i]);

    }

    cout << "YES\n";

}





int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    

    int t;

    cin >> t;

    while (t--) solve();

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


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <map>
using namespace std;

typedef long long ll;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = n - 2; i >= 0; --i) {
        if (a[i] > a[i + 1]) {
            int diff = a[i] - a[i + 1];
            a[i] -= diff;
            a[i + 1] -= diff;

            if (a[i] < 0 || a[i + 1] < 0) {
                cout << "NO\n";
                return;
            }
        }
    }

    cout << "YES\n";
}


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int t;
    cin >> t;
    while (t--) solve();
}