ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
//Bharti Nema
#include<bits/stdc++.h>
using namespace std;
bool isValid(int,int);
int n,m;
int main() {
	int t;
	cin>>t;
	while(t--) {
		long long int n,baari=0,ans=0,sum1=0,sum2=0;
		cin>>n;
		long long int a[n+1],b[n+1];
		for(int i=0;i<n;i++)
			cin>>a[i];

		for(int i=0;i<n;i++) {
			ans+=a[i];
		}
		if(n==1) {
			cout<<a[0]<<endl;
			continue;
		}
		while(n>1) {
			for(int i=0;i<n-1;i++) {
				a[i]=a[i]-a[i+1];
			}
			n-=1;
		}

		cout<<max(ans,abs(a[0]))<<endl;


		// while(n>1) {
		// for(int i=1,j=0;i<n && j<n-1;i++,j++) {

		// }
	// 		sum1+=(a[i]-a[i-1]);
	// 		sum2+=(a[j]-a[j+1]);
	// 	}
	// 	if(sum1>sum2) {
	// 		ans=max(ans,sum1);
	// 		for(int i=1;i<n;i++) {
	// 			if(baari==0)
	// 			    b[i-1]=a[i]-a[i-1];
	// 		    else
	// 		        a[i-1]=b[i]-b[i-1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// 	else {
	// 		ans=max(ans,sum2);
	// 		for(int i=0,kahan=n-2;i<n-1;i++,kahan--) {
	// 			if(baari==0)
	// 			    b[kahan]=a[i]-a[i+1];
	// 		    else
	// 		    	a[kahan]=b[i]-b[i+1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// }

	// 	if(baari==0)
	// 		cout<<max(ans,a[0]);
	// 	else
	// 		cout<<max(ans,b[0]);
	}
}

Submission (verdict: Wrong answer on test 2):
//Bharti Nema
#include<bits/stdc++.h>
using namespace std;
bool isValid(int,int);
int n,m;
int main() {
	int t;
	cin>>t;
	while(t--) {
		long long int n,baari=0,ans=0,sum=0,sum2=0;
		cin>>n;
		long long int a[n+1],b[n+1];
		for(int i=0;i<n;i++)
			cin>>a[i];

		for(int i=0;i<n;i++) {
			ans+=a[i];
		}
		if(n==1) {
			cout<<a[0]<<endl;
			continue;
		}
		while(n>1) {
			for(int i=0;i<n-1;i++) {
				a[i]=a[i]-a[i+1];
			}
			for(int i=0;i<n;i++) {
				sum+=a[i];
			}
			ans=max(ans,sum);
			sum=0;
			n-=1;
		}

		cout<<max(ans,abs(a[0]))<<endl;


		// while(n>1) {
		// for(int i=1,j=0;i<n && j<n-1;i++,j++) {

		// }
	// 		sum1+=(a[i]-a[i-1]);
	// 		sum2+=(a[j]-a[j+1]);
	// 	}
	// 	if(sum1>sum2) {
	// 		ans=max(ans,sum1);
	// 		for(int i=1;i<n;i++) {
	// 			if(baari==0)
	// 			    b[i-1]=a[i]-a[i-1];
	// 		    else
	// 		        a[i-1]=b[i]-b[i-1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// 	else {
	// 		ans=max(ans,sum2);
	// 		for(int i=0,kahan=n-2;i<n-1;i++,kahan--) {
	// 			if(baari==0)
	// 			    b[kahan]=a[i]-a[i+1];
	// 		    else
	// 		    	a[kahan]=b[i]-b[i+1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// }

	// 	if(baari==0)
	// 		cout<<max(ans,a[0]);
	// 	else
	// 		cout<<max(ans,b[0]);
	}
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
//Bharti Nema
#include<bits/stdc++.h>
using namespace std;
bool isValid(int,int);
int n,m;
int main() {
	int t;
	cin>>t;
	while(t--) {
		int n,baari=0,ans=0,sum1=0,sum2=0;
		cin>>n;
		int a[n+1],b[n+1];
		for(int i=0;i<n;i++)
			cin>>a[i];

		for(int i=0;i<n;i++) {
			ans+=a[i];
		}
		if(n==1) {
			cout<<a[0]<<endl;
			continue;
		}
		while(n>1) {
			for(int i=0;i<n-1;i++) {
				a[i]=a[i]-a[i+1];
			}
			n-=1;
		}

		cout<<max(ans,abs(a[0]))<<endl;


		// while(n>1) {
		// for(int i=1,j=0;i<n && j<n-1;i++,j++) {

		// }
	// 		sum1+=(a[i]-a[i-1]);
	// 		sum2+=(a[j]-a[j+1]);
	// 	}
	// 	if(sum1>sum2) {
	// 		ans=max(ans,sum1);
	// 		for(int i=1;i<n;i++) {
	// 			if(baari==0)
	// 			    b[i-1]=a[i]-a[i-1];
	// 		    else
	// 		        a[i-1]=b[i]-b[i-1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// 	else {
	// 		ans=max(ans,sum2);
	// 		for(int i=0,kahan=n-2;i<n-1;i++,kahan--) {
	// 			if(baari==0)
	// 			    b[kahan]=a[i]-a[i+1];
	// 		    else
	// 		    	a[kahan]=b[i]-b[i+1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// }

	// 	if(baari==0)
	// 		cout<<max(ans,a[0]);
	// 	else
	// 		cout<<max(ans,b[0]);
	}
}

Submission (verdict: Wrong answer on test 2):
//Bharti Nema
#include<bits/stdc++.h>
using namespace std;
bool isValid(int,int);
int n,m;
int main() {
	int t;
	cin>>t;
	while(t--) {
		long long int n,baari=0,ans=0,sum1=0,sum2=0;
		cin>>n;
		long long int a[n+1],b[n+1];
		for(int i=0;i<n;i++)
			cin>>a[i];

		for(int i=0;i<n;i++) {
			ans+=a[i];
		}
		if(n==1) {
			cout<<a[0]<<endl;
			continue;
		}
		while(n>1) {
			for(int i=0;i<n-1;i++) {
				a[i]=a[i]-a[i+1];
			}
			n-=1;
		}

		cout<<max(ans,abs(a[0]))<<endl;


		// while(n>1) {
		// for(int i=1,j=0;i<n && j<n-1;i++,j++) {

		// }
	// 		sum1+=(a[i]-a[i-1]);
	// 		sum2+=(a[j]-a[j+1]);
	// 	}
	// 	if(sum1>sum2) {
	// 		ans=max(ans,sum1);
	// 		for(int i=1;i<n;i++) {
	// 			if(baari==0)
	// 			    b[i-1]=a[i]-a[i-1];
	// 		    else
	// 		        a[i-1]=b[i]-b[i-1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// 	else {
	// 		ans=max(ans,sum2);
	// 		for(int i=0,kahan=n-2;i<n-1;i++,kahan--) {
	// 			if(baari==0)
	// 			    b[kahan]=a[i]-a[i+1];
	// 		    else
	// 		    	a[kahan]=b[i]-b[i+1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// }

	// 	if(baari==0)
	// 		cout<<max(ans,a[0]);
	// 	else
	// 		cout<<max(ans,b[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;
#define ll long long
#define fr(i, j, n) for(ll i = j; i <n; i++)
#define pb push_back
#define mod 1000000007
#define up upper_bound
#define lb lower_bound
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))
typedef vector<int>vi;
typedef vector<vector<int>>vvi;
typedef vector<long long>vll;
typedef vector<vector<long long>>vvll; 



ll binpow(ll a,ll b, ll m)
{
if(b==0)
{
    return 1;
}
if(b%2)
{
    return (a*binpow(a,b-1, m))%m;
}
return binpow((a*a)%m,b/2, m);
}
void vInp(auto & v){
    for(auto & it : v)cin>>it;
}


void vvInp(auto & v){
    for(auto & it : v){
        for(auto & it2 : it)cin>>it2;
    }
}

int solve(){
    int n;
    cin>>n;
    vector<int>indegree(n);
    vector<vector<int>>mp(n);
    
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        indegree[u]++;
        indegree[v]++;
        mp[u].pb(v);
        mp[v].pb(u);
    }
    int maxi=0;
    int node=-1;
    for(int  i=0;i<n;i++){
        if(indegree[i]>maxi){
            maxi=indegree[i];
            node=i;
        }
    }
    indegree[node]-=maxi;
    map<int,int>mp1;
    for(auto it:mp[node]){
            indegree[it]--;
            mp1[it]++;
    }
    int ans=0;
    int mx=0;
    int nd=-1;
    for(int i=0;i<n;i++){
        if(indegree[i]>=mx){
            mx=indegree[i];
            if(mp1.find(i)==mp1.end()){
                ans=max(ans,maxi+mx-1);
            }
            else{
                ans=max(ans,maxi+mx-2);
            }
        }
    }
    return ans;

    

}

int main(){
int t;
cin>>t;
while(t--){
    cout<<solve()<<endl;
}
     return 0;
}
    






/*   /\/\ 
*   (= ..) 
*   / >  \> 
*/
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string a,b,c;
//vector<vector<int>> dp(1e3+1,vector<int> (1e3+1,-1));
int fnc(int i, int j, string &s)
{
  if(i >= a.length() && j >= b.length())
  {
    // cout << s << endl;
    int cnt = 0;
    for(int i=0;i<(a.length()+b.length());++i)
    {
      if(c[i] != s[i])
      {
        ++cnt;
      }
    }
    return cnt;
  }
  // if(dp[i][j] != -1)
  // {
  //  return dp[i][j];
  // }
  int x1 = 1e9;
  int x2 = 1e9;
  if(i < a.length())
  {
  string op1 = s + a[i];
  x1 = fnc(i+1,j,op1);
  }
  if(j < b.length())
  {
  string op2  = s + b[j];
  x2 = fnc(i,j+1,op2);
  }
  return  min(x1,x2);
}
void solve()
{
  cin >> a >> b >> c;
//vector<vector<int>> ddp(1e3+1,vector<int> (1e3+1,-1));
  string s = "";
// dp = ddp;
  cout << fnc(0,0,s) << endl;
}
int32_t main(){
    int tt;
   cin >> tt;
   while(tt>0){
   solve();
   --tt;
   }


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

Previous submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string a,b,c;
//vector<vector<int>> dp(1e3+1,vector<int> (1e3+1,-1));
int fnc(int i, int j, string &s)
{
  if(i >= a.length() && j >= b.length())
  {
    // cout << s << endl;
    int cnt = 0;
    for(int i=0;i<(a.length()+b.length());++i)
    {
      if(c[i] != s[i])
      {
        ++cnt;
      }
    }
    return cnt;
  }
  // if(dp[i][j] != -1)
  // {
  //  return dp[i][j];
  // }
  int x1 = 1e9;
  int x2 = 1e9;
  if(i < a.length())
  {
  string op1 = s + a[i];
  x1 = fnc(i+1,j,op1);
  }
  if(j < b.length())
  {
  string op2  = s + b[j];
  x2 = fnc(i,j+1,op2);
  }
  return  min(x1,x2);
}
void solve()
{
  cin >> a >> b >> c;
//vector<vector<int>> ddp(1e3+1,vector<int> (1e3+1,-1));
  string s = "";
// dp = ddp;
  cout << fnc(0,0,s) << endl;
}
int32_t main(){
    int tt;
   cin >> tt;
   while(tt>0){
   solve();
   --tt;
   }


  //solve();
}

Submission (verdict: Time limit exceeded on test 5):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string a,b,c;
vector<vector<int>> dp(1e3+1,vector<int> (1e3+1,-1));
int fnc(int i, int j)
{
  if(i>=a.length() && j >= b.length())
  {
    return 0;
  }
  if(dp[i][j] != -1)
  {
    return dp[i][j];
  }
  int x1 = 1e9;
  int x2 = 1e9;
  if(i < a.length())
  {
  x1 = fnc(i+1,j) + (a[i] != c[i+j]);
  }
  if(j < b.length())
  {
  x2 = fnc(i,j+1) + (b[j] != c[i+j]);
  }
  return dp[i][j] =  min(x1,x2);
}
void solve()
{
  cin >> a >> b >> c;
vector<vector<int>> ddp(1e3+1,vector<int> (1e3+1,-1));
dp = ddp;
  cout << fnc(0,0) << endl;
}
int32_t main(){
    int tt;
   cin >> tt;
   while(tt>0){
   solve();
   --tt;
   }


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

Previous submission (verdict: Time limit exceeded on test 5):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string a,b,c;
vector<vector<int>> dp(1e3+1,vector<int> (1e3+1,-1));
int fnc(int i, int j)
{
  if(i>=a.length() && j >= b.length())
  {
    return 0;
  }
  if(dp[i][j] != -1)
  {
    return dp[i][j];
  }
  int x1 = 1e9;
  int x2 = 1e9;
  if(i < a.length())
  {
  x1 = fnc(i+1,j) + (a[i] != c[i+j]);
  }
  if(j < b.length())
  {
  x2 = fnc(i,j+1) + (b[j] != c[i+j]);
  }
  return dp[i][j] =  min(x1,x2);
}
void solve()
{
  cin >> a >> b >> c;
vector<vector<int>> ddp(1e3+1,vector<int> (1e3+1,-1));
dp = ddp;
  cout << fnc(0,0) << endl;
}
int32_t main(){
    int tt;
   cin >> tt;
   while(tt>0){
   solve();
   --tt;
   }


  //solve();
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string a,b,c;
vector<vector<int>> dp;
int fnc(int i, int j)
{
  if(i>=a.length() && j >= b.length())
  {
    return 0;
  }
  if(dp[i][j] != -1)
  {
    return dp[i][j];
  }
  int x1 = 1e9;
  int x2 = 1e9;
  if(i < a.length())
  {
  x1 = fnc(i+1,j) + (a[i] != c[i+j]);
  }
  if(j < b.length())
  {
  x2 = fnc(i,j+1) + (b[j] != c[i+j]);
  }
  return dp[i][j] =  min(x1,x2);
}
void solve()
{
  cin >> a >> b >> c;
vector<vector<int>> ddp(a.length()+1,vector<int> (b.length()+1,-1));
dp = ddp;
  cout << fnc(0,0) << endl;
}
int32_t main(){
    int tt;
   cin >> tt;
   while(tt>0){
   solve();
   --tt;
   }


  //solve();
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define pb push_back
#define int long long int
#define F first
#define S second
#define MOD 1000000007

signed main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n , m;
        cin >> n >> m;

        multiset <int> a , b;
        for(int i=0 ; i<n ; i++) {
            int x; cin >> x;
            a.insert(x);
        }

        for(int i=0 ; i<m ; i++) {
            int x; cin >> x;
            b.insert(x);
        }

        while(a.size() > 0 and b.size() > 0 and b.size() <= a.size()) {
            auto x = b.end(); x--;
            int xx = *x; b.erase(x);
            if(a.find(xx) != a.end()) 
                a.erase(a.find(xx));
            else {
                b.insert(float(xx/2.0));
                b.insert(ceil(xx/2.0));
            }
        }

        if(a.size() == 0 and b.size() == 0)
            cout << "YES";
        else
            cout << "NO";

        cout << '\n';
    }
}

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

#define pb push_back
#define int long long int
#define F first
#define S second
#define MOD 1000000007

signed main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n , m;
        cin >> n >> m;

        multiset <int> a , b;
        for(int i=0 ; i<n ; i++) {
            int x; cin >> x;
            a.insert(x);
        }

        for(int i=0 ; i<m ; i++) {
            int x; cin >> x;
            b.insert(x);
        }

        while(a.size() > 0 and b.size() > 0 and b.size() <= a.size()) {
            auto x = b.end(); x--;
            int xx = *x; b.erase(x);
            if(a.find(xx) != a.end()) 
                a.erase(a.find(xx));
            else {
                if(xx % 2){
                    b.insert(xx/2);
                    b.insert(xx/2 + 1);
                } else{
                    b.insert(xx/2);
                    b.insert(xx/2);
                }
            }
        }

        if(a.size() == 0 and b.size() == 0)
            cout << "YES";
        else
            cout << "NO";

        cout << '\n';
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define pb push_back
#define int long long int
#define F first
#define S second
#define MOD 1000000007

signed main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n , m;
        cin >> n >> m;

        multiset <int> a , b;
        for(int i=0 ; i<n ; i++) {
            int x; cin >> x;
            a.insert(x);
        }

        for(int i=0 ; i<m ; i++) {
            int x; cin >> x;
            if(a.find(x) != a.end()) {
                a.erase(a.find(x));
            } else {
                b.insert(x);
            }
        }
        
        while(a.size() > 1 and b.size() > 0) {
            int x = *a.begin(); a.erase(a.begin());
            int y = *b.begin(); b.erase(b.begin());

            int p = y - x;
            if(p <= 0)
                break;
            else if(abs(x-p) <= 1 and a.find(p) != a.end()) {
                a.erase(a.find(p));
            } else {
                b.insert(y);

                y = *a.begin(); a.erase(a.begin());

                if(abs(x - y) <= 1) {
                    int z = x+y;
                    if(b.find(z) != b.end()) 
                        b.erase(b.find(z));
                    else 
                        a.insert(z);
                } else
                    break;
            }
        }

        if(a.size() > 0 or b.size() > 0)
            cout << "NO";
        else 
            cout << "YES";

        cout << '\n';
    }
}

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

#define pb push_back
#define int long long int
#define F first
#define S second
#define MOD 1000000007

signed main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n , m;
        cin >> n >> m;

        multiset <int> a , b;
        for(int i=0 ; i<n ; i++) {
            int x; cin >> x;
            a.insert(x);
        }

        for(int i=0 ; i<m ; i++) {
            int x; cin >> x;
            b.insert(x);
        }

        while(a.size() > 0 and b.size() > 0 and b.size() <= a.size()) {
            auto x = b.end(); x--;
            int xx = *x; b.erase(x);
            if(a.find(xx) != a.end()) 
                a.erase(a.find(xx));
            else {
                b.insert(float(xx/2.0));
                b.insert(ceil(xx/2.0));
            }
        }

        if(a.size() == 0 and b.size() == 0)
            cout << "YES";
        else
            cout << "NO";

        cout << '\n';
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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

#define pb push_back
#define int long long int
#define F first
#define S second
#define MOD 1000000007

signed main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n , m;
        cin >> n >> m;

        multiset <int> a , b;
        for(int i=0 ; i<n ; i++) {
            int x; cin >> x;
            a.insert(x);
        }

        for(int i=0 ; i<m ; i++) {
            int x; cin >> x;
            if(a.find(x) != a.end()) {
                a.erase(a.find(x));
            } else {
                b.insert(x);
            } 
        }

        while(a.size() > 1) {
            int x = *a.begin(); a.erase(a.begin());
            int y = *a.begin(); a.erase(a.begin());
            if(abs(x - y) <= 1) {
                int z = x+y;
                if(b.find(z) != b.end()) 
                    b.erase(b.find(z));
                else 
                    a.insert(z);
            } else
                break;
        }

        if(a.size() > 0 or b.size() > 0)
            cout << "NO";
        else 
            cout << "YES";

        cout << '\n';
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define pb push_back
#define int long long int
#define F first
#define S second
#define MOD 1000000007

signed main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n , m;
        cin >> n >> m;

        multiset <int> a , b;
        for(int i=0 ; i<n ; i++) {
            int x; cin >> x;
            a.insert(x);
        }

        for(int i=0 ; i<m ; i++) {
            int x; cin >> x;
            if(a.find(x) != a.end()) {
                a.erase(a.find(x));
            } else {
                b.insert(x);
            } 
        }

        while(a.size() > 1) {
            int x = *a.begin(); a.erase(a.begin());
            int y = *a.begin(); a.erase(a.begin());
            if(abs(x - y) <= 1) {
                int z = x+y;
                if(b.find(z) != b.end()) 
                    b.erase(b.find(z));
                else 
                    a.insert(z);
            } else
                break;
        }

        if(a.size() > 0 or b.size() > 0)
            cout << "NO";
        else 
            cout << "YES";

        cout << '\n';
    }
}

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

#define pb push_back
#define int long long int
#define F first
#define S second
#define MOD 1000000007

signed main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n , m;
        cin >> n >> m;

        multiset <int> a , b;
        for(int i=0 ; i<n ; i++) {
            int x; cin >> x;
            a.insert(x);
        }

        for(int i=0 ; i<m ; i++) {
            int x; cin >> x;
            if(a.find(x) != a.end()) {
                a.erase(a.find(x));
            } else {
                b.insert(x);
            }
        }
        
        while(a.size() > 1 and b.size() > 0) {
            int x = *a.begin(); a.erase(a.begin());
            int y = *b.begin(); b.erase(b.begin());

            int p = y - x;
            if(p <= 0)
                break;
            else if(abs(x-p) <= 1 and a.find(p) != a.end()) {
                a.erase(a.find(p));
            } else {
                b.insert(y);

                y = *a.begin(); a.erase(a.begin());

                if(abs(x - y) <= 1) {
                    int z = x+y;
                    if(b.find(z) != b.end()) 
                        b.erase(b.find(z));
                    else 
                        a.insert(z);
                } else
                    break;
            }
        }

        if(a.size() > 0 or b.size() > 0)
            cout << "NO";
        else 
            cout << "YES";

        cout << '\n';
    }
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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 int n;
        cin>>n;
        if(n % 9 == 0){
            cout<<"YES"<<endl;
            continue;
        }
        long long int sum = 0;
        long long int a = n;
        long long int two = 0, three = 0;
        while(a > 0){
            long long int digit = a%10;
            sum += digit;
            if(digit == 2) two++;
            else if(digit == 3) three++;
            a/=10;
        }
        if(two == 0 && three == 0){
            cout<<"NO"<<endl;
            continue;
        }
        int f = 0;
        n = n % 9;
        int k = 1;
        while(two > 0 || three > 0){
            int number = (9 * k);
            if((number - n) % 2 == 0 && (number - n)/2 <= two){
                f = 1;
                break;
            }
            if((number - n) % 6 == 0 && (number - n)/6 <= three){
                f = 1;
                break;
            }
            if((number - n) % 8 == 0 && two > 0 && three > 0){
                f = 1;
                break;
            }
            else if(two > 0 && three > 0){
                n += 8;
                two--;
                three--;
            }
            while(n < number && three > 0){
                n += 6;
                three--;
            }
            while(n < number && two > 0){
                n += 2;
                two--;
            }
            k++;
        }
        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n;
        cin>>n;
        if(n % 9 == 0){
            cout<<"YES"<<endl;
            continue;
        }
        long long int sum = 0;
        long long int a = n;
        long long int two = 0, three = 0;
        while(a > 0){
            long long int digit = a%10;
            sum += digit;
            if(digit == 2) two++;
            else if(digit == 3) three++;
            a/=10;
        }
        if(two == 0 && three == 0){
            cout<<"NO"<<endl;
            continue;
        }
        int f = 0;
        if(two > 8) two = 8;
        if(three > 8) three = 8;
        for(int i = 0; i<=two; i++){
            for(int j = 0; j<=three; j++){
                if((sum + i*2 + j*6)% 9 == 0){
                    f = 1;
                    break;
                }
            }
        }
        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}