stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>



using namespace std;

int cnt4,cnt2,n;

int a;



int main()

{

    scanf("%d",&n);

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

    {

        scanf("%d",&a);

        if(a%4==0)

            cnt4++;

            else if(a%2==0)

                cnt2++;

    }

    if(cnt2+cnt4*2<n-1)

        printf("No\n");

        else if(cnt4*2+cnt2==n-1&&cnt2!=0)

            printf("No\n");

            else

                printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}




// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>



using namespace std;

int cnt4,cnt2,n;

int a;



int main()

{

    scanf("%d",&n);

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

    {

        scanf("%d",&a);

        if(a%4==0)

            cnt4++;

            else if(a%2==0)

                cnt2++;

    }

    if(cnt2+cnt4*2<n-1)

        printf("No\n");

        else if(cnt4*2+cnt2==n-1&&cnt2!=0)

            printf("No\n");

            else

                printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>



using namespace std;

int cnt4,cnt2,n;

int a;



int main()

{

    scanf("%d",&n);

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

    {

        scanf("%d",&a);

        if(a%4==0)

            cnt4++;

            else if(a%2==0)

                cnt2++;

    }

    if(cnt2+cnt4*2<n-1)

        printf("No\n");

        else if(cnt4*2+cnt2==n-1&&cnt2!=0)

            printf("No\n");

            else

                printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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";

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>



using namespace std;

int cnt4,cnt2,n;

int a;



int main()

{

    scanf("%d",&n);

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

    {

        scanf("%d",&a);

        if(a%4==0)

            cnt4++;

            else if(a%2==0)

                cnt2++;

    }

    if(cnt2+cnt4*2<n-1)

        printf("No\n");

        else if(cnt4*2+cnt2==n-1&&cnt2!=0)

            printf("No\n");

            else

                printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>



using namespace std;

int cnt4,cnt2,n;

int a;



int main()

{

    scanf("%d",&n);

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

    {

        scanf("%d",&a);

        if(a%4==0)

            cnt4++;

            else if(a%2==0)

                cnt2++;

    }

    if(cnt2+cnt4*2<n-1)

        printf("No\n");

        else if(cnt4*2+cnt2==n-1&&cnt2!=0)

            printf("No\n");

            else

                printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>



using namespace std;

int cnt4,cnt2,n;

int a;



int main()

{

    scanf("%d",&n);

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

    {

        scanf("%d",&a);

        if(a%4==0)

            cnt4++;

            else if(a%2==0)

                cnt2++;

    }

    if(cnt2+cnt4*2<n-1)

        printf("No\n");

        else if(cnt4*2+cnt2==n-1&&cnt2!=0)

            printf("No\n");

            else

                printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

	}

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>



using namespace std;

int cnt4,cnt2,n;

int a;



int main()

{

    scanf("%d",&n);

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

    {

        scanf("%d",&a);

        if(a%4==0)

            cnt4++;

            else if(a%2==0)

                cnt2++;

    }

    if(cnt2+cnt4*2<n-1)

        printf("No\n");

        else if(cnt4*2+cnt2==n-1&&cnt2!=0)

            printf("No\n");

            else

                printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

    }

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>



using namespace std;

int cnt4,cnt2,n;

int a;



int main()

{

    scanf("%d",&n);

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

    {

        scanf("%d",&a);

        if(a%4==0)

            cnt4++;

            else if(a%2==0)

                cnt2++;

    }

    if(cnt2+cnt4*2<n-1)

        printf("No\n");

        else if(cnt4*2+cnt2==n-1&&cnt2!=0)

            printf("No\n");

            else

                printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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);

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: