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# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Linq;
using System.Collections.Generic;


class Program
{
    static void Main(string[] args)
    {

        int N = int.Parse(Console.ReadLine());

        var v = Console.ReadLine().Split().Select(int.Parse).ToArray();
        

        int[] odd = new int[N/2];
        int[] even = new int[N/2];
        int total = 0 ;

       
        
        for(int i = 0; i <N/2; i++)
        {
            even[i]=v[i*2];
            odd[i]=v[(i*2)+1];
        }

        int cnt=0;
        for (int i= 0; i < N-1; i++)
        {
            if (v[i] == v[i + 1])
            {
                cnt++;
            }
        }
        if (cnt == N - 1)
        {
            Console.WriteLine(N / 2);
            return;
        }

        Array.Sort(even);
        Array.Sort(odd);

        //最頻値の数と値
        int[] max_count = new int[2];
      
        //最頻値から二番目
        int[] second_count = new int[2];
        //現在の数字のカウント
        int count = 1;
        
        int now=even[0];
        max_count[0] = 1;
        max_count[1] = now;
        second_count[0] = 1;
        second_count[1] = now;
        for(int i = 1; i < N/2; i++)
        {
            if (now == even[i])
            {
                count += 1;
            }
            else
            {
                now = even[i];
                
            }
            if (max_count[0] < count)
            {
                second_count[0] = max_count[0];
                second_count[1] = max_count[1];
                max_count[0] = count;
                max_count[1] = even[i];
            }
        }
        int even_max = max_count[1];
        int even_max_num = max_count[0];

        int even_second = second_count[1];
        int even_second_num=second_count[0];

        total += (N/2-max_count[0]);


        count = 1;
        now = odd[0];
        max_count[0] = 1;
        max_count[1] = now;
        second_count[0] = 1;
        second_count[1] = now;
        for (int i = 1; i < N/2; i++)
        {
            if (now == odd[i])
            {
                count += 1;
            }
            else
            {
                now = odd[i];
                
            }
            if (max_count[0] < count)
            {
                second_count[0] = max_count[0];
                second_count[1] = max_count[1];
                max_count[0] = count;
                max_count[1] = odd[i];
            }
        }
        int odd_max = max_count[1];
        int odd_max_num = max_count[0];

        int odd_second = second_count[1];
        int odd_second_num = second_count[0];

        if (odd_max == even_max)
        {
            if ((N / 2 - even_max_num) + (N / 2 - odd_second_num) > (N / 2 - odd_max_num) + (N / 2 - even_second_num))
            {
                Console.WriteLine((N / 2 - odd_max_num) + (N / 2 - even_second_num));
                return;
            }
            else
            {
                Console.WriteLine((N / 2 - even_max_num) + (N / 2 - odd_second_num));
                return;
            }
        }

        total += (N/2-max_count[0]);

        Console.WriteLine(total);
    }

}