ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

void init_code() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	init_code();

	int t;
	cin >> t;

	while (t--) {
		int n, k;
		int res = 0;

		cin >> n >> k;

		vector<int> a(n);

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

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

		int l = 0, r = 0;
		int unique = 0;
		while (r < n) {
			unique++;
			while (r < n && a[r] == a[l]) r++;
			if (r-l<=k) {
				unique--;
				k-= r-l;
			}
			l = r;
		}

		cout << (unique == 0 ? 1 : unique) << endl;
	}

	return 0;
}

Submission (verdict: Time limit exceeded on test 14):
#include <bits/stdc++.h>
using namespace std;

void init_code() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

void solve() {
	int n, k;
	int res = 0;

	cin >> n >> k;

	vector<int> a(n);
	unordered_map<int, int> freq;

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

	vector<int> frequency;
	for (auto& f : freq) {
		frequency.push_back(f.second);
	}

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

	int unique = frequency.size();
	for (int i = 0; i<frequency.size(); i++) {
		if (frequency[i] > k) {
			cout << unique - i << endl;
			return;
		}
		k -= frequency[i];
	}

	cout << 1 << endl;
}

int main() {
	init_code();

	int t;
	cin >> t;

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

	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 14):
#include <bits/stdc++.h>
using namespace std;

void init_code() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	init_code();

	int t;
	cin >> t;

	while (t--) {
		int n, k;
		int res = 0;

		cin >> n >> k;

		vector<int> a(n);
		unordered_map<int, int> freq;

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

		vector<pair<int, int>> sortedFreq;

		for (auto& p : freq) {
			sortedFreq.push_back(p);
		};

		sort(sortedFreq.begin(), sortedFreq.end(), [](const pair<int,int>& a, const pair<int,int>& b){
			return a.second < b.second;
		});

		for (auto& p : sortedFreq) {
			int e = p.first;
			while (p.second != 0 && k != 0) {
				p.second--;
				k--;
			}

			if (p.second == 0) freq.erase(e);
			if (k == 0) break;
		};


		cout << (freq.size() == 0 ? 1 : freq.size()) << endl;
	}

	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#include <bits/stdc++.h>
using namespace std;

void init_code() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	init_code();

	int t;
	cin >> t;

	while (t--) {
		int n, k;
		int res = 0;

		cin >> n >> k;

		vector<int> a(n);
		unordered_map<int, int> freq;

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

		vector<pair<int, int>> sortedFreq;

		for (auto& p : freq) {
			sortedFreq.push_back(p);
		};

		sort(sortedFreq.begin(), sortedFreq.end(), [](const pair<int,int>& a, const pair<int,int>& b){
			return a.second < b.second;
		});

		for (auto& p : sortedFreq) {
			int e = p.first;
			while (p.second != 0 && k != 0) {
				p.second--;
				k--;
			}

			if (p.second == 0) freq.erase(e);
			if (k == 0) break;
		};


		cout << (freq.size() == 0 ? 1 : freq.size()) << endl;
	}

	return 0;
}

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

void init_code() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	init_code();

	int t;
	cin >> t;

	while (t--) {
		int n, k;
		int res = 0;

		cin >> n >> k;

		vector<int> a(n);

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

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

		int l = 0, r = 0;
		int unique = 0;
		while (r < n) {
			unique++;
			while (r < n && a[r] == a[l]) r++;
			if (r-l<=k) {
				unique--;
				k-= r-l;
			}
			l = r;
		}

		cout << (unique == 0 ? 1 : unique) << endl;
	}

	return 0;
}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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

#define                 ll long long

#define sz(v)           (int)v.size()

#define lp1(i, n)       for(int i = 0; i < n; i++)

#define lp2(i, n)       for(int i = n - 1; i >= 0; i--)

#define lp3(i, j, k)    for(int i = j; i <= k; i++)

#define lp4(i, j, k)    for(int i = j; i >= k; i--)

#define all(v)          v.begin(), v.end()

using namespace std;









void solve() {

    int n;

    string s;

    cin >> n >> s;



    bool x = false;

    bool y = false;

    lp3(i, 1, n - 2) {

        if(s[i] == 'p') x = true;

        if(s[i] == 's') y = true;

    }

    if(x && y || s[0] == 'p' && y || s[n - 1] == 's' && x || s == "ps") {

        cout << "NO\n";

        return;

    }

    cout << "YES\n";

}













int main() {

    // freopen("input.txt", "r", stdin);

    // freopen("output.txt", "w", stdout);







    int t = 1;

    cin >> t;

    while(t--) {

        solve();

    }



}



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

#define                 ll long long

#define sz(v)           (int)v.size()

#define lp1(i, n)       for(int i = 0; i < n; i++)

#define lp2(i, n)       for(int i = n - 1; i >= 0; i--)

#define lp3(i, j, k)    for(int i = j; i <= k; i++)

#define lp4(i, j, k)    for(int i = j; i >= k; i--)

#define all(v)          v.begin(), v.end()

using namespace std;









void solve() {

    int n;

    string s;

    cin >> n >> s;

    if(s[0] == 'p') s[0] = '.';

    if(s.back() == 's') s.back() = '.';

    bool x = false;

    bool y = false;

    lp3(i, 1, n - 2) {

        if(s[i] == 'p') x = true;

        if(s[i] == 's') y = true;

    }

    if(x && y) {

        cout << "NO\n";

        return;

    }

    cout << "YES\n";

}













int main() {

    // freopen("input.txt", "r", stdin);

    // freopen("output.txt", "w", stdout);







    int t = 1;

    cin >> t;

    while(t--) {

        solve();

    }



}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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

#define                 ll long long

#define sz(v)           (int)v.size()

#define lp1(i, n)       for(int i = 0; i < n; i++)

#define lp2(i, n)       for(int i = n - 1; i >= 0; i--)

#define lp3(i, j, k)    for(int i = j; i <= k; i++)

#define lp4(i, j, k)    for(int i = j; i >= k; i--)

#define all(v)          v.begin(), v.end()

using namespace std;









void solve() {

    int n;

    string s;

    cin >> n >> s;

    if(s[0] == 'p') s[0] = '.';

    if(s.back() == 's') s.back() = '.';

    bool x = false;

    bool y = false;

    lp3(i, 1, n - 2) {

        if(s[i] == 'p') x = true;

        if(s[i] == 's') y = true;

    }

    if(x && y) {

        cout << "NO\n";

        return;

    }

    cout << "YES\n";

}













int main() {

    // freopen("input.txt", "r", stdin);

    // freopen("output.txt", "w", stdout);







    int t = 1;

    cin >> t;

    while(t--) {

        solve();

    }



}



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

#define                 ll long long

#define sz(v)           (int)v.size()

#define lp1(i, n)       for(int i = 0; i < n; i++)

#define lp2(i, n)       for(int i = n - 1; i >= 0; i--)

#define lp3(i, j, k)    for(int i = j; i <= k; i++)

#define lp4(i, j, k)    for(int i = j; i >= k; i--)

#define all(v)          v.begin(), v.end()

using namespace std;









void solve() {

    int n;

    string s;

    cin >> n >> s;

    if(s[0] == 's') s[0] = '.';

    if(s.back() == 'p') s.back() = '.';

    bool x = false;

    bool y = false;

    lp1(i, n) {

        if(s[i] == 'p') x = true;

        if(s[i] == 's') y = true;

    }

    if(x && y) {

        cout << "NO\n";

        return;

    }

    cout << "YES\n";

}













int main() {

    // freopen("input.txt", "r", stdin);

    // freopen("output.txt", "w", stdout);







    int t = 1;

    cin >> t;

    while(t--) {

        solve();

    }



}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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

#define                 ll long long

#define sz(v)           (int)v.size()

#define lp1(i, n)       for(int i = 0; i < n; i++)

#define lp2(i, n)       for(int i = n - 1; i >= 0; i--)

#define lp3(i, j, k)    for(int i = j; i <= k; i++)

#define lp4(i, j, k)    for(int i = j; i >= k; i--)

#define all(v)          v.begin(), v.end()

using namespace std;









void solve() {

    int n;

    string s;

    cin >> n >> s;



    bool x = false;

    bool y = false;

    lp3(i, 1, n - 2) {

        if(s[i] == 'p') x = true;

        if(s[i] == 's') y = true;

    }

    if(x && y || s[0] == 'p' && y || s[n - 1] == 's' && x) {

        cout << "NO\n";

        return;

    }

    cout << "YES\n";

}













int main() {

    // freopen("input.txt", "r", stdin);

    // freopen("output.txt", "w", stdout);







    int t = 1;

    cin >> t;

    while(t--) {

        solve();

    }



}



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

#define                 ll long long

#define sz(v)           (int)v.size()

#define lp1(i, n)       for(int i = 0; i < n; i++)

#define lp2(i, n)       for(int i = n - 1; i >= 0; i--)

#define lp3(i, j, k)    for(int i = j; i <= k; i++)

#define lp4(i, j, k)    for(int i = j; i >= k; i--)

#define all(v)          v.begin(), v.end()

using namespace std;









void solve() {

    int n;

    string s;

    cin >> n >> s;



    bool x = false;

    bool y = false;

    lp3(i, 1, n - 2) {

        if(s[i] == 'p') x = true;

        if(s[i] == 's') y = true;

    }

    if(x && y || s[0] == 'p' && y || s[n - 1] == 's' && x || s == "ps") {

        cout << "NO\n";

        return;

    }

    cout << "YES\n";

}













int main() {

    // freopen("input.txt", "r", stdin);

    // freopen("output.txt", "w", stdout);







    int t = 1;

    cin >> t;

    while(t--) {

        solve();

    }



}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)


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

#define                 ll long long

#define sz(v)           (int)v.size()

#define lp1(i, n)       for(int i = 0; i < n; i++)

#define lp2(i, n)       for(int i = n - 1; i >= 0; i--)

#define lp3(i, j, k)    for(int i = j; i <= k; i++)

#define lp4(i, j, k)    for(int i = j; i >= k; i--)

#define all(v)          v.begin(), v.end()

using namespace std;









void solve() {

    int n;

    string s;

    cin >> n >> s;



    bool x = false;

    bool y = false;

    lp3(i, 1, n - 2) {

        if(s[i] == 'p') x = true;

        if(s[i] == 's') y = true;

    }

    if(x && y || s[0] == 'p' && y || s[n - 1] == 's' && x) {

        cout << "NO\n";

        return;

    }

    cout << "YES\n";

}













int main() {

    // freopen("input.txt", "r", stdin);

    // freopen("output.txt", "w", stdout);







    int t = 1;

    cin >> t;

    while(t--) {

        solve();

    }



}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<deque>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<utility>
#include<set>
#include<fstream>
#include<map>
#include<stack>
#include <queue>
#define ll long long
#define lpi(i , n) for(int i = 0 ; i < n ; i++)
#define vi vector<int>
#define dvi vector<vector<int>>
#define srti(p) p.begin() , p.end()
#define ends "\n"
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main() {
  fst;
  ll t ;
  cin >> t;
  while (t--)
  {
    ll x;
    cin >> x;
    vector<ll>p(x);
   for(ll i = 0 ; i < x ;i++)
    {
      cin >> p[i];
    }
    int f = 0;
    for(ll i = 0 ; i < x-1 ;i++)
    {
      if(p[i] < p[i+1])
      {
        p[i+1] -= p[i];
        p[i] = 0;
      }
      else if(p[i] > p[i+1])
      {
        f= 1;
      }
    }
    if(p[x-2] > p[x-1] || f)
    {
      cout << "NO" << ends;
    }
    else{
      cout << "YES" << ends;
    }
  
  }
  
  
}

Submission (verdict: Accepted):
#include<iostream>
#include<vector>
#include<deque>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<utility>
#include<set>
#include<fstream>
#include<map>
#include<stack>
#include <queue>
#define ll long long
#define lpi(i , n) for(int i = 0 ; i < n ; i++)
#define vi vector<int>
#define dvi vector<vector<int>>
#define srti(p) p.begin() , p.end()
#define ends "\n"
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main() {
  fst;
  ll t ;
  cin >> t;
  while (t--)
  {
    ll x;
    cin >> x;
    vector<ll>p(x);
   for(ll i = 0 ; i < x ;i++)
    {
      cin >> p[i];
    }
    int f = 0;
    for(ll i = 0 ; i < x-1 ;i++)
    {
      if(p[i] < p[i+1])
      {
        p[i+1] -= p[i];
        p[i] = 0;
      }
      else if(p[i] > p[i+1])
      {
        f= 1;
      }
      else{
        p[i]=0;
        p[i+1]=0;
        i++;
      }
    }
    if(p[x-2] > p[x-1] || f)
    {
      cout << "NO" << ends;
    }
    else{
      cout << "YES" << ends;
    }
  
  }
  
  
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<deque>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<utility>
#include<set>
#include<fstream>
#include<map>
#include<stack>
#include <queue>
#define ll long long
#define lpi(i , n) for(int i = 0 ; i < n ; i++)
#define vi vector<int>
#define dvi vector<vector<int>>
#define srti(p) p.begin() , p.end()
#define ends "\n"
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main() {
  fst;
  int t ;
  cin >> t;
  while (t--)
  {
    int x;
    cin >> x;
    vi p(x);
    lpi(i , x)
    {
      cin >> p[i];
    }
    int f = 0;
    lpi(i , x-1)
    {
      if(p[i] < p[i+1])
      {
        p[i+1] -= p[i];
        p[i] = 0;
      }
    }
    if(p[x-2] > p[x-1])
    {
      cout << "NO" << ends;
    }
    else{
      cout << "YES" << ends;
    }
  
  }
  
  
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<deque>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<utility>
#include<set>
#include<fstream>
#include<map>
#include<stack>
#include <queue>
#define ll long long
#define lpi(i , n) for(int i = 0 ; i < n ; i++)
#define vi vector<int>
#define dvi vector<vector<int>>
#define srti(p) p.begin() , p.end()
#define ends "\n"
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main() {
  fst;
  ll t ;
  cin >> t;
  while (t--)
  {
    ll x;
    cin >> x;
    vector<ll>p(x);
   for(ll i = 0 ; i < x ;i++)
    {
      cin >> p[i];
    }
    int f = 0;
    for(ll i = 0 ; i < x-1 ;i++)
    {
      if(p[i] < p[i+1])
      {
        p[i+1] -= p[i];
        p[i] = 0;
      }
    }
    if(p[x-2] > p[x-1])
    {
      cout << "NO" << ends;
    }
    else{
      cout << "YES" << ends;
    }
  
  }
  
  
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<deque>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<utility>
#include<set>
#include<fstream>
#include<map>
#include<stack>
#include <queue>
#define ll long long
#define lpi(i , n) for(int i = 0 ; i < n ; i++)
#define vi vector<int>
#define dvi vector<vector<int>>
#define srti(p) p.begin() , p.end()
#define ends "\n"
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main() {
  fst;
  ll t ;
  cin >> t;
  while (t--)
  {
    ll x;
    cin >> x;
    vector<ll>p(x);
   for(ll i = 0 ; i < x ;i++)
    {
      cin >> p[i];
    }
    int f = 0;
    for(ll i = 0 ; i < x-1 ;i++)
    {
      if(p[i] < p[i+1])
      {
        p[i+1] -= p[i];
        p[i] = 0;
      }
      else if(p[i] > p[i+1])
      {
        f= 1;
      }
    }
    if(p[x-2] > p[x-1] || f)
    {
      cout << "NO" << ends;
    }
    else{
      cout << "YES" << ends;
    }
  
  }
  
  
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<deque>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<utility>
#include<set>
#include<fstream>
#include<map>
#include<stack>
#include <queue>
#define ll long long
#define lpi(i , n) for(int i = 0 ; i < n ; i++)
#define vi vector<int>
#define dvi vector<vector<int>>
#define srti(p) p.begin() , p.end()
#define ends "\n"
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main() {
  fst;
  int t ;
  cin >> t;
  while (t--)
  {
    int x;
    cin >> x;
    vi p(x);
    lpi(i , x)
    {
      cin >> p[i];
    }
    int f = 0;
    lpi(i , x-1)
    {
      if(p[i] < p[i+1])
      {
        p[i+1] -= p[i];
        p[i] = 0;
      }
    }
    if(p[x-2] > p[x-1])
    {
      cout << "NO" << ends;
    }
    else{
      cout << "YES" << ends;
    }
  
  }
  
  
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<deque>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<utility>
#include<set>
#include<fstream>
#include<map>
#include<stack>
#include <queue>
#define ll long long
#define lpi(i , n) for(int i = 0 ; i < n ; i++)
#define vi vector<int>
#define dvi vector<vector<int>>
#define srti(p) p.begin() , p.end()
#define ends "\n"
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main() {
  fst;
  ll t ;
  cin >> t;
  while (t--)
  {
    ll x;
    cin >> x;
    vector<ll>p(x);
   for(ll i = 0 ; i < x ;i++)
    {
      cin >> p[i];
    }
    int f = 0;
    for(ll i = 0 ; i < x-1 ;i++)
    {
      if(p[i] < p[i+1])
      {
        p[i+1] -= p[i];
        p[i] = 0;
      }
    }
    if(p[x-2] > p[x-1])
    {
      cout << "NO" << ends;
    }
    else{
      cout << "YES" << ends;
    }
  
  }
  
  
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

using namespace std;

int main()

{

    long long int n,a,b,t,th,p,i,j,sum,d,s;

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cin>>s;while(s--){

    cin>>n;

    a=n;

    b=0;

    t=0;th=0;

    while(a>0)

    {

      b=b+(a%10);

      if((a%10)==2){t=t+1;}

      if((a%10)==3){th=th+1;}

      a=a/10;

    }





    p=0;

    sum=b;

    for(i=0;i<=t;i++)

    for(j=0;j<=th;j++)

    {



        d=2*i+6*j;

        sum=sum+d;



        if(sum%9==0)

        {

            p=p+1;



        }

        else{sum=b;}

    }

    if(p>=1){cout<<"YES";}else{cout<<"NO";}

        cout<<"\n";

    }



    return 0;

}

Submission (verdict: Time limit exceeded on test 5):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n,i,t,th,sum,p,j,d,b,s;

    char str[100005];

    cin>>s;while(s--){

    cin>>str;

    t=0;th=0;sum=0;

    for(i=0;i<strlen(str);i++)

    {

       // cout<<str[i]-'a'+49<<"\n";

        if((str[i]-'a'+49)==2)

        {

                t=t+1;

        }

          if((str[i]-'a'+49)==3)

        {

            th=th+1;

        }

        sum=sum+str[i]-'a'+49;



    }



    p=0;

    if(sum%9==0)

    {

        p=p+1;

    }

    else

    {



        for(i=0;i<=t;i++)

        for(j=0;j<=th;j++)

        {

            d=2*i+6*j;

            b=sum+d;



            if(b%9==0)

            {

                p=p+1;

            }



        }

    }

    if(p>=1)

    {

        cout<<"YES";

    }else{cout<<"NO";}

    cout<<"\n";

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

using namespace std;

int main()

{

    long long int n,a,b,t,th,p,i,j,sum,d,s;

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cin>>s;while(s--){

    cin>>n;

    a=n;

    b=0;

    t=0;th=0;

    while(a>0)

    {

      b=b+(a%10);

      if((a%10)==2){t=t+1;}

      if((a%10)==3){th=th+1;}

      a=a/10;

    }





    p=0;

    sum=b;

    for(i=0;i<=t;i++)

    for(j=0;j<=th;j++)

    {



        d=2*i+6*j;

        sum=sum+d;



        if(sum%9==0)

        {

            p=1;

            j>th;

            i>t;



        }

        else{sum=b;}

    }

    if(p>=1){cout<<"YES";}else{cout<<"NO";}

        cout<<"\n";

    }



    return 0;

}



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

using namespace std;

int main()

{

    long long int n,a,b,t,th,p,i,j,sum,d,s;

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cin>>s;while(s--){

    cin>>n;

    a=n;

    b=0;

    t=0;th=0;

    while(a>0)

    {

      b=b+(a%10);

      if((a%10)==2){t=t+1;}

      if((a%10)==3){th=th+1;}

      a=a/10;

    }





    p=0;

    sum=b;

    for(i=0;i<=t;i++)

    for(j=0;j<=th;j++)

    {



        d=2*i+6*j;

        sum=sum+d;



        if(sum%9==0)

        {

            p=p+1;



        }

        else{sum=b;}

    }

    if(p>=1){cout<<"YES";}else{cout<<"NO";}

        cout<<"\n";

    }



    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

using namespace std;

int main()

{

    long long int n,a,b,t=0,th=0,p,i,j,sum,d,s;

    cin>>s;while(s--){

    cin>>n;

    a=n;

    b=0;

    t=0;th=0;

    while(a>0)

    {

      b=b+(a%10);

      if((a%10)==2){t=t+1;}

      if((a%10)==3){th=th+1;}

      a=a/10;

    }





    p=0;

    for(i=0;i<t+1;i++)

    for(j=0;j<th+1;j++)

    {

        sum=b;

        d=2*i+6*j;

        sum=sum+d;



        if(sum%9==0)

        {

            p=1;

            i=t+1;



        }

    }

    if(p==1){cout<<"YES";}else{cout<<"NO";}

        cout<<"\n";

    }



    return 0;

}

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

using namespace std;

int main()

{

    long long int n,a,b,t,th,p,i,j,sum,d,s;

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cin>>s;while(s--){

    cin>>n;

    a=n;

    b=0;

    t=0;th=0;

    while(a>0)

    {

      b=b+(a%10);

      if((a%10)==2){t=t+1;}

      if((a%10)==3){th=th+1;}

      a=a/10;

    }





    p=0;

    sum=b;

    for(i=0;i<=t;i++)

    for(j=0;j<=th;j++)

    {



        d=2*i+6*j;

        sum=sum+d;



        if(sum%9==0)

        {

            p=1;

            j>th;

            i>t;



        }

        else{sum=b;}

    }

    if(p>=1){cout<<"YES";}else{cout<<"NO";}

        cout<<"\n";

    }



    return 0;

}