Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int n;
    cin>>n;
    int v[n];
    map<int,int> g;
    map<int,int> k;
    rep(i,n) {
        cin>>v[i];
        if(i%2==0) g[v[i]]++;
        else k[v[i]]++;
    }
    int cg=0,ck=0,cga,cka,cgs=0,cks=0;
    bool zg=false,zs=false;
    for(auto p:g){
        cg=max(cg,p.second);

        if(cg==p.second) cga=p.first;
    }
    for(auto p:k){
        ck=max(ck,p.second);
        if(ck==p.second) cka=p.first;
    }
    if(cga!=cka) cout << n-cg-ck << endl;
    else{
        for(auto p:g){
            if(p.first==cga) continue;
            cgs=max(cgs,p.second);

        }
        for(auto p:k){
            if(p.first==cga) continue;
            cks=max(cks,p.second);
        }
        if(ck-cks>=cg-cgs) cout << n-ck-cgs << endl;
        else cout << n-cg-cks << endl;
    }



}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int n;
    cin>>n;
    int v[n];
    map<int,int> g;
    map<int,int> k;
    rep(i,n) {
        cin>>v[i];
        if(i%2==0) g[v[i]]++;
        else k[v[i]]++;
    }
    int cg=0,ck=0,cga,cka,cgs=0,cks=0;
    bool zg=false,zs=false;
    for(auto p:g){
        cg=max(cg,p.second);

        if(cg==p.second) cga=p.first;
    }
    for(auto p:k){
        ck=max(ck,p.second);
        if(ck==p.second) cka=p.first;
    }
    if(cga!=cka) cout << n-cg-ck << endl;
    else{
        for(auto p:g){
            if(p.first==cga) continue;
            cgs=max(cgs,p.second);

        }
        for(auto p:k){
            if(p.first==cga) continue;
            cks=max(cks,p.second);
        }
        if(ck-cks>=cg-cgs) cout << n-ck-cgs << endl;
        else cout << n-cg-cks << endl;
    }



}


Compiler output:
a.cc:61:15: error: redefinition of 'constexpr const long long int INF'
   61 | constexpr int INF = numeric_limits<int>::max() / 2;
      |               ^~~
a.cc:6:15: note: 'constexpr const long long int INF' previously defined here
    6 | constexpr int INF = numeric_limits<int>::max() / 2;
      |               ^~~
a.cc:62:21: error: redefinition of 'constexpr const long long int INFL'
   62 | constexpr long long INFL = numeric_limits<long long>::max() / 2;
      |                     ^~~~
a.cc:7:21: note: 'constexpr const long long int INFL' previously defined here
    7 | constexpr long long INFL = numeric_limits<long long>::max() / 2;
      |                     ^~~~
a.cc:63:15: error: redefinition of 'constexpr const long long int MOD'
   63 | constexpr int MOD = 1000000007;
      |               ^~~
a.cc:8:15: note: 'constexpr const long long int MOD' previously defined here
    8 | constexpr int MOD = 1000000007;
      |               ^~~
a.cc:68:8: error: redefinition of 'int main()'
   68 | signed main() {
      |        ^~~~
a.cc:13:8: note: 'int main()' previously defined here
   13 | signed main() {
      |        ^~~~