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 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  int v[MAX];
  scanf("%d", &n);
  rep(i, 0, n) {
    scanf("%d", &v[i]);
  }

  int cnt1[MAX] = {0};
  int cnt2[MAX] = {0};
  for (int c1 = 0; c1 < n; c1 += 2)
    cnt1[v[c1]]++;
  for (int c2 = 1; c2 < n; c2 += 2)
    cnt2[v[c2]]++;

  int max1 = 0, next1 = 0;
  int max2 = 0, next2 = 0; 
  for (int c = 0; c <= MAX; c++) {
    if (cnt1[c] > cnt1[max1]) {
      next2 = max1;
      max1 = c;
    } else if (cnt1[c] > cnt1[next1]) 
      next1 = c;
    if (cnt2[c] > cnt2[max2]) {
      next2 = max2;
      max2 = c;
    } else if (cnt2[c] > cnt2[next2]) 
      next2 = c;
  }
  
  int ans;
  if (max1 == max2) {
    if (cnt1[next1] >= cnt2[next2]) 
      ans = n - cnt1[next1] - cnt2[max2];
    else 
      ans = n - cnt1[max1] - cnt2[next2];
  } else
    ans = n - cnt1[max1] - cnt2[max2];

  printf("%d\n", ans);
  return 0;
}