ShaysXIA/CodeInsightBench huggingface dataset:
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;



// Header files, namespaces,

// macros as defined above

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;



#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



using ll = long long;

using ull = unsigned long long;



#define pb(v) push_back(v)

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

#define rall(v) (v).rbegin(), (v).rend()

#define MSET(c, v) memset(c, v, sizeof(c))

#define debug(x) cout << #x << " is " << x << endl



const int NEGINF = 0xC0C0C0C0;

const int NULO = -1;

const double EPS = 1e-10;

const ll mod = 1e9 + 7;

const ll llInf = 4e17;

const int inf = 2e9;



int dy[] = {0,1,-1,0};

int dx[] = {1,0,0,-1};



template <typename T,typename U>

std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {

return {l.first+r.first,l.second+r.second};

}



const int maxn = 2e5 + 100;



ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }



ll a[maxn];

void solveTestCase(int test) {



int n;

cin >> n;

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

cin >> a[i];

}

bool ok = true;

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

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

ok = false;

break;

} else {

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

a[i] = 0;

}

}

cout << (ok ? "YES" : "NO") << endl;

}



int main() {

ios::sync_with_stdio(false);

int test = 1;

cin >> test;

for (int t = 1; t <= test; t++) {

solveTestCase(t);

}



return 0;

}

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

using namespace std;



// Header files, namespaces,

// macros as defined above

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;



#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



using ll = long long;

using ull = unsigned long long;



#define pb(v) push_back(v)

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

#define rall(v) (v).rbegin(), (v).rend()

#define MSET(c, v) memset(c, v, sizeof(c))

#define debug(x) cout << #x << " is " << x << endl



const int NEGINF = 0xC0C0C0C0;

const int NULO = -1;

const double EPS = 1e-10;

const ll mod = 1e9 + 7;

const ll llInf = 4e17;

const int inf = 2e9;



int dy[] = {0,1,-1,0};

int dx[] = {1,0,0,-1};



template <typename T,typename U>

std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {

return {l.first+r.first,l.second+r.second};

}



const int maxn = 2e5 + 100;



ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }



ll a[maxn];

void solveTestCase(int test) {



int n;

cin >> n;

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

cin >> a[i];

}

bool ok = true;

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

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

ok = false;

break;

} else {

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

a[i] = 0;

}

}

cout << (ok ? "YES" : "NO") << endl;

}



int main() {

ios::sync_with_stdio(false);

int test = 1;

cin >> test;

for (int t = 1; t <= test; t++) {

solveTestCase(t);

}



return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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


void work(){
	string s; cin>>s;
	for(int i = 0; i < s.size(); i++){
		int maior_pos = i;
		int maior = s[i] - '0';
		int dec = 1;
		for(int k = i+1; k <= min((int)s.size()-1, k+10); k++){
			if(s[k] - '0' - dec > maior){
				maior = (s[k] - '0') - dec;
				maior_pos = k;
			}
			dec++;
		}
		s.erase(s.begin() + maior_pos);
		s.insert(s.begin() + i, maior + '0');
	}
	cout<<s<<endl;
}

signed main(){
	int tt; cin>>tt;
	while(tt--){
		work();
	}
}

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

void rearange(string &s, int pos, int k){
	int c = s[pos] - '0';
	c -= (pos - k);
	for(int i = pos; i > k; i--){
		s[i] = s[i-1];
	}
	s[k] = c + '0';
}

void work(){
	string s; cin>>s;
	for(int i = 0; i < s.size(); i++){
		int maior_pos = i;
		int maior = s[i] - '0';
		int dec = 1;
		for(int k = i+1; k <= min((int)s.size()-1, k+10); k++){
			if(s[k] - '0' - dec > maior){
				maior = (s[k] - '0') - dec;
				maior_pos = k;
			}
			dec++;
		}
		rearange(s, maior_pos, i);
	}
	cout<<s<<endl;
}

signed main(){
	int tt; cin>>tt;
	while(tt--){
		work();
	}
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

void rearange(string &s, int pos, int k){
	int c = s[pos] - '0';
	c -= (pos - k);
	for(int i = pos; i > k; i--){
		s[i] = s[i-1];
	}
	s[k] = c + '0';
}

void work(){
	string s; cin>>s;
	for(int i = 0; i < s.size(); i++){
		int maior_pos = i;
		int maior = s[i] - '0';
		int dec = 1;
		for(int k = i+1; k <= min((int)s.size()-1, k+10); k++){
			if(s[k] - '0' - dec > maior){
				maior = (s[k] - '0') - dec;
				maior_pos = k;
			}
			dec++;
		}
		rearange(s, maior_pos, i);
	}
	cout<<s<<endl;
}

signed main(){
	int tt; cin>>tt;
	while(tt--){
		work();
	}
}

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

void rearange(string &s, int pos, int k){
	int c = s[pos] - '0';
	c -= (pos - k);
	for(int i = pos; i > k; i--){
		s[i] = s[i-1];
	}
	s[k] = c + '0';
}

void work(){
	string s; cin>>s;
	for(int i = 0; i < s.size(); i++){
		int maior_pos = i;
		int maior = s[i] - '0';
		int dec = 1;
		for(int k = i+1; k <= min((int)s.size()-1, i+9); k++){
			if(s[k] - '0' - dec > maior){
				maior = (s[k] - '0') - dec;
				maior_pos = k;
			}
			dec++;
		}
		rearange(s, maior_pos, i);
	}
	cout<<s<<endl;
}

signed main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int tt; cin>>tt;
	while(tt--){
		work();
	}
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


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


void work(){
	string s; cin>>s;
	for(int i = 0; i < s.size(); i++){
		int maior_pos = i;
		int maior = s[i] - '0';
		int dec = 1;
		for(int k = i+1; k <= min((int)s.size()-1, k+10); k++){
			if(s[k] - '0' - dec > maior){
				maior = (s[k] - '0') - dec;
				maior_pos = k;
			}
			dec++;
		}
		s.erase(s.begin() + maior_pos);
		s.insert(s.begin() + i, maior + '0');
	}
	cout<<s<<endl;
}

signed main(){
	int tt; cin>>tt;
	while(tt--){
		work();
	}
}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>  



using namespace __gnu_pbds;

using namespace std;



using ll=long long;

using PII=pair<ll,ll>;

using TR=tuple<ll,ll,ll>; 

using ordered_set=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

const int N = 1e6+10,MOD=1e9+7;

const ll inf=0x3f;

ll n,m,k,q;

int dir[8][2]={{1,1},{1,-1},{-1,-1},{-1,1}};

unordered_map<int,vector<PII>>e;

int a[N];



struct node{	

	int x,w;

	int idx;

//	bool operator<(const node&t)const{

//	   if(k==t.k){

//	   	   if(idx==t.idx){

//	   	   	  return s>t.s;

//			}

//			return idx>t.idx;

//	   }

//	   return k<t.k;

//	}

};



void solve(){

	cin>>n;

	for(int i=0;i<n;i++)cin>>a[i];

	

	int sum1=0,sum2=0,odd=0,even=0;

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

		if(i%2)sum1+=a[i],odd++;

		else sum2+=a[i],even++; 

	}

	

	if(sum1%odd==0&&sum2%even==0&&sum1/odd==sum2/even)cout<<"YES"<<endl;

    else cout<<"NO"<<endl;

}                                



int main(){

	ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    

    

    int t=1;

    cin>>t;

    int cnt=1;

    while(t--){

      // cout<<cnt++<<endl; 

       solve(); 

    }

    return 0;

}

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>  



using namespace __gnu_pbds;

using namespace std;



using ll=long long;

using PII=pair<ll,ll>;

using TR=tuple<ll,ll,ll>; 

using ordered_set=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

const int N = 1e6+10,MOD=1e9+7;

const ll inf=0x3f;

ll n,m,k,q;

int dir[8][2]={{1,1},{1,-1},{-1,-1},{-1,1}};

unordered_map<int,vector<PII>>e;

int a[N];



struct node{	

	int x,w;

	int idx;

//	bool operator<(const node&t)const{

//	   if(k==t.k){

//	   	   if(idx==t.idx){

//	   	   	  return s>t.s;

//			}

//			return idx>t.idx;

//	   }

//	   return k<t.k;

//	}

};



void solve(){

	cin>>n;

	for(int i=0;i<n;i++)cin>>a[i];

	

	ll sum1=0,sum2=0,odd=0,even=0;

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

		if(i%2)sum1+=a[i],odd++;

		else sum2+=a[i],even++; 

	}

	

	if(sum1%odd==0&&sum2%even==0&&sum1/odd==sum2/even)cout<<"YES"<<endl;

    else cout<<"NO"<<endl;

}                                



int main(){

	ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    

    

    int t=1;

    cin>>t;

    int cnt=1;

    while(t--){

      // cout<<cnt++<<endl; 

       solve(); 

    }

    return 0;

}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)


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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>  



using namespace __gnu_pbds;

using namespace std;



using ll=long long;

using PII=pair<ll,ll>;

using TR=tuple<ll,ll,ll>; 

using ordered_set=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

const int N = 1e6+10,MOD=1e9+7;

const ll inf=0x3f;

ll n,m,k,q;

int dir[8][2]={{1,1},{1,-1},{-1,-1},{-1,1}};

unordered_map<int,vector<PII>>e;

int a[N];



struct node{	

	int x,w;

	int idx;

//	bool operator<(const node&t)const{

//	   if(k==t.k){

//	   	   if(idx==t.idx){

//	   	   	  return s>t.s;

//			}

//			return idx>t.idx;

//	   }

//	   return k<t.k;

//	}

};



void solve(){

	cin>>n;

	for(int i=0;i<n;i++)cin>>a[i];

	

	int sum=0;

	for(int i=0;i<n;i++)sum+=a[i];

	

	int tz=sum/n,odd=0,even=0;

	if(sum%n){

		cout<<"NO"<<endl;

		return;

	}

	

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

		odd+=a[i]-tz;

	}

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

		even+=a[i]-tz;

	}

	if(odd||even)cout<<"NO"<<endl;

	else cout<<"YES"<<endl;

}                                



int main(){

	ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    

    

    int t=1;

    cin>>t;

    int cnt=1;

    while(t--){

      // cout<<cnt++<<endl; 

       solve(); 

    }

    return 0;

}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>  



using namespace __gnu_pbds;

using namespace std;



using ll=long long;

using PII=pair<ll,ll>;

using TR=tuple<ll,ll,ll>; 

using ordered_set=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

const int N = 1e6+10,MOD=1e9+7;

const ll inf=0x3f;

ll n,m,k,q;

int dir[8][2]={{1,1},{1,-1},{-1,-1},{-1,1}};

unordered_map<int,vector<PII>>e;

int a[N];



struct node{	

	int x,w;

	int idx;

//	bool operator<(const node&t)const{

//	   if(k==t.k){

//	   	   if(idx==t.idx){

//	   	   	  return s>t.s;

//			}

//			return idx>t.idx;

//	   }

//	   return k<t.k;

//	}

};



void solve(){

	cin>>n;

	for(int i=0;i<n;i++)cin>>a[i];

	

	int sum=0;

	for(int i=0;i<n;i++)sum+=a[i];

	

	int tz=sum/n,odd=0,even=0;

	if(sum%n){

		cout<<"NO"<<endl;

		return;

	}

	

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

		odd+=a[i]-tz;

	}

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

		even+=a[i]-tz;

	}

	if(odd||even)cout<<"NO"<<endl;

	else cout<<"YES"<<endl;

}                                



int main(){

	ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    

    

    int t=1;

    cin>>t;

    int cnt=1;

    while(t--){

      // cout<<cnt++<<endl; 

       solve(); 

    }

    return 0;

}

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>  



using namespace __gnu_pbds;

using namespace std;



using ll=long long;

using PII=pair<ll,ll>;

using TR=tuple<ll,ll,ll>; 

using ordered_set=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

const int N = 1e6+10,MOD=1e9+7;

const ll inf=0x3f;

ll n,m,k,q;

int dir[8][2]={{1,1},{1,-1},{-1,-1},{-1,1}};

unordered_map<int,vector<PII>>e;

int a[N];



struct node{	

	int x,w;

	int idx;

//	bool operator<(const node&t)const{

//	   if(k==t.k){

//	   	   if(idx==t.idx){

//	   	   	  return s>t.s;

//			}

//			return idx>t.idx;

//	   }

//	   return k<t.k;

//	}

};



void solve(){

	cin>>n;

	for(int i=0;i<n;i++)cin>>a[i];

	

	int sum1=0,sum2=0,odd=0,even=0;

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

		if(i%2)sum1+=a[i],odd++;

		else sum2+=a[i],even++; 

	}

	

	if(sum1%odd==0&&sum2%even==0&&sum1/odd==sum2/even)cout<<"YES"<<endl;

    else cout<<"NO"<<endl;

}                                



int main(){

	ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    

    

    int t=1;

    cin>>t;

    int cnt=1;

    while(t--){

      // cout<<cnt++<<endl; 

       solve(); 

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


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

template <typename K, typename V>
void printMap(const map<K, V>& m) {
    for (const auto& pair : m) {
        cout << pair.first << " -> " << pair.second << "\n";
    }
}

void print(vector<ll> &v) {
    for (auto a : v) {
        cout << a << " ";
    }
    cout << endl;
}

void printNestedVector(const vector<vector<pair<ll, ll>>> &v) {
    for (size_t i = 0; i < v.size(); ++i) {
        cout << "Index " << i << ": ";
        if (v[i].empty()) {
            cout << "Empty";
        } else {
            for (const auto &p : v[i]) {
                cout << "(" << p.first << ", " << p.second << ") ";
            }
        }
        cout << endl;
    }
}
bool func(string &s,ll m,ll k){

}

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

    ll T;
    cin >> T;
    while (T--) {
        string s;
        cin>>s;
        ll n=s.size();
        ll sm=0,tos=0,tes=0;
        for(int i=0;i<n;i++){
            sm+=s[i]-'0';
            if(s[i]=='2'){
                tos++;
            }else if(s[i]=='3'){
                tes++;
            }
        }
        if(sm%9==0){
            cout<<"YES"<<endl;
        }else if(sm%9==1 && ((tos>3) || (tos>0 && tes>0))){
            cout<<"YES"<<endl;
        }else if(sm%9==3 && (tos>=3 || tes>=1)){
            cout<<"YES"<<endl;
        }else if(sm%9==5 && tos>=2){
            cout<<"YES"<<endl;
        }else if(sm%9==7 && tos>=1){
            cout<<"YES"<<endl;
        }else if(sm%9==6 && (tes>=2 || (tes>=1 || tos>=3) || (tos>=6))){
            cout<<"YES"<<endl;
        }else if(sm%9==4 && ((tes>=2 && tos>=1) || (tes>=1 || tos>=4) || (tos>=7)) ){
            cout<<"YES"<<endl;
        }else if(sm%9==2 && ((tes>=2 && tos>=2) || (tes>=1 || tos>=5) || (tos>=8))){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define lld  long double
#define fn(n) for (int i = 0; i < n; i++)
#define f(i, x, n) for (int i = x; i < n; i++)
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define cyes cout<<"YES"<<"\n"
#define cno cout<<"NO"<<"\n"
#define vi vector<int>
#define vll vector<ll>
#define inf 2147483647
#define msdfan ios_base::sync_with_stdio(false);cin.tie(NULL);
const int mod = 1e9+7;
const int N = 3000 + 2;
template <typename T>
void printv(const T &t){{std::copy(t.cbegin(), t.cend(), std::ostream_iterator<typename T::value_type>(std::cout, " "));  }  cout << "\n";}
template <class T>
void cc(T a) { cout << a << "\n"; } 
template <class T>
void kk(T a) { cout << a << " "; }


int dp[N][N];


int func(int i,int j,string &a,string &b,string &c){
    if(i == a.size()){
        int d = 0;
        while(j < b.size()){
             int currInd = i + j;
             d += (b[j] != c[currInd]);
             j++;
        }
        return d;
    }
    else if(j == b.size()){
        int d = 0;
        while(i < a.size()){
             int currInd = i + j;
             d += (a[i] != c[currInd]);
             i++;
        }
        return d;
    }
    if(dp[i][j] != -1) return dp[i][j];
    
    int fromA = 1e14,fromB = 1e14;

    if(i < a.size()){
        int currInd = i + j;
        fromA = (c[currInd] != a[i]) + func(i+1,j,a,b,c);
    }
    if(j < b.size()){
        int currInd = i + j;
        fromB = (c[currInd] != b[j]) + func(i,j+1,a,b,c);
    }

    return dp[i][j] = min(fromA,fromB);
}

void solve(){
string a,b,c;
cin >> a >> b >> c;

memset(dp,-1,sizeof(dp));

cc(func(0,0,a,b,c));
}




int32_t main(){
msdfan;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif


int tt = 1;
cin >> tt;

for(int i = 0; i < tt; i++){
    solve();
}


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

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

#include<algorithm>

#include<map>

#include<set>

#include<cstring>

#include<queue>

#include<vector>

#include<cmath>

#include<unordered_map>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

#define fir first

#define sec second

const int N=2e5+10,mod=1e9+7,inf=0x3f3f3f3f;



int dx[]={-1,0,1,0};

int dy[]={0,1,0,-1};







void solve(){

	int n;

	cin>>n;

	vector<int> a(n);

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

		int x;

		cin>>x;

		a[i-1]=x;

	}

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

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

		a[i]-=x;

		a[i+1]-=x;

	}

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

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

			cout<<"No\n";

			return;

		}

	}

	cout<<"Yes\n";

}



signed main(){

	ios::sync_with_stdio(false);

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

	int t=1;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

}

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

#include<algorithm>

#include<map>

#include<set>

#include<cstring>

#include<queue>

#include<vector>

#include<cmath>

#include<unordered_map>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

#define fir first

#define sec second

const int N=2e5+10,mod=1e9+7,inf=0x3f3f3f3f;



int dx[]={-1,0,1,0};

int dy[]={0,1,0,-1};







void solve(){

	int n;

	cin>>n;

	vector<int> a(n);

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

		int x;

		cin>>x;

		a[i-1]=x;

	}

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

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

		a[i]-=x;

		a[i+1]-=x;

	}

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

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

			cout<<"No\n";

			return;

		}

	}

	cout<<"Yes\n";

}



signed main(){

	ios::sync_with_stdio(false);

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

	int t=1;

	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 2):
#include<iostream>

#include<algorithm>

#include<map>

#include<set>

#include<cstring>

#include<queue>

#include<vector>

#include<cmath>

#include<unordered_map>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

#define fir first

#define sec second

const int N=2e5+10,mod=1e9+7,inf=0x3f3f3f3f;



int dx[]={-1,0,1,0};

int dy[]={0,1,0,-1};







void solve(){

	int n;

	cin>>n;

	vector<int> a(n);

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

		int x;

		cin>>x;

		a[i-1]=x;

	}

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

		if(a[i]<a[i-1]&&a[i]>a[i+1]){

			cout<<"No\n";

			return;

		}

	}

	cout<<"Yes\n";

}



signed main(){

	ios::sync_with_stdio(false);

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

	int t=1;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

}

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

#include<algorithm>

#include<map>

#include<set>

#include<cstring>

#include<queue>

#include<vector>

#include<cmath>

#include<unordered_map>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

#define fir first

#define sec second

const int N=2e5+10,mod=1e9+7,inf=0x3f3f3f3f;



int dx[]={-1,0,1,0};

int dy[]={0,1,0,-1};







void solve(){

	int n;

	cin>>n;

	vector<int> a(n);

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

		int x;

		cin>>x;

		a[i-1]=x;

	}

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

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

		a[i]-=x;

		a[i+1]-=x;

	}

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

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

			cout<<"No\n";

			return;

		}

	}

	cout<<"Yes\n";

}



signed main(){

	ios::sync_with_stdio(false);

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

	int t=1;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

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


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

#include<algorithm>

#include<map>

#include<set>

#include<cstring>

#include<queue>

#include<vector>

#include<cmath>

#include<unordered_map>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

#define fir first

#define sec second

const int N=2e5+10,mod=1e9+7,inf=0x3f3f3f3f;



int dx[]={-1,0,1,0};

int dy[]={0,1,0,-1};







void solve(){

	int n;

	cin>>n;

	vector<int> a(n);

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

		int x;

		cin>>x;

		a[i-1]=x;

	}

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

		if(a[i]<a[i-1]&&a[i]>a[i+1]){

			cout<<"No\n";

			return;

		}

	}

	cout<<"Yes\n";

}



signed main(){

	ios::sync_with_stdio(false);

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

	int t=1;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

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


Submission (verdict: Time limit exceeded on test 16):
#include <bits/stdc++.h>
using namespace std;
int ar[2001][2001]; //ar[a][b] la gia tri minimum cua de bai khi day st1 co a phan tu dau tien, 
                    //st2 co b phan tu dau tien, va st co a+b phan tu dau tien

int minn (int a, int b){
    if (a<b) return a;
    return b;
}
//ab 
//ba 
//aabb
void dp (string st1, int s1, string st2, int s2, string st){
    //s1 la do dai chuoi st1, s1 la do dai chuoi st2
    //s1, s2 la so luong phan tu nhe, trong ham main thi ghi la 
    // dp(st1, st1.length(), st2, st2.length(), st)
    int a = s1;
    int b = s2;
    // truong hop co so 
    if (a==0){
        if (ar[0][b-1]==-1) dp(st1, 0, st2, b-1, st);
        if (st[b-1]==st2[b-1]) ar[0][b]=ar[0][b-1];
        else ar[0][b]=ar[0][b-1]+1;
        return;
    }
    if (b==0){
        if (ar[0][b-1]==-1) dp(st1, 0, st2, b-1, st);
        if (st[a-1]==st1[a-1]) ar[a][0]=ar[a-1][0];
        else ar[a][0]=ar[a-1][0]+1;
        return;
    }
    // xu ly
    // so sanh st[i] voi st1[a] va st2[b]
    // neu st[i] bang mot trong hai thi ar[a][b]=(ar[a-1][b] HOAC ar[a][b-1])
    // neu st[i] bang ca hai thi ar[a][b]= MIN(ar[a-1][b] VA ar[a][b-1])
    // neu st[i] khac ca hai thi ar[a][b]= MIN(ar[a-1][b] VA ar[a][b-1]) + 1
    // tat nhien la phai check xem ar[a-1][b] co ton tai ko, neu ko thi = dp (...)
    int i=a+b-1;
    if (ar[a-1][b]==-1) {
        dp(st1, a-1, st2, b, st);
    }
    if (ar[a][b-1]==-1) {
        dp(st1, a, st2, b-1, st);
    }
    // --------------------------------------
    if (st[i]==st1[a-1] && st[i]==st2[b-1]){
        int mini = minn(ar[a-1][b], ar[a][b-1]);
        ar[a][b]=mini;
    }
    else if (st[i]!=st1[a-1] && st[i]==st2[b-1]) {
        ar[a][b]=minn(ar[a][b-1], ar[a-1][b]+1);
    }
    else if (st[i]==st1[a-1] && st[i]!=st2[b-1]) {
        ar[a][b]=minn(ar[a-1][b], ar[a][b-1]+1);
    }
    else {
        int mini = minn(ar[a-1][b], ar[a][b-1]) + 1;
        ar[a][b]=mini;
    }
}
// e   g   g
// ann    ie
// egaeg   ae   g
int main() {
    int test;
    cin>>test;
    string st, st1, st2;
    for (int it=0; it<test; it++){
        cin>>st1>>st2>>st;
        for (int i=0; i<2001; i++){
            for (int j=0; j<2001; j++){
                ar[i][j]=-1;
            }
        }
        if (st[0]==st1[0]) ar[1][0]=0; else ar[1][0]=1;
        if (st[0]==st2[0]) ar[0][1]=0; else ar[0][1]=1;//bang 1 het do
        dp(st1, st1.length(), st2, st2.length(), st); //dp(a, 1, bcd, 3, decf)
        cout<<ar[st1.length()][st2.length()]<<"\n";
    }
    return 0;
}