ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 7):
// Problem: D. Kevin and Numbers
// Contest: Codeforces - IAEPC Preliminary Contest (Codeforces Round 999, Div. 1 + Div. 2)
// URL: https://codeforces.com/contest/2061/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//空中散歩の SOS 僕ファー　僕ファー　僕ファー ~
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
const ll maxn=2e5+5;
multiset<ll>s;
ll a[maxn],tot;
ll n,m;
set<ll>vis;
bool check(ll x){
	if(vis.count(x))return 0;
	if(s.count(x)){
		s.erase(s.find(x));
		return 1;
	}
	if(x==1)return 0;
	bool res=1;
	res&=check(x/2);
	res&=check(x/2+(x&1));
	if(res==0)vis.insert(x);
	return res;
}
void solve(){
	cin>>n>>m;
	s.clear();
	vis.clear();
	tot=0;
	for(ll i=1;i<=n;i++){
		ll x;
		cin>>x;
		s.insert(x);
	}
	for(ll i=1;i<=m;i++){
		ll x;
		cin>>x;
		if(s.count(x)){
			s.erase(s.find(x));
			continue;
		}
		a[++tot]=x;
	}
	m=tot;
	sort(a+1,a+1+m);
	for(ll i=1;i<=m;i++){
		if(!check(a[i])){
			cout<<"No"<<endl;
			return ;
		}
	}
	if(s.empty())cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return ;
}
ll T=1;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>T;
	for(ll kase=1;kase<=T;kase++){
		solve();
	}
	return 0;
}

Submission (verdict: Accepted):
// Problem: D. Kevin and Numbers
// Contest: Codeforces - IAEPC Preliminary Contest (Codeforces Round 999, Div. 1 + Div. 2)
// URL: https://codeforces.com/contest/2061/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//空中散歩の SOS 僕ファー　僕ファー　僕ファー ~
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
const ll maxn=2e5+5;
map<ll,ll>s;
ll a[maxn],tot;
ll n,m;
bool check(ll x){
	// cerr<<x<<endl;
	if(s[x]){
		s[x]--;
		n--;
		return 1;
	}
	if(x==1)return 0;
	bool res=1;
	res&=check(x/2);
	if(!res)return 0;
	res&=check(x/2+(x&1));
	return res;
}
void solve(){
	cin>>n>>m;
	s.clear();
	tot=0;
	for(ll i=1;i<=n;i++){
		ll x;
		cin>>x;
		s[x]++;
	}
	for(ll i=1;i<=m;i++){
		ll x;
		cin>>x;
		a[i]=x;
	}
	sort(a+1,a+1+m);
	for(ll i=1;i<=m;i++){
		if(!check(a[i])){
			cout<<"No"<<endl;
			return ;
		}
	}
	if(!n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return ;
}
ll T=1;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>T;
	for(ll kase=1;kase<=T;kase++){
		solve();
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
// Problem: D. Kevin and Numbers
// Contest: Codeforces - IAEPC Preliminary Contest (Codeforces Round 999, Div. 1 + Div. 2)
// URL: https://codeforces.com/contest/2061/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//空中散歩の SOS 僕ファー　僕ファー　僕ファー ~
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
const ll maxn=2e5+5;
multiset<ll>s;
ll a[maxn],tot;
ll n,m;
void solve(){
	cin>>n>>m;
	s.clear();
	tot=0;
	for(ll i=1;i<=n;i++){
		ll x;
		cin>>x;
		s.insert(x);
	}
	for(ll i=1;i<=m;i++){
		ll x;
		cin>>x;
		if(s.count(x)){
			s.erase(s.find(x));
			continue;
		}
		a[++tot]=x;
	}
	m=tot;
	sort(a+1,a+1+m);
	for(ll i=1;i<=m;i++){
		if(s.empty()){
			cout<<"No"<<endl;
			return ;
		}
		ll sum=0;
		while(sum<a[i]&&(!s.empty())){
			auto it=s.lower_bound(sum);
			if(it==s.end())break;
			if(sum!=0&&*it-sum>1)break;
			sum+=*it;
			s.erase(it);
		}
		if(sum!=a[i]){
			cout<<"No"<<endl;
			return ;
		}
	}
	if(s.empty())cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return ;
}
ll T=1;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>T;
	for(ll kase=1;kase<=T;kase++){
		solve();
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
// Problem: D. Kevin and Numbers
// Contest: Codeforces - IAEPC Preliminary Contest (Codeforces Round 999, Div. 1 + Div. 2)
// URL: https://codeforces.com/contest/2061/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//空中散歩の SOS 僕ファー　僕ファー　僕ファー ~
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
const ll maxn=2e5+5;
multiset<ll>s;
ll a[maxn],tot;
ll n,m;
void solve(){
	cin>>n>>m;
	s.clear();
	tot=0;
	for(ll i=1;i<=n;i++){
		ll x;
		cin>>x;
		s.insert(x);
	}
	for(ll i=1;i<=m;i++){
		ll x;
		cin>>x;
		if(s.count(x)){
			s.erase(s.find(x));
			continue;
		}
		a[++tot]=x;
	}
	m=tot;
	sort(a+1,a+1+m);
	for(ll i=1;i<=m;i++){
		if(s.empty()){
			cout<<"No"<<endl;
			return ;
		}
		ll sum=0;
		while(sum<a[i]&&(!s.empty())){
			auto it=s.lower_bound(sum);
			if(it==s.end())break;
			if(sum!=0&&*it-sum>1)break;
			sum+=*it;
			s.erase(it);
		}
		if(sum!=a[i]){
			cout<<"No"<<endl;
			return ;
		}
	}
	if(s.empty())cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return ;
}
ll T=1;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>T;
	for(ll kase=1;kase<=T;kase++){
		solve();
	}
	return 0;
}

Submission (verdict: Time limit exceeded on test 7):
// Problem: D. Kevin and Numbers
// Contest: Codeforces - IAEPC Preliminary Contest (Codeforces Round 999, Div. 1 + Div. 2)
// URL: https://codeforces.com/contest/2061/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//空中散歩の SOS 僕ファー　僕ファー　僕ファー ~
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
const ll maxn=2e5+5;
multiset<ll>s;
ll a[maxn],tot;
ll n,m;
set<ll>vis;
bool check(ll x){
	if(vis.count(x))return 0;
	if(s.count(x)){
		s.erase(s.find(x));
		return 1;
	}
	if(x==1)return 0;
	bool res=1;
	res&=check(x/2);
	res&=check(x/2+(x&1));
	if(res==0)vis.insert(x);
	return res;
}
void solve(){
	cin>>n>>m;
	s.clear();
	vis.clear();
	tot=0;
	for(ll i=1;i<=n;i++){
		ll x;
		cin>>x;
		s.insert(x);
	}
	for(ll i=1;i<=m;i++){
		ll x;
		cin>>x;
		if(s.count(x)){
			s.erase(s.find(x));
			continue;
		}
		a[++tot]=x;
	}
	m=tot;
	sort(a+1,a+1+m);
	for(ll i=1;i<=m;i++){
		if(!check(a[i])){
			cout<<"No"<<endl;
			return ;
		}
	}
	if(s.empty())cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return ;
}
ll T=1;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>T;
	for(ll kase=1;kase<=T;kase++){
		solve();
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


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

using namespace std;



#define ll long long

#define db long double

#define vii vector<ll>

#define pll pair<ll, ll>

#define F first

#define S second





const ll N = (ll) 3e5 + 5;

const ll mod = (ll) 1e9 + 7;

const ll inf = (ll) 1e18;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    int t = 1;

    cin >> t;

    while(t--) {

        ll a, b, c, i, j, k, m, n, o, x, y, z;

        bool ok = true;

        cin >> n >> m;

        multiset<ll> sta, stb;

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

            cin >> a;

            sta.insert(a);

        }

        for(i = 0; i < m; i++) {

            cin >> b;

            stb.insert(b);

        }



        while(ok && sta.size() && stb.size()) {

            ll ca = *sta.begin();

            ll cb = *stb.begin();

            if(ca == cb) {

                sta.erase(sta.begin());

                stb.erase(stb.begin());

            } else if(ca < cb) {

                sta.erase(sta.begin());

                if(sta.size()) {

                    ll na = *sta.begin();

                    if(na <= ca + 1) {

                        sta.erase(sta.begin());

                        sta.insert(ca + na);

                    } else {

                        ok = false;

                    }

                } else {

                    ok = false;

                }

            } else {

                ok = false;

            }

        }

        ok &= (sta.size() == 0 && stb.size() == 0);

        cout << (ok ? "YES" : "NO") << "\n";

    }

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>

#include<iomanip>

#include<climits>

// INT_MAX LLONG_MAX

#include <vector>

#include<array>

#include<queue>

#include<stack>

#include<set>

#include<unordered_set>

#include<map>

#include<unordered_map>

#include<cstring>

#include<cmath>

#include <algorithm>

using namespace std;

#define endl "\n"

#define rep(i,a,b) for(int i=(a);i<(b);i++)

#define ffor(i,a,b) for(int i=(a);i<=(b);i++)

#define rfor(i,a,b) for(int i=(a);i>=(b);i--)

#define fios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define int long long

#define yes cout<<"Yes"<<endl;

#define no cout<<"No"<<endl;

#define DEBUG cout<<">>>>"<<endl;

using vi=vector<int>;

template<size_t N>

using ai = array<int, N>;

using pii=pair<int,int>;

typedef long long LL;

const int inf=1e18;

const int CJR=998244353;

const int HY_Spark=1e9+7;





void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	vi a (n+1,0);

	ffor(i,1,n-1){

		a[i]=a[i-1]^1;

	}

	if(n%2){

		a[n]=2;

	}else{

		a[n]=1;

	}

	if(a[x]==a[y]){

		if(x==1 && a[n]==2){

			swap(a[1],a[n]);

		}else{

			a[x]=2;

		}

	}

	ffor(i,1,n){

		cout<<a[i]<<" ";

	}

	cout<<endl;

}





signed main(){

    fios;

    int _=1;

    cin>>_;

    while(_--){

        solve();

    }

}

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

#include<iomanip>

#include<climits>

// INT_MAX LLONG_MAX

#include <vector>

#include<array>

#include<queue>

#include<stack>

#include<set>

#include<unordered_set>

#include<map>

#include<unordered_map>

#include<cstring>

#include<cmath>

#include <algorithm>

using namespace std;

#define endl "\n"

#define rep(i,a,b) for(int i=(a);i<(b);i++)

#define ffor(i,a,b) for(int i=(a);i<=(b);i++)

#define rfor(i,a,b) for(int i=(a);i>=(b);i--)

#define fios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define int long long

#define yes cout<<"Yes"<<endl;

#define no cout<<"No"<<endl;

#define DEBUG cout<<">>>>"<<endl;

using vi=vector<int>;

template<size_t N>

using ai = array<int, N>;

using pii=pair<int,int>;

typedef long long LL;

const int inf=1e18;

const int CJR=998244353;

const int HY_Spark=1e9+7;





void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	vi a (n+1,0);

	ffor(i,2,n-1){

		a[i]=a[i-1]^1;

	}

	if(n%2){

		a[n]=2;

	}else{

		a[n]=1;

	}

	if(a[x]==a[y]){

		if(x==1 && a[n]==2){

			swap(a[1],a[n]);

		}else{

			a[x]=2;

		}

	}

	ffor(i,1,n){

		cout<<a[i]<<" ";

	}

	cout<<endl;

}





signed main(){

    fios;

    int _=1;

    cin>>_;

    while(_--){

        solve();

    }

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>

#include<iomanip>

#include<climits>

// INT_MAX LLONG_MAX

#include <vector>

#include<array>

#include<queue>

#include<stack>

#include<set>

#include<unordered_set>

#include<map>

#include<unordered_map>

#include<cstring>

#include<cmath>

#include <algorithm>

using namespace std;

#define endl "\n"

#define rep(i,a,b) for(int i=(a);i<(b);i++)

#define ffor(i,a,b) for(int i=(a);i<=(b);i++)

#define rfor(i,a,b) for(int i=(a);i>=(b);i--)

#define fios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define int long long

#define yes cout<<"Yes"<<endl;

#define no cout<<"No"<<endl;

#define DEBUG cout<<">>>>"<<endl;

using vi=vector<int>;

template<size_t N>

using ai = array<int, N>;

using pii=pair<int,int>;

typedef long long LL;

const int inf=1e18;

const int CJR=998244353;

const int HY_Spark=1e9+7;





void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	vi a (n+1,0);

	ffor(i,1,n-1){

		a[i]=a[i-1]^1;

	}

	if(n%2){

		a[n]=2;

	}else{

		a[n]=1;

	}

	if(a[x]==a[y]){

		if(x==1 && a[n]==2){

			swap(a[1],a[n]);

		}else{

			a[1]=2;

		}

	}

	ffor(i,1,n){

		cout<<a[i]<<" ";

	}

	cout<<endl;

}





signed main(){

    fios;

    int _=1;

    cin>>_;

    while(_--){

        solve();

    }

}

Submission (verdict: Wrong answer on test 1):
#include <iostream>

#include<iomanip>

#include<climits>

// INT_MAX LLONG_MAX

#include <vector>

#include<array>

#include<queue>

#include<stack>

#include<set>

#include<unordered_set>

#include<map>

#include<unordered_map>

#include<cstring>

#include<cmath>

#include <algorithm>

using namespace std;

#define endl "\n"

#define rep(i,a,b) for(int i=(a);i<(b);i++)

#define ffor(i,a,b) for(int i=(a);i<=(b);i++)

#define rfor(i,a,b) for(int i=(a);i>=(b);i--)

#define fios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define int long long

#define yes cout<<"Yes"<<endl;

#define no cout<<"No"<<endl;

#define DEBUG cout<<">>>>"<<endl;

using vi=vector<int>;

template<size_t N>

using ai = array<int, N>;

using pii=pair<int,int>;

typedef long long LL;

const int inf=1e18;

const int CJR=998244353;

const int HY_Spark=1e9+7;





void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	vi a (n+1,0);

	ffor(i,1,n-1){

		a[i]=a[i-1]^1;

	}

	if(n%2){

		a[n]=2;

	}else{

		a[n]=1;

	}

	if(a[x]==a[y]){

		if(x==1 && a[n]==2){

			swap(a[1],a[n]);

		}else{

			a[x]=2;

		}

	}

	ffor(i,1,n){

		cout<<a[i]<<" ";

	}

	cout<<endl;

}





signed main(){

    fios;

    int _=1;

    cin>>_;

    while(_--){

        solve();

    }

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <iostream>

#include<iomanip>

#include<climits>

// INT_MAX LLONG_MAX

#include <vector>

#include<array>

#include<queue>

#include<stack>

#include<set>

#include<unordered_set>

#include<map>

#include<unordered_map>

#include<cstring>

#include<cmath>

#include <algorithm>

using namespace std;

#define endl "\n"

#define rep(i,a,b) for(int i=(a);i<(b);i++)

#define ffor(i,a,b) for(int i=(a);i<=(b);i++)

#define rfor(i,a,b) for(int i=(a);i>=(b);i--)

#define fios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define int long long

#define yes cout<<"Yes"<<endl;

#define no cout<<"No"<<endl;

#define DEBUG cout<<">>>>"<<endl;

using vi=vector<int>;

template<size_t N>

using ai = array<int, N>;

using pii=pair<int,int>;

typedef long long LL;

const int inf=1e18;

const int CJR=998244353;

const int HY_Spark=1e9+7;





void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	vi a (n+1,0);

	ffor(i,1,n-1){

		a[i]=a[i-1]^1;

	}

	if(n%2){

		a[n]=2;

	}else{

		a[n]=1;

	}

	if(a[x]==a[y]){

		if(x==1 && a[n]==2){

			swap(a[1],a[n]);

		}else{

			a[1]=2;

		}

	}

	ffor(i,1,n){

		cout<<a[i]<<" ";

	}

	cout<<endl;

}





signed main(){

    fios;

    int _=1;

    cin>>_;

    while(_--){

        solve();

    }

}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for (ll i = 0; i < n; i++)
#define forj(n) for (ll j = 0; j < n; j++)
#define fork(n) for (ll k = 0; k < n; k++)
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define v(n) vector<ll> a(n)
#define v1(n) vector<ll> b(n)
using namespace std;

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll n,k;
        cin >> n >> k;
        v(n);
        map<ll,ll>m;
        fori(n) {
            cin >> a[i];
            m[a[i]]++;
        }
        ll maxi = 0,val=0;
        for(auto it : m){
            if(it.second>maxi){
                maxi=it.second;
                val = it.first;
            }
        }
        // cout << "val " << val << endl;
        
        if(k==0){
            cout << m.size() << endl;
        }
        // if(k==n){
        //     cout << k << endl;
        // }
        else{
            ll count=0;
            ll i=0;
            while(i<n){
                if(a[i]!=val){
                    count++;
                    i+=k;
                }else i++;
            }
            cout << count << endl;
        }
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for (ll i = 0; i < n; i++)
#define forj(n) for (ll j = 0; j < n; j++)
#define fork(n) for (ll k = 0; k < n; k++)
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define v(n) vector<ll> a(n)
#define v1(n) vector<ll> b(n)
using namespace std;

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll n, k;
        cin >> n >> k;
        v(n);
        map<ll, ll> m;
        if (k == n)
        {
            cout << 1 << endl;
            continue;
        }
        fori(n)
        {
            cin >> a[i];
            m[a[i]]++;
        }
        ll maxi = 0, val = 0;
        for (auto it : m)
        {
            if (it.second > maxi)
            {
                maxi = it.second;
                val = it.first;
            }
        }
        // cout << "val " << val << endl;
        // cout <<"size" <<  m.size() << endl;
        if (k == 0)
        {
            cout << m.size() << endl;
        }
        else
        {
            if (m.size() == 1)
            {
                cout << 1 << endl;
            }
            else
            {
                ll count = 0;
                ll i = 0;
                while (i < n)
                {
                    if (a[i] != val)
                    {
                        count++;
                        i += k;
                    }
                    else
                        i++;
                }
                cout << count << endl;
            }
        }
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for (ll i = 0; i < n; i++)
#define forj(n) for (ll j = 0; j < n; j++)
#define fork(n) for (ll k = 0; k < n; k++)
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define v(n) vector<ll> a(n)
#define v1(n) vector<ll> b(n)
using namespace std;

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll n, k;
        cin >> n >> k;
        v(n);
        map<ll, ll> m;
        fori(n)
        {
            cin >> a[i];
            m[a[i]]++;
        }
        if (k >= n)
        {
            cout << 1 << endl;
            continue;
        }
        vector<ll> ans;
        for (auto it : m) ans.push_back(it.second);
        sort(ans.begin(), ans.end());
        ll i = 0;
        for (i = 0; i < ans.size() && k > 0; i++)
        {
            k -= ans[i];
        }

        if (k == 0) cout << ans.size() - i << endl;
        else cout << ans.size() - i + 1 << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for (ll i = 0; i < n; i++)
#define forj(n) for (ll j = 0; j < n; j++)
#define fork(n) for (ll k = 0; k < n; k++)
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define v(n) vector<ll> a(n)
#define v1(n) vector<ll> b(n)
using namespace std;

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll n,k;
        cin >> n >> k;
        v(n);
        map<ll,ll>m;
        if(k==n){
            cout << 1 << endl;
            continue;
        }
        fori(n) {
            cin >> a[i];
            m[a[i]]++;
        }
        ll maxi = 0,val=0;
        for(auto it : m){
            if(it.second>maxi){
                maxi=it.second;
                val = it.first;
            }
        }
        // cout << "val " << val << endl;
        
        if(k==0){
            cout << m.size() << endl;
        }
        else{
            ll count=0;
            ll i=0;
            while(i<n){
                if(a[i]!=val){
                    count++;
                    i+=k;
                }else i++;
            }
            cout << count << endl;
        }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for (ll i = 0; i < n; i++)
#define forj(n) for (ll j = 0; j < n; j++)
#define fork(n) for (ll k = 0; k < n; k++)
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define v(n) vector<ll> a(n)
#define v1(n) vector<ll> b(n)
using namespace std;

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll n, k;
        cin >> n >> k;
        v(n);
        map<ll, ll> m;
        if (k == n)
        {
            cout << 1 << endl;
            continue;
        }
        fori(n)
        {
            cin >> a[i];
            m[a[i]]++;
        }
        ll maxi = 0, val = 0;
        for (auto it : m)
        {
            if (it.second > maxi)
            {
                maxi = it.second;
                val = it.first;
            }
        }
        // cout << "val " << val << endl;
        // cout <<"size" <<  m.size() << endl;
        if (k == 0)
        {
            cout << m.size() << endl;
        }
        else
        {
            if (m.size() == 1)
            {
                cout << 1 << endl;
            }
            else
            {
                ll count = 0;
                ll i = 0;
                while (i < n)
                {
                    if (a[i] != val)
                    {
                        count++;
                        i += k;
                    }
                    else
                        i++;
                }
                cout << count << endl;
            }
        }
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for (ll i = 0; i < n; i++)
#define forj(n) for (ll j = 0; j < n; j++)
#define fork(n) for (ll k = 0; k < n; k++)
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define v(n) vector<ll> a(n)
#define v1(n) vector<ll> b(n)
using namespace std;

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll n,k;
        cin >> n >> k;
        v(n);
        map<ll,ll>m;
        fori(n) {
            cin >> a[i];
            m[a[i]]++;
        }
        ll maxi = 0,val=0;
        for(auto it : m){
            if(it.second>maxi){
                maxi=it.second;
                val = it.first;
            }
        }
        // cout << "val " << val << endl;
        
        if(k==0){
            cout << m.size() << endl;
        }
        // if(k==n){
        //     cout << k << endl;
        // }
        else{
            ll count=0;
            ll i=0;
            while(i<n){
                if(a[i]!=val){
                    count++;
                    i+=k;
                }else i++;
            }
            cout << count << endl;
        }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for (ll i = 0; i < n; i++)
#define forj(n) for (ll j = 0; j < n; j++)
#define fork(n) for (ll k = 0; k < n; k++)
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define v(n) vector<ll> a(n)
#define v1(n) vector<ll> b(n)
using namespace std;

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll n,k;
        cin >> n >> k;
        v(n);
        map<ll,ll>m;
        if(k==n){
            cout << 1 << endl;
            continue;
        }
        fori(n) {
            cin >> a[i];
            m[a[i]]++;
        }
        ll maxi = 0,val=0;
        for(auto it : m){
            if(it.second>maxi){
                maxi=it.second;
                val = it.first;
            }
        }
        // cout << "val " << val << endl;
        
        if(k==0){
            cout << m.size() << endl;
        }
        else{
            ll count=0;
            ll i=0;
            while(i<n){
                if(a[i]!=val){
                    count++;
                    i+=k;
                }else i++;
            }
            cout << count << endl;
        }
    }
    return 0;
}