ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define ll long long

int main(){
    fio();
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        vector<ll> a(n);
        ll ans=0;
        for(int i=0; i<n; i++){
            cin>>a[i];
            ans+=a[i];
        }
        while(n>1){
            n--;
            vector<ll> temp(n);
            for(int i=0; i<n; i++) temp[i]=a[i+1]-a[i];
            a=temp;
            ll m=abs(accumulate(a.begin(), a.end(), 0));
            ans=max(ans, m);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define fio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"

int main(){
    fio();
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        vector<int> a(n);
        int ans=0;
        for(int i=0; i<n; i++){
            cin>>a[i];
            ans+=a[i];
        }
        while(n>1){
            n--;
            vector<int> temp(n);
            for(int i=0; i<n; i++) temp[i]=a[i+1]-a[i];
            a=temp;
            ans=max(ans, accumulate(a.begin(), a.end(), 0));
        }
        cout<<ans<<endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):


#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	while(n--)
	{
	    int a,b;
	    cin>>a>>b;
	    vector<long long>ar(a);
	    for(int i=0;i<a;i++){
	        cin>>ar[i];
	    }
	    
	    unordered_map<long long,long long>mp;
	    for(int i=0;i<a;i++){
	        mp[ar[i]]++;
	    }
	     vector<long long>ans;
	    for(auto it:mp){
	        ans.push_back(it.second);
	    }
	    sort(ans.begin(),ans.end());
	    
	    long long x=ans.size();
	    long long ct=0;
	    while(b>0 && ct< x-1){
	        if(ans[ct]<=b){
	          b-=ans[ct];
	          ct++;
	        }
	        else{
	            break;
	        }
	    }
	    cout<<x-ct<<endl;
	    
	    
	    
	}

}




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

int main() {
	// your code goes here
	int n;
	cin>>n;
	while(n--)
	{
	    long long a,b;
	    cin>>a>>b;
	    vector<long long>ar(a);
	    for(long long i=0;i<a;i++){
	        cin>>ar[i];
	    }
	    
	    map<long long,long long>mp;
	    for(long long i=0;i<a;i++){
	        mp[ar[i]]++;
	    }
	     vector<long long>ans;
	    for(auto it:mp){
	        ans.push_back(it.second);
	    }
	    sort(ans.begin(),ans.end());
	    
	    long long x=ans.size();
	    long long ct=0;
	    while(b>0 && ct< x-1){
	        if(ans[ct]<=b){
	          b-=ans[ct];
	          ct++;
	        }
	        else{
	            break;
	        }
	    }
	    cout<<x-ct<<endl;
	    
	    
	    
	}

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


Submission (verdict: Time limit exceeded on test 14):
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	while(n--)
	{
	    int a,b;
	    cin>>a>>b;
	    vector<int>ar(a);
	    for(int i=0;i<a;i++){
	        cin>>ar[i];
	    }
	    
	    unordered_map<int,int>mp;
	    for(int i=0;i<a;i++){
	        mp[ar[i]]++;
	    }
	     vector<int>ans;
	    for(auto it:mp){
	        ans.push_back(it.second);
	    }
	    sort(ans.begin(),ans.end());
	    
	    int x=ans.size();
	    int ct=0;
	    while(b>0 && ct< x-1){
	        if(ans[ct]<=b){
	          b-=ans[ct];
	          ct++;
	        }
	        else{
	            break;
	        }
	    }
	    cout<<x-ct<<endl;
	    
	    
	    
	}

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

Previous submission (verdict: Time limit exceeded on test 14):
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	while(n--)
	{
	    int a,b;
	    cin>>a>>b;
	    vector<int>ar(a);
	    for(int i=0;i<a;i++){
	        cin>>ar[i];
	    }
	    
	    unordered_map<int,int>mp;
	    for(int i=0;i<a;i++){
	        mp[ar[i]]++;
	    }
	     vector<int>ans;
	    for(auto it:mp){
	        ans.push_back(it.second);
	    }
	    sort(ans.begin(),ans.end());
	    
	    int x=ans.size();
	    int ct=0;
	    while(b>0 && ct< x-1){
	        if(ans[ct]<=b){
	          b-=ans[ct];
	          ct++;
	        }
	        else{
	            break;
	        }
	    }
	    cout<<x-ct<<endl;
	    
	    
	    
	}

}




Submission (verdict: Time limit exceeded on test 14):


#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	while(n--)
	{
	    int a,b;
	    cin>>a>>b;
	    vector<long long>ar(a);
	    for(int i=0;i<a;i++){
	        cin>>ar[i];
	    }
	    
	    unordered_map<long long,long long>mp;
	    for(int i=0;i<a;i++){
	        mp[ar[i]]++;
	    }
	     vector<long long>ans;
	    for(auto it:mp){
	        ans.push_back(it.second);
	    }
	    sort(ans.begin(),ans.end());
	    
	    long long x=ans.size();
	    long long ct=0;
	    while(b>0 && ct< x-1){
	        if(ans[ct]<=b){
	          b-=ans[ct];
	          ct++;
	        }
	        else{
	            break;
	        }
	    }
	    cout<<x-ct<<endl;
	    
	    
	    
	}

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

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<set>
#include<string.h>
#include<cstdio>
#include<map>
#include<math.h>
#include<algorithm>
#include<queue>
#include<utility>
#include<unordered_map>
#include<bitset>
#include<iomanip>
using namespace std;
#define IOS ios::sync_with_stdio;cin.tie(0);
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define ll long long
#define lf double
#define MAX_NUM 10000
void solve(){
	int n;
	cin>>n;
	map<int,int>du;
//	map<int,int>reserve_du;
	map<int,set<int>>child;
	for(int i=1;i<=n-1;i++){
		int a,b;
		cin>>a>>b;
		du[a]+=1;
		du[b]+=1;
		child[a].insert(b);
		child[b].insert(a);
	}
	
	vector<int>ans_arr;
	int max_du=-1;
	for(auto x:du)max_du=max(max_du,x.second);
	for(auto x:du){
		if(x.second!=max_du)continue;
		int ord=x.first;
		for(int i=1;i<=n;i++){
			if(i==ord)continue;
			if(child[ord].find(i)!=child[ord].end()){
				ans_arr.push_back(du[ord]+du[i]-2);
			}else {
				ans_arr.push_back(du[ord]+du[i]-1);
			}
		}
	}
	int ans=-1;
	for(auto x:ans_arr){
		ans=max(ans,x);
	}
	cout<<"---------   "<<ans<<endl;
}
int main(){
	IOS;
	int T;
	cin>>T;
//	T=1;
	while(T--){
		solve();
	}
	return 0;
} 


Submission (verdict: Time limit exceeded on test 9):
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<set>
#include<string.h>
#include<cstdio>
#include<map>
#include<math.h>
#include<algorithm>
#include<queue>
#include<utility>
#include<unordered_map>
#include<bitset>
#include<iomanip>
using namespace std;
#define IOS ios::sync_with_stdio;cin.tie(0);
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define ll long long
#define lf double
#define MAX_NUM 10000
void solve(){
	int n;
	cin>>n;
	map<int,int>du;
//	map<int,int>reserve_du;
	map<int,set<int>>child;
	for(int i=1;i<=n-1;i++){
		int a,b;
		cin>>a>>b;
		du[a]+=1;
		du[b]+=1;
		child[a].insert(b);
		child[b].insert(a);
	}
	
	vector<int>ans_arr;
	int max_du=-1;
	for(auto x:du)max_du=max(max_du,x.second);
	for(auto x:du){
		if(x.second!=max_du)continue;
		int ord=x.first;
		for(int i=1;i<=n;i++){
			if(i==ord)continue;
			if(child[ord].find(i)!=child[ord].end()){
				ans_arr.push_back(du[ord]+du[i]-2);
			}else {
				ans_arr.push_back(du[ord]+du[i]-1);
			}
		}
	}
	int ans=-1;
	for(auto x:ans_arr){
		ans=max(ans,x);
	}
	cout<<ans<<endl;
}
int main(){
	IOS;
	int T;
	cin>>T;
//	T=1;
	while(T--){
		solve();
	}
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 9):
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<set>
#include<string.h>
#include<cstdio>
#include<map>
#include<math.h>
#include<algorithm>
#include<queue>
#include<utility>
#include<unordered_map>
#include<bitset>
#include<iomanip>
using namespace std;
#define IOS ios::sync_with_stdio;cin.tie(0);
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define ll long long
#define lf double
#define MAX_NUM 10000
void solve(){
	int n;
	cin>>n;
	map<int,int>du;
//	map<int,int>reserve_du;
	map<int,set<int>>child;
	for(int i=1;i<=n-1;i++){
		int a,b;
		cin>>a>>b;
		du[a]+=1;
		du[b]+=1;
		child[a].insert(b);
		child[b].insert(a);
	}
	
	vector<int>ans_arr;
	int max_du=-1;
	for(auto x:du)max_du=max(max_du,x.second);
	for(auto x:du){
		if(x.second!=max_du)continue;
		int ord=x.first;
		for(int i=1;i<=n;i++){
			if(i==ord)continue;
			if(child[ord].find(i)!=child[ord].end()){
				ans_arr.push_back(du[ord]+du[i]-2);
			}else {
				ans_arr.push_back(du[ord]+du[i]-1);
			}
		}
	}
	int ans=-1;
	for(auto x:ans_arr){
		ans=max(ans,x);
	}
	cout<<ans<<endl;
}
int main(){
	IOS;
	int T;
	cin>>T;
//	T=1;
	while(T--){
		solve();
	}
	return 0;
} 


Submission (verdict: Accepted):
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<set>
#include<string.h>
#include<cstdio>
#include<map>
#include<math.h>
#include<algorithm>
#include<queue>
#include<utility>
#include<unordered_map>
#include<bitset>
#include<iomanip>
using namespace std;
#define IOS ios::sync_with_stdio;cin.tie(0);
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define ll long long
#define lf double
#define MAX_NUM 10000
void solve(){
	int n;
	cin>>n;
	map<int,int>du;
//	map<int,int>reserve_du;
	map<int,set<int>>child;
	for(int i=1;i<=n-1;i++){
		int a,b;
		cin>>a>>b;
		du[a]+=1;
		du[b]+=1;
		child[a].insert(b);
		child[b].insert(a);
	}
	
	vector<int>ans_arr;
	int max_du=-1;
	int cnt=5;
	for(auto x:du)max_du=max(max_du,x.second);
	for(auto x:du){
		if(x.second!=max_du)continue;
		int ord=x.first;
		for(int i=1;i<=n;i++){
			if(i==ord)continue;
			if(child[ord].find(i)!=child[ord].end()){
				ans_arr.push_back(du[ord]+du[i]-2);
			}else {
				ans_arr.push_back(du[ord]+du[i]-1);
			}
		}
		if(cnt--==0)break;
	}
	int ans=-1;
	for(auto x:ans_arr){
		ans=max(ans,x);
	}
	cout<<ans<<endl;
}
int main(){
	IOS;
	int T;
	cin>>T;
//	T=1;
	while(T--){
		solve();
	}
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<set>
#include<string.h>
#include<cstdio>
#include<map>
#include<math.h>
#include<algorithm>
#include<queue>
#include<utility>
#include<unordered_map>
#include<bitset>
#include<iomanip>
using namespace std;
#define IOS ios::sync_with_stdio;cin.tie(0);
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define ll long long
#define lf double
#define MAX_NUM 10000
void solve(){
	int n;
	cin>>n;
	map<int,int>du;
//	map<int,int>reserve_du;
	map<int,set<int>>child;
	for(int i=1;i<=n-1;i++){
		int a,b;
		cin>>a>>b;
		du[a]+=1;
		du[b]+=1;
		child[a].insert(b);
		child[b].insert(a);
	}
	
	vector<int>ans_arr;
	int max_du=-1;
	for(auto x:du)max_du=max(max_du,x.second);
	for(auto x:du){
		if(x.second!=max_du)continue;
		int ord=x.first;
		for(int i=1;i<=n;i++){
			if(i==ord)continue;
			if(child[ord].find(i)!=child[ord].end()){
				ans_arr.push_back(du[ord]+du[i]-2);
			}else {
				ans_arr.push_back(du[ord]+du[i]-1);
			}
		}
	}
	int ans=-1;
	for(auto x:ans_arr){
		ans=max(ans,x);
	}
	cout<<"---------   "<<ans<<endl;
}
int main(){
	IOS;
	int T;
	cin>>T;
//	T=1;
	while(T--){
		solve();
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 27):
#include <bits/stdc++.h>
using namespace std;

#define vi vector<int>
#define int long long
#define pb(x) push_back(x)
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vii vector<pair<int, int>>
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define up(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define srt(a) sort(a.begin(),a.end())
#define arrin(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prnt(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<' ';
#define pii pair<int, int>
#define vc vector<char>
#define ss second
#define ff first

#define MOD 1000000007
#define INF 1e18


void solve() {
    int n,m;
    cin>>n>>m;
    multiset<int> a,b;
    int sum1=0,sum2=0;
    for(int i=0 ; i<n ; i++){
      int c;
      cin>>c;
      sum1+=c;
      a.insert(c);
    }
    for(int i=0 ; i<m ; i++){
      int c;
      cin>>c;
      sum2+=c;
      b.insert(c);
    }
    if(sum1!=sum2){cout<<"NO"<<endl; return;}
    while(!b.empty()){
        auto it=b.end();
        it--;
        int num=*it;
        b.erase(it);
        if(a.count(num)>0){
            a.erase(a.find(num));
            continue;
        }
        if(*a.begin()>num){
            cout<<"NO"<<endl;
            return;
        }
        b.insert(num/2);
        b.insert((num+1)/2);
    }
    if(a.empty() && b.empty()){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t=1;
    cin >> t;
    while (t--) {
        solve();
    }
    
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        string a, b, c;
        cin >> a >> b >> c;
        int shitty_dp[c.size() + 1][a.size() + 1];
        for(int i = 0; i <= c.size(); i++) for(int j = 0; j <= a.size(); j++) shitty_dp[i][j] = 0;
        for(int i = 0; i < c.size(); i++){
            for(int j = 0; j <= min(i, (int)a.size()); j++){
                if(j != a.size() )shitty_dp[i+1][j+1] = max(shitty_dp[i+1][j+1], shitty_dp[i][j]);
                if(i != j + b.size()) shitty_dp[i+1][j] = max(shitty_dp[i+1][j], shitty_dp[i][j]);
                if(j != a.size() && c[i] == a[j]) shitty_dp[i+1][j+1] = max(shitty_dp[i+1][j+1], shitty_dp[i][j] + 1);
                if(i != j + b.size() && c[i] == b[i-j]) shitty_dp[i+1][j] = max(shitty_dp[i+1][j], shitty_dp[i][j] + 1);
            }
        }
        int ans = 0;
        for(int i = 0; i < a.size() + 1; i++){
            ans = max(ans, shitty_dp[c.size()][i]);
        } 
        cout << c.size() - ans << endl;
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        string a, b, c;
        cin >> a >> b >> c;
        int amk_dp[c.size() + 1][a.size() + 1];
        for(int i = 0; i <= c.size(); i++) for(int j = 0; j < a.size() + 1; j++) amk_dp[i][j] = 0;

        for(int i = 1; i <= c.size(); i++){
            for(int j = max(0, i-(int)b.size()); j <= min(i,(int) a.size()); j++){
                if(j > 0) amk_dp[i][j] = max(amk_dp[i][j], amk_dp[i-1][j-1] + (c[i-1] == a[j-1]));
                if(j < i) amk_dp[i][j] = max(amk_dp[i][j], amk_dp[i-1][j] + (c[i-1] == b[i-j-1]));
                // cout << i << " " << j << " " << amk_dp[i][j] << endl;
            }
        }
        cout << c.size() - amk_dp[c.size()][a.size()] << endl;
    }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        string a, b, c;
        cin >> a >> b >> c;
        int shitty_dp[c.size() + 1][a.size() + 1];
        for(int i = 0; i <= c.size(); i++) for(int j = 0; j <= a.size(); j++) shitty_dp[i][j] = 0;
        for(int i = 0; i < c.size(); i++){
            for(int j = 0; j <= min(i, (int)a.size()); j++){
                shitty_dp[i+1][j+1] = max(shitty_dp[i+1][j+1], shitty_dp[i][j]);
                shitty_dp[i+1][j] = max(shitty_dp[i+1][j], shitty_dp[i][j]);
                if(c[i] == a[j]) shitty_dp[i+1][j+1] = max(shitty_dp[i+1][j+1], shitty_dp[i][j] + 1);
                if(c[i] == b[i-j]) shitty_dp[i+1][j] = max(shitty_dp[i+1][j], shitty_dp[i][j] + 1);
            }
        }
        int ans = 0;
        for(int i = 0; i < a.size() + 1; i++){
            ans = max(ans, shitty_dp[c.size()][i]);
        } 
        cout << c.size() - ans << endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        string a, b, c;
        cin >> a >> b >> c;
        int shitty_dp[c.size() + 1][a.size() + 1];
        for(int i = 0; i <= c.size(); i++) for(int j = 0; j <= a.size(); j++) shitty_dp[i][j] = 0;
        for(int i = 0; i < c.size(); i++){
            for(int j = 0; j <= min(i, (int)a.size()); j++){
                if(j != a.size() )shitty_dp[i+1][j+1] = max(shitty_dp[i+1][j+1], shitty_dp[i][j]);
                if(i != j + b.size()) shitty_dp[i+1][j] = max(shitty_dp[i+1][j], shitty_dp[i][j]);
                if(j != a.size() && c[i] == a[j]) shitty_dp[i+1][j+1] = max(shitty_dp[i+1][j+1], shitty_dp[i][j] + 1);
                if(i != j + b.size() && c[i] == b[i-j]) shitty_dp[i+1][j] = max(shitty_dp[i+1][j], shitty_dp[i][j] + 1);
            }
        }
        int ans = 0;
        for(int i = 0; i < a.size() + 1; i++){
            ans = max(ans, shitty_dp[c.size()][i]);
        } 
        cout << c.size() - ans << endl;
    }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        string a, b, c;
        cin >> a >> b >> c;
        int shitty_dp[c.size() + 1][a.size() + 1];
        for(int i = 0; i <= c.size(); i++) for(int j = 0; j <= a.size(); j++) shitty_dp[i][j] = 0;
        for(int i = 0; i < c.size(); i++){
            for(int j = 0; j <= min(i, (int)a.size()); j++){
                shitty_dp[i+1][j+1] = max(shitty_dp[i+1][j+1], shitty_dp[i][j]);
                shitty_dp[i+1][j] = max(shitty_dp[i+1][j], shitty_dp[i][j]);
                if(c[i] == a[j]) shitty_dp[i+1][j+1] = max(shitty_dp[i+1][j+1], shitty_dp[i][j] + 1);
                if(c[i] == b[i-j]) shitty_dp[i+1][j] = max(shitty_dp[i+1][j], shitty_dp[i][j] + 1);
            }
        }
        int ans = 0;
        for(int i = 0; i < a.size() + 1; i++){
            ans = max(ans, shitty_dp[c.size()][i]);
        } 
        cout << c.size() - ans << endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    vector<int>vec(n);
    for(auto &i:vec){
        cin>>vec[i];
    }
    for(int i=0;i<n-1;++i){
        int k=min(vec[i],vec[i+1]);
        if(vec[i]>vec[i+1]){
            vec[i]-=k;
            vec[i+1]-=k;
        }
    }
    for(int i=0;i<n-1;++i){
        if(vec[i+1]<vec[i]){
            cout<<"NO"<<'\n';
        }
    }
    cout<<"YES"<<"\n";
    return ;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    vector<int>vec(n);
    for(auto &i:vec){
        cin>>vec[i];
    }
    for(int i=0;i<n-1;++i){
        int k=min(vec[i],vec[i+1]);
        if(vec[i]>vec[i+1]){
            vec[i]-=k;
            vec[i+1]-=k;
        }
    }
    for(int i=0;i<n-1;++i){
        if(vec[i+1]<vec[i]){
            cout<<"NO"<<'\n';
        }
    }
    cout<<"YES"<<"\n";
    return ;
}
int main(){
    ios::sync_with_stdio(0);
    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;
void solve(){
    int n;
    cin>>n;
    vector<int>vec(n);
    for(auto &i:vec){
        cin>>vec[i];
    }
    for(int i=0;i<n-1;++i){
        int k=min(vec[i],vec[i+1]);
        if(vec[i]>vec[i+1]){
            vec[i]-=k;
            vec[i+1]-=k;
        }
    }
    for(int i=0;i<n-1;++i){
        if(vec[i+1]<vec[i]){
            cout<<"NO"<<'\n';
            return ;
        }
    }
    cout<<"YES"<<"\n";
    return ;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    vector<int>vec(n);
    for(auto &i:vec){
        cin>>vec[i];
    }
    for(int i=0;i<n-1;++i){
        int k=min(vec[i],vec[i+1]);
        
            vec[i]-=k;
            vec[i+1]-=k;
       
    }
    for(int i=0;i<n-1;++i){
        if(vec[i+1]<vec[i]){
            cout<<"NO"<<'\n';
            return ;
        }
    }
    cout<<"YES"<<"\n";
    return ;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    vector<int>vec(n);
    for(auto &i:vec){
        cin>>i;
    }
    for(int i=0;i<n-1;++i){
        int k=min(vec[i],vec[i+1]);
        
            vec[i]-=k;
            vec[i+1]-=k;
       
    }
    for(int i=0;i<n-1;++i){
        if(vec[i+1]<vec[i]){
            cout<<"NO"<<'\n';
            return ;
        }
    }
    cout<<"YES"<<"\n";
    return ;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    vector<int>vec(n);
    for(auto &i:vec){
        cin>>vec[i];
    }
    for(int i=0;i<n-1;++i){
        int k=min(vec[i],vec[i+1]);
        if(vec[i]>vec[i+1]){
            vec[i]-=k;
            vec[i+1]-=k;
        }
    }
    for(int i=0;i<n-1;++i){
        if(vec[i+1]<vec[i]){
            cout<<"NO"<<'\n';
            return ;
        }
    }
    cout<<"YES"<<"\n";
    return ;
}
int main(){
    ios::sync_with_stdio(0);
    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;
void solve(){
    int n;
    cin>>n;
    vector<int>vec(n);
    for(auto &i:vec){
        cin>>vec[i];
    }
    for(int i=0;i<n-1;++i){
        int k=min(vec[i],vec[i+1]);
        
            vec[i]-=k;
            vec[i+1]-=k;
       
    }
    for(int i=0;i<n-1;++i){
        if(vec[i+1]<vec[i]){
            cout<<"NO"<<'\n';
            return ;
        }
    }
    cout<<"YES"<<"\n";
    return ;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}