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

namespace ABC111C
{
    static class MainClass
    {

        public static void Main(string[] args)
        {


            int N = int.Parse(Console.ReadLine());
            string[] vstr = Console.ReadLine().Split(' ');

            var vlist = new List<int>();
            var vodd = new List<int>();
            var veven = new List<int>();
            for (int i = 0; i < N; i++)
            {
                if (i % 2 == 1)
                {
                    vodd.Add(int.Parse(vstr[i]));
                }
                else
                {
                    veven.Add(int.Parse(vstr[i]));
                }
            }


            var voddgrp = vodd.GroupBy(a => a)
                .Select(col => new { num = col.Key, cnt = col.Count() }).OrderByDescending(a => a.cnt);
            var vevengrp = veven.GroupBy(a => a)
                .Select(col => new { num = col.Key, cnt = col.Count() }).OrderByDescending(a => a.cnt);

            int omax1 = 0;
            int emax1 = 0;
            int omax1cnt = 0;
            int emax1cnt = 0;
            omax1 = voddgrp.First().num;
            emax1 = vevengrp.First().num;
            omax1cnt = voddgrp.First().cnt;
            emax1cnt = vevengrp.First().cnt;
            if (omax1 == emax1)
            {
                //偶数が複数あれば一つ減らす
                if (vevengrp.Count() > 1)
                {
                    emax1 = vevengrp.ElementAt(1).num;
                    emax1cnt = vevengrp.ElementAt(1).cnt;
                }
                //一つしかなければ
                else
                {
                    if (voddgrp.Count() > 1)
                    {
                        omax1 = voddgrp.ElementAt(1).num;
                        omax1cnt = voddgrp.ElementAt(1).cnt;
                    }
                    else
                    {
                        //全部同じ値のパターン
                        Console.WriteLine(N / 2);
                        return;
                    }
                }
            }


            int omax2 = 0;
            int emax2 = 0;
            int omax2cnt = 0;
            int emax2cnt = 0;
            omax2 = voddgrp.First().num;
            emax2 = vevengrp.First().num;
            omax2cnt = voddgrp.First().cnt;
            emax2cnt = vevengrp.First().cnt;
            if (omax2 == emax2)
            {
                if (voddgrp.Count() > 1)
                {
                    omax2 = voddgrp.ElementAt(1).num;
                    omax2cnt = voddgrp.ElementAt(1).cnt;
                }
                else
                {
                    if (vevengrp.Count() > 1)
                    {
                        emax2 = vevengrp.ElementAt(1).num;
                        emax2cnt = vevengrp.ElementAt(1).cnt;

                    }
                    else
                    {
                        //全部同じ値のパターン
                        Console.WriteLine(N / 2);
                        return;
                    }
                }
            }




            int idx = 0;
            int o1 = 0;
            int e1 = 0;
            int o2 = 0;
            int e2 = 0;

            if (omax1cnt >= omax2cnt)
            {
                var o1list = voddgrp.ToList();
                var e1list = vevengrp.ToList();
                idx = voddgrp.Select(a => a.cnt).ToList().IndexOf(omax1cnt);
                o1list.RemoveAt(idx);
                idx = vevengrp.Select(a => a.cnt).ToList().IndexOf(emax1cnt);
                e1list.RemoveAt(idx);
                o1 = o1list.Select(a => a.cnt).Sum();
                e1 = e1list.Select(a => a.cnt).Sum();
            }
            else
            {
                var o2list = voddgrp.ToList();
                var e2list = vevengrp.ToList();
                idx = voddgrp.Select(a => a.cnt).ToList().IndexOf(omax2cnt);
                o2list.RemoveAt(idx);
                idx = vevengrp.Select(a => a.cnt).ToList().IndexOf(emax2cnt);
                e2list.RemoveAt(idx);
                o2 = o2list.Select(a => a.cnt).Sum();
                e2 = e2list.Select(a => a.cnt).Sum();
            }


            if (o1 + e1 <= o2 + e2)
            {
                Console.WriteLine(o1 + e1);
            }
            else
            {
                Console.WriteLine(o2 + e2);
            }


            return;
        }

    }

}