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.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;

class _Class
{
  void _Do()
  {
    var N = Split.ints()[0];
    var vn = Split.ints();

    var a = new Dictionary<int,int>();
    var b = new Dictionary<int,int>();
    for (int i = 0; i < N; i += 2)
    {
      if (!a.ContainsKey(vn[i]))
        a.Add(vn[i],0);
      a[vn[i]]++;
      if (!b.ContainsKey(vn[i+1]))
        b.Add(vn[i+1], 0);
      b[vn[i+1]]++;
    }

    //
    int ret = 0;
    {
      int maxa = 0;
      int z = 0;
      foreach (var i in a)
      {
        if (i.Key > maxa)
        {
          maxa = i.Value;
          z = i.Key;
        }
      }
      int maxb = 0;
      foreach (var i in b)
      {
        if (i.Key == z)
          continue;
        if (i.Value > maxb)
          maxb = i.Value;
      }
      ret = N / 2 - maxa + N / 2 - maxb;
    }
    int ret2 = 0;
    {
      int maxb = 0;
      int z = 0;
      foreach (var i in b)
      {
        if (i.Key > maxb)
        {
          maxb = i.Value;
          z = i.Key;
        }
      }
      int maxa = 0;
      foreach (var i in a)
      {
        if (i.Key == z)
          continue;
        if (i.Value > maxa)
          maxa = i.Value;
      }
      ret2 = N / 2 - maxa + N / 2 - maxb;
    }
    if(ret<ret2)
      Console.WriteLine(ret);
    else
      Console.WriteLine(ret2);
  }



  static void Main(string[] args)
  {
    _(args);
    new _Class()._Do();
  }

  [Conditional("DEBUG")]
  static void _(string[] args)
  {
    if (args.Length != 0 && File.Exists(args[0]))
      Console.SetIn(new StreamReader(args[0]));
    else
      Console.Error.WriteLine("in");
  }
}

static class Split
{


  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}