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 Rust (1.15.1) (judge verdict: Wrong Answer)

#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;


static INF_I64 :i64 = 9223372036854775807;
static INF_I32 : i32 = 2147483647;




fn main() {

    input! { 
       n: usize,
       v : [i64;n],
    }

    let mut ans = 0;
    let mut a = vec![0;n/2];
    let mut b = vec![0;n/2];
    let mut a1 = std::collections::HashMap::new();
    let mut b1 = std::collections::HashMap::new();

    let mut index = 0;
    while(true){
        if index >= n { break;};
        
        a[index/2] = v[index];
        b[index/2] = v[index+1];

        let mut c = a1.entry(a[index/2]).or_insert(0_usize);
        *c+=1;
        let mut c2 = b1.entry(b[index/2]).or_insert(0_usize);
        *c2+=1;

        index+=2;
    }

    mydbg!(a1);

    let mut ac = vec![(0,0);n/2];
    let mut bc = vec![(0,0);n/2];
    let mut index = 0;
    for item in a1.iter(){
        ac[index] = (*item.0, *item.1);
        index+=1;

    }
    let mut index = 0;
    for item in b1.iter(){
        bc[index] = (*item.0, *item.1);
        index+=1;

    }

    ac.sort_by_key(|x|{return x.1});
    bc.sort_by_key(|x|{return x.1});
    ac.reverse();
    bc.reverse();
    ans = n - ac[0].1 - bc[0].1;

    if(ac[0].0 == bc[0].0){
        let av = ac[0].1;
        let bv = bc[0].1;
        ans = 0;
        ac.remove(0);
        bc.remove(0);
        ans = cmp::max(ans , n - av - bc[0].1);
        ans = cmp::max(ans , n - bv - ac[0].1);
        
    }


    
    
    println!("{}",ans);


}