ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

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

    unordered_map<int, int> freqMap;
    int x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        freqMap[x]++;
    }

    vector<pair<int, int> > freq(freqMap.begin(), freqMap.end());
    sort(freq.begin(), freq.end(), [](const auto &left, const auto &right) {
        return left.second < right.second;
    });

    int ans = freq.size();
    for (const auto &[_, count]: freq) {
        if (k == 0) break;
        if (count <= k) {
            k -= count;
            --ans;
        }
    }

    if (ans == 0) ++ans;

    cout << ans << "\n";
}

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

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

    return 0;
}


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

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

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

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

    unordered_map<int, int> freqMap;
    for (int i = 0; i < n; ++i) {
        freqMap[a[i]]++;
    }

    vector<pair<int, int> > freq(freqMap.begin(), freqMap.end());
    sort(freq.begin(), freq.end(), [](const auto &left, const auto &right) {
        return left.second < right.second;
    });

    int ans = freq.size();
    for (const auto &[_, count]: freq) {
        if (k == 0) break;
        if (count <= k) {
            k -= count;
            --ans;
        }
    }

    if (ans == 0) ++ans;

    cout << ans << "\n";
}

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

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

    return 0;
}
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;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

void solve() {
    int n;
    cin >> n;
    vector<i64> a(n);

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if (n == 1) {
        cout << a[0] << "\n";
        return;
    }

    i64 ans = 0;
    while (a.size() > 1) {
        for (int i = 0; i < a.size(); ++i) {
            ans += a[i];
        }

        i64 ans2 = a[a.size() - 1] - a[0];
        i64 ans3 = a[0] - a[a.size() - 1];

        if (ans3 > ans2 && ans3 > ans) {
            ans = ans3;
            reverse(a.begin(), a.end());
        } else if (ans2 > ans) {
            ans = ans2;
        }

        for (int i = 1; i < a.size(); ++i) {
            a[i - 1] = a[i] - a[i - 1];
        }
        a.pop_back();
    }

    cout << ans << "\n";
}

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

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

    return 0;
}


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

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

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

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

    i64 ans = accumulate(a.begin(), a.end(), 0LL);
    for (int i = 0; i < n; ++i) {
        vector<i64> b(a.size() - 1);
        for (int j = 0; j < b.size(); ++j) {
            b[j] = a[j + 1] - a[j];
        }
        ans = max(ans, abs(accumulate(b.begin(), b.end(), 0LL)));
        a = b;
    }

    cout << ans << "\n";
}

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

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

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

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

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

    i64 ans = accumulate(a.begin(), a.end(), 0LL);
    for (int i = 0; i < n; ++i) {
        vector<i64> b(a.size() - 1);
        for (int j = 0; j < b.size(); ++j) {
            b[j] = a[j + 1] - a[j];
        }
        i64 ans2 =  abs(accumulate(b.begin(), b.end(), 0LL));
        ans = max(ans, ans2);
        a = b;
    }

    cout << ans << "\n";
}

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

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

    return 0;
}


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

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

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

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

    i64 ans = accumulate(a.begin(), a.end(), 0LL);
    for (int i = 1; i < n; ++i) {
        vector<i64> b(a.size() - 1);
        for (int j = 0; j < b.size(); ++j) {
            b[j] = a[j + 1] - a[j];
        }
        i64 ans2 =  abs(accumulate(b.begin(), b.end(), 0LL));
        ans = max(ans, ans2);
        a = b;
    }

    cout << ans << "\n";
}

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

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

    return 0;
}
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;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if (n == 1) {
        cout << a[0] << "\n";
        return;
    }

    int ans = 0;
    while (a.size() > 1) {
        for (int i = 0; i < a.size(); ++i) {
            ans += a[i];
        }

        int ans2 = a[a.size() - 1] - a[0];
        int ans3 = a[0] - a[a.size() - 1];

        if (ans3 > ans2 && ans3 > ans) {
            ans = ans3;
            reverse(a.begin(), a.end());
        } else if (ans2 > ans) {
            ans = ans2;
        }

        for (int i = 1; i < a.size(); ++i) {
            a[i - 1] = a[i] - a[i - 1];
        }
        a.pop_back();
    }

    cout << ans << "\n";
}

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

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

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

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

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

    i64 ans = accumulate(a.begin(), a.end(), 0LL);
    for (int i = 0; i < n; ++i) {
        vector<i64> b(a.size() - 1);
        for (int j = 0; j < b.size(); ++j) {
            b[j] = a[j + 1] - a[j];
        }
        ans = max(ans, abs(accumulate(b.begin(), b.end(), 0LL)));
        a = b;
    }

    cout << ans << "\n";
}

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

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

    return 0;
}


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

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

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

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

    i64 ans = accumulate(a.begin(), a.end(), 0LL);
    for (int i = 0; i < n; ++i) {
        vector<i64> b(a.size() - 1);
        for (int j = 0; j < b.size(); ++j) {
            b[j] = a[j + 1] - a[j];
        }
        i64 ans2 =  abs(accumulate(b.begin(), b.end(), 0LL));
        ans = max(ans, ans2);
        a = b;
    }

    cout << ans << "\n";
}

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

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

    return 0;
}
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;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if (n == 1) {
        cout << a[0] << "\n";
        return;
    }

    int ans = 0;
    while (a.size() > 1) {
        for (int i = 0; i < a.size(); ++i) {
            ans += a[i];
        }

        int ans2 = a[a.size() - 1] - a[0];
        int ans3 = a[0] - a[a.size() - 1];

        if (ans3 > ans2 && ans3 > ans) {
            ans = ans3;
            reverse(a.begin(), a.end());
        } else if (ans2 > ans) {
            ans = ans2;
        }

        for (int i = 1; i < a.size(); ++i) {
            a[i - 1] = a[i] - a[i - 1];
        }
        a.pop_back();
    }

    cout << ans << "\n";
}

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

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

    return 0;
}


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

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

void solve() {
    int n;
    cin >> n;
    vector<i64> a(n);

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if (n == 1) {
        cout << a[0] << "\n";
        return;
    }

    i64 ans = 0;
    while (a.size() > 1) {
        for (int i = 0; i < a.size(); ++i) {
            ans += a[i];
        }

        i64 ans2 = a[a.size() - 1] - a[0];
        i64 ans3 = a[0] - a[a.size() - 1];

        if (ans3 > ans2 && ans3 > ans) {
            ans = ans3;
            reverse(a.begin(), a.end());
        } else if (ans2 > ans) {
            ans = ans2;
        }

        for (int i = 1; i < a.size(); ++i) {
            a[i - 1] = a[i] - a[i - 1];
        }
        a.pop_back();
    }

    cout << ans << "\n";
}

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

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

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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



using namespace std;



int main(){

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        int n = s.length(), r = 0, c2 = 0, c3 = 0;

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

            c2 += s[i] == '2';

            c3 += s[i] == '3';

            r = (r + s[i] - '0') % 9;

        }

        bool flag = false;

        for(int i = 0; i <= max(c2, 8); i++){

            for(int j = 0; j <= max(2, c3); j++)    if((r + i + i + j + j + j) % 9 == 0){

                flag = true;

                break;

            }

            if(flag)    break;

        }

        cout << (flag? "YES": "NO") << endl;

    }

    return 0;

}

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



using namespace std;



int main(){

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        int n = s.length(), r = 0, c2 = 0, c3 = 0;

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

            c2 += s[i] == '2';

            c3 += s[i] == '3';

            r = (r + s[i] - '0') % 9;

        }

        bool flag = false;

        for(int i = 0; i <= min(c2, 8); i++){

            for(int j = 0; j <= min(2, c3); j++)    if((r + i + i + j + j + j) % 9 == 0){

                flag = true;

                break;

            }

            if(flag)    break;

        }

        cout << (flag? "YES": "NO") << endl;

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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



using namespace std;



int main(){

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        int n = s.length(), r = 0, c2 = 0, c3 = 0;

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

            c2 += s[i] == '2';

            c3 += s[i] == '3';

            r = (r + s[i] - '0') % 9;

        }

        bool flag = false;

        for(int i = 0; i <= min(c2, 8); i++){

            for(int j = 0; j <= min(2, c3); j++)    if((r + i + i + j + j + j) % 9 == 0){

                flag = true;

                break;

            }

            if(flag)    break;

        }

        cout << (flag? "YES": "NO") << endl;

    }

    return 0;

}

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



using namespace std;



int main(){

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        int n = s.length(), r = 0, c2 = 0, c3 = 0;

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

            c2 += s[i] == '2';

            c3 += s[i] == '3';

            r = (r + s[i] - '0') % 9;

        }

        cout << c2 << " " << c3 << endl;

        bool flag = false;

        for(int i = 0; i <= min(c2, 8); i++){

            for(int j = 0; j <= min(2, c3); j++)    if((r + i + i + j + j + j) % 9 == 0){

                flag = true;

                break;

            }

            if(flag)    break;

        }

        cout << (flag? "YES": "NO") << endl;

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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



using namespace std;



int main(){

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        int n = s.length(), r = 0, c2 = 0, c3 = 0;

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

            c2 += s[i] == '2';

            c3 += s[i] == '3';

            r = (r + s[i] - '0') % 9;

        }

        cout << r << " " << c2 << " " << c3 << endl;

        bool flag = false;

        for(int i = 0; i <= min(c2, 8); i++){

            for(int j = 0; j <= min(2, c3); j++)    if((r + i + i + j + j + j) % 9 == 0){

                flag = true;

                break;

            }

            if(flag)    break;

        }

        cout << (flag? "YES": "NO") << endl;

    }

    return 0;

}

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



using namespace std;



int main(){

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        int n = s.length(), r = 0, c2 = 0, c3 = 0;

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

            c2 += s[i] == '2';

            c3 += s[i] == '3';

            r = (r + s[i] - '0') % 9;

        }

        bool flag = false;

        for(int i = 0; i <= min(c2, 8); i++){

            for(int j = 0; j <= min(2, c3); j++)    if((r + i + i + j * 6) % 9 == 0){

                flag = true;

                break;

            }

            if(flag)    break;

        }

        cout << (flag? "YES": "NO") << endl;

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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



using namespace std;



int main(){

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        int n = s.length(), r = 0, c2 = 0, c3 = 0;

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

            c2 += s[i] == '2';

            c3 += s[i] == '3';

            r = (r + s[i] - '0') % 9;

        }

        cout << c2 << " " << c3 << endl;

        bool flag = false;

        for(int i = 0; i <= min(c2, 8); i++){

            for(int j = 0; j <= min(2, c3); j++)    if((r + i + i + j + j + j) % 9 == 0){

                flag = true;

                break;

            }

            if(flag)    break;

        }

        cout << (flag? "YES": "NO") << endl;

    }

    return 0;

}

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



using namespace std;



int main(){

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        int n = s.length(), r = 0, c2 = 0, c3 = 0;

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

            c2 += s[i] == '2';

            c3 += s[i] == '3';

            r = (r + s[i] - '0') % 9;

        }

        cout << r << " " << c2 << " " << c3 << endl;

        bool flag = false;

        for(int i = 0; i <= min(c2, 8); i++){

            for(int j = 0; j <= min(2, c3); j++)    if((r + i + i + j + j + j) % 9 == 0){

                flag = true;

                break;

            }

            if(flag)    break;

        }

        cout << (flag? "YES": "NO") << endl;

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


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



using namespace std;



int main(){

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        int n = s.length(), r = 0, c2 = 0, c3 = 0;

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

            c2 += s[i] == '2';

            c3 += s[i] == '3';

            r = (r + s[i] - '0') % 9;

        }

        bool flag = false;

        for(int i = 0; i <= max(c2, 8); i++){

            for(int j = 0; j <= max(2, c3); j++)    if((r + i + i + j + j + j) % 9 == 0){

                flag = true;

                break;

            }

            if(flag)    break;

        }

        cout << (flag? "YES": "NO") << endl;

    }

    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define ll long long
#define vl vector<ll>
#define uli unordered_map<ll, int>
#define prio priority_queue<ll>

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  int t = 0;
  cin >> t;
  while (t--) {
    int n = 0;
    int m = 0;
    cin >> n >> m;
    vl a(n), b(m);
    ll suma = 0;
    ll sumb = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      suma += a[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> b[i];
      sumb += b[i];
    }
    if (suma != sumb) {
      cout << "No\n";
      continue;
    }
    uli freq;
    for (ll x : a) {
      freq[x]++;
    }
    prio pq;
    for (ll x : b) {
      pq.push(x);
    }
    int mt = 0;
    bool p = true;
    while (!pq.empty() && mt < n) {
      ll x = pq.top();
      pq.pop();
      if (freq[x] > 0) {
        freq[x]--;
        mt++;
        continue;
      }
      if (x == 1) {
        p = false;
        break;
      }
      ll l = x / 2;
      ll r = x - l;
      pq.push(l);
      pq.push(r);
    }
    if (mt != n) {
      p = false;
    }
    cout << (p ? "Yes" : "No") << "\n";
  }
  return 0;
}



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

#define ll long long
#define vl vector<ll>
#define uli unordered_map<ll, int>

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  int t = 0;
  cin >> t;
  while (t--) {
    int n = 0, m = 0;
    cin >> n >> m;
    vl a(n), b(m);
    ll suma = 0, sumb = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      suma += a[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> b[i];
      sumb += b[i];
    }
    if (suma != sumb) {
      cout << "No\n";
      continue;
    }
    uli freq;
    for (ll x : a) {
      freq[x]++;
    }
    map<ll, ll> board;
    for (ll x : b) {
      board[x]++;
    }
    bool ok = true;
    while (!board.empty()) {
      auto it = board.rbegin();
      ll x = it->first;
      ll cnt = it->second;
      board.erase(x);
      if (freq.find(x) != freq.end()) {
        ll available = freq[x];
        ll use = min((ll)available, cnt);
        freq[x] -= use;
        cnt -= use;
      }
      if (cnt > 0) {
        if (x == 1) { 
          ok = false;
          break;
        }
        ll l = x / 2;
        ll r = x - l;
        board[l] += cnt;
        board[r] += cnt;
      }
    }
    for (auto &p : freq) {
      if (p.second != 0) {
        ok = false;
        break;
      }
    }
    cout << (ok ? "Yes" : "No") << "\n";
  }
  return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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

#define ll long long
#define vl vector<ll>
#define uli unordered_map<ll, int>
#define pq priority_queue<ll>

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  int t = 0;
  cin >> t;
  while (t--) {
    int n = 0;
    int m = 0;
    cin >> n >> m;
    vl a(n);
    vl b(m);
    ll suma = 0;
    ll sumb = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      suma += a[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> b[i];
      sumb += b[i];
    }

    if (suma != sumb) {
      cout << "No\n";
      continue;
    }

    uli freq;
    for (ll x : a) {
      freq[x]++;
    }

    pq prio;
    for (ll x : b) {
      prio.push(x);
    }

    bool p = true;
    while (!prio.empty()) {
      ll x = prio.top();
      prio.pop();

      if (freq[x] > 0) {
        freq[x]--;
        continue;
      }

      if (x == 1) {
        p = true;
        break;
      }

      ll l = x / 2;
      ll r = x - l;
      prio.push(l);
      prio.push(r);
    }
    cout << (p ? "Yes" : "No") << '\n';
  }
  return 0;
}