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):
from collections import Counter


def main() -> None:
    n = int(input())
    p = [int(i) for i in input().split()]

    
    l1 = [int(p[i]) for i in range(0, n, 2)]
    
    l2 = [int(p[i]) for i in range(1, n, 2)]

    if len(set(p)) == 1:
        
        print(n // 2)
    else:
        lc1 = Counter(l1).most_common(2)
        lc2 = Counter(l2).most_common(2)

        if lc1[0][0] == lc2[0][0]:
            
            print(n - max(lc1[0][1] + lc2[1][1], lc1[1][1] + lc2[0][1]))
        else:
            
            print(n - lc1[0][1] - lc2[0][1])


from collections import Counter


def main() -> None:
    n = int(input())
    p = [int(i) for i in input().split()]

    
    l1 = [int(p[i]) for i in range(0, n, 2)]
    
    l2 = [int(p[i]) for i in range(1, n, 2)]

    if len(set(p)) == 1:
        
        print(n // 2)
    else:
        lc1 = Counter(l1).most_common(2)
        lc2 = Counter(l2).most_common(2)

        if lc1[0][0] == lc2[0][0]:
            
            print(n - max(lc1[0][1] + lc2[1][1], lc1[1][1] + lc2[0][1]))
        else:
            
            print(n - lc1[0][1] - lc2[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())
m=n//2
v1=list(map(int,input().split()))
v2=[]
for j in range(m):
    v2.append(v1.pop(j))
a1=sorted((collections.Counter(v1)).items(),key=lambda x:x[1],reverse=True)
a2=sorted((collections.Counter(v2)).items(),key=lambda x:x[1],reverse=True)
if a1[0][1]<a2[0][1]:a1,a2=a2[:],a1[:]
print(a2)
if a1[0][0]!=a2[0][0]:
    print(n-a1[0][1]-a2[0][1])
elif len(a2)==1:
    print(m)
else:
    print(n-a1[0][1]-a2[1][1])

import collections
n=int(input())
m=n//2
v1=list(map(int,input().split()))
v2=[]
for j in range(m):
    v2.append(v1.pop(j))
a1=sorted((collections.Counter(v1)).items(),key=lambda x:x[1],reverse=True)
a2=sorted((collections.Counter(v2)).items(),key=lambda x:x[1],reverse=True)
if a1[0][1]<a2[0][1]:a1,a2=a2[:],a1[:]
if a1[0][0]!=a2[0][0]:
    print(n-a1[0][1]-a2[0][1])
elif len(a2)==1:
    print(m)
elif a1[1][1]<a2[1][1]:
    print(n-a1[0][1]-a2[1][1])
else:
    print(n-a1[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):
#111
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
L=list(Counter(v[0::2]).items())
R=list(Counter(v[1::2]).items())


if L[0][0]!=R[0][0]:
    ans=n-L[0][1]-R[0][1]
elif len(R)!=1 and len(L)!=1:
    ans=n-max(L[0][1]+R[1][1],L[1][1]+R[0][1])
elif len(R)!=1 and len(L)==1:
    ans=n-R[1][1]-L[0][1]
elif len(R)==1 and len(L)!=1:
    ans=n-R[0][1]-L[1][1]
elif : len(R)==1 and len(L)==1:
    ans=n//2
print(ans)    


#112
from itertools import product

N=int(input())
px=[]
py=[]
ph=[]

for _ in range(N):
    x,y,h=map(int,input().split())
    if h!=0:
        px.append(x)
        py.append(y)
        ph.append(h)


        
def Calc_H(Cxi,Cyj,pxi,pyj,hi):
    return hi+abs(Cxi-pxi)+abs(Cyj-pyj)

    
    
for Cxi,Cyj in product(range(101),range(101)):
    preH=Calc_H(Cxi,Cyj,px[0],py[0],ph[0])
    for i in range(1,N):
        nowH=Calc_H(Cxi,Cyj,px[i],py[i],ph[i])
        if preH!=nowH:
            break
        preH=nowH
    else:
        print(Cxi,Cyj,nowH)

#111
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
L=Counter(v[0::2]).most_common()
R=Counter(v[1::2]).most_common()


if L[0][0]!=R[0][0]:
    ans=n-L[0][1]-R[0][1]
elif len(R)!=1 and len(L)!=1:
    ans=n-max(L[0][1]+R[1][1],L[1][1]+R[0][1])
elif len(R)!=1 and len(L)==1:
    ans=n-R[1][1]-L[0][1]
elif len(R)==1 and len(L)!=1:
    ans=n-R[0][1]-L[1][1]
elif len(R)==1 and len(L)==1:
    ans=n//2
print(ans)    


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):
from collections import Counter

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

even = a[1::2]
odd = a[::2]

c_even = Counter(even)
c_odd = Counter(odd)

arr_even = c_even.most_common()
arr_odd = c_odd.most_common()

sum_even = sum(x[1] for x in arr_even)
sum_odd = sum(x[1] for x in arr_odd)

min_sum = sum_even - arr_even[0] + n // 2

for i, x in arr_even:
    for j, y in arr_odd:
        if i != j:
            cnt = sum_even - x + sum_odd - y
            min_sum = min(min_sum, cnt)
            break
        else:
            continue

print(min_sum)

from collections import Counter

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

even = a[1::2]
odd = a[::2]

c_even = Counter(even)
c_odd = Counter(odd)

arr_even = c_even.most_common()
arr_odd = c_odd.most_common()

sum_even = sum(x[1] for x in arr_even)
sum_odd = sum(x[1] for x in arr_odd)

min_sum = sum_even - arr_even[0][1] + n // 2

for i, x in arr_even:
    for j, y in arr_odd:
        if i != j:
            cnt = sum_even - x + sum_odd - y
            min_sum = min(min_sum, cnt)
            break
        else:
            continue

print(min_sum)

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()))
for_set_v = v 
set_v = set(v)
even = []
odd = []
count = 0 
count_list = []
for num in range(n):
    if num % 2 == 0:
        even.append(v[num])
    else:
        odd.append(v[num])

even_most = Counter(even).most_common()
odd_most = Counter(odd).most_common()
print(even_most)
print(odd_most)
if len(set(v)) >= 2:
    if even_most[0][0] != odd_most[0][0]:
        if len(set(even)) != 1:
            count += (n/2) - int(even_most[0][1])
        if len(set(odd)) != 1:
            count += (n/2) - int(odd_most[0][1])
    else:
        try:
            count_list.append(n-int(even_most[0][1])-int(odd_most[1][1]))
            count_list.append(n-int(even_most[1][1])-int(odd_most[0][1]))
            count += int(max(count_list))
        except:
            if len(even_most) == 1:
                count += (n/2)-int(odd_most[1][1])
            elif len(odd_most) == 1:
                count += (n/2)-int(even_most[1][1])
else:
    count += (n/2)
print(int(count))


from collections import Counter

n = int(input())
v = list(map(int, input().split()))
for_set_v = v 
set_v = set(v)
even = []
odd = []
count = 0 
count_list = []
for num in range(n):
    if num % 2 == 0:
        even.append(v[num])
    else:
        odd.append(v[num])

even_most = Counter(even).most_common()
odd_most = Counter(odd).most_common()
#print(even_most)
#print(odd_most)
if len(set(v)) >= 2:
    if even_most[0][0] != odd_most[0][0]:
        if len(set(even)) != 1:
            count += (n/2) - int(even_most[0][1])
        if len(set(odd)) != 1:
            count += (n/2) - int(odd_most[0][1])
    else:
        try:
            count_list.append(n-int(even_most[0][1])-int(odd_most[1][1]))
            count_list.append(n-int(even_most[1][1])-int(odd_most[0][1]))
            #print(count_list)
            count += int(min(count_list))
        except:
            if len(even_most) == 1:
                count += (n/2)-int(odd_most[1][1])
            elif len(odd_most) == 1:
                count += (n/2)-int(even_most[1][1])
else:
    count += (n/2)
print(int(count))


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):
n1 = [[j, 0] for j in range(100005)]
n2 = [[j, 0] for j in range(100005)]
n = int(input())
v = list(map(int, input().split()))
for i in range(n):
    if(i % 2 == 0):
        n1[v[i]][1] += 1
    else:
        n2[v[i]][1] += 1
n1 = sorted(n1, key=lambda x:x[1], reverse=True)
n2 = sorted(n2, key=lambda x:x[1], reverse=True)

if(n1[0][0] == n2[0][0]):
    ans1 = n//2 - n1[0][1] + n//2 - n1[1][1]
    ans2 = n//2 - n1[1][1] + n//2 - n1[0][1]
    ans = min(ans1, ans2)
    print(ans)
else:
    ans = n//2 - n1[0][1] + n//2 - n1[0][1]
    print(ans)



n1 = [[j, 0] for j in range(100005)]
n2 = [[j, 0] for j in range(100005)]
n = int(input())
v = list(map(int, input().split()))
for i in range(n):
    if(i % 2 == 0):
        n1[v[i]][1] += 1
    else:
        n2[v[i]][1] += 1
n1 = sorted(n1, key=lambda x:x[1], reverse=True)
n2 = sorted(n2, key=lambda x:x[1], reverse=True)

if(n1[0][0] == n2[0][0]):
    ans1 = n//2 - n1[0][1] + n//2 - n2[1][1]
    ans2 = n//2 - n1[1][1] + n//2 - n2[0][1]
    ans = min(ans1, ans2)
    print(ans)
else:
    ans = n//2 - n1[0][1] + n//2 - n2[0][1]
    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):
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
​
cnt = [Counter(), Counter()]
cmn = [0, 0]
for parity in range(2):
    for i in (range(parity, n, 2)):
        cnt[parity][v[i]] += 1
    cmn[parity] = cnt[parity].most_common(1)[0]
​
if cmn[0][0] != cmn[1][0]:
    ret = n - cmn[0][1] - cmn[1][1]
else:
    subcmn_mult = [0, 0]
    for parity in range(2):
        try:
            subcmn_mult[parity] = cnt[parity].most_common(2)[1][1]
        except IndexError:
            subcmn_mult[parity] = 0
    ret = n - cmn[0][1] - max(subcmn_mult[0], subcmn_mult[1])
print(ret)

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

k = n // 2
half = [Counter(), Counter()]
for i in range(k):
    for par in range(2):
        half[par][v[2*i+par]] += 1

cmn = [0, 0]
for par in range(2):
    cmn[par] = half[par].most_common(2)
    if len(cmn[par]) == 1:
        cmn[par].append(('ghost', 0))
if cmn[0][0][0] != cmn[1][0][0]:
    ret = n - cmn[0][0][1] - cmn[1][0][1]
else:
    ret = n - max(cmn[0][0][1] + cmn[1][1][1], cmn[0][1][1] + cmn[1][0][1])
print(ret)

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
a=int(input())
A=list(map(int,input().split()))
b=[A[i] for i in range(a) if i%2==0].sort()
c=[A[i] for i in range(a) if i%2==1].sort()
if b==c:
    print(a//2)
else:
    bc=Counter(b).most_common()
    cc=Counter(c).most_common()
    if bc[0][0]==cc[0][0]:
        print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))
    else: print(a-bc[0][1]-cc[0][1])    

from collections import Counter
a=int(input())
A=list(map(int,input().split()))
bx=[A[i] for i in range(a) if i%2==0]
cx=[A[i] for i in range(a) if i%2==1]
b=sorted(bx)
c=sorted(cx)
print(b,c)
if b==c and len(set(b))==1 and len(set(c))==1:
    print(a//2)
else:
    bc=Counter(b).most_common()
    cc=Counter(c).most_common()
    print(bc,cc)
    if bc[0][0]==cc[0][0]:
        print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))
    else: print(a-bc[0][1]-cc[0][1])    

from collections import Counter

a=int(input())
A=list(map(int,input().split()))
bx=[A[i] for i in range(a) if i%2==0]
cx=[A[i] for i in range(a) if i%2==1]

if b==c and len(set(b))==1 and len(set(c))==1:
    print(a//2)
else:
    bc=Counter(b).most_common()
    cc=Counter(c).most_common()
    if bc[0][0]==cc[0][0]:
        print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))
    else: print(a-bc[0][1]-cc[0][1])    

from collections import Counter

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

if b==c and len(set(b))==1 and len(set(c))==1:
    print(a//2)
else:
    bc=Counter(b).most_common()
    cc=Counter(c).most_common()
    if bc[0][0]==cc[0][0]:
        print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))
    else: print(a-bc[0][1]-cc[0][1])    

Verdicts: Wrong Answer

Wrong Answer

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()))

evel = collections.Counter()
odd = collections.Counter()
for index, v in enumerate(V):
    if index % 2 == 0:
        evel[v] += 1
    else:
        odd[v] += 1
print(evel, odd)
if evel == odd:
    print(int(n / 2))
else:
    el = evel.most_common()
    ol = odd.most_common()
    max_val = 0
    for index_e, num_e in el:
        for index_o, num_o in ol:
            if index_e != index_o:
                max_val = max(max_val, num_e + num_o)
    ans = n - max_val
    print(ans)


import collections

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

evel = collections.Counter()
odd = collections.Counter()
for index, v in enumerate(V):
    if index % 2 == 0:
        evel[v] += 1
    else:
        odd[v] += 1

print(evel.most_common(), odd.most_common())
if evel == odd:
    print(int(n / 2))
else:
    if evel.most_common()[0][0] == odd.most_common()[0][0]:
        
        #     ans = int(n / 2) - evel.most_common()[0][1] + int(n / 2) - odd.most_common()[1][1]
        # else:
        #     ans = int(n / 2) - evel.most_common()[1][1] + int(n / 2) - odd.most_common()[0][1]
        el = evel.most_common(10)
        ol = odd.most_common(10)
        max_val = 0
        for index_e, num_e in el:
            for index_o, num_o in ol:
                if index_e != index_o:
                    max_val = max(max_val, num_e + num_o)
        ans = n - max_val
    else:
        ans = int(n / 2) - evel.most_common()[0][1] + int(n / 2) - odd.most_common()[0][1]
    print(ans)



import collections

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


def map_all(li):
    return all([e == li[0] for e in li[1:]]) if li else False


evel = collections.Counter()
evel2 = []
odd = collections.Counter()
odd2 = []
for index, v in enumerate(V):
    if index % 2 == 0:
        evel[v] += 1
        evel2.append(v)
    else:
        odd[v] += 1
        odd2.append(v)

if map_all(evel2) and map_all(odd2):
    
    if evel2[0] == odd2[0]:
        
        print(int(n / 2))
    else:
        print(0)
else:
    el = evel.most_common(100)
    ol = odd.most_common(100)
    max_val = 0
    for index_e, num_e in el:
        for index_o, num_o in ol:
            if index_e != index_o:
                max_val = max(max_val, num_e + num_o)
    ans = n - max_val
    print(ans)


Verdicts: Wrong Answer

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 collections import Counter
n,*v = map(int,open(0).read().split())
v1 = Counter(v[::2])
v2 = Counter(v[1::2])
v1 = sorted([(i,v1[i]) for i in v1.keys()],key =lambda x:x[1],reverse=True)
v2 = sorted([(i,v2[i]) for i in v2.keys()],key =lambda x:x[1],reverse=True)
print(v1,v2)
if len(v1) == 1:
  if len(v2) == 1:
    if v1[0][0] != v2[0][0]:
      print(0)
    else:
      print(n//2)
  else:
    if v1[0][0] != v2[0][0]:
      print(n//2-v2[0][1])
    else:
      print(n//2-v2[1][1])
else:
  if len(v2) == 1:
    if v1[0][0] != v2[0][0]:
      print(n//2-v1[0][1])
    else:
      print(n//2-v1[1][1])
  else:
    if v1[0][0] != v2[0][0]:
      print(n-v1[0][1]-v2[0][1])
    else:
      print(min(n-v1[0][1]-v2[1][1],n-v1[1][1]-v2[0][1]))

from collections import Counter
n,*v = map(int,open(0).read().split())
v1 = Counter(v[::2])
v2 = Counter(v[1::2])
v1 = sorted([(i,v1[i]) for i in v1.keys()],key =lambda x:x[1],reverse=True)
v2 = sorted([(i,v2[i]) for i in v2.keys()],key =lambda x:x[1],reverse=True)
if v1[0][0] != v2[0][0]:
  print(n-v1[0][1]-v2[0][1])
else:
  e1 = n-v2[0][1] if len(v1) == 1 else n-v1[1][1]-v2[0][1]
  e2 = n-v1[0][1] if len(v2) == 1 else n-v1[0][1]-v2[1][1]
  print(min(e1,e2))

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 collections import Counter
def main():
    N = int(input())
    V = list(map(int, input().split()))
    c0 = Counter(V[::2])
    c1 = Counter(V[1::2])
    cc0 = sorted([(0, 0)] + [(v, k) for k, v in c0.items()], reverse=True)
    cc1 = sorted([(0, 0)] + [(v, k) for k, v in c1.items()], reverse=True)
    m0, v0 = cc0[0]
    m1, v1 = cc0[1]
    if v0 != v1:
        return N - m0 - m1
    if m0 > m1:
        return N - m0 - cc1[1][0]
    return N - m1 - cc0[1][0]
print(main())


from collections import Counter
def main():
    N = int(input())
    V = list(map(int, input().split()))
    c0 = Counter(V[::2])
    c1 = Counter(V[1::2])
    cc0 = sorted([(0, 0)] + [(v, k) for k, v in c0.items()], reverse=True)
    cc1 = sorted([(0, 0)] + [(v, k) for k, v in c1.items()], reverse=True)
    m0, v0 = cc0[0]
    m1, v1 = cc1[0]
    if v0 != v1:
        return N - m0 - m1
    return min(N - m0 - cc1[1][0], N - m1 - cc0[1][0])
print(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()))

l1 = []
l2 = []
for i in range(n):
    if i % 2 == 0:
        l1.append(v[i])
    else:
        l2.append(v[i])

counter1 = collections.Counter(l1)
counter2 = collections.Counter(l2)

mode_v1 = counter1.most_common()
mode_v2 = counter2.most_common()
print(mode_v1, mode_v2)

if mode_v1[0][0] != mode_v2[0][0]:
    print(n - mode_v1[0][1] - mode_v2[0][1])
else:
    print(n // 2 )

import collections

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

l1 = []
l2 = []
for i in range(n):
    if i % 2 == 0:
        l1.append(v[i])
    else:
        l2.append(v[i])

counter1 = collections.Counter(l1)
counter2 = collections.Counter(l2)

mode_v1 = counter1.most_common()
mode_v2 = counter2.most_common()
# print(mode_v1, mode_v2)

if mode_v1[0][0] != mode_v2[0][0]:
    print(n - mode_v1[0][1] - mode_v2[0][1])
else:
    if len(set(v)) == 1:
        print(n // 2)
    elif len(set(l1)) == 1:
        print(mode_v2[0][1])
    elif len(set(l2)) == 1:
        print(mode_v1[0][1])
    else:
        print(min(n - mode_v1[0][1] - mode_v2[1][1], n - mode_v1[1][1] - mode_v2[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())
vl = [int(i) for i in input().split()]
oc = Counter(a for i, a in enumerate(vl) if i % 2 == 0)
ec = Counter(a for i, a in enumerate(vl) if i % 2 == 1)
ol = sorted(((v, k) for k, v in oc.items()), reverse=True)
el = sorted(((v, k) for k, v in ec.items()), reverse=True)

if ol[0][1] != el[0][1]:
    print(n - ol[0][0] - el[0][0])
else:
    if ol[0][0] >= el[0][0]:
        if len(el) >= 2:
            print(n - ol[0][0] - el[1][0])
        else:
            print(n - ol[0][0])
    else:
        if len(ol) >= 2:
            print(n - ol[1][0] - el[0][0])
        else:
            print(n - el[0][0])

from collections import Counter
n = int(input())
vl = [int(i) for i in input().split()]
oc = Counter(a for i, a in enumerate(vl) if i % 2 == 0)
ec = Counter(a for i, a in enumerate(vl) if i % 2 == 1)
ol = sorted(((v, k) for k, v in oc.items()), reverse=True)
el = sorted(((v, k) for k, v in ec.items()), reverse=True)

if ol[0][1] != el[0][1]:
    print(n - ol[0][0] - el[0][0])
else:
    res = 1 << 30
    if len(ol) == len(el) == 1:
        res = n // 2
    if len(ol) > 1:
        res = min(res, n - ol[1][0] - el[0][0])
    if len(el) > 1:
        res = min(res, n - ol[0][0] - el[1][0])
    print(res)

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:

    c1 = Counter(v[::2])
    c2 = Counter(v[1::2])
    o = c1.most_common(2)
    e = c2.most_common(2)
    o.append((0,0))
    e.append((0,0))
    if o[0][0] == e[0][0]:
        print(min(n-o[1][1]-e[0][1],n-o[0][1]-e[1][1]))
    else:
        print(n-o(2)[0][1]-e(2)[0][1])

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

if len(set(v)) == 1:
    print(n//2)
else:

    c1 = Counter(v[::2])
    c2 = Counter(v[1::2])
    o = c1.most_common(2)
    e = c2.most_common(2)
    o.append((0,0))
    e.append((0,0))
    if o[0][0] == e[0][0]:
        print(min(n-o[1][1]-e[0][1],n-o[0][1]-e[1][1]))
    else:
        print(n-o[0][1]-e[0][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):
import collections

N = int(input())
items = list(map(int, input().split()))


even_num = items[::2]
odd_num = items[1::2]


dev = Counter(even_num).most_common(2)
dod = Counter(odd_num).most_common(2)

if dev[0][0] == dod[0][0] :
    if len(dev) == len(dod) == 1 :
        print(N//2)
    elif len(dev) < len(dod) :
        print(N//2 - dod[1][1])
    elif len(dev) > len(dod) :
        print(N//2 - dev[1][1])
    else :
        print(N - max(dod[1][1] + dev[0][1], dod[0][1] + dev[1][1]))
else :
    print(N - dod[0][1]- dev[0][1])



from collections import Counter

N = int(input())
items = list(map(int, input().split()))


even_num = items[::2]
odd_num = items[1::2]


dev = Counter(even_num).most_common(2)
dod = Counter(odd_num).most_common(2)

if dev[0][0] == dod[0][0] :
    if len(dev) == len(dod) == 1 :
        print(N//2)
    elif len(dev) < len(dod) :
        print(N//2 - dod[1][1])
    elif len(dev) > len(dod) :
        print(N//2 - dev[1][1])
    else :
        print(N - max(dod[1][1] + dev[0][1], dod[0][1] + dev[1][1]))
else :
    print(N - dod[0][1]- dev[0][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()))

v_odd[1::2]
v_even[0::2]

v_odd_mc = Counter(v_odd).most_common()
v_even_mc = Counter(v_even).most_common()

v_odd_mc.append((0, 0))
v_even_mc.append((0, 0))

if v_odd_mc[0] != v_even_mc[0]:
    print(n-v_odd_mc[0][1]-v_even_mc[0][1])
else:
    print(n - max(v_odd_mc[0][1] + v_even_mc[1][1], v_odd_mc[1][0]+v_even_mc[0][1]))

from collections import Counter

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

v_odd = v[1::2]
v_even = v[0::2]

v_odd_mc = Counter(v_odd).most_common()
v_even_mc = Counter(v_even).most_common()

v_odd_mc.append((0, 0))
v_even_mc.append((0, 0))

if v_odd_mc[0] != v_even_mc[0]:
    print(n-v_odd_mc[0][1]-v_even_mc[0][1])
else:
    print(n - max(v_odd_mc[0][1] + v_even_mc[1][1], v_odd_mc[1][1]+v_even_mc[0][1]))
    # print(min(n - v_odd_mc[0][1] - v_even_mc[1][1], n - v_odd_mc[1][1] - v_even_mc[0][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):

def main():


    N = int(input())
    V = list(map(int,input().split()))
    V1 = [i for i in V[0::2]]
    V2 = [i for i in V[1::2]]
    count1 = 0

    if len(list(set(V)))==1:
        print(int(N/2))
        exit()

    for i,j in enumerate(V1[1::]):
        if V1[i-1] != j:
            count1 +=1

    
    for i,j in enumerate(V2[1::]):
        if V2[i-1] != j:
            count1 +=1

    print(count1)





if __name__== "__main__":
    main() 


import collections
def main():


    N = int(input())
    V = list(map(int,input().split()))
    V1 = V[0::2]
    V2 = V[1::2]
    count = 0

    fre1 = collections.Counter(V1).most_common(2)
    fre2 = collections.Counter(V2).most_common(2)
    

    if len(list(set(V)))==1:
        print(int(N/2))
        exit()


    if fre1[0][0] != fre2[0][0]:

        count += len(V1)-fre1[0][1]
        count += len(V2)-fre2[0][1]
        print(count)
    elif len(V1)-fre1[0][1] == len(V2)-fre2[0][1]:
        bigger = max(fre1[1][1],fre2[1][1])
        count += len(V1)-bigger
        count += len(V1)-fre1[0][1]
        print(count)
    else:
        if len(V1)-fre1[0][1] < len(V2)-fre2[0][1]:
            count += len(V1)-fre1[0][1]
            count += len(V2)-fre2[1][1]
            print(count)
        else:
            count += len(V1)-fre1[1][1]
            count += len(V2)-fre2[0][1]
            print(count)

        






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):
from collections import Counter
n=int(input())
l=list(map(int,input().split()))
f=l[0::2]
s=l[1::2]
ans=[]
if len(Counter(l).values()) == 1:
  ans.append(len(f))
elif len(Counter(f).values()) == len(Counter(s).values()) == 1:
  ans.append(0)
else:
  print(Counter(f).items(),Counter(s).items())
  for fk,fv in sorted(Counter(f).items(),key=lambda x:x[0]):
    fdk=fk
    a=sum(Counter(f).values())-fv
    for sk,sv in sorted(Counter(s).items(),key=lambda x:x[0]):
      if fk != sk:
        ans.append(a+sum(Counter(s).values())-sv)
print(min(ans))

from collections import Counter
n=int(input())
l=list(map(int,input().split()))
f=l[0::2]
s=l[1::2]
fn=sorted(Counter(f).items(),key=lambda x:x[1],reverse=True) + [(0, 0)]
sn=sorted(Counter(s).items(),key=lambda x:x[1],reverse=True) + [(0, 0)]
if fn[0][0]!=sn[0][0]:
  ans=n-fn[0][1]-sn[0][1]
else:
  ans=n-max(fn[1][1]+sn[0][1],fn[0][1]+sn[1][1])
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 = [int(v) for v in input().split()]

V1 = [V[n] for n in range(0, n, 2)] #v1, v3, v5, ...
V2 = [V[n] for n in range(1, n, 2)] #v2, v4, v6, ...

V1_set = list(set(V1))
V1_cnt = []
for i in V1_set:
  i_cnt = V1.count(i)
  V1_cnt += [i, i_cnt]
V1_cnt += [0, 0] 
V1_cnt.sort(key=lambda x: x[1], reverse=True)
  
V2_set = list(set(V2))
V2_cnt = []
for i in V2_set:
  i_cnt = V2.count(i)
  V2_cnt += [i, i_cnt]
V2_cnt += [0, 0] 
V2_cnt.sort(key=lambda x: x[1], reverse=True)

mxnum_V1_cnt = V1_cnt[0][0] 
mxnum_V2_cnt = V2_cnt[0][0] 
if mxnum_V1_cnt != mxnum_V2_cnt:
  ans = n - (V1_cnt[0][1] + V2_cnt[0][1])
else:
  ans = n - max(V1_cnt[0][1] + V2_cnt[1][1], V1_cnt[1][1] + V2_cnt[0][1])

print(ans)

n = int(input())
V = [int(v) for v in input().split()]

V1 = [V[n] for n in range(0, n, 2)] #v1, v3, v5, ...
V2 = [V[n] for n in range(1, n, 2)] #v2, v4, v6, ...

mx_V1 = max(V1)
V1_cnt = [[0, 0]] 
for i in range(1, mx_V1+1):
  V1_cnt.append([i, 0])
for v in V1:
  V1_cnt[v][1] += 1  
V1_cnt.sort(key=lambda x: x[1], reverse=True)

mx_V2 = max(V2)
V2_cnt = [[0, 0]] 
for j in range(1, mx_V2+1):
  V2_cnt.append([j, 0])
for v in V2:
  V2_cnt[v][1] += 1  
V2_cnt.sort(key=lambda x: x[1], reverse=True)

mxnum_V1_cnt = V1_cnt[0][0] 
mxnum_V2_cnt = V2_cnt[0][0] 
if mxnum_V1_cnt != mxnum_V2_cnt:
  ans = n - (V1_cnt[0][1] + V2_cnt[0][1])
else:
  ans = n - max(V1_cnt[0][1] + V2_cnt[1][1], V1_cnt[1][1] + V2_cnt[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):
n = int(input())
v = list(map(int, input().split()))

va, ve = v[0::2], v[1::2]
da, de = {}, {}
for a in va:
  da[a] = da.get(a, 0)+1
for e in ve:
  de[e] = de.get(e, 0)+1
add = sorted([(k,v) for k,v in da.items()], key=lambda x:-x[1])+[(0,0)]
even = sorted([(k,v) for k,v in de.items()], key=lambda x:-x[1])+[(0,0)]
if add[0][0] == even[0][0]:
  if add[1][1] <= even[1][1]:
    even.pop(0)
  else:
    add.pop(0)
print(n-add[0][1]-even[0][1])
print(add, even)


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

va, ve = v[0::2], v[1::2]
da, de = {}, {}
for a in va:
  da[a] = da.get(a, 0)+1
for e in ve:
  de[e] = de.get(e, 0)+1
add = sorted([(k,v) for k,v in da.items()], key=lambda x:-x[1])+[(0,0)]
even = sorted([(k,v) for k,v in de.items()], key=lambda x:-x[1])+[(0,0)]
if add[0][0] == even[0][0]:
  if add[1][1] <= even[1][1]:
    even.pop(0)
  else:
    add.pop(0)
print(n-add[0][1]-even[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):
import collections
n = int(input())
v = [int(i) for i in input().split()]

dummy = (-1, -1)
(av1, ak1), (av2, ak2) = (collections.Counter(v[::2]).most_common(2) + dummy)[:2]
(bv1, bk1), (bv2, bk2) = (collections.Counter(v[1::2]).most_common(2) + dummy)[:2]

if av1 != bv1:
    print(n-ak1-bk1)
elif ak1 < bk1:
    print(n-ak2-bk1)
else:
    print(n-ak1-bk2)

import collections
n = int(input())
v = [int(i) for i in input().split()]

dummy = [(-1, 0)]
(av1, ak1), (av2, ak2) = (collections.Counter(v[::2]).most_common(2) + dummy)[:2]
(bv1, bk1), (bv2, bk2) = (collections.Counter(v[1::2]).most_common(2) + dummy)[:2]

if av1 != bv1:
    print(n-ak1-bk1)
elif ak1 < bk1:
    print(n-ak2-bk1)
elif ak1 > bk1:
    print(n-ak1-bk2)
elif ak1+bk2 > bk1+ak2:
    print(n-ak1-bk2)
else:
    print(n-ak2-bk1)

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()))
nums = [v for v in V if V.count(x) != int(N/2)]
print(int(len(nums)/2))


from collections import Counter

N = int(input())
V = list(map(int,input().split()))

even = Counter(V[1::2]).most_common() + [(0, 0)]
odd = Counter(V[::2]).most_common() + [(0, 0)]

if even[0][0] != odd[0][0]:
  print(N-even[0][1]-odd[0][1])
else:
  print(min(N-even[0][1]-odd[1][1], N-even[1][1]-odd[0][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):
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**7)
mod = 10**9+7
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def counter_top(c,exclude):
    for a in c.most_common():
        if a[0]!=exclude:
            return a
    return (object(),0)

def conv_seq(seq,exclude = None):
    c = collections.Counter(seq)
    mc = counter_top(c,exclude)
    return sum(c.values()) - mc[1],mc[0]

N = I()
V = LI()

l = [V[i] for  i in range(0,N,2)]
r = [V[i] for i in range(1,N,2)]

s1,a = conv_seq(V[::2])
s2,b = conv_seq(V[1::2])

if s1!=s2:
    print(a+b)
else:
    s1_new,_ = conv_seq(V[::2],exclude=b)
    s2_new,_ = conv_seq(V[1::2],exclude=a)
    print(min(s1_new+s2,s1+s2_new))

import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**7)
mod = 10**9+7
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def counter_top(c,exclude):
    for a in c.most_common():
        if a[0]!=exclude:
            return a
    return (object(),0)

def conv_seq(seq,exclude = None):
    c = collections.Counter(seq)
    mc = counter_top(c,exclude)
    return sum(c.values()) - mc[1],mc[0]

N = I()
V = LI()

s1,a = conv_seq(V[::2])
s2,b = conv_seq(V[1::2])


if s1!=s2:
    print(s1+s2)
else:
    s1_new,_ = conv_seq(V[::2],exclude=b)
    s2_new,_ = conv_seq(V[1::2],exclude=a)
    print(min(s1_new+s2,s1+s2_new))


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().split()[0])
v_list = list(map(int, input().split()))


odd_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 1]

even_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 0]


odd_counter = collections.Counter(odd_list)
odd_1 = odd_counter.most_common()[0][0]

if len(odd_counter) >= 2:
    odd_2 = odd_counter.most_common()[1][0]
else:
    odd_2 = '*' 


even_counter = collections.Counter(even_list)
even_1 = even_counter.most_common()[0][0]

if len(even_counter) >= 2:
    even_2 = even_counter.most_common()[1][0]
else:
    even_2 = '+' 




if even_1 == odd_1:
    
    even_op_count = len([v for v in even_list if v != even_1])
    
    odd_op_count = len([v for v in odd_list if v != odd_2])
    count_1 = even_op_count + odd_op_count

    
    even_op_count = len([v for v in even_list if v != even_2])
    
    odd_op_count = len([v for v in odd_list if v != odd_1])
    count_2 = even_op_count + odd_op_count

    count = min(count_1, count_2)
else:
    
    even_op_count = len([v for v in even_list if v != even_1])
    odd_op_count = len([v for v in odd_list if v != odd_1])
    count = even_op_count + odd_op_count

print(count)



# C - /\/\/\/
import collections

n = int(input().split()[0])
v_list = list(map(int, input().split()))


odd_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 1]

even_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 0]


odd_counter = collections.Counter(odd_list)
odd_1 = odd_counter.most_common()[0][0]

if len(odd_counter) >= 2:
    odd_2 = odd_counter.most_common()[1][0]
else:
    odd_2 = '*' 


even_counter = collections.Counter(even_list)
even_1 = even_counter.most_common()[0][0]

if len(even_counter) >= 2:
    even_2 = even_counter.most_common()[1][0]
else:
    even_2 = '+' 




if even_1 == odd_1:
    
    even_op_count = len([v for v in even_list if v != even_1])
    
    odd_op_count = len([v for v in odd_list if v != odd_2])
    count_1 = even_op_count + odd_op_count

    
    even_op_count = len([v for v in even_list if v != even_2])
    
    odd_op_count = len([v for v in odd_list if v != odd_1])
    count_2 = even_op_count + odd_op_count

    count = min(count_1, count_2)
else:
    
    even_op_count = len([v for v in even_list if v != even_1])
    odd_op_count = len([v for v in odd_list if v != odd_1])
    count = even_op_count + odd_op_count

print(count)


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=input().split()
vodd=[]
veven=[]
for i in range(n):
    if i%2:
        veven.append(int(v[i]))
    else:
        vodd.append(int(v[i]))

changeCnt=0

voddNum=[vodd[0]]
voddCnt=[0]
j=0
for i,odd in enumerate(vodd):
    if voddNum[j]!=odd:
        for k,num in enumerate(voddNum):
            if num==odd:
                j=k
                break
        else:
            j=k+1
            voddNum.append(odd)
            voddCnt.append(0)
            
    voddCnt[j]+=1

voddSet=list(zip(voddCnt, voddNum))
print(voddSet)
for i in range(len(voddSet)):
    voddSet[i]=list(voddSet[i])

voddSet=list(reversed(sorted(voddSet,key=lambda x:x[0])))



vevenNum=[veven[0]]
vevenCnt=[0]
j=0
for i,even in enumerate(veven):
    if vevenNum[j]!=even:
        for k,num in enumerate(vevenNum):
            if num==even:
                j=k
                break
        else:
            j=k+1
            vevenNum.append(even)
            vevenCnt.append(0)

    vevenCnt[j]+=1
vevenSet=list(zip(vevenCnt, vevenNum))
print(vevenSet)
for i in range(len(vevenSet)):
    vevenSet[i]=list(vevenSet[i])

vevenSet=list(reversed(sorted(vevenSet,key=lambda x:x[0])))

'''
print()
print(veven)
print(vevenNum)
print(vevenCnt)
print(vevenSet)
'''

changeCnt+=len(vodd)+len(veven)
if voddSet[0][1]==vevenSet[0][1]:
    if len(voddSet==1):
        changeCnt+=-len(vodd)
    else:
        if voddSet[1][0]>vevenSet[1][0]:
            changeCnt+=-voddSet[1][0]-vevenSet[0][0]
        else:
            changeCnt+=-voddSet[0][0]-vevenSet[1][0]
else:
    changeCnt+=-voddSet[0][0]-vevenSet[0][0]
    
print(changeCnt)
               


n=int(input())
v=map(int,input().split())
vodd={-1:0}
veven={-1:0}
for i,vi in enumerate(v):
    if i%2:
        if(vi in veven):
            veven[vi]+=1
        else:
            veven[vi]=1
    else:
        if(vi in vodd):
            vodd[vi]+=1
        else:
            vodd[vi]=1
veven=list(veven.items())
veven.sort(key=lambda x:-x[1])
vodd=list(vodd.items())
vodd.sort(key=lambda x:-x[1])
if veven[0][0]==vodd[0][0]:
    a=veven[0][1]+vodd[1][1]
    b=veven[1][1]+vodd[0][1]
    changeCnt=n-a if a>b else n-b
else:
    changeCnt=n-veven[0][1]-vodd[0][1]

print(changeCnt)

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 = [int(n) for n in input().split()]

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else vp[0][1] == vn[0][1]:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vn[0][1]
            else:
                gp = vp[0][1]
                gn = vn[1][1]
 
    ans = n - gp - gn
print(ans)

from collections import Counter

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

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else vp[0][1] == vn[0][1]:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vp[0][1]
            else:
                gp = vp[0][1]
                gn = vp[1][1]
 
    ans = n - gp - gn
print(ans)

from collections import Counter

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

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vn[0][1]
            else:
                gp = vp[0][1]
                gn = vn[1][1]
 
    ans = n - gp - gn
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted