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
N = int(input())
V = list(map(int, input().split()))
a1, a2, *_ = Counter(V[0::2]).most_common() + [(0, 0)]
b1, b2, *_ = Counter(V[1::2]).most_common() + [(0, 0)]
print(N - max(a1[1] + b2[1], a2[1] + b1[1]) if a1[0] == b1[0] else N - a1[1] + b1[1])


from collections import Counter
N = int(input())
V = list(map(int, input().split()))
a1, a2, *_ = Counter(V[0::2]).most_common() + [(0, 0)]
b1, b2, *_ = Counter(V[1::2]).most_common() + [(0, 0)]
print(N - max(a1[1] + b2[1], a2[1] + b1[1]) if a1[0] == b1[0] else N - (a1[1] + b1[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())
l = list(map(int, input().split()))

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

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]

ce = collections.Counter(leven)
co = collections.Counter(lodd)
ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

if ce[-1][0] != ce[-1][0]:
	print(n - ce[-1][1] - co[-1][1])
elif ce[-2][1] > co[-2][1]:
    print(n - ce[-2][1] - co[-1][1])
else:
    print(n - ce[-1][1] - co[-2][1])


import collections


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

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

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]
ce = collections.Counter(leven)
co = collections.Counter(lodd)

ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

if ce[-1][0] != ce[-1][0]:
	print(n - ce[-1][1] - co[-1][1])
elif ce[-2][1] > co[-2][1]:
    print(n - ce[-2][1] - ce[-1][1])
else:
    print(n - ce[-1][1] - ce[-2][1])


import collections


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

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

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]

ce = collections.Counter(leven)
co = collections.Counter(lodd)
ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

if ce[-1][0] != co[-1][0]:
	print(n - ce[-1][1] - co[-1][1])
elif ce[-2][1] > co[-2][1]:
    print(n - ce[-2][1] - co[-1][1])
else:
    print(n - ce[-1][1] - co[-2][1])


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):
n = int(input())
v = input().split()
o = {"":0}
e = {"":0}
for s in v[::2]:
    if s in o:
        o[s] += 1
    else:
        o[s] = 1

for s in v[1::2]:
    if s in e:
        e[s] += 1
    else:
        e[s] = 1

o = sorted(o.items(), key=lambda x:x[1])
e = sorted(e.items(), key=lambda x:x[1])

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

n = int(input())
v = input().split()
o = {"":0}
e = {"":0}
for s in v[::2]:
    if s in o:
        o[s] += 1
    else:
        o[s] = 1

for s in v[1::2]:
    if s in e:
        e[s] += 1
    else:
        e[s] = 1

o = sorted(o.items(), key=lambda x:x[1])
e = sorted(e.items(), key=lambda x:x[1])

if o[-1][0] != e[-1][0]:
    print(n-o[-1][1]-e[-1][1])
else:
    print(n - max(o[-1][1]+e[-2][1], o[-2][1]+e[-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):
import collections

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
#a1.append((0,0))
#a2.append((0,0))
print(a1)
print(a2)

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



import collections

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
a1.append((0,0))
a2.append((0,0))
#print(a1)
#print(a2)

if a1[0] != a2[0]:
    print(n-a1[0][1]-a2[0][1])
else:
    print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[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):
n = int(input())
v = list(map(int, input().split()))
even_list = [0] * (n + 1)
odd_list = [0] * (n + 1)

for i in range(n):
    if i % 2 == 0:
        even_list[i] += 1

    else:
        odd_list[i] += 1

if even_list.index(max(even_list)) == odd_list.index(max(odd_list)):
    even_sorted, odd_sorted = sorted(even_list), sorted(odd_list)
    print(n - min(even_sorted[-1] - odd_sorted[-2], n - even_sorted[-2] - odd_sorted[-1]))

else:
    print(n - max(even_list) - max(odd_list))


n = int(input())
v = list(map(int, input().split()))
even_list = [0] * (n + 1)
odd_list = [0] * (n + 1)

for i in range(n):
    if i % 2 == 0:
        even_list[i] += 1

    else:
        odd_list[i] += 1

if even_list.index(max(even_list)) == odd_list.index(max(odd_list)):
    even_sorted, odd_sorted = sorted(even_list), sorted(odd_list)
    print(min(even_sorted[-1] + odd_sorted[-2], even_sorted[-2] + odd_sorted[-1]))

else:
    print(n - max(even_list) - max(odd_list))


n = int(input())
v = list(map(int, input().split()))
even_list = [0] * (n + 1)
odd_list = [0] * (n + 1)

for i in range(n):
    if i % 2 == 0:
        even_list[i] += 1

    else:
        odd_list[i] += 1

if even_list.index(max(even_list)) == odd_list.index(max(odd_list)):
    even_sorted, odd_sorted = sorted(even_list), sorted(odd_list)
    print(min(n - even_sorted[-1] - odd_sorted[-2], n - even_sorted[-2] - odd_sorted[-1]))

else:
    print(n - max(even_list) - max(odd_list))


n = int(input())
v = list(map(int, input().split()))
even_list = [0] * (100000 + 1)
odd_list = [0] * (100000 + 1)

for i in range(n):
    if i % 2 == 0:
        even_list[v[i]] += 1

    else:
        odd_list[v[i]] += 1

if even_list.index(max(even_list)) == odd_list.index(max(odd_list)):
    even_sorted, odd_sorted = sorted(even_list), sorted(odd_list)
    print(min(n - even_sorted[-1] - odd_sorted[-2], n - even_sorted[-2] - odd_sorted[-1]))

else:
    print(n - max(even_list) - max(odd_list))


Verdicts: Wrong Answer

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):
import math,fractions
from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]
a = Counter(v[1::2]).most_common()
b = Counter(v[0::2]).most_common()
a.append(0,0)
b.append(0,0)

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


import math,fractions
from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]
a = Counter(v[1::2]).most_common()
b = Counter(v[0::2]).most_common()
a.append((0,0))
b.append((0,0))

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


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 corections import Counter 
n = int(input())
v = list(map(int,input().split()))
 
odd = []
even = []
for i in range(n//2):
	odd.append(v[2*i+1])
	even.append(v[2*i])
 
odd = sorted(odd)
even = sorted(even)
ac = Counter(odd).most_common(2)
bc = Counter(even).most_common(2)
def cnt(X):
	count = 0
	ans = 0
	for i in range(len(X)-1):
		if X[i+1] == X[i]:
			count += 1
			ans = max(ans,count)
		else:
			count = 0
	return ans+1
            
if ac[0][0] != bc[0][0]:
  print(len(v)-cnt(odd)-cnt(even))
elif len(ac) == 1 and len(bc) == 1:
	print(n//2)
else:
	print(n-max(ac[0][1]+bc[1][1],ac[1][1]+bc[0][1]))

from collections import Counter 
n = int(input())
v = list(map(int,input().split()))
 
odd = []
even = []
for i in range(n//2):
	odd.append(v[2*i+1])
	even.append(v[2*i])

odd = sorted(odd)
even = sorted(even)
ac = Counter(odd).most_common(2)
bc = Counter(even).most_common(2)
def cnt(X):
	count = 0
	ans = 0
	for i in range(len(X)-1):
		if X[i+1] == X[i]:
			count += 1
			ans = max(ans,count)
		else:
			count = 0
	return ans+1
            
if ac[0][0] != bc[0][0]:
  print(len(v)-cnt(odd)-cnt(even))
elif len(ac) == 1 and len(bc) == 1:
	print(n//2)
else:
	print(n-max(ac[0][1]+bc[1][1],ac[1][1]+bc[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())
u = list(map(int,input().split()))

hantei = 0

for i in range(1,n):
    if u[0] != u[i]:
        hantei = 1
        break

if hantei == 0:
    print(n // 2)
else:
   u1 = [] 
   u2 = [] 
   ans = 0
   for j in range(n):
       if j % 2 == 0:
           u2.append(u[j])
       else:
   u1_list =collections.Counter(u1)
   u2_list =collections.Counter(u2)
   values1, counts1 = u1_list.most_common()[0]
   values2, counts2 = u2_list.most_common()[0]
   ans += n // 2 - counts1
   ans += n // 2 - counts2
   print(ans)

import collections

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

hantei = 0

for i in range(0,n):
    if u[0] != u[i]:
        hantei = 1
        break

if hantei == 0:
    print(n // 2)
else:
   u1 = [] 
   u2 = [] 
   ans = 0
   for j in range(n):
       if j % 2 == 0:
           u2.append(u[j])
       else:
           u1.append(u[j])
   u1_list =collections.Counter(u1)
   u2_list =collections.Counter(u2)
   values1, counts1 = u1_list.most_common()[0]
   values2, counts2 = u2_list.most_common()[0]
   if values1 != values2:
       ans += n // 2 - counts1
       ans += n // 2 - counts2
   else:
       if len(u1_list) > 1 and len(u2_list) > 1:
           values3, counts3 = u1_list.most_common()[1]
           values4, counts4 = u2_list.most_common()[1]
           ans1 = n - counts1 - counts4
           ans2 = n - counts2 - counts3
           ans = max(ans1,ans2)
       elif len(u1_list) > 1 and len(u2_list) < 2:
           values3, counts3 = u1_list.most_common()[1]
           ans = n - counts2 - counts3
       elif len(u1_list) < 2 and len(u2_list) > 1:
           values3, counts3 = u2_list.most_common()[1]
           ans = n - counts1 - counts3

       ans = min(ans1,ans2)
   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):
import collections

n=int(input())
l=list(map(int,input().split()))
#print(l)
e=[None]*(n//2)
o=[None]*(n//2)
for i in range(n//2):
    e[i]=l[2*i]
    o[i]=l[2*i+1]
print(e,o)
ce=collections.Counter(e)
co=collections.Counter(o)
ce=ce.most_common()
co=co.most_common()
#print(co)
ce.append((0,0))
co.append((0,0))
if ce[0][0]!=co[0][0]:
    print(n-co[0][1]-ce[0][1])
else:
    print(min(n-ce[1][1]-co[0][1],n-ce[0][1]-co[1][1]))

import collections

n=int(input())
l=list(map(int,input().split()))
#print(l)
e=[None]*(n//2)
o=[None]*(n//2)
for i in range(n//2):
    e[i]=l[2*i]
    o[i]=l[2*i+1]
#print(e,o)
ce=collections.Counter(e)
co=collections.Counter(o)
ce=ce.most_common()
co=co.most_common()
#print(co)
ce.append((0,0))
co.append((0,0))
if ce[0][0]!=co[0][0]:
    print(n-co[0][1]-ce[0][1])
else:
    print(min(n-ce[1][1]-co[0][1],n-ce[0][1]-co[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):
import collections
n = int(input())
v = list(map(str, input().split()))
gu_row = []
ki_row = []

for i in range(n):
    if i % 2 == 0:
        gu_row.append(v[i])
    elif i % 2 == 1:
        ki_row.append(v[i])

gu_count = collections.Counter(gu_row).most_common()
ki_count = collections.Counter(ki_row).most_common()
print(gu_count)
print(ki_count)

if len(gu_count) > 1 and len(ki_count) > 1:
    if gu_count[0][0] != ki_count[0][0]:
        ans = n - gu_count[0][1] - ki_count[0][1]
    elif gu_count[0][0] == ki_count[0][0] and len(gu_count) == 1:
        ans = n - gu_count[0][1] - ki_count[1][1]
    elif gu_count[0][0] == ki_count[0][0] and len(ki_count) == 1:
        ans = n - gu_count[1][1] - ki_count[0][1]
    else:
        ans = n - max(gu_count[0][1] + ki_count[1][1], gu_count[1][1] + ki_count[0][1])
else:
    if gu_count[0][0] != ki_count[0][0]:
        ans = n - gu_count[0][1] - ki_count[0][1]
    else:
        ans = gu_count[0][1]

print(ans)

import collections
n = int(input())
v = list(map(str, input().split()))
gu_row = []
ki_row = []

for i in range(n):
    if i % 2 == 0:
        gu_row.append(v[i])
    elif i % 2 == 1:
        ki_row.append(v[i])

gu_count = collections.Counter(gu_row).most_common()
ki_count = collections.Counter(ki_row).most_common()

if len(gu_count) > 1 and len(ki_count) > 1:
    if gu_count[0][0] != ki_count[0][0]:
        ans = n - gu_count[0][1] - ki_count[0][1]
    elif gu_count[0][0] == ki_count[0][0] and len(gu_count) == 1:
        ans = n - gu_count[0][1] - ki_count[1][1]
    elif gu_count[0][0] == ki_count[0][0] and len(ki_count) == 1:
        ans = n - gu_count[1][1] - ki_count[0][1]
    else:
        ans = n - max(gu_count[0][1] + ki_count[1][1], gu_count[1][1] + ki_count[0][1])
else:
    if gu_count[0][0] != ki_count[0][0]:
        ans = n - gu_count[0][1] - ki_count[0][1]
    else:
        ans = gu_count[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
import sys
n = int(input())
v = [int(x) for x in input().split()]
test = [x == v[0] for x in v]
if all(test):
    print(0)
    sys.exit()
odd = [int(x) for x in v[0::2]]
even = [int(x) for x in v[1::2]]
odd_count = Counter(odd)
key1 = list(odd_count)
even_count = Counter(even)
key2 = list(even_count)
num = 0
if key1[0] == key2[0]:
    num = min(odd_count[key1[0]]-odd_count[key1[1]],even_count[key2[0]]-even_count[key2[1]])
    print(n-odd_count[key1[0]]-even_count[key2[0]]+num)
else:
    print(odd_count[key1[0]],even_count[key2[0]])
    print(n-odd_count[key1[0]]-even_count[key2[0]])


from collections import Counter
import sys
n = int(input())
v = [int(x) for x in input().split()]
test = [x == v[0] for x in v]
if all(test):
    print(int(n/2))
    sys.exit()
odd = [int(x) for x in v[0::2]]
even = [int(x) for x in v[1::2]]
odd_count = Counter(odd)
key1 = list(odd_count)
even_count = Counter(even)
key2 = list(even_count)
num = 0
if key1[0] == key2[0]:
    num = min(odd_count[key1[0]]-odd_count[key1[1]],even_count[key2[0]]-even_count[key2[1]])
    print(n-odd_count[key1[0]]-even_count[key2[0]]+num)
else:
    print(odd_count[key1[0]],even_count[key2[0]])
    print(n-odd_count[key1[0]]-even_count[key2[0]])


from collections import Counter


def solve(V):
    n = len(V)
    ac = Counter(V[::2]).most_common(2)
    bc = Counter(V[1::2]).most_common(2)

    if ac[0][0] != bc[0][0]:
        return n - ac[0][1] - bc[0][1]
    else:
        if len(bc) == 1 or len(ac) == 1:
            return n // 2
        else:
            return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])


if __name__ == "__main__":
    n = int(input())
    l = input()
    print(solve(l.split(" ")))

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):
n=int(input())
count=0
v=[]
v=[int(i) for i in input().split()]
for i in range(n-2):
    if v[i]==v[i+2]:
        pass
    else:
        count+=1
num=v[0]
for i in range(n):
    v.remove(num)
print(v)
if len(v)==0:
    if n%2==0:
        count=int(n/2)
    else:
        count=int((n-1)/2)
print(count)


import itertools
from collections import Counter


n = int(input())
v = list(map(int, input().split()))
ev_cnt = Counter(v[::2])
od_cnt = Counter(v[1::2])
ev_cnt[-1] = 0
od_cnt[-2] = 0
ev = ev_cnt.most_common(2)
od = od_cnt.most_common(2)
ans = n
for (k1, v1), (k2, v2) in itertools.product(ev, od):
    if k1 == k2:
        continue
    x = (n - v1 - v2)
    ans = min(ans, x)
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 -*-
from collections import Counter
from operator import itemgetter
def solve():
    input()
    V = list(map(int, input().split()))
    l = sorted(Counter(V[::2]).items()+[(0,0)], key=itemgetter(1), reverse=True)
    u = sorted(Counter(V[1::2]).items()+[(0,0)], key=itemgetter(1), reverse=True)
    res = sum(map(itemgetter(1), l+u)) - (max(l[0][1]+u[1][1], l[1][1]+u[0][1]) if l[0][0]==u[0][0] else (l[0][1]+u[0][1]))
    return str(res)

if __name__ == '__main__':
    print(solve())



# -*- coding: utf-8 -*-
from collections import Counter
from operator import itemgetter
def solve():
    input()
    V = list(map(int, input().split()))
    l = sorted(list(Counter(V[::2]).items())+[(0,0)], key=itemgetter(1), reverse=True)
    u = sorted(list(Counter(V[1::2]).items())+[(0,0)], key=itemgetter(1), reverse=True)
    res = sum(map(itemgetter(1), l+u)) - (max(l[0][1]+u[1][1], l[1][1]+u[0][1]) if l[0][0]==u[0][0] else (l[0][1]+u[0][1]))
    return str(res)

if __name__ == '__main__':
    print(solve())



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()))
c1=collections.Counter(v[::2])
c2=collections.Counter(v[1::2])
c1_v1=c1.most_common()[0][0]
c2_v1=c2.most_common()[0][0]
c1_n1=c1.most_common()[0][1]
c2_n1=c2.most_common()[0][1]
c1_n2=c1.most_common(2)[1][1]
c2_n2=c2.most_common(2)[1][1]

if c1_v1!=c2_v1:
    print(n-c1_n1-c2_n1)
else:
    if c1_n1==n//2:
        if c2_n1==n//2:
            print(n//2)
        else:
            print(n-c1_n1-c2_n2)
    else:
        if c2_n1==n//2:
            print(n-c1_n2-c2_n1)
        else:
            print(n-c1_n2-c2_n2)

import collections
n=int(input())
v=list(map(int,input().split()))
c1=collections.Counter(v[::2])
c2=collections.Counter(v[1::2])
c1_v1=c1.most_common()[0][0]
c2_v1=c2.most_common()[0][0]
c1_n1=c1.most_common()[0][1]
c2_n1=c2.most_common()[0][1]

if c1_v1!=c2_v1:
    print(n-c1_n1-c2_n1)
else:
    if c1_n1==n//2:
        if c2_n1==n//2:
            print(n//2)
        else:
            c2_n2=c2.most_common(2)[1][1]
            print(n-c1_n1-c2_n2)
    else:
        c1_n2=c1.most_common(2)[1][1]
        if c2_n1==n//2:
            print(n-c1_n2-c2_n1)
        else:
            c2_n2=c2.most_common(2)[1][1]
            print(min(n-c1_n2-c2_n1,n-c1_n1-c2_n2))


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

if len(set(v)) == 1:
  print(n//2)
else:
  v1 = v[::2]
  v2 = v[1::2]
  
  cl1 = collections.Counter(v1)
  cl2 = collections.Counter(v2)
  
  cmc_1st_1 = cl1.most_common()[0][1]
  cmc_1st_2 = cl2.most_common()[0][1]
  cmc_2nd_1 = cl1.most_common()[1][1]
  cmc_2nd_2 = cl2.most_common()[1][1] 
  
  if cmc_1st_1 == cmc_1st_2:
    if cmc_2nd_1 > cmc_2nd_2:
      ans = len(v1) - cmc_2nd_1
      ans += len(v2) - cmc_1st_2
    else:
      ans = len(v1) - cmc_1st_1
      ans += len(v2) - cmc_2nd_2
  else:
    ans = len(v1) - cmc_1st_1
    ans += len(v2) - cmc_1st_2
  
  print(ans)

import collections

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

if len(set(v)) == 1:
  print(n//2)
else:
  v1 = v[::2]
  v2 = v[1::2]
  
  cmc1 = collections.Counter(v1).most_common()
  cmc2 = collections.Counter(v2).most_common()
  
  print(cmc1[:5])
  print(cmc2[:5])
  
  if cmc1[0][0] == cmc2[0][0]:    
    ans1 = (len(v1) - cmc1[0][1]) + (len(v2) - cmc2[1][1])
    ans2 = (len(v1) - cmc1[1][1]) + (len(v2) - cmc2[0][1])
    print(min(ans1, ans2))
  else:
    ans = (len(v1) - cmc1[0][1]) + (len(v2) - cmc2[0][1])
    print(ans)

import collections

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

if len(set(v)) == 1:
  print(n//2)
else:
  v1 = v[::2]
  v2 = v[1::2]
  
  cmc1 = collections.Counter(v1).most_common()
  cmc2 = collections.Counter(v2).most_common()
  
  if cmc1[0][0] == cmc2[0][0]:    
    ans1 = (len(v1) - cmc1[0][1]) + (len(v2) - cmc2[1][1])
    ans2 = (len(v1) - cmc1[1][1]) + (len(v2) - cmc2[0][1])
    print(min(ans1, ans2))
  else:
    ans = (len(v1) - cmc1[0][1]) + (len(v2) - cmc2[0][1])
    print(ans)

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

N = int(input())

if str(N)[0]*len(str(N)) == str(N):
  print(N//2)
  exit()

Veve, Vodd = [],[]
idx = 0
for v in map(int,input().split()):
  if idx%2 == 0: Veve.append(v)
  else: Vodd.append(v)
  idx += 1

Veve_cnt, Vodd_cnt = [], []
[heapq.heappush(Veve_cnt, [-num,val]) for val, num in Counter(Veve).items()]
[heapq.heappush(Vodd_cnt, [-num,val]) for val, num in Counter(Vodd).items()]

eve_val, odd_val = None, None
while eve_val == odd_val:
  if eve_val is None:
    neg_num, val = heapq.heappop(Veve_cnt)
    eve_val = val
    eve_num = -neg_num
  if odd_val is None:
    neg_num, val = heapq.heappop(Vodd_cnt)
    odd_val = val
    odd_num = -neg_num
print(N-eve_num-odd_num)

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

even_idx_cnt = {}
odd_idx_cnt = {}
for idx, v in enumerate(V):
    if idx % 2 == 0:
        if v not in even_idx_cnt:
            even_idx_cnt[v] = 0
        even_idx_cnt[v] += 1
    else:
        if v not in odd_idx_cnt:
            odd_idx_cnt[v] = 0
        odd_idx_cnt[v] += 1

if len(even_idx_cnt) == 1 and len(odd_idx_cnt) == 1:
    if even_idx_cnt.keys() == odd_idx_cnt.keys():
        print(N - even_idx_cnt[V[0]])
    else:
        print(0)
    exit()

even_idx_cnt = sorted(even_idx_cnt.items(), key=lambda  x:x[1], reverse=True)
odd_idx_cnt = sorted(odd_idx_cnt.items(), key=lambda  x:x[1], reverse=True)

if even_idx_cnt[0][0] != odd_idx_cnt[0][0]:
    print(N - even_idx_cnt[0][1] - odd_idx_cnt[0][1])
elif len(even_idx_cnt) == 1:
    print(N - even_idx_cnt[0][1] - odd_idx_cnt[1][1])
elif len(odd_idx_cnt) == 1:
    print(N - even_idx_cnt[1][1] - odd_idx_cnt[0][1])
else:
    if even_idx_cnt[1][1] > odd_idx_cnt[1][1]:
        print(N - even_idx_cnt[1][1] - odd_idx_cnt[0][1])
    else:
        print(N - even_idx_cnt[0][1] - odd_idx_cnt[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 collections import Counter
n = int(input())
v = list(map(int,input().split()))
even = Counter(v[::2]).most_common(2)
odd = Counter(n[1::2]).most_common(2)
if even[0][0] != odd[0][0]:
    ans =  n - even[0][1] - odd[0][1]
else:
    if len(even) == 1:
        ans = n//2
    else:
        ans =  n - max(even[0][1] + odd[1][1],even[1][1],odd[0][1])
print(ans)


from collections import Counter
n = int(input())
v = list(map(int,input().split()))
even = Counter(v[::2]).most_common(2)
odd = Counter(n[1::2]).most_common(2)
if even[0][0] != odd[0][0]:
    ans =  n - even[0][1] - odd[0][1]
else:
    if len(even) == 1:
        ans = n//2:
    else:
        ans =  n - max(even[0][1] + odd[1][1],even[1][1],odd[0][1])
print(ans)

from collections import Counter
n = int(input())
v = list(map(int,input().split()))
even = Counter(v[::2]).most_common(2)
odd = Counter(v[1::2]).most_common(2)

if even[0][0] != odd[0][0]:
    ans =  n - even[0][1] - odd[0][1]
else:
    if len(even) == 1 or len(odd)==1:
        ans = n//2
    else:
        ans =  n - max(even[0][1] + odd[1][1],even[1][1]+odd[0][1])
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):
n = int(input())
v = [int(i) for i in input().split()] 

from statistics import mode
if len(set(v))  == 1:
    print(int(len(v) / 2))
else:
    print(len(v[0::2]) - collections.Counter(v[0::2]).most_common()[0][1] + len(v[1::2]) - collections.Counter(v[1::2]).most_common()[0][1])

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

from statistics import mode
if len(set(v))  == 1:
    print(int(len(v) / 2))
else:
    print(len(v[0::2]) - collections.Counter(v[0::2]).most_common()[0][1] + len(v[1::2]) - collections.Counter(v[1::2]).most_common()[0][1])

n = int(input())
v = [int(i) for i in input().split()] 
import collections
if len(set(v))  == 1:
    print(int(len(v) / 2))
else:
    a = collections.Counter(v[0::2]).most_common()
    b = collections.Counter(v[1::2]).most_common() 
    if a[0][0] == b[0][0]:
        print(min((len(v[0::2]) - a[1][1] + len(v[1::2]) - b[0][1]),(len(v[0::2]) - a[0][1] + len(v[1::2]) - b[1][1])))
    else:
        print(len(v[0::2]) - a[0][1] + len(v[1::2]) - b[0][1])

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):
n = int(input())
V = list(map(int, input().split()))

even = []
odd = []
for nn in range(n):
    if nn % 2 == 0:
        even.append(V[nn])
    else:
        odd.append(V[nn])

e = collections.Counter(even).most_common()
o = collections.Counter(odd).most_common()

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(n // 2)
    elif len(e) == 1 and len(o) >= 2:
        print(n - o[0][1])
    elif len(e) >= 2 and len(o) == 1:
        print(n - e[0][1])
    else:
        print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))

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

even = [0] * (n//2)
odd = [0] * (n//2)
for nn in range(n):
    if nn % 2 == 0:
        even.append(V[nn])
    else:
        odd.append(V[nn])

e = collections.Counter(even).most_common()
o = collections.Counter(odd).most_common()

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(n // 2)
    elif len(e) == 1 and len(o) >= 2:
        print(n - o[0][1])
    elif len(e) >= 2 and len(o) == 1:
        print(n - e[0][1])
    else:
        print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))




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

even = [0] * 100001
odd = [0] * 100001
for nn in range(n):
    if nn % 2 == 0:
        even.append(V[nn])
    else:
        odd.append(V[nn])

e = collections.Counter(even).most_common()
o = collections.Counter(odd).most_common()

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(n // 2)
    elif len(e) == 1 and len(o) >= 2:
        print(n - o[0][1])
    elif len(e) >= 2 and len(o) == 1:
        print(n - e[0][1])
    else:
        print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))




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

even = []
odd = []
for nn in range(n):
    if nn % 2 == 0:
        even.append(V[nn])
    else:
        odd.append(V[nn])

e = collections.Counter(even).most_common()
o = collections.Counter(odd).most_common()

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(n // 2)
    elif len(e) == 1 and len(o) >= 2:
        print(n - o[0][1])
    elif len(e) >= 2 and len(o) == 1:
        print(n - e[0][1])
    else:
        print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))




Verdicts: Runtime Error

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 = int(input())
V = [i for i in input().split()]
 
odd = Counter(V[::2]).most_common(2)
even = Counter(V[1::2]).most_common(2)

print(odd)
 
if odd[0][0] != even[0][0]:
    print(N - odd[0][1] - even[0][1])
elif len(odd) == 1:
    print(N // 2)
else:
    o0e1 = N - odd[0][1] - even[1][1]
    o1e0 = N - odd[1][1] - even[0][1]
    print(min(o0e1, o1e0))

from collections import Counter
 
N = int(input())
V = [i for i in input().split()]
 
odd = Counter(V[::2]).most_common(2)
even = Counter(V[1::2]).most_common(2)

if odd[0][0] != even[0][0]:
    print(N - odd[0][1] - even[0][1])
elif len(odd) == 1:
    print(N // 2)
else:
    o0e1 = N - odd[0][1] - even[1][1]
    o1e0 = N - odd[1][1] - even[0][1]
    print(min(o0e1, o1e0))

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
import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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

nn = n // 2
for i in range(nn):
    a[v[i * 2]] += 1
    b[v[i * 2 + 1]] += 1

ma1 = max(a, key=a.get)
mb1 = max(b, key=b.get)
a[ma1] = 0
b[mb1] = 0
ma2 = max(a, key=a.get)
mb2 = max(b, key=b.get)
a[ma2] = 0
b[mb2] = 0

ma = [ma1, ma2]
mb = [mb1, mb2]
mx = 0xFFFFFFFF
for i in ma:
    for j in mb:
        mx = min(sum(a.values()) + i + sum(b.values()) + j, mx)
        
print(mx)

# coding: UTF-8
import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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

nn = n // 2
for i in range(nn):
    a[v[i * 2]] += 1
    b[v[i * 2 + 1]] += 1

ma1 = max(a, key=a.get)
mb1 = max(b, key=b.get)
mva1 = a[ma1]
mvb1 = b[mb1]
a[ma1] = 0
b[mb1] = 0
ma2 = max(a, key=a.get)
mb2 = max(b, key=b.get)
mva2 = a[ma2]
mvb2 = b[mb2]
a[ma2] = 0
b[mb2] = 0

ma = [(ma1, mva1), (ma2, mva2)]
mb = [(mb1, mvb1), (mb2, mvb2)]
mx = 0xFFFFFFFF
for i in ma:
    for j in mb:
        if i[0] == j[0]:
            pass
        else:
            mx = min(sum(a.values()) + i[1] + sum(b.values()) + j[1], mx)
if mx == 0xFFFFFFFF:
    print(0)
else:
    print(mx

# coding: UTF-8
import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = int(input())
a = list(map(int, input().split()))
even = defaultdict(int)
odd = defaultdict(int)
for i in range(n):
    if i % 2 == 0:
        even[a[i]] += 1
    else:
        odd[a[i]] += 1
x = sorted(even.items(), reverse=True, key=lambda t:t[1])
y = sorted(odd.items(), reverse=True, key=lambda t:t[1])
even_index = 0
odd_index = 0
if x[0][0] == y[0][0]:
    if x[0][1] > y[0][1]:
        even_index = 0
        odd_index = 1
    elif x[0][1] < y[0][1]:
        odd_index = 0
        even_index = 1
    else:
        if len(x) > 1:
            print(n - x[0][1] - max(x[1][1], y[1][1]))
        else:
            print(n // 2)
        exit()
            
else:
    even_index = 0
    odd_index = 0
print(n - x[even_index][1] - y[odd_index][1])


Verdicts: 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):
n = int(input())
v = list(map(int, input().split()))
v1 = []
v2 = []
for i in range(n):
	if i%2 == 0:
		v1.append(v[i])
	else:
		v2.append(v[i])
v1.sort()
v2.sort()

cnt1 = []
cnt2 = []
now = v1[0]
con = 1
for i in range(1, len(v1)):
	if now == v1[i]:
		con += 1
	else:
		now = v1[i]
		cnt1.append(con)
		con = 1
cnt1.append(con)
now = v2[0]
con = 1
for i in range(1, len(v2)):
	if now == v2[i]:
		con += 1
	else:
		now = v2[i]
		cnt2.append(con)
		con = 1
cnt2.append(con)
if cnt1.index(max(cnt1)) != cnt2.index(max(cnt2)):
	cnt1.sort()
	cnt2.sort()
	print(sum(cnt1[:len(cnt1)-1])+sum(cnt2[:len(cnt2)-1]))
else:
	cnt1.sort()
	cnt2.sort()
	ans = max(sum(cnt1[:len(cnt1)-2])+cnt1[len(cnt1)-1]+sum(cnt2[:len(cnt2)-1]), sum(cnt1[:len(cnt1)-1])+cnt2[len(cnt2)-1]+sum(cnt2[:len(cnt2)-2]))
	print(ans)

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

cnt1 = []
cnt2 = []
now = v1[0]
con = 1
for i in range(1, len(v1)):
	if now == v1[i]:
		con += 1
	else:
		cnt1.append([con, now])
		now = v1[i]
		con = 1
cnt1.append([con, now])
now = v2[0]
con = 1
for i in range(1, len(v2)):
	if now == v2[i]:
		con += 1
	else:
		cnt2.append([con, now])
		now = v2[i]
		con = 1
cnt2.append([con, now])

cnt1.sort()
cnt2.sort()
if cnt1[len(cnt1)-1][1] != cnt2[len(cnt2)-1][1]:
	p1 = [cnt1[i][0] for i in range(len(cnt1))]
	p2 = [cnt2[i][0] for i in range(len(cnt2))]
	print(sum(p1[:len(p1)-1])+sum(p2[:len(p2)-1]))
else:
	p1 = [cnt1[i][0] for i in range(len(cnt1))]
	p2 = [cnt2[i][0] for i in range(len(cnt2))]
	ans = min(sum(p1[:len(p1)-2])+p1[len(p1)-1]+sum(p2[:len(p2)-1]), sum(p1[:len(p1)-1])+p2[len(p2)-1]+sum(p2[:len(p2)-2]))
	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):
import collections
N=list(map(int,input().split(" ")))
list_odd=N[::2]
list_even=N[1::2]
c_odd = collections.Counter(list_odd)
c_even = collections.Counter(list_even)
most_odd=c_odd.most_common()[0][1]
most_even=c_even.most_common()[0][1]
print(len(list_even)+len(list_odd)-most_even-most_odd)

import collections

N=list(map(int,input().split(" ")))
list_odd=N[::2]
list_even=N[1::2]
c_odd = collections.Counter(list_odd)
c_even = collections.Counter(list_even)
most_odd=c_odd.most_common()[0][1]
most_even=c_even.most_common()[0][1]
print(len(list_even)+len(list_odd)-most_even-most_odd)


import collections
n=int(input())
N=list(map(int,input().split(" ")))
list_odd=N[::2]
list_even=N[1::2]
c_odd = collections.Counter(list_odd)
c_even = collections.Counter(list_even)
most_odd=c_odd.most_common()[0][1]
most_even=c_even.most_common()[0][1]
if (n<=2):
    print("0")
elif (len(list_even)==most_even and len(list_odd)==most_odd and c_odd.most_common()[0][0]==c_even.most_common()[0][0]):
    print(most_odd)
else:
    if(c_odd.most_common()[0][0]==c_even.most_common()[0][0]):
        M=max(c_odd.most_common()[1][1],c_even.most_common()[1][1])
        print(min((len(list_even)+len(list_odd)-M-most_odd),(len(list_even)+len(list_odd)-M-most_even)))
    else:
        print(len(list_even)+len(list_odd)-most_even-most_odd)


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 = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
eve = V[0::2]
odd = V[1::2]
cntEve = collections.Counter(eve)
cntOdd = collections.Counter(odd)

if cntEve.most_common()[0][0] == cntOdd.most_common()[0][0]:
    ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - max(cntEve.most_common()[1][1],cntOdd.most_common()[1][1])
else:
    ans = N - cntEve.most_common()[0][1] - cntOdd.most_common()[0][1]

print(ans)

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

ans = 0
eve = V[0::2]
odd = V[1::2]
cntEve = collections.Counter(eve)
cntOdd = collections.Counter(odd)

if cntEve.most_common()[0][0] == cntOdd.most_common()[0][0]:
    if len(cntEve) == 1 and len(cntOdd) > 1:
        ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - cntOdd.most_common()[1][1]
    elif len(cntEve) > 1 and len(cntOdd) == 1:
        ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - cntEve.most_common()[1][1]
    elif len(cntEve) == 1 and len(cntOdd) == 1:
        ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1])
    else:
        ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - max(cntEve.most_common()[1][1],cntOdd.most_common()[1][1])
else:
    ans = N - int(cntEve.most_common()[0][1]) - int(cntOdd.most_common()[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())
alist  = list(map(int,input().split()))
list1 = alist[1::2]
list2 = alist[0::2]
from collections import Counter
dic1 = Counter(list1).most_common()
dic2 = Counter(list2).most_common()

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

n = int(input())
alist  = list(map(int,input().split()))
list1 = alist[1::2]
list2 = alist[0::2]
from collections import Counter
dic1 = Counter(list1).most_common()
dic2 = Counter(list2).most_common()
dic1.append([0,0])
dic2.append([0,0])
if dic1[0][0]!=dic2[0][0]:
  print(n - dic1[0][1] - dic2[0][1])
else:
  print(min(n - dic1[0][1] - dic2[1][1], n -dic1[1][1] - dic2[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):
#coding:utf-8
import numpy as np
import collections
N = 1000000
ls = list(map(int,input().split()))
ls.append(N)
ls.append(N)
array = np.array(ls).reshape(-1,2).T
c_even = collections.Counter(array[0])
c_odd = collections.Counter(array[1])
if len(set(ls))==2:
    print (int((len(ls)-2)/2))
elif c_even.most_common()[0][0] != c_odd.most_common()[0][0]:
    print (len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[0][1]-2)
else:
    print (min(len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[1][1]-2,len(ls)-c_even.most_common()[1][1]-c_odd.most_common()[0][1]-2))


#coding:utf-8
import numpy as np
import collections
N = 1000000
_ = int(input())
ls = list(map(int,input().split()))
ls.append(N)
ls.append(N)
array = np.array(ls).reshape(-1,2).T
c_even = collections.Counter(array[0])
c_odd = collections.Counter(array[1])
if len(set(ls))==2:
    print (int((len(ls)-2)/2))
elif c_even.most_common()[0][0] != c_odd.most_common()[0][0]:
    print (len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[0][1]-2)
else:
    print (min(len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[1][1]-2,len(ls)-c_even.most_common()[1][1]-c_odd.most_common()[0][1]-2))


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

even = [v[2*i] for i in range(N//2)]
odd = [v[2*i+1] for i in range(N//2)]

from collections import Counter
dev = Counter(even)
dod = Counter(odd)

evmax = sorted(dev, key=dev.get, reverse = True)[0]
if len(dev) != 1 :
    ev2nd = sorted(dev, key=dev.get, reverse = True)[1]
odmax = sorted(dod, key=dod.get, reverse = True)[0]
if len(dod) != 1 :
    od2nd = sorted(dod, key=dod.get, reverse = True)[1]

if evmax != odmax :
    print(N//2 - max(dev[evmax],dod[odmax]))
elif len(dev) == 1 and len(dod) == 1 :
    print(N//2)
elif len(dev) == 1 :
    print(N//2 - max(dev[evmax],dod[od2nd]))
elif len(dod) == 1 :
    print(N//2 - max(dev[ev2nd],dod[odmax]))
else :
    print(min(N//2 - max(dev[evmax],dod[od2nd]), N//2 - max(dev[ev2nd],dod[odmax])))


N = int(input())
v = [int(x) for x in input().split()]

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

from collections import Counter
dev = Counter(even).most_common(2)
dod = Counter(odd).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: Wrong Answer

Accepted