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())
list=list(map(int,input().split()))
#print(list)
list_1=list[::2]
list_2=list[1::2]
if (list_1[0]==list_2[0] & all(list_1) & all(list_2)):
  print(n//2)
  #print(list_1)
  #print(list_2)
  a=collections.Counter(list_1)
  b=collections.Counter(list_2)
elif(a==b):
  print(n//2)
else
  #print(a)
  #print(b)
  #print(a.most_common())
  #print(b.most_common())
  #print(a.most_common()[0][1])
  #print(b.most_common()[0][1])
  print(n-a.most_common()[0][1]-b.most_common()[0][1])

import collections
n=int(input())
list=list(map(int,input().split()))
list_1=list[::2]
list_2=list[1::2]
a=collections.Counter(list_1)
b=collections.Counter(list_2)
print(a.most_common()[0]==b.most_common()[0])
print(len(list_1),a.most_common()[0][1])
if((a.most_common()[0]==b.most_common()[0]) & (a.most_common()[0][1]!=len(list_1))):
  if(n-a.most_common()[0][1]-b.most_common()[1][1]>n-a.most_common()[1][1]-b.most_common()[0][1]):
  	print(n-a.most_common()[1][1]-b.most_common()[0][1])
  else:
    print(n-a.most_common()[0][1]-b.most_common()[1][1])
elif ((a.most_common()==b.most_common()) & (a.most_common()[0][1]==len(list_1))):
  print(n//2)
else:

  print(n-a.most_common()[0][1]-b.most_common()[0][1])

import collections
n=int(input())
list=list(map(int,input().split()))
#print(list)
list_1=list[::2]
list_2=list[1::2]
print(list_1)
#print(list_2)
a=collections.Counter(list_1)
b=collections.Counter(list_2)
#print(a)
#print(b)
#print(a.most_common())
#print(b.most_common())
#print(a.most_common()[0][1])
#print(b.most_common()[0][1])
print(n-a.most_common()[0][1]-b.most_common()[0][1])

import collections
n=int(input())
list=list(map(int,input().split()))
#print(list)
list_1=list[::2]
list_2=list[1::2]
if (list_1==list_2):
  print(n//2)
  break
#print(list_1)
#print(list_2)
a=collections.Counter(list_1)
b=collections.Counter(list_2)
#print(a)
#print(b)
#print(a.most_common())
#print(b.most_common())
#print(a.most_common()[0][1])
#print(b.most_common()[0][1])

print(n-a.most_common()[0][1]-b.most_common()[0][1])

import collections
n=int(input())
list=list(map(int,input().split()))
#print(list)
list_1=list[::2]
list_2=list[1::2]
#print(list_1)
#print(list_2)
a=collections.Counter(list_1)
b=collections.Counter(list_2)
#print(a)
#print(b)
#print(a.most_common())
#print(b.most_common())
if (list_1[0]==list_2[0] & all(list_1) & all(list_2)):
  print(n//2)
elif (a.most_common==b.most>common):
  print(n//2)
else:
  #print(a.most_common()[0][1])
  #print(b.most_common()[0][1])
  print(n-a.most_common()[0][1]-b.most_common()[0][1])

import collections
n=int(input())
list=list(map(int,input().split()))
#print(list)
list_1=list[::2]
list_2=list[1::2]
#print(list_1)
#print(list_2)
a=collections.Counter(list_1)
b=collections.Counter(list_2)
print(a.most_common()[0]==b.most_common()[0])
print(len(list_1),a.most_common()[0][1])
if ((a.most_common()==b.most_common()) & a.most_common()[0][1]==len(list_1)):
  print('test1')
  print(n//2)
elif(a.most_common()[0]==b.most_common()[0]):
  print('test2')
  print(n-a.most_common()[0][1]-b.most_common()[1][1])
else:
  print(n-a.most_common()[0][1]-b.most_common()[0][1])

import collections
n=int(input())
list=list(map(int,input().split()))
#print(list)
list_1=list[::2]
list_2=list[1::2]
#print(list_1)
#print(list_2)
a=collections.Counter(list_1)
b=collections.Counter(list_2)
#print(a.most_common()[0]==b.most_common()[0])
#print(len(list_1),a.most_common()[0][1])
if((a.most_common()[0]==b.most_common()[0]) & (a.most_common()[0][1]!=len(list_1))):
  #print('test2')
  if(n-a.most_common()[0][1]-b.most_common()[1][1]>n-a.most_common()[1][1]-b.most_common()[0][1]):
  	print(n-a.most_common()[1][1]-b.most_common()[0][1])
  else:
    print(n-a.most_common()[0][1]-b.most_common()[1][1])
elif ((a.most_common()==b.most_common()) & (a.most_common()[0][1]==len(list_1))):
  #print('test1')
  print(n//2)
else:
  #print(a)
  #print(b)
  #print(a.most_common())
  #print(b.most_common())
  #print(a.most_common()[0][1])
  #print(b.most_common()[0][1])

  print(n-a.most_common()[0][1]-b.most_common()[0][1])

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted