TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
a = [[], []]
[a[i%2].append(t) for i, t in enumerate(map(int, input().split()))]
print(sum([(lambda x: len(x) -max([x.count(xi) for xi in x]))(ai) for ai in a]))

N = int(input())
a = [[],[]]
[a[i%2].append(t) for i, t in enumerate(map(int, input().split()))]

a_cnt = [{},{}]
for i in range(2):
    for j in range(len(a[i])):
        if a[i][j] in a_cnt[i]:
            a_cnt[i][a[i][j]] += 1
        else:
            a_cnt[i][a[i][j]] = 1

for i in range(2):
    # print(list(a_cnt[i].items()))
    a_cnt[i] = list(sorted(list(a_cnt[i].items()),\
        key=(lambda x:x[1]), reverse=True))[:2]

# print(a_cnt)
if a_cnt[0][0][0] != a_cnt[1][0][0]:
    print(N -a_cnt[0][0][1] -a_cnt[1][0][1])
else:
    if len(a_cnt[0])==1 and len(a_cnt[1])==1:
        print(N//2)
    else:
        ans1 = N -a_cnt[0][0][1] -a_cnt[1][1][1]
        ans2 = N -a_cnt[0][1][1] -a_cnt[1][0][1]
        print(min(ans1, ans2))


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# coding: utf-8
# Your code here!
n=int(input())
w=list(map(int,input().split()))
ans=0
if len(set(w))==1:
    print(len(w)//2)
elif len(set(w))==2:
    w.sort()
    print(abs(w.count(w[0])-w.count(w[len(w)-1])))
else:
    cnt=[]
    ans=0
    w.sort()
    t=w[0]
    for j in range(n):
        if w[j]==t:
            ans+=1
        else:
            cnt.append(ans)
            t=w[j]
            ans=1
        if j==n-1:
            cnt.append(ans)
    print(cnt)
    cnt.sort(reverse=True)
    if cnt[0]+cnt[1]>n:
        print(cnt[0]+cnt[1]-n)
    elif cnt[0]+cnt[1]<n:
        if cnt[0]>=n//2:
            print(n//2-cnt[1])
        else:
            print(n-cnt[1]-cnt[0])
    else:
        print(cnt[0]-cnt[1])
    

# coding: utf-8
# Your code here!
n=int(input())
w=list(map(int,input().split()))
ans=0
if len(set(w))==1:
    print(len(w)//2)
else:
    a=[]
    a1=[]
    for i in range(n):
        if i%2==0:
            a.append(w[i])
        else:
            a1.append(w[i])
    a.sort()
    a1.sort()
    ans=0
    t=a[0]
    cnt1=[]
    cnt=[]
    b=[]
    b1=[]
    for j in range(len(a)):
        if a[j]==t:
            ans+=1
        else:
            cnt.append([ans,t])
            t=a[j]
            ans=1
        if j==len(a)-1:
            cnt.append([ans,t])
    s=a1[0]
    ans=0
    for j in range(len(a)):
        if a1[j]==s:
            ans+=1
        else:
            cnt1.append([ans,s])
            s=a1[j]
            ans=1
        if j==len(a1)-1:
            cnt1.append([ans,s])
    cnt.sort(reverse=True)
    cnt1.sort(reverse=True)
    """
    print(a)
    print(a1)
    print(cnt)
    print(cnt1)
    """
    if cnt[0][1]!=cnt1[0][1]:
        print(n-cnt[0][0]-cnt1[0][0])
    else:
        if cnt[0][0]>cnt1[0][0]:
            print(n-cnt[0][0]-cnt1[1][0])
        elif cnt[0][0]<cnt1[0][0]:
            print(n-cnt1[0][0]-cnt[1][0])
        else:
            t=0
            s=0
            for i in range(1,min(len(cnt),len(cnt1))):
                if cnt[i][0]!=cnt1[i][0]:
                    if cnt[i][0]==max(cnt[i][0],cnt1[i][0]):
                        t=cnt[i][0]
                        s=cnt1[0][0]
                        break
                if cnt[i][0]!=cnt1[i][0]:
                    if cnt1[i][0]==max(cnt[i][0],cnt1[i][0]):
                        t=cnt1[i][0]
                        s=cnt[0][0]
                        break
                if i==-1+min(len(cnt),len(cnt1)):
                    t=cnt[0][0]
                    s=cnt1[1][0]
            print(n-t-s)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
v = list(map(int, input().split()))

vv = [[], []]
for i in range(n):
    vv[i % 2].append(v[i])

import collections
items0 = sorted(collections.Counter(vv[0]).items(), key=lambda x: -x[1])
items1 = sorted(collections.Counter(vv[1]).items(), key=lambda x: -x[1])
key0 = [x[0] for x in items0]
key1 = [x[0] for x in items1]
val0 = [x[1] for x in items0]
val1 = [x[1] for x in items1]

if key0[0] = ! key1[0]:
    if len(items0) == 1:
        print(n//2)
    else:
        print(min(n - val0[0] - val1[1], min(n - val0[1] - val1[0])))
else key0[0] != key1[0]:
    print(n - val0[0] - val1[0])


n = int(input())
v = list(map(int, input().split()))

vv = [[], []]
for i in range(n):
    vv[i % 2].append(v[i])

import collections
items0 = sorted(collections.Counter(vv[0]).items(), key=lambda x: -x[1])
items1 = sorted(collections.Counter(vv[1]).items(), key=lambda x: -x[1])
key0 = [x[0] for x in items0]
key1 = [x[0] for x in items1]
val0 = [x[1] for x in items0]
val1 = [x[1] for x in items1]

ans = n - val0[0] - val1[0]

if key0[0] == key1[0]:
    tmp0=tmp1=1000000000000000
    if len(items0) > 1:
        tmp0 = n - val0[1] - val1[0]
    if len(items1) > 1:
        tmp1 = n - val0[0] - val1[1]
    ans = min(tmp0, tmp1)
    if len(items0) == 1 and len(items1) == 1:
        ans=n//2
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
v = list(map(int, input().split()))

even = {}
odd = {}

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

even_sorted = sorted(even.items(), key=lambda x:x[i])[::-1]
odd_sorted = sorted(odd.items(), key=lambda x:x[i])[::-1]

ans = 0
if even_sorted[0][0] != odd_sorted[0][0]:
    ans += n - even_sorted[0][1] - odd_sorted[0][1]
else:
    x = n - even_sorted[0][1] - odd_sorted[1][1]
    y = n - even_sorted[1][1] - odd_sorted[0][1]
    ans += min(x, y)

print(ans)

n = int(input())
v = list(map(int, input().split()))

even = {}
odd = {}

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

even_sorted = sorted(even.items(), key=lambda x:x[1])[::-1]
odd_sorted = sorted(odd.items(), key=lambda x:x[1])[::-1]

ans = 0
if even_sorted[0][0] != odd_sorted[0][0]:
    ans += n - even_sorted[0][1] - odd_sorted[0][1]
else:
    if len(even_sorted) == 1 or len(odd_sorted) == 1:
        even_sorted.append((-1, 0))
        odd_sorted.append((-1, 0))
    x = n - even_sorted[0][1] - odd_sorted[1][1]
    y = n - even_sorted[1][1] - odd_sorted[0][1]
    ans += min(x, y)

print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]


# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':

n = int(input().rstrip())
v = list(map(int, input().rstrip().split()))
v_even = dict()
v_odd = dict()

def solve(d1, d2):
	d1_max = [[0, 0], [0, 0]]
	d2_max = [[0, 0], [0, 0]]
	for i in d1:
		if d1_max[0][1] <= d1[i]:
			d1_max[1] = d1_max[0]
			d1_max[0] = [i, d1[i]]
	for i in d2:
		if d2_max[0][1] <= d2[i]:
			d2_max[1] = d2_max[0]
			d2_max[0] = [i, d2[i]]

	print(d1_max)
	print(d2_max)

	if d1_max[0][0] != d2_max[0][0]:
		return(n - d1_max[0][1]- d2_max[0][1])
	else:
		return(min(n - d1_max[1][1]- d2_max[0][1], n - d1_max[0][1]- d2_max[1][1]))

for i in range(len(v)):
	if i % 2 == 0:
		if v[i] not in v_even:
			v_even[v[i]] = 1
		else:
			v_even[v[i]] += 1
	else:
		if v[i] not in v_odd:
			v_odd[v[i]] = 1
		else:
			v_odd[v[i]] += 1
	
print(solve(v_even, v_odd))


# /user/bin/python
# -*- coding: utf-8 -*-
from collections import Counter
import sys

n = int(sys.stdin.readline().rstrip())
v_s = list(map(int, sys.stdin.readline().rstrip().split()))

v_even = Counter(v_s[0::2]).most_common()
v_even.append((0,0))
v_odd = Counter(v_s[1::2]).most_common()
v_odd.append((0,0))

if v_even[0][0] != v_odd[0][0]:
  print(n-v_even[0][1]-v_odd[0][1])
else:
  print(min(n-v_even[0][1]-v_odd[1][1], n-v_odd[0][1]-v_even[1][1]))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from itertools import accumulate
from collections import Counter

N = int(input())
v = list(map(int,input().split()))
d = Counter(v).most_common()
most_common = d[0][0]
try:
    second_common = d[1][0]
except:
    print(N//2)
    exit()
try:
    third_common = d[2][0]
except:
    third_common = float('Inf')

def f(v,m,s):
    cnt = 0
    for j in range(N):
        if j % 2 != 0:
            if v[j] != m:
                cnt += 1
        else:
            if v[j] != s:
                cnt += 1
    return cnt

p = [most_common,second_common,third_common]
p = list(product(p,p))
p = [i for i in p if i[0] != i[1]]
ans = float('inf')
for i in p:
    tmp = f(v,i[0],i[1])
    ans = min(ans,tmp)
print(ans)


from collections import Counter
n = int(input())
v = list(map(int,input().split()))
o = Counter(v[::2]).most_common()
o.append((0,0))
e = Counter(v[1::2]).most_common()
e.append((0,0))
if o[0][0] == e[0][0]:
    ans = min(n - o[0][1] - e[1][1], n - o[1][1] - e[0][1])
else:
    ans = n - o[0][1] - e[0][1]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])

if a[0][0] != b[0][0]:
  print(n-(a[0][1]+b[0][1]))
else:
  print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1]))
         

from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])

if a[0][0] != b[0][0]:
  print(n-(a[0][1]+b[0][1]))
else:
  print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))
         

    
   

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
n = int(input())
V = list(map(int,input().split()))
A = Counter(V[0::2]).most_common(2)
A = Counter(V[1::2]).most_common(2)
A.append((0,0))
A.append((0,0))
if A[0][0]!=B[0][0]:
    print(n-(A[0][1]+B[0][1]))
else:
    print(min(n-(A[1][1]+B[0][1]),n-(A[0][1]+B[1][1])))


from collections import Counter
n = int(input())
V = list(map(int,input().split()))
A = Counter(V[0::2]).most_common(2)
B = Counter(V[1::2]).most_common(2)
A.append((0,0))
B.append((0,0))
if A[0][0]!=B[0][0]:
    print(n-(A[0][1]+B[0][1]))
else:
    print(min(n-(A[1][1]+B[0][1]),n-(A[0][1]+B[1][1])))


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
S = list(input())
S0 = {}
S1 = {}
for i, item in enumerate(S):
  if i%2 == 0:
    if item not in S0:
      S0[item] =1
    else:
      S0[item] += 1
  else:
    if item not in S1:
      S1[item] =1
    else:
      S1[item] += 1

S0list = list(S0.values()).sort(reverse=True)
S1list = list(S1.values()).sort(reverse=True)

S00 = S0list[0]
if len(S0list) == 1:
  S01 = 0
else:
  S01 = S0list[1]
S10 = S1list[0]
if len(S1list) == 1:
  S11 = 0
else:
  S11 = S1list[1]
Answer = min(len(S) - S00 - S11,len(S) - S01 - S10)

print(Answer)

n = int(input())
S = [int(x) for x in input().split()]

S0 = {}
S1 = {}
for i in range(len(S)):
  if i%2 == 0:
    if S[i] not in S0:
      S0[S[i]] =1
    else:
      S0[S[i]] += 1
  else:
    if S[i] not in S1:
      S1[S[i]] =1
    else:
      S1[S[i]] += 1

if max(S0, key = S0.get) != max(S1, key = S1.get):
  Answer = len(S) - max(S0.values()) -max(S1.values())
  print(Answer)
  exit()
      
S0list = sorted(list(S0.values()),reverse = True)
S1list = sorted(list(S1.values()),reverse = True)

S00 = S0list[0]

if len(S0list) == 1:
  S01 = 0
else:
  S01 = S0list[1]
S10 = S1list[0]
if len(S1list) == 1:
  S11 = 0
else:
  S11 = S1list[1]
Answer = min(len(S) - S00 - S11,len(S) - S01 - S10)

print(Answer)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import copy

n = int(input())
v = list(map(int, input().split()))
# print(v)

la = [0 for i in range(5+10**5)]
lb = [0 for i in range(5+10**5)]

for i in range(0, n, 2):
    la[v[i]] += 1
for i in range(1, n, 2):
    lb[v[i]] += 1

# print(sum(la))
# print(sum(lb))
# print(max(la))
# print(max(lb))
# print(la.index(max(la)))
# print(lb.index(max(lb)))

sla = sum(la)
slb = sum(lb)
maxla = max(la)
maxlb = max(lb)
argmaxla = la.index(max(la))
argmaxlb = lb.index(max(lb))

if argmaxla != argmaxlb:
    if maxla != maxlb:
        print(0)
    else:
        print(sla-maxla+slb-maxlb)
else:
    
    _la = copy.deepcopy(la)
    _la[argmaxla] = 0
    _maxla = max(_la)
    aa = sla-_maxla+slb-maxlb
    
    _lb = copy.deepcopy(lb)
    _lb[argmaxlb] = 0
    _maxlb = max(_lb)
    bb = sla-maxla+slb-_maxlb
    if bb>aa:
        print(aa)
    else:
        print(bb)


import copy

n = int(input())
v = list(map(int, input().split()))
# print(v)

la = [0 for i in range(5+10**5)]
lb = [0 for i in range(5+10**5)]

for i in range(0, n, 2):
    la[v[i]] += 1
for i in range(1, n, 2):
    lb[v[i]] += 1

# print(sum(la))
# print(sum(lb))
# print(max(la))
# print(max(lb))
# print(la.index(max(la)))
# print(lb.index(max(lb)))

sla = sum(la)
slb = sum(lb)
maxla = max(la)
maxlb = max(lb)
argmaxla = la.index(max(la))
argmaxlb = lb.index(max(lb))

if argmaxla != argmaxlb:
    if sla-maxla == 0 and slb-maxlb == 0:
        print(0)
    else:
        print(sla-maxla+slb-maxlb)
else:
    
    _la = copy.deepcopy(la)
    _la[argmaxla] = 0
    _maxla = max(_la)
    aa = sla-_maxla+slb-maxlb
    
    _lb = copy.deepcopy(lb)
    _lb[argmaxlb] = 0
    _maxlb = max(_lb)
    bb = sla-maxla+slb-_maxlb
    if bb > aa:
        print(aa)
    else:
        print(bb)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
N=int(input())
V=list(map(int,input().split()))
a=[V[i] for i in range(N) if i%2==0]
b=[V[i] for i in range(N) if i%2==1]

a=collections.Counter(a)
b=collections.Counter(b)
a=a.most_common()
b=b.most_common()
print(a)
print(b)
if len(a)==len(b)==1:
    if a[0][0]==b[0][0]:
        print(int(N/2))
    else:
        print(0)
elif len(a)==1 and len(b)>=2:
    print(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1])
elif len(a)>=2 and len(b)==1:
    print(N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1])
elif len(a)>=2 and len(a)>=2:
    print(min(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1],N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1]))


import collections
N=int(input())
V=list(map(int,input().split()))
a=[V[i] for i in range(N) if i%2==0]
b=[V[i] for i in range(N) if i%2==1]

a=collections.Counter(a)
b=collections.Counter(b)
a=a.most_common()
b=b.most_common()
if len(a)==len(b)==1:
    if a[0][0]==b[0][0]:
        print(int(N/2))
    else:
        print(0)
elif len(a)==1 and len(b)>=2:
    print(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1])
elif len(a)>=2 and len(b)==1:
    print(N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1])
elif len(a)>=2 and len(a)>=2:
    print(min(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1],N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1]))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())

seq=list(map(int,input().split()))
oddlist=[]
evenlist=[]

for i in range(n):
    if ( i+1)%2!=0:
    
        oddlist.append(seq[i])
    else:    
        evenlist.append(seq[i])
print(seq)
print(oddlist)
print(evenlist)
maxi=n/2
mini=n/2
if oddlist!=evenlist:
    for j in set(evenlist):
        if evenlist.count(j)==int(n/2):
            maxi=0
        else:
            if evenlist.count(j)<maxi:
                maxi=evenlist.count(j)
            else:
                maxi=maxi

    for k in set(oddlist):
        if oddlist.count(k)==int(n/2):
            mini=0
        else:
        
            if oddlist.count(k)<mini:
                mini=oddlist.count(k)
            else:
                mini=mini
    
    print(maxi+mini)    
else:
    print(2)



from collections import Counter as ct

n = int(input())
a = [int(i) for i in input().split()]
oddlists=[a[i] for i in range(n)if i%2==0]
evenlists=[a[i]for i in range(n) if i%2!=0]

a1=ct(oddlists).most_common()
a2=ct(evenlists).most_common()


min1=a1[0][1]
min2=a2[0][1]
if a1[0][0]!=a2[0][0]:
    print(n-min1-min2)
if a1[0][0]==a2[0][0]:
    if a1[0][1]==int(n/2):
        print(int(n/2))
    elif a1[0][1]<int(n/2):
        print(min(n-a1[0][1]-a2[1][1],n-a2[0][1]-a1[1][1]))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
input()
V = [int(v) for v in input().split()]
count = 0
c1 = Counter(V[::2] + [0]).most_common()[0][0]
for v in V[::2]:
    if v != c1:
        count += 1
c2 = Counter(V[1::2] + [0]).most_common()
c2 = c2[0][0] if c1 != c2[0][0] else c2[1][0]
for v in V[1::2]:
    if v != c2:
        count += 1
print(count)

from collections import Counter

input()
V = [int(v) for v in input().split()]
count1 = 0
count2 = 0
c11 = Counter(V[::2]).most_common()[0][0]
c12 = Counter(V[1::2]).most_common()[0][0]
for v1, v2 in zip(V[::2], V[1::2]):
    if v1 != c11:
        count1 += 1
    if v2 != c12:
        count2 += 1
c21 = Counter(V[1::2]).most_common()
c22 = Counter(V[::2]).most_common()
c21.append((0, 1))
c22.append((0, 1))
c21 = c21[0][0] if c21[0][0] != c11 else c21[1][0]
c22 = c22[0][0] if c22[0][0] != c12 else c22[1][0]
for v1, v2 in zip(V[1::2], V[::2]):
    if v1 != c21:
        count1 += 1
    if v2 != c22:
        count2 += 1
print(min(count1, count2))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a = int(input())
x = list(map(int, input().split()))
y=[]
z=[]
from collections import Counter
for i in range(a):
    if i%2==0:
        y.append(x[i])
    else:
        z.append(x[i])
y.append(0)
z.append(0)
c= Counter(y)
d = Counter(z)
c1=c.most_common()[0][1]
if c.most_common()[1][0]==0:c2=0
else:c2=c.most_common()[1][1]
d1=d.most_common()[0][1]
if d.most_common()[1][0]==0:d2=0
else:d2=d.most_common()[1][1]
print(c1,c2,d1,d2)
if c.most_common()[0][0]== d.most_common()[0][0]:
    s = a-max(c1+d2,c2+d1)
    print(a,c1+d2,c2+d1)
    print(c)
    print(d)

else:s= a - c.most_common()[0][1] - d.most_common()[0][1]
print(s)

a = int(input())
x = list(map(int, input().split()))
y=[]
z=[]
from collections import Counter
for i in range(a):
    if i%2==0:
        y.append(x[i])
    else:
        z.append(x[i])
y.append(0)
z.append(0)
c= Counter(y)
d = Counter(z)
c1=c.most_common()[0][1]
if c.most_common()[1][0]==0:c2=0
else:c2=c.most_common()[1][1]
d1=d.most_common()[0][1]
if d.most_common()[1][0]==0:d2=0
else:d2=d.most_common()[1][1]
#print(c1,c2,d1,d2)
if c.most_common()[0][0]== d.most_common()[0][0]:
    s = a-max(c1+d2,c2+d1)
    #print(a,c1+d2,c2+d1)
    #print(c)
    #print(d)

else:s= a - c.most_common()[0][1] - d.most_common()[0][1]
print(s)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())

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

s = []
t = []


import collections

for i in range(0,n//2,2):
	s.append(v[i])
for i in range(1,n//2,2):
	t.append(v[i])

S = collections.Counter(s)
	
T = collections.Counter(t)

x = S.most_common()[0][0]  

z = T.most_common()[0][0]

print(n-s.count(x)-t.count(z))


n = int(input())

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

s = []
t = []


import collections

for i in range(0,n,2):
	s.append(v[i])
for i in range(1,n,2):
	t.append(v[i])

S = Counter(s)
	
T = Counter(t)

x = S.most_common()[0][0]  

y = S.most_common()[1][0]  

z = T.most_common()[0][0]　

w = T.most_common()[1][0]

if x!=z:
	print(n-S.most_common()[0][1]-T.most_common()[0][1])
elif y>w:
	print(n-S.most_common()[0][1]-S.most_common()[1][1])
else:
	print(n-S.most_common()[0][1]-T.most_common()[1][1])


n = int(input())

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

s = []
t = []


import collections

for i in range(0,n//2,2):
	s.append(v[i])
for i in range(1,n//2,2):
	t.append(v[i])

S = Counter(s)
	
T = Counter(t)

x = S.most_common()[0][0]  

y = S.most_common()[1][0]  

z = T.most_common()[0][0]　

w = T.most_common()[1][0]

if x!=z:
	print(n-S.most_common()[0][1]-T.most_common()[0][1])
elif y>w:
	print(n-S.most_common()[0][1]-S.most_common()[1][1])
else:
	print(n-S.most_common()[0][1]-T.most_common()[1][1])


import collections

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

a = collections.Counter(a)
b = collections.Counter(b)

A = a.most_common()[:2]
A.append(("x",0))
B = b.most_common()[:2]
B.append(("x",0))
if A[0][0]==B[0][0]:
    print(n-max(A[0][1]+B[1][1],A[1][1]+B[0][1]))
else:
    print(n-A[0][1]-B[0][1])


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def rewrite_count(vi_list):
    if len(set(vi_list)) != 1:
        vi_count_list = [(i, vi_list.count(i)) for i in set(vi_list)]
        vi_count_list = sorted(vi_count_list, key=lambda x: x[1])
        return vi_count_list[-1][0], len(vi_list) - vi_count_list[-1][1], len(vi_list) - vi_count_list[-2][1]
    else:
        return vi_list[0], 0, 0

N = int(input())
v_list = input().split()

if len(set(v_list)) == 1:
    print(len(v_list) // 2)
    exit()

v1_list = []
v2_list = []

for i in range(len(v_list)):
    if i%2 == 0:
        v1_list.append(i)
    else:
        v2_list.append(i)
max_v1, max_value_v1, second_value_v1 = rewrite_count(v1_list)
max_v2, max_value_v2, second_value_v2 = rewrite_count(v2_list)

if max_v1 != max_v2:
    ans = max_value_v1 + max_value_v2
elif max_value_v1 > max_value_v2:
    ans = max_value_v2 + second_value_v1
else:
    ans = max_value_v1 + second_value_v2
print(ans)

from collections import *

N = input()
v_list = input().split()

if len(set(v_list)) == 1:
    print(len(v_list) // 2)
    exit()

v1_count_list = Counter(v_list[::2]).most_common(2)
v2_count_list = Counter(v_list[1::2]).most_common(2)

if v1_count_list[0][0] != v2_count_list[0][0]:
    leave_value = v1_count_list[0][1] + v2_count_list[0][1]
else:
    leave_value = max(v1_count_list[1][1] + v2_count_list[0][1], v1_count_list[0][1] + v2_count_list[1][1])
print(len(v_list) - leave_value)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# coding: utf-8
# Your code here!

import collections

n=int(input())
li=list(map(int,input().split()))
l=[]
r=[]

for i in range(n):
    if i%2==0:
        l.append(li[i])
    else:
        r.append(li[i])

l_cnt=collections.Counter(l)
r_cnt=collections.Counter(r)


ll=l_cnt.most_common(2)
rr=r_cnt.most_common(2)

if ll[0][0]==rr[0][0]:
    print()

print(ll,rr)




# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!

import collections

n=int(input())
li=list(map(int,input().split()))
l=[]
r=[]

for i in range(n):
    if i%2==0:
        l.append(li[i])
    else:
        r.append(li[i])

l_cnt=collections.Counter(l)
r_cnt=collections.Counter(r)


ll=l_cnt.most_common(2)
rr=r_cnt.most_common(2)


if ll[0][0]==rr[0][0]:
    if len(ll)==1 and len(rr)==1:
        print(n//2)
    elif len(ll)==1:
        print(n//2-rr[-1][1])
    elif len(rr)==1:
        print(n//2-ll[-1][1])
    else:
        print((n-max(ll[0][1]+rr[1][1],ll[1][1]+rr[0][1])))
else:
    print(n-ll[0][1]-rr[0][1])





Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
n2 = n/2
v = [int(i) for i in input().split()]
v1 = []
v2 = []
for i in range(n):
    if(i % 2 == 0):
        v1.append(v[i])
    else:
        v2.append(v[i])
count1 = [v1.count(v1[i]) for i in range(int(n2))]
count2 = [v2.count(v2[i]) for i in range(int(n2))]
if(v1[count1.index(max(count1))] == v2[count2.index(max(count2))]):
    max1 = max(count1)
    max2 = max(count2)
    count1 = list(set(count1))
    count1.remove(max(count1))
    count2 = list(set(count2))
    count2.remove(max(count2))
    if(max(count1) > max(count2)):
        print(n - max(count1) - max2)
    else:
        print(n - max(count2) - max1)
else:
    print(n - max1 - max2)


from collections import Counter

n = int(input())
if(n == 2):
    print(0)
else:
    v = [int(i) for i in input().split()]
    v1 = Counter(v[::2])
    v2 = Counter(v[1::2])
    v1mc = v1.most_common()
    v2mc = v2.most_common()
    print(len(v1mc))
    if(v1mc[0][0] == v2mc[0][0]):
        if(len(v1mc) == 1 and len(v2mc) == 1):
            print(n/2)
        elif(len(v1mc) == 1):
            print(n - (v1mc[0][1]+v2mc[1][1]))
        elif(len(v2mc) == 1):
            print(n - (v2mc[0][1]+v1mc[1][1]))
        else:
            print(n - max(v1mc[0][1]+v2mc[1][1], v2mc[0][1]+v1mc[1][1]))
    else:
        print(n - (v1mc[0][1]+v2mc[0][1]))


from collections import Counter

n = int(input())
v = [int(i) for i in input().split()]
v1 = Counter(v[::2])
v2 = Counter(v[1::2])
v1mc = v1.most_common()
v2mc = v2.most_common()
if(v1mc[0][0] == v2mc[0][0]):
    if(len(v1mc) == 1 and len(v2mc) == 1):
        print(int(n/2))
    elif(len(v1mc) == 1):
        print(n - (v1mc[0][1]+v2mc[1][1]))
    elif(len(v2mc) == 1):
        print(n - (v2mc[0][1]+v1mc[1][1]))
    else:
        print(n - max(v1mc[0][1]+v2mc[1][1], v2mc[0][1]+v1mc[1][1]))
else:
    print(n - (v1mc[0][1]+v2mc[0][1]))


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
V = list(map(int, input().split()))
E = {}
O = {}
n = 1
for i, v in enumerate(V):
    if n:
        if v in E.keys():
            E[v] += 1
        else:
            E[v] = 1
    else:
        if v in O.keys():
            O[v] += 1
        else:
            O[v] = 1
    n = 1 - n
E = sorted(E.items(), key=lambda x: -x[1])
O = sorted(O.items(), key=lambda x: -x[1])
if E[0][0] != O[0][0]:
    ans = n - E[0][1] - O[0][1]
    print(ans)
else:
    if len(E) == 1 and len(O) == 1:
        print(E[0][1])
    elif len(E) == 1:
        ans = n - E[0][1] - O[1][1]
        print(ans)
    elif len(O) == 1:
        ans = n -E[1][1] - O[0][1]
        print(ans)
    else:
        ans1 = n - E[0][1] - O[1][1]
        ans2 = n - E[1][1] - O[0][1]
        print(min(ans1, ans2))

n = int(input())
V = list(map(int, input().split()))
E = {}
O = {}
now = 1
for i, v in enumerate(V):
    if now:
        if v in E.keys():
            E[v] += 1
        else:
            E[v] = 1
    else:
        if v in O.keys():
            O[v] += 1
        else:
            O[v] = 1
    now = 1 - now
E = sorted(E.items(), key=lambda x: -x[1])
O = sorted(O.items(), key=lambda x: -x[1])
if E[0][0] != O[0][0]:
    print(n - E[0][1] - O[0][1])
else:
    if len(E) == 1 and len(O) == 1:
        print(E[0][1])
    elif len(E) == 1:
        print(n-E[0][1]-O[1][1])
    elif len(O) == 1:
        print(n-E[1][1]-O[0][1])
    else:
        print(min(n-E[0][1]-O[1][1], n-E[1][1]-O[0][1]))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a = int(input())

b = list(map(int,input().split()))
d = max(b)
c = [0 for i in range(pow(10,5)+1)]
cc = [0 for i in range(pow(10,5)+1)]
for i in range(len(b)):
    if i % 2 == 0:
        c[b[i]-1] += 1
    else:
        cc[b[i]-1] += 1

one = 0
onee = 0
two = 0
twoo = 0
k = 0
kk = 0
for i in range(d+1):
    if one <= c[i]:
        onee = one
        one = c[i]
        k = i
    if two <= cc[i]:
        twoo = two
        two = cc[i]
        kk = i

t = max(one+twoo,onee+twso)

if k != kk:
    print(a-one-two)
else:
    print(a-t)

a = int(input())

b = list(map(int,input().split()))
d = max(b)
c = [0 for i in range(pow(10,5)+100)]
cc = [0 for i in range(pow(10,5)+100)]
for i in range(len(b)):
    if i % 2 == 0:
        cc[b[i]-1] += 1
    else:
        c[b[i]-1] += 1

one = 0
onee = 0
two = 0
twoo = 0
k = 0
kk = 0
for i in range(len(c)+10):
    if one <= c[i]:
        onee = one
        one = c[i]
        k = i
    if two <= cc[i]:
        twoo = two
        two = cc[i]
        kk = i

t = max(one+twoo,onee+two)

if k != kk:
    print(a-one-two)
else:
    print(a-t)


a = int(input())

b = list(map(int,input().split()))
d = max(b)
c = [0 for i in range(pow(10,5))]
cc = [0 for i in range(pow(10,5))]
for i in range(a):
    if i % 2 == 0:
        c[b[i]-1] += 1
    else:
        cc[b[i]-1] += 1

one = 0
onee = 0
two = 0
twoo = 0
p = 0
pp = 0
for i in range(d):
    if one < c[i]:
        onee = one
        one = c[i]
        p += 1
    if two < cc[i]:
        twoo = two
        two = cc[i]
        p += 1
    if p == 2
        pp = 1
    else:
        pp = 0
    p = 0

t = max(one+twoo,onee+two)

if pp == 0
    print(a-one-two)
else:
    print(a-t)


from collections import Counter

a = int(input())

b = list(map(int,input().split()))
d = max(b)
c = [0 for i in range(pow(10,5)+1)]
cc = [0 for i in range(pow(10,5)+1)]
for i in range(len(b)):
    if i % 2 == 0:
        c[b[i]] += 1
    else:
        cc[b[i]] += 1
first = Counter(b[::2]).most_common(2) + [(0, 0)]
latter = Counter(b[1::2]).most_common(2) + [(0, 0)]
one = 0
onee = 0
two = 0
twoo = 0
k = 0
kk = 0
for i in range(d+1):
    if one <= c[i]:
        onee = one
        one = c[i]
        k = i
    elif onee <= c[i]:
        onee = c[i]
    if two <= cc[i]:
        twoo = two
        two = cc[i]
        kk = i
    elif twoo <= cc[i]:
        twoo = cc[i]
t = max(one+twoo,onee+two)

if k != kk:
    print(a-one-two)
else:
    print(a-t)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
from operator import itemgetter
def main():
    n=int(input())
    V=[int(_) for _ in input().split()]
    even=V[0::2]
    odd=V[1::2]
    even_c=Counter(even)
    odd_c=Counter(odd)
    even_ci,odd_ci=list(even_c.items()),list(odd_c.items())
    even_ci.sort(key=itemgetter(1),reverse=True)
    odd_ci.sort(key=itemgetter(1),reverse=True)
    print(even_ci)
    print(odd_ci)
    if even_ci[0][0]==odd_ci[0][0]:
        print(n//2)
    else:
        print(sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[0][1])

if __name__=='__main__':
    main()

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
from operator import itemgetter
def main():
    n=int(input())
    V=[int(_) for _ in input().split()]
    even,odd=V[0::2],V[1::2]
    even_c,odd_c=Counter(even),Counter(odd)
    even_ci,odd_ci=list(even_c.items()),list(odd_c.items())
    even_ci.sort(key=itemgetter(1),reverse=True)
    odd_ci.sort(key=itemgetter(1),reverse=True)
    if even_ci[0][0]==odd_ci[0][0]:
        if len(even_ci)>1 and len(odd_ci)>1:
            print(min(sum(even_c.values())-even_ci[1][1]+sum(odd_c.values())-odd_ci[0][1],
                        sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[1][1]))
        elif len(even_ci)>1 and len(odd_ci)==1:
            print(sum(even_c.values())-even_ci[1][1])        
        elif len(even_ci)==1 and len(odd_ci)>1:
            print(sum(odd_c.values())-odd_ci[0][1])        
        else:
            print(n//2)   
    else:
        print(sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[0][1])

if __name__=='__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n = int(input())
v = list(map(int,input().split()))
ans = 0
lia = v[::2]
lib = v[1::2]
tmp1 = len(lia)
tmp2 = len(lib)
lia.sort()
lib.sort()
if lia[0]==lib[-1]:
  print(n//2)
  exit()
lib.sort(reverse=True)
lia = collections.Counter(lia)
lib = collections.Counter(lib)
ans += tmp1-lia.most_common()[0][1]
ans += tmp2-lib.most_common()[0][1]
if lia.most_common()[0][1]%2==1 and lib.most_common()[0][1]2==1:
  print(ans+1)
else:
  print(ans)

from collections import Counter
N = int(input())
V = list(map(int, input().split()))
a = Counter(V[0::2]).most_common() + [(0,0)]
b = Counter(V[1::2]).most_common() + [(0,0)]
if a[0][0]!=b[0][0]:
    print(N-a[0][1]-b[0][1])
else:
    print(N-max(a[1][1]+b[0][1],a[0][1]+b[1][1]))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(n // 2)
else:
    v1 = [v[i] for i in range(0, n, 2)]
    v2 = [v[i + 1] for i in range(0, n, 2)]

    kw1 = Counter(v1)
    kw2 = Counter(v2)

    print(kw1)
    print(kw2)

    x1 = kw1.most_common()[0][0]
    x2 = kw2.most_common()[0][0]

    if x1 == x2:
        if kw1.most_common()[1][1] > kw2.most_common()[1][1]:
            x1 = kw1.most_common()[1][0]
        else:
            x2 = kw2.most_common()[1][0]

    ans = 0

    for i in v1:
        if i != x1:
            ans += 1

    for i in v2:
        if i != x2:
            ans += 1

    print(ans)


from collections import Counter

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(n // 2)
else:
    v1 = [v[i] for i in range(0, n, 2)]
    v2 = [v[i + 1] for i in range(0, n, 2)]

    kw1 = Counter(v1)
    kw2 = Counter(v2)

    x1 = kw1.most_common()[0][0]
    x2 = kw2.most_common()[0][0]

    if x1 != x2:
        ans = 0
        for i in v1:
            if i != x1:
                ans += 1
        for i in v2:
            if i != x2:
                ans += 1
    else:
        y1 = kw1.most_common()[1][0]
        y2 = kw2.most_common()[1][0]

        ans1 = 0
        ans2 = 0

        for i in v1:
            if i != y1:
                ans1 += 1
        for i in v2:
            if i != x2:
                ans1 += 1

        for i in v1:
            if i != x1:
                ans2 += 1
        for i in v2:
            if i != y2:
                ans2 += 1

        ans = min(ans1, ans2)

    print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
V = list(map(int, input().split()))
o = {}
e = {}
for i, v in enumerate(V):
    if i % 2 == 1:
        if not v in e.keys():
            e[v] = 0
        e[v] += 1
    else:
        if not v in o.keys():
            o[v] = 0
        o[v] += 1

o = sorted(o.values(), reverse=True)
e = sorted(e.values(), reverse=True)

e1 = sum(e[1:])
e2 = sum(e[0] + e[2:])
o1 = sum(o[1:])
o2 = sum(o[2:])
ret = min(e1+o2, e2+o1)
print(ret)


from collections import Counter
N = int(input())
v = list(map(int, input().split()))
e = []
o = []
for idx, i in enumerate(v):
    if idx % 2 == 0:
        o.append(i)
    else:
        e.append(i)

e = Counter(e).most_common()
o = Counter(o).most_common()
ea = N // 2
e1 = e[0][1]
e2 = e[1][1]
oa = N - ea
o1 = o[0][1]
o2 = o[1][1]
cnt = 0
if e1 != o1:
    cnt = N - e1 - o1
else:
    if o2 > e1:
        cnt = N - e2 - o1
    else:
        cnt = N - e1 - o2
print(cnt)

from collections import Counter
N = int(input())
v = list(map(int, input().split()))
e = []
o = []
for idx, i in enumerate(v):
    if idx % 2 == 0:
        o.append(i)
    else:
        e.append(i)

e = Counter(e).most_common()
o = Counter(o).most_common()
e1 = e[0][1]
e2 = e[1][1] if len(e) > 1 else 0
o1 = o[0][1]
o2 = o[1][1] if len(o) > 1 else 0
cnt = 0
if e[0][0] != o[0][0]:
    cnt = N - e1 - o1
else:
    o = N - e1 - o2
    e = N - e2 - o1
    cnt = min(o, e)
print(cnt)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n = int(input())
v = list(map(int, input().split()))

odd = [v[i] for i in range(n) if i % 2 == 0]
even = [v[i] for i in range(n) if i % 2 == 1]

t = collections.Counter(odd).most_common()
t2 = collections.Counter(even).most_common()

t = list(t.items())
t.sort(reverse=True)

t2 = list(t2.items())
t2.sort(reverse=True)


t.append([0, 0])
t2.append([0, 0])
ans = t[0][1] + t2[0][1]
if t[0][0] == t2[0][0]:
    ans = max(t[0][1] + t2[1][1], t[1][1]+t2[0][1])
print(n - ans)


import collections
n = int(input())
v = list(map(int, input().split()))

odd = [v[i] for i in range(n) if i % 2 == 0]
even = [v[i] for i in range(n) if i % 2 == 1]

t = collections.defaultdict(int)
t2 = collections.defaultdict(int)
for x in odd:
    t[x] += 1
for x in even:
    t2[x] += 1

t = list(t.items())
t.sort(key = lambda x:x[1], reverse=True)

t2 = list(t2.items())
t2.sort(key = lambda x:x[1],reverse=True)


t.append([0, 0])
t2.append([0, 0])
ans = t[0][1] + t2[0][1]
if t[0][0] == t2[0][0]:
    ans = max(t[0][1] + t2[1][1], t[1][1]+t2[0][1])
print(n - ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import collections

n = int(input())
v = list(map(int, input().split()))

v0 = [v[i] for i in range(0,n,2)]
v1 = [v[i] for i in range(1,n,2)]

v0cnt = collections.Counter(v0)
v1cnt = collections.Counter(v1)

v0most = v0cnt.most_common()[0]
v1most = v1cnt.most_common()[0]
v0next = v0cnt.most_common()[1]
v1next = v1cnt.most_common()[1]
if v0most[0] != v1most[0]:
    ans = n - v0most[1] -v1most[1]
else:
    if v0most[1] == v1most[1]:
        if v0most[1] == n//2:
            ans = n//2
        else:
            if v0next[1] > v1next[1]:
                ans = n - v1most[1] - v0next[1]
            else:
                ans = n - v0most[1] - v1next[1]            
    elif v0most[1] > v1most[1]:
        ans = n - v0most[1] - v1next[1]
    else:
        ans = n - v1most[1] - v0next[1]

print(ans)

# -*- coding: utf-8 -*-
"""
Created on Sat Sep 29 16:33:51 2018
ABC111C
@author: maezawa
"""

import collections

n = int(input())
v = list(map(int, input().split()))

v0 = [v[i] for i in range(0,n,2)]
v1 = [v[i] for i in range(1,n,2)]

v0cnt = collections.Counter(v0)
v1cnt = collections.Counter(v1)

v0most = v0cnt.most_common()[0]
v1most = v1cnt.most_common()[0]
if len(v0cnt) > 1:
    v0next = v0cnt.most_common()[1]
if len(v1cnt) > 1:
    v1next = v1cnt.most_common()[1]
if v0most[0] != v1most[0]:
    ans = n - v0most[1] -v1most[1]
else:
    if v0most[1] == v1most[1]:
        if v0most[1] == n//2:
            ans = n//2
        else:
            if v0next[1] > v1next[1]:
                ans = n - v1most[1] - v0next[1]
            else:
                ans = n - v0most[1] - v1next[1]            
    elif v0most[1] > v1most[1]:
        ans = n - v0most[1] - v1next[1]
    else:
        ans = n - v1most[1] - v0next[1]

print(ans)
    

Verdicts: Runtime Error

Accepted