ShaysXIA/CodeInsightBench huggingface dataset:
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;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pii>
#define F first
#define S second
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7;
const int INF = 1e9;

void solve() {

    ll n;
    cin>>n;


    ll two = 0;
    ll thr = 0;
    ll sum=0;

    while(n!=0){
        ll k = n%10;
        sum+=k;
        if(k==2) two++;
        if(k==3) thr++;
        n/=10;
    }

        for(ll i=0 ; i<=two ; i++){
            for(ll j=0 ; j<=thr ; j++){
                if((sum + i*2 + j*6)%9==0){
                    cout<<"YES"<<endl;
                    return;
                }
            }
        }

        cout<<"NO"<<endl;

    

    
}

int main() {
    fast_io;

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

    return 0;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pii>
#define F first
#define S second
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7;
const int INF = 1e9;

void solve() {

    string s;
    cin>>s;

    int two = 0;
    int thr = 0;
    int sum=0;

    for(int i=0 ; i<s.size() ; i++){
        if(s[i]=='2'){
            two++;
        }
        if(s[i]=='3'){
            thr++;
        }
        sum+=s[i]-'0';
    }

    // cout<<sum<<" "<<two<<" "<<thr<<" ";

        for(int i=0 ; i<=two ; i++){
            for(int j=0 ; j<=thr ; j++){
                if((sum + i*2 + j*6)%9==0){
                    cout<<"YES"<<endl;
                    return;
                }
            }
        }

        cout<<"NO"<<endl;

    

    
}

int main() {
    fast_io;

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

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


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

#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pii>
#define F first
#define S second
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7;
const int INF = 1e9;

int solve(string a,string b,string c,int i,int j,int k,vector<vector<vi>> &dp){

    if(k>=c.size()){
        return 0;
    }

    if(dp[i][j][k]!=-1){
        return dp[i][j][k];
    }

    int left = INT_MAX;
    int right = INT_MAX;

    if(i<a.size() && a[i]==c[k]){
        left = solve(a,b,c,i+1,j,k+1,dp);
    }
    else if(i<a.size() && a[i]!=c[k]) {
        left = 1+solve(a,b,c,i+1,j,k+1,dp);
    }

    if(j<b.size() && b[j]==c[k]){
        right = solve(a,b,c,i,j+1,k+1,dp);
    }
    else if(j<b.size() && b[j]!=c[k]){
        right = 1+solve(a,b,c,i,j+1,k+1,dp);
    }

    return dp[i][j][k] = min(left,right);

}

void solve() {

    string a,b,c;
    cin>>a>>b>>c;

    vector<vector<vi>> dp(a.size()+1,vector<vi> (b.size()+1,vector<int> (c.size()+1,-1)));

    cout<<solve(a,b,c,0,0,0,dp)<<endl;
    
}

int main() {
    fast_io;

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

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

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

#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pii>
#define F first
#define S second
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7;
const int INF = 1e9;

int solve(string a,string b,string c,int i,int j,int k,vector<vector<vi>> &dp){

    if(k>=c.size()){
        return 0;
    }

    if(dp[i][j][k]!=-1){
        return dp[i][j][k];
    }

    int left = INT_MAX;
    int right = INT_MAX;

    if(i<a.size() && a[i]==c[k]){
        left = solve(a,b,c,i+1,j,k+1,dp);
    }
    else if(i<a.size() && a[i]!=c[k]) {
        left = 1+solve(a,b,c,i+1,j,k+1,dp);
    }

    if(j<b.size() && b[j]==c[k]){
        right = solve(a,b,c,i,j+1,k+1,dp);
    }
    else if(j<b.size() && b[j]!=c[k]){
        right = 1+solve(a,b,c,i,j+1,k+1,dp);
    }

    return dp[i][j][k] = min(left,right);

}

void solve() {

    string a,b,c;
    cin>>a>>b>>c;

    vector<vector<vi>> dp(a.size()+1,vector<vi> (b.size()+1,vector<int> (c.size()+1,-1)));

    cout<<solve(a,b,c,0,0,0,dp)<<endl;
    
}

int main() {
    fast_io;

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

    return 0;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pii>
#define F first
#define S second
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7;
const int INF = 1e9;

int solve(string a,string b,string c,int i,int j,int k,vector<vi> &dp){

    if(k>=c.size()){
        return 0;
    }

    if(dp[i][j]!=-1){
        return dp[i][j];
    }

    int left = INT_MAX;
    int right = INT_MAX;

    if(i<a.size() && a[i]==c[k]){
        left = solve(a,b,c,i+1,j,k+1,dp);
    }
    else if(i<a.size() && a[i]!=c[k]) {
        left = 1+solve(a,b,c,i+1,j,k+1,dp);
    }

    if(j<b.size() && b[j]==c[k]){
        right = solve(a,b,c,i,j+1,k+1,dp);
    }
    else if(j<b.size() && b[j]!=c[k]){
        right = 1+solve(a,b,c,i,j+1,k+1,dp);
    }

    return dp[i][j] = min(left,right);

}

void solve() {

    string a,b,c;
    cin>>a>>b>>c;

    vector<vector<int>> dp(a.size()+1,vector<int> (b.size()+1,-1));

    cout<<solve(a,b,c,0,0,0,dp)<<endl;
    
}

int main() {
    fast_io;

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

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

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

#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pii>
#define F first
#define S second
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7;
const int INF = 1e9;

int solve(string a,string b,string c,int i,int j,int k,vector<vi> &dp){

    if(k>=c.size()){
        return 0;
    }

    if(dp[i][j]!=-1){
        return dp[i][j];
    }

    int left = INT_MAX;
    int right = INT_MAX;

    if(i<a.size() && a[i]==c[k]){
        left = solve(a,b,c,i+1,j,k+1,dp);
    }
    else if(i<a.size() && a[i]!=c[k]) {
        left = 1+solve(a,b,c,i+1,j,k+1,dp);
    }

    if(j<b.size() && b[j]==c[k]){
        right = solve(a,b,c,i,j+1,k+1,dp);
    }
    else if(j<b.size() && b[j]!=c[k]){
        right = 1+solve(a,b,c,i,j+1,k+1,dp);
    }

    return dp[i][j] = min(left,right);

}

void solve() {

    string a,b,c;
    cin>>a>>b>>c;

    vector<vector<int>> dp(a.size()+1,vector<int> (b.size()+1,-1));

    cout<<solve(a,b,c,0,0,0,dp)<<endl;
    
}

int main() {
    fast_io;

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

    return 0;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pii>
#define F first
#define S second
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7;
const int INF = 1e9;

int solve(string &a,string &b,string &c,int i,int j,vector<vi> &dp){

    // if(k>=c.size()){
    //     return 0;
    // }

    int k = i+j;

    if (i == a.size() && j == b.size())
        return 0;

    if(dp[i][j]!=-1){
        return dp[i][j];
    }

    int left = INT_MAX;
    int right = INT_MAX;

    if(i<a.size() && a[i]==c[k]){
        left = solve(a,b,c,i+1,j,dp);
    }
    else if(i<a.size() && a[i]!=c[k]) {
        left = 1+solve(a,b,c,i+1,j,dp);
    }

    if(j<b.size() && b[j]==c[k]){
        right = solve(a,b,c,i,j+1,dp);
    }
    else if(j<b.size() && b[j]!=c[k]){
        right = 1+solve(a,b,c,i,j+1,dp);
    }

    return dp[i][j] = min(left,right);

}

void solve() {

    string a,b,c;
    cin>>a>>b>>c;

    vector<vector<int>> dp(a.size()+1,vector<int> (b.size()+1,-1));

    cout<<solve(a,b,c,0,0,dp)<<endl;
    
}

int main() {
    fast_io;

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

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: Rust 2021


Submission (verdict: Wrong answer on test 3):
#![allow(unused)]



use std::{

    cmp::{max, min, Ordering, Reverse},

    collections::{BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque},

    io::stdin,

    mem::swap,

    ops::Index,

    str::FromStr,

    thread::current,

    usize,

};



fn take_usize() -> usize {

    let mut input = String::new();

    stdin().read_line(&mut input).unwrap();

    input.trim().parse().unwrap()

}



fn take_vector<T>() -> Vec<T>

where

    T: FromStr,

    <T as FromStr>::Err: std::fmt::Debug,

{

    let mut input = String::new();

    stdin().read_line(&mut input).unwrap();

    input

        .trim()

        .split_whitespace()

        .map(|x| T::from_str(x).unwrap())

        .collect()

}



fn take_vector_usize() -> Vec<usize> {

    take_vector()

}



fn take_vector_int() -> Vec<i64> {

    take_vector()

}



fn take_string() -> String {

    let mut input = String::new();

    stdin().read_line(&mut input).unwrap();

    input = input.trim().to_string();

    input

}



fn take_chars() -> Vec<char> {

    take_string().chars().collect()

}



fn create_vector<T>(n: usize, initial_value: T) -> Vec<T>

where

    T: Clone,

{

    (0..n).map(|_| initial_value.clone()).collect()

}



type VV<T> = Vec<Vec<T>>;



fn solve() {

    let input = take_vector_usize();

    let n = input[0];

    let m = input[1];



    let a = take_vector_usize();

    let mut b = take_vector_usize();

    b.sort();



    let mut pq = a.iter().map(|val| Reverse(*val)).collect::<BinaryHeap<_>>();

    let mut can = true;



    for i in 0..m {

        if pq.is_empty() {

            can = false;

            break;

        }



        loop {

            let top = pq.pop().unwrap();

            if top.0 > b[i] {

                can = false;

                break;

            } else if top.0 == b[i] {

                break;

            } else {

                if let Some(next) = pq.pop() {

                    if next.0 - top.0 <= 1 {

                        let val = next.0 + top.0;

                        pq.push(Reverse(val));

                    } else {

                        can = false;

                        break;

                    }

                } else {

                    can = false;

                    break;

                }

            }

        }



        if !can {

            break;

        }

    }



    if can && pq.is_empty() {

        println!("YES");

    } else {

        println!("NO");

    }

}



pub fn main() {

    let t = take_usize();



    for t in 0..t {

        solve();

    }



    // solve();

}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

#define fastIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL);              \
    cout.precision(numeric_limits<double>::max_digits10);
#define int long long

const int M = 1e9 + 7;

int powm(int x, int n)
{
    x %= M;
    if (n == 0)
        return 1;
    else if (n == 1)
        return x;
    int p = powm(x * x, n / 2);
    if (n % 2)
        return p * x % M;
    else
        return p;
}

int mod_div(int p, int q) { return p % M * powm(q, M - 2) % M; }

vector<int> fact;
int N = 1e6;

int ncr(int n, int r)
{
    if (r > n)
        return 0;
    return mod_div(fact[n], fact[n - r] * fact[r]);
}

bool check(int n, unordered_map<int, int> &mp,int mode) {
    if (mp.find(n) != mp.end() && mp[n] > 0) {
        mp[n]--;
        if(mode==1){
          mp[n]--;  
        }
        if (mp[n] == 0) {
            mp.erase(n);  
        }
        return true;
    }
    if (n == 1 and mp.find(1) == mp.end()) {
        return false;
    }
    if (n & 1) { // If n is odd
        bool t1 = check((n - 1) / 2, mp,0);
        bool t2 = check((n + 1) / 2, mp,0);
        return t1 && t2;
    }
    return check(n / 2, mp,1); 
}

void ved() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    unordered_map<int, int> mp;

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

    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    sort(b.begin(),b.end());
    for (int i = 0; i < m; i++) {
        if (!check(b[i], mp,0)) {
            cout << "No" << endl;
            return;
        }
    }
    if(mp.size()){
        cout<<"No"<<endl;
        return;
    }

    cout << "Yes" << endl;

}


int32_t main()
{
    fastIO;

    fact.assign(N, 1);
    for (int i = 1; i < N; i++)
    {
        fact[i] = fact[i - 1] * i % M;
    }
    
    int t = 1;
    cin >> t;
    while (t--)
    {
        ved();
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#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 ll long long
#define vll vector <long long>
#define vc vector <char>
#define vi vector <int>
#define all(v) v.begin(),v.end()
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define repd(i,a,b) for(ll i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define Yes cout<<"YES"<<endl;
#define No cout<<"NO"<<endl;
#define hey cout<<"hey"<<endl;
#define vpi vector<pair<int,int>>
#define vpll vector<pair<long long,long long>>
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define ub(a,x) upper_bound(a.begin(),a.end(),x)


vll input(ll n){
    vll v(n);
    repi(i,0,n)     cin>>v[i];
    return v;
}


void dfs(map<ll,set<ll>> &g,ll &node,vll &vis){
    vis[node]=1;
    for(auto it : g[node]){
        // if(g.find(it)==g.end()) continue;
        if(vis[it]==0){
            dfs(g,it,vis);
        }
    }
}


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


int t;
cin>>t;
while(t--)
    {
        ll n;
        cin>>n;
        
        map<ll,set<ll>> g;

        repi(i,0,n-1){
            ll u,v;
            cin>>u>>v;
            g[u].insert(v);
            g[v].insert(u);
        }

        
        ll first=-1;
        ll curr=0;
        for(auto it:g){ 
            if( it.second.size()>=curr){
                curr= it.second.size();
                first=it.first;
            }
        }

        for(auto it:g[first]){
            g[it].erase(first);
        }
        g.erase(first);
        
        first=-1;
        curr=0;
        for(auto it:g){
            if( it.second.size()>=curr){
                curr= it.second.size();
                first=it.first;
            }
        }
        // cout<<g[first].size()<<endl;
        // cout<<"first2="<<first<<endl;
        for(auto it:g[first]){
            g[it].erase(first);
        }
        g.erase(first);


        ll cnt=0;
        vll vis(n+1);
        repi(i,1,n+1){
            if(g.find(i)!=g.end()){
                if(vis[i]==0){
                    cnt++;
                    dfs(g,i,vis);
                }
            }
        }

        cout<<cnt<<endl;
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long int ull;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ll my_rand(ll l, ll r) {
//     return uniform_int_distribution<ll>(l, r) (rng);
// }

void tcase(int Tcase)
{
	int n;
    scanf("%d",&n);
    int a[n+5], pos[n+5], b[n+5];
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        pos[a[i]] = i;
        b[i] = n+1-i;
    }
    vector<pair<int,int>>v;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            v.push_back({j, i});
        }
    }
    int curr = 1;
    while(curr < n){
        if(curr == pos[b[curr]]){
            curr++;
            continue;
        }
        int temp = b[curr];
        int diff = pos[temp]-curr;
        for(int i = 1; i <= diff; i++){
            v.push_back({b[curr+i], temp});
            b[curr+i-1] = b[curr+i];
        }
        b[curr+diff] = temp;
    }
    int siz = v.size();
    printf("%d\n",siz);
    for(int i = 0; i < siz; i++){
        printf("%d %d\n",v[i].first, v[i].second);
    }
}

int main(){
	int T = 1;
  	//scanf("%d",&T);
  	for(int Tcase = 1; Tcase <= T; Tcase++){
		  tcase(Tcase);
  	}
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

// Function to solve the problem
int solve(int n, vector<int> sequence, int l, int r) {
    vector<int> copy = sequence;
    sort(copy.begin(), copy.begin() + r,greater<int>());
    sort(sequence.begin() + (l - 1), sequence.end());
    int left = 0, right = 0;
    for (int i = l - 1; i < r; i++) {
        left += copy[i];
        right += sequence[i];
    }
    return min(left, right);
}

int main() {
    int t;
    cin >> t;
    
    while (t-- > 0) {
        int n, l, r;
        cin >> n >> l >> r;
        vector<int> sequence(n);
        
        for (int i = 0; i < n; i++) {
            cin >> sequence[i];
        }
        
        cout << solve(n, sequence, l, r) << endl;
    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

// Function to solve the problem
int solve(int n, vector<int> sequence, int l, int r) {
    vector<int> copy = sequence;
    sort(copy.begin(), copy.begin() + r,greater<int>());
    sort(sequence.begin() + (l - 1), sequence.end());
    int left = 0, right = 0;
    for (int i = l - 1; i < r; i++) {
        left += copy[i];
        right += sequence[i];
    }
    return min(left, right);
}

int main() {
    int t;
    cin >> t;
    
    while (t-- > 0) {
        int n, l, r;
        cin >> n >> l >> r;
        vector<int> sequence(n);
        
        for (int i = 0; i < n; i++) {
            cin >> sequence[i];
        }
        
        cout << solve(n, sequence, l, r) << endl;
    }

    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



int solve(int n, vector<int>& sequence, int l, int r) {

    vector<int> sorted_seq = sequence;

    sort(sorted_seq.begin(), sorted_seq.end()); // Sort the entire array



    int segment_size = r - l + 1;

    int min_sum = 0;



    // Take the smallest `segment_size` elements from the sorted array

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

        min_sum += sorted_seq[i];

    }



    return min_sum;

}



int main() {

    int t;

    cin >> t;

    

    while (t-- > 0) {

        int n, l, r;

        cin >> n >> l >> r;

        vector<int> sequence(n);

        

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

            cin >> sequence[i];

        }

        

        cout << solve(n, sequence, l, r) << endl;

    }



    return 0;

}



//#include <iostream>

//#include <vector>

//#include <algorithm>

//

//using namespace std;

//int solve(int n, vector<int>& sequence, int l, int r) {

//    vector<int> left_part(sequence.begin(), sequence.begin() + r);

//    vector<int> right_part(sequence.begin() + (l - 1), sequence.end());

//    sort(left_part.begin(), left_part.end(), greater<int>());

//    sort(right_part.begin(), right_part.end()); // Ascending

//

//    int left_sum = 0, right_sum = 0;

//    for (int i = l - 1; i < r; i++) {

//        left_sum += left_part[i];

//        right_sum += right_part[i - (l - 1)];

//    }

//

//    return min(left_sum, right_sum);

//}

//

//int main() {

//    int t;

//    cin >> t;

//    

//    while (t-- > 0) {

//        int n, l, r;

//        cin >> n >> l >> r;

//        vector<int> sequence(n);

//        

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

//            cin >> sequence[i];

//        }

//        

//        cout << solve(n, sequence, l, r) << endl;

//    }

//

//    return 0;

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


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


signed main() {
    int q;
    cin>>q;
    while(q--){
        string n;
        cin>>n;
        int sum=0;
        for(int i=0;i<n.size();i++){
            int num = n[i] - '0';
            sum+=num;

        }
        bool flag=true;
        if(sum%9==0){
            cout<<"YES"<<endl;
        }
        else{
            for(int i=0;i<n.size();i++){
                int num = n[i] - '0';
                if(num<=3){
                    sum-=num;
                    sum+=num*num;
                    if(sum%9==0){
                        cout<<"YES"<<endl;
                        flag=false;
                        break;
                    }
                    else{
                        sum-=num*num;
                        sum+=num;
                    }
                }
                
            }
            if(flag==true){
                for(int i=0;i<n.size();i++){
                int num = n[i] - '0';
                if(num<=3){
                    sum-=num;
                    sum+=num*num;
                    }
            }
            if(sum%9==0){
                cout<<"YES"<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
        }
        }

    }
}