stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	int n; cin >> n;

	vector<int> v(n);

	for (int i = 0; i < n; i++) cin >> v[i];

	vector<int> cnt(110000, 0);

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

		cnt[v[i]]++;

	}

	int i1 = max_element(cnt.begin(), cnt.end()) - cnt.begin(), i2 = 0;

	for (int i = 0; i < cnt.size(); i++) {

		if (i != i1) {

			if (cnt[i2] < cnt[i]) i2 = i;

		}

	}

	int ci1 = cnt[i1], ci2 = cnt[i2];

	for (auto& val : cnt) val = 0;

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

		cnt[v[i]]++;

	}

	int j1 = max_element(cnt.begin(), cnt.end()) - cnt.begin(), j2 = 0;

	for (int i = 0; i < cnt.size(); i++) {

		if (i != j1) {

			if (cnt[j2] < cnt[i]) j2 = i;

		}

	}

	int cj1 = cnt[j1], cj2 = cnt[j2];

	int ans;

	if (i1 == j1) {

		ans = n - ci1 - max(ci2, cj2);

	} else {

		ans = n - ci1 - cj1;

	}

	cout << ans << endl;

	return 0;

}


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

using namespace std;

 

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

#define mod 1000000007LL

#define FOR(i,m,n) for(int i = (m); i < (n); i++)

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

#define all(v) v.begin(),v.end()

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

 

 

typedef long long ll;

typedef vector<int> vi; 

typedef pair<int,int> ii;





ll pow(ll a, ll b){

    int ans = 1;

    while(b){

        if(b&1) ans=(ans*a)%mod;

        b>>=1;

        a=(a*a)%mod;

    }

    return ans;

}





const int N=1e5;





void run(){

	

	int n; cin>>n;

	

	vi v(n);

	FOR(i,0,n) cin>>v[i];

	

	map<int, int> m, p;

	int x=0, ans=0, b;

	

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

		if(!m.count(v[i])){

			m[v[i]]=1;

		}

		else m[v[i]]=m[v[i]]+1;

		

		if(m[v[i]]>x){

			x=m[v[i]]; b=v[i];

		}

	}

	

	

	int y=0, c;

	

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

		if(!p.count(v[i])){

			p[v[i]]=1;

		}

		else p[v[i]]=p[v[i]]+1;

		

		if(p[v[i]]>y){

			y=p[v[i]]; c=v[i];

		}

	}

		

	if(b==c){

		int w=0, z=0;

		for(auto xd : m){

			if(xd.fst==b) continue;

			w=max(w,xd.snd);

		}

		for(auto xd : p){

			if(xd.fst==c) continue;

			w=max(w,xd.snd);

		}

		ans=n-x-max(w,z);

	}

	else ans=n-x-y;

	

	cout<<ans<<"\n";

}





int main(){

	

	fastio;

	

	int tt=1; 

	//cin>>tt;

	

	while(tt--){

		run();

	}

	

	return 0;

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

#include<cstdio>

#include<algorithm>

#include<map>

#define in(a) scanf("%d",&a)

using namespace std;

const int maxn = 1e5 + 10;

int a[maxn]; int b[maxn];



int main()

{

	int n; in(n);

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

	{

		int x; in(x);

		if (i & 1 == 1)a[x] += 1;

		else b[x] += 1;

	}

	

	int pmax = 0; int sec = 0; int pos = 0;

	for (int i = 1; i < maxn; i++)

	{

		if (a[i] > pmax)

		{

			sec = pmax; pmax = a[i]; pos = i;

		}

		else

		{

			sec = max(sec, a[i]);

		}

	}

	int ans = 1e9;

	for (int i = 1; i < maxn; i++)

	{

		if (pos != i)ans = min(ans, n - pmax - b[i]);

		else ans = min(ans, n - sec - b[i]);

	}

	printf("%d\n", ans);

	return 0;

}

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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

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

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

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

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

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

#include<cstring>

#include<algorithm>

#include<map>

#include<vector>

std::map<int,int> a,b;

const int maxn=1e5+10;

int n,v[maxn];

bool cmp(const std::pair<int,int> &a,const std::pair<int,int> &b)

{

    return a.second>b.second;

}

int main()

{

    scanf("%d",&n);

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

    {

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

        if(i%2==1) a[v[i]]++;

        if(i%2==0) b[v[i]]++;

    }

    std::vector<std::pair<int,int> > A(a.begin(),a.end());

    std::vector<std::pair<int,int> > B(b.begin(),b.end());

    std::sort(A.begin(),A.end(),cmp);

    std::sort(B.begin(),B.end(),cmp);

    int min=0x7fffffff;

    if(A[0].first!=B[0].first)

    {

        min=std::min(min,n-A[0].second-B[0].second);

    } else

    {

        if(A.size()>1)

        {

            min=std::min(min,n-A[1].second-B[0].second);

        }

        if(B.size()>1)

        {

            min=std::min(min,n-A[0].second-B[1].second);

        }

    }

    if(min==0x7fffffff) min=n/2;

    printf("%d\n",min);

}


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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

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

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

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

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout << fixed << setprecision(15); 

    int n;

    cin >> n;

    vector<int> a(n);

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

        cin >> a[i]; 

    }

    map<int, int> mpodd, mpeven;

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

        ++mpodd[a[i]]; 

    }  

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

        ++mpeven[a[i]];

    }

    vector<pair<int, int>> odd, even; 

    for (auto it: mpodd) {

        odd.push_back(make_pair(-it.second, it.first)); 

    }

    for (auto it: mpeven) {

        even.push_back(make_pair(-it.second, it.first));  

    }

    odd.push_back(make_pair(0, 0));

    even.push_back(make_pair(0, 0)); 

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

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

    int ans = 0; 

    if (odd[0].second != even[0].second) ans = n + odd[0].first + even[0].first; 

    else {

        ans = n + min(odd[1].first + even[0].first, odd[0].first + even[1].first); 

    }

    cout << ans << endl; 

    return 0; 

}

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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

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

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

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

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

typedef long long ll;

typedef long double ld;

using namespace std;

mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());

#define ii for(int i=1;i<=n;++i)

#define ji for(int j=1;j<=n;++j)

#define jj for(int j=1;j<=m;++j)

#define ij for(int i=1;i<=m;++i)

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

#define all(x) x.begin(),x.end()

#define alll(x) x+1,x+1+n

#define asd cout<<"ok"<<endl;

#define endl '\n'



int a[100005];

int cnt[100005],cnt2[100005];

int main()

{

    int n;

    cin>>n;

    ii cin>>a[i];

    for(int i=1;i<=n;i+=2) cnt[a[i]]++;

    for(int i=2;i<=n;i+=2) cnt2[a[i]]++;

    int mx1=0,mx2=0,mi1=0,mi2=0;

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

        if(cnt[i] > mx1) {

            mx2 = mx1, mi2 = mi1;

            mx1 = cnt[i], mi1 = i;

        } else if(cnt[i] > mx2) {

            mx2 = cnt[i], mi2 = i;

        }

    }

    int mx12=0,mx22=0,mi12=0,mi22=0;

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

        if(cnt2[i] > mx12) {

            mx22 = mx12, mi22 = mi12;

            mx12 = cnt2[i], mi12 = i;

        } else if(cnt2[i] > mx22) {

            mx22 = cnt2[i], mi22 = i;

        }

    }

    if(mi12 != mi1) cout << n - mx1 - mx12 << endl;

    else cout << min(n-mx1-mx22,n-mx2-mx12) << endl;

}

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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

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

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

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

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

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

#include<iostream>

#include<cstring>

#include<algorithm>

#define debug cout<<"****************"<<endl

using namespace std;

typedef long long ll;

inline void ju() {

	freopen("***.in","r",stdin);

	freopen("***.out","w",stdout);

}

inline ll rd() {

	ll x=0,f=1; char c=getchar();

	while((c<'0'||c>'9')&&(c!='-')) c=getchar();

	if(c=='-') f=-1,c=getchar();

	while(c>='0'&&c<='9') {

		x=(x<<3)+(x<<1)+c-'0';

		c=getchar();

	}

	return x*f;

}

const int N=1e5+10;

int a[N],b1[N],b2[N];

int main() {

	int n=rd(),x1=0,y1=0,x2=0,y2=0;

	for(int i=1;i<=n;++i) a[i]=rd();

	for(int i=1;i<=n;i+=2) ++b1[a[i]];

	for(int i=2;i<=n;i+=2) ++b2[a[i]];

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

		if(b1[i]>b1[x1]) y1=x1,x1=i;

		else if(b1[i]>b1[y1]) y1=i;

		if(b2[i]>b2[x2]) y2=x2,x2=i;

		else if(b2[i]>b2[y2]) y2=i;

	}

	int ans;

	if(x1!=x2) ans=n-b1[x1]-b2[x2];

	else ans=n-max(b1[x1]+b2[y2],b1[y1]+b2[x2]);

	printf("%d\n",ans);

	return 0;

}


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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

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

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

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

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	int n; cin >> n;

	vector<int> v(n);

	for (int i = 0; i < n; i++) cin >> v[i];

	vector<int> cnt(110000, 0);

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

		cnt[v[i]]++;

	}

	int i1 = max_element(cnt.begin(), cnt.end()) - cnt.begin(), i2 = 0;

	for (int i = 0; i < cnt.size(); i++) {

		if (i != i1) {

			if (cnt[i2] < cnt[i]) i2 = i;

		}

	}

	int ci1 = cnt[i1], ci2 = cnt[i2];

	for (auto& val : cnt) val = 0;

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

		cnt[v[i]]++;

	}

	int j1 = max_element(cnt.begin(), cnt.end()) - cnt.begin(), j2 = 0;

	for (int i = 0; i < cnt.size(); i++) {

		if (i != j1) {

			if (cnt[j2] < cnt[i]) j2 = i;

		}

	}

	int cj1 = cnt[j1], cj2 = cnt[j2];

	int ans;

	if (i1 == j1) {

		ans = n - ci1 - max(ci2, cj2);

	} else {

		ans = n - ci1 - cj1;

	}

	cout << ans << endl;

	return 0;

}


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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

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

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

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

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define int long long

#define pb push_back

#define pf push_front

#define pii pair <int, int>

#define all(vv) (vv).begin(), (vv).end()

#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0

 

//link: https://atcoder.jp/contests/arc103/tasks/arc103_a

 

vector <int> e;

vector <int> o;

map <int, int> mpe;

map <int, int> mpo;

int32_t main() {

	ios_base::sync_with_stdio(0); cin.tie(0);

	bool can = true;

	int n; cin >> n;

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

		int x; cin >> x;

		if (i % 2 == 0) o.pb(x);

		else e.pb(x);

	}

	// find the top 2 modes

	for(auto it:e) {

		++mpe[it];

	}

	vector <pii> MPE; // convert to vector for sorting

	for(auto it:mpe) {

		MPE.pb(make_pair(it.second, it.first));

	}

	sort(all(MPE), greater<pair<int, int> > ());

	int e1 = MPE[0].second;

	int e2 = MPE[1].second;

	cerr << e1 << ' ' << e2 << '\n';

	// repeat!!

	for(auto it:o) {

		++mpo[it];

	}

	vector <pii> MPO;

	for(auto it:mpo) {

		MPO.pb(make_pair(it.second, it.first));

	}

	sort(all(MPO), greater<pair<int, int> >());

	int o1 = MPO[0].second;

	int o2 = MPO[1].second;

	cerr << o1 << ' ' << o2 << '\n';

 

	if (e1 != o1) {

		// assert(0);

		int count = 0;

		for(auto it:e) {

			if (it != e1) ++count;

		}

		for(auto it:o) {

			if (it != o1) ++count;

		}

		cout << count;

		time;

	}

 

	// find the number of changes required for first type

	int count = 0;

	for(auto it:e) {

		if (it != e1) ++count;

	}

	for(auto it:o) {

		if (it != o2) ++count;

	}

	// second type

	int sum = 0;

	for(auto it:e) {

		if (it != e2) ++sum;

	}

	for(auto it:o) {

		if (it != o1) ++sum;

	}

	cout << min(count, sum);

}

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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

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

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

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

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

 

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

#define mod 1000000007LL

#define FOR(i,m,n) for(int i = (m); i < (n); i++)

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

#define all(v) v.begin(),v.end()

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

 

 

typedef long long ll;

typedef vector<int> vi; 

typedef pair<int,int> ii;





ll pow(ll a, ll b){

    int ans = 1;

    while(b){

        if(b&1) ans=(ans*a)%mod;

        b>>=1;

        a=(a*a)%mod;

    }

    return ans;

}





const int N=1e5;





void run(){

	

	int n; cin>>n;

	

	vi v(n);

	FOR(i,0,n) cin>>v[i];

	

	map<int, int> m, p;

	int x=0, ans=0, b;

	

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

		if(!m.count(v[i])){

			m[v[i]]=1;

		}

		else m[v[i]]=m[v[i]]+1;

		

		if(m[v[i]]>x){

			x=m[v[i]]; b=v[i];

		}

	}

	

	

	int y=0, c;

	

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

		if(!p.count(v[i])){

			p[v[i]]=1;

		}

		else p[v[i]]=p[v[i]]+1;

		

		if(p[v[i]]>y){

			y=p[v[i]]; c=v[i];

		}

	}

		

	if(b==c){

		int w=0, z=0;

		for(auto xd : m){

			if(xd.fst==b) continue;

			w=max(w,xd.snd);

		}

		for(auto xd : p){

			if(xd.fst==c) continue;

			w=max(w,xd.snd);

		}

		ans=n-x-max(w,z);

	}

	else ans=n-x-y;

	

	cout<<ans<<"\n";

}





int main(){

	

	fastio;

	

	int tt=1; 

	//cin>>tt;

	

	while(tt--){

		run();

	}

	

	return 0;

}


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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

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

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

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

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

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

#include <vector>

#include <algorithm>



#define MAX 100000



using namespace std;



int main() {

    int n, v;

    scanf("%d", &n);

    vector< vector<int> > d(2, vector<int>(MAX + 1));

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

        scanf("%d", &v);

        ++d.at(i % 2).at(v);

    }

    auto a = max_element(d.front().begin(), d.front().end()), b = max_element(d.back().begin(), d.back().end());

    if (a - d.front().begin() != b - d.back().begin()) printf("%d\n", n - *a - *b);

    else {

        int va = *a, vb = *b;

        *a = 0, *b = 0;

        a = max_element(d.front().begin(), d.front().end()), b = max_element(d.back().begin(), d.back().end());

        printf("%d\n", min(n - va - *b, n - vb - *a));

    }

    return 0;

}


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

#include<algorithm>



constexpr int Maxn=100000;



inline int Max(const int&x,const int&y)

	{return x>y?x:y;}

inline void chkMax(int&x,const int&y)

	{(x<y)&&(x=y);}



namespace IOManager{

	constexpr int FILESZ(131072);

	unsigned char buf[FILESZ];

	const unsigned char*ibuf=buf,*tbuf=buf;



	struct IOManager{

		inline unsigned char gc()

			{return(ibuf==tbuf)&&(tbuf=(ibuf=buf)+fread(buf,1,FILESZ,stdin),ibuf==tbuf)?EOF:*ibuf++;}



		template<class _Tp>

			inline operator _Tp(){

				_Tp s=0u;unsigned char c=gc();

				for(;c<48;c=gc());

				for(;c>47;c=gc())

					s=(_Tp)(s*10u+c-48u);

				return s;

			}

	};

}IOManager::IOManager io;



int cnt[2][Maxn+1];



int main(){

	const int n=io;

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

		++cnt[i&1][(int)io];



	auto mxp1=std::max_element(cnt[0]+1,cnt[0]+Maxn+1);

	auto mxp2=std::max_element(cnt[1]+1,cnt[1]+Maxn+1);

	int mx1=*mxp1,mx1p=mxp1-cnt[0],mx2=*mxp2,mx2p=mxp2-cnt[1];

	*mxp1=*mxp2=0;

	mxp1=std::max_element(cnt[0]+1,cnt[0]+Maxn+1);

	mxp2=std::max_element(cnt[1]+1,cnt[1]+Maxn+1);



	printf("%d",n-(mx1p==mx2p?Max(mx1+*mxp2,mx2+*mxp1):mx1+mx2));



	return 0;

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

#include <vector>

#include <algorithm>



#define MAX 100000



using namespace std;



int main() {

    int n, v;

    scanf("%d", &n);

    vector< vector<int> > d(2, vector<int>(MAX + 1));

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

        scanf("%d", &v);

        ++d.at(i % 2).at(v);

    }

    auto a = max_element(d.front().begin(), d.front().end()), b = max_element(d.back().begin(), d.back().end());

    if (a - d.front().begin() != b - d.back().begin()) printf("%d\n", n - *a - *b);

    else {

        int va = *a, vb = *b;

        *a = 0, *b = 0;

        a = max_element(d.front().begin(), d.front().end()), b = max_element(d.back().begin(), d.back().end());

        printf("%d\n", min(n - va - *b, n - vb - *a));

    }

    return 0;

}


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

 *    author:  tourist

 *    created: 29.09.2018 15:26:49       

**/

#include <bits/stdc++.h>



using namespace std;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  int n;

  cin >> n;

  map<int,int> mp[2];

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

    int x;

    cin >> x;

    mp[i & 1][x]++;

  }

  vector<pair<int,int>> v[2];

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

    for (auto &p : mp[u]) {

      v[u].emplace_back(p.second, p.first);

    }

    if (v[u].size() == 1) {

      v[u].emplace_back(0, -1);

    }

    sort(v[u].rbegin(), v[u].rend());

  }

  int ans = 0;

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

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

      if (v[0][i].second != v[1][j].second) {

        ans = max(ans, v[0][i].first + v[1][j].first);

      }

    }

  }

  cout << n - ans << '\n';

  return 0;

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

#include<algorithm>



constexpr int Maxn=100000;



inline int Max(const int&x,const int&y)

	{return x>y?x:y;}

inline void chkMax(int&x,const int&y)

	{(x<y)&&(x=y);}



namespace IOManager{

	constexpr int FILESZ(131072);

	unsigned char buf[FILESZ];

	const unsigned char*ibuf=buf,*tbuf=buf;



	struct IOManager{

		inline unsigned char gc()

			{return(ibuf==tbuf)&&(tbuf=(ibuf=buf)+fread(buf,1,FILESZ,stdin),ibuf==tbuf)?EOF:*ibuf++;}



		template<class _Tp>

			inline operator _Tp(){

				_Tp s=0u;unsigned char c=gc();

				for(;c<48;c=gc());

				for(;c>47;c=gc())

					s=(_Tp)(s*10u+c-48u);

				return s;

			}

	};

}IOManager::IOManager io;



int cnt[2][Maxn+1];



int main(){

	const int n=io;

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

		++cnt[i&1][(int)io];



	auto mxp1=std::max_element(cnt[0]+1,cnt[0]+Maxn+1);

	auto mxp2=std::max_element(cnt[1]+1,cnt[1]+Maxn+1);

	int mx1=*mxp1,mx1p=mxp1-cnt[0],mx2=*mxp2,mx2p=mxp2-cnt[1];

	*mxp1=*mxp2=0;

	mxp1=std::max_element(cnt[0]+1,cnt[0]+Maxn+1);

	mxp2=std::max_element(cnt[1]+1,cnt[1]+Maxn+1);



	printf("%d",n-(mx1p==mx2p?Max(mx1+*mxp2,mx2+*mxp1):mx1+mx2));



	return 0;

}


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

 *    author:  tourist

 *    created: 29.09.2018 15:26:49       

**/

#include <bits/stdc++.h>



using namespace std;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  int n;

  cin >> n;

  map<int,int> mp[2];

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

    int x;

    cin >> x;

    mp[i & 1][x]++;

  }

  vector<pair<int,int>> v[2];

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

    for (auto &p : mp[u]) {

      v[u].emplace_back(p.second, p.first);

    }

    if (v[u].size() == 1) {

      v[u].emplace_back(0, -1);

    }

    sort(v[u].rbegin(), v[u].rend());

  }

  int ans = 0;

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

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

      if (v[0][i].second != v[1][j].second) {

        ans = max(ans, v[0][i].first + v[1][j].first);

      }

    }

  }

  cout << n - ans << '\n';

  return 0;

}