Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

map<int,int> memo;
int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K;cin >> N >> K;
  int x;
  rep(i,N){
    cin >> x;
    memo[x]++;
  }
  vector<PII> v(memo.size());
  int index = 0;
  for(auto itr = memo.begin(), m_end = memo.end(); itr != m_end; ++itr){
    v[index] = PII(itr->second,itr->first);
    ++index;
  }
  sort(all(v),greater<PII>());
  int count = 0;
  rep(i,min(v.size(),K)) count+= v[i].first;
  cout << N - count << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:12: error: no matching function for call to 'min(std::vector<std::pair<int, int> >::size_type, int&)'
   50 |   rep(i,min(v.size(),K)) count+= v[i].first;
      |         ~~~^~~~~~~~~~~~
a.cc:3:39: note: in definition of macro 'rep'
    3 | #define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
      |                                       ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:50:12: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   50 |   rep(i,min(v.size(),K)) count+= v[i].first;
      |         ~~~^~~~~~~~~~~~
a.cc:3:39: note: in definition of macro 'rep'
    3 | #define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
      |                                       ^
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:50:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   50 |   rep(i,min(v.size(),K)) count+= v[i].first;
      |         ~~~^~~~~~~~~~~~
a.cc:3:39: note: in definition of macro 'rep'
    3 | #define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
      |                                       ^