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

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
string s;
void hs()
{
	long long ans=0;
	int x=0,y=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		ans+=s[i]-'0';
		if(s[i]=='2') x++;
		else if(s[i]=='3') y++;
	}
	if(ans%9==0) cout<<"YES"<<endl;
	else if(ans%9==8&&(x>=5||(y>=1&&x>=2))) cout<<"YES"<<endl;
	else if(ans%9==7&&x>=1) cout<<"YES"<<endl;
	else if(ans%9==6&&(y>=2||x>=6||(x>=3&&y>=1))) cout<<"YES"<<endl;
	else if(ans%9==5) 
	{
		if(x>=11)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=8)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=5)
		cout<<"YES"<<endl;
		else if(y>=3&&x>=2)
		cout<<"YES"<<endl;
		else
	    cout<<"NO"<<endl;
	}
	else if(ans%9==4)
	{
		if(x>=7)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=4)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=1)
		cout<<"YES"<<endl;
		else 
		cout<<"NO"<<endl;
	 } 
	else if(ans%9==3&&(y>=1||x>=3)) cout<<"YES"<<endl;
	else if(ans%9==2) 
	{
		if(x>=8)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=5)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=2)
		cout<<"YES"<<endl;
		else 
		cout<<"NO"<<endl;
	}
	else if(ans%9==1&&(x>=4||(x>=1&&y>=1))) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int __;
	cin>>__;
	while(__--)
	hs();
	return 0;
 } 

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
string s;
int a[100100];
int b[100100];
void hs()
{
	long long ans=0;
	int x=0,y=0;
	a[0]=0,b[0]=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		ans+=s[i]-'0';
		if(s[i]=='2') x++;
		else if(s[i]=='3') y++;
	}
	if(ans%9==0) 
	{
		cout<<"YES"<<endl;
		return;
	}
	ans%=9;
	
	int tmp=0;
	for(int i=1;i<=x;i++)
	{
		tmp+=2;
		tmp%=9;
		a[i]=tmp;
	}
	tmp=0;
	for(int i=1;i<=y;i++)
	{
		tmp+=6;
		tmp%=9;
		b[i]=tmp;
	}
	for(int i=0;i<=y;i++)
	{
		for(int j=0;j<=x;j++) 
		if(a[j]+b[i]==9-ans)
		{
			cout<<"YES"<<endl;
			return;
		}
	}
	cout<<"NO"<<endl;
}
int main()	
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int __;
	cin>>__;
	while(__--)
	hs();
	return 0;
 }
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
string s;
void hs()
{
	int ans=0;
	int x=0,y=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		ans+=s[i]-'0';
		if(s[i]=='2') x++;
		else if(s[i]=='3') y++;
	}
	if(ans%9==0) cout<<"YES"<<endl;
	else if(ans%9==8&&(x>=5||(y>=1&&x>=2))) cout<<"YES"<<endl;
	else if(ans%9==7&&x>=1) cout<<"YES"<<endl;
	else if(ans%9==6&&(y>=2||x>=6||(x>=3&&y>=1))) cout<<"YES"<<endl;
	else if(ans%9==5) 
	{
		if(x>=11)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=8)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=5)
		cout<<"YES"<<endl;
		else if(y>=3&&x>=2)
		cout<<"YES"<<endl;
		else
	    cout<<"NO"<<endl;
	}
	else if(ans%9==4)
	{
		if(x>=7)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=4)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=1)
		cout<<"YES"<<endl;
		else 
		cout<<"NO"<<endl;
	 } 
	else if(ans%9==3&&(y>=1||x>=3)) cout<<"YES"<<endl;
	else if(ans%9==2) 
	{
		if(x>=8)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=5)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=2)
		cout<<"YES"<<endl;
		else 
		cout<<"NO"<<endl;
	}
	else if(ans%9==1&&(x>=4||(x>=1&&y>=1))) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int __;
	cin>>__;
	while(__--)
	hs();
	return 0;
 } 

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
string s;
void hs()
{
	long long ans=0;
	int x=0,y=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		ans+=s[i]-'0';
		if(s[i]=='2') x++;
		else if(s[i]=='3') y++;
	}
	if(ans%9==0) cout<<"YES"<<endl;
	else if(ans%9==8&&(x>=5||(y>=1&&x>=2))) cout<<"YES"<<endl;
	else if(ans%9==7&&x>=1) cout<<"YES"<<endl;
	else if(ans%9==6&&(y>=2||x>=6||(x>=3&&y>=1))) cout<<"YES"<<endl;
	else if(ans%9==5) 
	{
		if(x>=11)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=8)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=5)
		cout<<"YES"<<endl;
		else if(y>=3&&x>=2)
		cout<<"YES"<<endl;
		else
	    cout<<"NO"<<endl;
	}
	else if(ans%9==4)
	{
		if(x>=7)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=4)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=1)
		cout<<"YES"<<endl;
		else 
		cout<<"NO"<<endl;
	 } 
	else if(ans%9==3&&(y>=1||x>=3)) cout<<"YES"<<endl;
	else if(ans%9==2) 
	{
		if(x>=8)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=5)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=2)
		cout<<"YES"<<endl;
		else 
		cout<<"NO"<<endl;
	}
	else if(ans%9==1&&(x>=4||(x>=1&&y>=1))) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int __;
	cin>>__;
	while(__--)
	hs();
	return 0;
 }
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

#include<string>

#include<algorithm>

#include<vector>

#include<climits>

#include<stack>

#include<queue>

#include<set>

#include<map>

#include<unordered_set>

#include<cmath>

using namespace std;



int main() {

int t;

cin>>t;

int n;

while(t--) {

cin>>n;

vector<int>v(n);

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

cin>>v[i];

}

int small = min(v[0], v[1]);

v[0] = v[0] - small;

v[1] = v[1] - small;

if(v[0]<v[1]) {

cout<<"YES"<<"\n";

} else {

cout<<"NO"<<"\n";

}

}

return 0;

}

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

#include<string>

#include<algorithm>

#include<vector>

#include<climits>

#include<stack>

#include<queue>

#include<set>

#include<map>

#include<unordered_set>

#include<cmath>

using namespace std;



int main() {

int t;

cin>>t;

int n;

while(t--) {

cin>>n;

vector<int>v(n);

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

cin>>v[i];

}

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

int small = min(v[i], v[i+1]);

v[i] = v[i] - small;

v[i+1] = v[i+1] - small;

}

int big = INT_MIN;

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

big = max(v[i], big);

}

if(big>v[n-1]) {

cout<<"NO"<<"\n";

} else {

cout<<"YES"<<"\n";

}

}

return 0;

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

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

#include<string>

#include<algorithm>

#include<vector>

#include<climits>

#include<stack>

#include<queue>

#include<set>

#include<map>

#include<unordered_set>

#include<cmath>

using namespace std;



int main() {

int t;

cin>>t;

int n;

while(t--) {

cin>>n;

vector<int>v(n);

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

cin>>v[i];

}

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

int small = min(v[i], v[i+1]);

v[i] = v[i] - small;

v[i+1] = v[i+1] - small;

}

int big = INT_MIN;

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

big = max(v[i], big);

}

if(big>v[n-1]) {

cout<<"NO"<<"\n";

} else {

cout<<"YES"<<"\n";

}

}

return 0;

}

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

#include<string>

#include<algorithm>

#include<vector>

#include<climits>

#include<stack>

#include<queue>

#include<set>

#include<map>

#include<unordered_set>

#include<cmath>

using namespace std;



int main() {

int t;

cin>>t;

int n;

while(t--) {

cin>>n;

vector<int>v(n);

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

cin>>v[i];

}

int small;

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

small = min(v[i], v[i+1]);

v[i] = v[i] - small;

v[i+1] = v[i+1] - small;

}

bool f = false;

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

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

f = true;

break;

}

}

if(f) {

cout<<"NO"<<"\n";

} else {

cout<<"YES"<<"\n";

}

}

return 0;

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


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

#include<string>

#include<algorithm>

#include<vector>

#include<climits>

#include<stack>

#include<queue>

#include<set>

#include<map>

#include<unordered_set>

#include<cmath>

using namespace std;



int main() {

int t;

cin>>t;

int n;

while(t--) {

cin>>n;

vector<int>v(n);

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

cin>>v[i];

}

int small = min(v[0], v[1]);

v[0] = v[0] - small;

v[1] = v[1] - small;

if(v[0]<v[1]) {

cout<<"YES"<<"\n";

} else {

cout<<"NO"<<"\n";

}

}

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 rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define range(i, a, b, s) for (int i = a; (s > 0 && i < (b)) || (s < 0 && i > (b)); i += s)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

template <typename T>
void print_arr(vector<T> a) {
	trav(x, a) cout << to_string(x) << " ";
	cout << "\n";
}

int T;
int n;
vector<set<int>> g;

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

	cin >> T;
	while (T--) {
		cin >> n;
		g = vector<set<int>>(n);
		rep(i, 0, n-1) {
			int u, v;
			cin >> u >> v;
			u--; v--;
			g[u].insert(v);
			g[v].insert(u);
		}

		if (n == 2) {
			cout << 0 << '\n';
			continue;
		}

		vpi pairs(n);
		rep(i, 0, n) {
			pairs[i] = pii(sz(g[i]), i);
		}

		sort(all(pairs));
		// 1. 3 of the highest value (find two not connected)
		// 2. 2 of the highest value (take both)
		// 3. 1 of the highest value (check if there's a value 
		//    among the next highest that doesn't overlap)

		if (pairs[n-1].first == pairs[n-2].first && pairs[n-1].first == pairs[n-3].first) {
			cout << pairs[n-1].first * 2 << '\n';
			continue;
		}

		if (pairs[n-1].first == pairs[n-2].first) {
			int u = pairs[n-1].second;
			int v = pairs[n-2].second;
			cout << sz(g[u]) * 2 - (g[u].count(v) ? 1 : 0) << '\n';
			continue;
		}

		bool found = false;
		int cnt = pairs[n-2].first;
		rep(i, 0, n-1) {
			int v = pairs[n-1].second;
			if (sz(g[i]) == cnt && g[v].count(i) == 0) {
				found = true;
				break;
			}
		}

		//cout << "last " << pairs[n-1].first << " " << cnt << " " << found << '\n';
		cout << pairs[n-1].first + cnt - (found ? 0 : 1) - 1 << '\n';
	}

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

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

using namespace std;

#define int long long



signed main () {

    ios_base::sync_with_stdio(0); cin.tie(0);



    int tt; cin >> tt;

    

    while (tt--) {

        string s; cin >> s;

        int n = s.size();

        vector<int> a (n);

        for(int i = 0; i < n; i++) a[i] = s[i] - '0';

        

        vector<vector<int>> dp (n + 1 , vector<int> (10 , 0));

        

        dp[0][a[0]] = 1;

        if(a[0] * a[0] < 10) dp[0][(a[0] * a[0]) % 9] = 1;

        

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

          for(int j = 0; j < 10; j++){

              if(dp[i - 1][j]){

                  dp[i][(j + a[i]) % 9] = 1;

                 if(a[i] * a[i] < 10) dp[i][(j + a[i] * a[i]) % 9] = 1;

              }

          }

        }

        

        cout << (dp[n - 1][0] ? "YES\n" : "NO\n");

    }



    return 0;

}



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

using namespace std;

#define int long long



signed main () {

    ios_base::sync_with_stdio(0); cin.tie(0);



    int tt; cin >> tt;

    

    while (tt--) {

        string s; cin >> s;

        int n = s.size();

        vector<int> a (n);

        for(int i = 0; i < n; i++) a[i] = s[i] - '0';

        

        vector<vector<int>> dp (n + 1 , vector<int> (10 , 0));

        

        dp[0][a[0] % 9] = 1;

        if(a[0] * a[0] < 10) dp[0][(a[0] * a[0]) % 9] = 1;

        

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

          for(int j = 0; j < 10; j++){

              if(dp[i - 1][j]){

                  dp[i][(j + a[i]) % 9] = 1;

                 if(a[i] * a[i] < 10) dp[i][(j + a[i] * a[i]) % 9] = 1;

              }

          }

        }

        

        cout << (dp[n - 1][0] ? "YES\n" : "NO\n");

    }



    return 0;

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


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

using namespace std;

#define int long long



signed main () {

    ios_base::sync_with_stdio(0); cin.tie(0);



    int tt; cin >> tt;

    

    while (tt--) {

        string s; cin >> s;

        int n = s.size();

        vector<int> a (n);

        for(int i = 0; i < n; i++) a[i] = s[i] - '0';

        

        vector<vector<int>> dp (n + 1 , vector<int> (10 , 0));

        

        dp[0][a[0]] = 1;

        if(a[0] * a[0] < 10) dp[0][a[0] * a[0]] = 1;

        

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

          for(int j = 0; j < 10; j++){

              if(dp[i - 1][j]){

                  dp[i][(j + a[i]) % 9] = 1;

                 if(a[i] * a[i] < 10) dp[i][(j + a[i] * a[i]) % 9] = 1;

              }

          }

        }

        

        cout << (dp[n - 1][0] ? "YES\n" : "NO\n");

    }



    return 0;

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

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

using namespace std;

#define int long long



signed main () {

    ios_base::sync_with_stdio(0); cin.tie(0);



    int tt; cin >> tt;

    

    while (tt--) {

        string s; cin >> s;

        int n = s.size();

        vector<int> a (n);

        for(int i = 0; i < n; i++) a[i] = s[i] - '0';

        

        vector<vector<int>> dp (n + 1 , vector<int> (10 , 0));

        

        dp[0][a[0]] = 1;

        if(a[0] * a[0] < 10) dp[0][a[0] * a[0]] = 1;

        

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

          for(int j = 0; j < 10; j++){

              if(dp[i - 1][j]){

                  dp[i][(j + a[i]) % 9] = 1;

                 if(a[i] * a[i] < 10) dp[i][(j + a[i] * a[i]) % 9] = 1;

              }

          }

        }

        

        cout << (dp[n - 1][0] ? "YES\n" : "NO\n");

    }



    return 0;

}



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

using namespace std;

#define int long long



signed main () {

    ios_base::sync_with_stdio(0); cin.tie(0);



    int tt; cin >> tt;

    

    while (tt--) {

        string s; cin >> s;

        int n = s.size();

        vector<int> a (n);

        for(int i = 0; i < n; i++) a[i] = s[i] - '0';

        

        vector<vector<int>> dp (n + 1 , vector<int> (10 , 0));

        

        dp[0][a[0]] = 1;

        if(a[0] * a[0] < 10) dp[0][(a[0] * a[0]) % 9] = 1;

        

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

          for(int j = 0; j < 10; j++){

              if(dp[i - 1][j]){

                  dp[i][(j + a[i]) % 9] = 1;

                 if(a[i] * a[i] < 10) dp[i][(j + a[i] * a[i]) % 9] = 1;

              }

          }

        }

        

        cout << (dp[n - 1][0] ? "YES\n" : "NO\n");

    }



    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>
using namespace std;
#define int long long


signed main() {
    ios::sync_with_stdio(false); cin.tie(0);

   int tt; cin >> tt;
   while(tt--){
       int n; cin >> n;
       vector<int> a (n);
       for(int i = 0; i < n; i++) cin >> a[i];
       string ans = "YES\n";
       for(int i = 1; i < n; i += 2){
           if(a[i] < a[i - 1]){
               ans = "NO\n";
               break;
           }
       }
       if(n % 2){
           if(a[n - 1] <= a[n - 2] - a[n - 3]) ans = "NO\n";
       }
       cout << ans;
   }

    return 0;
}


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


signed main() {
    ios::sync_with_stdio(false); cin.tie(0);

   int tt; cin >> tt;
   while(tt--){
       int n; cin >> n;
       vector<int> a (n);
       for(int i = 0; i < n; i++) cin >> a[i];
       string ans = "YES\n";
       for(int i = 1; i < n; i += 2){
           if(a[i] < a[i - 1] || (i > 1 && a[i - 1] < a[i - 2] - a[i - 3])){
               ans = "NO\n";
               break;
           }
       }
       cout << ans;
   }

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


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


signed main() {
    ios::sync_with_stdio(false); cin.tie(0);

   int tt; cin >> tt;
   while(tt--){
       int n; cin >> n;
       vector<int> a (n);
       for(int i = 0; i < n; i++) cin >> a[i];
       string ans = "YES\n";
       for(int i = 1; i < n; i += 2){
           if(a[i] < a[i - 1]){
               ans = "NO\n";
               break;
           }
       }
       cout << ans;
   }



    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>
using namespace std;
#define int long long


signed main() {
    ios::sync_with_stdio(false); cin.tie(0);

   int tt; cin >> tt;
   while(tt--){
       int n; cin >> n;
       vector<int> a (n);
       for(int i = 0; i < n; i++) cin >> a[i];
       string ans = "YES\n";
       for(int i = 1; i < n; i += 2){
           if(a[i] < a[i - 1] || (i > 1 && a[i - 1] < a[i - 2] - a[i - 3])){
               ans = "NO\n";
               break;
           }
       }
       cout << ans;
   }

    return 0;
}


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


signed main() {
    ios::sync_with_stdio(false); cin.tie(0);

   int tt; cin >> tt;
   while(tt--){
       int n; cin >> n;
       vector<int> a (n);
       for(int i = 0; i < n; i++) cin >> a[i];
       for(int i = 1; i < n; i++){
           int mn = min(a[i] , a[i - 1]);
           a[i] -= mn;
           a[i - 1] -= mn;
       }
       
       if(is_sorted(a.begin() , a.end())) cout << "YES\n";
       else cout << "NO\n";
   }

    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>
using namespace std;
#define int long long


signed main() {
    ios::sync_with_stdio(false); cin.tie(0);

   int tt; cin >> tt;
   while(tt--){
       int n; cin >> n;
       vector<int> a (n);
       for(int i = 0; i < n; i++) cin >> a[i];
       string ans = "YES\n";
       for(int i = 1; i < n; i += 2){
           if(a[i] < a[i - 1]){
               ans = "NO\n";
               break;
           }
       }
       cout << ans;
   }



    return 0;
}


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


signed main() {
    ios::sync_with_stdio(false); cin.tie(0);

   int tt; cin >> tt;
   while(tt--){
       int n; cin >> n;
       vector<int> a (n);
       for(int i = 0; i < n; i++) cin >> a[i];
       string ans = "YES\n";
       for(int i = 1; i < n; i += 2){
           if(a[i] < a[i - 1]){
               ans = "NO\n";
               break;
           }
       }
       if(n % 2){
           if(a[n - 1] < a[n - 2] - a[n - 3]) ans = "NO\n";
       }
       cout << ans;
   }



    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>
using namespace std;
#define int long long


signed main() {
    ios::sync_with_stdio(false); cin.tie(0);

   int tt; cin >> tt;
   while(tt--){
       int n; cin >> n;
       vector<int> a (n);
       for(int i = 0; i < n; i++) cin >> a[i];
       string ans = "YES\n";
       for(int i = 1; i < n; i += 2){
           if(a[i] < a[i - 1]){
               ans = "NO\n";
               break;
           }
       }
       if(n % 2){
           if(a[n - 1] < a[n - 2] - a[n - 3]) ans = "NO\n";
       }
       cout << ans;
   }



    return 0;
}


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


signed main() {
    ios::sync_with_stdio(false); cin.tie(0);

   int tt; cin >> tt;
   while(tt--){
       int n; cin >> n;
       vector<int> a (n);
       for(int i = 0; i < n; i++) cin >> a[i];
       string ans = "YES\n";
       for(int i = 1; i < n; i += 2){
           if(a[i] < a[i - 1]){
               ans = "NO\n";
               break;
           }
       }
       if(n % 2){
           if(a[n - 1] <= a[n - 2] - a[n - 3]) ans = "NO\n";
       }
       cout << ans;
   }

    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: Python 3


Submission (verdict: Wrong answer on test 2):
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 21 21:15:24 2025

@author: hp
"""

case = input()

ans = []
for i in range(int(case)):
    value = input()
    v = input().split()
    if True:
        answer = 0 
        for j in range(len(v)):
            if j < int(value)-1:
                answer = int(v[j+1]) - int(v[j])
                
        if answer >=0:
            ans.append("yes")
        
        else:
            ans.append("no")
            

for m in ans:
    print(m)
Problem: 2060D - Subtract Min Sort
Language: Python 3

Previous submission (verdict: Wrong answer on test 2):
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 21 21:15:24 2025

@author: hp
"""

case = input()

ans = []
for i in range(int(case)):
    value = input()
    v = input().split()
    if True:
        answer = 0 
        for j in range(len(v)):
            if j < int(value)-1:
                answer = int(v[j+1]) - int(v[j])
                
        if answer >=0:
            ans.append("yes")
        
        else:
            ans.append("no")
            

for m in ans:
    print(m)
            
    
        
        

Submission (verdict: Wrong answer on test 2):
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 21 21:15:24 2025

@author: hp
"""

case = input()

ans = []
for i in range(int(case)):
    value = input()
    v = input().split()
    if int(len(v)) == int(value):
        answer = 0 
        for j in range(len(v)):
            if j < int(value)-1:
                answer = int(v[j+1]) - int(v[j])
                
        if answer >=0:
            ans.append("yes")
        
        else:
            ans.append("no")
            

for m in ans:
    print(m)
Problem: 2060D - Subtract Min Sort
Language: Python 3

Previous submission (verdict: Wrong answer on test 2):
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 21 21:15:24 2025

@author: hp
"""

case = input()

ans = []
for i in range(int(case)):
    value = input()
    v = input().split()
    if int(len(v)) == int(value):
        answer = 0 
        for j in range(len(v)):
            if j < int(value)-1:
                answer = int(v[j+1]) - int(v[j])
                
        if answer >=0:
            ans.append("yes")
        
        else:
            ans.append("no")
            

for m in ans:
    print(m)
            
    
        
        

Submission (verdict: Accepted):
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 21 21:15:24 2025

@author: hp
"""

case = input()

ans = []
for i in range(int(case)):
    value = input()
    v = input().split()
    if int(len(v)) == int(value):
        flag = 1
        answer = 0 
        for j in range(len(v)):
            if j < int(value)-1:
                if j == 0:
                    answer = int(v[j+1]) - int(v[j])
                else:
                    answer = int(v[j+1]) - answer
            
            if answer < 0:
                flag=-1
                
        if flag == 1:
            ans.append("yes")
        
        else:
            ans.append("no")
            

for m in ans:
    print(m)