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)

#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var n = Console.ReadLine().ToInt32();
        var vi = Console.ReadLine().SplittedStringToInt32List();
        var vikisuu = new Dictionary<int,int>();
        var viguusuu = new Dictionary<int,int>();
        var counts = vi.Count;
        for (int i = 0; i < counts; i++)
        {
            var num = vi[i];
            if (i % 2 == 0)
            {
                if (!vikisuu.ContainsKey(num))
                    vikisuu.Add(num, 1);
                else
                    vikisuu[num]++;
            }
            else
            {
                if (!viguusuu.ContainsKey(num))
                    viguusuu.Add(num, 1);
                else
                    viguusuu[num]++;
            }
        }
        
        var numgusuu = viguusuu.OrderByDescending(x => x.Value).First();
        var numkisuu = vikisuu.OrderByDescending(x => x.Value).First();

        if (numgusuu.Key == numkisuu.Key)
        {
            try
            {
                if (numgusuu.Value <= numkisuu.Value)
                {
                    numgusuu = viguusuu.OrderByDescending(x => x.Value).First(x => x.Key != numkisuu.Key);

                }
                else
                {
                    numkisuu = vikisuu.OrderByDescending(x => x.Value).First(x => x.Key != numgusuu.Key);
                }
            }
            catch
            {
                Console.WriteLine(n / 2);
                Console.ReadLine();
                return;
            }
        }
        Console.WriteLine(n - numgusuu.Value - numkisuu.Value);
        Console.ReadLine();
    }


    //public class Edge
    //{
    //    public int From;
    //    public int To;
    //    public int Cost;
    //}

    //public static List<KeyValuePair<int, int>> GetShortestPathes(int s, IEnumerable<Edge> edges, int vertices)
    //{
    //    var ls = new KeyValuePair<int, int>[vertices];

    //    return ls.ToList();
    //}


    #region ライブラリ

    #region 文字列処理

    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();

    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
    #region DeepClone
    public static T DeepClone<T>(this T src)
    {
        using (var memoryStream = new MemoryStream())
        {
            var binaryFormatter
              = new BinaryFormatter();
            binaryFormatter.Serialize(memoryStream, src);
            memoryStream.Seek(0, SeekOrigin.Begin);
            return (T)binaryFormatter.Deserialize(memoryStream);
        }
    }
    #endregion

    public static int Gcd(int a, int b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }
    public static BigInteger Gcd(BigInteger a, BigInteger b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }


    public static BigInteger Factorial(int n)
    {
        var dp = new BigInteger[n];
        dp[0] = 1;
        for (int i = 1; i < n; i++)
        {
            dp[i] = dp[i - 1] * (i + 1);
        }
        return dp[n - 1];
    }

    public static List<int> PrimeFactorize(int n)
    {
        var bases = n;
        var num = (int)Math.Pow(n, 0.5);
        var ls = new List<int>();
        for (int i = 2; i <= num; i++)
        {
            if (n % i == 0)
            {
                n = n / i;
                ls.Add(i);
                i--;
                continue;
            }
        }
        var nnn = 1;
        foreach (var item in ls)
        {
            nnn = nnn * item;
        }
        if (nnn != bases)
            ls.Add(n);
        return ls;
    }

    #endregion

}