ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long

signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

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

cin>>v[i];



}

bool z=true;

int res=0;

if(v[1]<v[0]){

cout<<"NO"<<endl;

}

else{

res=v[1]-v[0];

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

if((v[i+1]-v[i])<res){

z=false;

break;



}

else{

res=v[i+1]-v[i];

++i;

}



}

if(z){

cout<<"YES"<<endl;

}

else{

cout<<"NO"<<endl;

}



}

}

}

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

using namespace std;

#define int long long

signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

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

cin>>v[i];



}

bool z=true;

int res=0;

if(v[1]<v[0]){

cout<<"NO"<<endl;

}

else{

res=v[1]-v[0];

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

if(v[i+1]-v[i]<res){

z=false;

break;



}

else{

res=v[i+1]-v[i];

++i;

}



}

if(z){

cout<<"YES"<<endl;

}

else{

cout<<"NO"<<endl;

}



}

}

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

using namespace std;

#define int long long

signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

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

cin>>v[i];



}

bool z=true;

int res=0;

if(v[1]<v[0]){

cout<<"NO"<<endl;

}

else{

res=v[1]-v[0];

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

if((v[i+1]-v[i])<res){

z=false;

break;



}

else{

res=v[i+1]-v[i];

++i;

}



}

if(z){

cout<<"YES"<<endl;

}

else{

cout<<"NO"<<endl;

}



}

}

}
Problem: 2060D - Subtract Min Sort
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

signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

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

cin>>v[i];



}

bool z=true;

int res=0;

if(v[1]<v[0]){

cout<<"NO"<<endl;

}

else{

res=v[1]-v[0];

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

if(v[i+1]-v[i]<res){

z=false;

break;



}

else{

res=v[i+1]-v[i];

++i;

}



}

if(z){

cout<<"YES"<<endl;

}

else{

cout<<"NO"<<endl;

}



}

}

}

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

using namespace std;

#define int long long

signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

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

cin>>v[i];

}

bool z=true;

if(v[0]>v[1]){

cout<<"N0"<<endl;

}

else{

v[1]=v[1]-v[0];

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

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

z=false;

cout<<"NO"<<endl;

break;



}

else{

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

}

}

if(z){

cout<<"YES"<<endl;

}

}

}

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long

signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

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

cin>>v[i];

}

bool z=true;

if(v[0]>v[1]){

cout<<"N0"<<endl;

}

else{

v[1]=v[1]-v[0];

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

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

z=false;

cout<<"NO"<<endl;

break;



}

else{

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

}

}

if(z){

cout<<"YES"<<endl;

}

}

}

}

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

using namespace std;

#define int long long

signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

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

cin>>v[i];

}

bool z=true;

if(v[0]>v[1]){

cout<<"NO"<<endl;

}

else{

v[1]=v[1]-v[0];

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

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

z=false;

cout<<"NO"<<endl;

break;



}

else{

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

}

}

if(z){

cout<<"YES"<<endl;

}

}

}

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 5):
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long int
using namespace std;
    
int main() {
   int z;
   cin>>z;
    int a[z];
    int b[z];
    vector<vector<int>> v(z,vector<int> (z,0));
    for(int i=0;i<z;i++){
      cin>>a[i];
      b[i]=i+1;
    }
    vector<pair<int,int>> ans;
    for(int i=0;i<z;i++){
      if(b[i]!=a[i]){
         ans.push_back({a[i],b[i]});
         v[a[i]-1][b[i]-1]=1;
         v[b[i]-1][a[i]-1]=1;
         b[a[i]-1]=b[i];
         b[i]=a[i];
      }
    }
   for(int i=z-1;i>=1;i--){
     int j=i-1;
     while(j>=0&&v[b[i]-1][b[j]-1]==0){
      ans.push_back({b[i],b[j]});
      j--;
     }
     while(j<i-1){
      ans.push_back({b[j+1],b[i]});
      j++;
     }
   }
   cout<<ans.size()<<endl;
   for(int i=0;i<ans.size();i++){
      cout<<ans[i].first<<" "<<ans[i].second<<endl;
   }
   
    return 0;
}

Submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long int
using namespace std;
    
int main() {
   int z;
   cin>>z;
    int a[z];
    int b[z];
    vector<vector<int>> v(z,vector<int> (z,0));
    for(int i=0;i<z;i++){
      cin>>a[i];
      b[i]=i+1;
    }
    vector<pair<int,int>> ans;
    for(int i=0;i<z;i++){
      if(b[i]!=a[i]){
        int j=i;
        while(b[j]!=a[i]){
         j++;
        }
        while (j>i)
        {
         ans.push_back({a[i],b[j-1]});
         swap(b[j],b[j-1]);
         v[b[j]-1][b[j-1]-1]=1;
         j--;
        }
      }
    }
   for(int i=z-1;i>=1;i--){
     int j=i-1;
     while(j>=0&&v[b[i]-1][b[j]-1]==0&&v[b[j]-1][b[i]-1]==0){
      ans.push_back({b[i],b[j]});
      j--;
     }
     while(j<i-1){
      ans.push_back({b[j+1],b[i]});
      j++;
     }
   }
   cout<<ans.size()<<endl;
   for(int i=0;i<ans.size();i++){
      cout<<ans[i].first<<" "<<ans[i].second<<endl;
   }
   
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long int
using namespace std;
    
int main() {
   int z;
   cin>>z;
    int a[z];
    int b[z];
    vector<vector<int>> v(z,vector<int> (z,0));
    for(int i=0;i<z;i++){
      cin>>a[i];
      b[i]=i+1;
    }
    vector<pair<int,int>> ans;
    for(int i=0;i<z;i++){
      if(b[i]!=a[i]){
         ans.push_back({a[i],b[i]});
         v[a[i]-1][b[i]-1]=1;
         v[b[i]-1][a[i]-1]=1;
         b[a[i]-1]=b[i];
         b[i]=a[i];
      }
    }
   for(int i=0;i<z;i++){
      for(int j=0;j<z;j++){
         if(v[i][j]==0&&i!=j){
            ans.push_back({i+1,j+1});
         }
      }
   }
   cout<<ans.size()<<endl;
   for(int i=0;i<ans.size();i++){
      cout<<ans[i].first<<" "<<ans[i].second<<endl;
   }
   
    return 0;
}

Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long int
using namespace std;
    
int main() {
   int z;
   cin>>z;
    int a[z];
    int b[z];
    vector<vector<int>> v(z,vector<int> (z,0));
    for(int i=0;i<z;i++){
      cin>>a[i];
      b[i]=i+1;
    }
    vector<pair<int,int>> ans;
    for(int i=0;i<z;i++){
      if(b[i]!=a[i]){
         ans.push_back({a[i],b[i]});
         v[a[i]-1][b[i]-1]=1;
         v[b[i]-1][a[i]-1]=1;
         b[a[i]-1]=b[i];
         b[i]=a[i];
      }
    }
   for(int i=0;i<z-1;i++){
         if(v[b[i]-1][b[i+1]-1]==0){
            ans.push_back({b[i+1],b[i]});
            ans.push_back({b[i],b[i+1]});
         }
   }
   cout<<ans.size()<<endl;
   for(int i=0;i<ans.size();i++){
      cout<<ans[i].first<<" "<<ans[i].second<<endl;
   }
   
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long int
using namespace std;
    
int main() {
   int z;
   cin>>z;
    int a[z];
    int b[z];
    vector<vector<int>> v(z,vector<int> (z,0));
    for(int i=0;i<z;i++){
      cin>>a[i];
      b[i]=i+1;
    }
    vector<pair<int,int>> ans;
    for(int i=0;i<z;i++){
      if(b[i]!=a[i]){
        int j=i;
        while(b[j]!=a[i]){
         j++;
        }
        while (j>i)
        {
         ans.push_back({a[i],b[j-1]});
         swap(b[j],b[j-1]);
         v[b[j]-1][b[j-1]-1]=1;
         j--;
        }
      }
    }
   for(int i=z-1;i>=1;i--){
     int j=i-1;
     while(j>=0&&v[b[i]-1][b[j]-1]==0&&v[b[j]-1][b[i]-1]==0){
      ans.push_back({b[i],b[j]});
      j--;
     }
     while(j<i-1){
      ans.push_back({b[j+1],b[i]});
      j++;
     }
   }
   cout<<ans.size()<<endl;
   for(int i=0;i<ans.size();i++){
      cout<<ans[i].first<<" "<<ans[i].second<<endl;
   }
   
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long int
using namespace std;
    
int main() {
   int z;
   cin>>z;
    int a[z];
    int b[z];
    for(int i=0;i<z;i++){
      cin>>a[i];
      b[i]=z-i;
    }
    vector<pair<int,int>> ans;
    for(int i=z;i>=2;i--){
      for(int j=i-1;j>=1;j--){
         ans.push_back({i,j});
      }
    }
    for(int i=0;i<z-1;i++){
      int j=i;
      while(a[i]!=b[j]){
         j++;
      }
      while(j>i){
         ans.push_back({a[i],b[j-1]});
         swap(b[j],b[j-1]);
         j--;
      }
    }
   cout<<ans.size()<<endl;
   for(int i=0;i<ans.size();i++){
      cout<<ans[i].first<<" "<<ans[i].second<<endl;
   }
   
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long int
using namespace std;
    
int main() {
   int z;
   cin>>z;
    int a[z];
    int b[z];
    vector<vector<int>> v(z,vector<int> (z,0));
    for(int i=0;i<z;i++){
      cin>>a[i];
      b[i]=i+1;
    }
    vector<pair<int,int>> ans;
    for(int i=0;i<z;i++){
      if(b[i]!=a[i]){
         ans.push_back({a[i],b[i]});
         v[a[i]-1][b[i]-1]=1;
         v[b[i]-1][a[i]-1]=1;
         b[a[i]-1]=b[i];
         b[i]=a[i];
      }
    }
   for(int i=0;i<z;i++){
      for(int j=0;j<z;j++){
         if(v[i][j]==0&&i!=j){
            ans.push_back({i+1,j+1});
         }
      }
   }
   cout<<ans.size()<<endl;
   for(int i=0;i<ans.size();i++){
      cout<<ans[i].first<<" "<<ans[i].second<<endl;
   }
   
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long int
using namespace std;
    
int main() {
   int z;
   cin>>z;
    int a[z];
    int b[z];
    vector<vector<int>> v(z,vector<int> (z,0));
    for(int i=0;i<z;i++){
      cin>>a[i];
      b[i]=i+1;
    }
    vector<pair<int,int>> ans;
    for(int i=0;i<z;i++){
      if(b[i]!=a[i]){
         ans.push_back({a[i],b[i]});
         v[a[i]-1][b[i]-1]=1;
         v[b[i]-1][a[i]-1]=1;
         b[a[i]-1]=b[i];
         b[i]=a[i];
      }
    }
   for(int i=0;i<z-1;i++){
         if(v[b[i]-1][b[i+1]-1]==0){
            ans.push_back({b[i+1],b[i]});
            ans.push_back({b[i],b[i+1]});
         }
   }
   cout<<ans.size()<<endl;
   for(int i=0;i<ans.size();i++){
      cout<<ans[i].first<<" "<<ans[i].second<<endl;
   }
   
    return 0;
}

Submission (verdict: Wrong answer on test 5):
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long int
using namespace std;
    
int main() {
   int z;
   cin>>z;
    int a[z];
    int b[z];
    vector<vector<int>> v(z,vector<int> (z,0));
    for(int i=0;i<z;i++){
      cin>>a[i];
      b[i]=i+1;
    }
    vector<pair<int,int>> ans;
    for(int i=0;i<z;i++){
      if(b[i]!=a[i]){
         ans.push_back({a[i],b[i]});
         v[a[i]-1][b[i]-1]=1;
         v[b[i]-1][a[i]-1]=1;
         b[a[i]-1]=b[i];
         b[i]=a[i];
      }
    }
   for(int i=z-1;i>=1;i--){
     int j=i-1;
     while(j>=0&&v[b[i]-1][b[j]-1]==0){
      ans.push_back({b[i],b[j]});
      j--;
     }
     while(j<i-1){
      ans.push_back({b[j+1],b[i]});
      j++;
     }
   }
   cout<<ans.size()<<endl;
   for(int i=0;i<ans.size();i++){
      cout<<ans[i].first<<" "<<ans[i].second<<endl;
   }
   
    return 0;
}
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 ll long long int

int main() {
    ll t;
    cin >> t;
    
    while (t--) {
        ll z;
        cin >> z;
        vector<set<ll>> tree(z + 1);
        
        for (ll i = 0; i < z - 1; i++) {
            ll x, y;
            cin >> x >> y;
            tree[x].insert(y);
            tree[y].insert(x);
        }

        ll connected = 0, idx = 1;
        
        // Finding the most connected node
        for (ll i = 1; i <= z; i++) {
            if (connected < (ll)tree[i].size()) {
                connected = tree[i].size();
                idx = i;
            }
        }

        ll ans = 0;
        ans += tree[idx].size();
        
        // Remove first selected node's edges
        for (auto x : tree[idx]) {
            tree[x].erase(idx);
        }
        tree[idx].clear();

        // Find the next most connected node
        connected = 0, idx = 1;
        for (ll i = 1; i <= z; i++) {
            if (connected < (ll)tree[i].size()) {
                connected = tree[i].size();
                idx = i;
            }
        }

        ans += tree[idx].size();
        cout << ans-1 << endl;
    }
    
    return 0;
}


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

int main() {
	ll t;
	cin >> t;
	
	while (t--) {
		ll z;
		cin >> z;
		vector<set<ll>> tree(z + 1);
		
		for (ll i = 0; i < z - 1; i++) {
			ll x, y;
			cin >> x >> y;
			tree[x].insert(y);
			tree[y].insert(x);
		}
	  bool isall2=0;
	  ll count1=0,count2=0;
	  for(ll i=1;i<=z;i++)
	  {
	  	if(tree[i].size()==1)
		{
			count1++;
		}
		else if(tree[i].size()==2)
		{
			count2++;
		}
	  }

	  if(z>=5&&count2==z-2&&count1==2)
	  {
	  	isall2=1;
	  }
		ll connected = 0, idx = 1;
		
		// Finding the most connected node
		for (ll i = 1; i <= z; i++) {
			if (connected < (ll)tree[i].size()) {
				connected = tree[i].size();
				idx = i;
			}
		}

		ll ans = 1;
		ans += tree[idx].size()-1;
		// Remove first selected node's edges
		for (auto x : tree[idx]) {
			tree[x].erase(idx);
		}
		tree[idx].clear();

		// Find the next most connected node
		connected = 0, idx = 1;
		for (ll i = 1; i <= z; i++) {
			if (connected < (ll)tree[i].size()) {
				connected = tree[i].size();
				idx = i;
			}
		}

		ans += tree[idx].size()-1;
		if(isall2)
		{
			cout<<"3"<<endl;
		}
		else{
		cout << ans << endl;
		}
	}
	
	return 0;
}
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 ll long long int

int main() {
    ll t;
    cin >> t;
    
    while (t--) {
        ll z;
        cin >> z;
        vector<set<ll>> tree(z + 1);
        
        for (ll i = 0; i < z - 1; i++) {
            ll x, y;
            cin >> x >> y;
            tree[x].insert(y);
            tree[y].insert(x);
        }

        ll connected = 0, idx = 1;
        
        // Finding the most connected node
        for (ll i = 1; i <= z; i++) {
            if (connected < (ll)tree[i].size()) {
                connected = tree[i].size();
                idx = i;
            }
        }

        ll ans = 0;
        ans += tree[idx].size();
        
        // Remove first selected node's edges
        for (auto x : tree[idx]) {
            tree[x].erase(idx);
        }
        tree[idx].clear();

        // Find the next most connected node
        connected = 0, idx = 1;
        for (ll i = 1; i <= z; i++) {
            if (connected < (ll)tree[i].size()) {
                connected = tree[i].size();
                idx = i;
            }
        }

        ans += tree[idx].size();
        cout << ans-1 << endl;
    }
    
    return 0;
}
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 ll long long int

int main() {
	ll t;
	cin >> t;
	
	while (t--) {
		ll z;
		cin >> z;
		vector<set<ll>> tree(z + 1);
		
		for (ll i = 0; i < z - 1; i++) {
			ll x, y;
			cin >> x >> y;
			tree[x].insert(y);
			tree[y].insert(x);
		}
	  bool isall2=0;
	  ll count1=0,count2=0;
	  for(ll i=1;i<=z;i++)
	  {
	  	if(tree[i].size()==1)
		{
			count1++;
		}
		else if(tree[i].size()==2)
		{
			count2++;
		}
	  }

	  if(z>=5&&count2==z-2&&count1==2)
	  {
	  	isall2=1;
	  }
		ll connected = 0, idx = 1;
		
		// Finding the most connected node
		for (ll i = 1; i <= z; i++) {
			if (connected < (ll)tree[i].size()) {
				connected = tree[i].size();
				idx = i;
			}
		}

		ll ans = 1;
		ans += tree[idx].size()-1;
		// Remove first selected node's edges
		for (auto x : tree[idx]) {
			tree[x].erase(idx);
		}
		tree[idx].clear();

		// Find the next most connected node
		connected = 0, idx = 1;
		for (ll i = 1; i <= z; i++) {
			if (connected < (ll)tree[i].size()) {
				connected = tree[i].size();
				idx = i;
			}
		}

		ans += tree[idx].size()-1;
		if(isall2)
		{
			cout<<"3"<<endl;
		}
		else{
		cout << ans << endl;
		}
	}
	
	return 0;
}




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

int main() {
	ll t;
	cin >> t;
	
	while (t--) {
		ll z;
		cin >> z;
		vector<set<ll>> tree(z + 1);
		
		for (ll i = 0; i < z - 1; i++) {
			ll x, y;
			cin >> x >> y;
			tree[x].insert(y);
			tree[y].insert(x);
		}
		vector<set<ll>> tree1=tree;
		ll connected = 0, idx = 1;
		
		// Finding the most connected node
		for (ll i = 1; i <= z; i++) {
			if (connected < (ll)tree[i].size()) {
				connected = tree[i].size();
				idx = i;
			}
		}

		ll ans = 1;
		ans += tree[idx].size()-1;
		// Remove first selected node's edges
		for (auto x : tree[idx]) {
			tree[x].erase(idx);
		}
		tree[idx].clear();

		// Find the next most connected node
		connected = 0, idx = 1;
		for (ll i = 1; i <= z; i++) {
			if (connected < (ll)tree[i].size()) {
				connected = tree[i].size();
				idx = i;
			}
		}

		ans += tree[idx].size()-1;
		
		
		 connected = 0;
		  idx = 1;
		
		// Finding the most connected node
		for (ll i = z; i >=1; i--) {
			if (connected < (ll)tree1[i].size()) {
				connected = tree1[i].size();
				idx = i;
			}
		}

		ll ans1 = 1;
		ans1 += tree1[idx].size()-1;
		// Remove first selected node's edges
		for (auto x : tree1[idx]) {
			tree1[x].erase(idx);
		}
		tree1[idx].clear();

		// Find the next most connected node
		connected = 0, idx = 1;
		for (ll i = 1; i <= z; i++) {
			if (connected < (ll)tree1[i].size()) {
				connected = tree1[i].size();
				idx = i;
			}
		}

		ans1 += tree1[idx].size()-1;
		cout <<max(ans,ans1)<< endl;
	}
	
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
#define inpv(v,n) for(int i=0;i<n;i++)cin>>v[i]
#define disp(v) for(auto x:v) cout<<x<<" "; cout<<"\n"
#define srt(x) sort(x.begin(),x.end())
#define N "\n"
using namespace std;
typedef long long ll;
typedef vector <ll> vll;

void solve() {
    // Your code here
    string s;
    cin>>s;
    int sum=0;
    int three=0;
    int two=0;
    for(int i=0;i<s.length();i++)
    {
        sum+=s[i]-'0';
        switch(s[i])
        {
            case '2':two++;
            break;
            case '3':three++;
            break;
        }
    }
    sum=sum%9;
    bool yes=false;
    for(int i=0;i<=two;i++)
    {
        for(int j=0;j<=three;j++)
        {
            if((i*2+j*6+sum)%9==0)
            {
                yes=true;
                break;
            }
        }
    }
    if(sum==0)yes=true;
    //cout<<two<<" "<<three<<N;
    cout<<(yes?"YES\n":"NO\n");
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--) solve();
}

Submission (verdict: Compilation error):
#include <bits/stdc++.h>
#define inpv(v,n) for(int i=0;i<n;i++)cin>>v[i]
#define disp(v) for(auto x:v) cout<<x<<" "; cout<<"\n"
#define srt(x) sort(x.begin(),x.end())
#define N "\n"
using namespace std;
typedef long long ll;
typedef vector <ll> vll;

void solve() {
    // Your code here
    string s;
    cin>>s;
    int sum=0;
    ll three=0;
    ll two=0;
    for(ll i=0;i<s.length();i++)
    {
        sum+=s[i]-'0';
        switch(s[i])
        {
            case '2':two++;
            break;
            case '3':three++;
            break;
        }
    }
    sum=sum%9;
    bool yes=false;
    two=two%9;
    three=three%9;
    for(ll i=0;i<=two;i++)
    {
        for(ll j=0;j<=three;j++)
        {
            if((i*2+j*6+sum)%9==0)
            {
                yes=true;
                break;
            }
        }
    }
    if(sum==0)yes=true;
    //cout<<two<<" "<<three<<N;
    cout<<(yes?"YES\n":"NO\n");
}


void main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll t;
    cin >> t;
    while (t--) solve();
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
#define inpv(v,n) for(int i=0;i<n;i++)cin>>v[i]
#define disp(v) for(auto x:v) cout<<x<<" "; cout<<"\n"
#define srt(x) sort(x.begin(),x.end())
#define N "\n"
using namespace std;
typedef long long ll;
typedef vector <ll> vll;

void solve() {
    // Your code here
    string s;
    cin>>s;
    int sum=0;
    int three=0;
    int two=0;
    for(int i=0;i<s.length();i++)
    {
        sum+=s[i]-'0';
        switch(s[i])
        {
            case '2':two++;
            break;
            case '3':three++;
            break;
        }
    }
    sum=sum%9;
    bool yes=false;
    for(int i=0;i<=two;i++)
    {
        for(int j=0;j<=three;j++)
        {
            if((i*2+j*6+sum)%9==0)
            {
                yes=true;
                break;
            }
        }
    }
    if(sum==0)yes=true;
    //cout<<two<<" "<<three<<N;
    cout<<(yes?"YES\n":"NO\n");
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--) solve();
}