ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
//don't stick at only one idea,think openly.you can do it Junaid
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll N=1e5+5;
ll mod =1e9+7;
string s[2];
ll dp[3][N];


void solve(){
     int n;
     cin>>n;
     vector<int>deg(n+1,0);
     set<pair<int,int>>st;
     for(int i=1 ; i<n;i++){
         int u,v;
         cin>>u>>v;
         deg[u]++;
         deg[v]++;
         st.insert({u,v});
         st.insert({v,u});
     }
     vector<pair<int,int>>edges;
     for(int i=1;i<=n;i++){
          edges.push_back({deg[i],i});
     }
     sort(edges.rbegin(),edges.rend());
     int ans=-1;
     for(int i=0;i<edges.size();i++){
         int u=edges[i].second;
         for(int j=i+1;j<edges.size();j++){
             int v=edges[j].second;
             if(st.count({u,v})==0){
                 ans=deg[u]+deg[v]-1;
                 break;
             }
         }
         if(ans!=-1)break;
     }
     for(int i=1;i<=n;i++){
          if(st.find({edges[0].second,i})!=st.end()){
              ans= max(ans,deg[edges[0].second]+deg[i]-2);
             // break;
          }
     }
     cout<<ans<<endl;
}
   
  






int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
   int t=1;
   cin>>t;
  // sieve();
   while(t--){
        solve();
   }

}


Submission (verdict: Wrong answer on test 4):
//don't stick at only one idea,think openly.you can do it Junaid
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll N=1e5+5;
ll mod =1e9+7;
string s[2];
ll dp[3][N];


void solve(){
     int n;
     cin>>n;
     vector<int>deg(n+1,0);
     set<pair<int,int>>st;
     for(int i=1 ; i<n;i++){
         int u,v;
         cin>>u>>v;
         deg[u]++;
         deg[v]++;
         st.insert({u,v});
         st.insert({v,u});
     }
     vector<pair<int,int>>edges;
     for(int i=1;i<=n;i++){
          edges.push_back({deg[i],i});
     }
     sort(edges.rbegin(),edges.rend());
     int ans=-1;
     for(int i=0;i<edges.size();i++){
         int u=edges[i].second;
         for(int j=i+1;j<edges.size();j++){
             int v=edges[j].second;
             if(st.find({u,v})==st.end()){
                 ans=deg[u]+deg[v]-1;
                 break;
             }
         }
         if(ans!=-1)break;
     }
     for(int i=1;i<=n;i++){
          if(st.find({edges[0].second,i})!=st.end()){
              ans= max(ans,deg[edges[0].second]+deg[i]-2);
             // break;
          }
     }
     cout<<ans<<endl;
}
   
  






int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
   int t=1;
   cin>>t;
  // sieve();
   while(t--){
        solve();
   }

}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
//don't stick at only one idea,think openly.you can do it Junaid
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll N=1e5+5;
ll mod =1e9+7;
string s[2];
ll dp[3][N];


void solve(){
     int n;
     cin>>n;
     vector<int>deg(n+1,0);
     set<pair<int,int>>st;
     for(int i=1 ; i<n;i++){
         int u,v;
         cin>>u>>v;
         deg[u]++;
         deg[v]++;
         st.insert({u,v});
         st.insert({v,u});
     }
     vector<pair<int,int>>edges;
     for(int i=1;i<=n;i++){
          edges.push_back({deg[i],i});
     }
     sort(edges.rbegin(),edges.rend());
     int ans=-1;
     for(int i=0;i<edges.size();i++){
         int u=edges[i].second;
         for(int j=i+1;j<edges.size();j++){
             int v=edges[j].second;
             if(st.find({u,v})==st.end()){
                 ans=deg[u]+deg[v]-1;
                 break;
             }
         }
         if(ans!=-1)break;
     }
     for(int i=1;i<=n;i++){
          if(st.find({edges[0].second,i})!=st.end()){
              ans= max(ans,deg[edges[0].second]+deg[i]-2);
             // break;
          }
     }
     cout<<ans<<endl;
}
   
  






int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
   int t=1;
   cin>>t;
  // sieve();
   while(t--){
        solve();
   }

}


Submission (verdict: Wrong answer on test 4):
//don't stick at only one idea,think openly.you can do it Junaid
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll N=1e5+5;
ll mod =1e9+7;
string s[2];
ll dp[3][N];


void solve(){
     int n;
     cin>>n;
     vector<int>deg(n+1,0);
     set<pair<int,int>>st;
     for(int i=1 ; i<n;i++){
         int u,v;
         cin>>u>>v;
         deg[u]++;
         deg[v]++;
         st.insert({u,v});
         st.insert({v,u});
     }
     vector<pair<int,int>>edges;
     for(int i=1;i<=n;i++){
          edges.push_back({deg[i],i});
     }
     sort(edges.rbegin(),edges.rend());
     int ans=-1;
     for(int i=0;i<edges.size();i++){
         int u=edges[i].second;
         for(int j=i+1;j<edges.size();j++){
             int v=edges[j].second;
             if(st.find({u,v})==st.end()){
                 ans=max(ans,deg[u]+deg[v]-1);
                // break;
             }
         }
         if(ans!=-1)break;
     }
     for(int i=1;i<=n;i++){
          if(st.find({edges[0].second,i})!=st.end()){
              ans= max(ans,deg[edges[0].second]+deg[i]-2);
             // break;
          }
     }
     cout<<ans<<endl;
}
   
  






int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
   int t=1;
   cin>>t;
  // sieve();
   while(t--){
        solve();
   }

}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
//don't stick at only one idea,think openly.you can do it Junaid
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll N=1e5+5;
ll mod =1e9+7;
string s[2];
ll dp[3][N];


void solve(){
     int n;
     cin>>n;
     vector<int>deg(n+1,0);
     set<pair<int,int>>st;
     for(int i=1 ; i<n;i++){
         int u,v;
         cin>>u>>v;
         deg[u]++;
         deg[v]++;
         st.insert({u,v});
         st.insert({v,u});
     }
     vector<pair<int,int>>edges;
     for(int i=1;i<=n;i++){
          edges.push_back({deg[i],i});
     }
     sort(edges.rbegin(),edges.rend());
     int ans=-1;
     for(int i=0;i<edges.size();i++){
         int u=edges[i].second;
         for(int j=i+1;j<edges.size();j++){
             int v=edges[j].second;
             if(st.find({u,v})==st.end()){
                 ans=max(ans,deg[u]+deg[v]-1);
                // break;
             }
         }
         if(ans!=-1)break;
     }
     for(auto it:st){
          int u=it.first;
          int v=it.second;
          ans=max(ans,deg[u]+deg[v]-2);
     }
     cout<<ans<<endl;
}
   
  






int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
   int t=1;
   cin>>t;
  // sieve();
   while(t--){
        solve();
   }

}


Submission (verdict: Accepted):
//don't stick at only one idea,think openly.you can do it Junaid
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll N=1e5+5;
ll mod =1e9+7;
string s[2];
ll dp[3][N];


void solve(){
     int n;
     cin>>n;
     vector<int>deg(n+1,0);
     set<pair<int,int>>st;
     for(int i=1 ; i<n; i++){
         int u,v;
         cin>>u>>v;
         deg[u]++;
         deg[v]++;
         st.insert({u,v});
         st.insert({v,u});
     }
     vector<pair<int,int>>edges;
     for(int i=1;i<=n;i++){
          edges.push_back({deg[i],i});
     }
      sort(edges.begin(),edges.end(),greater<pair<ll,ll>>());
     int ans=-1;
     for(int i=0;i<edges.size();i++){
         int u=edges[i].first;
         for(int j=i+1;j<edges.size();j++){
             int v=edges[j].first;
             if(st.find({edges[i].second,edges[j].second})==st.end()){
                 ans=max(ans,u+v-1);
                 break;
             }
         }
         //if(ans!=-1)break;
     }
     for(auto it:st){
          int u=it.first;
          int v=it.second;
          ans=max(ans,deg[u]+deg[v]-2);
     }
     cout<<ans<<endl;
}
   
  






int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
   int t=1;
   cin>>t;
  // sieve();
   while(t--){
        solve();
   }

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long 

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

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

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

           if(i%2){

               a[i]=0;

           }else{

               a[i]=1;

           }

    }

    if(n%2==1) a[1]=2;

    if(a[x]==a[y]){

         a[y]=2;

    }

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

         cout<<a[i]<<" \n"[i==n];

    }

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    

    int t = 1;

    cin >> t;



    while (t--) {

        solve();

    }

}

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

using namespace std;

#define int long long 

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

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

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

           if(i%2){

               a[i]=0;

           }else{

               a[i]=1;

           }

    }

    if(n%2==1) a[1]=2;

    if(a[x]==a[y]){

        if(y==n&&a[1]==2) a[y]=3;

        else  a[y]=2;

    }

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

         cout<<a[i]<<" \n"[i==n];

    }

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    

    int t = 1;

    cin >> t;



    while (t--) {

        solve();

    }

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


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

using namespace std;

#define int long long 

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

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

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

           if(i%2){

               a[i]=0;

           }else{

               a[i]=1;

           }

    }

    if(n%2==1) a[1]=2;

    if(a[x]==a[y]){

         a[y]=2;

    }

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

         cout<<a[i]<<" \n"[i==n];

    }

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    

    int t = 1;

    cin >> t;



    while (t--) {

        solve();

    }

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long 

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

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

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

           if(i%2){

               a[i]=0;

           }else{

               a[i]=1;

           }

    }

    if(n%2==1) a[1]=2;

    if(a[x]==a[y]){

        if(y==n&&a[1]==2) a[y]=3;

        else  a[y]=2;

    }

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

         cout<<a[i]<<" \n"[i==n];

    }

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    

    int t = 1;

    cin >> t;



    while (t--) {

        solve();

    }

}

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

using namespace std;

#define int long long 

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

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

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

           if(i%2){

               a[i]=0;

           }else{

               a[i]=1;

           }

    }

    if(n%2==1) a[1]=2;

    if(a[x]==a[y]){

        if(y==n&&a[1]==2) a[y]=2,a[1]=0;

        else  a[y]=2;

    }

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

         cout<<a[i]<<" \n"[i==n];

    }

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    

    int t = 1;

    cin >> t;



    while (t--) {

        solve();

    }

}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
vector<vector<int>>e(N);
int dp[N];
int ans=0; 
void dfs(int u,int fa){
         for(auto v:e[u]){
              if(v!=fa){
                  dfs(v,u);
              }
         }
         if(u==1) return ;
         int cnt=0;
         for(auto v:e[u]){
              if(v!=fa){
                 cnt++;
                 dp[u]=max(dp[u],dp[v]);   
              }
         }
        if(cnt>0) ans=max((int)e[fa].size()+dp[u],ans);
         dp[u]=max(dp[u],cnt);
         if(fa==1){
             ans=max(ans,cnt);
         }else{
            ans=max(ans,cnt+1);
         }

       
         
}
void solve() {
       int n;
       cin>>n;
       for(int i=1;i<=n;i++){
            e[i].clear();
            dp[i]=0;
       }
       for(int i=1;i<n;i++){
            int u,v;
            cin>>u>>v;
            e[u].push_back(v);
            e[v].push_back(u);
       }
       ans=0;
       dfs(1,0);
       cout<<ans<<'\n';

}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int t = 1;
    cin >> t;

    while (t--) {
        solve();
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
vector<vector<int>>e(N);
int dp[N];
int ans=0; 
void dfs(int u,int fa){
         for(auto v:e[u]){
              if(v!=fa){
                  dfs(v,u);
              }
         }
         if(u==1) return ;
         int cnt=0;
         for(auto v:e[u]){
              if(v!=fa){
                 cnt++;
                 dp[u]=max(dp[u],dp[v]);   
              }
         }
        if(cnt>0) ans=max((int)e[fa].size()+dp[u],ans);
         dp[u]=max(dp[u],cnt);
         ans=max(ans,(int)e[fa].size()-1+cnt);

       
         
}
void solve() {
       int n;
       cin>>n;
       for(int i=1;i<=n;i++){
            e[i].clear();
            dp[i]=0;
       }
       for(int i=1;i<n;i++){
            int u,v;
            cin>>u>>v;
            e[u].push_back(v);
            e[v].push_back(u);
       }
       ans=0;
       dfs(1,0);
       cout<<ans<<'\n';

}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int t = 1;
    cin >> t;

    while (t--) {
        solve();
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
vector<vector<int>>e(N);
int dp[N];
int ans=0; 
void dfs(int u,int fa){
         for(auto v:e[u]){
              if(v!=fa){
                  dfs(v,u);
              }
         }
        
         int cnt=0;
         int mx=0,sec=0;
         for(auto v:e[u]){
              if(v!=fa){
                 cnt++;
                 dp[u]=max(dp[u],dp[v]);
                 if(dp[v]>mx){
                      sec=mx;
                      mx=dp[v];
                 }else if(dp[v]>sec){
                      sec=dp[v];
                 }   
              }
         }
         if(cnt>=2) ans=max(ans,mx+sec+1);
          if(u==1) return ;
        if(cnt>0) ans=max((int)e[fa].size()+dp[u],ans);
         dp[u]=max(dp[u],cnt);
         ans=max(ans,(int)e[fa].size()-1+cnt);

       
         
}
void solve() {
       int n;
       cin>>n;
       for(int i=1;i<=n;i++){
            e[i].clear();
            dp[i]=0;
       }
       for(int i=1;i<n;i++){
            int u,v;
            cin>>u>>v;
            e[u].push_back(v);
            e[v].push_back(u);
       }
       ans=0;
       dfs(1,0);
       cout<<ans<<'\n';

}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int t = 1;
    cin >> t;

    while (t--) {
        solve();
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
vector<vector<int>>e(N);
int dp[N];
int ans=0; 
void dfs(int u,int fa){
         for(auto v:e[u]){
              if(v!=fa){
                  dfs(v,u);
              }
         }
         if(u==1) return ;
         int cnt=0;
         for(auto v:e[u]){
              if(v!=fa){
                 cnt++;
                 dp[u]=max(dp[u],dp[v]);   
              }
         }
        if(cnt>0) ans=max((int)e[fa].size()+dp[u],ans);
         dp[u]=max(dp[u],cnt);
         if(fa==1){
             ans=max(ans,cnt);
         }else{
            ans=max(ans,cnt+1);
         }

       
         
}
void solve() {
       int n;
       cin>>n;
       for(int i=1;i<=n;i++){
            e[i].clear();
            dp[i]=0;
       }
       for(int i=1;i<n;i++){
            int u,v;
            cin>>u>>v;
            e[u].push_back(v);
            e[v].push_back(u);
       }
       ans=0;
       dfs(1,0);
       cout<<ans<<'\n';

}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int t = 1;
    cin >> t;

    while (t--) {
        solve();
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
vector<vector<int>>e(N);
int dp[N];
int ans=0; 
void dfs(int u,int fa){
         for(auto v:e[u]){
              if(v!=fa){
                  dfs(v,u);
              }
         }
         if(u==1) return ;
         int cnt=0;
         for(auto v:e[u]){
              if(v!=fa){
                 cnt++;
                 dp[u]=max(dp[u],dp[v]);   
              }
         }
        if(cnt>0) ans=max((int)e[fa].size()+dp[u],ans);
         dp[u]=max(dp[u],cnt);
         ans=max(ans,(int)e[fa].size()-1+cnt);

       
         
}
void solve() {
       int n;
       cin>>n;
       for(int i=1;i<=n;i++){
            e[i].clear();
            dp[i]=0;
       }
       for(int i=1;i<n;i++){
            int u,v;
            cin>>u>>v;
            e[u].push_back(v);
            e[v].push_back(u);
       }
       ans=0;
       dfs(1,0);
       cout<<ans<<'\n';

}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int t = 1;
    cin >> t;

    while (t--) {
        solve();
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define N    1000010
#define int  long long
#define i128 __int128
#define ull  unsigned long long
#define db   long double
#define pii  pair<int,int>
#define st   first
#define ed   second
#define mkp  make_pair
#define pb   push_back
#define eps  1e-9
#define mod  998244353
#define mod2 1000000007
#define bs   13131
#define bs2  131
#define INF  0x3f3f3f3f3f3f3f3f
#define il   inline
#define vi   vector<int>
#define ins  insert
#define umap unordered_map
#define uset unordered_set
#define R(x) x.begin(),x.end()
#define B(x) x.begin()
#define E(x) x.end()
#define lb   lower_bound
#define ub   upper_bound
#define prq  priority_queue
#define rd(l,r) (rnd()%(r-l+1)+l)
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());
il int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int T=1,n,m,q,k;
int ans;
int d[N];
vector<int> v[N];
il void work(){
	int p=1;
	for(int i=2;i<=n;i++)
		if(d[i]>d[p])p=i;
	ans+=d[p]-1;
	for(auto x:v[p])d[x]--;
	d[p]=-INF;
}
il void solve(){
	n=read();
	for(int i=1;i<=n;i++)v[i].clear(),d[i]=0;
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		v[x].pb(y),v[y].pb(x);
		d[x]++,d[y]++;
	}
	ans=1;
	work(),work();
	printf("%lld\n",ans);
}
signed main(){
	T=read();
	while(T--)solve();
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
// "ولا تقولن لشيء إني فاعل ذلك غدا"
// "إلا أن يشاء الله واذكر ربك إذا نسيت وقل عسى أن يهديني ربي لأقرب من هذا رشدا"

// LINK :
#include <bits/stdc++.h>
#define ll long long
#define nl '\n'
#define sp ' '
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define no cout<<"NO\n"
#define yes cout<<"YES\n"
#define ENG_GAMAL ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using namespace std;
// ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
const int N = 2e5 + 5, M = 1e3, LOG = 20, inf = 0x3f3f3f3f;
ll infLL = 0x3f3f3f3f3f3f3f3f;

void solve() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (ll i = 0; i < n - 1; ++i) {
        ll sub = min(a[i] , a[i + 1]);
        a[i] -= sub;
        a[i + 1] -= sub;
    }
    count(all(a) , 0) == n - 1 ? yes : no;
}
void file()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    freopen("Error.txt", "w", stderr);
#endif
}

int main() {
    file();
    ENG_GAMAL
// test-independent code ——————————————————————
// ————————————————————————————————————————————
    ll 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):
// "ولا تقولن لشيء إني فاعل ذلك غدا"
// "إلا أن يشاء الله واذكر ربك إذا نسيت وقل عسى أن يهديني ربي لأقرب من هذا رشدا"

// LINK :
#include <bits/stdc++.h>
#define ll long long
#define nl '\n'
#define sp ' '
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define no cout<<"NO\n"
#define yes cout<<"YES\n"
#define ENG_GAMAL ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using namespace std;
// ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
const int N = 2e5 + 5, M = 1e3, LOG = 20, inf = 0x3f3f3f3f;
ll infLL = 0x3f3f3f3f3f3f3f3f;

void solve() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (ll i = 0; i < n - 1; ++i) {
        ll sub = min(a[i] , a[i + 1]);
        a[i] -= sub;
        a[i + 1] -= sub;
    }
    count(all(a) , 0) == n - 1 ? yes : no;
}
void file()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    freopen("Error.txt", "w", stderr);
#endif
}

int main() {
    file();
    ENG_GAMAL
// test-independent code ——————————————————————
// ————————————————————————————————————————————
    ll t = 1;
     cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

Submission (verdict: Wrong answer on test 2):
// "ولا تقولن لشيء إني فاعل ذلك غدا"
// "إلا أن يشاء الله واذكر ربك إذا نسيت وقل عسى أن يهديني ربي لأقرب من هذا رشدا"

// LINK :
#include <bits/stdc++.h>
#define ll long long
#define nl '\n'
#define sp ' '
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define no cout<<"NO\n"
#define yes cout<<"YES\n"
#define ENG_GAMAL ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using namespace std;
// ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
const int N = 2e5 + 5, M = 1e3, LOG = 20, inf = 0x3f3f3f3f;
ll infLL = 0x3f3f3f3f3f3f3f3f;

void solve() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (ll i = 0; i < n - 1; ++i) {
        ll sub = min(a[i] , a[i + 1]);
        a[i] -= sub;
        a[i + 1] -= sub;
    }
    count(all(a) , 0) == n - 1 && a[n - 1]? yes : no;
}
void file()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    freopen("Error.txt", "w", stderr);
#endif
}

int main() {
    file();
    ENG_GAMAL
// test-independent code ——————————————————————
// ————————————————————————————————————————————
    ll t = 1;
     cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}