Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int N;
    vector<int> V;
    cin >> N;
    V.resize(N);
    REP(i, N) {
        cin >> V[i];
    }

    // key: 数, val: 出現数
    map<int, int> even, odd;
    REP(i, N) {
        if(i % 2 == 0) {
            even[V[i]]++;
        }
        else {
            odd[V[i]]++;
        }
    }

    vector< pair<int, int> > v_even, v_odd;


    for(auto& tmp : even) {
        v_even.push_back(make_pair(tmp.second, tmp.first));
    }
    v_even.push_back(make_pair(0, -1));
    for(auto& tmp : odd) {
        v_odd.push_back(make_pair(tmp.second, tmp.first));
    }
    v_odd.push_back(make_pair(0, -1));
    SORT(v_even);
    reverse(v_even.begin(), v_even.end());
    SORT(v_odd);
    reverse(v_odd.begin(), v_odd.end());

    int ans = N;

    REP(i, min(10, v_even.size())) {
        REP(j, min(10, v_odd.size())) {
            if(v_even[i].second != v_odd[j].second) {
                ans = min(ans, N - v_even[i].first - v_odd[j].first);
            }
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:15: error: no matching function for call to 'min(int, std::vector<std::pair<long long int, long long int> >::size_type)'
   65 |     REP(i, min(10, v_even.size())) {
      |            ~~~^~~~~~~~~~~~~~~~~~~
a.cc:7:32: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0;i<n;++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:65:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'})
   65 |     REP(i, min(10, v_even.size())) {
      |            ~~~^~~~~~~~~~~~~~~~~~~
a.cc:7:32: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0;i<n;++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:65:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   65 |     REP(i, min(10, v_even.size())) {
      |            ~~~^~~~~~~~~~~~~~~~~~~
a.cc:7:32: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0;i<n;++i)
      |                                ^
a.cc:66:19: error: no matching function for call to 'min(int, std::vector<std::pair<long long int, long long int> >::size_type)'
   66 |         REP(j, min(10, v_odd.size())) {
      |                ~~~^~~~~~~~~~~~~~~~~~
a.cc:7:32: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0;i<n;++i)
      |                                ^
/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:66:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'})
   66 |         REP(j, min(10, v_odd.size())) {
      |                ~~~^~~~~~~~~~~~~~~~~~
a.cc:7:32: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0;i<n;++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
/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:66:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   66 |         REP(j, min(10, v_odd.size())) {
      |                ~~~^~~~~~~~~~~~~~~~~~
a.cc:7:32: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0;i<n;++i)
      |                                ^