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


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

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif

using i64 = long long;

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

    vector<int> a(n);
    for(auto &_ : a) cin >> _;

    i64 ans = INT64_MIN;
    while(a.size()) {
        i64 curSum = accumulate(begin(a), end(a), 0LL);
        ans = max(curSum, ans);
        reverse(begin(a), end(a));
        vector<int> t;
        for(int i = 1; i < int(size(a)); ++i) {
            t.push_back(a[i] - a[i - 1]);
        }
        a = t;
    }
    cout << ans << "\n";
}

int32_t main() {
    ios::sync_with_stdio(0); 
    cin.tie(nullptr); 

    int Q; 
    cin >> Q; 
    while(Q--) solve(); 
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif

using i64 = long long;

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

    vector<i64> a(n);
    for(auto &_ : a) cin >> _;

    i64 ans = INT64_MIN;
    while(a.size()) {
        i64 curSum = accumulate(begin(a), end(a), 0LL);
        ans = max(curSum, ans);
        reverse(begin(a), end(a));
        vector<i64> t;
        for(int i = 1; i < int(size(a)); ++i) {
            t.push_back(a[i] - a[i - 1]);
        }
        a = t;
    }
    cout << ans << "\n";
}

int32_t main() {
    ios::sync_with_stdio(0); 
    cin.tie(nullptr); 

    int Q; 
    cin >> Q; 
    while(Q--) solve(); 
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif

using i64 = long long;

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

    vector<i64> a(n);
    for(auto &_ : a) cin >> _;

    i64 ans = accumulate(begin(a), end(a), 0LL);
    while(a.size() > 1) {
        reverse(begin(a), end(a));
        vector<i64> t;
        for(int i = 1; i < int(size(a)); ++i) {
            t.push_back(a[i] - a[i - 1]);
        }
        a = t;
        i64 curSum = accumulate(begin(a), end(a), 0LL);
        ans = max(abs(curSum), ans);
        dbg(a);
    }
    cout << ans << "\n";
}

int32_t main() {
    ios::sync_with_stdio(0); 
    cin.tie(nullptr); 

    int Q; 
    cin >> Q; 
    while(Q--) solve(); 
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif

using i64 = long long;

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

    vector<int> a(n);
    for(auto &_ : a) cin >> _;

    i64 ans = INT64_MIN;
    while(a.size()) {
        i64 curSum = accumulate(begin(a), end(a), 0LL);
        ans = max(curSum, ans);
        reverse(begin(a), end(a));
        vector<int> t;
        for(int i = 1; i < int(size(a)); ++i) {
            t.push_back(a[i] - a[i - 1]);
        }
        a = t;
    }
    cout << ans << "\n";
}

int32_t main() {
    ios::sync_with_stdio(0); 
    cin.tie(nullptr); 

    int Q; 
    cin >> Q; 
    while(Q--) solve(); 
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif

using i64 = long long;

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

    vector<i64> a(n);
    for(auto &_ : a) cin >> _;

    i64 ans = INT64_MIN;
    while(a.size()) {
        i64 curSum = accumulate(begin(a), end(a), 0LL);
        ans = max(curSum, ans);
        reverse(begin(a), end(a));
        vector<i64> t;
        for(int i = 1; i < int(size(a)); ++i) {
            t.push_back(a[i] - a[i - 1]);
        }
        a = t;
    }
    cout << ans << "\n";
}

int32_t main() {
    ios::sync_with_stdio(0); 
    cin.tie(nullptr); 

    int Q; 
    cin >> Q; 
    while(Q--) solve(); 
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#ifdef WIDA_WORK_SPACE
    #include "debug.h"
#endif

using i64 = long long;

signed main() {
    int n;
    cin >> n;
    vector<int> in(n);
    for (auto &i : in) {
        cin >> i;
    }

    vector<int> now(n);
    vector<pair<int, int>> ans;
    map<pair<int, int>, int> dic;
    iota(now.begin(), now.end(), 1);
    for (int p = n - 1; p >= 0; p--) {
        for (int i = 0; i < n; i++) {
            if (now[i] == in[p]) {
                for (int j = i + 1; j <= p; j++) {
                    dic[{now[j], now[j - 1]}]++;
                    ans.push_back({now[j], now[j - 1]});
                    swap(now[j - 1], now[j]);
                }
                break;
            }
        }
    }

    for (int i = 0; i < now.size(); i++) {
        for (int j = i + 1; j < now.size(); j++) {
            if (dic[{now[i], now[j]}] + dic[{now[j], now[i]}] != 2) {
                ans.push_back({now[j], now[i]});
                ans.push_back({now[i], now[j]});
                goto P;
            }
        }
    }
    P:{};

    cout << ans.size() << "\n";
    for (auto [i, j] : ans) {
        cout << i << " " << j << "\n";
    }
}

int __OI_INIT__ = []() {
    ios::sync_with_stdio(0), cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    return 0;
}();
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#ifdef WIDA_WORK_SPACE
    #include "debug.h"
#endif

using i64 = long long;

signed main() {
    int n;
    cin >> n;
    vector<int> in(n);
    for (auto &i : in) {
        cin >> i;
    }

    vector<int> now(n);
    vector<pair<int, int>> ans;
    map<pair<int, int>, int> dic;
    iota(now.begin(), now.end(), 1);
    for (int p = n - 1; p >= 0; p--) {
        for (int i = 0; i < n; i++) {
            if (now[i] == in[p]) {
                for (int j = i + 1; j <= p; j++) {
                    dic[{now[j], now[j - 1]}]++;
                    ans.push_back({now[j], now[j - 1]});
                    swap(now[j - 1], now[j]);
                }
                break;
            }
        }
    }

    for (int i = 0; i < now.size(); i++) {
        for (int j = i + 1; j < now.size(); j++) {
            if (dic[{now[i], now[j]}] + dic[{now[j], now[i]}] != 2) {
                ans.push_back({now[j], now[i]});
                ans.push_back({now[i], now[j]});
                goto P;
            }
        }
    }
    P:{};

    cout << ans.size() << "\n";
    for (auto [i, j] : ans) {
        cout << i << " " << j << "\n";
    }
}

int __OI_INIT__ = []() {
    ios::sync_with_stdio(0), cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    return 0;
}();

Submission (verdict: Wrong answer on test 5):
#include <bits/stdc++.h>
using namespace std;
#ifdef WIDA_WORK_SPACE
    #include "debug.h"
#endif

using i64 = long long;

signed main() {
    int n;
    cin >> n;
    vector<int> in(n);
    for (auto &i : in) {
        cin >> i;
    }

    vector<int> now(n);
    vector<pair<int, int>> ans;
    map<pair<int, int>, int> dic;
    iota(now.begin(), now.end(), 1);

    if (now == in) {
        for (int i = 0; i < n; i++) {
            for (int j = 1; j < n; j++) {
                ans.push_back({now[j], now[j - 1]});
                swap(now[j - 1], now[j]);
            }
        }
    } else {
        for (int p = n - 1; p >= 0; p--) {
            for (int i = 0; i < n; i++) {
                if (now[i] == in[p]) {
                    for (int j = i + 1; j <= p; j++) {
                        dic[{now[j], now[j - 1]}]++;
                        ans.push_back({now[j], now[j - 1]});
                        swap(now[j - 1], now[j]);
                    }
                    break;
                }
            }
        }

        for (int i = 0; i < now.size(); i++) {
            for (int j = i + 1; j < now.size(); j++) {
                if (dic[{now[i], now[j]}] + dic[{now[j], now[i]}] != 2) {
                    ans.push_back({now[j], now[i]});
                    ans.push_back({now[i], now[j]});
                    goto P;
                }
            }
        }
    }
    P:{};

    cout << ans.size() << "\n";
    for (auto [i, j] : ans) {
        cout << i << " " << j << "\n";
    }
}

int __OI_INIT__ = []() {
    ios::sync_with_stdio(0), cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    return 0;
}();
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


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

int const N = 100005;
int edges[N];
int vis[N];


// int dfs(int cur, vector<int>v[])
// {
//     vis[cur] = 1;
    
//     for(int i = 0 ; i < v[cur].size() ; i++)
//     {
//         int child = v[cur][i];
//         if(vis[child] == 0)
//         {
//             dfs(child, v);
//             edges[child] += 1;
//         }
//     }
    
// }

signed main()
{
    int t = 1;
    cin>>t;
    while(t--)
    {
        int n ; cin >> n;
        vector<int>v[n+2];
        int b[n+2] = {0};
        int ans = 0;
        
        for(int i = 1 ; i < n ; i++)
        {
            int x, y;
            cin >> x >> y;
            v[x].pb(y);
            v[y].pb(x);
            b[x] += 1;
            b[y] += 1;
        }
        
        vector<pair<int, int>>a;
        for(int i = 1 ; i <= n ; i++)
        {
            int sz = v[i].size();
            a.pb({sz, i});
        }
        
        int mx = 0;
        int node = 0;
        for(int i =1 ; i <= n ; i++) {
            if(b[i] > mx)  {
                mx = b[i];
                node = i;
            }
        }
        
        for(int i = 0 ; i< v[node].size(); i++) {
            b[v[node][i]] -= 1; 
        }
        b[node] = -1;
        
        // cout << node << " " << mx << "\n";
        
        ans += mx;
        mx = 0;
        for(int i = 1 ; i <= n ; i++) {
            if(b[i] > mx)  {
                mx = b[i];
                node = i;
            }
        }
        
        // cout << node << " " << mx << "\n";
        
        ans += mx;
        
        // sort(a.begin(), a.end(), greater<>());
        
        
        // int ans = 0;
        // int f = 0;
        // int pre_node = 0;
        // int cnt = 0;

        // for(int i = 0; i < a.size(); i++)
        // {
        //     int sz = a[i].first, node_val = a[i].second;
        //     cout << sz << " " << node_val << endl;
        //     if( f == 0) {
        //         ans += sz;
        //     }
        //     else {
        //         int last_ans = 0;
        //         for(int j = 0 ; j < v[i].size(); j++) {
        //             if(v[i][j] == pre_node) last_ans = sz - 1;
        //         }
                
        //         if(sz > last_ans) ans += sz;
        //         else ans += last_ans;
                
        //     }
        //     cnt += 1;
        //     if(cnt == 3) break;
        // }
        
        // memset(edges, 0, sizeof(edges));
        // memset(vis, 0, sizeof(vis));

        ans -= 1;
        cout << ans << "\n";
        
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define endlb'\n'
#define ll long long
#define optimize() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
    optimize();
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        if(k>=n)cout<<1<<endl;
        else{
        vector<int>arr(n);
        unordered_map<int,int>freq_map;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            freq_map[arr[i]]++;
        }
        vector<pair<int,int>>freq_vec;
        for(auto&entry:freq_map){
            freq_vec.push_back(entry);
        }
        sort(freq_vec.begin(),freq_vec.end(),[](pair<int,int>&a,pair<int,int>&b){
            return a.second<b.second;
        });
        int cnt=0;
        for(auto&u:freq_vec){
            if(u.second<=k){
                k-=u.second;
                u.second=0;
            }
        }
 
        for(auto&u:freq_vec){
            if(u.second!=0)cnt++;
        }
        if(cnt==0)cout<<1<<endl;
        else cout<<cnt<<endl;
     }
    }
    return 0;
}


Submission (verdict: Time limit exceeded on test 11):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define optimize() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
    optimize();
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        unordered_map<int,int>freq_map;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            freq_map[arr[i]]++;
        }
        vector<pair<int,int>>freq_vec;
        for(auto&entry:freq_map){
            freq_vec.push_back(entry);
        }
        sort(freq_vec.begin(),freq_vec.end(),[](pair<int,int>&a,pair<int,int>&b){
            return a.second<b.second;
        });
        int cnt=0;
        for(auto&u:freq_vec){
            if(u.second<=k){
                k-=u.second;
                u.second=0;
            }
        }
 
        for(auto&u:freq_vec){
            if(u.second!=0)cnt++;
        }
        if(cnt==0)cout<<1<<endl;
        else cout<<cnt<<endl;
     }
    
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 11):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define optimize() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
    optimize();
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        unordered_map<int,int>freq_map;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            freq_map[arr[i]]++;
        }
        vector<pair<int,int>>freq_vec;
        for(auto&entry:freq_map){
            freq_vec.push_back(entry);
        }
        sort(freq_vec.begin(),freq_vec.end(),[](pair<int,int>&a,pair<int,int>&b){
            return a.second<b.second;
        });
        int cnt=0;
        for(auto&u:freq_vec){
            if(u.second<=k){
                k-=u.second;
                u.second=0;
            }
        }
 
        for(auto&u:freq_vec){
            if(u.second!=0)cnt++;
        }
        if(cnt==0)cout<<1<<endl;
        else cout<<cnt<<endl;
     }
    
    return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define optimize() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
    optimize();
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int arr[n];
        map<int,int>mp;
        for(int i=0;i<n;i++)
        {
         cin>>arr[i];
         mp[arr[i]]++;
        }
        vector<int>v;
        for(auto u:mp)v.push_back(u.second);
         sort(v.begin(),v.end());
         int cnt=v.size();
        for(auto u:v)
        {
         if(u<=k)
          {
            cnt--;
            k=k-u;
          }
        }
        cout<<max(1,cnt)<<endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 11):
#include<bits/stdc++.h>
using namespace std;
#define endlb'\n'
#define ll long long
#define optimize() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
    optimize();
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        unordered_map<int,int>freq_map;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            freq_map[arr[i]]++;
        }
        vector<pair<int,int>>freq_vec;
        for(auto&entry:freq_map){
            freq_vec.push_back(entry);
        }
        sort(freq_vec.begin(),freq_vec.end(),[](pair<int,int>&a,pair<int,int>&b){
            return a.second<b.second;
        });
        int cnt=0;
        for(auto&u:freq_vec){
            if(u.second<=k){
                k-=u.second;
                u.second=0;
            }
        }
 
        for(auto&u:freq_vec){
            if(u.second!=0)cnt++;
        }
        if(cnt==0)cout<<1<<endl;
        else cout<<cnt<<endl;
    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define endlb'\n'
#define ll long long
#define optimize() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
    optimize();
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        if(k>=n)cout<<1<<endl;
        else{
        vector<int>arr(n);
        unordered_map<int,int>freq_map;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            freq_map[arr[i]]++;
        }
        vector<pair<int,int>>freq_vec;
        for(auto&entry:freq_map){
            freq_vec.push_back(entry);
        }
        sort(freq_vec.begin(),freq_vec.end(),[](pair<int,int>&a,pair<int,int>&b){
            return a.second<b.second;
        });
        int cnt=0;
        for(auto&u:freq_vec){
            if(u.second<=k){
                k-=u.second;
                u.second=0;
            }
        }
 
        for(auto&u:freq_vec){
            if(u.second!=0)cnt++;
        }
        if(cnt==0)cout<<1<<endl;
        else cout<<cnt<<endl;
     }
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 11):
#include<bits/stdc++.h>
using namespace std;
#define endlb'\n'
#define ll long long
#define optimize() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
    optimize();
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        unordered_map<int,int>freq_map;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            freq_map[arr[i]]++;
        }
        vector<pair<int,int>>freq_vec;
        for(auto&entry:freq_map){
            freq_vec.push_back(entry);
        }
        sort(freq_vec.begin(),freq_vec.end(),[](pair<int,int>&a,pair<int,int>&b){
            return a.second<b.second;
        });
        int cnt=0;
        for(auto&u:freq_vec){
            if(u.second<=k){
                k-=u.second;
                u.second=0;
            }
        }
 
        for(auto&u:freq_vec){
            if(u.second!=0)cnt++;
        }
        if(cnt==0)cout<<1<<endl;
        else cout<<cnt<<endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
#define all(vec) vec.begin(), vec.end()
#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rep2(i,a,b) for(int i = a; i >= b; i--)
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int>> vvi;
const int INF = 1e9;
const long LINF = 4e18;
// const long MOD = 1e9+7; // 998244353 
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());
// long inv[1000003], fac[1000003], ifac[1000003];
// inv[1] = fac[0] = ifac[0] = 1;
// rep(i, 2, 1000000) inv[i]=MOD-(MOD/i)*inv[MOD%i]%MOD;
// rep(i, 1, 1000000) fac[i] = (i*fac[i-1])%MOD, ifac[i] = (inv[i]*ifac[i-1])%MOD;

// long C(int n, int k) { return (k > n)? 0 : ((fac[n]*ifac[n-k])%MOD)*ifac[k]%MOD; }


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int r, f;
	cin >> r >> f;
	int x = f/r;
	int rem = f - x*r;
	// cout << x << " " << rem << "\n";
	if(rem > r-rem) x++;
	if(x&1) cout << "down\n";
	else cout << "up\n";
}
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;
 
int main() {
    long long t;
    cin>>t;
    while(t--){
        long long n,s=0,tw=0,th=0;
        cin>>n;
        string m=to_string(n);
        for(int i=0;i<m.size();i++){
            if(m[i]-'0'==2)
                tw++;
            if(m[i]-'0'==3)
                th++;
            s+=(m[i]-'0');
            s=s%9;
        }
        if(s==0)
            cout<<"YES"<<endl;
        else{
            long long f=0,l=8;
            for(int i=0;i<=min(l,tw);i++){
                for(int j=0;j<=min(l,th);j++){
                    if((s+i*2+j*6)%9==0){
                        f=1;
                        break;
                    }
                }
            }
            if(tw==0){
                for(int j=0;j<=min(l,th);j++){
                    if((s+j*6)%9==0){
                        f=1;
                        break;
                    }
                }
            }
            if(th==0){
                for(int j=0;j<=min(l,tw);j++){
                    if((s+j*2)%9==0){
                        f=1;
                        break;
                    }
                }
            }
            if(f==1)
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;   
        }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long t;
    cin>>t;
    while(t--){
        long long n,s=0,tw=0,th=0;
        cin>>n;
        string m=to_string(n);
        for(int i=0;i<m.size();i++){
            if(m[i]-'0'==2&&tw<10)
                tw++;
            if(m[i]-'0'==3&&th<10)
                th++;
            s+=(m[i]-'0');
            s=s%9;
        }
        if(s==0)
            cout<<"YES"<<endl;
        else{
            long long f=0,l=8;
            if(tw==0){
                for(int j=0;j<=min(l,th);j++){
                    if((s+j*6)%9==0){
                        f=1;
                        break;
                    }
                }
            }
            else if(th==0){
                for(int j=0;j<=min(l,tw);j++){
                    if((s+j*2)%9==0){
                        f=1;
                        break;
                    }
                }
            }
            else{
                for(int i=0;i<=min(l,tw);i++){
                    for(int j=0;j<=min(l,th);j++){
                        if((s+i*2+j*6)%9==0){
                            f=1;
                            break;
                        }
                    }
                    if(f==1)
                        break;
                }
            }
            if(f==1)
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;   
        }
    }
    return 0;
}