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 <cstdio>
#include <cstring>
#include <algorithm>

#define ll long long
#define inf 0x3f3f3f3f 
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)

inline void read( int &x ){
    x = 0 ; int f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    x *= f ;
}

inline void readl( ll &x ){
    x = 0 ; ll f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    x *= f ;
}

using namespace std ;

#define N 100010

int a[ N ] , n , m ; 
int cnt1[ N ] , cnt2[ N ] ;

int main() {
	scanf( "%d" , &n ) ;
	for( int i = 1 ; i <= n ; i ++ ) {
		scanf( "%d" , &a[ i ] ) ; 
		if( a[ i ] & 1 ) cnt1[ a[ i ] ] ++ ;
		else cnt2[ a[ i ] ] ++ ;
	}
	int p1 , p2 , mx1 , mx2 , P1 , P2 , M1 , M2 ; 
	for( int i = 1 ; i <= int( 1e5 ) ; i ++ ) {
		if( cnt1[ i ] > mx1 ) {
			swap( p1 , p2 ) ;
			swap( mx1 , mx2 ) ;
			mx1 = cnt1[ i ] ;
			p1 = i ;
		}else if( cnt1[ i ] > mx2 ) {
			mx2 = cnt1[ i ] ;
			p2 = i ;
		}
		if( cnt2[ i ] > M1 ) {
			swap( P1 , P2 ) ;
			swap( M1 , M2 ) ;
			M1 = cnt2[ i ] ;
			P1 = i ;
		}else if( cnt2[ i ] > M2 ) {
			M2 = cnt2[ i ] ;
			P2 = i ;
		} 
	}
	if( p1 != P1 ) {
		printf( "%d\n" , n - M1 - mx1 ) ;
	}else {
		printf( "%d\n" , n - max( M1 + mx2 , M2 + mx1 ) ) ;
	}
	return 0 ;
}