Language: C++

# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
 
int main()
{
  int count;
  cin >> count;
  vector<int> v(count);
  vector<int> vodd(count/2);
  vector<int> voddCount(count/2);
  vector<int> veven(count/2);
  vector<int> vevenCount(count/2);
  
  int oddMax;
  int evenMax;
 
  rep(i, count) {
    cin >> v.at(i);
  }
  
  rep(i, count) {
    if(i%2 == 0){
      veven.at(i/2) = v.at(i);
    } else {
      vodd.at(i/2) = v.at(i);
    }
  }
  
  rep(i, count/2) {
    vevenCount.at(i) = std::count(veven.begin(), veven.end(), veven.at(i));
    voddCount.at(i) = std::count(vodd.begin(), vodd.end(), vodd.at(i));
  }
  
  evenMax = *max_element(vevenCount.begin(), vevenCount.end());
  oddMax = *max_element(voddCount.begin(), voddCount.end());
  
  int e = veven.size() - evenMax;
  int o = vodd.size() - oddMax;
 
  cout <<  e + o << endl;
  
  return 0;
}
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
 
int main()
{
  int count;
  cin >> count;
  vector<int> v(count);
  vector<int> vodd(count/2);
  vector<int> voddCount(count/2);
  vector<int> veven(count/2);
  vector<int> vevenCount(count/2);
  
  int oddMax;
  int evenMax;

  rep(i, count) {
    cin >> v.at(i);
  }
  
  rep(i, count) {
    if(i%2 == 0){
      veven.at(i/2) = v.at(i);
    } else {
      vodd.at(i/2) = v.at(i);
    }
  }
  
  rep(i, count/2) {
    vevenCount.at(i) = std::count(veven.begin(), veven.end(), veven.at(i));
    voddCount.at(i) = std::count(vodd.begin(), vodd.end(), vodd.at(i));
  }
  
  evenMax = *max_element(vevenCount.begin(), vevenCount.end());
  oddMax = *max_element(voddCount.begin(), voddCount.end());
  
  int e = veven.size() - evenMax;
  int o = vodd.size() - oddMax;

  cout <<  e + o << endl;
  
  return 0;
}

Compiler output:
a.cc:66:23: error: redefinition of 'template<class T> bool chmax(T&, const T&)'
   66 | template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
      |                       ^~~~~
a.cc:12:23: note: 'template<class T> bool chmax(T&, const T&)' previously declared here
   12 | template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
      |                       ^~~~~
a.cc:67:23: error: redefinition of 'template<class T> bool chmin(T&, const T&)'
   67 | template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
      |                       ^~~~~
a.cc:13:23: note: 'template<class T> bool chmin(T&, const T&)' previously declared here
   13 | template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
      |                       ^~~~~
a.cc:69:5: error: redefinition of 'int main()'
   69 | int main()
      |     ^~~~
a.cc:15:5: note: 'int main()' previously defined here
   15 | int main()
      |     ^~~~