ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define f(n) for(int i=0;i<n;i++)
#define in(n) long long n; cin>>n;

void solve() {
    in(n);
    long long sum = 0;
    int c2 = 0, c3 = 0;
    // cout<<n<<" ";
    // Calculate the sum of digits and count of 2's and 3's
    while (n > 0) {
        int digit = n % 10;
        sum += digit;
        if (digit == 2) c2++;
        if (digit == 3) c3++;
        n /= 10;
    }
    
    // cout<<sum<<" ";
    for (int i = 0; i <=min(8,c2); i++) {
        for (int j =0; j <= min(8,c3); j++) {
            if ((sum + i * 2 + j * 6) % 9 == 0) {
                cout<< "YES\n";
                return;
            }
        }
    }
    
    cout << "NO\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

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


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define f(n) for(int i=0;i<n;i++)
#define in(n) long long n; cin>>n;

void solve() {
    in(n);
    long long sum = 0;
    int c2 = 0, c3 = 0;
    // cout<<n<<" ";
    // Calculate the sum of digits and count of 2's and 3's
    while (n > 0) {
        int digit = n % 10;
        sum += digit;
        if (digit == 2) c2++;
        if (digit == 3) c3++;
        n /= 10;
    }
    
    // cout<<sum<<" ";
    for (int i = 0; i <=min(10,c2); i++) {
        for (int j =0; j <= min(10,c3); j++) {
            if ((sum + i * 2 + j * 6) % 9 == 0) {
                cout<< "YES\n";
                return;
            }
        }
    }
    
    cout << "NO\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// Name-Anshu Raj Jaiswal
// Scholar id-2212172
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ff first
#define ss second
#define mpq priority_queue<ll,vector<ll>,greater<ll>>
#define mpqp priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> 
#define Mpq priority_queue<ll>
#define Mpqp priority_queue<pair<ll,ll>>
#define all(x) (x).begin(), (x).end()
const ll MOD=998244353;
const ll N=200000;
ll ceil(ll a,ll b){return (a+b-1)/b;}
void solve()
{         
 ll n;
 cin>>n;
 vector<ll>temp(n+1,0);
 vector<ll>temp2(n+1,0);
 vector<pair<ll,ll>>arr(n-1);
 for(ll i=0;i<n-1;i++)
 {
  ll u,v;
  cin>>u>>v;
  temp[u]++;temp[v]++;
  arr[i]={u,v};
 } 
 ll ans=0;
 ll in=-1;
 for(ll i=1;i<=n;i++)
 {
   if(temp[i]>ans)
   {
    ans=temp[i];
    in=i;
   }
 }
 ans--;
 for(ll i=0;i<n-1;i++) 
 {
  ll u=arr[i].ff,v=arr[i].ss;
  if(u==in || v==in)
  continue;
  temp2[u]++;temp2[v]++;
 }
 ll pi=0;
 for(ll i=1;i<=n;i++)
 pi=max(pi,temp2[i]); 
 ans+=pi;
 cout<<ans<<endl;
} 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  ll t;
  cin>>t;
  while(t--)
  {        
	  solve();
  }
  return 0;
} 

Submission (verdict: Accepted):
// Name-Anshu Raj Jaiswal
// Scholar id-2212172
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ff first
#define ss second
#define mpq priority_queue<ll,vector<ll>,greater<ll>>
#define mpqp priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> 
#define Mpq priority_queue<ll>
#define Mpqp priority_queue<pair<ll,ll>>
#define all(x) (x).begin(), (x).end()
const ll MOD=998244353;
const ll N=200000;
ll ceil(ll a,ll b){return (a+b-1)/b;}
void solve()
{         
 ll n;
 cin>>n;
 vector<ll>temp(n+1,0);
 vector<ll>temp2(n+1,0);
 vector<pair<ll,ll>>arr(n-1);
 map<ll,ll>my;
 for(ll i=0;i<n-1;i++)
 {
  ll u,v;
  cin>>u>>v;
  temp[u]++;temp[v]++;
  arr[i]={u,v};
 } 
 ll ans=0;
 ll in=-1;
 for(ll i=1;i<=n;i++)
 {
   if(temp[i]>ans)
   {
    ans=temp[i];
    in=i;
   }
   my[temp[i]]++;
 }     
 if(my[ans]>2)
 {
  cout<<2*ans-1<<endl;
  return;
 }  
 ans--;
 for(ll i=0;i<n-1;i++) 
 {      
  ll u=arr[i].ff,v=arr[i].ss;       
  if(u==in || v==in)              
  continue;
  temp2[u]++;temp2[v]++;
 }
 ll pi=0;
 for(ll i=1;i<=n;i++)
 pi=max(pi,temp2[i]); 
 ans+=pi;
 cout<<ans<<endl;
} 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  ll t;
  cin>>t;
  while(t--)
  {        
	  solve();
  }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// Name-Anshu Raj Jaiswal
// Scholar id-2212172
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ff first
#define ss second
#define mpq priority_queue<ll,vector<ll>,greater<ll>>
#define mpqp priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> 
#define Mpq priority_queue<ll>
#define Mpqp priority_queue<pair<ll,ll>>
#define all(x) (x).begin(), (x).end()
const ll MOD=998244353;
const ll N=200000;
ll ceil(ll a,ll b){return (a+b-1)/b;} 
ll pi=0; 
void dfs(ll node,vector<ll>&vis,vector<ll>&temp2,vector<vector<ll>>&adj)
{
  vis[node]=1;
  for(auto it:adj[node])
  {
    if(!vis[it])
    {
      temp2[node]++;
      temp2[it]++;
      dfs(it,vis,temp2,adj);
    }
  }
  return;
}
void solve()
{         
 ll n;
 cin>>n;
 vector<vector<ll>>adj(n+1);
 vector<ll>temp(n+1,0);
 vector<pair<ll,ll>>arr(n-1);
 for(ll i=0;i<n-1;i++)
 {
  ll u,v;
  cin>>u>>v;
  temp[u]++;temp[v]++;
  arr[i]={u,v};
 } 
 ll ans=0;
 ll in=-1;
 for(ll i=0;i<=n;i++)
 {
   if(temp[i]>ans)
   {
    ans=temp[i];
    in=i;
   }
 }
 ans--;
 for(ll i=0;i<n-1;i++)
 {
  ll u=arr[i].ff,v=arr[i].ss;
  if(u==in || v==in)
  continue;
  adj[u].pb(v);adj[v].pb(u);
 }
 vector<ll>vis(n+1,0);
 vector<ll>temp2(n+1,0);
 for(ll i=0;i<=n;i++)
 {
   if(!vis[i])
   {
      dfs(i,vis,temp2,adj);
   }
 }
 ll pi=0;
 for(ll i=0;i<=n;i++)
 {
   pi=max(pi,temp2[i]);
 }
 ans+=pi;
 cout<<ans<<endl;
} 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  ll t;
  cin>>t;
  while(t--)
  {        
	  solve();
  }
  return 0;
} 

Submission (verdict: Wrong answer on test 2):
// Name-Anshu Raj Jaiswal
// Scholar id-2212172
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ff first
#define ss second
#define mpq priority_queue<ll,vector<ll>,greater<ll>>
#define mpqp priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> 
#define Mpq priority_queue<ll>
#define Mpqp priority_queue<pair<ll,ll>>
#define all(x) (x).begin(), (x).end()
const ll MOD=998244353;
const ll N=200000;
ll ceil(ll a,ll b){return (a+b-1)/b;}
void solve()
{         
 ll n;
 cin>>n;
 vector<ll>temp(n+1,0);
 vector<ll>temp2(n+1,0);
 vector<pair<ll,ll>>arr(n-1);
 for(ll i=0;i<n-1;i++)
 {
  ll u,v;
  cin>>u>>v;
  temp[u]++;temp[v]++;
  arr[i]={u,v};
 } 
 ll ans=0;
 ll in=-1;
 for(ll i=1;i<=n;i++)
 {
   if(temp[i]>ans)
   {
    ans=temp[i];
    in=i;
   }
 }
 ans--;
 for(ll i=0;i<n-1;i++) 
 {
  ll u=arr[i].ff,v=arr[i].ss;
  if(u==in || v==in)
  continue;
  temp2[u]++;temp2[v]++;
 }
 ll pi=0;
 for(ll i=1;i<=n;i++)
 pi=max(pi,temp2[i]); 
 ans+=pi;
 cout<<ans<<endl;
} 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  ll t;
  cin>>t;
  while(t--)
  {        
	  solve();
  }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
// Name-Anshu Raj Jaiswal
// Scholar id-2212172
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ff first
#define ss second
#define mpq priority_queue<ll,vector<ll>,greater<ll>>
#define mpqp priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> 
#define Mpq priority_queue<ll>
#define Mpqp priority_queue<pair<ll,ll>>
#define all(x) (x).begin(), (x).end()
const ll MOD=998244353;
const ll N=200000;
ll ceil(ll a,ll b){return (a+b-1)/b;} 
ll pi=0; 
void dfs(ll node,vector<ll>&vis,vector<ll>&temp2,vector<vector<ll>>&adj)
{
  vis[node]=1;
  for(auto it:adj[node])
  {
    if(!vis[it])
    {
      temp2[node]++;
      temp2[it]++;
      dfs(it,vis,temp2,adj);
    }
  }
  return;
}
void solve()
{         
 ll n;
 cin>>n;
 vector<vector<ll>>adj(n+1);
 vector<ll>temp(n+1,0);
 vector<pair<ll,ll>>arr(n-1);
 for(ll i=0;i<n-1;i++)
 {
  ll u,v;
  cin>>u>>v;
  temp[u]++;temp[v]++;
  arr[i]={u,v};
 } 
 ll ans=0;
 ll in=-1;
 for(int i=0;i<n;i++)
 {
   if(temp[i]>ans)
   {
    ans=temp[i];
    in=i;
   }
 }
 ans--;
 for(ll i=0;i<n-1;i++)
 {
  ll u=arr[i].ff,v=arr[i].ss;
  if(u==in || v==in)continue;
  adj[u].pb(v);adj[v].pb(u);
 }
 vector<ll>vis(n+1,0);
 vector<ll>temp2(n+1,0);
 for(ll i=0;i<n;i++)
 {
   if(!vis[i])
   {
      dfs(i,vis,temp2,adj);
   }
 }
 ll pi=0;
 for(ll i=0;i<n;i++)
 {
   pi=max(pi,temp2[i]);
 }
 ans+=pi;
 cout<<ans<<endl;
} 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  ll t;
  cin>>t;
  while(t--)
  {        
	  solve();
  }
  return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll long long

void solve() {

    ll n,l,r;

    cin >> n >> l >> r;

    vector<ll> arr(n+1);

    for (int i=1; i<=n; i++) cin >> arr[i];

    priority_queue<ll> mxhp;

    priority_queue<ll, vector<ll>, greater<ll>> minp;

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

        if (i>=l && i<=r) {

            mxhp.push(arr[i]);

        }

        else {

            minp.push(arr[i]);

        }

    }

    ll elements = r-l+1;

    ll sum = 0;

    while (!mxhp.empty() && !minp.empty() && elements>0) {

        auto maxtop = mxhp.top();

        auto mintop = minp.top();

        if (mintop >= maxtop) {

            break;

        }

        sum += mintop;

        mxhp.pop();

        minp.pop();

        elements--;

    }

    while (!mxhp.empty() && elements>0) {

        sum += mxhp.top();

        mxhp.pop();

    }

    cout << sum << endl;

}

int main() {

    ll t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}

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

using namespace std;

#define ll long long

void solve() {

    ll n,l,r;

    cin >> n >> l >> r;

    vector<ll> arr(n+1);

    for (int i=1; i<=n; i++) cin >> arr[i];

    priority_queue<ll> mxhp;

    priority_queue<ll, vector<ll>, greater<ll>> minp;

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

        minp.push(arr[i]);

    }

    if (minp.empty()) {

        for (ll i=r+1; i<=n; i++) minp.push(arr[i]);

    }

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

        mxhp.push(arr[i]);

    }

    ll elements = r-l+1;

    ll sum = 0;

    while (!mxhp.empty() && !minp.empty() && elements>0) {

        auto maxtop = mxhp.top();

        auto mintop = minp.top();

        if (mintop >= maxtop) {

            break;

        }

        sum += mintop;

        mxhp.pop();

        minp.pop();

        elements--;

    }

    while (!mxhp.empty() && elements>0) {

        sum += mxhp.top();

        mxhp.pop();

    }

    cout << sum << endl;

}

int main() {

    ll t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

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

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

using namespace std;

#define ll long long

void solve() {

    ll n,l,r;

    cin >> n >> l >> r;

    vector<ll> arr(n+1);

    for (int i=1; i<=n; i++) cin >> arr[i];

    priority_queue<ll> mxhp;

    priority_queue<ll, vector<ll>, greater<ll>> minp;

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

        minp.push(arr[i]);

    }

    if (minp.empty()) {

        for (ll i=r+1; i<=n; i++) minp.push(arr[i]);

    }

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

        mxhp.push(arr[i]);

    }

    ll elements = r-l+1;

    ll sum = 0;

    while (!mxhp.empty() && !minp.empty() && elements>0) {

        auto maxtop = mxhp.top();

        auto mintop = minp.top();

        if (mintop >= maxtop) {

            break;

        }

        sum += mintop;

        mxhp.pop();

        minp.pop();

        elements--;

    }

    while (!mxhp.empty() && elements>0) {

        sum += mxhp.top();

        mxhp.pop();

    }

    cout << sum << 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

void solve() {

    ll n,l,r;

    cin >> n >> l >> r;

    vector<ll> arr(n+1);

    ll sum = 0;

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

        cin >> arr[i];

    }

    vector<ll> before, after;

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

        before.push_back(arr[i]);

    }

    for (int i=l; i<=n; i++) after.push_back(arr[i]);

    ll ans = LLONG_MAX, size = r-l+1;

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

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

    ll sum1 = 0;

    for (ll i=0; i<size; i++) sum1+=before[i];

    ans = min(ans,sum1);

    sum1 = 0;

    for (ll i=0; i<size; i++) sum1+=after[i];

    ans = min(ans, sum1);

    cout << ans << endl;

}

int main() {

    ll t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

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


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

using namespace std;

#define ll long long

void solve() {

    ll n,l,r;

    cin >> n >> l >> r;

    vector<ll> arr(n+1);

    for (int i=1; i<=n; i++) cin >> arr[i];

    priority_queue<ll> mxhp;

    priority_queue<ll, vector<ll>, greater<ll>> minp;

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

        if (i>=l && i<=r) {

            mxhp.push(arr[i]);

        }

        else {

            minp.push(arr[i]);

        }

    }

    ll elements = r-l+1;

    ll sum = 0;

    while (!mxhp.empty() && !minp.empty() && elements>0) {

        auto maxtop = mxhp.top();

        auto mintop = minp.top();

        if (mintop >= maxtop) {

            break;

        }

        sum += mintop;

        mxhp.pop();

        minp.pop();

        elements--;

    }

    while (!mxhp.empty() && elements>0) {

        sum += mxhp.top();

        mxhp.pop();

    }

    cout << sum << endl;

}

int main() {

    ll t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main() {
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>adj[n+1];
       vector<int>size(n+1,0);
       for(int i=0;i<n-1;i++){
           int u,v;
           cin>>u>>v;
           adj[u].push_back(v);
           adj[v].push_back(u);
           size[u]++;
           size[v]++;
       }
      int maxi=0;
      int node=-1;
      int ans=0;
      for(int i=1;i<=n;i++){
          if(maxi<size[i]){
              maxi=size[i];
              node=i;
          }
      }
      ans=maxi;
      
      for(auto it:adj[node]){
          size[it]--;
      }
     
     maxi=0;
      for(int i=1;i<=n;i++){
          if(maxi<size[i] && i!=node){
              maxi=size[i];
              
          }
      }
      ans+=maxi;
      cout<<ans-1<<endl;
       
   }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main() {
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>adj[n+1];
       vector<int>size(n+1,0);
       for(int i=0;i<n-1;i++){
           int u,v;
           cin>>u>>v;
           adj[u].push_back(v);
           adj[v].push_back(u);
           size[u]++;
           size[v]++;
       }
      int maxi=0;
      int node=-1;
      int ans=0;
      for(int i=1;i<=n;i++){
          if(maxi<size[i]){
              maxi=size[i];
              node=i;
          }
      }
      ans=maxi;
      
      for(auto it:adj[node]){
          size[it]--;
      }
     
     maxi=0;
      for(int i=1;i<=n;i++){
          if(maxi<size[i] && i!=node){
              maxi=size[i];
              
          }
      }
      ans+=maxi;
      cout<<ans-1<<endl;
       
   }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main() {
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>adj[n+1];
       vector<int>size(n+1,0);
       for(int i=0;i<n-1;i++){
           int u,v;
           cin>>u>>v;
           adj[u].push_back(v);
           adj[v].push_back(u);
           size[u]++;
           size[v]++;
       }
      int maxi=0;
      int node=-1;
      int ans=0;
      for(int i=1;i<=n;i++){
          if(maxi<size[i]){
              maxi=size[i];
              node=i;
          }
      }
      ans=maxi;
      if(ans==2 && n>=5)
      cout<<3<<endl;
      else{
      
      for(auto it:adj[node]){
          size[it]--;
      }
     
     maxi=0;
      for(int i=1;i<=n;i++){
          if(maxi<size[i] && i!=node){
              maxi=size[i];
              
          } 
      }
      ans+=maxi;
      cout<<ans-1<<endl;
      }
       
   }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main() {
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>adj[n+1];
       vector<int>size(n+1,0);
       for(int i=0;i<n-1;i++){
           int u,v;
           cin>>u>>v;
           adj[u].push_back(v);
           adj[v].push_back(u);
           size[u]++;
           size[v]++;
       }
      int maxi=0;
      int node=-1;
      int ans=0;
      for(int i=1;i<=n;i++){
          if(maxi<size[i]){
              maxi=size[i];
              node=i;
          }
      }
      ans=maxi;
      if(ans==2 && n>=5)
      cout<<3<<endl;
      else{
      
      for(auto it:adj[node]){
          size[it]--;
      }
     
     maxi=0;
      for(int i=1;i<=n;i++){
          if(maxi<size[i] && i!=node){
              maxi=size[i];
              
          } 
      }
      ans+=maxi;
      cout<<ans-1<<endl;
      }
       
   }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main() {
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       
       vector<int>size(n+1,0);
       set<pair<int,int>>st;
       
       for(int i=0;i<n-1;i++){
           int u,v1;
           cin>>u>>v1;
           st.insert({u,v1});
           st.insert({v1,u});
           size[u]++;
           size[v1]++;
       }
       vector<pair<int,int>>v;
       for(int i=1;i<=n;i++){
           v.push_back({size[i],i});
       }
       sort(v.begin(),v.end(),greater<pair<int,int>>());
       
       int maxi=0;
       for(auto it:st){
           maxi=max(size[it.first]+size[it.second]-2,maxi);
       }
       
       for(int i=0;i<v.size();i++){
           for(int j=i+1;j<v.size();j++){
               if(st.find({v[i].second,v[j].second})==st.end()){
                   maxi=max(maxi,v[i].first+v[j].first-1);
                   break;
               }
           }
       }
       cout<<maxi<<endl;
     
       
   }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

using namespace std;

#define int long long

 

signed main() {

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        int n = s.size();

        int sum = 0;

        int two,three;

        two = three = 0;

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

            sum+=s[i]-'0';

            if(s[i]-'0' == 2) two++;

            if(s[i]-'0' == 3) three++;

        }

        int flag=0;

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

            for(int j=0;j<=three;j++){

                if((sum+i*2+j*6)%9==0){

                    flag++;

                    break;

                }

            }

        }

        if(flag) cout<<"YES\n";

        else{

            cout<<"NO\n";

        }      

        }

        

    

    return 0;

}

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

using namespace std;

#define int long long

 

signed main() {

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        int n = s.size();

        int sum = 0;

        int two,three;

        two = three = 0;

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

            sum+=s[i]-'0';

            if(s[i]-'0' == 2) two++;

            if(s[i]-'0' == 3) three++;

        }

        int flag=0;

        int a =10;

        two = min(a,two);

        three = min(a,three);

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

            for(int j=0;j<=three;j++){

                if((sum+i*2+j*6)%9==0){

                    flag++;

                    break;

                }

            }

        }

        if(flag) cout<<"YES\n";

        else{

            cout<<"NO\n";

        }      

        }

        

    

    return 0;

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

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

using namespace std;

#define int long long

 

signed main() {

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        int n = s.size();

        int sum = 0;

        int two,three;

        two = three = 0;

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

            sum+=s[i]-'0';

            if(s[i]-'0' == 2) two++;

            if(s[i]-'0' == 3) three++;

        }

        if(sum%9==0) cout<<"YES\n";

        else{

            int d = 9 - sum%9;

            if(d%2!=0) d+=9;

            // cout<<d<<" "<<two*2 + three*6<<endl;

            if(two*2 + three*6 >=d  ){

                d = d - two*2;

                if(d>=0 &&d%6!=0 )

                cout<<"NO\n";

                else if(d>=0 && d%6==0 && d/6 < three){

                    cout<<"NO\n";

                }

                else

                cout<<"YES\n";

            }

            else{

                cout<<"NO\n";

            }

            

        }

        

    }

    return 0;

}

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

using namespace std;

#define int long long

 

signed main() {

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        int n = s.size();

        int sum = 0;

        int two,three;

        two = three = 0;

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

            sum+=s[i]-'0';

            if(s[i]-'0' == 2) two++;

            if(s[i]-'0' == 3) three++;

        }

        if(sum%9==0) cout<<"YES\n";

        else{

            int d = 9 - sum%9;

            if(d%2!=0) d+=9;

            // cout<<d<<" "<<two*2 + three*6<<endl;

            if(two*2 + three*6 >=d  ){

                d = d - two*2;

                if(d>0 &&d%6!=0 )

                cout<<"NO\n";

                else if(d>0 && d%6==0 && d/6 < three){

                    cout<<"NO\n";

                }

                else

                cout<<"YES\n";

            }

            else{

                cout<<"NO\n";

            }

            

        }

        

    }

    return 0;

}