Language: C++

#include <bits/stdc++.h>
// #include <boost/functional/hash.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

#define debug 0
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define urep(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define drep(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) urep(i,0,(n) - 1)
#define rep1(i,n) urep(i,1,(n))
#define rrep(i,n) drep(i,(n) - 1,0)
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define rsz resize
#define era erase
#define emp emplace
#define emf emplace_front
#define emb emplace_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define odd(x) ((x) & 1)
#define even(x) (~(x) & 1)

using namespace std;

// typedef boost::multiprecision::cpp_int mlint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vct<vct<ll>> mat;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef map<int,int> mpii;
typedef unordered_map<int,int> umpii;

const int dir[8][2] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const ll inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;
const ll mod = 1e9 + 7;
const db eps = 1e-9;

template <class T, class U> T qceil(T x, U y) { return x > 0 ? (x - 1) / y + 1 : x / y; }
template <class T, class U> bool parity(T x, U y) { return odd(x) ^ even(y); }
template <class T, class U> bool chmax(T &m, U x) { if(m < x) { m = x; return 1; } return 0; }
template <class T, class U> bool chmin(T &m, U x) { if(m > x) { m = x; return 1; } return 0; }
template <class T> bool cmprs(T &v) {
    T tmp = v;
    sort(all(tmp));
    tmp.erase(unique(all(tmp)),end(tmp));
    for(auto it = begin(v); it != end(v); ++it) *it = l_bnd(all(tmp),*it) - begin(tmp) + 1;
    return v.size() > tmp.size();
}
mat mulmat(mat &x, mat &y, ll md = mod) {
    int xrow = x.size();
    int xcol = x[0].size();
    int ycol = y[0].size();
    mat ret(xrow,vct<ll>(ycol));
    rep(i,xrow)rep(j,ycol)rep(k,xcol) ret[i][j] += x[i][k] * y[k][j] % md,ret[i][j] %= md;
    return ret;
}

template<class T> T gcd(T a, T b){ if(a % b) return gcd(b, a % b); return b; }

/*ll modpow(ll n, ll e, ll md = mod) {
    n %= md;
    if(!n) return 0;
    e %= md - 1;
    ll ret = 1;
    while(e) {
        if(e & 1) ret = ret * n % md;
        n = n * n % md;
        e /= 2;
    }
    return ret;
}*/

ll modpow(ll n, ull e, ll md = mod) {
    n %= md;
    if(!e) return 0;
    return modpow(n * n % md,e / 2,md) * (e & 1 ? n : 1) % md;
}

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

    int n;
    int v[100010];
    cin>>n;
    rep(i,n) cin>>v[i];
    int mx1=0,memo[100010]={},now1;
    rep(i,n/2){
        int j = 2*i;
        ++memo[v[j]];
        if(chmax(mx,memo[v[j]])) now1=v[j];
    }
    sort(rall(memo));
    int mx2=0,now2;
    int memo2[100010]={};
    rep(i,n/2){
        int j = 2*i+1;
        if(chmax(mx2,++memo2[v[j]]) now2=v[j];
    }
    sort(rall(memo2));
    if(now1!=now2) esc(n-mx1-mx2);
    esc(n-max(memo[0]+memo2[1],memo2[0]+memo[1]));
}


Compiler output:
a.cc: In function 'int main()':
a.cc:104:18: error: 'mx' was not declared in this scope; did you mean 'mx1'?
  104 |         if(chmax(mx,memo[v[j]])) now1=v[j];
      |                  ^~
      |                  mx1
a.cc:111:36: error: expected ';' before 'now2'
  111 |         if(chmax(mx2,++memo2[v[j]]) now2=v[j];
      |                                    ^~~~~
      |                                    ;
a.cc:112:5: error: expected primary-expression before '}' token
  112 |     }
      |     ^
a.cc:111:47: error: expected ')' before '}' token
  111 |         if(chmax(mx2,++memo2[v[j]]) now2=v[j];
      |           ~                                   ^
      |                                               )
  112 |     }
      |     ~                                          
a.cc:112:5: error: expected primary-expression before '}' token
  112 |     }
      |     ^