Problem:


Score : 300 points

Problem Statement

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.

Constraints

2 \leq n \leq 10^5

n is even.

1 \leq v_i \leq 10^5

v_i is an integer.

Input

Input is given from Standard Input in the following format:

n
v_1 v_2 ... v_n

Output

Print the minimum number of elements that needs to be replaced.

Sample Input 1

4
3 1 3 2

Sample Output 1

1

The sequence 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.

Sample Input 2

6
105 119 105 119 105 119

Sample Output 2

0

The sequence 105,119,105,119,105,119 is /\/\/\/.

Sample Input 3

4
1 1 1 1

Sample Output 3

2

The elements of the sequence 1,1,1,1 are all the same, so it is not /\/\/\/.



Sample input:
4
3 1 3 2


Sample output:
1

Submission status: Wrong Answer

Solution code:
import sys

def solve(N, ls_v):
    # Uncomment the following if you want to check the input.
    #print('N =', N)
    #print('ls_v =', ls_v)
    inc=[]
    incc={}
    count=0
    for i in ls_v:
        if i not in incc:
            incc[i] = 1
        else:
            incc[i] += 1
    cl =[i for i in incc.values()]
    cls =[i for i in incc.keys()]
    a = max(cl)
    a = cl.index(a)
    a = cls[a]
    counter = 0
    couneter2 = 0
    counter3 = 0
    ckk = ""
    ck = ""
    for key,value in incc.items():
        if key != a and counter < value:
            counter,ck = value , key
        elif key == a:
            ckk,counter2 = key,value
        else:
            counter3 += 1
    #print(ck,ckk)
    if counter2 == N:
        return N//2
    elif (ls_v[0] != ck and ls_v[1] != ckk):
        z = 10
        k = 0
        for line in ls_v:
            if z%2 == 0 and line != ckk:
                k += 1
            elif z%2 != 0 and line != ck:
                k += 1
            z += 1
        return k
    elif ls_v[0] != ckk and ls_v[1] != ck:
        z = 10
        k = 0
        for line in ls_v:
            if z%2 == 0 and line != ck:
                k += 1
            elif z%2 != 0 and line != ckk:
                k += 1
            z += 1
        return k
    elif counter + counter2 != N:
        return counter3,"counter3"
    else:
        return 0

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    ls_v = list(map(int, ws))
    return (N, ls_v)

def main():
    print(solve(*readQuestion()))

main()

Submission status: Wrong Answer

Solution code:
import sys

def solve(N, ls_v):
    # Uncomment the following if you want to check the input.
    #print('N =', N)
    #print('ls_v =', ls_v)
    inc=[]
    incc={}
    count=0
    for i in ls_v:
        if i not in incc:
            incc[i] = 1
        else:
            incc[i] += 1
    cl =[i for i in incc.values()]
    cls =[i for i in incc.keys()]
    a = max(cl)
    a = cl.index(a)
    a = cls[a]
    counter = 0
    couneter2 = 0
    counter3 = 0
    ckk = ""
    ck = ""
    for key,value in incc.items():
        if key != a and counter < value:
            counter,ck = value , key
        elif key == a:
            ckk,counter2 = key,value
        else:
            counter3 += 1
    #print(ck,ckk)
    if counter2 == N:
        return N//2
    elif (ls_v[0] != ck and ls_v[0] != ckk):
        z = 10
        k = 0
        for line in ls_v:
            if z%2 == 0 and line != ckk:
                k += 1
            elif z%2 != 0 and line != ck:
                k += 1
            z += 1
        return k
    elif (ls_v[0] != ckk and ls_v[1] != ck) and counter + counter2 == N:
        for line in ls_v:
            if z%2 == 0 and line != ck:
                k += 1
            elif z%2 != 0 and line != ckk:
                k += 1
            z += 1
        return k
    elif counter + counter2 != N:
        return counter3
    else:
        return 0

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    ls_v = list(map(int, ws))
    return (N, ls_v)

def main():
    print(solve(*readQuestion()))

main()

Submission status: Wrong Answer

Solution code:
import sys

def solve(N, ls_v):
    # Uncomment the following if you want to check the input.
    #print('N =', N)
    #print('ls_v =', ls_v)
    inc=[]
    incc={}
    count=0
    for i in ls_v:
        if i not in incc:
            incc[i] = 1
        else:
            incc[i] += 1
    cl =[i for i in incc.values()]
    cls =[i for i in incc.keys()]
    a = max(cl)
    a = cl.index(a)
    a = cls[a]
    counter = 0
    couneter2 = 0
    counter3 = 0
    ckk = ""
    ck = ""
    for key,value in incc.items():
        if key != a and counter < value:
            counter,ck = value , key
        elif key == a:
            ckk,counter2 = key,value
        else:
            counter3 += 1
    #print(ck,ckk)
    if counter2 == N:
        return N//2
    elif ls_v[0] != ck and ls_v[0] != ckk:
        z = 10
        k = 0
        for line in ls_v:
            if z%2 == 0 and line != ckk:
                k += 1
            elif z%2 != 0 and line != ck:
                k += 1
        return k
    elif counter + counter2 != N:
        return counter3
    else:
        return 0

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    ls_v = list(map(int, ws))
    return (N, ls_v)

def main():
    print(solve(*readQuestion()))

main()

Submission status: Wrong Answer

Solution code:
import sys

def solve(N, ls_v):
    # Uncomment the following if you want to check the input.
    #print('N =', N)
    #print('ls_v =', ls_v)
    inc=[]
    incc={}
    count=0
    for i in ls_v:
        if i not in incc:
            incc[i] = 1
        else:
            incc[i] += 1
    cl =[i for i in incc.values()]
    cls =[i for i in incc.keys()]
    a = max(cl)
    a = cl.index(a)
    a = cls[a]
    counter = 0
    couneter2 = 0
    counter3 = 0
    ckk = ""
    ck = ""
    for key,value in incc.items():
        if key != a and counter < value:
            counter,ck = value , key
        elif key == a:
            ckk,counter2 = key,value
        else:
            counter3 += 1
    if counter + counter2 == N and counter2 != N:
        return N-(counter + counter2)
    elif counter2 == N:
        return N//2
    else:
        return counter3


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    ls_v = list(map(int, ws))
    return (N, ls_v)

def main():
    print(solve(*readQuestion()))

main()

Submission status: Wrong Answer

Solution code:
import sys

def solve(N, ls_v):
    # Uncomment the following if you want to check the input.
    #print('N =', N)
    #print('ls_v =', ls_v)
    inc=[]
    incc={}
    count=0
    for i in ls_v:
        if i not in incc:
            incc[i] = 1
        else:
            incc[i] += 1
    cl =[i for i in incc.values()]
    cls =[i for i in incc.keys()]
    a = max(cl)
    a = cl.index(a)
    a = cls[a]
    counter = 0
    couneter2 = 0
    counter3 = 0
    ckk = ""
    ck = ""
    for key,value in incc.items():
        if key != a and counter < value:
            counter,ck = value , key
        elif key == a:
            ckk,counter2 = key,value
        else:
            counter3 += 1
    if counter + counter2 == N and counter2 != N:
        return N-(counter + counter2)
    elif counter2 == N:
        return N//2
    else:
        return counter3


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    ls_v = list(map(int, ws))
    return (N, ls_v)

def main():
    print(solve(*readQuestion()))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = list(int(i) for i in input().split())

a = v[:n:2]
b = v[1:n:2]
c = collections.Counter(a)
d = collections.Counter(b)

if len(c) ==1 and len(d) == 1:
    if c.most_common()[0][0] != d.most_common()[0][0]:
        print(n-c.most_common()[0][1]-d.most_common()[0][1])
    if c.most_common()[0][0] == d.most_common()[0][0]:
        print(n/2)

if len(c) ==1 and len(d) !=1:
    if c.most_common()[0][0] != d.most_common()[0][0]:
        print(n-c.most_common()[0][1]-d.most_common()[0][1])
    if c.most_common()[0][0] == d.most_common()[0][0]:
        print(n-c.most_common()[0][1]-d.most_common()[1][1])

if len(d) ==1 and len(c) !=1:
    if c.most_common()[0][0] != d.most_common()[0][0]:
        print(n-c.most_common()[0][1]-d.most_common()[0][1])
    if c.most_common()[0][0] == d.most_common()[0][0]:
        print(n-c.most_common()[1][1]-d.most_common()[0][1])

if len(c) != 1 and len(d) != 1:
    if c.most_common()[0][0] != d.most_common()[0][0]:
        print(n-c.most_common()[0][1]-d.most_common()[0][1])
    if c.most_common()[0][0] == d.most_common()[0][0]:
        if (c.most_common()[0][1]+d.most_common()[1][1]) >= (c.most_common()[1][1]+d.most_common()[0][1]):
            print(n-c.most_common()[0][1]-d.most_common()[1][1])
        else:
            print(n-c.most_common()[1][1]-d.most_common()[0][1])

Submission status: Wrong Answer

Solution code:
# coding:utf-8
# 找第二大的数的个数
n = input()
array = map(int, raw_input().split())
e_list = [array[i] for i in range(0, n, 2)]
o_list = [array[i] for i in range(1, n+1, 2)]


def process(arr):
    arr.sort()
    num = arr[0]
    counter = 0
    amt_arr = []
    arr.append(0)
    max = 0
    max_amt_num = []
    for i in arr:
        if i == num:
            counter += 1
        else:
            if counter > max:
                max_amt_num = [num]
                max = counter
            elif counter == max:
                max_amt_num.append(num)
                max = counter
            num = i
            amt_arr.append(counter)
            counter = 1
    if len(amt_arr) == 1:
        amt_arr.append(0)
    if len(max_amt_num) > 1:
        max_amt_num = "haha"
    amt_arr.sort()

    return amt_arr[-1], amt_arr[-2], max_amt_num
v1, v2, a1 = process(e_list)
v3, v4, a2 = process(o_list)
print v1, v2, v3, v4, a1, a2
if a1 != a2 and a1 != "haha":
    result = len(array) - v1 - v3
else:
    result = len(array) - max(v1+v4, v2+v3)
print result

Submission status: Wrong Answer

Solution code:
# coding:utf-8
# 找第二大的数的个数
n = input()
array = map(int, raw_input().split())
e_list = [array[i] for i in range(0, n, 2)]
o_list = [array[i] for i in range(1, n+1, 2)]


def process(arr):
    arr.sort()
    num = arr[0]
    counter = 0
    amt_arr = []
    arr.append(0)
    max = 0
    max_amt_num = []
    for i in arr:
        if i == num:
            counter += 1
        else:
            if counter > max:
                max_amt_num = [num]
                max = counter
            elif counter == max:
                max_amt_num.append(num)
                max = counter
            num = i
            amt_arr.append(counter)
            counter = 1
    if len(amt_arr) == 1:
        amt_arr.append(0)
    else:
        max_amt_num = "haha"
    amt_arr.sort()

    return amt_arr[-1], amt_arr[-2], max_amt_num
v1, v2, a1 = process(e_list)
v3, v4, a2 = process(o_list)

if a1 != a2 and a1 != "haha":
    result = len(array) - v1 - v3
else:
    result = len(array) - max(v1+v4, v2+v3)
print result

Submission status: Wrong Answer

Solution code:
# coding:utf-8
# 找第二大的数的个数
n = input()
array = map(int, raw_input().split())
e_list = [array[i] for i in range(0, n, 2)]
o_list = [array[i] for i in range(1, n+1, 2)]


def process(arr):
    arr.sort()
    num = arr[0]
    counter = 0
    amt_arr = []
    arr.append(0)
    max = 0
    max_amt_num = []
    for i in arr:
        if i == num:
            counter += 1
        else:
            if counter > max:
                max_amt_num = [num]
                max = counter
            elif counter == max:
                max_amt_num.append(num)
                max = counter
            num = i
            amt_arr.append(counter)
            counter = 1
    if len(amt_arr) == 1:
        amt_arr.append(0)
    amt_arr.sort()

    return amt_arr[-1], amt_arr[-2]


v1, v2 = process(e_list)
v3, v4 = process(o_list)
result = len(array) - max(v1+v4, v2+v3)
print result

Submission status: Wrong Answer

Solution code:
n = input()
array = map(int, raw_input().split())
e_list = [array[i] for i in range(0, n, 2)]
o_list = [array[i] for i in range(1, n+1, 2)]


def process(arr):
    arr.sort()
    num = arr[0]
    counter = 0
    amt_arr = []
    arr.append(0)
    max = 0
    max_amt_num = []
    for i in arr:
        if i == num:
            counter += 1
        else:
            if counter > max:
                max_amt_num = [num]
                max = counter
            elif counter == max:
                max_amt_num.append(num)
                max = counter
            num = i
            amt_arr.append(counter)
            counter = 1
    if len(amt_arr) == 1:
        amt_arr.append(0)
    amt_arr.sort()

    return amt_arr[-1], amt_arr[-2]



if e_list == o_list and len(e_list) == e_list.count(e_list[0]):
    print len(array) / 2
else:
    v1, v2 = process(e_list)
    v3, v4 = process(o_list)
    result = len(array) - max(v1+v4, v2+v3)
    print result

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int, input().split()))

a = [arr[i] for i in range(0,n,2)]
b = [arr[y] for y in range(1,n,2)]

import collections
acnt = collections.Counter(a)
bcnt = collections.Counter(b)

amaxval = acnt[list(acnt)[0]]
bmaxval = bcnt[list(bcnt)[0]]

amaxkey = list(acnt)[0]
bmaxkey = list(bcnt)[0]

def val(ab, abcnt):
	if len(ab) < 2:
		return abcnt[list(abcnt)[0]]
	else:
		return 0

if amaxkey != bmaxkey:
	ans = n - amaxval - bmaxval
elif amaxkey == bmaxkey:
	if amaxval >= bmaxval:
		ans = n - amaxval - val(b,bcnt)
	else:
		ans = n - val(a,acnt) - bmaxval

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int, input().split()))

a = [arr[i] for i in range(0,n,2)]
b = [arr[y] for y in range(1,n,2)]

import collections
acnt = collections.Counter(a)
bcnt = collections.Counter(b)

amaxval = acnt[list(acnt)[0]]
bmaxval = bcnt[list(bcnt)[0]]

amaxkey = list(acnt)[0]
bmaxkey = list(bcnt)[0]

def val(ab, abcnt):
	if len(ab) < 2:
		return 0
	else:
		return abcnt[list(abcnt)[0]]

if amaxkey != bmaxkey:
	ans = n - amaxval - bmaxval
else:
	if amaxval >= bmaxval:
		ans = n - amaxval - val(b,bcnt)
	else:
		ans = n - val(a,acnt) - bmaxval

print(ans)

Submission status: Wrong Answer

Solution code:
#n = input()
#arr = list(map(int, input().split()))
n=4
arr =[3, 1, 3, 2]

a = [arr[i] for i in range(0,n,2)]
b = [arr[y] for y in range(1,n,2)]

import collections
acnt = collections.Counter(a)
bcnt = collections.Counter(b)

amaxval = acnt[list(acnt)[0]]
bmaxval = bcnt[list(bcnt)[0]]

amaxkey = list(acnt)[0]
bmaxkey = list(bcnt)[0]

def val(ab, abcnt):
	if len(ab) < 2:
		return 0
	else:
		return abcnt[list(abcnt)[0]]

if amaxkey != bmaxkey:
	ans = n - amaxval - bmaxval
else:
	if amaxval >= bmaxval:
		ans = n - amaxval - val(b,bcnt)
	else:
		ans = n - val(a,acnt) - bmaxval

print(ans)

Submission status: Wrong Answer

Solution code:
n = input()
array = map(int, raw_input().split())
e_list = [array[i] for i in range(0, n, 2)]
o_list = [array[i] for i in range(1, n+1, 2)]

if e_list == o_list and len(e_list) == e_list.count(e_list[0]):
    print len(array) / 2
else:
    e_set = []
    e_count = []
    max = 1
    for x in e_list:
        if x not in e_set:
            e_set.append(x)
            e_count.append(1)
        else:
            e_count[e_set.index(x)]+=1
            if e_count[e_set.index(x)]>max:
                max = e_count[e_set.index(x)]
    e_result = len(e_list) - max
    o_set = []
    o_count = []
    max = 1
    for x in o_list:
        if x not in o_set:
            o_set.append(x)
            o_count.append(1)
        else:
            o_count[o_set.index(x)] += 1
            if o_count[o_set.index(x)] > max:
                max = o_count[o_set.index(x)]
    o_result = len(o_list) - max
    print o_result + e_result

Submission status: Wrong Answer

Solution code:
n = input()
array = map(int, raw_input().split())
e_list = [array[i] for i in range(0, n, 2)]
o_list = [array[i] for i in range(1, n+1, 2)]
if e_list == o_list:
    print len(array) / 2
else:
    e_set = [n for n in set(e_list)]
    o_set = [n for n in set(o_list)]
    e_number = []
    o_number = []
    for number in e_set:
        e_number.append(e_list.count(number))
    e_result = sum(e_number) - max(e_number)
    for number in o_set:
        o_number.append(o_list.count(number))
    o_result = sum(o_number) - max(o_number)
    print e_result + o_result

Submission status: Wrong Answer

Solution code:
# abc111_c_new

from collections import Counter


def solve(n, seq):
    odd = seq[::2]  # odd numbers of the seq
    even = seq[1::2]  # even numbers of the seq

    # print(odd)
    # print(even)

    odd = Counter(odd).most_common()  # example -> returns [(1, 5), (2, 5)]
    even = Counter(even).most_common()
    # odd = sorted([(k, v) for k, v in Counter(odd).items()], key=lambda x: x[1], reverse=True)
    # even = sorted([(k, v) for k, v in Counter(even).items()], key=lambda x: x[1], reverse=True)

    # print(odd)
    # print(even)

    sol = 0
    if odd[0][0] == even[0][0]:
        if len(odd) == 1 and len(even) == 1:  # seq [1, 1, 1, 1]  (special case)
            sol = int(n // 2)  # [1, 1, 1, 1] sol = N / 2
        else:
            if odd[0][1] > even[1][1]:
                # sol = n - odd[0][1] - even[1][1] ==
                sol = (n // 2 - odd[0][1]) + (n // 2 - even[1][1])
            else:
                # sol = n - odd[1][1] - even[0][1] ==
                sol = (n // 2 - odd[1][1]) + (n // 2 - even[0][1])
    else:
        # sol = n - odd[0][1] - even[0][1] ==
        sol = (n // 2 - odd[0][1]) + (n // 2 - even[0][1])

    return sol


if __name__ == "__main__":
    n = int(input())
    seq = list(map(int, input("").split(" ")))
    print(solve(n, seq))

Submission status: Wrong Answer

Solution code:
# abc111_c_new

from collections import Counter


def solve(n, seq):
    odd = seq[::2]  # odd numbers of the seq
    even = seq[1::2]  # even numbers of the seq

    # print(odd)
    # print(even)

    # odd = Counter(odd).most_common()  # example -> returns [(1, 5), (2, 5)]
    # even = Counter(even).most_common()
    odd = sorted([(k, v) for k, v in Counter(odd).items()], key=lambda x: x[1], reverse=True)
    even = sorted([(k, v) for k, v in Counter(even).items()], key=lambda x: x[1], reverse=True)

    # print(odd)
    # print(even)

    sol = 0
    if odd[0][0] == even[0][0]:
        if len(odd) == 1 and len(even) == 1:  # seq [1, 1, 1, 1]  (special case)
            sol = int(n // 2)  # [1, 1, 1, 1] sol = N / 2
        else:
            if odd[0][1] > even[1][1]:
                # sol = n - odd[0][1] - even[1][1] ==
                sol = (n // 2 - odd[0][1]) + (n // 2 - even[1][1])
            else:
                # sol = n - odd[1][1] - even[0][1] ==
                sol = (n // 2 - odd[1][1]) + (n // 2 - even[0][1])
    else:
        # sol = n - odd[0][1] - even[0][1] ==
        sol = (n // 2 - odd[0][1]) + (n // 2 - even[0][1])

    return sol


if __name__ == "__main__":
    n = int(input())
    seq = list(map(int, input("").split(" ")))
    print(solve(n, seq))

Submission status: Wrong Answer

Solution code:
# abc111_c_new

from collections import Counter


def solve(n, seq):
    odd = seq[::2]  # odd numbers of the seq
    even = seq[1::2]  # even numbers of the seq

    odd = Counter(odd).most_common()  # example -> returns [(1, 5), (2, 5)]
    # odd = sorted([(k, v) for k, v in Counter(odd).items()], key=lambda x: x[1], reverse=True)
    # even = sorted([(k, v) for k, v in Counter(even).items()], key=lambda x: x[1], reverse=True)
    even = Counter(even).most_common()

    # print(odd)
    # print(even)

    sol = 0
    if odd[0][0] == even[0][0]:
        if len(odd) == 1 and len(even) == 1:  # seq [1, 1, 1, 1]  (special case)
            sol = int(n // 2)  # [1, 1, 1, 1] sol = N / 2
        else:
            if odd[0][1] > even[1][1]:
                # sol = n - odd[0][1] - even[1][1]
                sol = (n / 2 - odd[0][1]) + (n / 2 - even[1][1])
            else:
                # sol = n - odd[1][1] - even[0][1]
                sol = (n / 2 - odd[1][1]) + (n / 2 - even[0][1])
    else:
        # sol = n - odd[0][1] - even[0][1]
        sol = (n / 2 - odd[0][1]) + (n / 2 - even[0][1])

    return sol


if __name__ == "__main__":
    n = int(input())
    seq = list(map(int, input("").split(" ")))
    print(solve(n, seq))

Submission status: Wrong Answer

Solution code:
# abc111_c_new

from collections import Counter


def solve(n, seq):
    odd = seq[::2]  # odd numbers of the seq
    even = seq[1::2]  # even numbers of the seq

    # odd = Counter(odd).most_common()  # example -> returns [(1, 5), (2, 5)]
    odd = sorted([(k, v) for k, v in Counter(odd).items()], key=lambda x: x[1], reverse=True)
    even = sorted([(k, v) for k, v in Counter(even).items()], key=lambda x: x[1], reverse=True)
    # even = Counter(even).most_common()

    # print(odd)
    # print(even)

    sol = 0
    if odd[0][0] == even[0][0]:
        if len(odd) == 1 and len(even) == 1:  # seq [1, 1, 1, 1]  (special case)
            sol = int(n // 2)  # [1, 1, 1, 1] sol = N / 2
        else:
            if odd[0][1] > even[1][1]:
                # sol = n - odd[0][1] - even[1][1]
                sol = (n / 2 - odd[0][1]) + (n / 2 - even[1][1])
            else:
                # sol = n - odd[1][1] - even[0][1]
                sol = (n / 2 - odd[1][1]) + (n / 2 - even[0][1])
    else:
        # sol = n - odd[0][1] - even[0][1]
        sol = (n / 2 - odd[0][1]) + (n / 2 - even[0][1])

    return sol


if __name__ == "__main__":
    n = int(input())
    seq = list(map(int, input("").split(" ")))
    print(solve(n, seq))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int,input().split()))

gu = []
ki = []

for i in range(0,n,2):
	gu.append(arr[i])
for y in range(1,n,2):
	ki.append(arr[y])

import collections

gusu = collections.Counter(gu)
lgusu = list(collections.Counter(gu))

kisu = collections.Counter(ki)
lkisu = list(collections.Counter(ki))

if lgusu[0] == lkisu[0]:
	if gusu[lgusu[0]] > kisu[lkisu[0]] and len(lkisu) != 1:
		ans = n - kisu[lkisu[1]] - gusu[lgusu[0]]
	elif gusu[lgusu[0]] <= kisu[lkisu[0]] and len(lgusu) != 1:
		ans = n - kisu[lkisu[0]] - gusu[lgusu[1]]
	else:
		ans = n - max(kisu[lkisu[0]],gusu[lgusu[0]])
else:
	ans = n - kisu[lkisu[0]] - gusu[lgusu[0]]
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
inputs=[]
if(n%2==0):
    inputs =list(map(int, input().split()))

a=[]
b=[]
count=int(n/2)    

for i in range(count):
    a.append(inputs[i+i])
    b.append(inputs[i+i+1])    

counter1=collections.Counter(a)
count1=counter1[1]
output1=""
for x in counter1:
    key = x    
    value = counter1[key]
    if(value<count1):
        count1=value
        output1=key

counter2=collections.Counter(b)
count2=counter2[1]
output2=""
for x in counter2:
    key = x    
    value = counter2[key]
    if(value<count2):
        count2=value
        output2=key


if(count1<count2):
    print(count2)
else:
    print(count1)

Submission status: Wrong Answer

Solution code:
n=int(input())
inputs=[]
if(n%2==0):
    inputs =list(map(int, input().split()))

a=[]
b=[]
count=int(n/2)    

for i in range(count):
    a.append(inputs[i+i])
    b.append(inputs[i+i+1])    

af=a[0]
count=0
for i in range(1,len(a)):
    if af!=a[i]:
        count+=1
bf=b[0]
for i in range(1,len(b)):
    if bf!=b[i]:
        count+=1
if(af==bf):
    for i in range(0,len(b)):
        if(af==b[i]):
            count+=1
            
print(count)

Submission status: Wrong Answer

Solution code:
# abc111_c


def solve(seq):
    i, changes = 0, 0

    condition1_OK = False
    initial_num = seq[0]
    for i in range(len(seq)):
        current_num = seq[i]
        if current_num != initial_num:
            condition1_OK = True
            break

    if condition1_OK:
        for i in range(len(seq)-3):
            if (seq[i] != seq[i+2]):
                changes += 1
            if (seq[i+1] != seq[i+3]):
                changes += 1
        return changes
    else:
        return 2


if __name__ == "__main__":
    n = int(input(""))
    seq = list(map(int, input("").split(" ")))
    print(solve(seq))

Submission status: Wrong Answer

Solution code:
from collections import Counter

N=int(input())
n=list(map(int,input().split()))
#Divide it into even and odd
n1=[]
n2=[]
for i in range(N//2):
    n1.append(n[i*2])
    n2.append(n[i*2-1])
#end

#make lile {key,value}             tabunn kokoga ikenai

cm1=Counter(n1).most_common(2)
cn1=[]
cn1.append([cm1[0][1],cm1[0][0]])
if len(cm1) != 1:
    cn1.append([cm1[1][1],cm1[1][0]])

cm2=Counter(n2).most_common(2)
cn2=[]
cn2.append([cm2[0][1],cm2[0][0]])
if len(cm2) != 1:
    cn2.append([cm2[1][1],cm2[1][0]])

#end

#for example(4,1 1 1 1)
cn1.append([0,0])
cn2.append([0,0])
#end

#sort
    #first input
sum1=0
sum2=0
if cn1[0][0]>=cn1[1][0]:
    max11=cn1[0][0]
    num11=cn1[0][1]

    max12=cn1[1][0]
    num12=cn1[1][1]
else:
    max11=cn1[1][0]
    num11=cn1[1][1]

    max12=cn1[0][0]
    num12=cn1[0][1]


if cn2[0][0]>=cn2[1][0]:
    max21=cn2[0][0]
    num21=cn2[0][1]

    max22=cn2[1][0]
    num22=cn2[1][1]
else:
    max21=cn2[1][0]
    num21=cn2[1][1]

    max22=cn2[0][0]
    num22=cn2[0][1]
    #end

for i in range(2,len(cn1)):
    if max12<cn1[i][0]:
        if max11<cn1[i][0]: #if new one is max
            sum1+=max12

            max12=max11
            num12=num11

            max11=cn1[i][0]
            num11=cn1[i][1]
        else:                #if new one is second max
            sum1+=max12

            max12=cn1[i][0]
            num12=cn1[i][1]
    else:
        sum1+=cn1[i][0]


for i in range(2,len(cn2)):
    if max22<cn2[i][0]:
        if max21<cn2[i][0]: #if new one is max
            sum2+=max22

            max22=max21
            num22=num21

            max21=cn2[i][0]
            num21=cn2[i][1]
        else:               #if new one is second max
            sum2+=max22

            max22=cn2[i][0]
            num22=cn2[i][1]
    else:
        sum2+=cn2[i][0]
#end

#print(cn1,max11,num11,max12,num12,"\n")
#print(cn2,max21,num21,max22,num22,"\n")

#answer
if num11 != num21:
    ans=sum1+sum2+max12+max22
elif max11-max12 > max21-max22:#prefer large disadvantage  
    ans=sum1+sum2+max12+max21
else:
    ans=sum1+sum2+max11+max22
print(ans)
#end

Submission status: Wrong Answer

Solution code:
N=int(input())
n=list(map(int,input().split()))
#Divide it into even and odd
n1=[]
n2=[]
for i in range(N//2):
    n1.append(n[i*2])
    n2.append(n[i*2-1])
#end

#make lile {key,value}             tabunn kokoga ikenai
cn1=[]
s=0
j=1
while n1!=[]:
    count=1
    while j < len(n1):
        if n1[j]==n1[0]:
            n1.pop(j)
            count+=1
        else:
            j+=1
    else:
        cn1.append([count,n1[0]])
        n1.pop(0)
        s+=1

cn2=[]
s=0
j=1
while n2!=[]:
    count=1
    while j < len(n2):
        if n2[j]==n2[0]:
            n2.pop(j)
            count+=1
        else:
            j+=1
    else:
        cn2.append([count,n2[0]])
        n2.pop(0)
        s+=1
#end

#for example(4,1 1 1 1)
cn1.append([0,0])
cn2.append([0,0])
#end

#sort
    #first input
sum1=0
sum2=0
if cn1[0][0]>=cn1[1][0]:
    max11=cn1[0][0]
    num11=cn1[0][1]

    max12=cn1[1][0]
    num12=cn1[1][1]
else:
    max11=cn1[1][0]
    num11=cn1[1][1]

    max12=cn1[0][0]
    num12=cn1[0][1]


if cn2[0][0]>=cn2[1][0]:
    max21=cn2[0][0]
    num21=cn2[0][1]

    max22=cn2[1][0]
    num22=cn2[1][1]
else:
    max21=cn2[1][0]
    num21=cn2[1][1]

    max22=cn2[0][0]
    num22=cn2[0][1]
    #end

for i in range(2,len(cn1)):
    if max12<cn1[i][0]:
        if max11<cn1[i][0]: #if new one is max
            sum1+=max12

            max12=max11
            num12=num11

            max11=cn1[i][0]
            num11=cn1[i][1]
        else:                #if new one is second max
            sum1+=max12

            max12=cn1[i][0]
            num12=cn1[i][1]
    else:
        sum1+=cn1[i][0]


for i in range(2,len(cn2)):
    if max22<cn2[i][0]:
        if max21<cn2[i][0]: #if new one is max
            sum2+=max22

            max22=max21
            num22=num21

            max21=cn2[i][0]
            num21=cn2[i][1]
        else:               #if new one is second max
            sum2+=max22

            max22=cn2[i][0]
            num22=cn2[i][1]
    else:
        sum2+=cn2[i][0]
#end

#print(cn1,max11,num11,max12,num12,"\n")
#print(cn2,max21,num21,max22,num22,"\n")

#answer
if num11 != num21:
    ans=sum1+sum2+max12+max22
elif max11-max12 > max21-max22:#prefer large disadvantage  
    ans=sum1+sum2+max12+max21
else:
    ans=sum1+sum2+max11+max22
print(ans)
#end

Submission status: Wrong Answer

Solution code:
import math as M
n=int(input())
Numbers=list(map(int,input().split(' ')))
Evens={}
Odds={}
for i in range(n):
    if i%2==0:
        if Numbers[i] in Evens:
            Evens[Numbers[i]]=Evens[Numbers[i]]+1
        else:
            Evens[Numbers[i]]=1

    if i%2!=0:
        if Numbers[i] in Odds:
            Odds[Numbers[i]]=Odds[Numbers[i]]+1
        else:
            Odds[Numbers[i]]=1
            
Evens=sorted(Evens.items(),key=lambda x:x[1])
Odds=sorted(Odds.items(),key=lambda x:x[1])
Evens.reverse()
Odds.reverse()

if Evens[0][0]==Odds[0][0]:
    if len(Evens)==1:
        Evens.append([Evens[0][0]+1,0])
    if len(Odds) == 1:
        Odds.append([Odds[0][0] + 1, 0])
    print(min(n,n-Evens[0][1]-Odds[1][1],n - Evens[0][1] - Odds[1][1]))
else:
    print(n-Evens[0][1]-Odds[0][1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
v1 = v[0::2]
v2 = v[1::2]
v3 = Counter(v1)
v4 = Counter(v2)
a = v3.most_common()[0][0]
b = v4.most_common()[0][0]
c = v3.most_common()[0][1]
d = v4.most_common()[0][1]
if a != b:
 print(len(v1)-c+len(v2)-d)
else:
 if len(list(set(v1))) == 1 and len(list(set(v2))) == 1:
  print(len(v1))

 else:
  if c <= d:
   print(len(v1)+len(v2)-d-v3.most_common()[1][1])
  else:
   print(len(v1)+len(v2)-c-v4.most_common()[1][1])

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = list(input().split())
 
v_odd = []
v_even = []
 
for i in range(int(n)):
  if i % 2 == 1:
  	v_odd.append(v[i])
  else:
    v_even.append(v[i])
  
  
v_odd_counter = collections.Counter(v_odd)
a = v_odd_counter.most_common()[0][1]
 
v_even_counter = collections.Counter(v_even)
b = v_even_counter.most_common()[0][1]
 
if a + b == n :
  print(n - a)
elif v_odd_counter.most_common()[0][1] == v_even_counter.most_common()[0][1] and a <= b:
  print(int(n/2) + a - b)
elif v_odd_counter.most_common()[0][1] == v_even_counter.most_common()[0][1] and a > b:
  print(int(n/2) - a + b)
else:
  print(n - a - b)