ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

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

using namespace std;

int main() {
	int t; cin >> t;
	while (t--) {
		int n; cin >> n;
		vector<vector<int>> adjs(n);
		vector<pair<int, int>> edgs(n, pair<int, int>(0, 0));
		for (int i = 0; i < n; i++) edgs[i].second = i;
		for (int i = 0; i < n-1; i++) {
			int u, v; cin >> u >> v; u--; v--;
			adjs[u].push_back(v); adjs[v].push_back(u);
			edgs[u].first++; edgs[v].first++;
		}
		sort(edgs.begin(), edgs.end());
		if (edgs[n-1].first != edgs[n-2].first) {
			auto& _ = adjs[edgs[n-1].second];
			if (find(_.begin(), _.end(), edgs[n-2].second) == _.end()) {
				cout << (edgs[n-1].first + edgs[n-2].first - 1) << '\n';
			} else {
				cout << (edgs[n-1].first + edgs[n-2].first - 2) << '\n';
			}
		} else {
			int i = 0;
			int ss = edgs[n-1].first;
			while ((n-i-1) >= 0 && edgs[n-i-1].first == ss) i++;
			if (i >= 3) {
				cout << (ss + ss - 2) << '\n';
			} else {
				auto& _ = adjs[edgs[n-1].second];
				if (find(_.begin(), _.end(), edgs[n-2].second) == _.end()) {
					cout << (edgs[n-1].first + edgs[n-2].first - 1) << '\n';
				} else {
					cout << (edgs[n-1].first + edgs[n-2].first - 2) << '\n';
				}
			}

		}
	}

	return 0;
}


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

using namespace std;

int main() {
	int t; cin >> t;
	while (t--) {
		int n; cin >> n;
		vector<vector<int>> adjs(n);
		vector<pair<int, int>> edgs(n, pair<int, int>(0, 0));
		for (int i = 0; i < n; i++) edgs[i].second = i;
		for (int i = 0; i < n-1; i++) {
			int u, v; cin >> u >> v; u--; v--;
			adjs[u].push_back(v); adjs[v].push_back(u);
			edgs[u].first++; edgs[v].first++;
		}
		sort(edgs.begin(), edgs.end());
		if (edgs[n-1].first != edgs[n-2].first) {
				int i = 0;
				int ss = edgs[n-2].first;
				while ((n-i-2) >= 0 && edgs[n-i-2].second == ss) i++;
				auto& _ = adjs[edgs[n-1].second];
				_.sort();
				bool found = false;
				for (int j = n-2; j > (n-2-i); j--) {
					if (!binary_search(_.begin(), _.end(), edgs[j].second)) {
						found = true;
						cout << (edgs[n-1].first + edgs[n-2].first - 1) << '\n';
					}
				}
				if (!found) cout << (edgs[n-1].first + edgs[n-2].first - 2) << '\n';
		} else {
			int i = 0;
			int ss = edgs[n-1].first;
			while ((n-i-1) >= 0 && edgs[n-i-1].first == ss) i++;
			if (i >= 3) {
				cout << (ss + ss - 2) << '\n';
			} else {
				auto& _ = adjs[edgs[n-1].second];
				if (find(_.begin(), _.end(), edgs[n-2].second) == _.end()) {
					cout << (edgs[n-1].first + edgs[n-2].first - 1) << '\n';
				} else {
					cout << (edgs[n-1].first + edgs[n-2].first - 2) << '\n';
				}
			}

		}
	}

	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


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

using namespace std;

int main() {
	int t; cin >> t;
	while (t--) {
		int n; cin >> n;
		vector<vector<int>> adjs(n);
		vector<pair<int, int>> edgs(n, pair<int, int>(0, 0));
		for (int i = 0; i < n; i++) edgs[i].second = i;
		for (int i = 0; i < n-1; i++) {
			int u, v; cin >> u >> v; u--; v--;
			adjs[u].push_back(v); adjs[v].push_back(u);
			edgs[u].first++; edgs[v].first++;
		}
		sort(edgs.begin(), edgs.end());
		if (edgs[n-1].first != edgs[n-2].first) {
			auto& _ = adjs[edgs[n-1].second];
			if (find(_.begin(), _.end(), edgs[n-2].second) == _.end()) {
				cout << (edgs[n-1].first + edgs[n-2].first - 1) << '\n';
			} else {
				cout << (edgs[n-1].first + edgs[n-2].first - 2) << '\n';
			}
		} else {
			int i = 0;
			int ss = edgs[n-1].first;
			while ((n-i-1) >= 0 && edgs[n-i-1].first == ss) i++;
			if (i >= 3) {
				cout << (ss + ss - 2) << '\n';
			} else {
				auto& _ = adjs[edgs[n-1].second];
				if (find(_.begin(), _.end(), edgs[n-2].second) == _.end()) {
					cout << (edgs[n-1].first + edgs[n-2].first - 1) << '\n';
				} else {
					cout << (edgs[n-1].first + edgs[n-2].first - 2) << '\n';
				}
			}

		}
	}

	return 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 int
const ll M = 1e9 + 7; 
#define aa ios::sync_with_stdio(false)
#define bb cin.tie(nullptr)

void solve() {
    ll n; cin >> n;
    set<pair<ll, ll>> st;
    vector<ll> deg(n);
    for(ll i = 0; i < n - 1; ++i){
        ll a, b; cin >> a >> b;
        st.insert({min(a, b) - 1, max(a, b) - 1});
        deg[a - 1]++;
        deg[b - 1]++;
    }

    map<ll, vector<ll>> mpp;
    for(ll i = 0; i < n; ++i){
        mpp[deg[i]].push_back(i);
    }

    vector<pair<ll, vector<ll>>> v;
    for(auto it : mpp) {
        v.push_back({it.first, it.second});
    }

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

    ll cnt = 0;
    ll sm = 0;
    ll ele1 = -1;
    ll ele2 = -1;
    for(ll i = v.size()-1; i >= 0; --i){
        ll sz = v[i].second.size() - 1;
        // cout<<v[i].second.size()<<"hh\n";
        while(cnt < 2) {
            sm += v[i].first;
            if(ele1 == -1) {
                ele1 = v[i].second[v[i].second.size() - 1 - sz];
                // cout<<ele1<<"h\n";
            }else if(ele2 == -1) {
                ele2 = v[i].second[v[i].second.size() - 1 - sz];
            }
            sz--;
            cnt++;
            if(sz == -1) break;
        }


        if(cnt >= 3) {
            cout<<(sm - 1)<<"\n";
            return;
        }else if(cnt == 2) {
            if(st.find({min(ele1, ele2), max(ele1, ele2)}) == st.end()) {
                cout<<(sm - 1)<<"\n";
                return;
            }
            cout<<(sm - 2)<<"\n";
            return;
        } 
        
    }

    cout<<0<<"\n";




}

int main() {
    aa; bb;
    ll t; 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):
/*

 *  - Dhiraj Yadav

 *  - Progress is slow, but quitting guarantees failure

 *  - Stay consistent, stay disciplined, and success will follow!

 */



#include <bits/stdc++.h>

using namespace std;



#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define yy cout << "YES\n"

#define nn cout << "NO\n"

#define ll long long

#define v vector<int>

#define inp(v) for (auto &x : v) cin >> x;



int main() {

    fastio;

    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

        v a(n);

        inp(a);



        int left = 0, right = 0;

        

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

            if (a[i] > a[i - 1]) left++;

            else if (a[i] < a[i - 1]) right++;

        }

        if (right > left) {

            nn;

        } else {

            yy;

        }

    }

    return 0;

}



Submission (verdict: Accepted):
/*

 *  - Dhiraj Yadav

 *  - Progress is slow, but quitting guarantees failure

 *  - Stay consistent, stay disciplined, and success will follow!

 */

 

#include <bits/stdc++.h>

using namespace std;



#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define yy cout << "YES" << endl

#define nn cout << "NO" << endl

#define ll long long

#define v vector<int>

#define inp(v) for (auto &x : v) cin >> x;

#define pb push_back

#define po pop_back

#define f2(v) for (int i = 0; i < (v).size(); i++) cout << (v)[i] << " ";

#define vvi vector<vector<int>>

#define vll vector<long long>

#define mapii map<int, int>

#define mapci map<char, int>

#define SORT(v) sort(v.begin(), v.end())

#define REV(v) reverse(v.begin(), v.end())

const int MOD = 1e9 + 7;

vector<bool> sieve(int maxNum) {

    vector<bool> isPrime(maxNum + 1, true);

    isPrime[0] = isPrime[1] = false; // 0 and 1 are not prime numbers



    for (int i = 2; i * i <= maxNum; i++) {

        if (isPrime[i]) {

            for (int j = i * i; j <= maxNum; j += i) {

                isPrime[j] = false;

            }

        }

    }

    return isPrime;

}



bool isPrime(int x) {

    if (x <= 1)

        return false;

    for (int i = 2; i * i <= x; i++) {

        if (x % i == 0) {

            return false;

        }

    }

    return true;

}



int gcd(int a, int b) {

    if (b == 0)

        return a;

    return gcd(b, a % b);

}

int main() {

    fastio;

    int t;

    cin >> t;

    while (t--)

    {

        int n;

        cin>>n;

        v a(n);

        inp(a);

        if(is_sorted(a.begin(),a.end()))

        {

            cout<<"YES"<<endl;

            continue;

        }

        bool possible = true;

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

        {

            if(a[i-1]>a[i])

            {

                possible = false;

                break;

            }

            a[i]-=a[i-1];

        }

        if (possible) yy;

         else nn;

    }

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


Submission (verdict: Wrong answer on test 2):
/*

 *  - Dhiraj Yadav

 *  - Progress is slow, but quitting guarantees failure

 *  - Stay consistent, stay disciplined, and success will follow!

 */

 

#include <bits/stdc++.h>

using namespace std;



#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define yy cout << "YES" << endl

#define nn cout << "NO" << endl

#define ll long long

#define v vector<int>

#define inp(v) for (auto &x : v) cin >> x;

#define pb push_back

#define po pop_back

#define f2(v) for (int i = 0; i < (v).size(); i++) cout << (v)[i] << " ";

#define vvi vector<vector<int>>

#define vll vector<long long>

#define mapii map<int, int>

#define mapci map<char, int>

#define SORT(v) sort(v.begin(), v.end())

#define REV(v) reverse(v.begin(), v.end())

const int MOD = 1e9 + 7;

vector<bool> sieve(int maxNum) {

    vector<bool> isPrime(maxNum + 1, true);

    isPrime[0] = isPrime[1] = false; // 0 and 1 are not prime numbers



    for (int i = 2; i * i <= maxNum; i++) {

        if (isPrime[i]) {

            for (int j = i * i; j <= maxNum; j += i) {

                isPrime[j] = false;

            }

        }

    }

    return isPrime;

}



bool isPrime(int x) {

    if (x <= 1)

        return false;

    for (int i = 2; i * i <= x; i++) {

        if (x % i == 0) {

            return false;

        }

    }

    return true;

}



int gcd(int a, int b) {

    if (b == 0)

        return a;

    return gcd(b, a % b);

}

int main() {

    fastio;

    int t;

    cin >> t;

    while (t--)

    {

        int n;

        cin>>n;

        v a(n);

        inp(a);

        int left=0;

        int right=0;

        if(is_sorted(a.begin(),a.end()))

        {

            cout<<"YES"<<endl;

            continue;

        }

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

        {2060

            if(a[i]>a[i-1])

            {

                left++;

            }

        }

         for(int i=n-1;i>=0;i--)

        {

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

            {

                right++;

            }

        }

      //  cout<<left<<" "<<right<<endl;

        if(abs(left-right)<=1)

        {

            cout<<"YES"<<endl;

        }

        else

        {

            cout<<"NO"<<endl;

        }

    }

}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define debug(i) cout << #i << ' '<<i<<endl;
#define int long long
#define yy cout << "YES\n";
#define nn cout << "NO\n";
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define f(i, x, n) for (int i = x; i < n; i++)
#define rf(i, x, n) for (int i = x; i >= n; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const int inf = LLONG_MAX;
const int mod = 1e9 + 7;
const int mod2 = 998244353;

void solve(){
    int n;
    cin>>n;

    vector<int> v,v1(n);
    int sum=0;
    f(i,0,n){
        int x;
        cin>>x;
        v.pb(x);
        sum+=v[i];
        v1[i]=v[i];
    }

    int mx=sum;
    f(i,0,n){
        sum=0;
        if(v.size()==1) break;
        reverse(all(v));
        vector<int> a;
        f(j,1,v.size()){
            a.pb(v[j]-v[j-1]);
            sum+=(v[j]-v[j-1]);
        }
        mx=max(mx,sum);
        v.clear();
        f(j,0,a.size()){
            v.pb(a[j]);
        }
    }

    f(i,0,n){
        sum=0;
        if(v.size()==1) break;
        vector<int> a;
        f(j,1,v.size()){
            a.pb(v[j]-v[j-1]);
            sum+=(v[j]-v[j-1]);
        }
        mx=max(mx,sum);
        v.clear();
        f(j,0,a.size()){
            v.pb(a[j]);
        }
        reverse(all(v));
    }

    cout<<mx<<endl;
}

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

    int T=1;
    cin >> T;

    while (T--) {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define debug(i) cout << #i << ' '<<i<<endl;
#define int long long
#define yy cout << "YES\n";
#define nn cout << "NO\n";
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define f(i, x, n) for (int i = x; i < n; i++)
#define rf(i, x, n) for (int i = x; i >= n; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const int inf = LLONG_MAX;
const int mod = 1e9 + 7;
const int mod2 = 998244353;

void solve(){
    int n;
    cin>>n;

    vector<int> v,v1(n);
    int sum=0;
    f(i,0,n){
        int x;
        cin>>x;
        v.pb(x);
        sum+=v[i];
        v1[i]=v[i];
    }

    int mx=sum;
    f(i,0,n){
        sum=0;
        if(v.size()==1) break;
        vector<int> a;
        f(j,1,v.size()){
            a.pb(v[j]-v[j-1]);
            sum+=abs(v[j]-v[j-1]);
        }
        mx=max(mx,sum);
        v.clear();
        f(j,0,a.size()){
            v.pb(a[j]);
        }
    }

    cout<<mx<<endl;
}

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

    int T=1;
    cin >> T;

    while (T--) {
        solve();
    }
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define debug(i) cout << #i << ' '<<i<<endl;
#define int long long
#define yy cout << "YES\n";
#define nn cout << "NO\n";
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define f(i, x, n) for (int i = x; i < n; i++)
#define rf(i, x, n) for (int i = x; i >= n; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const int inf = LLONG_MAX;
const int mod = 1e9 + 7;
const int mod2 = 998244353;

void solve(){
    int n;
    cin>>n;

    vector<int> v,v1(n);
    int sum=0;
    f(i,0,n){
        int x;
        cin>>x;
        v.pb(x);
        sum+=v[i];
        v1[i]=v[i];
    }

    int mx=sum;
    f(i,0,n){
        sum=0;
        if(v.size()==1) break;
        vector<int> a;
        f(j,1,v.size()){
            a.pb(v[j]-v[j-1]);
            sum+=(v[j]-v[j-1]);
        }
        mx=max(mx,abs(sum));
        v.clear();
        f(j,0,a.size()){
            v.pb(a[j]);
        }
    }

    cout<<mx<<endl;
}

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

    int T=1;
    cin >> T;

    while (T--) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

using namespace std;

void solve()
{

    string s;
    cin >> s;
    int nn = s.size();
    int change = 1;
    while (change > 0)
    {
        change = 0;

        for (int i = s.size() - 1; i > 0; i--)
        {
            // cout << i << endl;
            if (s[i] > s[i - 1] + 1)
            {
                s[i]--;
                swap(s[i], s[i - 1]);
                change++;
            }
        }
    }
    cout << s << endl;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
        solve();

    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 8):
#include <bits/stdc++.h>
#define ll long long

using namespace std;

void solve()
{

    string s;
    cin >> s;
    int nn = s.size();
    int change = 1;
    while (change > 0)
    {
        change = 0;

        for (int i = s.size() - 1; i > 0; i--)
        {
            // cout << i << endl;
            if (s[i] > s[i - 1] + 1)
            {
                s[i]--;
                swap(s[i], s[i - 1]);
                change++;
            }
        }
    }
    cout << s << endl;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
        solve();

    return 0;
}

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

using namespace std;

void solve()
{

    string s;
    cin >> s;
    int nn = s.size();
    // int change = 1;
    while (nn--)
    {
        // change = 0;

        for (int i = s.size() - 1; i > 0; i--)
        {
            // cout << i << endl;
            if (s[i] > s[i - 1] + 1)
            {
                s[i]--;
                swap(s[i], s[i - 1]);
                // change++;
            }
        }
    }
    cout << s << endl;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
        solve();

    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#define ll long long

using namespace std;

void solve()
{

    string s;
    cin >> s;
    int nn = s.size();
    // int change = 1;
    while (nn--)
    {
        // change = 0;

        for (int i = s.size() - 1; i > 0; i--)
        {
            // cout << i << endl;
            if (s[i] > s[i - 1] + 1)
            {
                s[i]--;
                swap(s[i], s[i - 1]);
                // change++;
            }
        }
    }
    cout << s << endl;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
        solve();

    return 0;
}

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

using namespace std;

void solve()
{

    string s;
    cin >> s;
    int nn = s.size();
    int n = s.size();

    for (int i = 0; i < s.size(); i++)
    {
        int maxi_ind = -1;
        int maxi = s[i] - '0';
        for (int j = i + 1; j < min(i + 9, n); j++)
        {
            if (s[j] - '0' - (j - i) > maxi)
            {
                maxi = s[j] - '0' - (j - i);
                maxi_ind = j;
            }
        }

        while (maxi_ind > i)
        {
            swap(s[maxi_ind], s[maxi_ind - 1]);
            maxi_ind--;
        }
        s[i] = maxi + '0';
    }

    cout << s << endl;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
        solve();

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


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

#define pb push_back
#define ll long long int
#define mp make_pair
#define MAXN 100001

#define sz(x) static_cast<int>((x).size())
#define all(x) (x).begin(), (x).end()
#define input(v) for(ll i=0;i<(long long int)v.size();i++) cin>>v[i];
ll MOD=998244353;
void YES() {cout<<"YES"<<endl;}
void NO(){cout<<"NO"<<endl;}
ll max(ll a,ll b){
    if(a>=b) return a;
    return b;
}
ll gcd(ll a,ll b)
{
    ll x1=min(a,b);
    ll x2=max(a,b);
    if(x1<=0) return x2;
    ll x=x2%x1;
    return gcd(x,x1);
}
void print(vector<ll>&v){
    ll n=(ll)v.size();
    for(ll j=0;j<n;j++) cout<<v[j]<<" ";
    cout<<"\n";
    return;
}
ll lcm(ll a,ll b){
    if(a==0) return b;
    if(b==0) return a;
    ll g=gcd(a,b);
    return (a*b)/g;
}
ll onesComplement(ll n){
    ll number_of_bits = floor(log2(n)) + 1;
    return ((1 << number_of_bits) - 1) ^ n;
}
ll powmod(ll n,ll k){
    ll ans=1;
    if(k<0) return 0;
    while(k--){
        ans*=n;
        ans%=MOD;
    }
    return ans;
}

ll power(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p){
    return power(n, p - 2, p);
}

void solve(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    input(a);
    vector<pair<ll,ll>>v;
    map<ll,ll>m;
    for(ll i=0;i<n;i++) m[a[i]]=i;
    for(ll i=1;i<=n;i++){
        for(ll j=i+1;j<=n;j++){
            v.pb({j,i});
            if(m[i]<m[j]) v.pb({i,j});
        }
    }
    cout<<v.size()<<"\n";
    for(auto i:v) cout<<i.first<<" "<<i.second<<"\n";
    return;
}



int main ()
{
    #ifndef ONLINE_JUDGE  
        // For getting input from input.txt file
        freopen("input.txt", "r", stdin);  
        // Printing the Output to output.txt file
        freopen("output.txt", "w", stdout);
        // Printing the run time of code in Terminal
        class Timer { chrono::time_point <chrono::steady_clock> B, E; public: Timer () : B(), E()
        { B = chrono::steady_clock::now(); } ~Timer () { E = chrono::steady_clock::now();
        cerr << "\nDuration: " << ((chrono::duration <double>)(E - B)).count() << "s\n"; } } TimerT;  
    #endif
       // For faster Input/Output
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    while(t--) solve();
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

using namespace std;

long long get_sum(long long sum){
    while(sum > 9){
        long long n = sum;
        sum = 0;
        while(n > 0){
            sum += n%10;
            n /= 10;
        }
    }
    return sum;
}

void solve(string s){
    long long arr[s.size()];
    long long sum = 0;
    int two = 0,three = 0;
    for(int i = 0;i < s.size();i++){
        arr[i] = s[i] - '0';
        sum += arr[i];
        if(arr[i] == 2)two++;
        else if(arr[i] == 3)three++;
    }
    sum = get_sum(sum);
    for(int i = 0;i < min(10,two + 1);i++){
        for(int j = 0;j < min(10,three + 1);j++){
            if((sum + i*2 + j*3)%9 == 0){
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
    return;
}


int main(){
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        solve(s);
    }
    return 0;
}

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

using namespace std;

long long get_sum(long long sum){
    while(sum > 9){
        long long n = sum;
        sum = 0;
        while(n > 0){
            sum += n%10;
            n /= 10;
        }
    }
    return sum;
}

void solve(string s){
    long long arr[s.size()];
    long long sum = 0;
    int two = 0,three = 0;
    for(int i = 0;i < s.size();i++){
        arr[i] = s[i] - '0';
        sum += arr[i];
        if(arr[i] == 2)two++;
        else if(arr[i] == 3)three++;
    }
    sum = get_sum(sum);
    for(int i = 0;i < min(10,two + 1);i++){
        for(int j = 0;j < min(10,three + 1);j++){
            if((sum + i*2 + j*6)%9 == 0){
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
    return;
}


int main(){
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        solve(s);
    }
    return 0;
}