Language: C++

////////////////////////////////////////////////
//                                            //
//  Author: Muhammad Faishol Amirul Mukminin  //
//                                            //
////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef pair<ll,ll> pl;
typedef pair<pl,ll> pll;
typedef pair<double,double> pd;
typedef pair<pd,double> pdd;
typedef pair<string, int> psi;
 
#define FOR(i,x,y) for(int i=(x);i<(y);i++)
#define FORN(i,x,y) for(int i=(x);i<=(y);i++)
#define REV(i,a,b) for(int i=(a);i>(b);i--)
#define REVN(i,a,b) for(int i=(a);i>=(b);i--)
#define BTW(i,a,b) a <= i && i <= b
 
#define DB(x) cerr << #x << ": " << x << endl;
 
#define fi first
#define se second
#define PUB push_back
#define POB pop_back
#define PUF push_front
#define POF pop_front
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
 
const double EPS = 1e-9;
const double PI = acos(-1);
const ll MOD = 1e9+7;
const int INF = 0x7FFFFFFF;
const ll LINF = 0x7FFFFFFFFFFFFFFFLL;
const ull UINF = 0xFFFFFFFFFFFFFFFFLL;
const int dCol[] = {0,+1,0,-1,+1,+1,-1,-1};
const int dRow[] = {-1,0,+1,0,-1,+1,+1,-1};
 
template <typename T>
inline void VIN(vector<T> &i){ T x; cin >> x; i.PUB(x); }
inline void FIO(string i){ freopen((i+".in").c_str(), "r", stdin); freopen((i+".out").c_str(), "w", stdout);}
 
 
int N, ans = 0;
int data[100005];
int frek[2][100005];
vector<pi> gtw[2];
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> N;
	FOR(i,0,N) cin >> data[i];
	FOR(i,0,2) for(int j=i;j<N;j+=2){
		frek[i][data[j]]++;
	}

	for(int i=1;i<=100000;i++){
		if(frek[0][i] > 0) gtw[0].PUB({frek[0][i], i});
		if(frek[1][i] > 0) gtw[1].PUB({frek[1][i], i});
	}
	
	FOR(i,0,2) sort(gtw[i].begin(), gtw[i].end(), greater<pi>());
	//for(auto elm:gtw[0]) cout << elm.fi << " " << elm.se << endl;

	if(gtw[0][0].se == gtw[1][0].se){
		ans = max(gtw[0].front(), gtw[1].front());
		if(gtw[1].size() > 1) ans = max(ans, gtw[0][0].fi+gtw[1][1].fi);
		if(gtw[0].size() > 1) ans = max(ans, gtw[0][1].fi+gtw[1][0].fi);
	}else{
		ans = gtw[0][0].fi+gtw[1][0].fi;
	}

	cout << N-ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:27: error: reference to 'data' is ambiguous
   58 |         FOR(i,0,N) cin >> data[i];
      |                           ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:6:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:51:5: note:                 'int data [100005]'
   51 | int data[100005];
      |     ^~~~
a.cc:60:25: error: reference to 'data' is ambiguous
   60 |                 frek[i][data[j]]++;
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:51:5: note:                 'int data [100005]'
   51 | int data[100005];
      |     ^~~~
a.cc:72:26: error: cannot convert 'const std::pair<int, int>' to 'int' in assignment
   72 |                 ans = max(gtw[0].front(), gtw[1].front());
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                          |
      |                          const std::pair<int, int>