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 /\/\/\/.



Sample input:
4
3 1 3 2


Sample output:
1

Submission status: Wrong Answer

Solution code:
# 数列を2つに分割。arr1, arr2とする。
# arr1, arr2

from collections import *
N = int(input())
As = list(map(int, input().split()))

def solve(arr1, arr2):
    cnt1 = Counter(arr1)
    cnt2 = Counter(arr2)

    # 最大出現文字の集合を得る
    most1 = cnt1.most_common()
    most2 = cnt2.most_common()

    if len(most1) > 1 or len(most2) > 1:
        return len(arr1) - most1[0][1] + len(arr2) - most2[0][1]
    elif most1[0][0] != most2[0][0]:
        return 0
    else:
        try:
            ans1 = len(arr1) - most1[0][1] \
                + len(arr2) - cnt2.most_common(2)[1][1]
        except:
            ans1 = len(arr1) - most1[0][1] \
                + len(arr2)
        try:
            ans2 = len(arr2) - most2[0][1] \
                + len(arr1) - cnt1.most_common(2)[1][1]
        except:
            ans2 = len(arr2) - most2[0][1] \
                + len(arr1)
        return min(ans1, ans2)


arr1 = As[0::2]
arr2 = As[1::2]
print(solve(arr1, arr2))

Submission status: Wrong Answer

Solution code:
from collections import *
N = int(input())
As = list(map(int, input().split()))

def solve(arr1, arr2):
    cnt1 = Counter(arr1)
    cnt2 = Counter(arr2)
    ans = len(arr1) - cnt1.most_common()[0][1]
    if cnt1.most_common()[0][0] != cnt2.most_common()[0][0]:
        ans += len(arr2) - cnt2.most_common()[0][1]
    else:
        if cnt2.most_common()[0][1] == len(arr2):
            ans += len(arr2)
        else:
            ans += len(arr2) - cnt2.most_common(2)[1][1]
    return ans

arr1 = As[0::2]
arr2 = As[1::2]
print(max(solve(arr1, arr2), solve(arr2, arr1)))

Submission status: Wrong Answer

Solution code:
n = int(input())
vn = list(map(int, input().split(' ')))
count = 0
v0 = vn[0]
v1 = vn[1]
if vn.count(vn[0]) == n:
    count = n // 2
else:
    for idx, v in enumerate(vn):
        if idx % 2 == 0 and v0 == v:
            continue
        elif idx % 2 == 1 and v1 == v:
            continue
        else:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
vL = [int(i) for i in input().split()]
vLo = [vL[i] for i in range(n) if i%2 == 0]
vLe = [vL[i] for i in range(n) if i%2 == 1]
vLos = set(vLo)
vLes = set(vLe)
if len(vLos) == 1:
    ao = 0
else:
    d = dict((i, vLo.count(i)) for i in vLos)
    ao = len(vLo) - max(d.values())
if len(vLes) == 1:
    ae = 0
else:
    d = dict((i, vLe.count(i)) for i in vLes)
    ae = len(vLe) - max(d.values())
a = ao + ae
if vLos == vLes:
    a = (n/2)
print(int(a))

Submission status: Wrong Answer

Solution code:
N = int(input())
V = [int(i) for i in input().split()]
res = N

temp = [0] * (100000 + 1)

for i in range(N//2):
    a = V[2*i]
    temp[a] += 1

res -= max(temp)

temp = [0] * (100000 + 1)

for i in range(N//2):
    a = V[2*i+1]
    temp[a] += 1

res -= max(temp)

if res == 0 and V[0] == V[1]:
    res = N//2

print(res)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
V = [int(x) for x in input().split()]
if all(v == V[0] for v in V):
    print(N // 2)
    quit()
even = Counter([v for i, v in enumerate(V) if i % 2 == 0])
odd = Counter([v for i, v in enumerate(V) if i % 2 != 0])
print(N - even.most_common()[0][1] - odd.most_common()[0][1])

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input().split()
s=[int(o) for o in s]
left=dict()
right=dict()
def count_nums(mydict,o):
  if o in mydict.keys():
    mydict[o]+=1
  else:
    mydict[o]=1
flag=True
for o in s:
  if flag:
    count_nums(left,o)
    flag=False
  else:
    count_nums(right,o)
    flag=True
myleft=sorted(left.keys(),key=lambda x: left[x])
myright=sorted(right.keys(),key=lambda x: right[x])
if myleft[-1]!=myright[-1]:
  print( len(s)-left[myleft[-1]]-right[myright[-1]])
a0,b0=left[myleft[-1]],right[myright[-1]]
a1=0 if len(myleft)==1 else left[myleft[-2]]
b1=0 if len(myright)==1 else right[myright[-2]]
print( len(s)-max(a0+b1,a1+b0))

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input().strip())
vs = list(map(int, input().strip().split()))
oddv = [v for i, v in enumerate(vs) if i % 2 == 0]
evenv = [v for i, v in enumerate(vs) if i % 2 == 1]

oddc = Counter(oddv)
evenc = Counter(evenv)
if oddc.most_common(1)[0][0] != evenc.most_common(1)[0][0]:
  print(len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(1)[0][1])
else:
  if len(oddc.most_common()) == 1 and len(evenc.most_common()) == 1:
    print(len(oddv))
  elif len(oddc.most_common()) == 1:
    print(len(evenv) - evenc.most_common(2)[1][1])
  elif len(evenc.most_common()) == 1:
    print(len(oddv) - oddc.most_common(2)[1][1])
  else:
    print(min(len(oddv) - oddc.most_common(2)[1][1] + len(evenv) - evenc.most_common(1)[0][1], len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(2)[0][1]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
vv = list(map(int, input().split()))
d1 = {}
d2 = {}

for i in range(n):
    v = vv[i]
    if i%2==0:
        if v not in d2:
            d2[v] = 0
        d2[v] += 1
    else:
        if v not in d1:
            d1[v] = 0
        d1[v] += 1

dl1 = sorted(list(d1.keys()), reverse=True, key=lambda k:d1[k])
dl2 = sorted(list(d2.keys()), reverse=True, key=lambda k:d2[k])
i1 = 0
i2 = 0

if len(dl1)==1 and len(dl2)==1:
    if dl1[0]==dl2[0]:
        print(n//2)
    else:
        print(0)
    exit()
elif len(dl1)==1:
    print(sum(sorted(d2.values(), reverse=True)[1:]))
    exit()
elif len(dl2)==1:
    print(sum(sorted(d1.values(), reverse=True)[1:]))
    exit()


if dl1[0]!=dl2[0]:
    res = 0
    res += sum(sorted(d1.values(), reverse=True)[1:])
    res += sum(sorted(d2.values(), reverse=True)[1:])
    print(res)
else:
    if d1[dl1[0]]<d2[dl2[0]]:
        res = 0
        l = sorted(d1.values(), reverse=True)
        res += l[0]
        if len(l)>2:
            res += sum(l[2:])
        res += sum(sorted(d2.values(), reverse=True)[1:])
        print(res)
    else:
        res = 0
        l = sorted(d2.values(), reverse=True)
        res += l[0]
        if len(l)>2:
            res += sum(l[2:])
        res += sum(sorted(d1.values(), reverse=True)[1:])
        print(res)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
vv = list(map(int, input().split()))
d1 = {}
d2 = {}

for i in range(n):
    v = vv[i]
    if i%2==0:
        if v not in d2:
            d2[v] = 0
        d2[v] += 1
    else:
        if v not in d1:
            d1[v] = 0
        d1[v] += 1

res = 0
res += sum(sorted(d1.values(), reverse=True)[1:])
res += sum(sorted(d2.values(), reverse=True)[1:])

if len(set(list(d1.keys())+list(d2.keys())))==1:
    print(n//2)
else:
    print(res)

Submission status: Wrong Answer

Solution code:
def count(lst):
    dic = {}
    for i in lst:
        if i not in dic:
            dic[i] = 1
        else:
            dic[i] += 1
    return dic

n = int(input())
lst = list(map(int, input().split()))
co1 = count([lst[2 * p] for p in range(round(n/2))])
co2 = count([lst[2 * p + 1] for p in range(round(n/2))])


if max(co1, key=co1.get) != max(co2, key=co2.get):
    result = n - max(co1.values()) -max(co2.values())
else:
    l1 = [kv for kv in co1.items() if kv[1] == min(co1.values())]
    l2 = [kv for kv in co2.items() if kv[1] == min(co2.values())]
    result = n - max(max(co1.values()), max(co2.values()))
    for p in l1:
    	for q in l2:
    		if p != q:
    			result = n - max(co1.values()) - max(co2.values())
    			break

print(result)

Submission status: Wrong Answer

Solution code:
def count(lst):
    dic = {}
    for i in lst:
        if i not in dic:
            dic[i] = 1
        else:
            dic[i] += 1
    return dic

n = int(input())
lst = list(map(int, input().split()))
co1 = count([lst[2 * p] for p in range(round(n/2))])
co2 = count([lst[2 * p + 1] for p in range(round(n/2))])


if max(co1, key=co1.get) != max(co2, key=co2.get):
    result = n - max(co1.values()) -max(co2.values())
else:
    l1 = [kv for kv in co1.items() if kv[1] == min(co1.values())]
    l2 = [kv for kv in co2.items() if kv[1] == min(co2.values())]
    for p in l1:
    	for q in l2:
    		if p != q:
    			result = n - max(co1.values()) - max(co2.values())
    			break
    result = n - max(max(co1.values()), max(co2.values()))

print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = [int(i) for i in input().split()]

e = v[0::2]
o = v[1::2]

# 数値と個数
elst = sorted([{"num": n, "cnt": v.count(n)}
               for n in set(e)], key=lambda elem: elem["cnt"], reverse=True)
olst = sorted([{"num": n, "cnt": v.count(n)}
               for n in set(o)], key=lambda elem: elem["cnt"], reverse=True)

if len(elst) == 1 and len(olst) == 1:
    if elst[0]["num"] == olst[0]["num"]:
        print(olst[0]["cnt"])
    else:
        print(0)

elif elst[0]["num"] != olst[0]["num"]:
    ew = 0
    ow = 0
    if len(elst) != 1:
        ew = sum([elem["cnt"] for elem in elst[1:]])
    if len(olst) != 1:
        ow = sum([elem["cnt"] for elem in olst[1:]])

    print(ew+ow)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = list(map(int, input().split()))

def count(in_list): # listを集計し、要素数が最小のものの個数
    l = list(set(in_list)) # 重複を除く
    result = [in_list.count(x) for x in l]
    return min(list(result))

def method(in_list):
    l = list(set(in_list)) # 重複を除く
    result = [(in_list.count(x), x) for x in l]
    result.sort()
    return result[:2]

def anser(n, p):
    # 例外① 全部同じ数
    if len(set(p)) == 1:
        return int(n/2)
    o = [t[1] for t in enumerate(p) if t[0] % 2 == 0]
    e = [t[1] for t in enumerate(p) if t[0] % 2 == 1]
    # 例外② すでにVMVMになっているもの ①以外なのでo!=e
    if len(set(o)) == 1 and len(set(e)) == 1:
        return 0
    # case ① 片一方は0
    if len(set(o)) == 1:
        return count(e)
    if len(set(e)) == 1:
        return count(o)
    ee = method(e) # e = (個数、値)、(個数、値)
    oo = method(o) # o = (個数、値)、(個数、値)
    if ee[0][1] != oo[0][1]:
        return ee[0][0] + oo[0][0]
    else:
        return min(ee[0][0]+oo[1][0], ee[0][1]+oo[0][0])

print(anser(n, p))

Submission status: Wrong Answer

Solution code:
n = int(input())
p = list(map(int, input().split()))

def count(in_list): # listを集計し、要素数が最小のものの個数
    l = list(set(in_list)) # 重複を除く
    result = [in_list.count(x) for x in l]
    return min(list(result))

def anser(n, p):
    # 例外① 全部同じ数
    if len(set(p)) == 1:
        return int(n/2)
    o = [t[1] for t in enumerate(p) if t[0] % 2 == 0]
    e = [t[1] for t in enumerate(p) if t[0] % 2 == 1]
    # 例外② すでにVMVMになっているもの ①以外なのでo!=e
    if len(set(o)) == 1 and len(set(e)) == 1:
        return 0
    # case ① 片一方は0
    if len(set(o)) == 1:
        return count(e)
    if len(set(e)) == 1:
        return count(o)
    return count(o)+count(e)

print(anser(n, p))

Submission status: Wrong Answer

Solution code:
n = int(input())

p = list(map(int, input().split()))


if len(set(p)) == 1:
    print(int(n/2))
    exit()

o = []
e = []

for i in range(n):
    if i % 2 == 0:
        o.append(p[i])
    else:
        e.append(p[i])

# o = map(lambda v: v[1], list(filter(lambda x: x % 2 == 0, enumerate(list))))
# e = map(lambda v: v[1], list(filter(lambda x: x % 2 == 1, enumerate(list))))

def count(in_list):
    l = list(set(in_list)) # 重複を除く
    if len(l) == 1:
        return 0
    result = map(lambda x: in_list.count(x), l)
    return min(list(result))

print(count(o)+count(e))

Submission status: Wrong Answer

Solution code:
import collections as collect
N = int(input())
lists = list(map(int, input().split()))
if len(list(set(lists))) == 1:
    print(int(len(lists) / 2))
else:
    NewList = collect.Counter(lists)
    Values = NewList.values()
    List = list(Values)
    List = sorted(List)
    if List[-1] > sum(List[:-1]):
        print(int(N / 2 - List[-2]))
    sums = sum(List[:-2])

Submission status: Wrong Answer

Solution code:
import collections as collect
N = int(input())
lists = list(map(int, input().split()))
if len(list(set(lists))) == 1:
    print(int(len(lists) / 2))
else:
    NewList = collect.Counter(lists)
    Values = NewList.values()
    List = list(Values)
    List = sorted(List)
    sums = sum(List[:-1])
    print(sums)

Submission status: Wrong Answer

Solution code:
import collections as collect
N = int(input())
lists = list(map(int, input().split()))
if len(list(set(lists))) == 1:
    print(int(len(lists) / 2))
else:
    NewList = collect.Counter(lists)
    Values = NewList.values()
    List = list(Values)
    List = sorted(List)
    sums = sum(List[:-2])
    print(sums)

Submission status: Wrong Answer

Solution code:
from collections import Counter

def solve(size=int(input()), ary=list(map(int, input().split()))):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    even[0], odd[0] = 0, 0
    print(even)
    print(odd)
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om

print(solve())

Submission status: Wrong Answer

Solution code:
def put(len=int(input()), arys=input()):
    return [int(_) for _ in arys.split(' ')]

def solve(ary):
    if len(set(ary)) < 2:
        return len(ary) // 2

    freq = {}
    nums = list(set(ary))
    for _ in nums:
        freq[_] = ary.count(_)

    even, odd = [], []
    for i, _ in enumerate(ary):
        if i % 2 == 0:
            even.append(_)
        else:
            odd.append(_)

    if odd[0] != even[0] and len(set(odd)) == len(set(even)):
        return 0

    curr_max = 0
    most_freq_key = 0

    for n, f in freq.items():
        if curr_max < f:
            curr_max = f
            most_freq_key = n

    freq.pop(most_freq_key)

    curr_max = 0
    sec_freq_key = 0

    for n, f in freq.items():
        if curr_max < f:
            curr_max = f
            sec_freq_key = n

    e_size, o_size = len(even), len(odd)

    return min(e_size - even.count(most_freq_key)
               + o_size - odd.count(sec_freq_key),
               e_size - even.count(sec_freq_key)
               + o_size - odd.count(most_freq_key))


print(solve(put()))

Submission status: Wrong Answer

Solution code:
n = int(input())
v = [int(i) for i in input().split()]

# 数値と個数
d1 = [{"num": n, "cnt": v.count(n)} for n in set(v)]

if len(d1) == 2:
    # 2種類
    print(abs(d1[0]["cnt"]-d1[1]["cnt"]))
elif len(d1) == 1:
    # 1種類
    print(int(d1[0]["cnt"]/2))
else:
    # 2種類以上
    # 123123 -> 4
    # 121312 -> 1
    g1 = v[0::2]
    k1 = v[1::2]
    gMax = max(g1)
    kMax = max(k1)
    print((len(g1) - g1.count(gMax)) + (len(k1) - k1.count(kMax)))

Submission status: Wrong Answer

Solution code:
n = int(input())
v = [int(i) for i in input().split()]

# 数値と個数
d1 = sorted([{"num": n, "cnt": v.count(n)}
             for n in set(v)], key=lambda item: item["cnt"])

if len(d1) == 2:
    # 2種類
    print(abs(d1[0]["cnt"]-d1[1]["cnt"]))
elif len(d1) == 1:
    # 1種類
    print(int(d1[0]["cnt"]/2))
else:
    # 2種類以上
    # 123123 -> 4
    # 121312 -> 1
    g1 = v[0::2]
    k1 = v[1::2]
    gMax = max(g1)
    kMax = max(k1)
    print((len(g1) - g1.count(gMax)) + (len(k1) - k1.count(kMax)))

Submission status: Wrong Answer

Solution code:
import collections

def get_must_rewrite_count(arr) :
	c = collections.Counter(arr)
	commons = c.most_common()
	
	must_rewrite_count = 0
	for item in commons[1::] :
		must_rewrite_count += item[1]

	return must_rewrite_count
	
	

n = int(input())

arr = input().split()
odd_arr = arr[::2]
even_arr = arr[1::2]

answer = get_must_rewrite_count(odd_arr)
answer += get_must_rewrite_count(even_arr)

if (len(list(set(arr))) == 1) :
	answer += len(even_arr)

print(answer)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=v[::2]
b=v[1::2]
a1=dict(Counter(a).most_common())
a2=list(a1.values())
a3=list(a1.keys())
a2.sort(reverse=True)
b1=dict(Counter(b).most_common())
b2=list(b1.values())
b3=list(b1.keys())
b2.sort(reverse=True)
if a3[0]==b3[0]:
    if a2[0]>b2[0]:
        ans_a=sum(a2)-a2[0]
        ans_b=sum(b2)-b2[1]
    elif a2[0]<b2[0]:
        ans_a=sum(a2)-a2[1]
        ans_b=sum(b2)-b2[0]
    else:
        print(n//2)
        sys.exit()
else:
    ans_a=sum(a2)-a2[0]
    ans_b=sum(b2)-b2[0]
print(ans_a+ans_b)

Submission status: Wrong Answer

Solution code:
n = int(input())

a = []
b = []
v = list(map(int, input().split()))
for i in range(n):
	if i % 2 == 0:
		a.append(v[i])
	else:
		b.append(v[i])

a = sorted(a)
b = sorted(b)

al = []
bl = []

x = a[0]
c = 1
for i in range(1, int(n // 2)):
	if x == a[i]:
		c += 1
	else:
		al.append([c, x])
		x = a[i]


al.append([c, x])


y = b[0]
c = 1
for i in range(1, int(n // 2)):
	if y == b[i]:
		c += 1
	else:
		bl.append([c, y])
		y = b[i]

bl.append([c, y])

al = sorted(al)
bl = sorted(bl)

x = [[0, 0]]
al = x + al
bl = x + bl

if al[-1][1] == bl[-1][1]:
	print(min(n - al[-1][0] - bl[-2][0], n - al[-2][0] - bl[-1][0]))
else:
	print(n - al[-1][0] - bl[-1][0])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

n = getN()
nums = getlist()
lis1 = defaultdict(int)
lis2 = defaultdict(int)

for i,s in enumerate(nums):
    if i % 2 == 0:
        lis1[s] += 1
    else:
        lis2[s] += 1

maxk1 = []
maxv1 = 0
for k in lis1.keys():
    if lis1[k] == maxv1:
        maxk1.append(k)
    elif lis1[k] > maxv1:
        maxv1 = lis1[k]
        maxk1 = [k]

maxk2 = []
maxv2 = 0
for k in lis2.keys():
    if lis2[k] == maxv2:
        maxk2.append(k)
    elif lis2[k] > maxv2:
        maxv2 = lis2[k]
        maxk2 = [k]

v1 = list(lis1.values())
v1.sort(reverse=True)
v1 = v1 + [0]
v2 = list(lis2.values())
v2.sort(reverse=True)
v2 = v2 + [0]

if (len(maxk1) == 1) and (len(maxk2) == 1) and (maxk1[0] == maxk2[0]):
    if v1[0] >= v2[0]:
        ans = n - v1[0] -v2[1]
    else:
        ans = n- v2[0] - v1[1]

else:
    ans = n - maxv1 - maxv2
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def check(A):
    N = len(A)
    even = Counter()
    odd = Counter()
    for i, a in enumerate(A):
        if i % 2 == 0:
            odd[a] += 1
        else:
            even[a] += 1
    
    even = even.most_common() + [(None, 0)]
    odd = odd.most_common() + [(None, 0)]
    
    if even[0][0] != odd[0][0]:
        return N - even[0][1] - odd[0][1]
    else:
        return min(N - even[0][1] - odd[1][1], N - odd[0][1] - even[1][1])

N = int(raw_input())
A = map(int, raw_input().split())
ans = check(A)
print A

Submission status: Wrong Answer

Solution code:
from collections import Counter


def check(A):
    N = len(A)
    even = Counter()
    odd = Counter()
    for i, a in enumerate(A):
        if i % 2 == 0:
            odd[a] += 1
        else:
            even[a] += 1
    
    even = even.most_common() + [(None, 0)]
    odd = odd.most_common() + [(None, 0)]
    
    if even[0][0] != odd[0][0]:
        return N - even[0][1] - odd[0][1]
    else:
        return min(N - even[0][1] - odd[1][1], N - odd[0][1] - even[1][1])
    
A = map(int, raw_input().split())
ans = check(A)
print A

Submission status: Wrong Answer

Solution code:
import re
n = int(input())
vs = list(map(lambda x: int(x), re.split(r'\s+', input().rstrip())))

# split
vs1 = []
vs2 = []
for i, v in enumerate(vs):
  if i % 2 == 0:
    vs1.append(v)
  else:
    vs2.append(v)

vs1map = {}
vs2map = {}
for v in vs1:
  if not (v in vs1map):
    vs1map[v] = 0
  vs1map[v] += 1

for v in vs2:
  if not (v in vs2map):
    vs2map[v] = 0
  vs2map[v] += 1

vs1map[0.5] = 0
vs2map[0.5] = 0


# それぞれ個数2位のキーまでを探索すれば良い
v1m = []
v2m = []

cnt = 0
for k, v in sorted(vs1map.items(), key=lambda x: -x[1]):
  v1m.append([k,v])
  cnt += 1
  if cnt >= 2:
    break

cnt = 0
for k, v in sorted(vs2map.items(), key=lambda x: -x[1]):
  v2m.append([k,v])
  cnt += 1
  if cnt >= 2:
    break

out = n
half = n // 2
if v1m[0][0] != v2m[0][0]:
  out = (half - v1m[0][1]) + (half - v2m[0][1])
else:
  out1 = (half - v1m[1][1]) + (half - v2m[0][1])
  out2 = (half - v1m[0][1]) + (half - v2m[1][1])
  out = max([out1, out2])

print(out)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
odd = {}
even = {}
change = 0
for i in range(n):
    if i % 2 == 0:
        if v[i] in even:
            even[v[i]] += 1
        else:
            even[v[i]] = 1
    else:
        if v[i] in odd:
            odd[v[i]] += 1
        else:
            odd[v[i]] = 1

if len(odd) == 1 and len(even) == 1:
    if odd == even:
        change = int(n / 2)
else:
    max_e = max(even, key=even.get)
    max_o = max(odd, key=odd.get)
    if max_e != max_o:
        change = n - even[max_e] - odd[max_o]
    else:
        if even[max_e] >= even[max_o]:
            max_o2 = min(odd, key=odd.get)
            for o in odd:
                if o != max_o and odd[o] > odd[max_o2]:
                    max_o2 = o
            change = n - even[max_e] - odd[max_o2]
        else:
            max_e2 = min(even, key=even.get)
            for e in even:
                if e != max_e and even[e] > even[max_e2]:
                    max_e2 = e
            change = n - odd[max_o] - even[max_e2]
print(change)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
odd = {}
even = {}
change = 0
for i in range(n):
    if i % 2 == 0:
        if v[i] in even:
            even[v[i]] += 1
        else:
            even[v[i]] = 1
    else:
        if v[i] in odd:
            odd[v[i]] += 1
        else:
            odd[v[i]] = 1

if len(odd) == 1 and len(even) == 1:
    if odd == even:
        change = int(n / 2)
else:
    max_e = max(even, key=even.get)
    max_o = max(odd, key=odd.get)
    if max_e != max_o:
        for e in even:
            if e != max_e:
                change += even[e]
        for o in odd:
            if o != max_o:
                change += odd[o]
    else:
        if even[max_e] >= even[max_o]:
            max_o2 = 0
            for o in odd:
                if o != max_o and o > max_o2:
                    max_o2 = o
            change = n - even[max_e] - odd[max_o2]
        else:
            max_e2 = 0
            for e in even:
                if e != max_e and e > max_e2:
                    max_e2 = e
            change = n - odd[max_o] - even[max_e2]
print(change)

Submission status: Wrong Answer

Solution code:
import numpy as np
from collections import Counter
N = input()
t = np.array(map(int, raw_input().split()))

odd = t[0::2]
even = t[1::2]
rest = 0

for _k in [odd, even]:
    counter = Counter(_k)
    rest += len(_k) - counter.most_common()[0][1]
print rest

Submission status: Wrong Answer

Solution code:
from collections import Counter

print 'h'

Submission status: Wrong Answer

Solution code:
import numpy as np

N = input()
# N = int(input())
# t = np.array(list(map(int, input().split())))
t = np.array(map(int, raw_input().split()))

odd = t[0::2]
even = t[1::2]

Submission status: Wrong Answer

Solution code:
import numpy as np

N = input()
# N = int(input())
# t = np.array(list(map(int, input().split())))
t = np.array(map(int, raw_input().split()))

odd = t[0::2]
even = t[1::2]
np.unique(odd)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import numpy as np

N = input()
# N = int(input())
# t = np.array(list(map(int, input().split())))
t = map(int, raw_input().split())

odd = t[0::2]
even = t[1::2]

rest = 0

for _k in [odd, even]:
    uni = list(set(_k))
    cnt = np.zeros((len(uni), ))
    for _i in uni:
        cnt[uni.index(_i)] += 1
    # unique = np.unique(odd, return_counts=True)
    # rest += len(_k) - count[np.argmax(count)]
    rest += len(_k) - np.max(cnt)
print rest

Submission status: Wrong Answer

Solution code:
import numpy as np

N = input()
# N = int(input())
# t = np.array(list(map(int, input().split())))
t = map(int, raw_input().split())

odd = t[0::2]
even = t[1::2]

rest = 0

for _k in [odd, even]:
    uni = list(set(_k))
    cnt = np.zeros((len(uni), ))

Submission status: Wrong Answer

Solution code:
import numpy as np
np.zeros((20, ))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = input()
# N = int(input())
# t = np.array(list(map(int, input().split())))
t = map(int, raw_input().split())

odd = t[0::2]
even = t[1::2]

rest = 0

for _k in [odd, even]:
    uni = list(set(_k))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = input()
# N = int(input())
# t = np.array(list(map(int, input().split())))
t = map(int, raw_input().split())

odd = t[0::2]
even = t[1::2]

rest = 0

Submission status: Wrong Answer

Solution code:
import numpy as np

N = input()
# N = int(input())
# t = np.array(list(map(int, input().split())))
t = map(int, raw_input().split())

odd = t[0::2]
even = t[1::2]

print 'hello'

Submission status: Wrong Answer

Solution code:
import numpy as np

print 'hello'

Submission status: Wrong Answer

Solution code:
print "hello"

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
vvv = list(map(int, input().split()))
cnt1 = Counter(vvv[0::2])
cnt2 = Counter(vvv[1::2])
mc1 = cnt1.most_common(2)
mc2 = cnt2.most_common(2)
if mc1[0][0] == mc2[0][0]:
    sc1 = mc1[1][1] if len(mc1) > 1 else 0
    sc2 = mc2[1][1] if len(mc2) > 1 else 0
    print(min(n - mc1[0][1] - sc2, sc1 - mc2[0][1]))
else:
    print(n - mc1[0][1] - mc2[0][1])

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
odd = {}
even = {}
change = 0
for i in range(n):
    if i % 2 == 0:
        if v[i] in even:
            even[v[i]] += 1
        else:
            even[v[i]] = 1
    else:
        if v[i] in odd:
            odd[v[i]] += 1
        else:
            odd[v[i]] = 1

if len(odd) == 1 and len(even) == 1:
    if odd == even:
        change = list(odd.values())[0]
elif len(odd) == 1 and len(even) != 1:
    max_v = max(even, key=even.get)
    for e in even:
        if e != max_v:
            change += even[e]
elif len(odd) != 1 and len(even) == 1:
    max_v = max(odd, key=odd.get)
    for o in odd:
        if o != max_v:
            change += odd[o]
else:
    max_e = max(even, key=even.get)
    max_o = max(odd, key=odd.get)
    if max_e != max_o:
        for e in even:
            if e != max_e:
                change += even[e]
        for o in odd:
            if o != max_o:
                change += odd[o]
    else:
        if even[max_e] >= even[max_o]:
            max_o2 = 0
            for o in odd:
                if o != max_o and o > max_o2:
                    max_o2 = o
            change = n - even[max_e] - odd[max_o2]
        else:
            max_e2 = 0
            for e in even:
                if e != max_e and e > max_e2:
                    max_e2 = e
            change = n - odd[max_o] - even[max_e2]
print(change)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
odd = {}
even = {}
change = 0
for i in range(n):
    if i % 2 == 0:
        if v[i] in even:
            even[v[i]] += 1
        else:
            even[v[i]] = 1
    else:
        if v[i] in odd:
            odd[v[i]] += 1
        else:
            odd[v[i]] = 1

if len(odd) == 1 and len(even) == 1:
    if odd == even:
        change = list(odd.values())[0]
elif len(odd) == 1 and len(even) != 1:
    max_v = max(even, key=even.get)
    for e in even:
        if e != max_v:
            change += even[e]
elif len(odd) != 1 and len(even) == 1:
    max_v = max(odd, key=odd.get)
    for o in odd:
        if o != max_v:
            change += odd[o]
else:
    max_e = max(even, key=even.get)
    max_o = max(odd, key=odd.get)
    if max_e != max_o:
        for e in even:
            if e != max_e:
                change += even[e]
        for o in odd:
            if o != max_o:
                change += odd[o]
    else:
        if even[max_e] >= even[max_o]:
            max_o2 = 0
            for o in odd:
                if o != max_o and o > max_o2:
                    max_o2 = o
            change = n - even[max_e] - o
        else:
            max_e2 = 0
            for e in even:
                if e != max_e and e > max_e2:
                    max_e2 = e
            change = n - odd[max_o] - max_e2
print(change)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
odd = {}
even = {}
change = 0
for i in range(n):
    if i % 2 == 0:
        if v[i] in even:
            even[v[i]] += 1
        else:
            even[v[i]] = 1
    else:
        if v[i] in odd:
            odd[v[i]] += 1
        else:
            odd[v[i]] = 1
if len(odd) == 1 and len(even) == 1:
    if odd == even:
        change = list(odd.values())[0]
elif len(odd) == 1 and len(even) != 1:
    max_v = max(even, key=even.get)
    for e in even:
        if e != max_v:
            change += even[e]
elif len(odd) != 1 and len(even) == 1:
    max_v = max(odd, key=odd.get)
    for o in odd:
        if o != max_v:
            change += odd[o]
else:
    max_e = max(even, key=even.get)
    max_o = max(odd, key=odd.get)
    if max_e != max_o:
        for e in even:
            if e != max_e:
                change += even[e]
        for o in odd:
            if o != max_o:
                change += odd[o]
    else:
        if even[max_e] >= even[max_o]:
            for o in odd:
                if o != max_o:
                    change += 1
            change = n - even[max_e] - change
        else:
            for e in even:
                if e != max_e:
                    change += 1
            change = n - odd[max_o] - change
print(change)