Problem: A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:    * For each i = 1,2,..., n-2, a_i = a_{i+2}.   * Exactly two different numbers appear in the sequence.  You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.

Submission attempts (in order):
a = input()
dict1 = dict()
dict2 = dict()
counter = 0
b = input()
for i in b:
	if counter % 2 == 0:
		if i not in dict1:
			dict1[i] = 1
		else:
			dict1[i] += 1
	elif counter % 2 == 1:
		if i not in dict2:
			dict2[i] = 1
		else:
			dict2[i] += 1
			
	counter += 1

dict1list = []
for i in dict1.keys():
	dict1list.append([i, dict1[i]])

dict2list = []
for i in dict2.keys():
	dict2list.append([i, dict2[i]])

dict1list.sort(key = lambda x: x[1])
dict2list.sort(key = lambda x: x[1])
print(dict1list,dict2list)
if dict1list[-1][0] == dict2list[-1][0] and len(dict2list) > 1 and dict1list[-1][1]  > dict2list[-1][1]:
	print(len(b) - dict1list[-1][1] - dict2list[-2][1])
elif dict1list[-1][0] == dict2list[-1][0] and len(dict2list) == 1 and dict1list[-1][1]  > dict2list[-1][1]:
	print(len(b) - dict1list[-1][1])
elif dict1list[-1][0] == dict2list[-1][0] and len(dict1list) > 1 and dict1list[-1][1]  < dict2list[-1][1]:
	print(len(b) - dict1list[-2][1] - dict2list[-1][1])
elif dict1list[-1][0] == dict2list[-1][0] and len(dict1list) == 1 and dict1list[-1][1]  < dict2list[-1][1]:
	print(len(b) - dict2list[-1][1])
elif dict1list[-1][0] == dict2list[-1][0] and dict1list[-1][1]  == dict2list[-1][1]:
	if len(dict1list) == 1 and len(dict2list) == 1:
		print(len(b) - dict2list[-1][1])
	elif len(dict1list) == 1 and len(dict2list) > 1:
		print(len(b) - dict2list[-2][1] - dict1list[-1][1])
	elif len(dict1list) > 1 and len(dict2list) == 1:
		print(len(b) - dict2list[-1][1] - dict1list[-2][1])
	else:
		if (dict2list[-2][-1] >= dict1list[-2][-1]):
			print(len(b) - dict2list[-2][1] - dict1list[-1][1])
		elif (dict2list[-2][-1] < dict1list[-2][-1]):
			print(len(b) - dict2list[-1][1] - dict1list[-2][1])
else:
	print(len(b) - dict1list[-1][1] - dict2list[-1][1])


a = input()
dict1 = dict()
dict2 = dict()
counter = 0
b = input().split()
for i in b:
	if counter % 2 == 0:
		if i not in dict1:
			dict1[i] = 1
		else:
			dict1[i] += 1
	elif counter % 2 == 1:
		if i not in dict2:
			dict2[i] = 1
		else:
			dict2[i] += 1
			
	counter += 1

dict1list = []
for i in dict1.keys():
	dict1list.append([i, dict1[i]])

dict2list = []
for i in dict2.keys():
	dict2list.append([i, dict2[i]])

dict1list.sort(key = lambda x: x[1])
dict2list.sort(key = lambda x: x[1])
if dict1list[-1][0] == dict2list[-1][0] and len(dict2list) > 1 and dict1list[-1][1]  > dict2list[-1][1]:
	print(len(b) - dict1list[-1][1] - dict2list[-2][1])
elif dict1list[-1][0] == dict2list[-1][0] and len(dict2list) == 1 and dict1list[-1][1]  > dict2list[-1][1]:
	print(len(b) - dict1list[-1][1])
elif dict1list[-1][0] == dict2list[-1][0] and len(dict1list) > 1 and dict1list[-1][1]  < dict2list[-1][1]:
	print(len(b) - dict1list[-2][1] - dict2list[-1][1])
elif dict1list[-1][0] == dict2list[-1][0] and len(dict1list) == 1 and dict1list[-1][1]  < dict2list[-1][1]:
	print(len(b) - dict2list[-1][1])
elif dict1list[-1][0] == dict2list[-1][0] and dict1list[-1][1]  == dict2list[-1][1]:
	if len(dict1list) == 1 and len(dict2list) == 1:
		print(len(b) - dict2list[-1][1])
	elif len(dict1list) == 1 and len(dict2list) > 1:
		print(len(b) - dict2list[-2][1] - dict1list[-1][1])
	elif len(dict1list) > 1 and len(dict2list) == 1:
		print(len(b) - dict2list[-1][1] - dict1list[-2][1])
	else:
		if (dict2list[-2][-1] >= dict1list[-2][-1]):
			print(len(b) - dict2list[-2][1] - dict1list[-1][1])
		elif (dict2list[-2][-1] < dict1list[-2][-1]):
			print(len(b) - dict2list[-1][1] - dict1list[-2][1])
else:
	print(len(b) - dict1list[-1][1] - dict2list[-1][1])


Verdicts: Wrong Answer

Accepted