Problem:
Score : 300 points

Problem Statement

A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:

For each i = 1,2,..., n-2, a_i = a_{i+2}.

Exactly two different numbers appear in the sequence.

You are given a sequence v_1,v_2,...,v_n whose length is even.
We would like to make this sequence /\/\/\/ by replacing some of its elements.
Find the minimum number of elements that needs to be replaced.

Constraints

2 \leq n \leq 10^5

n is even.

1 \leq v_i \leq 10^5

v_i is an integer.

Input

Input is given from Standard Input in the following format:

n
v_1 v_2 ... v_n

Output

Print the minimum number of elements that needs to be replaced.

Sample Input 1

4
3 1 3 2

Sample Output 1

1

The sequence 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.

Sample Input 2

6
105 119 105 119 105 119

Sample Output 2

0

The sequence 105,119,105,119,105,119 is /\/\/\/.

Sample Input 3

4
1 1 1 1

Sample Output 3

2

The elements of the sequence 1,1,1,1 are all the same, so it is not /\/\/\/.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
#define inl long long
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}
void keta(string s) {
	for (int i = 0; i < s.size(); i++) {

	}
}
int main() {
	inl n = 0;
	cin >> n;
	inl a = 0;
	inl kisu[200000] = { 0 }, gusu[200000] = {0};
	vector<inl> kisuv, gusuv;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (i % 2 == 0) {
			if (kisu[a - 1] == 0) {
				kisuv.push_back(a);
              //cout<<a<<endl;
				
			}
			kisu[a - 1]++;
		}
		else {
			if (gusu[a - 1] == 0) {
				gusuv.push_back(a);
              //cout<<a<<endl;

			}
			gusu[a - 1]++;
		}
      //cout<<gusu[1]<<endl;
	}
	inl kisuf = 0, kisus = 0,kisum=0;
  //cout<<kisuv.size()<<endl;
	for (int i = 0; i < kisuv.size(); i++) {
		kisum = kisuf;
      //cout<<kisuv[i]-1<<endl;
      if(kisuf==0||kisu[kisuv[i]-1]>kisu[kisuf-1]){
		kisuf =kisuv[i];
      }
      
		if (kisuf != kisuv[i]) {
           if(kisum==0||kisu[kisuv[i]-1]>kisu[kisum-1]){
		      kisum =kisuv[i];
           }
		}
		else{
			kisus = kisum;
		}
      //cout<<kisus<<kisuf<<endl;
	}
	inl gusuf = 0, gusus = 0, gusum = 0;
	for (int i = 0; i < gusuv.size(); i++) {
		if(gusuf==0||gusu[gusuv[i]-1]>gusu[gusuf-1]){
		gusuf =gusuv[i];
      }
      
		if (gusuf != gusuv[i]) {
           if(gusum==0||gusu[gusuv[i]-1]>gusu[gusum-1]){
		      gusum =gusuv[i];
           }
		}
		else{
			gusus = gusum;
		}
      //cout<<gusus<<gusuf<<endl;
	}
	
	if (gusuf != kisuf) {
		cout << n - kisu[kisuf - 1] - gusu[gusuf - 1];
      
		return 0;
	}
 // cout<<gusuf<<endl;
  //cout<<kisuf<<endl;
	inl ans1 = 0, ans2 = 0;
	ans1=n- kisu[kisum - 1] - gusu[gusuf - 1];
	ans2= kisu[kisuf - 1] - gusu[gusum - 1];
	cout << min(ans1, ans2) << endl;
	return 0;
}