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 <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;

typedef signed long long ll;

int main()
{
	
	int n;
	cin >> n;
	vector<int>ki(n/2);
	vector<int>gu(n);
	vector<int> lo(n / 2);
	
	
	for (int i = 0; i < n; i++) {
		cin >> gu[i];
		if (i % 2 == 0) {
		 lo[i/2]=gu[i];
		}
		else {
			ki[(i - 1) / 2] = gu[i];

		}
			//if(i%2==0)
				//ki[i] = gu[i];
			//if (i % 2 == 1)
				//lo[i] = gu[i];
		
	}
	/*vector<int> counter(n);
	int answer;
	sort(ki.begin(), ki.end());
	auto itr = unique(ki.begin(), ki.end());
	ki.erase(itr, ki.end());
	int m = ki.size();*/
	/*for (int j = 0; j < n-2; j++) {*/
		
		/*if (j % 2 == 0) {
			counter[j] = 0;*/

	int temp_mode, temp_cnt, cnt, mode,s_cnt,s_mode;
	mode = 0;
	cnt = 0;
	s_cnt = 0;
	for (int i = 0; i < n/2; i++) {
		temp_cnt = 1;
		for (int j = i + 1; j < n/2; j++) {
			if (ki[i] == ki[j]) {
				temp_cnt++;
			}
		}
		if (temp_cnt > cnt) {
			s_cnt = cnt;
			s_mode = mode;
			cnt = temp_cnt;
			mode = ki[i];
			
		}
		else if (s_cnt < temp_cnt&& ki[i] != mode) {
			s_cnt = temp_cnt;
			s_mode = ki[i];
		}
	}


	int temp_mode_1, temp_cnt_1, cnt_1, mode_1,s_cnt_1,s_mode_1;
	mode_1 = 0;
	cnt_1 = 0;
	

	for (int i = 0; i < n / 2; i++) {
		temp_cnt_1 = 1;
		for (int j = i + 1; j < n / 2; j++) {
			if (lo[i] == lo [j]) {
				temp_cnt_1++;
			}
		}
		if (temp_cnt_1 > cnt_1) {
			s_cnt_1 = cnt_1;
			s_mode_1 = mode_1;
			cnt_1 = temp_cnt_1;
			mode_1 = lo[i];
		}
		else if (temp_cnt > s_cnt_1&&lo[i] != mode_1) {
			s_cnt_1 = temp_cnt_1;
			s_mode_1 = lo[i];
		}
	}
	
	//cout << "0" << mode << s_mode <<" "<< mode_1 << s_mode_1<<endl;
	
	
	int counter = 0;
	int counter_1 =0;
	if (mode == mode_1) {
		for (int i = 0; i < n; i++) {



			if (i % 2 == 0) {
				if (mode_1 != gu[i]) {
					//cout << mode_1 <<" a"<< endl;
					counter++;
				}
				if (s_mode_1 != gu[i]) {
					counter_1++;
				}

			}
			else {
				if (mode != gu[i]) {
					//cout << mode << " b" <<gu[i]<< endl;
					counter_1++;
				}

				if (s_mode != gu[i]) {
					counter++;
				}
			}
		}

		
		counter = min(counter, counter_1);

	}
	else {


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



			if (i % 2 == 0) {
				if (mode_1 != gu[i]) {
					//cout << mode_1 <<" a"<< endl;
					counter++;
				}

			}
			else {
				if (mode != gu[i]) {
					//cout << mode << " b" <<gu[i]<< endl;
					counter++;
				}
			}
		}
	}
			//answer = min(answer, counter[j]);
		//}
		
		
	/*}*/

	cout<<  counter<< endl;
}