ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define rep(i ,a ,b) for(int i =a;i<=b;++i)
#define endl '\n'
#define debug(a) cout<<#a<<'='<<a<<endl;
#define inf 0x3f3f3f3f
#define ls u<<1
#define rs u<<1|1
typedef pair<int,int> pii;
int ksm(int a , int b){
	int res = 1;
	while(b){
		if(b&1) res = res * a ;
		b >>= 1;
		a = a * a ;
	}
	return res;
}
void solve(){
   int l , r;
   cin>>l>>r;
   int cnt = 0;
   int ans = 0;
//    while(1){
//     if(ksm(2 , cnt) <= r){
//         ans = ksm(2 , cnt);
//         cnt++;
//     }
//     else{
//         break;
//     }

//    }
//    if(ans -2 <= l){
//     cout<<ans<<' '<<ans-1<<' '<<l<<endl;
//    }
//     int a = (123  ^121) + (123 ^118) + (121 ^ 118);
//     int b = (115  ^ 117) + (120 ^117) + (115^120);
//     cout<<a<<' '<<b<<endl;

    if(r - l >= 5){
        cout<<l<<' '<<l+2<<' '<<l+2+3<<endl;
        return;
    }
    cout<<l<<' '<<l+1<<' '<<l+2<<endl;
}
 
 
signed main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int _ = 1;
    cin>>_; 
    while(_--)solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define rep(i ,a ,b) for(int i =a;i<=b;++i)
#define endl '\n'
#define debug(a) cout<<#a<<'='<<a<<endl;
#define inf 0x3f3f3f3f
#define ls u<<1
#define rs u<<1|1
typedef pair<int,int> pii;
int ksm(int a , int b){
	int res = 1;
	while(b){
		if(b&1) res = res * a ;
		b >>= 1;
		a = a * a ;
	}
	return res;
}
void solve(){
   int l , r;
   cin>>l>>r;
   int cnt = 0;
   int ans = 0;
   while(1){
    if(ksm(2 , cnt) <= r){
        ans = ksm(2 , cnt);
        cnt++;
    }
    else{
        break;
    }

   }
 
   if(ans -2 >= l){
    cout<<ans<<' '<<ans-1<<' '<<l<<endl;
    return;
   }
    if(r - l >= 5){
        cout<<l<<' '<<l+2<<' '<<l+2+3<<endl;
        return;
    }
    cout<<l<<' '<<l+1<<' '<<l+2<<endl;
}
 
 
signed main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int _ = 1;
    cin>>_; 
    while(_--)solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
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 
#define rep(i ,a ,b) for(int i =a;i<=b;++i)
#define endl '\n'
#define debug(a) cout<<#a<<'='<<a<<endl;
#define inf 0x3f3f3f3f
#define ls u<<1
#define rs u<<1|1
typedef pair<int,int> pii;
int ksm(int a , int b){
	int res = 1;
	while(b){
		if(b&1) res = res * a ;
		b >>= 1;
		a = a * a ;
	}
	return res;
}
void solve(){
   int l , r;
   cin>>l>>r;
   int cnt = 0;

   if(r - l == 2){
    cout<<l<<' '<<l+1<<' '<<l+2<<endl;
    return;
   }
   int ans = 0;
   while(1){
    int x = 1;
    while(x*2 <= r)x *=2;
    if(x <=l){
        ans +=x;
        r -=x;
        l -=x;
        continue;
    }
    cout<<x + ans<<' '<<x + ans-1<<' '<<l+ans<<endl;
    return;
    

   }
 
  
}
 
 
signed main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int _ = 1;
    cin>>_; 
    while(_--)solve();
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define rep(i ,a ,b) for(int i =a;i<=b;++i)
#define endl '\n'
#define debug(a) cout<<#a<<'='<<a<<endl;
#define inf 0x3f3f3f3f
#define ls u<<1
#define rs u<<1|1
typedef pair<int,int> pii;
int ksm(int a , int b){
	int res = 1;
	while(b){
		if(b&1) res = res * a ;
		b >>= 1;
		a = a * a ;
	}
	return res;
}
void solve(){
   int l , r;
   cin>>l>>r;
   int cnt = 0;

   if(r - l == 2){
    cout<<l<<' '<<l+1<<' '<<l+2<<endl;
    return;
   }
   int ans = 0;
   while(1){
    int x = 1;
    while(x*2 <= r)x *=2;
    if(x <=l){
        ans +=x;
        r -=x;
        l -=x;
        continue;
    }
    if(x == r)cout<<x + ans<<' '<<x + ans-1<<' '<<l+ans<<endl;
    else cout<<x + ans<<' '<<x + ans-1<<' '<<r+ans<<endl;
    return;
    

   }
 
  
}
 
 
signed main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int _ = 1;
    cin>>_; 
    while(_--)solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define rep(i ,a ,b) for(int i =a;i<=b;++i)
#define endl '\n'
#define debug(a) cout<<#a<<'='<<a<<endl;
#define inf 0x3f3f3f3f
#define ls u<<1
#define rs u<<1|1
typedef pair<int,int> pii;
int ksm(int a , int b){
	int res = 1;
	while(b){
		if(b&1) res = res * a ;
		b >>= 1;
		a = a * a ;
	}
	return res;
}
void solve(){
   int l , r;
   cin>>l>>r;
   int cnt = 0;
   int ans = 0;
   while(1){
    if(ksm(2 , cnt) <= r){
        ans = ksm(2 , cnt);
        cnt++;
    }
    else{
        break;
    }

   }
   cout<<ans<<' '<<ans-1<<' '<<l<<endl;

}
 
 
signed main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int _ = 1;
    cin>>_; 
    while(_--)solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define rep(i ,a ,b) for(int i =a;i<=b;++i)
#define endl '\n'
#define debug(a) cout<<#a<<'='<<a<<endl;
#define inf 0x3f3f3f3f
#define ls u<<1
#define rs u<<1|1
typedef pair<int,int> pii;
int ksm(int a , int b){
	int res = 1;
	while(b){
		if(b&1) res = res * a ;
		b >>= 1;
		a = a * a ;
	}
	return res;
}
void solve(){
   int l , r;
   cin>>l>>r;
   int cnt = 0;
   int ans = 0;
   while(1){
    if(ksm(2 , cnt) <= r){
        ans = ksm(2 , cnt);
        cnt++;
    }
    else{
        break;
    }

   }
 
   if(ans -2 >= l){
    cout<<ans<<' '<<ans-1<<' '<<l<<endl;
    return;
   }
    if(r - l >= 5){
        cout<<l<<' '<<l+2<<' '<<l+2+3<<endl;
        return;
    }
    cout<<l<<' '<<l+1<<' '<<l+2<<endl;
}
 
 
signed main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int _ = 1;
    cin>>_; 
    while(_--)solve();
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define rep(i ,a ,b) for(int i =a;i<=b;++i)
#define endl '\n'
#define debug(a) cout<<#a<<'='<<a<<endl;
#define inf 0x3f3f3f3f
#define ls u<<1
#define rs u<<1|1
typedef pair<int,int> pii;
int ksm(int a , int b){
	int res = 1;
	while(b){
		if(b&1) res = res * a ;
		b >>= 1;
		a = a * a ;
	}
	return res;
}
void solve(){
   int l , r;
   cin>>l>>r;
   int cnt = 0;

   if(r - l == 2){
    cout<<l<<' '<<l+1<<' '<<l+2<<endl;
    return;
   }
   int ans = 0;
   while(1){
    int x = 1;
    while(x*2 <= r)x *=2;
    if(x <=l){
        ans +=x;
        r -=x;
        l -=x;
        continue;
    }
    cout<<x + ans<<' '<<x + ans-1<<' '<<l+ans<<endl;
    return;
    

   }
 
  
}
 
 
signed main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int _ = 1;
    cin>>_; 
    while(_--)solve();
    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;
inline int read(){
	int kkksc03=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){kkksc03=(kkksc03<<1)+(kkksc03<<3)+(ch^48);ch=getchar();}
	return kkksc03*f;
}
inline void write(int kkk){
	if(kkk<0) kkk=-kkk,putchar('-');
	int cnt=0;char cc[20];
	do{cc[++cnt]=48+kkk%10;kkk/=10;}while(kkk);
	while(cnt) putchar(cc[--cnt+1]);
	putchar('\n');
	return;
}
struct Z{
	int y,d,o;
	bool operator < (const Z& bb) const{
		return d-o < bb.d-bb.o;
	}
};
int t,n,ans=0,du[200010];
bool vis[200010];
vector<int> v[200010];
priority_queue<Z> pq;
signed main(){
	t=read();
	while(t--){
		n=read();ans=0;
		for(int i=1,a,b;i<n;i++){
			a=read();b=read();
			++du[a];++du[b];
			v[a].push_back(b);
			v[b].push_back(a);
		}
		int mx=0;
		for(int i=1;i<=n;i++) pq.push((Z){i,du[i],0}),mx=max(mx,du[i]);
		while(!pq.empty()){
			Z x=pq.top();pq.pop();
			if(x.o) continue;
			if(x.d!=mx) break;
			for(auto u:v[x.y]) vis[u]=1,pq.push((Z){u,du[u],1});
			while(!pq.empty()){
				Z xx=pq.top();pq.pop();
				if(xx.o!=vis[xx.y]) continue;
				ans=max(ans,x.d+xx.d-xx.o-1);
				break;
			}
			for(auto u:v[x.y]) vis[u]=0;
		}
		write(ans);
		while(!pq.empty()) pq.pop();
		for(int i=1;i<=n;i++) du[i]=0,v[i].clear();
	}
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int kkksc03=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){kkksc03=(kkksc03<<1)+(kkksc03<<3)+(ch^48);ch=getchar();}
	return kkksc03*f;
}
inline void write(int kkk){
	if(kkk<0) kkk=-kkk,putchar('-');
	int cnt=0;char cc[20];
	do{cc[++cnt]=48+kkk%10;kkk/=10;}while(kkk);
	while(cnt) putchar(cc[--cnt+1]);
	putchar('\n');
	return;
}
struct Z{
	int y,d,o;
	bool operator < (const Z& bb) const{
		return d-o < bb.d-bb.o;
	}
};
int t,n,ans=0,du[200010];
bool vis[200010];
vector<int> v[200010];
priority_queue<Z> pq;
signed main(){
	t=read();
	while(t--){
		n=read();ans=0;
		for(int i=1,a,b;i<n;i++){
			a=read();b=read();
			++du[a];++du[b];
			v[a].push_back(b);
			v[b].push_back(a);
		}
		int mx=0;
		for(int i=1;i<=n;i++) pq.push((Z){i,du[i],0}),mx=max(mx,du[i]);
		while(!pq.empty()){
			Z x=pq.top();pq.pop();
			if(x.o) continue;
			for(auto u:v[x.y]) vis[u]=1,pq.push((Z){u,du[u],1});
			while(!pq.empty()){
				Z xx=pq.top();pq.pop();
				if(xx.o!=vis[xx.y]) continue;
				ans=max(ans,x.d+xx.d-xx.o-1);
				break;
			}
			for(auto u:v[x.y]) vis[u]=0;
		}
		write(ans);
		while(!pq.empty()) pq.pop();
		for(int i=1;i<=n;i++) du[i]=0,v[i].clear();
	}
	return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int kkksc03=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){kkksc03=(kkksc03<<1)+(kkksc03<<3)+(ch^48);ch=getchar();}
	return kkksc03*f;
}
inline void write(int kkk){
	if(kkk<0) kkk=-kkk,putchar('-');
	int cnt=0;char cc[20];
	do{cc[++cnt]=48+kkk%10;kkk/=10;}while(kkk);
	while(cnt) putchar(cc[--cnt+1]);
	putchar('\n');
	return;
}
int t,n,ans=0,du[200010];
vector<int> v[200010],qwq;
map<pair<int,int>,bool> mp;
signed main(){
	t=read();
	while(t--){
		n=read();ans=0;
		for(int i=1,a,b;i<n;i++){
			a=read();b=read();
			mp[{a,b}]=1;mp[{b,a}]=1;
			++du[a];++du[b];
			v[a].push_back(b);
			v[b].push_back(a);
		}
		if(n==2){
			puts("0");
			qwq.clear();mp.clear();
			for(int i=1;i<=n;i++) du[i]=0,v[i].clear();
			continue;
		}
		int mx=0;
		for(int i=1;i<=n;i++) mx=max(mx,du[i]);
		for(int i=1;i<=n;i++) if(mx==du[i]) qwq.push_back(i);
		if(qwq.size()==1){
			mx=0;
			for(int i=1;i<=n;i++) if(i!=qwq.back()) mx=max(mx,du[i]);
			for(int i=1;i<=n;i++) if(mx==du[i]) ans=max(ans,du[qwq.back()]+du[i]-1-mp[{i,qwq.back()}]);
		}else{
			ans=mx*2-2;
			bool p=0;
			for(int i=0;i<qwq.size();i++){
				for(int j=i+1;j<qwq.size();j++){
					if(!mp[{qwq[i],qwq[j]}]){
						p=1;
						++ans;
						break;
					}
				}
				if(p) break;
			}
		}
		write(ans);
		qwq.clear();mp.clear();
		for(int i=1;i<=n;i++) du[i]=0,v[i].clear();
	}
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int kkksc03=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){kkksc03=(kkksc03<<1)+(kkksc03<<3)+(ch^48);ch=getchar();}
	return kkksc03*f;
}
inline void write(int kkk){
	if(kkk<0) kkk=-kkk,putchar('-');
	int cnt=0;char cc[20];
	do{cc[++cnt]=48+kkk%10;kkk/=10;}while(kkk);
	while(cnt) putchar(cc[--cnt+1]);
	putchar('\n');
	return;
}
struct Z{
	int y,d,o;
	bool operator < (const Z& bb) const{
		return d-o < bb.d-bb.o;
	}
};
int t,n,ans=0,du[200010];
bool vis[200010];
vector<int> v[200010];
priority_queue<Z> pq;
signed main(){
	t=read();
	while(t--){
		n=read();ans=0;
		for(int i=1,a,b;i<n;i++){
			a=read();b=read();
			++du[a];++du[b];
			v[a].push_back(b);
			v[b].push_back(a);
		}
		int mx=0;
		for(int i=1;i<=n;i++) pq.push((Z){i,du[i],0}),mx=max(mx,du[i]);
		while(!pq.empty()){
			Z x=pq.top();pq.pop();
			if(x.o) continue;
			if(x.d!=mx) break;
			for(auto u:v[x.y]) vis[u]=1,pq.push((Z){u,du[u],1});
			while(!pq.empty()){
				Z xx=pq.top();pq.pop();
				if(xx.o!=vis[xx.y]) continue;
				ans=max(ans,x.d+xx.d-xx.o-1);
				break;
			}
			for(auto u:v[x.y]) vis[u]=0;
		}
		write(ans);
		while(!pq.empty()) pq.pop();
		for(int i=1;i<=n;i++) du[i]=0,v[i].clear();
	}
	return 0;
}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int kkksc03=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){kkksc03=(kkksc03<<1)+(kkksc03<<3)+(ch^48);ch=getchar();}
	return kkksc03*f;
}
inline void write(int kkk){
	if(kkk<0) kkk=-kkk,putchar('-');
	int cnt=0;char cc[20];
	do{cc[++cnt]=48+kkk%10;kkk/=10;}while(kkk);
	while(cnt) putchar(cc[--cnt+1]);
	putchar('\n');
	return;
}
struct Z{
	int y,d,o;
	bool operator < (const Z& bb) const{
		return d-o < bb.d-bb.o;
	}
};
int t,n,ans=0,du[200010];
bool vis[200010];
vector<int> v[200010];
priority_queue<Z> pq;
signed main(){
	t=read();
	while(t--){
		n=read();ans=0;
		for(int i=1,a,b;i<n;i++){
			a=read();b=read();
			++du[a];++du[b];
			v[a].push_back(b);
			v[b].push_back(a);
		}
		int mx=0;
		for(int i=1;i<=n;i++) pq.push((Z){i,du[i],0}),mx=max(mx,du[i]);
		while(!pq.empty()){
			Z x=pq.top();pq.pop();
			if(x.o) continue;
			for(auto u:v[x.y]) vis[u]=1,pq.push((Z){u,du[u],1});
			while(!pq.empty()){
				Z xx=pq.top();pq.pop();
				if(xx.o!=vis[xx.y]) continue;
				ans=max(ans,x.d+xx.d-xx.o-1);
				break;
			}
			for(auto u:v[x.y]) vis[u]=0;
		}
		write(ans);
		while(!pq.empty()) pq.pop();
		for(int i=1;i<=n;i++) du[i]=0,v[i].clear();
	}
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
int a[200005]; 
void solve()
{	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];

	for(int i=1;i<=n-1;i++)	if(a[i]<=a[i+1])	a[i+1]-=a[i],a[i]=0;
	
	for(int i=1;i<n;i++)	if(a[i]>a[i+1])	{
		ans=0;
		break;
	}
	if(!ans)	cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)	solve();	
	return 0;
 } 

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int a[200005]; 
void solve()
{	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];

	for(int i=1;i<=n-1;i++)	if(a[i]<=a[i+1])	a[i+1]-=a[i],a[i]=0;
	int ans=1; 
	for(int i=1;i<n;i++)	if(a[i]>a[i+1])	{
		ans=0;
		break;
	}
	if(!ans)	cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.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 2):
#include<bits/stdc++.h>
using namespace std;
int a[200005]; 
void solve()
{	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	
	for(int i=1;i<=n-1;i++)
	{
		if(a[i]>a[i+1])	
		{
		cout<<"NO"<<endl;
		return ;
		}
		else if(a[i+1]>a[i+2])
		{
			int res=min(a[i],a[i+1]);
			a[i]-=res;
			a[i+1]-=res;
		}
	}
	cout<<"YES"<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)	solve();	
	return 0;
 } 

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int a[200005]; 
void solve()
{	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	
	for(int i=1;i<=n-1;i++)
	{
		if(a[i]>a[i+1])	
		{
		cout<<"NO"<<endl;
		return ;
		}
		else if(a[i+1]>=a[i+2])
		{
			int res=min(a[i],a[i+1]);
			a[i]-=res;
			a[i+1]-=res;
		}
	}
	cout<<"YES"<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)	solve();	
	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 a[200005]; 
void solve()
{	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	
	for(int i=1;i<=n-1;i++)
	{
		if(a[i]>a[i+1])	
		{
		cout<<"NO"<<endl;
		return ;
		}
		else if(a[i+1]>a[i+2])
		{
			int res=min(a[i],a[i+1]);
			a[i]-=res;
			a[i+1]-=res;
		}
	}
	cout<<"YES"<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.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 2):
#include<bits/stdc++.h>
using namespace std;
int a[200005]; 
void solve()
{	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	
	for(int i=1;i<=n-1;i++)
	{
		if(a[i]>a[i+1])	
		{
		cout<<"NO"<<endl;
		return ;
		}
		else if(a[i+1]>=a[i+2])
		{
			int res=min(a[i],a[i+1]);
			a[i]-=res;
			a[i+1]-=res;
		}
	}
	cout<<"YES"<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)	solve();	
	return 0;
 } 

Submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
int a[200005]; 
void solve()
{	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];

	for(int i=1;i<=n-1;i++)	if(a[i]<=a[i+1])	a[i+1]-=a[i],a[i]=0;
	
	for(int i=1;i<n;i++)	if(a[i]>a[i+1])	{
		ans=0;
		break;
	}
	if(!ans)	cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)	solve();	
	return 0;
 }
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf LONG_LONG_MAX
void solve() {
	int n,l,r;
	ll sum = 0;
	cin>>n>>l>>r;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	for(int i=0;i<=r-l;i++) sum+=a[i];
	cout<<sum<<"\n";
}
int main() {
	int T;
	cin>>T;
	while(T--){
		solve();
	}
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf LONG_LONG_MAX
void solve() {
	int n,l,r;
	ll sum = 0;
	cin>>n>>l>>r;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	for(int i=0;i<=r-l;i++) sum+=a[i];
	cout<<sum<<"\n";
}
int main() {
	int T;
	cin>>T;
	while(T--){
		solve();
	}
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf LONG_LONG_MAX
void solve() {
	int n;
	ll sum=0,l,r;
	cin>>n>>l>>r;
	vector<ll> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	for(int i=0;i<=r-l;i++) sum+=a[i];
	cout<<sum<<"\n";
}
int main() {
	int T;
	cin>>T;
	while(T--){
		solve();
	}
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf LONG_LONG_MAX
void solve() {
	int n;
	ll sum=0,l,r;
	cin>>n>>l>>r;
	vector<ll> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	for(int i=0;i<=r-l;i++) sum+=a[i];
	cout<<sum<<"\n";
}
int main() {
	int T;
	cin>>T;
	while(T--){
		solve();
	}
}

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

using namespace std;

typedef long long ll;

#define inf LONG_LONG_MAX

void solve() {

	int n;

	ll suml=0,sumr=0,l,r,ans=inf;

	cin>>n>>l>>r;

	vector<ll> a(n),left,right;

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

	//左突

	for(int i=0;i<r;i++) left.push_back(a[i]);

	sort(left.begin(),left.end());

	for(int i=0;i<r-l+1;i++) suml+=left[i];

	//右突

	for(int i=l-1;i<n;i++) right.push_back(a[i]);

	sort(right.begin(),right.end());

	for(int i=0;i<r-l+1;i++) sumr+=right[i];

	//答案

	ans=min(suml,sumr);

	cout<<ans<<"\n";

}

int main() {

	int T;

	cin>>T;

	while(T--){

		solve();

	}

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

 

int main() {

	// your code goes here

	int t;

	cin>>t;

	int i= 1;

	while(t--){

	    int n;

	    cin>>n;

	    string s;

	    cin>>s;

	   // cout<<"hii"<<endl;

	    int lasts=-1;

	    int firstp=-1;

	    int counts=0;

	    int countp=0;

	    bool flag=true;

	    for(int i=0;i<s.size();i++){

	        //cout<<s[i]<<endl;

	        if(s[i]=='s'){

	            lasts=i;

	            counts++;

	        }

	        if(s[i]=='p'){

	            countp++;

	        }

	        if(s[i]=='p' && flag){

	            firstp=i;

	            flag=false;

	        }

	        

	    }

	    //cout<<lasts<<" "<<firstp<<endl;

	    if(counts==0 || countp==0){

	        cout<<"YES"<<endl;

	        continue;

	    }

	    if(lasts>firstp){

	       cout<<"NO"<<endl;

	        continue;

	    }

	   

	    

	    if(counts>1 && countp>1){

	        cout<<"NO"<<endl;

	        continue;

	    }

	    int countdot1=0;

	    int countdot2=0;

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

	        if(s[i]=='.')countdot1++;

	    }

	    for(int i=firstp+1;i<s.size();i++){

	        if(s[i]=='.')countdot2++;

	    }

	    

	    if(countdot1>0 && countdot2>0){

	        cout<<"NO"<<endl;

	        continue;

	    }

	    if(countp==1 && countdot2>0){

	        cout<<"NO"<<endl;

	        continue;

	    }

	    if(counts==1 && countdot1>0){

	        cout<<"NO"<<endl;

	        continue;

	    }

	    cout<<"YES"<<endl;

	 

	    

	}



 

}

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

using namespace std;

 

int main() {

	// your code goes here

	int t;

	cin>>t;

	int i= 1;

	while(t--){

	    int n;

	    cin>>n;

	    string s;

	    cin>>s;

	   // cout<<"hii"<<endl;

	    int lasts=-1;

	    int firstp=-1;

	    int counts=0;

	    int countp=0;

	    bool flag=true;

	    for(int i=0;i<s.size();i++){

	        //cout<<s[i]<<endl;

	        if(s[i]=='s'){

	            lasts=i;

	            counts++;

	        }

	        if(s[i]=='p'){

	            countp++;

	        }

	        if(s[i]=='p' && flag){

	            firstp=i;

	            flag=false;

	        }

	        

	    }

	    //cout<<lasts<<" "<<firstp<<endl;

	    if(counts==0 || countp==0){

	        cout<<"YES"<<endl;

	        continue;

	    }

	    if(lasts>firstp){

	       cout<<"NO"<<endl;

	        continue;

	    }

	   

	    

	    if(counts>1 && countp>1){

	        cout<<"NO"<<endl;

	        continue;

	    }

	    int countdot1=0;

	    int countdot2=0;

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

	        if(s[i]=='.')countdot1++;

	    }

	    for(int i=firstp+1;i<s.size();i++){

	        if(s[i]=='.')countdot2++;

	    }

	    

	    if(countdot1>0 && countdot2>0){

	        cout<<"NO"<<endl;

	        continue;

	    }

	    if(countp==1 && countdot2>0 && counts!=1){

	        cout<<"NO"<<endl;

	        continue;

	    }

	    if(counts==1 && countdot1>0 && countp!=1){

	        cout<<"NO"<<endl;

	        continue;

	    }

	    cout<<"YES"<<endl;

	 

	    

	}



 

}