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: Runtime Error)

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];
        
        string[] ns = Console.ReadLine().Split(' ');
        
        string a1 = "";
        string a2 = "";
        string b1 = "";
        string b2 = "";
        
        Dictionary <string,int> nums1 = new Dictionary<string,int>();
        Dictionary <string,int> nums2 = new Dictionary<string,int>();
        
        for(int i = 0 ; i < n ; i += 2)
        {
            if(!nums1.Keys.Contains(ns[i]))
            {
                nums1.Add(ns[i],1);
            }
            else
            {
                nums1[ns[i]]++;
            }
            
        }
        var sorted = nums1.OrderBy((x) => x.Value);
        List <string> sss1 = new List<string>();
        foreach (var p in sorted)
        {
            sss1.Add(p.Key);
        }
        a1 = sss1[sss1.Count-1];
        
        for(int i = 1 ; i < n ; i += 2)
        {
            if(!nums2.Keys.Contains(ns[i]))
            {
                nums2.Add(ns[i],1);
            }
            else
            {
                nums2[ns[i]]++;
            }
            
        }
        sorted = nums2.OrderBy((x) => x.Value);
        List <string> sss2 = new List<string>();
        foreach (var p in sorted) sss2.Add(p.Key);
        b1 = sss2[sss2.Count-1];
        
        for(int i = sss1.Count-1 ; i > 0 ; i++)
        {
            if(b1 != sss1[i])
            {
                a2 = sss1[i];
                break;
            }
        }
        for(int i = sss1.Count-1 ; i > 0 ; i++)
        {
            if(a1 != sss2[i])
            {
                b2 = sss2[i];
                break;
            }
        }
        
        int cnt1 = 0;
        int cnt2 = 0;
        
        for(int i = 0 ; i < sss1.Count ; i++)
        {
            if(a1 != sss1[i]) cnt1++;
            if(a2 != sss1[i]) cnt2++;
            if(b1 != sss2[i]) cnt1++;
            if(b2 != sss2[i]) cnt2++;
        }
        
        bool same = true;
        for(int i = 0 ; i < sss1.Count ; i++)
        {
            if(sss1[i] != sss2[i]) same = false;
        }
        
        if(same) Console.WriteLine(n/2);
        else Console.WriteLine(Math.Min(cnt2,cnt1));
    }
}