ShaysXIA/CodeInsightBench huggingface dataset:
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;
 
/* clang-format off */
 
/* TYPES  */
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define sll set<long long>
#define sc set<char>
#define ff first
#define ss second
 
/* FUNCTIONS */
#define f(i,s,e) for(long long int i=s;i<e;i++)
#define cf(i,s,e) for(long long int i=s;i<=e;i++)
#define rf(i,e,s) for(long long int i=e-1;i>=s;i--)
#define pb push_back
#define eb emplace_back
 
/* PRINTS */
template <class T>
void print_v(vector<T> &v) { cout<<  "{"; for (auto x : v) cout<<  x << ","; cout<<  "\b}"; }
 
/* UTILS */
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define read(type) readInt<type>()
ll min(ll a,int b) { if (a<b) return a; return b; }
ll min(int a,ll b) { if (a<b) return a; return b; }
ll max(ll a,int b) { if (a>b) return a; return b; }
ll max(int a,ll b) { if (a>b) return a; return b; }
ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }
string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }
bool prime(ll a) { if (a==1) return 0; for (int i=2;i<=round(sqrt(a));++i) if (a%i==0) return 0; return 1; }
void yes() { cout<<"YES\n"; }
void no() { cout<<"NO\n"; }
 
/*  All Required define Pre-Processors and typedef Constants */
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
 
/* clang-format on */
void solve(){
    ll n;
    cin>>n;
    vector<set<ll>> graph(n);
    f(i,0,n-1){
        ll x,y;
        cin>>x>>y;
        graph[x-1].insert(y-1);
        graph[y-1].insert(x-1);
    }
    ll maxi=0,node=0;
    f(i,0,n){
        if(graph[i].size()>maxi){
            maxi=graph[i].size();
            node=i;
        }
    }
    ll ans=maxi,maxi2=0;
    f(i,0,n){
        if(i!=node&&graph[i].find(node)!=graph[i].end()){
            graph[i].erase(node);
            maxi2=max(maxi2,graph[i].size());
        }
    }
    if(maxi2==0){
        cout<<ans-1<<endl;
        return;
    }
    cout<<ans+maxi2<<endl;
}
 
/* Main()  function */
int main()
{
 
    #ifdef LOCAL
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

map<pair<int,int>,int> mp;
// k=0,不翻转取差值；k = 1，翻转并取差值
vector<int> replace_Seq(vector<int> arr,int k){
    vector<int> vector1;
    if(k == 0){
        for (int i = 0;i < arr.size() - 1;i ++) {
            vector1.push_back(arr[i + 1] - arr[i]);
        }
    }
    else {
        for (auto it = arr.rbegin(); it != arr.rend() - 1; ++it) {
            vector1.push_back(*(it + 1) - *it);
        }
    }
    return vector1;
}

int dfs(vector<int> arr,int zero,int one){
    if(arr.size() == 1){
        mp.insert({{zero,one},arr[0]});
        return arr[0];
    }
    int a1 = mp.count({zero + 1,one}) ? mp[{zero + 1,one}] : dfs(replace_Seq(arr,0),zero + 1,one);
    int a2 = mp.count({zero ,one + 1}) ? mp[{zero,one + 1}] : dfs(replace_Seq(arr,1), zero,one + 1) ;

    return max(a1,a2);
}

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t;cin >> t;
    while (t --) {
        int n, add = 0;
        cin >> n;
        vector<int> arr(n, 0);
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
            add += arr[i];
        }
        cout << max(add, dfs(arr,0,0)) << '\n';
        mp.clear();
    }
    return 0;
}


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


signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t;cin >> t;
    while (t --) {
        int n;
        cin >> n;
        vector<int> arr(n + 1, 0);
        for (int i = 1; i <= n; ++i) {
            cin >> arr[i];
        }
        int ans = -1e18;

        for (int i = 1; i <= n; i++){
            int sum = 0;
            for (int i = 1; i <= arr.size() - 1; i++) sum = (sum + arr[i]) ;
            if (i == 1) ans = max(ans, sum);
            else ans = max(ans, max(sum, ( - sum) ));
            for (int i = 1; i < arr.size() - 1; i++)
                arr[i] = (arr[i + 1] - arr[i]) ;
            arr.pop_back();
        }

        cout << ans << '\n';

    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

// k=0,不翻转取差值；k = 1，翻转并取差值
vector<int> replace_Seq(vector<int> arr,int k){
    vector<int> vector1;
    if(k == 0){
        for (int i = 0;i < arr.size() - 1;i ++) {
            vector1.push_back(arr[i + 1] - arr[i]);
        }
    }
    else {
        for (auto it = arr.rbegin(); it != arr.rend() - 1; ++it) {
            vector1.push_back(*(it + 1) - *it);
        }
    }
    return vector1;
}



signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t;cin >> t;
    while (t --) {
        int n, add = 0;
        cin >> n;
        vector<int> arr(n, 0);
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
            add += arr[i];
        }
        vector<int> vector0 = arr;
        int vl = vector0.size();
        for (int i = 0; i < vl - 1; ++i) {
            vector0 = replace_Seq(vector0, 1);
        }
        cout << max(add, vector0[0]) << '\n';
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
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


// k=0,不翻转取差值；k = 1，翻转并取差值
vector<int> replace_Seq(vector<int> arr,int k){
    vector<int> vector1;
    if(k == 0){
        for (int i = 0;i < arr.size() - 1;i ++) {
            vector1.push_back(arr[i + 1] - arr[i]);
        }
    }
    else {
        for (auto it = arr.rbegin(); it != arr.rend() - 1; ++it) {
            vector1.push_back(*(it + 1) - *it);
        }
    }
    return vector1;
}

int dfs(vector<int> arr,map<pair<int,int>,int>& mp,int zero,int one){
    if(arr.size() == 1){
        mp.insert({{zero,one},arr[0]});
        return arr[0];
    }
    // cout << one << ' ' << zero << '\n';

    int a1 = mp.count({zero + 1,one}) ?mp[{zero + 1,one}] : dfs(replace_Seq(arr,0),mp,zero ++,one);
    int a2 = mp.count({zero ,one + 1}) ?mp[{zero,one + 1}] : dfs(replace_Seq(arr,1),mp, zero, one ++);
    // cout << a1 << ' ' << a2 << '\n';

    return max(a1,a2);
}

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t;cin >> t;
    while (t --) {
        int n, add = 0;
        map<pair<int,int>,int> mp;
        cin >> n;
        vector<int> arr(n, 0);
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
            add += arr[i];
        }
        cout << max(add, dfs(arr,mp,0,0)) << '\n';
    }
    return 0;
}


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

map<pair<int,int>,int> mp;
// k=0,不翻转取差值；k = 1，翻转并取差值
vector<int> replace_Seq(vector<int> arr,int k){
    vector<int> vector1;
    if(k == 0){
        for (int i = 0;i < arr.size() - 1;i ++) {
            vector1.push_back(arr[i + 1] - arr[i]);
        }
    }
    else {
        for (auto it = arr.rbegin(); it != arr.rend() - 1; ++it) {
            vector1.push_back(*(it + 1) - *it);
        }
    }
    return vector1;
}

int dfs(vector<int> arr,int zero,int one){
    if(arr.size() == 1){
        mp.insert({{zero,one},arr[0]});
        return arr[0];
    }
    int a1 = mp.count({zero + 1,one}) ? mp[{zero + 1,one}] : dfs(replace_Seq(arr,0),zero + 1,one);
    int a2 = mp.count({zero ,one + 1}) ? mp[{zero,one + 1}] : dfs(replace_Seq(arr,1), zero,one + 1) ;

    return max(a1,a2);
}

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t;cin >> t;
    while (t --) {
        int n, add = 0;
        cin >> n;
        vector<int> arr(n, 0);
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
            add += arr[i];
        }
        cout << max(add, dfs(arr,0,0)) << '\n';
        mp.clear();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
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

// k=0,不翻转取差值；k = 1，翻转并取差值
vector<int> replace_Seq(vector<int> arr,int k){
    vector<int> vector1;
    if(k == 0){
        for (int i = 0;i < arr.size() - 1;i ++) {
            vector1.push_back(arr[i + 1] - arr[i]);
        }
    }
    else {
        for (auto it = arr.rbegin(); it != arr.rend() - 1; ++it) {
            vector1.push_back(*(it + 1) - *it);
        }
    }
    return vector1;
}



signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t;cin >> t;
    while (t --) {
        int n, add = 0;
        cin >> n;
        vector<int> arr(n, 0);
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
            add += arr[i];
        }
        vector<int> vector0 = arr;
        int vl = vector0.size();
        for (int i = 0; i < vl - 1; ++i) {
            vector0 = replace_Seq(vector0, 1);
        }
        cout << max(add, vector0[0]) << '\n';
    }
    return 0;
}


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

// k=0,不翻转取差值；k = 1，翻转并取差值
vector<int> replace_Seq(vector<int> arr,int k){
    vector<int> vector1;
    if(k == 0){
        for (int i = 0;i < arr.size() - 1;i ++) {
            vector1.push_back(arr[i + 1] - arr[i]);
        }
    }
    else {
        for (auto it = arr.rbegin(); it != arr.rend() - 1; ++it) {
            vector1.push_back(*(it + 1) - *it);
        }
    }
    return vector1;
}

int dfs(vector<int> arr){
    if(arr.size() == 1){
        return arr[0];
    }

    return max(dfs(replace_Seq(arr,0)),dfs(replace_Seq(arr,1)));
}

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t;cin >> t;
    while (t --) {
        int n, add = 0;
        cin >> n;
        vector<int> arr(n, 0);
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
            add += arr[i];
        }
        cout << max(add, dfs(arr)) << '\n';
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

// k=0,不翻转取差值；k = 1，翻转并取差值
vector<int> replace_Seq(vector<int> arr,int k){
    vector<int> vector1;
    if(k == 0){
        for (int i = 0;i < arr.size() - 1;i ++) {
            vector1.push_back(arr[i + 1] - arr[i]);
        }
    }
    else {
        for (auto it = arr.rbegin(); it != arr.rend() - 1; ++it) {
            vector1.push_back(*(it + 1) - *it);
        }
    }
    return vector1;
}

int dfs(vector<int> arr){
    if(arr.size() == 1){
        return arr[0];
    }

    return max(dfs(replace_Seq(arr,0)),dfs(replace_Seq(arr,1)));
}

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t;cin >> t;
    while (t --) {
        int n, add = 0;
        cin >> n;
        vector<int> arr(n, 0);
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
            add += arr[i];
        }
        cout << max(add, dfs(arr)) << '\n';
    }
    return 0;
}


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


// k=0,不翻转取差值；k = 1，翻转并取差值
vector<int> replace_Seq(vector<int> arr,int k){
    vector<int> vector1;
    if(k == 0){
        for (int i = 0;i < arr.size() - 1;i ++) {
            vector1.push_back(arr[i + 1] - arr[i]);
        }
    }
    else {
        for (auto it = arr.rbegin(); it != arr.rend() - 1; ++it) {
            vector1.push_back(*(it + 1) - *it);
        }
    }
    return vector1;
}

int dfs(vector<int> arr,map<pair<int,int>,int>& mp,int zero,int one){
    if(arr.size() == 1){
        mp.insert({{zero,one},arr[0]});
        return arr[0];
    }
    // cout << one << ' ' << zero << '\n';

    int a1 = mp.count({zero + 1,one}) ?mp[{zero + 1,one}] : dfs(replace_Seq(arr,0),mp,zero ++,one);
    int a2 = mp.count({zero ,one + 1}) ?mp[{zero,one + 1}] : dfs(replace_Seq(arr,1),mp, zero, one ++);
    // cout << a1 << ' ' << a2 << '\n';

    return max(a1,a2);
}

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t;cin >> t;
    while (t --) {
        int n, add = 0;
        map<pair<int,int>,int> mp;
        cin >> n;
        vector<int> arr(n, 0);
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
            add += arr[i];
        }
        cout << max(add, dfs(arr,mp,0,0)) << '\n';
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


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

#define ll long long
#define int long long
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;

/* check file name :) */
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        mp[v[i]]++;
    }
    vector<int> f;
    for (auto i:mp) {
        f.push_back(i.second);
    }
    sort(all(f));
    for (int i = 0; i < f.size(); i++) {
        if (f[i] <= k) {
            f[n-1] += f[i];
            k -= f[i];
            f[i] = 0;
        }
    }
    int cnt = 0;
    for (int i = 0; i < f.size(); i++) {
        if (f[i] != 0) {
            cnt++;
        }
    }
    cout << cnt << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

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

#define ll long long
#define int long long
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;

/* check file name :) */
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        mp[v[i]]++;
    }
    vector<int> f;
    for (auto i:mp) {
        f.push_back(i.second);
    }
    sort(all(f));
    for (int i = 0; i < f.size(); i++) {
        if (f[i] <= k) {
            f[f.size()-1] += f[i];
            k -= f[i];
            f[i] = 0;
        }
    }
    int cnt = 0;
    for (int i = 0; i < f.size(); i++) {
        if (f[i] != 0) {
            cnt++;
        }
    }
    cout << cnt << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    return 0;
}


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

#define ll long long
#define int long long
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;

/* check file name :) */
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        mp[v[i]]++;
    }
    vector<int> f;
    for (auto i:mp) {
        f.push_back(i.second);
    }
    sort(all(f));
    int sub = 0;
    for (int i = 0; i < f.size(); i++) {
        f[i] += sub;
        if (f[i] <= k) {
            int sub = f[i];
            k -= f[i];
            f[i] = 0;
        }
        else {
            break;
        }
    }
    int cnt = 0;
    for (int i = 0; i < f.size(); i++) {
        if (f[i] != 0) {
            cnt++;
        }
    }
    cout << max(cnt, 1LL) << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

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

#define ll long long
#define int long long
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;

/* check file name :) */
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        mp[v[i]]++;
    }
    vector<int> f;
    for (auto i:mp) {
        f.push_back(i.second);
    }
    sort(all(f));
    for (int i = 0; i < f.size(); i++) {
        if (f[i] <= k) {
            f[n-1] += f[i];
            k -= f[i];
            f[i] = 0;
        }
    }
    int cnt = 0;
    for (int i = 0; i < f.size(); i++) {
        if (f[i] != 0) {
            cnt++;
        }
    }
    cout << cnt << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    return 0;
}


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

#define ll long long
#define int long long
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;

/* check file name :) */
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        mp[v[i]]++;
    }
    vector<int> f;
    for (auto i:mp) {
        f.push_back(i.second);
    }
    sort(all(f));
    for (int i = 0; i < f.size(); i++) {
        if (f[i] <= k) {
            f[f.size()-1] += f[i];
            k -= f[i];
            f[i] = 0;
        }
    }
    int cnt = 0;
    for (int i = 0; i < f.size(); i++) {
        if (f[i] != 0) {
            cnt++;
        }
    }
    cout << cnt << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: Rust 2021

Previous submission (verdict: Wrong answer on test 1):
use std::io::{stdin, stdout, BufWriter, Write};
use std::cmp;

fn solve(nTwos : u32, nThrees : u32, sum : u32) -> bool{
    
    for i in 0..=nTwos {
        for j in 0..=nThrees {
            
            if (sum + (i * 2) + (j * 6)) % 9 == 0 {
                return true;
            }

        }
    }

    return false;
}

fn main() -> std::io::Result<()> {
    let mut buf: String = String::new();
    let mut output = BufWriter::new(stdout().lock());
    stdin().read_line(&mut buf)?;

    let trim_func = |c: char| -> bool { (c == '\n') || (c == '\r') };

    let mut tcs = 0;
    {
        let line: &str = buf.trim_end_matches(trim_func);
        tcs = line.parse::<u32>().unwrap();
    }

    while tcs > 0 {
        tcs -= 1;
        buf.clear();
        stdin().read_line(&mut buf)?;
        
        let mut nTwos : u32 = 0;
        let mut nThrees : u32 = 0;
        let mut sum : u32 = 0;

        let slice : &[u8] = buf.as_bytes();

        for i in 0..(slice.len() - 1) {
            if slice[i] == ('2' as u8) {
                nTwos += 1;
            }
            else if slice[i] == ('3' as u8) {
                nThrees += 1;
            }

            sum += (slice[i] - ('0' as u8)) as u32;
        }

        if solve(cmp::min(nTwos, 8), cmp::min(nThrees, 8), sum) {
            writeln!(output, "YES");
        }
        else{
            writeln!(output, "NO");
        }
    }

    Ok(())
}


Submission (verdict: Wrong answer on test 1):
use std::io::{stdin, stdout, BufWriter, Write};
use std::cmp;

fn solve(nTwos : u32, nThrees : u32, sum : u32) -> bool{
    
    for i in 0..=nTwos {
        for j in 0..=nThrees {
            
            if (sum + (i * 2) + (j * 6)) % 9 == 0 {
                return true;
            }

        }
    }

    return false;
}

fn main() -> std::io::Result<()> {
    let mut buf: String = String::new();
    let mut output = BufWriter::new(stdout().lock());
    stdin().read_line(&mut buf)?;

    let trim_func = |c: char| -> bool { (c == '\n') || (c == '\r') };

    let mut tcs = 0;
    {
        let line: &str = buf.trim_end_matches(trim_func);
        tcs = line.parse::<u32>().unwrap();
    }

    while tcs > 0 {
        tcs -= 1;
        buf.clear();
        stdin().read_line(&mut buf)?;
        
        let mut nTwos : u32 = 0;
        let mut nThrees : u32 = 0;
        let mut sum : u32 = 0;

        let slice : &[u8] = buf.as_bytes();

        for i in 0..(slice.len() - 1) {
            if slice[i] == ('2' as u8) {
                nTwos += 1;
            }
            else if slice[i] == ('3' as u8) {
                nThrees += 1;
            }

            sum += (slice[i] - ('0' as u8)) as u32;
        }

        if solve(cmp::min(nTwos, 9), cmp::min(nThrees, 9), sum) {
            writeln!(output, "YES");
        }
        else{
            writeln!(output, "NO");
        }
    }

    Ok(())
}
Problem: 2050C - Uninteresting Number
Language: Rust 2021


Submission (verdict: Wrong answer on test 1):
use std::io::{stdin, stdout, BufWriter, Write};
use std::cmp;

fn solve(nTwos : u32, nThrees : u32, sum : u32) -> bool{
    
    for i in 0..=nTwos {
        for j in 0..=nThrees {
            
            if (sum + (i * 2) + (j * 6)) % 9 == 0 {
                return true;
            }

        }
    }

    return false;
}

fn main() -> std::io::Result<()> {
    let mut buf: String = String::new();
    let mut output = BufWriter::new(stdout().lock());
    stdin().read_line(&mut buf)?;

    let trim_func = |c: char| -> bool { (c == '\n') || (c == '\r') };

    let mut tcs = 0;
    {
        let line: &str = buf.trim_end_matches(trim_func);
        tcs = line.parse::<u32>().unwrap();
    }

    while tcs > 0 {
        tcs -= 1;
        buf.clear();
        stdin().read_line(&mut buf)?;
        
        let mut nTwos : u32 = 0;
        let mut nThrees : u32 = 0;
        let mut sum : u32 = 0;

        let slice : &[u8] = buf.as_bytes();

        for i in 0..(slice.len() - 1) {
            if slice[i] == ('2' as u8) {
                nTwos += 1;
            }
            else if slice[i] == ('3' as u8) {
                nThrees += 1;
            }

            sum += (slice[i] - ('0' as u8)) as u32;
        }

        if solve(cmp::min(nTwos, 8), cmp::min(nThrees, 8), sum) {
            writeln!(output, "YES");
        }
        else{
            writeln!(output, "NO");
        }
    }

    Ok(())
}