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



using namespace std;



#define fir first

#define sec second

#define ins insert

#define pb push_back

#define po pop_back

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

#define PI 3.14159265

#define YES cout << "Yes" << '\n';

#define NO cout << "No" << '\n';



typedef long long ll;



const ll max_n = 1e6 + 10 , Mod = 1e9 + 7 , inf = 1e18;

ll n , four , m_two , tmp , num;



void read_input(){

        cin >> n;

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

                cin >> num;

                

                if(num % 4 == 2)

                        m_two++;

                

                else if(num % 4 == 0)

                        four++;

        }

}



void solve(){

        tmp = n - m_two - four;



        if(m_two){

                if(four >= tmp)

                        YES

                else

                        NO

        }



        else{

                if(four != 0 && ((four + 1) >= tmp))

                        YES

                else

                        NO

        }

}



void output(){

        //no output

}



int main(){

        IOS;

        read_input();

        solve();

        output();

        return 0;

}

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

const int maxn = 100005;



int main(){

//	freopen("b.txt","r",stdin);

	int a=0,b=0,c=0,n,x;

	scanf("%d", &n);

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

		scanf("%d", &x);

		if(x%4==0){

			c++;

		}else if(x%2==0){

			b++;

		}else{

			a++;

		}

	}

	if(b==0){

		if(a-1>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}else{

		if(a>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}



	return 0;

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

using namespace std;



#define vi push_back

#define vo pop_back

#define mp make_pair

#define fe first

#define se second

typedef long long ll;



int n;

vector <int> a, Foura;



void Solve () {

	int tmp, FourCount = 0, TwoCount = 0;

	cin >> n;

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

		cin >> tmp;

		if (tmp % 4 == 0) {

			FourCount++;

		}

		else if (tmp % 2 == 0) {

			TwoCount++;

		}

	}

	if (FourCount + (TwoCount / 2) < (n / 2)) {

		cout << "No\n";

		exit (0);

	}

	else {

		cout << "Yes\n";

		exit(0);

	}

}



int main () {

	Solve();

	return 0;

}




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

const int maxn = 100005;



int main(){

//	freopen("b.txt","r",stdin);

	int a=0,b=0,c=0,n,x;

	scanf("%d", &n);

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

		scanf("%d", &x);

		if(x%4==0){

			c++;

		}else if(x%2==0){

			b++;

		}else{

			a++;

		}

	}

	if(b==0){

		if(a-1>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}else{

		if(a>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}



	return 0;

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

using namespace std;

int main()

{

	int n,a1=0,a2=0,a4=0;

	cin>>n;

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

		int t;

		cin>>t;

		if(t%4==0)

			a4++;

		else if(t%2==0)

			a2++;

		else a1++;

	}

	if(a1<=a4&&a2>0)

		cout<<"Yes"<<endl;

	else if(a2==0&&a1<=a4+1)

	cout<<"Yes"<<endl;

		else cout<<"No"<<endl;

	return 0;

}

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

const int maxn = 100005;



int main(){

//	freopen("b.txt","r",stdin);

	int a=0,b=0,c=0,n,x;

	scanf("%d", &n);

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

		scanf("%d", &x);

		if(x%4==0){

			c++;

		}else if(x%2==0){

			b++;

		}else{

			a++;

		}

	}

	if(b==0){

		if(a-1>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}else{

		if(a>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}



	return 0;

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

#include <algorithm>

#include <map>

using namespace std;

typedef long long ll;



int main(){

    int n, ji = 0, b4 = 0;

    cin >> n;

    ll t;

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

        cin >> t;

        if (t & 1) ji++;

        if (t % 4 == 0) b4++;

    }

    if ((!(n & 1) && b4 >= ji) || ((n & 1) && b4 + 1 >= ji)) cout << "Yes" << endl;

    else cout << "No" << endl; 

    return 0;

}

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

const int maxn = 100005;



int main(){

//	freopen("b.txt","r",stdin);

	int a=0,b=0,c=0,n,x;

	scanf("%d", &n);

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

		scanf("%d", &x);

		if(x%4==0){

			c++;

		}else if(x%2==0){

			b++;

		}else{

			a++;

		}

	}

	if(b==0){

		if(a-1>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}else{

		if(a>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}



	return 0;

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))





int main()

{

    LL n,m,M4=0,M2=0;

    cin>>n;

    LL  a[100002]= {0};

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

        cin>>a[i];

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

    {

        if(a[i]%4==0)

            M4++;

        else if(a[i]%2==0)

            M2++;

    }

    M2=M2/2*2;

    if(M4*2+1+M2>=n)

        cout<<"Yes";

    else

        cout<<"No";

}


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

const int maxn = 100005;



int main(){

//	freopen("b.txt","r",stdin);

	int a=0,b=0,c=0,n,x;

	scanf("%d", &n);

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

		scanf("%d", &x);

		if(x%4==0){

			c++;

		}else if(x%2==0){

			b++;

		}else{

			a++;

		}

	}

	if(b==0){

		if(a-1>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}else{

		if(a>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}



	return 0;

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

using namespace std;

int main(){

	int N;

	int num[100000]={0};

	cin>>N;

	int jishu=0,oushu=0,numfour=0;

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

		cin>>num[i];

		if(num[i]%4==0){

			numfour++;

		}else if(num[i]%2==0){

			oushu++;

		}else{

			jishu++;

		}

	}

	if(oushu){

		jishu++;

	}

	if(jishu-1>numfour){

		cout<<"No"<<endl;

	}else{

		cout<<"Yes"<<endl;

	}

	return 0;

}

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

const int maxn = 100005;



int main(){

//	freopen("b.txt","r",stdin);

	int a=0,b=0,c=0,n,x;

	scanf("%d", &n);

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

		scanf("%d", &x);

		if(x%4==0){

			c++;

		}else if(x%2==0){

			b++;

		}else{

			a++;

		}

	}

	if(b==0){

		if(a-1>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}else{

		if(a>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}



	return 0;

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

#include <algorithm>

#include <cmath>

#include <deque>

#include <vector>

#include <queue>

#include <string>

#include <cstring>

#include <map>

#include <stack>

#include <set>

using namespace std;

int main(){

	int n,i,flag=0,flag2=0;

	cin>>n;

	long long a[n];

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

		cin>>a[i];

	}

	sort(a,a+n);

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

		if(a[i]%4==0){

			flag++;

		}

		if(a[i]%2==0&&a[i]%4!=0){

			flag2++;

		}

	}

	flag2/=2;

	int s=2*(flag+flag2)+1;

	if(n>s){

		cout<<"No"<<endl;

	}else{

		cout<<"Yes"<<endl;

	}

}

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

const int maxn = 100005;



int main(){

//	freopen("b.txt","r",stdin);

	int a=0,b=0,c=0,n,x;

	scanf("%d", &n);

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

		scanf("%d", &x);

		if(x%4==0){

			c++;

		}else if(x%2==0){

			b++;

		}else{

			a++;

		}

	}

	if(b==0){

		if(a-1>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}else{

		if(a>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}



	return 0;

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

#include<stdio.h>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<map>

#define ll long long

using namespace std;

int a[200009];

int main(){

    int n;

    cin>>n;

    int two=0;

    int fou=0;

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

        cin>>a[i];

 

        if(a[i]%4==0){

            fou++;

        }

        else if(a[i]%2==0){

            two++;

        }

    }

    n-=(two/2)*2;

    n-=fou;

    if(fou>=n-1){

        cout<<"Yes"<<endl;

    }

    else{

        cout<<"No"<<endl;

    }

}

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

const int maxn = 100005;



int main(){

//	freopen("b.txt","r",stdin);

	int a=0,b=0,c=0,n,x;

	scanf("%d", &n);

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

		scanf("%d", &x);

		if(x%4==0){

			c++;

		}else if(x%2==0){

			b++;

		}else{

			a++;

		}

	}

	if(b==0){

		if(a-1>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}else{

		if(a>c){

			printf("No\n");

		}else{

			printf("Yes\n");

		}

	}



	return 0;

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))





int main()

{

    LL n,m,M4=0,M2=0;

    cin>>n;

    LL  a[100002]= {0};

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

        cin>>a[i];

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

    {

        if(a[i]%4==0)

            M4++;

        else if(a[i]%2==0)

            M2++;

    }

    M2=M2/2*2;

    if(M4*2+1+M2>=n)

        cout<<"Yes";

    else

        cout<<"No";

}


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

using namespace std;

int main(){

	int a1=0,a2=0,a4=0,a;

	int n;

	scanf("%d",&n);

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

		scanf("%d",&a);

		if(a%4==0)	a4++;

		else if(a%2==0)	a2++;

		else a1++; 

	}

	if(a2==0&&a1<=a4+1){

		printf("Yes\n");return 0;

	}	

	if(a1<=a4&&a2>0){

		printf("Yes\n");return 0;

	}

	printf("No\n");

	return 0;

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

using namespace std;

int main(){

	int N;

	int num[100000]={0};

	cin>>N;

	int jishu=0,oushu=0,numfour=0;

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

		cin>>num[i];

		if(num[i]%4==0){

			numfour++;

		}else if(num[i]%2==0){

			oushu++;

		}else{

			jishu++;

		}

	}

	if(oushu){

		jishu++;

	}

	if(jishu-1>numfour){

		cout<<"No"<<endl;

	}else{

		cout<<"Yes"<<endl;

	}

	return 0;

}

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

using namespace std;

int main(){

	int a1=0,a2=0,a4=0,a;

	int n;

	scanf("%d",&n);

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

		scanf("%d",&a);

		if(a%4==0)	a4++;

		else if(a%2==0)	a2++;

		else a1++; 

	}

	if(a2==0&&a1<=a4+1){

		printf("Yes\n");return 0;

	}	

	if(a1<=a4&&a2>0){

		printf("Yes\n");return 0;

	}

	printf("No\n");

	return 0;

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

#include <cstdio>

#include <algorithm>

#include <cstring>

#include <string>

#include <map>

using namespace std;

int A[200005], c[200005];

int main()

{

    int n;

    while(~scanf("%d", &n))

    {

        memset(c, 0, sizeof(c));

        int ans = 0, m = 0, a, a2, b, b2;

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

        {

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

            m = max(m, A[i]);

        }

        int tmpa = 0, tmpa2 = 0, tmpb = 0, tmpb2 = 0;

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

            c[A[i]]++;

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

        {

            if(c[i] > tmpa)

            {

                swap(tmpa2, tmpa);

                swap(a, a2);

                tmpa = c[i];

                a = i;

            }

            else if(c[i] > tmpa2)

            {

                tmpa2 = c[i];

                a2 = i;

            }

        }

        memset(c, 0, sizeof(c));

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

            c[A[i]]++;

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

        {

            if(c[i] > tmpb)

            {

                swap(tmpb2, tmpb);

                swap(b, b2);

                tmpb = c[i];

                b = i;

            }

            else if(c[i] > tmpb2)

            {

                tmpb2 = c[i];

                b2 = i;

            }

        }

        if(a == b)

        {

            ans = n - max(tmpa + tmpb2, tmpb + tmpa2);

        }

        else

            ans = n - tmpa - tmpb;

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

    }

    return 0;

}


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

#include <cstdio>

#include <cstring>

#include <map>

#define fre

#define DEBUG

using namespace std;

map<int, int> m[2];

int main()

{

    int n, v;

    scanf("%d", &n);

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

    {

        scanf("%d", &v);

        m[0][v]++;

        scanf("%d", &v);

        m[1][v]++;

    }

    int mx[2][2][2], ans;

    memset(mx, 0, sizeof(mx));

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

    {

        for (auto s : m[i]) 

        {

            if (s.second > mx[i][0][0])

            {

                if (mx[i][0][0] > mx[i][1][0]) mx[i][1][0] = mx[i][0][0], mx[i][1][1] = mx[i][0][1];

                mx[i][0][0] = s.second, mx[i][0][1] = s.first;

            } 

            else if (s.second > mx[i][1][0]) mx[i][1][0] = s.second, mx[i][1][1] = s.first;

        }

    }

    if (mx[0][0][1] == mx[1][0][1]) ans = max(mx[0][0][0] + mx[1][1][0], mx[0][1][0] + mx[1][0][0]);

    else ans = mx[0][0][0] + mx[1][0][0];

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

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

#include <cstdio>

#include <algorithm>

#include <cstring>

#include <string>

#include <map>

using namespace std;

int A[200005], c[200005];

int main()

{

    int n;

    while(~scanf("%d", &n))

    {

        memset(c, 0, sizeof(c));

        int ans = 0, m = 0, a, a2, b, b2;

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

        {

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

            m = max(m, A[i]);

        }

        int tmpa = 0, tmpa2 = 0, tmpb = 0, tmpb2 = 0;

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

            c[A[i]]++;

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

        {

            if(c[i] > tmpa)

            {

                swap(tmpa2, tmpa);

                swap(a, a2);

                tmpa = c[i];

                a = i;

            }

            else if(c[i] > tmpa2)

            {

                tmpa2 = c[i];

                a2 = i;

            }

        }

        memset(c, 0, sizeof(c));

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

            c[A[i]]++;

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

        {

            if(c[i] > tmpb)

            {

                swap(tmpb2, tmpb);

                swap(b, b2);

                tmpb = c[i];

                b = i;

            }

            else if(c[i] > tmpb2)

            {

                tmpb2 = c[i];

                b2 = i;

            }

        }

        if(a == b)

        {

            ans = n - max(tmpa + tmpb2, tmpb + tmpa2);

        }

        else

            ans = n - tmpa - tmpb;

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

    }

    return 0;

}


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

#include <algorithm>

using namespace std;



int arr[100010];

int cta[100010], ctb[100010];



int main() {

	int n;

	scanf("%d", &n);

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

		scanf("%d", arr + i);

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

		if (i % 2) ++ctb[arr[i]];

		else ++cta[arr[i]];

	}

	int mx1 = 0, mx2 = 0;

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

		if (cta[i] > cta[mx1])

			mx1 = i;

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

		if (ctb[i] > ctb[mx2])

			mx2 = i;

	if (mx1 != mx2)

		printf("%d\n", n - cta[mx1] - ctb[mx2]);

	else {

		int smx1 = 0, smx2 = 0;

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

			if (i != mx1 && cta[i] > cta[smx1])

				smx1 = i;

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

			if (i != mx2 && ctb[i] > ctb[smx2])

				smx2 = i;

		printf("%d\n", min(n - cta[mx1] - ctb[smx2], n - cta[smx1] - ctb[mx2]));

	}

	return 0;

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

#include <iomanip>

#include <bits/stdc++.h>

#include <vector>

#include <iterator>

#include <string>

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

#define ll long long int

#define vi vector<int>

#define pb push_back

#define INF 1e9+7

#define PI 3.141592653

#define inf 200001

using namespace std; 





int main(){

    int n;

    cin>>n;

    vi v,p;

    pan(i,n){int x;

        cin>>x;

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

        else p.pb(x);

    }

    int o=0,o1=-1,e=0,e1=-1,x[inf],y[inf];

    memset(x,0,sizeof(x));

    memset(y,0,sizeof(y));

    for(int i=0;i<v.size();i++) x[v[i]]++;

    int ce=*max_element(x,x+inf);

    e=distance(x,max_element(x,x+inf));

    x[e]=0;

    int ce1=*max_element(x,x+inf);

    e1=distance(x,max_element(x,x+inf));

    pan(i,p.size()) y[p[i]]++;

    int co=*max_element(y,y+inf);

    o=distance(y,max_element(y,y+inf));

    y[o]=0;

    int co1=*max_element(y,y+inf);

    o1=distance(y,max_element(y,y+inf));

    int ans=0;

    if(o!=e) ans=n-co-ce;

    else{

        ans=min(n-co-ce1,n-co1-ce);

    }

    // cout<<co<<" "<<ce1<<endl;

    cout<<ans;

}

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

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

#define ll long long int

#define vi vector<int>

#define pb push_back

#define INF 1e9+7

#define inf 100001

#define PI 3.141592653

using namespace std; 



int main(){

    int n;

    cin>>n;

    vi v,p;

    pan(i,n){int x;

        cin>>x;

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

        else p.pb(x);

    }

    int o=0,o1=-1,e=0,e1=-1,x[inf],y[inf];

    memset(x,0,sizeof(x));

    memset(y,0,sizeof(y));

    for(int i=0;i<v.size();i++) x[v[i]]++;

    int ce=*max_element(x,x+inf);

    e=distance(x,max_element(x,x+inf));

    x[e]=0;

    int ce1=*max_element(x,x+inf);

    e1=distance(x,max_element(x,x+inf));

    pan(i,p.size()) y[p[i]]++;

    int co=*max_element(y,y+inf);

    o=distance(y,max_element(y,y+inf));

    y[o]=0;

    int co1=*max_element(y,y+inf);

    o1=distance(y,max_element(y,y+inf));

    int ans=0;

    if(o!=e) ans=n-co-ce;

    else{

        ans=min(n-co-ce1,n-co1-ce);

    }

    cout<<ans;

}
// 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: 2.050810161611123x):
#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);

}
// 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: 1.8597661190783579x):
#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; 

}