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.Collections;
using System.Collections.Generic;
using System.Linq;


public class MyProgram
{	
  
    public static void Main()
	{
      　int n = int.Parse(Console.ReadLine());
        int[] nCount1 = new int[100000];
        int[] nCount2 = new int[100000];
        
        int[] ns = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        
        int a1 = 0, a2 = 0 , b1 = 0 , b2 = 0;
        
        Dictionary <int,int> nums1 = new Dictionary<int,int>();
        Dictionary <int,int> nums2 = new Dictionary<int,int>();
        
        for(int i = 0 ; i < n ; i++)
        {
            if(i % 2 == 0)
            {
                if(!nums1.Keys.Contains(ns[i])) nums1.Add(ns[i],1);
                else nums1[ns[i]]++;
            }
            else
            {
            if(!nums2.Keys.Contains(ns[i])) nums2.Add(ns[i],1);
            else nums2[ns[i]]++;
            }
        }
        nums1 = nums1.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
        var sorted = nums1.OrderByDescending((x) => x.Value);
        List <int> sss1 = new List<int>();
        foreach (var p in sorted) sss1.Add(p.Key);
        a1 = nums1[sss1[0]];
        
        nums2 = nums2.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
        sorted = nums2.OrderByDescending((x) => x.Value);
        List <int> sss2 = new List<int>();
        foreach (var p in sorted) sss2.Add(p.Key);
        b1 = nums2[sss2[0]];
        
        if(sss1[sss1.Count-1] != sss2[sss2.Count-1])
        {
            Console.WriteLine(n-a1-b1);
        }
        else
        {
            if(sss1.Count > 1) a2 = nums1[sss1[1]];
            if(sss2.Count > 1) b2 = nums2[sss2[1]];
            
            int a1b2 = n - a1 - b2;
            int a2b1 = n - a2 - b1;
            
            Console.WriteLine(Math.Min(a1b2,a2b1));
        }
    }
}