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)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        v: [i32; n],
    }

    let mut hist1 = std::collections::BTreeMap::new();
    let mut hist2 = std::collections::BTreeMap::new();

    for i in 0..n {
        if i % 2 == 0 {
            *hist1.entry(v[i]).or_insert(0) += 1;
        } else {
            *hist2.entry(v[i]).or_insert(0) += 1;
        }
    }
    let mut v1 = vec![];
    for h in hist1 {
        v1.push((h.1, h.0));
    }
    v1.sort();
    v1.reverse();
    let mut v2 = vec![];
    for h in hist2 {
        v2.push((h.1, h.0));
    }
    v2.sort();
    v2.reverse();

    if v1[0].1 != v2[0].1 {
        println!("{}", n - v1[0].0 - v2[0].0);
    } else if v1.len() != 1 && v2.len() != 1 {
        if v1[1].1 > v2[1].1 {
            println!("{}", n - v1[0].0 - v2[1].0);
        } else {
            println!("{}", n - v1[1].0 - v2[0].0);
        }
    } else if v1.len() != 1 {
        println!("{}", n - v1[1].0 - v2[0].0);
    } else if v2.len() != 1 {
        println!("{}", n - v1[0].0 - v2[1].0);
    } else {
        println!("{}", n / 2);
    }
}
*/

fn main() {
    let exe = "/tmp/bin5FA75703";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";