ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
/**
 *      codeforces: _joKer_0
 *      codechef:  joker_0000
 *      created: 24-02-2025 09:50:35
 **/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl "\n"
#ifdef DEBUG
#include "algo/debug.h"
#else
#define debug(...)
#define print(x)
#define dclear(x)
#endif
#define free                                                                   \
    freopen("input.txt", "r", stdin);                                          \
    freopen("output.txt", "w", stdout);                                        \
    freopen("error.txt", "w", stderr);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define LOG(n) 63 - __builtin_clzll(n)
const long long MAX_N = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long mod = 998244353;
const long long INF = LONG_LONG_MAX;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_multiset;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_map;
#define int long long

void solve() {
    int n = 0, m = 0, k = 0, ans = 0, cnt = 0, sum = 0;
    cin >> n;
    vector<int> v(n);
    for (auto &i : v) {
        cin >> i;
    }
    vector<int> vtemp;
    vtemp = v;
    sum = reduce(all(v), 0);
    while (vtemp.size() > 2) {
        vector<int> vNew;
        for (int i = 1; i < vtemp.size(); i++) {
            vNew.push_back(vtemp[i] - vtemp[i - 1]);
        }
        int sumNew = reduce(all(vNew), 0);
        sum = max(sum, sumNew);
        vtemp = vNew;
    }
    if (vtemp.size() == 2) {
        sum = max(sum, abs(vtemp[0] - vtemp[1]));
    }
    cout << sum;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifdef SUBLIME
    free
#endif
        int Test = 1;
    cin >> Test;
    for (int I = 1; I <= Test; I++) {
        dclear(I);
        solve();
        cout << endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ppb pop_back
void solve(){
    ll l,r;
    cin>>l>>r;
    ll a=0,b=0,c=0;
    for(ll i=29;i>=0;i--){
      if((l^r)>>i & 1){
        b|=(1<<i);
        a|=(1<<i)-1;
        break;
      }
      else{
        a|=1&(1<<i);
        b|=1&(1<<i);
      }
    }
    c=l;
    while(c==a || c==b){
      c++;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}

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

    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ppb pop_back
void solve(){
    ll l,r;
    cin>>l>>r;
    ll a=0,b=0,c=0;
    for(ll i=29;i>=0;i--){
      if((l^r)>>i & 1){
        b|=(1<<i);
        a|=(1<<i)-1;
        break;
      }
      else{
        a|=l&(1<<i);
        b|=l&(1<<i);
      }
    }
    c=l;
    while(c==a || c==b){
      c++;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}

int main(){
    ll t;
    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):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ppb pop_back
void solve(){
    ll l,r;
    cin>>l>>r;
    int m = 31 - __builtin_clz((unsigned int)l^r);
    ll candA = (1LL << m) - 1;
    ll candB = (1LL << m);
    if(candA >= l && candB <= r && candB != r){
        cout << candA << " " << candB << " " << r << "\n";
    } 
    else {
        cout << r-2 << " " << r-1 << " " << r << "\n";
    }
}

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

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

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ppb pop_back
void solve(){
    ll l,r;
    cin>>l>>r;
    int m = 31 - __builtin_clz((unsigned int)l^r);
    ll candA = (1LL << m) - 1;
    ll candB = (1LL << m);
    if(candA >= l && candB <= r && candB != r){
        cout << candA << " " << candB << " " << r << "\n";
    } 
    else {
        cout << r-2 << " " << r-1 << " " << r << "\n";
    }
}

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

    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ppb pop_back
void solve(){
    ll l,r;
    cin>>l>>r;
    ll a=0,b=0,c=0;
    for(ll i=29;i>=0;i--){
      if((l^r)>>i & 1){
        b|=(1<<i);
        a|=(1<<i)-1;
        break;
      }
      else{
        a|=1&(1<<i);
        b|=1&(1<<i);
      }
    }
    c=l;
    while(c==a || c==b){
      c++;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}

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

    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define int long long
using i64 = long long;
using i128 = __int128;
using u64 = unsigned long long;
const int mod = 998244353;
const int N = 1e6 + 9;
const int iinf = 1e9;
const i64 linf = 1e18;
vector<int> g[N];
int d[N];
void solve() {
  int n;cin>>n;
  for (int i=1;i<=n;++i) g[i].clear(),d[i]=0;
  for (int i=1;i<n;++i) {
    int x,y;cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
    d[x]++,d[y]++;
  }
  vector<int> id(n+1);
  iota(id.begin(),id.end(),0);
  sort(id.begin(),id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  int ans=1;
  ans+=(d[id[n]]-1);
  d[id[n]]=-1;
  for (const auto& y:g[id[n]]) d[y]--;
  sort(id.begin(),id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  ans+=(d[id[n]]-1);
  cout<<ans<<"\n";
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int Case = 1;
  cin >> Case;
  while (Case--) solve();
  return 0;
}


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define int long long
using i64 = long long;
using i128 = __int128;
using u64 = unsigned long long;
const int mod = 998244353;
const int N = 1e6 + 9;
const int iinf = 1e9;
const i64 linf = 1e18;
vector<int> g[N];
void solve() {
  int n;cin>>n;
  for (int i=1;i<=n;++i) g[i].clear();
  vector<int> d(n+1);
  for (int i=1;i<n;++i) {
    int x,y;cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
    d[x]++,d[y]++;
  }
  vector<int> id(n+1);
  iota(id.begin(),id.end(),0);
  sort(id.begin()+1,id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  int ans=1;
  ans+=(d[id[n]]-1);
  d[id[n]]=-1;
  for (const auto& y:g[id[n]]) d[y]--;
  sort(id.begin()+1,id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  ans+=(d[id[n]]-1);
  cout<<ans<<"\n";
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int Case = 1;
  cin >> Case;
  while (Case--) solve();
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define int long long
using i64 = long long;
using i128 = __int128;
using u64 = unsigned long long;
const int mod = 998244353;
const int N = 1e6 + 9;
const int iinf = 1e9;
const i64 linf = 1e18;
vector<int> g[N];
int d[N];
void solve() {
  int n;cin>>n;
  for (int i=1;i<=n;++i) g[i].clear(),d[i]=0;
  for (int i=1;i<n;++i) {
    int x,y;cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
    d[x]++,d[y]++;
  }
  vector<int> id(n+1);
  iota(id.begin(),id.end(),0);
  sort(id.begin(),id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  int ans=1;
  ans+=(d[id[n]]-1);
  d[id[n]]=0;
  for (const auto& y:g[id[n]]) d[y]--;
  sort(id.begin(),id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  ans+=(d[id[n]]-1);
  cout<<ans<<"\n";
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int Case = 1;
  cin >> Case;
  while (Case--) solve();
  return 0;
}


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define int long long
using i64 = long long;
using i128 = __int128;
using u64 = unsigned long long;
const int mod = 998244353;
const int N = 1e6 + 9;
const int iinf = 1e9;
const i64 linf = 1e18;
vector<int> g[N];
int d[N];
void solve() {
  int n;cin>>n;
  for (int i=1;i<=n;++i) g[i].clear(),d[i]=0;
  for (int i=1;i<n;++i) {
    int x,y;cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
    d[x]++,d[y]++;
  }
  vector<int> id(n+1);
  iota(id.begin(),id.end(),0);
  sort(id.begin(),id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  int ans=1;
  ans+=(d[id[n]]-1);
  d[id[n]]=-1;
  for (const auto& y:g[id[n]]) d[y]--;
  sort(id.begin(),id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  ans+=(d[id[n]]-1);
  cout<<ans<<"\n";
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int Case = 1;
  cin >> Case;
  while (Case--) solve();
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define int long long
using i64 = long long;
using i128 = __int128;
using u64 = unsigned long long;
const int mod = 998244353;
const int N = 1e6 + 9;
const int iinf = 1e9;
const i64 linf = 1e18;
vector<int> g[N];
void solve() {
  int n;cin>>n;
  for (int i=1;i<=n;++i) g[i].clear();
  vector<int> d(n+1);
  for (int i=1;i<n;++i) {
    int x,y;cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
    d[x]++,d[y]++;
  }
  vector<int> id(n+1);
  iota(id.begin(),id.end(),0);
  sort(id.begin()+1,id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  int ans=1;
  ans+=(d[id[n]]-1);
  d[id[n]]=-1;
  for (const auto& y:g[id[n]]) d[y]--;
  sort(id.begin()+1,id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  ans+=(d[id[n]]-1);
  cout<<ans<<"\n";
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int Case = 1;
  cin >> Case;
  while (Case--) solve();
  return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
using i64 = long long;
using i128 = __int128;
using u64 = unsigned long long;
const int mod = 998244353;
const int N = 1e6 + 9;
const int iinf = 1e9;
const i64 linf = 1e18;
vector<int> g[N];
void solve() {
  int n;cin>>n;
  for (int i=1;i<=n;++i) g[i].clear();
  vector<int> d(n+1);
  for (int i=1;i<n;++i) {
    int x,y;cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
    d[x]++,d[y]++;
  }
  multiset<int> st;
  for (int i=1;i<=n;++i) st.insert(d[i]);
  int ans=0;
  for (int i=1;i<=n;++i) {
    int mx=0;
    st.erase(st.find(d[i]));
    for (const auto& x:g[i]) {
      mx=max(mx,d[x]);
      st.erase(st.find(d[x]));
    }
    int res=mx-1;
    if (st.size() and *st.rbegin()>res) res=*st.rbegin();
    ans=max(ans,d[i]+res-1);
    // cout<<d[i]<<" "<<res<<'\n';
    st.insert(d[i]);
    for (const auto& x:g[i]) {
      st.insert(d[x]);
    }
  }
  cout<<ans<<"\n";
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int Case = 1;
  cin >> Case;
  while (Case--) solve();
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define int long long
using i64 = long long;
using i128 = __int128;
using u64 = unsigned long long;
const int mod = 998244353;
const int N = 1e6 + 9;
const int iinf = 1e9;
const i64 linf = 1e18;
vector<int> g[N];
int d[N];
void solve() {
  int n;cin>>n;
  for (int i=1;i<=n;++i) g[i].clear(),d[i]=0;
  for (int i=1;i<n;++i) {
    int x,y;cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
    d[x]++,d[y]++;
  }
  vector<int> id(n+1);
  iota(id.begin(),id.end(),0);
  sort(id.begin(),id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  int ans=1;
  ans+=(d[id[n]]-1);
  d[id[n]]=0;
  for (const auto& y:g[id[n]]) d[y]--;
  sort(id.begin(),id.end(),[&](const int& x ,const int & y) {return d[x]<d[y];});
  ans+=(d[id[n]]-1);
  cout<<ans<<"\n";
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int Case = 1;
  cin >> Case;
  while (Case--) solve();
  return 0;
}
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64

Previous submission (verdict: Runtime error on test 6):
def dp(n, i, length, total):
    if(i >= length): return False
    if int(n[i]) < 4:
        mul = int(n[i])*int(n[i]) + total - int(n[i])
        if mul % 9 == 0: return True
        else: return dp(n, i+1, length, mul) or dp(n, i+1, length, total)
    else: return dp(n, i+1, length, total) 

t = int(input())
for _ in range(t):
    n  = input()
    length = len(n)
    total = 0
    for i in range(length): total += int(n[i])
    if(total % 9 == 0): print("YES")
    else:
        if dp(n, 0, length, total): print("YES")
        else: print("No")

    

Submission (verdict: Wrong answer on test 2):
t = int(input())
for _ in range(t):
    n  = input()
    length = len(n)
    total = 0
    max_total = 0
    two = 0
    three = 0
    for i in range(length): 
        total += int(n[i])
        if(int(n[i]) == 2): two += 1
        if(int(n[i]) == 3): three += 1
        if(int(n[i]) < 4): max_total += int(n[i])*int(n[i])
        else: max_total += int(n[i])
    if(total % 9 == 0 or max_total % 9 == 0): print("YES")
    else:   
        ans = False
        for i in range(two):
            for j in range(three):
                if (total + i * 2 + j * 6) % 9 == 0:
                    ans = True
                    break
        if ans == True: print("YES")
        else: print("No")
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
t = int(input())
for _ in range(t):
    n  = input()
    length = len(n)
    total = 0
    max_total = 0
    two = 0
    three = 0
    for i in range(length): 
        total += int(n[i])
        if(int(n[i]) == 2): two += 1
        if(int(n[i]) == 3): three += 1
        if(int(n[i]) < 4): max_total += int(n[i])*int(n[i])
        else: max_total += int(n[i])
    if(total % 9 == 0 or max_total % 9 == 0): print("YES")
    else:   
        ans = False
        for i in range(two):
            for j in range(three):
                if (total + i * 2 + j * 6) % 9 == 0:
                    ans = True
                    break
        if ans == True: print("YES")
        else: print("No")
                        

Submission (verdict: Accepted):
t = int(input())
for _ in range(t):
    n  = input()
    length = len(n)
    total = 0  
    two = 0
    three = 0
    for i in range(length): 
        total += int(n[i])
        if(int(n[i]) == 2): two += 1
        if(int(n[i]) == 3): three += 1
    if(total % 9 == 0): print("YES")
    else:   
        ans = True
        for i in range(two+1):
            if ans == False: break
            for j in range(three+1):
                if (total + i * 2 + j * 6) % 9 == 0:
                    ans = False
                    break
        if ans : print("NO")
        else: print("YES")
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64


Submission (verdict: Runtime error on test 6):
def dp(n, i, length, total):
    if(i >= length): return False
    if int(n[i]) < 4:
        mul = int(n[i])*int(n[i]) + total - int(n[i])
        if mul % 9 == 0: return True
        else: return dp(n, i+1, length, mul) or dp(n, i+1, length, total)
    else: return dp(n, i+1, length, total) 

t = int(input())
for _ in range(t):
    n  = input()
    length = len(n)
    total = 0
    for i in range(length): total += int(n[i])
    if(total % 9 == 0): print("YES")
    else:
        if dp(n, 0, length, total): print("YES")
        else: print("No")
Problem: 2050D - Digital string maximization
Language: PyPy 3-64


Submission (verdict: Time limit exceeded on test 5):
t = int(input())
for _ in range(t):
    num = input()
    n = len(num)
    ans = ""
    for j in range(n-1):
        max_el = j
        for i in range(j+1, n):
            # print(num)
            # print(f"i: {i}, j: {j}")
            if(int(num[i]) == 0): continue
            if((int(num[i]) - (i - j)) > int(num[max_el]) - (max_el - j)):
                max_el = i
        num = num[:j]+str(int(num[max_el]) - (max_el - j))+num[j:]
        # print(f"num: {num}")
        num = num[:max_el+1] + num[max_el+2:]
    print(num)

        #     if int(num[i]) - j + i > int(num[max_el]):
        #         max_el = i
        # # ans += str(int(num[max_el]) - j - max_el)
        # num = num[:j] + str(int(num[max_el]) - j - max_el) + num[j:]
        # num = num[:max_el+1] + num[max_el+2: ]
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 5):
t = int(input())
for _ in range(t):
    num = input()
    n = len(num)
    ans = ""
    for j in range(n-1):
        max_el = j
        for i in range(j+1, n):
            # print(num)
            # print(f"i: {i}, j: {j}")
            if(int(num[i]) == 0): continue
            if((int(num[i]) - (i - j)) > int(num[max_el]) - (max_el - j)):
                max_el = i
        num = num[:j]+str(int(num[max_el]) - (max_el - j))+num[j:]
        # print(f"num: {num}")
        num = num[:max_el+1] + num[max_el+2:]
    print(num)

        #     if int(num[i]) - j + i > int(num[max_el]):
        #         max_el = i
        # # ans += str(int(num[max_el]) - j - max_el)
        # num = num[:j] + str(int(num[max_el]) - j - max_el) + num[j:]
        # num = num[:max_el+1] + num[max_el+2: ]

Submission (verdict: Time limit exceeded on test 5):
t = int(input())
for _ in range(t):
    num = input()
    n = len(num)
    ans = ""
    for j in range(n-1):
        max_el = j
        for i in range(j+1, n):
            # print(num)
            # print(f"i: {i}, j: {j}")
            if(int(num[i]) == 0): continue
            if((int(num[i]) - (i - j)) > int(num[max_el]) - (max_el - j)):
                max_el = i
        if(max_el != j):
            num = num[:j]+str(int(num[max_el]) - (max_el - j))+num[j:]
            # print(f"num: {num}")
            num = num[:max_el+1] + num[max_el+2:]
    print(num)
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 5):
t = int(input())
for _ in range(t):
    num = input()
    n = len(num)
    ans = ""
    for j in range(n-1):
        max_el = j
        for i in range(j+1, n):
            # print(num)
            # print(f"i: {i}, j: {j}")
            if(int(num[i]) == 0): continue
            if((int(num[i]) - (i - j)) > int(num[max_el]) - (max_el - j)):
                max_el = i
        if(max_el != j):
            num = num[:j]+str(int(num[max_el]) - (max_el - j))+num[j:]
            # print(f"num: {num}")
            num = num[:max_el+1] + num[max_el+2:]
    print(num)

Submission (verdict: Accepted):
t = int(input())
for _ in range(t):
    num = list(input())  # Convert string to list for mutable operations
    n = len(num)
    for i in range(n - 1):
        j = i + 1
        while j < n and (int(num[j]) - 1 > int(num[j - 1])):
            temp = str(int(num[j]) - 1)
            num[j] = num[j - 1]
            num[j - 1] = temp
            j -= 1  # Move backward to recheck the order
            if j <= 0:  # Prevent going out of bounds
                break
    print(''.join(num))  # Convert list back to string for output
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
int calculateX(int m, int n) {
    
    int k = static_cast<int>(ceil(static_cast<double>(m) / n));
    
    int x = (k * n) - m;
    
    return x;
}
int main() {
    int t;
    cin>>t;
    vector<string>v;
    while(t--){
        long long int number;
        int sum = 0;
    
    cin >> number;
    int m=0,n=0;
    while (number > 0) {
        if(number%10==2){
            m++;
        }
        if(number%10==3){
            n++;
        }
        sum += number % 10; 
        number /= 10;       
    }
    
    int remi=sum%9;
    if(m==0 && n==0){
        if(remi==0){
            v.push_back("YES");
        }
        else{
            v.push_back("NO");
        }

    } 
    else{
        int rem=calculateX(remi,9);
        int check=0;
        for(int i=0;i<=m;i++){
            for(int j=0;j<=n;j++){
                if((sum+2*i+6*j) % 9 ==0){
                    check=1;
                    break;
                }

            }
        }
        if(check){
            v.push_back("YES");
        }
        else{
            v.push_back("NO");
        }
  
   

    }
    
    

    }
    
    for(auto i:v){
        cout<<i<<endl;
    }
    return 0;
}


Submission (verdict: Compilation error):
def solve():
    s = [int(x) for x in list(input())]

    sm = sum(s)
    twos = s.count(2)
    threes = s.count(3)

    for i in range(min(10, twos + 1)):
        for j in range(min(10, threes + 1)):
            if (sm + i * 2 + j * 6) % 9 == 0:
                print('YES')
                return
    print('NO')


t = int(input())
for _ in range(t):
    solve()
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
def solve():
    s = [int(x) for x in list(input())]

    sm = sum(s)
    twos = s.count(2)
    threes = s.count(3)

    for i in range(min(10, twos + 1)):
        for j in range(min(10, threes + 1)):
            if (sm + i * 2 + j * 6) % 9 == 0:
                print('YES')
                return
    print('NO')


t = int(input())
for _ in range(t):
    solve()

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <string>
using namespace std;

void solve() {
    string input;
    cin >> input;

    vector<int> s;
    for (char c : input) {
        s.push_back(c - '0'); // Convert char to int and store in vector
    }

    int sm = 0;
    int twos = 0, threes = 0;

    for (int digit : s) {
        sm += digit;
        if (digit == 2) twos++;
        if (digit == 3) threes++;
    }

    for (int i = 0; i <= min(10, twos); i++) {
        for (int j = 0; j <= min(10, threes); j++) {
            if ((sm + i * 2 + j * 6) % 9 == 0) {
                cout << "YES" << endl;
                return;
            }
        }
    }

    cout << "NO" << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
int calculateX(int m, int n) {
    
    int k = static_cast<int>(ceil(static_cast<double>(m) / n));
    
    int x = (k * n) - m;
    
    return x;
}
int main() {
    int t;
    cin>>t;
    vector<string>v;
    while(t--){
        long long int number;
        int sum = 0;
    
    cin >> number;
    int m=0,n=0;
    while (number > 0) {
        if(number%10==2){
            m++;
        }
        if(number%10==3){
            n++;
        }
        sum += number % 10; 
        number /= 10;       
    }
    
    int remi=sum%9;
    if(m==0 && n==0){
        if(remi==0){
            v.push_back("YES");
        }
        else{
            v.push_back("NO");
        }

    } 
    else{
        int rem=calculateX(remi,9);
        int check=0;
        for(int i=0;i<=m;i++){
            for(int j=0;j<=n;j++){
                if((sum+2*i+6*j) % 9 ==0){
                    check=1;
                    break;
                }

            }
        }
        if(check){
            v.push_back("YES");
        }
        else{
            v.push_back("NO");
        }
  
   

    }
    
    

    }
    
    for(auto i:v){
        cout<<i<<endl;
    }
    return 0;
}