ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
/*
   Cool_ewrey_boy
*/
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define size(v) (int) size(v)
#define all(v) begin(v), end(v)
#if !LOCAL
   #define endl '\n'
#endif
 
using namespace std;
using ll = long long;
const ll INF = 1e18l + 10;
const int mod = 1e9 + 7, inf = 2e9 + 10;

void solve() {
   int n;
   cin >> n;
   vector<int> a(n);
   for(int &i: a) cin >> i;
   for(int i = 0; i < n - 1; i++) {
      if(a[i] < a[i + 1]) {
         cout << "YES\n";
         return;
      }
      else if(a[i] == a[i + 1]) continue;
      else {
         cout << "NO\n";
         return;
      }
   }
} 

int main() {
   cin.tie(0)->sync_with_stdio(0);
   if(auto s = "in.txt"; fopen(s, "r") && freopen(s, "r", stdin));
   int t = 1;
   cin >> t;
   //t = 1;
   while(t--) solve();
   return 0;
}

Submission (verdict: Wrong answer on test 2):
/*
   Cool_ewrey_boy
*/
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define size(v) (int) size(v)
#define all(v) begin(v), end(v)
#if !LOCAL
   #define endl '\n'
#endif
 
using namespace std;
using ll = long long;
const ll INF = 1e18l + 10;
const int mod = 1e9 + 7, inf = 2e9 + 10;

void solve() {
   int n;
   cin >> n;
   vector<int> a(n);
   for(int &i: a) cin >> i;
   for(int i = 0; i < n - 1; i++) {
      if(a[i] < a[i + 1]) {
         cout << "YES\n";
         return;
      }
      else if(a[i] == a[i + 1]) continue;
      else {
         cout << "NO\n";
         return;
      }
   }
   cout << "NO\n";
} 

int main() {
   cin.tie(0)->sync_with_stdio(0);
   if(auto s = "in.txt"; fopen(s, "r") && freopen(s, "r", stdin));
   int t = 1;
   cin >> t;
   //t = 1;
   while(t--) solve();
   return 0;
}
Problem: 2049B - pspspsps
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 MOD 1000000007



int32_t main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        int n;

        string str;

        cin >> n >> str;

        bool s = 0, dot = 0, p = 0, flag = true;

        for (char cur : str)

        {

            if (cur == 'p')

            {

                p = 1;

            }

            else

            {

                if (p)

                {

                    if (cur == '.' && (!s || !dot))

                    {

                        dot = true;

                        continue;

                    }

                    else

                    {

                        flag = false;

                        break;

                    }

                }

                if (cur == 's')

                    s = true;

                if (cur == '.')

                    dot = true;

            }

        }

        if (flag)

            cout << "YES" << endl;

        else

            cout << "NO" << endl;

    }

    return 0;

}

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

using namespace std;

#define int long long

#define MOD 1000000007



int32_t main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        int n;

        string str;

        cin >> n >> str;

        if (str[0] == 's')

            str[0] = '.';

        if (str[n - 1] == 'p')

            str[n - 1] = '.';

        char last = '.';

        bool flag = true;

        for (char c : str)

        {

            if (c != '.')

            {

                if (last == '.')

                {

                    last = c;

                }

                else if (last != c)

                {   

                    flag = false;

                    break;

                }

            }

        }

        if (flag)

            cout << "YES" << endl;

        else

            cout << "NO" << endl;

    }

    return 0;

}
Problem: 2049B - pspspsps
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 MOD 1000000007



int32_t main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        int n;

        string str;

        cin >> n >> str;

        bool s = 0, dot = 0, p = 0, flag = true;

        for (char cur : str)

        {

            if (cur == 'p')

            {

                p = 1;

            }

            else

            {

                if (p)

                {

                    if (cur == '.' && !s)

                    {

                        dot = true;

                        continue;

                    }

                    else

                    {

                        flag = false;

                        break;

                    }

                }

                if (cur == 's')

                    s = true;

            }

        }

        if (flag)

            cout << "YES" << endl;

        else

            cout << "NO" << endl;

    }

    return 0;

}

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

using namespace std;

#define int long long

#define MOD 1000000007



int32_t main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        int n;

        string str;

        cin >> n >> str;

        bool s = 0, dot = 0, p = 0, flag = true;

        for (char cur : str)

        {

            if (cur == 'p')

            {

                p = 1;

            }

            else

            {

                if (p)

                {

                    if (cur == '.' && (!s || !dot))

                    {

                        dot = true;

                        continue;

                    }

                    else

                    {

                        flag = false;

                        break;

                    }

                }

                if (cur == 's')

                    s = true;

                if (cur == '.')

                    dot = true;

            }

        }

        if (flag)

            cout << "YES" << endl;

        else

            cout << "NO" << endl;

    }

    return 0;

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


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

using namespace std;

#define int long long

#define MOD 1000000007



int32_t main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        int n;

        string str;

        cin >> n >> str;

        bool s = 0, dot = 0, p = 0, flag = true;

        for (char cur : str)

        {

            if (cur == 'p')

            {

                p = 1;

            }

            else

            {

                if (p)

                {

                    if (cur == '.' && !s)

                    {

                        dot = true;

                        continue;

                    }

                    else

                    {

                        flag = false;

                        break;

                    }

                }

                if (cur == 's')

                    s = true;

            }

        }

        if (flag)

            cout << "YES" << endl;

        else

            cout << "NO" << endl;

    }

    return 0;

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


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

using namespace std;

#define IOS                           \

    std::ios::sync_with_stdio(false); \

    cin.tie(0);                       \

    cout.tie(0)

#define int long long

#define dbug cout << '!' << '\n'

typedef pair<int,int> pi;

const int N = 1e7 + 10;

const int inf = 998244353;

void solve()

{

    int n;

    cin>>n;

    vector<int>a(n);

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

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

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

        if(!k) continue;

        a[i]-=k;

        a[i+1]-=k;

    }

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

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

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

signed main()

{

    IOS;

    int t = 1;

    cin >> t;

    while(t--) solve();

    return 0;

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

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

using namespace std;

#define IOS                           \

    std::ios::sync_with_stdio(false); \

    cin.tie(0);                       \

    cout.tie(0)

#define int long long

#define dbug cout << '!' << '\n'

typedef pair<int,int> pi;

const int N = 1e7 + 10;

const int inf = 998244353;

void solve()

{

    int n;

    cin>>n;

    vector<int>a(n);

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

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

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

        a[i]-=k;

        a[i+1]-=k;

    }

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

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

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

signed main()

{

    IOS;

    int t = 1;

    cin >> t;

    while(t--) solve();

    return 0;

}

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

using namespace std;

#define IOS                           \

    std::ios::sync_with_stdio(false); \

    cin.tie(0);                       \

    cout.tie(0)

#define int long long

#define dbug cout << '!' << '\n'

typedef pair<int,int> pi;

const int N = 2e5 + 10;

const int inf = 998244353;

void solve()

{

    int n;

    cin>>n;

    vector<int>a(n);

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

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

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

        a[i]-=k;

        a[i+1]-=k;

    }

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

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

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

signed main()

{

    IOS;

    int t = 1;

    cin >> t;

    while(t--) solve();

    return 0;

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

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

using namespace std;

#define IOS                           \

    std::ios::sync_with_stdio(false); \

    cin.tie(0);                       \

    cout.tie(0)

#define int long long

#define dbug cout << '!' << '\n'

typedef pair<int,int> pi;

const int N = 1e7 + 10;

const int inf = 998244353;

void solve()

{

    int n;

    cin>>n;

    vector<int>a(n);

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

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

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

        if(!k) continue;

        a[i]-=k;

        a[i+1]-=k;

    }

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

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

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

signed main()

{

    IOS;

    int t = 1;

    cin >> t;

    while(t--) solve();

    return 0;

}

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

using namespace std;

#define IOS                           \

    std::ios::sync_with_stdio(false); \

    cin.tie(0);                       \

    cout.tie(0)

#define int long long

#define dbug cout << '!' << '\n'

typedef pair<int,int> pi;

const int N = 1e7 + 10;

const int inf = 998244353;

void solve()

{

    int n;

    cin>>n;

    vector<int>a(n);

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

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

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

        a[i]-=k;

        a[i+1]-=k;

    }

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

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

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

signed main()

{

    IOS;

    int t = 1;

    cin >> t;

    while(t--) solve();

    return 0;

}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 
using namespace __gnu_pbds;
   
typedef long long ll;
#define int long long
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#ifndef ONLINE_JUDGE
#include "ciphertxt.cpp"
#else
#define dff(...)
#define dfa(...)
#endif

vector<int> bin(int x){
    vector<int> arr;
    while(x){arr.push_back(x%2);x/=2;}
    while(arr.size()!=30){arr.push_back(0);}
    return arr;
}

void solve(){
    int l,r;cin>>l>>r;
    int i,j;    
    // int a,b,c;cin>>a>>b>>c;
    // cout<<(a ^ b) + (b ^ c) + (c ^ a)<<" ";cout<<endl;
    // bin(a);bin(b);bin(c);cout<<endl;
    auto la=bin(l);auto ra=bin(r);
    
    for(i=29;i>=0;i--){if(la[i]!=ra[i]){break;}}
    int a=0;
    int b=0;
    int id=i;int t=1;
    dff(la,ra);

    for(i=0;i<id;i++){a+=t;t*=2;}
    t*=2;
    for(i=id+1;i<30;i++){if(la[i]){a+=t;}t*=2;}

    t=1;
    for(i=0;i<id;i++){t*=2;}
    b+=t;
    t*=2;
    for(i=id+1;i<30;i++){if(ra[i]){b+=t;}t*=2;}
    cout<<a<<" "<<b<<" "<<b<<endl;
    //cout<<2*(a ^ b) <<endl;
    }
    
 
signed main(){
    
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    #ifndef ONLINE_JUDGE
    freopen("rr.txt", "w", stderr);
    #endif

    int t;cin>>t;while(t--){
        solve();
        }
    return 0;
    }
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

int T,n;

signed main(){
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>T;
	auto solve = [&](){
	    cin>>n;
		vector<int> a(n+100);
		vector<int> b(n+100);
		int sum=0,len=n;
		for(int i=1;i<=n;++i) cin>>a[i],sum+=a[i];
		if(n==1) cout<<sum;
		else{
		    for(int i=1;i<=n-1;++i){
				sum=max(sum,abs(a[1]-a[len]));
				len--;
				for(int j=1;j<=len;++j) b[j]=a[j+1]-a[j];
				for(int j=1;j<=len;++j) a[j]=b[j];
			}
			cout<<sum<<'\n';
		}
	};
	while(T--) solve();
	return 0;
}

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

int T,n;

signed main(){
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>T;
	auto solve = [&](){
	    cin>>n;
		vector<int> a(n+100);
		vector<int> b(n+100);
		int sum=0,len=n;
		for(int i=1;i<=n;++i) cin>>a[i],sum+=a[i];
		if(n==1) cout<<sum<<'\n';
		else{
		    for(int i=1;i<=n-1;++i){
				sum=max(sum,abs(a[1]-a[len]));
				len--;
				for(int j=1;j<=len;++j) b[j]=a[j+1]-a[j];
				for(int j=1;j<=len;++j) a[j]=b[j];
			}
			cout<<sum<<'\n';
		}
	};
	while(T--) solve();
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

int T,n;

signed main(){
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>T;
	auto solve = [&](){
	  	cin>>n;
		int sum=0;
		vector<int> a(n+100);
		vector<int> b(n+100);
		for(int i=1;i<=n;++i){
			cin>>a[i];
			sum+=a[i];
		}
		if(n==1) cout<<sum<<'\n';
		else{
			int len=n;
			for(int i=1;i<=n;++i){
				len--;
				for(int j=1;j<=len;++j) b[j]=a[j+1]-a[j];
				for(int j=1;j<=len;++j) a[j]=b[j];
				sum=max(sum,abs(a[1]-a[len]));
			}
		}
		cout<<sum<<'\n';
	}; 
	while(T--) solve();
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

int T,n;

signed main(){
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>T;
	auto solve = [&](){
	  	cin>>n;
		int sum=0;
		vector<int> a(n+100);
		vector<int> b(n+100);
		for(int i=1;i<=n;++i){
			cin>>a[i];
			sum+=a[i];
		}
		if(n==1) cout<<sum<<'\n';
		else{
			int len=n;
			for(int i=1;i<=n;++i){
				len--;
				for(int j=1;j<=len;++j) b[j]=a[j+1]-a[j];
				for(int j=1;j<=len;++j) a[j]=b[j];
				sum=max(sum,abs(a[1]-a[len]));
			}
		}
		cout<<sum<<'\n';
	}; 
	while(T--) solve();
	return 0;
}

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

int T,n;

signed main(){
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>T;
	auto solve = [&](){
	    cin>>n;
		vector<int> a(n+100);
		vector<int> b(n+100);
		int sum=0,len=n;
		for(int i=1;i<=n;++i) cin>>a[i],sum+=a[i];
		if(n==1) cout<<sum;
		else{
		    for(int i=1;i<=n-1;++i){
				sum=max(sum,abs(a[1]-a[len]));
				len--;
				for(int j=1;j<=len;++j) b[j]=a[j+1]-a[j];
				for(int j=1;j<=len;++j) a[j]=b[j];
			}
			cout<<sum<<'\n';
		}
	};
	while(T--) solve();
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


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

using namespace std;

signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //ifstream fin;
  //fin.open("b.txt");

  int T;
  cin >> T;
  while(T--)  {
    string s;
    cin >> s;
    int suma = 0;
    int cnt3 = 0, cnt2 = 0;
    for(int i = 0; i < s.size(); i++)  {
        if(s[i] == '2')
            cnt2++;
        if(s[i] == '3')
            cnt3++;
        suma += s[i] - '0';
    }
    bool b = 0;
    for(int i = 1; i <= cnt3; i++)  {
        int nuevo = suma + i * 6ll;
        for(int j = 0; j <= 20; j++)
            if((nuevo + j) % 9 == 0 && j / 2 <= cnt2)
                b = 1;
    }
    if(b)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
  }

  return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

using namespace std;

signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //ifstream fin;
  //fin.open("b.txt");

  int T;
  cin >> T;
  while(T--)  {
    string s;
    cin >> s;
    int suma = 0;
    int cnt3 = 0, cnt2 = 0;
    for(int i = 0; i < s.size(); i++)  {
        if(s[i] == '2')
            cnt2++;
        if(s[i] == '3')
            cnt3++;
        suma += s[i] - '0';
    }
    bool b = 0;
    if(suma % 9 == 0)
        b = 1;
    for(int i = 0; i <= cnt3 && !b; i++)  {
        int nuevo = suma + i * 6ll;
        for(int j = 0; j <= 20; j++)
            if((nuevo + j) % 9 == 0 && j / 2 <= cnt2)
                b = 1;
    }
    if(b)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
  }

  return 0;
}


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

using namespace std;

signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //ifstream fin;
  //fin.open("b.txt");

  int T;
  cin >> T;
  while(T--)  {
    string s;
    cin >> s;
    int suma = 0;
    int cnt3 = 0, cnt2 = 0;
    for(int i = 0; i < s.size(); i++)  {
        if(s[i] == '2')
            cnt2++;
        if(s[i] == '3')
            cnt3++;
        suma += s[i] - '0';
    }
    bool b = 0;
    if(suma % 9 == 0)
        b = 1;
    for(int i = 0; i <= cnt3 && !b; i++)  {
        int nuevo = suma + i * 6ll;
        for(int j = 0; j <= 20; j += 2)
            if((nuevo + j) % 9 == 0 && j / 2 <= cnt2)
                b = 1;
    }
    if(b)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
  }

  return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

using namespace std;

signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //ifstream fin;
  //fin.open("b.txt");

  int T;
  cin >> T;
  while(T--)  {
    string s;
    cin >> s;
    int suma = 0;
    int cnt3 = 0, cnt2 = 0;
    for(int i = 0; i < s.size(); i++)  {
        if(s[i] == '2')
            cnt2++;
        if(s[i] == '3')
            cnt3++;
        suma += s[i] - '0';
    }
    bool b = 0;
    if(suma % 9 == 0)
        b = 1;
    for(int i = 1; i <= cnt3 && !b; i++)  {
        int nuevo = suma + i * 6ll;
        for(int j = 0; j <= 20; j++)
            if((nuevo + j) % 9 == 0 && j / 2 <= cnt2)
                b = 1;
    }
    if(b)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
  }

  return 0;
}


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

using namespace std;

signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //ifstream fin;
  //fin.open("b.txt");

  int T;
  cin >> T;
  while(T--)  {
    string s;
    cin >> s;
    int suma = 0;
    int cnt3 = 0, cnt2 = 0;
    for(int i = 0; i < s.size(); i++)  {
        if(s[i] == '2')
            cnt2++;
        if(s[i] == '3')
            cnt3++;
        suma += s[i] - '0';
    }
    bool b = 0;
    if(suma % 9 == 0)
        b = 1;
    for(int i = 0; i <= cnt3 && !b; i++)  {
        int nuevo = suma + i * 6ll;
        for(int j = 0; j <= 20; j++)
            if((nuevo + j) % 9 == 0 && j / 2 <= cnt2)
                b = 1;
    }
    if(b)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
  }

  return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

using namespace std;

signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //ifstream fin;
  //fin.open("b.txt");

  int T;
  cin >> T;
  while(T--)  {
    string s;
    cin >> s;
    int suma = 0;
    int cnt3 = 0, cnt2 = 0;
    for(int i = 0; i < s.size(); i++)  {
        if(s[i] == '2')
            cnt2++;
        if(s[i] == '3')
            cnt3++;
        suma += s[i] - '0';
    }
    bool b = 0;
    for(int i = 1; i <= cnt3; i++)  {
        int nuevo = suma + i * 6ll;
        for(int j = 0; j <= 20; j++)
            if((nuevo + j) % 9 == 0 && j / 2 <= cnt2)
                b = 1;
    }
    if(b)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
  }

  return 0;
}


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

using namespace std;

signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //ifstream fin;
  //fin.open("b.txt");

  int T;
  cin >> T;
  while(T--)  {
    string s;
    cin >> s;
    int suma = 0;
    int cnt3 = 0, cnt2 = 0;
    for(int i = 0; i < s.size(); i++)  {
        if(s[i] == '2')
            cnt2++;
        if(s[i] == '3')
            cnt3++;
        suma += s[i] - '0';
    }
    bool b = 0;
    if(suma % 9 == 0)
        b = 1;
    for(int i = 1; i <= cnt3 && !b; i++)  {
        int nuevo = suma + i * 6ll;
        for(int j = 0; j <= 20; j++)
            if((nuevo + j) % 9 == 0 && j / 2 <= cnt2)
                b = 1;
    }
    if(b)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
  }

  return 0;
}