stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#include<string>

#include<vector>

#include<queue>

#include<stack>

#include<map>

#include<set>

#include<list>

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long



using namespace std;

int num[100005];

int ev[100005];

int od[100005];

int main()

{

	int n;

	cin>>n;

	for(int i=0;i<n;i++)

		cin>>num[i];



	for(int i=0;i<n;i++)

	{

		if(i&1) od[num[i]]++;

		else ev[num[i]]++;

	}

	int anse = 0,anso = 0;

	int ae = 0 , ao = 0;

	int sume = 0,sumo = 0;

	for(int i=0;i<100005;i++)

	{

		if(anse <= ev[i])

		{

			ae = anse;

			anse = ev[i];

			sume = i;

		}

		else if(ae < ev[i])

		{

			ae = ev[i];

		}

		if(anso <= od[i])

		{

			ao = anso;

			anso = od[i];

			sumo = i;

		}

		else if(ao < od[i])

		{

			ao = od[i];

		}

	}

	if(sumo != sume)

	{

		cout<<n-anse-anso<<endl;

	}

	else cout<<min(n-anse-ao,n-anso-ae)<<endl;

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.4818973150067787x):
// oh, the less I know the better

// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz

#include <bits/stdc++.h>

#define endl '\n'

#define pb push_back

#define sz(x) int(x.size())

#define REP(i,n) for(int i = 0; i < int(n); ++i)

#define trace(x) cout << #x << " = " << x << endl

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

typedef long long ll;

typedef pair<int,int> ii;



int main(){



	fastio;

	int n;

	cin >> n;

	vector<int> a,b;

	for(int i = 0; i < n; ++i){

		int x;

		cin >> x;

		if(i&1) a.pb(x);

		else b.pb(x);

	}



	vector< pair<int,int> > besta, bestb;

	map<int,int> mpa,mpb;

	mpa[1e6]; mpb[1e6+1];

	for(int x : a) mpa[x]++;

	for(auto p : mpa){

		besta.pb(make_pair(p.second,p.first));

	}

	for(int x : b) mpb[x]++;

	for(auto p : mpb){

		bestb.pb(make_pair(p.second,p.first));

	}



	sort(besta.rbegin(),besta.rend());

	sort(bestb.rbegin(),bestb.rend());



	int ans = 1e9;

	for(int i = 0; i < min(sz(besta),10); ++i){

		for(int j = 0; j < min(sz(bestb),10); ++j){

			if(besta[i].second == bestb[j].second) continue;

			ans = min(ans, n - besta[i].first - bestb[j].first);

		}

	}



	cout << ans << endl;



	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

using namespace std;

const int M=2e5+7;

int read(){

	int ans=0,f=1,c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}

	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}

	return ans*f;

}

int n,s[M],v1[M],v2[M];

int main(){

	n=read();

	for(int i=1;i<=n;i++){

		s[i]=read();

		if(i&1) v1[s[i]]++;

		else v2[s[i]]++;

	}

	int id1=0,cnt1=0,id2=0,cnt2=0;

	for(int i=1;i<=1e5;i++) if(v1[i]>cnt1) cnt1=v1[i],id1=i;

	for(int i=1;i<=1e5;i++) if(i!=id1&&v1[i]>cnt2) cnt2=v1[i],id2=i;

	int id3=0,cnt3=0,id4=0,cnt4=0;

	for(int i=1;i<=1e5;i++) if(v2[i]>cnt3) cnt3=v2[i],id3=i;

	for(int i=1;i<=1e5;i++) if(i!=id3&&v2[i]>cnt4) cnt4=v2[i],id4=i;

	if(id1!=id3) printf("%d\n",n-cnt1-cnt3);

	else printf("%d\n",n-cnt1-max(cnt2,cnt4));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.2757345579228219x):
#include<bits/stdc++.h>

using namespace std;

const int MAXN=100005;

int a[MAXN];

map<int,int> odd;

map<int,int> even;

typedef pair<int,int> pa;

pa od[MAXN];

pa ev[MAXN];

int main(){

	int n;

	int mxo=0,mx1=0,mxe=0,mx2=0;

	int num1,num2,num3,num4;

	int inf=0;

	scanf("%d",&n);

	for(int i=1;i<=n;i++){

		scanf("%d",&a[i]); 

		inf=inf<a[i]?a[i]:inf;

		if(i&1){

			odd[a[i]]=odd.count(a[i])?odd[a[i]]+1:1;

		}

		else{

			even[a[i]]=even.count(a[i])?even[a[i]]+1:1;

		}

	}

	n>>=1;

	int cnt=0;

	for(map<int,int>::iterator it=odd.begin();it!=odd.end();it++){

		od[++cnt]=make_pair(it->second,it->first);

	}

	cnt=0;

	for(map<int,int>::iterator it=even.begin();it!=even.end();it++){

		ev[++cnt]=make_pair(it->second,it->first);

	}

	sort(od+1,od+n+1);

	sort(ev+1,ev+n+1);

	if(n==1){

		mx1=mx2=0;

	}

	mxe=od[n].first,mxo=ev[n].first;

	mx1=od[n-1].first,mx2=ev[n-1].first;

	num1=od[n].second,num3=ev[n].second;

	num2=od[n-1].second,num4=ev[n-1].second;

	if(num1!=num3){

		printf("%d\n",n*2-mxe-mxo);

	} 

	else{

		printf("%d\n",min(n*2-mx1-mxe,n*2-mx2-mxo));

	}

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

using namespace std;

const int M=2e5+7;

int read(){

	int ans=0,f=1,c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}

	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}

	return ans*f;

}

int n,s[M],v1[M],v2[M];

int main(){

	n=read();

	for(int i=1;i<=n;i++){

		s[i]=read();

		if(i&1) v1[s[i]]++;

		else v2[s[i]]++;

	}

	int id1=0,cnt1=0,id2=0,cnt2=0;

	for(int i=1;i<=1e5;i++) if(v1[i]>cnt1) cnt1=v1[i],id1=i;

	for(int i=1;i<=1e5;i++) if(i!=id1&&v1[i]>cnt2) cnt2=v1[i],id2=i;

	int id3=0,cnt3=0,id4=0,cnt4=0;

	for(int i=1;i<=1e5;i++) if(v2[i]>cnt3) cnt3=v2[i],id3=i;

	for(int i=1;i<=1e5;i++) if(i!=id3&&v2[i]>cnt4) cnt4=v2[i],id4=i;

	if(id1!=id3) printf("%d\n",n-cnt1-cnt3);

	else printf("%d\n",n-cnt1-max(cnt2,cnt4));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.2449324361205298x):
#include <iostream>

#include <vector>

#include <map>

#include <set>

#include <cmath>

#include <algorithm>

#include <iomanip>

#include <queue>

#include <string>

#include <utility>

#include <cassert>

#include <functional>

#include <numeric>

#include <chrono>

#include <random>

#include <optional>



using namespace std;

typedef long long ll;



int main() {

  ios_base::sync_with_stdio(0);

  cin.tie(0);

  int n;

  cin >> n;

  map<ll, ll> odd, even;

  for (int i = 0; i < n; i++) {

    int a;

    cin >> a;

    if (i & 1) odd[a]++;

    else even[a]++;

  }



  vector<pair<ll, ll>> impar;

  for (auto p: odd) {

    ll tot = n / 2;

    ll dif = tot - p.second;

    impar.push_back({dif, p.first});

  }



  vector<pair<ll, ll>> par;

  for (auto p: even) {

    ll tot = n / 2;

    ll dif = tot - p.second;

    par.push_back({dif, p.first});

  }



  sort(impar.begin(), impar.end());

  sort(par.begin(), par.end());

  ll res = 1e9;

  for (int i = 0; i < min(2, (int)impar.size()); i++) {

    for (int j = 0; j < min(2, (int)par.size()); j++) {

      ll val = impar[i].first + par[j].first;

      if (impar[i].second == par[j].second) {

        val = min(impar[i].first, par[j].first) + n/2;

      }

      res = min(res, val);

    }

  }

  cout << res << endl;

  return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

using namespace std;

const int M=2e5+7;

int read(){

	int ans=0,f=1,c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}

	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}

	return ans*f;

}

int n,s[M],v1[M],v2[M];

int main(){

	n=read();

	for(int i=1;i<=n;i++){

		s[i]=read();

		if(i&1) v1[s[i]]++;

		else v2[s[i]]++;

	}

	int id1=0,cnt1=0,id2=0,cnt2=0;

	for(int i=1;i<=1e5;i++) if(v1[i]>cnt1) cnt1=v1[i],id1=i;

	for(int i=1;i<=1e5;i++) if(i!=id1&&v1[i]>cnt2) cnt2=v1[i],id2=i;

	int id3=0,cnt3=0,id4=0,cnt4=0;

	for(int i=1;i<=1e5;i++) if(v2[i]>cnt3) cnt3=v2[i],id3=i;

	for(int i=1;i<=1e5;i++) if(i!=id3&&v2[i]>cnt4) cnt4=v2[i],id4=i;

	if(id1!=id3) printf("%d\n",n-cnt1-cnt3);

	else printf("%d\n",n-cnt1-max(cnt2,cnt4));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.2522825841669454x):
//Forever... Check size - Reading order - Use scanf - Clear structures

#pragma GCC optimize ("Ofast,unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define sz(x) int(x.size())

#define pb push_back

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define ff first

#define ss second

#define REP(i,a,b) for(int i = int(a); i < int(b); ++ i)

typedef long long ll;

typedef pair<int, int> ii;



const int N = 1e5 + 2;



vector<int> par, impar;

map<int, int> mapa[2];

int a[N];



int main(){

	fastio;

	int n; cin >> n;

	for(int i = 0; i < n; ++ i) {

		cin >> a[i];

		mapa[i % 2][a[i]] ++;

	}

	mapa[0][0] = 0; mapa[1][-1] = 0;

	

	REP(i,0,2){

		int high = -1, key = -1;

		for(auto x: mapa[0]){

			if(x.ss > high){

				high = x.ss;

				key = x.ff;

			}

		}

		par.pb(key);

		mapa[0].erase(key);

	}



	REP(i,0,2){

		int high = -1, key = -2;

		for(auto x: mapa[1]){

			if(x.ss > high){

				high = x.ss;

				key = x.ff;

			}

		}

		impar.pb(key);

		mapa[1].erase(key);

	}

	

	int ans = 1e9;

	for(int x: par){

		for(int y: impar){

			if(x == y) continue;

			int ret = 0;

			for(int i = 0; i < n; i += 2){

				if(a[i] != x) ret ++;

			}

			for(int i = 1; i < n; i += 2){

				if(a[i] != y) ret ++;

			}

			ans = min(ans, ret);

		}

	}

	cout << ans << endl;



	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

using namespace std;

const int M=2e5+7;

int read(){

	int ans=0,f=1,c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}

	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}

	return ans*f;

}

int n,s[M],v1[M],v2[M];

int main(){

	n=read();

	for(int i=1;i<=n;i++){

		s[i]=read();

		if(i&1) v1[s[i]]++;

		else v2[s[i]]++;

	}

	int id1=0,cnt1=0,id2=0,cnt2=0;

	for(int i=1;i<=1e5;i++) if(v1[i]>cnt1) cnt1=v1[i],id1=i;

	for(int i=1;i<=1e5;i++) if(i!=id1&&v1[i]>cnt2) cnt2=v1[i],id2=i;

	int id3=0,cnt3=0,id4=0,cnt4=0;

	for(int i=1;i<=1e5;i++) if(v2[i]>cnt3) cnt3=v2[i],id3=i;

	for(int i=1;i<=1e5;i++) if(i!=id3&&v2[i]>cnt4) cnt4=v2[i],id4=i;

	if(id1!=id3) printf("%d\n",n-cnt1-cnt3);

	else printf("%d\n",n-cnt1-max(cnt2,cnt4));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.245374628663911x):
//nani?

#include<bits/stdc++.h>

#define pi acos(-1);

#define fs first

#define sc second

#define pb push_back

#define mp make_pair

#define f(i,a,b) for( int i = a; i < b ; i++ )

#define sor(a) sort( a.begin(), a.end() )

#define rsor(a) sort( a.rbegin(), a.rend() )

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;

typedef double ld;

using namespace std;

const ll inf=1e10+6;

const ll MOD=1e9+7;

const ll mod=998244353;

// ac cmtr;

const int MX = 1e6+5;

const int LG = 25;



#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)

template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}

template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){

    const char* xd=strchr(x+1, ',');

    cout.write(x, xd-x)<<" : "<<val1<<" | ";

    fff(xd+1, val2...);

}

 

//---------------------------



ll a[MX];



int main(){

    fastio;

    ll n;

    cin>>n;

    map <ll,ll> m1;

    map <ll,ll> m2;

    vector <pair <ll,ll> > v1;

    vector <pair <ll,ll> > v2;

    f(i,0,n){

        cin>>a[i];

        if(i%2==0) m1[a[i]]++;

        else m2[a[i]]++;

    }

    for(auto xd : m1){

        v1.pb({xd.sc,xd.fs});

    }

    for(auto xd : m2){

        v2.pb({xd.sc,xd.fs});

    }

    rsor(v1);rsor(v2);

    if(v1.size() == 1 && v2.size() == 1){

        if(v1[0].sc == v2[0].sc) {cout<<n/2<<endl;return 0;}

        cout<<0<<endl;return 0;

    }

    if(v1.size() == 1 && v2.size() >= 2){

        if(v1[0].sc != v2[0].sc) {cout<<n/2-v2[0].fs<<endl;return 0;}

        else{

            cout<<n/2-v2[1].fs<<endl;return 0;

        }

    }

    if(v2.size() == 1 && v1.size() >= 2){

        if(v1[0].sc != v2[0].sc) {cout<<n/2-v1[0].fs<<endl;return 0;}

        else{

            cout<<n/2-v1[1].fs<<endl;return 0;

        }

    }



    if(v1[0].sc != v2[0].sc){

        cout<<n-v1[0].fs-v2[0].fs<<endl;return 0;

    }

    else{

        ll ans = min(n-v1[0].fs-v2[1].fs,n-v1[1].fs-v2[0].fs);

        cout<<ans<<endl;

        return 0;

    }











}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

using namespace std;

const int M=2e5+7;

int read(){

	int ans=0,f=1,c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}

	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}

	return ans*f;

}

int n,s[M],v1[M],v2[M];

int main(){

	n=read();

	for(int i=1;i<=n;i++){

		s[i]=read();

		if(i&1) v1[s[i]]++;

		else v2[s[i]]++;

	}

	int id1=0,cnt1=0,id2=0,cnt2=0;

	for(int i=1;i<=1e5;i++) if(v1[i]>cnt1) cnt1=v1[i],id1=i;

	for(int i=1;i<=1e5;i++) if(i!=id1&&v1[i]>cnt2) cnt2=v1[i],id2=i;

	int id3=0,cnt3=0,id4=0,cnt4=0;

	for(int i=1;i<=1e5;i++) if(v2[i]>cnt3) cnt3=v2[i],id3=i;

	for(int i=1;i<=1e5;i++) if(i!=id3&&v2[i]>cnt4) cnt4=v2[i],id4=i;

	if(id1!=id3) printf("%d\n",n-cnt1-cnt3);

	else printf("%d\n",n-cnt1-max(cnt2,cnt4));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.2575332065381752x):
/**

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀

⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀

⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀

⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀

⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀

⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀

⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀

 *    author:  Daredevil666

 *    institution: IIT Patna

**/

#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

#define nl cout<<"\n";

#define ll long long int

#define REP(i,a,n) for(i=a;i<=n;i++)

#define F(i,a,b) for(i=a;i<b;i++)

#define RF(i,b,a) for(i=b;i>=a;i--)

#define IOS  ios::sync_with_stdio(false);cin.tie(0);

using namespace std;

const ll mod=1e9+7;

const ll MAXN=1000200;

ll i,j,mask,test;

int main()

{

IOS

/*#ifndef ONLINE_JUDGE

   freopen("input.txt","r",stdin);

   freopen("output.txt","w",stdout);

#endif // ONLINE_JUDGE*/

ll n;

cin>>n;

map<ll,ll> a,b;

F(i,0,n)

{

    ll x;

    cin>>x;

    if(i%2==0)

    {

        a[x]++;

    }

    else

    {

        b[x]++;

    }

}

ll mx1=0,mx2=0,p1,p2;

for(auto t:a)

{

    if(mx1<t.second)

    {

        mx1=t.second;

        p1=t.first;

    }

}

for(auto t:b)

{

    if(mx2<t.second)

    {

        mx2=t.second;

        p2=t.first;

    }

}

n/=2;

if(p1!=p2)

{

    cout<<2*n-mx1-mx2;

}

else

{

    ll minn=mod;

    for(ll i=1;i<=1e5;i++)

    {

        if(p1!=i)

        minn=min(minn,2*n-mx1-b[i]);

    }

    for(ll i=1;i<=1e5;i++)

    {

        if(p2!=i)

        minn=min(minn,2*n-mx2-a[i]);

    }

    cout<<minn;

}

return 0;

}
// Slower C++ solution:
#include <iostream>

#include <map>

#include <vector>

#include <algorithm>

#include <string.h>

using namespace std;

#define sz(x) int(x.size())

#define pb push_back

#define ff first

#define ss second

typedef long long ll;



const int N=1e5+100;

int f[N];



int main(){

	int n;cin>>n;

	map<int,int>M;

	vector<int>vec1;

	vector<int>vec2;

	for(int i=0;i<n;i++){

		int val;cin>>val;

		M[val]++;

		if(i&1)vec2.pb(val);

		else vec1.pb(val);

	}

	if(sz(M)==1){

		cout<<n/2<<endl;

		return 0;

	}

	int mx=0,id=-1;

	for(int i=0;i<sz(vec1);i++){

		f[vec1[i]]++;

		if(f[vec1[i]]>mx){

			mx=f[vec1[i]];

			id=vec1[i];

		}

	}

	memset(f,0,sizeof(f));

	int mx2=0,id2=-1;

	for(int i=0;i<sz(vec2);i++){

		f[vec2[i]]++;

		if(f[vec2[i]]>mx2){

			mx2=f[vec2[i]];

			id2=vec2[i];

		}

	}

	if(id!=id2)cout<<sz(vec1)-mx+sz(vec2)-mx2<<endl;

	else{

		int ans=N;

		for(int g=0;g<2;g++){

			memset(f,0,sizeof(f));

			int x=0;

			for(int i=0;i<sz(vec2);i++)if(vec2[i]!=id2){

				f[vec2[i]]++;

				if(f[vec2[i]]>x)x=f[vec2[i]];

			}

			ans=min(ans,sz(vec1)-mx+sz(vec2)-x);

			swap(vec1,vec2);

			swap(id,id2);

			swap(mx,mx2);

		}

		cout<<ans<<endl;



	}

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.393883397158219x):
/**

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀

⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀

⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀

⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀

⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀

⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀

⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀

 *    author:  Daredevil666

 *    institution: IIT Patna

**/

#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

#define nl cout<<"\n";

#define ll long long int

#define REP(i,a,n) for(i=a;i<=n;i++)

#define F(i,a,b) for(i=a;i<b;i++)

#define RF(i,b,a) for(i=b;i>=a;i--)

#define IOS  ios::sync_with_stdio(false);cin.tie(0);

using namespace std;

const ll mod=1e9+7;

const ll MAXN=1000200;

ll i,j,mask,test;

int main()

{

IOS

/*#ifndef ONLINE_JUDGE

   freopen("input.txt","r",stdin);

   freopen("output.txt","w",stdout);

#endif // ONLINE_JUDGE*/

ll n;

cin>>n;

map<ll,ll> a,b;

F(i,0,n)

{

    ll x;

    cin>>x;

    if(i%2==0)

    {

        a[x]++;

    }

    else

    {

        b[x]++;

    }

}

ll mx1=0,mx2=0,p1,p2;

for(auto t:a)

{

    if(mx1<t.second)

    {

        mx1=t.second;

        p1=t.first;

    }

}

for(auto t:b)

{

    if(mx2<t.second)

    {

        mx2=t.second;

        p2=t.first;

    }

}

n/=2;

if(p1!=p2)

{

    cout<<2*n-mx1-mx2;

}

else

{

    ll minn=mod;

    for(ll i=1;i<=1e5;i++)

    {

        if(p1!=i)

        minn=min(minn,2*n-mx1-b[i]);

    }

    for(ll i=1;i<=1e5;i++)

    {

        if(p2!=i)

        minn=min(minn,2*n-mx2-a[i]);

    }

    cout<<minn;

}

return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

using namespace std;

const int M=2e5+7;

int read(){

	int ans=0,f=1,c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}

	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}

	return ans*f;

}

int n,s[M],v1[M],v2[M];

int main(){

	n=read();

	for(int i=1;i<=n;i++){

		s[i]=read();

		if(i&1) v1[s[i]]++;

		else v2[s[i]]++;

	}

	int id1=0,cnt1=0,id2=0,cnt2=0;

	for(int i=1;i<=1e5;i++) if(v1[i]>cnt1) cnt1=v1[i],id1=i;

	for(int i=1;i<=1e5;i++) if(i!=id1&&v1[i]>cnt2) cnt2=v1[i],id2=i;

	int id3=0,cnt3=0,id4=0,cnt4=0;

	for(int i=1;i<=1e5;i++) if(v2[i]>cnt3) cnt3=v2[i],id3=i;

	for(int i=1;i<=1e5;i++) if(i!=id3&&v2[i]>cnt4) cnt4=v2[i],id4=i;

	if(id1!=id3) printf("%d\n",n-cnt1-cnt3);

	else printf("%d\n",n-cnt1-max(cnt2,cnt4));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.256470148813836x):
/******************************************************************************



Welcome to GDB Online.

GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 

C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS

Code, Compile, Run and Debug online from anywhere in world.



*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

bool csort(const pair<int,int>&a,const pair<int,int>& b)

{

    return a.second>b.second;

}



int main()

{

    cin.tie(0);

    

    

        int n;

        cin>>n;

        vector<int> v(n);

        for(int i=0;i<n;i++)

        cin>>v[i];

        

        map<int,int> m;

        map<int,int> m1;

        for(int i=0;i<n;i++)

        {

            //if(i>0 && v[i]==v[i-1])

            //same=v[i];

            if(i%2==0)

            m[v[i]]++;

            else

            m1[v[i]]++;

        }

        vector<pair<int,int>> v1,v2;

        for(auto i:m)

        {

            v1.push_back({i.first,i.second});

        }

        sort(v1.begin(),v1.end(),csort);

        //reverse(v1.begin(),v1.end());

        for(auto i:m1)

        {

            v2.push_back({i.first,i.second});

        }

        sort(v2.begin(),v2.end(),csort);

        //reverse(v2.begin(),v2.end());

        int s=0;

        if(v2[0].first==v1[0].first)

        {

            s=min(n-v1[0].second-v2[1].second,n-v1[1].second-v2[0].second);

        

        }

        else

        {

            s=n-v1[0].second-v2[0].second;

        }

        cout<<s<<"\n";

    



    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <map>

#include <vector>

#include <algorithm>

#include <string.h>

using namespace std;

#define sz(x) int(x.size())

#define pb push_back

#define ff first

#define ss second

typedef long long ll;



const int N=1e5+100;

int f[N];



int main(){

	int n;cin>>n;

	map<int,int>M;

	vector<int>vec1;

	vector<int>vec2;

	for(int i=0;i<n;i++){

		int val;cin>>val;

		M[val]++;

		if(i&1)vec2.pb(val);

		else vec1.pb(val);

	}

	if(sz(M)==1){

		cout<<n/2<<endl;

		return 0;

	}

	int mx=0,id=-1;

	for(int i=0;i<sz(vec1);i++){

		f[vec1[i]]++;

		if(f[vec1[i]]>mx){

			mx=f[vec1[i]];

			id=vec1[i];

		}

	}

	memset(f,0,sizeof(f));

	int mx2=0,id2=-1;

	for(int i=0;i<sz(vec2);i++){

		f[vec2[i]]++;

		if(f[vec2[i]]>mx2){

			mx2=f[vec2[i]];

			id2=vec2[i];

		}

	}

	if(id!=id2)cout<<sz(vec1)-mx+sz(vec2)-mx2<<endl;

	else{

		int ans=N;

		for(int g=0;g<2;g++){

			memset(f,0,sizeof(f));

			int x=0;

			for(int i=0;i<sz(vec2);i++)if(vec2[i]!=id2){

				f[vec2[i]]++;

				if(f[vec2[i]]>x)x=f[vec2[i]];

			}

			ans=min(ans,sz(vec1)-mx+sz(vec2)-x);

			swap(vec1,vec2);

			swap(id,id2);

			swap(mx,mx2);

		}

		cout<<ans<<endl;



	}

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3927050755803287x):
/******************************************************************************



Welcome to GDB Online.

GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 

C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS

Code, Compile, Run and Debug online from anywhere in world.



*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

bool csort(const pair<int,int>&a,const pair<int,int>& b)

{

    return a.second>b.second;

}



int main()

{

    cin.tie(0);

    

    

        int n;

        cin>>n;

        vector<int> v(n);

        for(int i=0;i<n;i++)

        cin>>v[i];

        

        map<int,int> m;

        map<int,int> m1;

        for(int i=0;i<n;i++)

        {

            //if(i>0 && v[i]==v[i-1])

            //same=v[i];

            if(i%2==0)

            m[v[i]]++;

            else

            m1[v[i]]++;

        }

        vector<pair<int,int>> v1,v2;

        for(auto i:m)

        {

            v1.push_back({i.first,i.second});

        }

        sort(v1.begin(),v1.end(),csort);

        //reverse(v1.begin(),v1.end());

        for(auto i:m1)

        {

            v2.push_back({i.first,i.second});

        }

        sort(v2.begin(),v2.end(),csort);

        //reverse(v2.begin(),v2.end());

        int s=0;

        if(v2[0].first==v1[0].first)

        {

            s=min(n-v1[0].second-v2[1].second,n-v1[1].second-v2[0].second);

        

        }

        else

        {

            s=n-v1[0].second-v2[0].second;

        }

        cout<<s<<"\n";

    



    return 0;

}