ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main () {
    int z;
    cin >> z;
    while(z--) {
        int n , l ,r ;
        cin >> n >> l >> r;
        vector<int> a(n);
        // take in all elements in vector
        for(int i = 0 ; i < n ; i++){
            cin >> a[i];
        }

        vector<int> v1(a.begin(), a.begin() + l - 1);
        vector<int> v2(a.begin() + l - 1, a.begin() + r);
        vector<int> v3(a.begin() + r, a.end());

        // sort all vectors
        sort(v1.begin(), v1.end());
        sort(v2.begin(), v2.end());
        sort(v3.begin(), v3.end());

        int s1 = 0;
        if(v1.size() != 0) {
            int it = 0;
            for(int i = v2.size() - 1 ; i >= 0; i--) {
                if(it <= v1.size() - 1) {
                    if(v2[i] > v1[it]) {
                        s1 += v1[it];
                    } else {
                        s1 += v2[i];
                    }
                    it++;
                }
            }
        }

        if(v2.size() > v1.size()) {
            for(int i = 0; i < v2.size()-v1.size(); i++) {
                s1 += v2[i];
            }
        }

        int s2 = 0;
        if(v3.size() != 0) {
            int it = 0;
            for(int i = v2.size() - 1 ; i >= 0; i--) {
                if(it <= v3.size() - 1) {
                    if(v2[i] > v3[it]) {
                        s2 += v3[it];
                    } else {
                        s2 += v2[i];
                    }
                    it++;
                }
            }
        }

        if(v2.size() > v3.size()) {
            for(int i = 0; i < v2.size()-v3.size(); i++) {
                s2 += v2[i];
            }
        }

        if(s1 < s2) {
            cout << s1 << endl;
        } else {
            cout << s2 << endl;
        }
    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--)
    {
int n,l,r;
cin>>n>>l>>r;
vector<long long int> nums(n);
for(int i=0;i<n;i++)
{
    cin>>nums[i];
}
long long int digits = r-l+1;
if(l==1||r==n){
sort(nums.begin(),nums.end());

long long int sum=0;
for(int i=0;i<digits;i++)
{
    sum+=nums[i];
}

cout<<sum<<endl;
}
else
{
    vector<long long int>nums2=nums;
    long long int sum1=0,sum2=0;
    sort(nums.begin(),nums.begin()+r-1);


    for(int i=0;i<digits;i++)
    {
        sum1+=nums[i];
    }
    sort(nums2.begin()+l-1,nums2.end());
    for(int i=l-1;i<l-1+digits;i++)
    {
        sum2+=nums2[i];
    }
    cout<<min(sum1,sum2)<<endl;
}

    }
    return 0;
}

Submission (verdict: Accepted):
#include<iostream>

#include<vector>

#include<algorithm>

#include<cmath>

using namespace std;



int main(){

    int t;

    cin>>t;

    while(t--)

    {

int n,l,r;

cin>>n>>l>>r;

vector<long long int> nums(n);

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

{

    cin>>nums[i];

}

long long int digits = r-l+1;

if(l==1||r==n){

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



long long int sum=0;

for(int i=0;i<digits;i++)

{

    sum+=nums[i];

}



cout<<sum<<endl;

}

else

{

    vector<long long int>nums2=nums;

    long long int sum1=0,sum2=0;

    sort(nums.begin(),nums.begin()+r);





    for(int i=0;i<digits;i++)

    {

        sum1+=nums[i];

    }



    sort(nums2.begin()+l-1,nums2.end());

    for(int i=l-1;i<l-1+digits;i++)

    {

        sum2+=nums2[i];

    }

    cout<<min(sum1,sum2)<<endl;

}



    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--)
    {
int n,l,r;
cin>>n>>l>>r;
vector<long long int> nums(n);
for(int i=0;i<n;i++)
{
    cin>>nums[i];
}
long long int digits = r-l+1;
if(l==1||r==n){
sort(nums.begin(),nums.end());

long long int sum=0;
for(int i=0;i<digits;i++)
{
    sum+=nums[i];
}

cout<<sum<<endl;
}
else
{
    long long int sum1=0,sum2=0;
    sort(nums.begin(),nums.begin()+l-2);
    sort(nums.begin()+l-1,nums.begin()+r-1);
    sort(nums.begin()+r,nums.end());

    for(int i=0;i<digits;i++)
    {
        sum1+=nums[i];
    }
    for(int i=l-1;i<l-1+digits;i++)
    {
        sum2+=nums[i];
    }
    cout<<min(sum1,sum2)<<endl;
}

    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--)
    {
int n,l,r;
cin>>n>>l>>r;
vector<long long int> nums(n);
for(int i=0;i<n;i++)
{
    cin>>nums[i];
}
long long int digits = r-l+1;
if(l==1||r==n){
sort(nums.begin(),nums.end());

long long int sum=0;
for(int i=0;i<digits;i++)
{
    sum+=nums[i];
}

cout<<sum<<endl;
}
else
{
    long long int sum1=0,sum2=0;
    sort(nums.begin(),nums.begin()+l-2);
    sort(nums.begin()+l-1,nums.begin()+r-1);
    sort(nums.begin()+r,nums.end());

    for(int i=0;i<digits;i++)
    {
        sum1+=nums[i];
    }
    for(int i=l-1;i<l-1+digits;i++)
    {
        sum2+=nums[i];
    }
    cout<<min(sum1,sum2)<<endl;
}

    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--)
    {
int n,l,r;
cin>>n>>l>>r;
vector<long long int> nums(n);
for(int i=0;i<n;i++)
{
    cin>>nums[i];
}
long long int digits = r-l+1;
if(l==1||r==n){
sort(nums.begin(),nums.end());

long long int sum=0;
for(int i=0;i<digits;i++)
{
    sum+=nums[i];
}

cout<<sum<<endl;
}
else
{
    vector<long long int>nums2=nums;
    long long int sum1=0,sum2=0;
    sort(nums.begin(),nums.begin()+r-1);


    for(int i=0;i<digits;i++)
    {
        sum1+=nums[i];
    }
    sort(nums2.begin()+l-1,nums2.end());
    for(int i=l-1;i<l-1+digits;i++)
    {
        sum2+=nums2[i];
    }
    cout<<min(sum1,sum2)<<endl;
}

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define int ll
#define sz(A) ((int)A.size())

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        int n;
        cin >> n;
        vector<int> a(n);
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            ans += a[i];
        }
        for (int i = 0; i < n - 1; ++i) {
            int s = 0;
            vector<int> t;
            for (int j = 1; j < sz(a); ++j) {
                t.push_back(a[j] - a[j - 1]);
            }
            a = t;
            s = a[sz(a) - 1] - a[0];
            if (sz(a) == 1) {
                s = a[0];
            }
            if (i % 2 == 0) {
                s = max(s, -s);
            }
            ans = max(ans, s);
        }
        cout << ans << '\n';
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define int ll
#define sz(A) ((int)A.size())

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        int n;
        cin >> n;
        vector<int> a(n);
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            ans += a[i];
        }
        for (int i = 0; i < n; ++i) {
            int s = a[sz(a) - 1] - a[0];
            if (sz(a) == 1) {
                s = a[0];
            }
            if (i % 2 == 0 && n != 1) {
                s = max(s, -s);
            }
            vector<int> t;
            for (int j = 1; j < sz(a); ++j) {
                t.push_back(a[j] - a[j - 1]);
            }
            a = t;
            ans = max(ans, s);
        }
        cout << ans << '\n';
    }
    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;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define int ll
#define sz(A) ((int)A.size())

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        int n;
        cin >> n;
        vector<int> a(n);
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            ans += a[i];
        }
        if (n == 1) {
            cout << a[0] << '\n';
            continue;
        }
        for (int i = 0; i < n; ++i) {
            int s = a[sz(a) - 1] - a[0];
            if (sz(a) == 1) {
                s = a[0];
            }
            if (i % 2 == 0) {
                s = max(s, -s);
            }
            vector<int> t;
            for (int j = 1; j < sz(a); ++j) {
                t.push_back(a[j] - a[j - 1]);
            }
            a = t;
            ans = max(ans, s);
        }
        cout << ans << '\n';
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define int ll
#define sz(A) ((int)A.size())

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        int n;
        cin >> n;
        vector<int> a(n);
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            ans += a[i];
        }
        if (n == 1) {
            cout << a[0] << '\n';
            continue;
        }
        for (int i = 0; i < n; ++i) {
            int s = a[sz(a) - 1] - a[0];
            if (sz(a) == 1) {
                s = a[0];
            }
                s = max(s, -s);
            vector<int> t;
            for (int j = 1; j < sz(a); ++j) {
                t.push_back(a[j] - a[j - 1]);
            }
            a = t;
            ans = max(ans, s);
        }
        cout << ans << '\n';
    }
    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;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define int ll
#define sz(A) ((int)A.size())

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        int n;
        cin >> n;
        vector<int> a(n);
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            ans += a[i];
        }
        for (int i = 0; i < n; ++i) {
            int s = a[sz(a) - 1] - a[0];
            if (sz(a) == 1) {
                s = a[0];
            }
            if (i % 2 == 0 && n != 1) {
                s = max(s, -s);
            }
            vector<int> t;
            for (int j = 1; j < sz(a); ++j) {
                t.push_back(a[j] - a[j - 1]);
            }
            a = t;
            ans = max(ans, s);
        }
        cout << ans << '\n';
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define int ll
#define sz(A) ((int)A.size())

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        int n;
        cin >> n;
        vector<int> a(n);
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            ans += a[i];
        }
        if (n == 1) {
            cout << a[0] << '\n';
            continue;
        }
        for (int i = 0; i < n; ++i) {
            int s = a[sz(a) - 1] - a[0];
            if (sz(a) == 1) {
                s = a[0];
            }
            if (i % 2 == 0) {
                s = max(s, -s);
            }
            vector<int> t;
            for (int j = 1; j < sz(a); ++j) {
                t.push_back(a[j] - a[j - 1]);
            }
            a = t;
            ans = max(ans, s);
        }
        cout << ans << '\n';
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define int ll
#define sz(A) ((int)A.size())

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        int n;
        cin >> n;
        vector<int> a(n);
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            ans += a[i];
        }
        for (int i = 0; i < n - 1; ++i) {
            int s = 0;
            vector<int> t;
            for (int j = 1; j < sz(a); ++j) {
                t.push_back(a[j] - a[j - 1]);
            }
            a = t;
            s = a[sz(a) - 1] - a[0];
            if (sz(a) == 1) {
                s = a[0];
            }
            if (i % 2 == 0) {
                s = max(s, -s);
            }
            ans = max(ans, s);
        }
        cout << ans << '\n';
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

typedef long long ll;
#define nl "\n"

#ifndef ONLINE_JUDGE
#include "debug_template.h"
#else
#define debug(...)
#define debugArr(...)
#endif

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

  int t; cin >> t; while (t--)
  {
    ll n; cin>>n; ll  a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    ll cnt= 0;
    for(int i=2; i<n; i++) {
      if(a[i-1]>a[i-2] && a[i-1]-a[i-2]<=a[i]) {
        cnt++;
        a[i-1]-=a[i-2];
        a[i-2]=0;
      }
    }
    cout<<(cnt==n-2? "YES\n":"No\n");

    debugArr(a,n);

  }
  return 0;
}

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

typedef long long ll;
#define nl "\n"

#ifndef ONLINE_JUDGE
#include "debug_template.h"
#else
#define debug(...)
#define debugArr(...)
#endif

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

  int t; cin >> t; while (t--)
  {
    ll n; cin>>n; ll  a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    ll cnt= 0;
    for(int i=2; i<n; i++) {
      if(a[i-1]>=a[i-2] && a[i-1]-a[i-2]<=a[i]) {
        cnt++;
        a[i-1]-=a[i-2];
        a[i-2]=0;
      }
    }
    cout<<(cnt==n-2? "YES\n":"No\n");

    debugArr(a,n);

  }
  return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

typedef long long ll;
#define nl "\n"

#ifndef ONLINE_JUDGE
#include "debug_template.h"
#else
#define debug(...)
#define debugArr(...)
#endif

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

  int t; cin >> t; while (t--)
  {
    ll n; cin>>n; ll  a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    if(a[0]>a[1]) cout<<"NO"<<nl;
    else {
      for(int i=1; i<n-1; i++) {
        if(a[i]-a[i-1]<a[i+1]) {
          a[i-1]=0;
          a[i]-=a[i-1];
        }
      }
      cout<<(is_sorted(a,a+n)? "YES\n":"No\n");
    }
    

  }
  return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

typedef long long ll;
#define nl "\n"

#ifndef ONLINE_JUDGE
#include "debug_template.h"
#else
#define debug(...)
#define debugArr(...)
#endif

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

  int t; cin >> t; while (t--)
  {
    ll n; cin>>n; ll  a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    if(a[0]>a[1]) cout<<"NO"<<nl;
    else {
      for(int i=1; i<n-1; i++) {
        if(a[i]-a[i-1]<a[i+1]) {
          a[i-1]=0;
          a[i]-=a[i-1];
        }
      }
      cout<<(is_sorted(a,a+n)? "YES\n":"No\n");
    }
    

  }
  return 0;
}

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

typedef long long ll;
#define nl "\n"

#ifndef ONLINE_JUDGE
#include "debug_template.h"
#else
#define debug(...)
#define debugArr(...)
#endif

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

  int t; cin >> t; while (t--)
  {
    ll n; cin>>n; ll  a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    ll cnt= 0;
    for(int i=2; i<n; i++) {
      if(a[i-1]>a[i-2] && a[i-1]-a[i-2]<=a[i]) {
        cnt++;
        a[i-1]-=a[i-2];
        a[i-2]=0;
      }
    }
    cout<<(cnt==n-2? "YES\n":"No\n");

    debugArr(a,n);

  }
  return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

typedef long long ll;
#define nl "\n"

#ifndef ONLINE_JUDGE
#include "debug_template.h"
#else
#define debug(...)
#define debugArr(...)
#endif

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

  int t; cin >> t; while (t--)
  {
    ll n; cin>>n; ll  a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    ll cnt= 0;
    for(int i=2; i<n; i++) {
      if(a[i-1]>=a[i-2] && a[i-1]-a[i-2]<=a[i]) {
        cnt++;
        a[i-1]-=a[i-2];
        a[i-2]=0;
      }
    }
    cout<<(cnt==n-2? "YES\n":"No\n");

    debugArr(a,n);

  }
  return 0;
}

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

typedef long long ll;
#define nl "\n"

#ifndef ONLINE_JUDGE
#include "debug_template.h"
#else
#define debug(...)
#define debugArr(...)
#endif

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

  int t; cin >> t; while (t--)
  {
    ll n; cin>>n; ll  a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    ll cnt= 0;
    for(int i=2; i<n; i++) {
      if(a[i-1]>=a[i-2] && a[i-1]-a[i-2]<=a[i]) {
        cnt++;
        a[i-1]-=a[i-2];
        a[i-2]=0;
      }
    }
    cout<<(is_sorted(a,a+n)? "YES\n":"No\n");

    debugArr(a,n);

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


Submission (verdict: Wrong answer on test 6):
#include <iostream>
#include <fstream>
#include <istream>
#include <cmath>
#include <stack>
#include <climits>
#include <string.h>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;

typedef long long int ll;
#define nl << "\n"
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);
#define all(a) a.begin(), a.end()
#define cnl cout nl
#define YES cout << "YES" nl
#define NO cout << "NO" nl
template <typename... T>
void see(T &...args) {
    ((cin >> args), ...);
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (auto &i : v)
        is >> i;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto &i : v)
        os << i << ' ';
    return os;
}

void solve() {
    ll n; cin >> n;
    vector<ll> v(n); cin >> v;
    if(v.size() == 1) return void(cout << v.front() nl);
    ll best_sum = accumulate(all(v), 0);


    while(v.size() != 1) {
        for(ll i = 0; i < n - 1; i++) {
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
        best_sum = max(best_sum, abs(v.back() - v.front()));
    }
    assert(v.size() == 1);
    cout << max(best_sum, abs(v.front())) nl;
}

int main() {
    IOS
    // ifstream in("in");
    // cin.rdbuf(in.rdbuf()); 
    
    #ifdef LOCAL
    ifstream in("in");
    cin.rdbuf(in.rdbuf());
    #endif

    int t = 1;
    see(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 1):
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int t;
  cin>>t;
  while(t--){
    int n;
    int k;
    cin>>n>>k;
    vector<long long>a(n);
    int i=0;
    unordered_map<long long,int>mp;
    for(i=0;i<n;i++){
      cin>>a[i];
      mp[a[i]]++;
    }
    int c=0;
    for(auto p:mp){
      c++;
    }
    if(c<k)
    cout<<"0"<<endl;
    else
    cout<<(c-k)<<endl;
  }
  return 0;
}

Submission (verdict: Compilation error):
#include <bits/stdc++.h>
#include <unordered_map>
#include <ordered_map>
using namespace std;
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int t;
  cin>>t;
  while(t--){
    int n;
    int k;
    cin>>n>>k;
    vector<long long>a(n);
    int i=0;
    unordered_map<long long,int>mp;
    for(i=0;i<n;i++){
      cin>>a[i];
      mp[a[i]]++;
    }
    ordered_map<int,int>mp1;
    for(auto p:mp){
      mp1[p.second]++;
    }
    int c=0;
    int s=0;
    for(auto it:mp1){
      if((s+(it.first)*(it.second))>k)
      break;
      else
      s+=(it.first)*(it.second);
      c++;
    }
    cout<<(n-c)<<endl;
  }
  return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
#include <unordered_map>
#include <ordered_map>
using namespace std;
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int t;
  cin>>t;
  while(t--){
    int n;
    int k;
    cin>>n>>k;
    vector<long long>a(n);
    int i=0;
    unordered_map<long long,int>mp;
    for(i=0;i<n;i++){
      cin>>a[i];
      mp[a[i]]++;
    }
    ordered_map<int,int>mp1;
    for(auto p:mp){
      mp1[p.second]++;
    }
    int c=0;
    int s=0;
    for(auto it:mp1){
      if((s+(it.first)*(it.second))>k)
      break;
      else
      s+=(it.first)*(it.second);
      c++;
    }
    cout<<(n-c)<<endl;
  }
  return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int t;
  cin>>t;
  while(t--){
    int n;
    int k;
    cin>>n>>k;
    vector<long long>a(n);
    int i=0;
    map<long long,int>mp;
    for(i=0;i<n;i++){
      cin>>a[i];
      mp[a[i]]++;
    }
    if(n==k)
    cout<<"1"<<endl;
    else{
   vector<int>f;
   int c=0;
   f.reserve(n);
   for(auto p:mp){
     f.push_back(p.second);
     c++;
   }
   sort(f.begin(),f.end());
   int s=0;
   int co=0;
   for(i=0;i<c;i++){
    if((s+f[i])<=k){
      s=s+f[i];
      co++;
    }
     else if((s+f[i])>k){
       break;
     }
   }
   cout<<(c-co)<<endl;
    }
  }
  return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int t;
  cin>>t;
  while(t--){
    int n;
    int k;
    cin>>n>>k;
    vector<long long>a(n);
    int i=0;
    unordered_map<long long,int>mp;
    for(i=0;i<n;i++){
      cin>>a[i];
      mp[a[i]]++;
    }
    int c=0;
    for(auto p:mp){
      c++;
    }
    if(c<k)
    cout<<"0"<<endl;
    else
    cout<<(c-k)<<endl;
  }
  return 0;
}