ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;
#define ll long long
#define limit 200000
#define MOD 998244353
vector<ll> pow2(limit + 1);



void solve()
{
	ll n, l, r;
	cin >> n >> l >> r;

	vector<int> niz1(l - 1);
	vector<int> niz2(r - l + 1);
	vector<int> niz3(n - r);
	for (int i = 0; i < n; i++)
	{
		if (i < l - 1)
			cin >> niz1[i];
		else if (i >= l-1 && i < r)
			cin >> niz2[i - (l-1)];
		else
			cin >> niz3[i - r];
	}
	sort(niz1.begin(), niz1.end());
	sort(niz2.begin(), niz2.end(), greater<int>());
	sort(niz3.begin(), niz3.end());

	std::vector<ll> cumsum1(niz1.size());
	std::partial_sum(niz1.begin(), niz1.end(), cumsum1.begin());
	std::vector<ll> cumsum2(niz2.size());
	std::partial_sum(niz2.begin(), niz2.end(), cumsum2.begin());
	std::vector<ll> cumsum3(niz3.size());
	std::partial_sum(niz3.begin(), niz3.end(), cumsum3.begin());

	ll pom = 0;
	ll pom2 = 0;
	for (int i = 0; i < niz1.size() && i < niz2.size(); i++)
	{
		ll x = cumsum2[i] - cumsum1[i];
		if (x > pom)
		{
			pom = x;
		}
		else break;
	}
	for (int i = 0; i < niz3.size() && i < niz2.size(); i++)
	{
		ll x = cumsum2[i] - cumsum3[i];
		if (x > pom2)
		{
			pom2 = x;
		}
		else break;
	}

	cout << cumsum2[r - l] - max(pom, pom2)<< endl;

}


int main()
{
	cin.tie(nullptr)->sync_with_stdio(false);

	ll n; cin >> n;

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

		solve();

	}
}

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

using namespace std;
#define ll long long
#define limit 200000
#define MOD 998244353
vector<ll> pow2(limit + 1);



void solve()
{
	ll n, l, r;
	cin >> n >> l >> r;

	vector<ll> niz1(l - 1);
	vector <ll > niz2(r - l + 1);
	vector<ll> niz3(n - r);
	for (int i = 0; i < n; i++)
	{
		if (i < l - 1)
			cin >> niz1[i];
		else if (i >= l-1 && i < r)
			cin >> niz2[i - (l-1)];
		else
			cin >> niz3[i - r];
	}
	sort(niz1.begin(), niz1.end());
	sort(niz2.begin(), niz2.end(), greater<ll>());
	sort(niz3.begin(), niz3.end());

	std::vector<ll> cumsum1(niz1.size());
	std::partial_sum(niz1.begin(), niz1.end(), cumsum1.begin());
	std::vector<ll> cumsum2(niz2.size());
	std::partial_sum(niz2.begin(), niz2.end(), cumsum2.begin());
	std::vector<ll> cumsum3(niz3.size());
	std::partial_sum(niz3.begin(), niz3.end(), cumsum3.begin());

	ll pom = 0;
	ll pom2 = 0;
	for (int i = 0; i < niz1.size() && i < niz2.size(); i++)
	{
		ll x = cumsum2[i] - cumsum1[i];
		if (x > pom)
		{
			pom = x;
		}
		else break;
	}
	for (int i = 0; i < niz3.size() && i < niz2.size(); i++)
	{
		ll x = cumsum2[i] - cumsum3[i];
		if (x > pom2)
		{
			pom2 = x;
		}
		else break;
	}

	cout << cumsum2[r - l] - max(pom, pom2)<< endl;

}


int main()
{
	cin.tie(nullptr)->sync_with_stdio(false);

	ll n; cin >> n;

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

		solve();

	}
}
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;


int main(){
    long long t;
    cin >> t;
    while(t--){
        long long n;
        cin >> n;
        vector<long long> v(n);
        for(long i=0 ;i<n ;i++){
            cin >> v[i];
        }

        for(long long i =0 ; i<n-1 ;i++){
            long long temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }

        int cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 1){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long n;
        cin >> n;
        vector<long long> v(n);
        for(long i=0 ;i<n ;i++){
            cin >> v[i];
        }

        for(long long i =0 ; i<n-1 ;i++){
            long long temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }
        v[n-1]=0;

        long long cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 0){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    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;

int main(){
    int t;
    cin >> t;
    while(t--){
        long long n;
        cin >> n;
        vector<long long> v(n);
        for(long i=0 ;i<n ;i++){
            cin >> v[i];
        }

        for(long long i =0 ; i<n-1 ;i++){
            int temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }

        int cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 1){
            cout << "yes" << endl;
        }else{
            cout << "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>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        long long n;
        cin >> n;
        vector<long long> v(n);
        for(long i=0 ;i<n ;i++){
            cin >> v[i];
        }

        for(long long i =0 ; i<n-1 ;i++){
            int temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }

        int cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 1){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long n;
        cin >> n;
        vector<long long> v(n);
        for(long i=0 ;i<n ;i++){
            cin >> v[i];
        }

        for(long long i =0 ; i<n-1 ;i++){
            int temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }

        int cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 1){
            cout << "YES" << endl;
        }else{
            cout << "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>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long n;
        cin >> n;
        vector<long long> v(n);
        for(long i=0 ;i<n ;i++){
            cin >> v[i];
        }

        for(long long i =0 ; i<n-1 ;i++){
            int temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }

        int cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 1){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

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


int main(){
    long long t;
    cin >> t;
    while(t--){
        long long n;
        cin >> n;
        vector<long long> v(n);
        for(long i=0 ;i<n ;i++){
            cin >> v[i];
        }

        for(long long i =0 ; i<n-1 ;i++){
            long long temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }

        int cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 1){
            cout << "YES" << endl;
        }else{
            cout << "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>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        long long n;
        cin >> n;
        vector<long long> v(n);
        for(long i=0 ;i<n ;i++){
            cin >> v[i];
        }

        for(long long i =0 ; i<n-1 ;i++){
            int temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }

        int cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 1){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}

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

int main(){
    int t;
    cin >> t;
    while(t--){
        long long n;
        cin >> n;
        vector<long long> v(n);
        for(long i=0 ;i<n ;i++){
            cin >> v[i];
        }

        for(long long i =0 ; i<n-1 ;i++){
            int temp = min(v[i] , v[i+1]);
            v[i] =v[i] - temp;
            v[i+1] = v[i+1]- temp;
        }

        int cnt =0;
        for(long long i=0 ;i< n ;i++){
            if(v[i]!=0){
                ++cnt;
            }
        }

        if(cnt == 1){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


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

ll mod=1e9+7;

void print_array(vector<ll> &arr)
{
    ll n = arr.size();
    for(int i = 0; i < n; i++)
    {
        if(i)
            cout << " ";
        cout << arr[i];
    }
    cout<< endl;
}

void input_array(vector<ll> &arr)
{
    ll n = arr.size();
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
}

ll power(ll n,ll k)
{
    ll ans=1;
    for(int i=0;i<k;i++)
    {
        ans*=n;
    }
    return ans;
}
//[2,1,3,0]

//map<ll,ll> mp;

void countDivisors(ll n,map<ll,ll> &mp) 
{ 
    //int cnt = 0; 
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                {
                    mp[i]++;
                }
  
            else // Otherwise count both 
            {
               mp[i]++; 
               mp[n/i]++;
            }
        } 
    } 
    return ; 
} 

ll fact(ll n)
{
    ll ans=1;
    for(int i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}

ll highest_pow(ll n)
{
    ll ans=0;
    while(n/2>1)
    {
        n/=2;
        ans++;
    }
    return ans;
}

void allDivisors(int n,map<ll,ll>& mp)
{
    
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            if (n / i == i)
                mp[i]++;
            else // Otherwise print both
                {
                    mp[i]++;
                    mp[n/i]++;
                }
        }
    }
}

void divisors(ll n, map<ll,ll>& mp)
{
    while (n % 2 == 0) {
        mp[2]++;
        n = n/2; 
    } 
    for (int i = 3; i*i <= n; i = i + 2) {
      
        // While i divides n, print i and divide n 
        while (n % i == 0) {
          
            mp[i]++; 
            n = n/i; 
        } 
    }
    if(n>2)
    {
        mp[n]++;
    }
}
vector<vector<ll>> directions={{1,0},{0,1},{-1,0},{0,-1}};

ll value(ll a, ll b, ll c)
{
    ll ans=(a^b)+(b^c)+(a^c);
    return ans;
}


void solve()
{
   // ll l,r;
    //cin>>l>>r;
    //max power, max_power-1, 
    ll l,r;
    cin>>l>>r;
    ll a=l,b=r;
  /*  for(ll c=l;c<=r;c++)
    {
        if(c!=a&&c!=b)
        {
       ll ans=(a^b)+(b^c)+(a^c);
       cout<<ans<<endl;
        }
    }*/
    ll c=0;
   for(int i=0;i<=30;i++)
   {
       ll t1=(a&(1<<i));
       ll t2=(b&(1<<i));
       if(t1!=0&&t2!=0)
       continue;
       else 
       if((c|(1<<i))<=r)
       c=(c|(1<<i));
   }
   // ll p=(a^b)+(b^c)+(a^c);
    cout<<a<<" "<<b<<" "<<c<<endl; 
  //  cout<<p<<endl;
    //cout<<"---------------- "<<endl;
}




int main(){
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <vector>
#define vi vector<int>
#define pb push_back
#define int long long
using namespace std;
const int N = 5e5+10; 
int t,sum=0;
string s;

void solve(){
	cin>>s;
	for(int i=0;i<s.length();i++){
		for(int j=i;j>=1;j--){
			if(s[j-1]<s[j]-1){
				s[j]=(s[j]-'0')-1+'0';
				char w=s[j];
				s[j]=s[j-1];
				s[j-1]=w;
			}
		}
	} 
	cout<<s<<endl;
}

signed main(void){
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	solve();
	return 0;
} 

Submission (verdict: Accepted):
#include <iostream>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <vector>
#define vi vector<int>
#define pb push_back
#define int long long
using namespace std;
const int N = 5e5+10; 
int t,sum=0;
string s;

void solve(){
	cin>>s;
	for(int i=0;i<s.length();i++){
		for(int j=i;j>=1;j--){
			if(s[j-1]<s[j]-1){
				s[j]=(s[j]-'0')-1+'0';
				char w=s[j];
				s[j]=s[j-1];
				s[j-1]=w;
			}
			else{
				break;
			}
		}
	} 
	cout<<s<<endl;
}

signed main(void){
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	solve();
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <vector>
#define vi vector<int>
#define pb push_back
#define int long long
using namespace std;
const int N = 5e5+10; 
int t,sum=0;
string s;

void solve(){
	cin>>s;
	int len=s.length()-1;
	while(len--){
		for(int i=1;i<s.length();i++){
			if(s[i-1]<s[i]-1){
				s[i]=(s[i]-'0')-1+'0';
				char w=s[i];
				s[i]=s[i-1];
				s[i-1]=w;
			}
		} 
	}
	cout<<s<<endl;
}

signed main(void){
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	solve();
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <vector>
#define vi vector<int>
#define pb push_back
#define int long long
using namespace std;
const int N = 5e5+10; 
int t,sum=0;
string s;

void solve(){
	cin>>s;
	for(int i=1;i<s.length();i++){
		if(s[i-1]<s[i]-1){
			s[i]=(s[i]-'0')-1+'0';
			char w=s[i];
			s[i]=s[i-1];
			s[i-1]=w;
		}
	} 
	for(int i=s.length()-1;i>=1;i--){
		if(s[i-1]<s[i]-1){
			s[i]=(s[i]-'0')-1+'0';
			char w=s[i];
			s[i]=s[i-1];
			s[i-1]=w;
		}
	} 
	cout<<s<<endl;
}

signed main(void){
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	solve();
	return 0;
} 

Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <vector>
#define vi vector<int>
#define pb push_back
#define int long long
using namespace std;
const int N = 5e5+10; 
int t,sum=0;
string s;

void solve(){
	cin>>s;
	for(int i=s.length()-1;i>=0;i--){
		for(int j=1;j<s.length();j++){
			if(s[j-1]<s[j]-1){
				s[j]=(s[j]-'0')-1+'0';
				char w=s[j];
				s[j]=s[j-1];
				s[j-1]=w;
			}
		}
	} 
	cout<<s<<endl;
}

signed main(void){
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	solve();
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <vector>
#define vi vector<int>
#define pb push_back
#define int long long
using namespace std;
const int N = 5e5+10; 
int t,sum=0;
string s;

void solve(){
	cin>>s;
	int len=s.length()-1;
	while(len--){
		for(int i=1;i<s.length();i++){
			if(s[i-1]<s[i]-1){
				s[i]=(s[i]-'0')-1+'0';
				char w=s[i];
				s[i]=s[i-1];
				s[i-1]=w;
			}
		} 
	}
	cout<<s<<endl;
}

signed main(void){
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	solve();
	return 0;
} 

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <vector>
#define vi vector<int>
#define pb push_back
#define int long long
using namespace std;
const int N = 5e5+10; 
int t,sum=0;
string s;

void solve(){
	cin>>s;
	for(int i=1;i<s.length();i++){
		if(s[i-1]<s[i]-1){
			s[i]=(s[i]-'0')-1+'0';
			char w=s[i];
			s[i]=s[i-1];
			s[i-1]=w;
		}
	} 
	for(int i=s.length()-1;i>=1;i--){
		if(s[i-1]<s[i]-1){
			s[i]=(s[i]-'0')-1+'0';
			char w=s[i];
			s[i]=s[i-1];
			s[i-1]=w;
		}
	} 
	cout<<s<<endl;
}

signed main(void){
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	solve();
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <vector>
#define vi vector<int>
#define pb push_back
#define int long long
using namespace std;
const int N = 5e5+10; 
int t,sum=0;
string s;

void solve(){
	cin>>s;
	for(int i=s.length()-1;i>=0;i--){
		for(int j=1;j<s.length();j++){
			if(s[j-1]<s[j]-1){
				s[j]=(s[j]-'0')-1+'0';
				char w=s[j];
				s[j]=s[j-1];
				s[j-1]=w;
			}
		}
	} 
	cout<<s<<endl;
}

signed main(void){
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	solve();
	return 0;
} 

Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <vector>
#define vi vector<int>
#define pb push_back
#define int long long
using namespace std;
const int N = 5e5+10; 
int t,sum=0;
string s;

void solve(){
	cin>>s;
	for(int i=0;i<s.length();i++){
		for(int j=i;j>=1;j--){
			if(s[j-1]<s[j]-1){
				s[j]=(s[j]-'0')-1+'0';
				char w=s[j];
				s[j]=s[j-1];
				s[j-1]=w;
			}
		}
	} 
	cout<<s<<endl;
}

signed main(void){
	cin.tie(0);
	cout.tie(0);
	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 2):
#include <bits/stdc++.h>

using namespace std;
/*
8
4 5 4 5 4 5 4 5
0 1 1 1
*/
int T, a[200001], n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while(T--)
    {
        int i;
        cin >> n;
        for(i = 1; i <= n; i++)
            cin >> a[i];
        int x = min(a[1], a[2]);
        a[2] -= x;
        a[1] -= x;
        for(i = 3; i <= n; i++)
        {
            if(a[i - 1] != 0)
            {
                while(a[i] - a[i - 1] >= a[i - 1])
                    a[i] -= a[i - 1];
            }
        }
        bool ok = true;
        for(i = 1; i < n and ok == true; i++)
            if(a[i] > a[i + 1])
                ok = false;
        if(ok == false)
            cout << "NO\n";
        else cout << "Yes\n";
    }
    return 0;
}


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

using namespace std;
/*
4
1 4 3 2
0 3
*/
int T, a[200001], n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while(T--)
    {
        int i;
        cin >> n;
        for(i = 1; i <= n; i++)
            cin >> a[i];
        if(a[1] > a[2])
            cout << "NO\n";
        else
        {
            a[2] -= a[1];
            a[1] = 0;
            for(i = 3; i <= n; i++)
            {
                int x = a[i];
                if(a[i] == a[i - 1])
                    a[i] = a[i - 1] = 0;
                if(a[i - 1] != 0)
                {
                    while(a[i] - a[i - 1] >= a[i - 1])
                        a[i] -= a[i - 1];
                }
            }
            bool ok = true;
            for(i = 1; i < n and ok == true; i++)
                if(a[i] > a[i + 1])
                    ok = false;
            if(ok == false)
                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 <bits/stdc++.h>

using namespace std;
/*
4
1 4 3 2
0 3
*/
int T, a[200001], n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while(T--)
    {
        int i;
        cin >> n;
        for(i = 1; i <= n; i++)
            cin >> a[i];
        if(a[1] > a[2])
            cout << "NO\n";
        else
        {
            a[2] -= a[1];
            a[1] = 0;
            for(i = 3; i <= n; i++)
            {
                int x = a[i];
                if(a[i] == a[i - 1])
                    a[i] = a[i - 1] = 0;
                if(a[i - 1] != 0)
                {
                    while(a[i] - a[i - 1] >= a[i - 1])
                        a[i] -= a[i - 1];
                }
            }
            bool ok = true;
            for(i = 1; i < n and ok == true; i++)
                if(a[i] > a[i + 1])
                    ok = false;
            if(ok == false)
                cout << "NO\n";
            else cout << "Yes\n";
        }
    }
    return 0;
}


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

using namespace std;
/*
4
1 4 3 2
0 3
4
1 3 4 2
0 2 2 2
2
4
1 4 3 2
4
1 3 4 2
*/
int T, a[200001], n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while(T--)
    {
        int i;
        cin >> n;
        for(i = 1; i <= n; i++)
            cin >> a[i];
        if(a[1] > a[2])
            cout << "NO\n";
        else
        {
            a[2] -= a[1];
            a[1] = 0;
            for(i = 3; i <= n; i++)
            {
                int x = a[i - 1];
                if(a[i - 1] != 0)
                {
                    while(a[i - 1] != 0 and a[i - 1] >= a[i - 2])
                    {
                        a[i] -= a[i - 1];
                        a[i - 1] -= a[i - 1];
                    }
                }
            }
            bool ok = true;
            for(i = 1; i < n and ok == true; i++)
                if(a[i] > a[i + 1])
                    ok = false;
            if(ok == false)
                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 <bits/stdc++.h>

using namespace std;
/*
8
4 5 4 5 4 5 4 5
0 1 1 1
*/
int T, a[200001], n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while(T--)
    {
        int i;
        cin >> n;
        for(i = 1; i <= n; i++)
            cin >> a[i];
        if(a[1] > a[2])
            cout << "NO\n";
        else
        {
            a[2] -= a[1];
            a[1] = 0;
            for(i = 3; i <= n; i++)
            {
                if(a[i - 1] != 0)
                {
                    while(a[i] - a[i - 1] >= a[i - 1])
                        a[i] -= a[i - 1];
                }
            }
            bool ok = true;
            for(i = 1; i < n and ok == true; i++)
                if(a[i] > a[i + 1])
                    ok = false;
            if(ok == false)
                cout << "NO\n";
            else cout << "Yes\n";
        }
    }
    return 0;
}