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
    counter2 = 0
    reco = 0
    counter3 = 0
    ckk = ""
    ck = ""
    rk = ""
    for key,value in incc.items():
        #print(key,value)
        if key == a:
            ckk,counter2 = key,value
        elif key != a and counter < value:
            counter,ck = value,key
        if (key != a and key != ck) and reco <= value:
            rk,reco = key,value
            #print("c")
        else:
            counter3 += 1
    #print("1",reco,rk)
    corli = []
    corli1 = []
    corli2 = []
    corli3 = []
    corli4 = []
    corli5 = []
    i = 10
    for line in ls_v:
        if i%2 == 0:
            corli.append(ckk)
            corli1.append(ck)
            corli2.append(rk)
            corli3.append(ck)
            corli4.append(rk)
            corli5.append(ckk)
        elif i%2 != 0:
            corli.append(ck)
            corli1.append(ckk)
            corli2.append(ck)
            corli3.append(rk)
            corli4.append(ckk)
            corli5.append(rk)
        i += 1
    #print(corli2)
    cc,c1,c2,c3,c4 = 0,0,0,0,0
    c = 0
    for (line1,line2) in zip(ls_v,corli):
        if line1 != line2:
            c += 1
    for (line1,line2) in zip(ls_v,corli1):
        if line1 != line2:
            cc += 1
    for (line1,line2) in zip(ls_v,corli2):
        #print(line1,line2)
        if line1 != line2:
            c1 += 1
    for (line1,line2) in zip(ls_v,corli3):
        if line1 != line2:
            c2 += 1
    for (line1,line2) in zip(ls_v,corli4):
        if line1 != line2:
            c3 += 1
    for (line1,line2) in zip(ls_v,corli5):
        if line1 != line2:
            c4 += 1
    #print(c,cc,c1,c2,c3,c4)
    if cc == 0 or c == 0:
        return 0
    else:
        return min(c,cc,c1,c2,c3,c4)
        #print(corli,corli1,corli3,corli4,corli5)

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
    counter2 = 0
    reco = 0
    counter3 = 0
    ckk = ""
    ck = ""
    rk = ""
    for key,value in incc.items():
        #print(key,value)
        if key == a:
            ckk,counter2 = key,value
        elif key != a and counter < value:
            counter,ck = value,key
        if (key != a and key != ck) and reco <= value:
            rk,reco = key,value
            #print("c")
        else:
            counter3 += 1
    #print("1",reco,rk)
    corli = []
    corli1 = []
    corli2 = []
    corli3 = []
    corli4 = []
    corli5 = []
    i = 10
    for line in ls_v:
        if i%2 == 0:
            corli.append(ckk)
            corli1.append(ck)
            corli2.append(rk)
            corli3.append(ck)
            corli4.append(rk)
            corli5.append(ckk)
        elif i%2 != 0:
            corli.append(ck)
            corli1.append(ckk)
            corli2.append(ck)
            corli3.append(rk)
            corli4.append(ckk)
            corli5.append(rk)
        i += 1
    #print(corli2)
    cc,c1,c2,c3,c4 = 0,0,0,0,0
    c = 0
    for (line1,line2) in zip(ls_v,corli):
        if line1 != line2:
            c += 1
    for (line1,line2) in zip(ls_v,corli1):
        if line1 != line2:
            cc += 1
    for (line1,line2) in zip(ls_v,corli2):
        #print(line1,line2)
        if line1 != line2:
            c1 += 1
    for (line1,line2) in zip(ls_v,corli3):
        if line1 != line2:
            c2 += 1
    for (line1,line2) in zip(ls_v,corli4):
        if line1 != line2:
            c3 += 1
    for (line1,line2) in zip(ls_v,corli5):
        if line1 != line2:
            c4 += 1
    #print(cc,c1,c2,c3,c4)
    if cc == 0 or c == 0:
        return 0
    else:
        return min(c1,c2,c3,c4)
        #print(corli,corli1,corli3,corli4,corli5)

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
    counter2 = 0
    reco = 0
    counter3 = 0
    ckk = ""
    ck = ""
    rk = ""
    for key,value in incc.items():
        #print(key,value)
        if key == a:
            ckk,counter2 = key,value
        elif key != a and counter < value:
            counter,ck = value,key
        if (key != a and key != ck) and reco <= value:
            rk,reco = key,value
            #print("c")
        else:
            counter3 += 1
    #print("1",reco,rk)
    corli = []
    corli1 = []
    corli2 = []
    corli3 = []
    corli4 = []
    corli5 = []
    i = 10
    for line in ls_v:
        if i%2 == 0:
            corli.append(ckk)
            corli1.append(ck)
            corli2.append(rk)
            corli3.append(ck)
            corli4.append(rk)
            corli5.append(ckk)
        elif i%2 != 0:
            corli.append(ck)
            corli1.append(ckk)
            corli2.append(ck)
            corli3.append(rk)
            corli4.append(ckk)
            corli5.append(rk)
        i += 1
    cc,c1,c2,c3,c4 = 0,0,0,0,0
    c = [0,0,0,0,0]
    for (line1,line2) in zip(ls_v,corli1):
        if line1 != line2:
            c[0] += 1
    for (line1,line2) in zip(ls_v,corli2):
        if line1 != line2:
            c[1] += 1
    for (line1,line2) in zip(ls_v,corli3):
        if line1 != line2:
            c[2] += 1
    for (line1,line2) in zip(ls_v,corli4):
        if line1 != line2:
            c[3] += 1
    for (line1,line2) in zip(ls_v,corli5):
        if line1 != line2:
            c[4] += 1
    if c[0] == 0 or c[1] == 0:
        return 0
    else:
        minc = 1000
        for i in c:
            if i !=0 and minc >= i:
                minc = i
        #print(c)
        #print(corli,corli1,corli3,corli4,corli5)
        return minc

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
    counter2 = 0
    reco = 0
    counter3 = 0
    ckk = ""
    ck = ""
    rk = ""
    for key,value in incc.items():
        #print(key,value)
        if key == a:
            ckk,counter2 = key,value
        elif key != a and counter < value:
            counter,ck = value,key
        if (key != a and key != ck) and reco <= value:
            rk,reco = key,value
            #print("c")
        else:
            counter3 += 1
    #print("1",reco,rk)
    corli = []
    corli1 = []
    corli2 = []
    corli3 = []
    corli4 = []
    corli5 = []
    i = 10
    for line in ls_v:
        if i%2 == 0:
            corli.append(ckk)
            corli1.append(ck)
            corli2.append(rk)
            corli3.append(ck)
            corli4.append(rk)
            corli5.append(ckk)
        elif i%2 != 0:
            corli.append(ck)
            corli1.append(ckk)
            corli2.append(ck)
            corli3.append(rk)
            corli4.append(ckk)
            corli5.append(rk)
        i += 1
    cc,c1,c2,c3,c4 = 0,0,0,0,0
    c = [0,0,0,0,0]
    for (line1,line2,line3,line4,line5,line6) in zip(ls_v,corli1,corli2,corli3,corli4,corli5):
        if line1 != line2:
            c[0] += 1
        elif line1 != line3:
            c[1] += 1
        elif line1 != line4:
            c[2] += 1
        elif line1 != line5:
            c[3] += 1
        elif line1 != line6:
            c[4] += 1
    if c[0] == 0 or c[1] == 0:
        return 0
    else:
        minc = 1000
        for i in c:
            if i !=0 and minc >= i:
                minc = i
        #print(c)
        #print(corli,corli1,corli3,corli4,corli5)
        return minc

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
    counter2 = 0
    reco = 0
    counter3 = 0
    ckk = ""
    ck = ""
    rk = ""
    for key,value in incc.items():
        #print(key,value)
        if key == a:
            ckk,counter2 = key,value
        elif key != a and counter < value:
            counter,ck = value,key
        if (key != a and key != ck) and reco <= value:
            rk,reco = key,value
            #print("c")
        else:
            counter3 += 1
    #print("1",reco,rk)
    corli = []
    corli1 = []
    corli2 = []
    corli3 = []
    corli4 = []
    corli5 = []
    i = 10
    for line in ls_v:
        if i%2 == 0:
            corli.append(ckk)
            corli1.append(ck)
            corli2.append(rk)
            corli3.append(ck)
            corli4.append(rk)
            corli5.append(ckk)
        elif i%2 != 0:
            corli.append(ck)
            corli1.append(ckk)
            corli2.append(ck)
            corli3.append(rk)
            corli4.append(ckk)
            corli5.append(rk)
        i += 1
    cc,c1,c2,c3,c4 = 0,0,0,0,0
    c = [0,0,0,0,0]
    for (line1,line2,line3,line4,line5,line6) in zip(ls_v,corli1,corli2,corli3,corli4,corli5):
        if line1 != line2:
            c[0] += 1
        if line1 != line3:
            c[1] += 1
        if line1 != line4:
            c[2] += 1
        if line1 != line5:
            c[3] += 1
        if line1 != line6:
            c[4] += 1
    if c[0] == 0 or c[1] == 0:
        return 0
    else:
        minc = 1000
        for i in c:
            if i !=0 and minc >= i:
                minc = i
        #print(c)
        #print(corli,corli1,corli3,corli4,corli5)
        return minc

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
    counter2 = 0
    reco = 0
    counter3 = 0
    ckk = ""
    ck = ""
    rk = ""
    for key,value in incc.items():
        #print(key,value)
        if key == a:
            ckk,counter2 = key,value
        elif key != a and counter < value:
            counter,ck = value,key
        if (key != a and key != ck) and reco <= value:
            rk,reco = key,value
            #print("c")
        else:
            counter3 += 1
    print("1",reco,rk)
    corli = []
    corli1 = []
    corli2 = []
    corli3 = []
    corli4 = []
    corli5 = []
    i = 10
    for line in ls_v:
        if i%2 == 0:
            corli.append(ckk)
            corli1.append(ck)
            corli2.append(rk)
            corli3.append(ck)
            corli4.append(rk)
            corli5.append(ckk)
        elif i%2 != 0:
            corli.append(ck)
            corli1.append(ckk)
            corli2.append(ck)
            corli3.append(rk)
            corli4.append(ckk)
            corli5.append(rk)
        i += 1
    cc,c1,c2,c3,c4 = 0,0,0,0,0
    c = [0,0,0,0,0]
    for (line1,line2,line3,line4,line5,line6) in zip(ls_v,corli1,corli2,corli3,corli4,corli5):
        if line1 != line2:
            c[0] += 1
        if line1 != line3:
            c[1] += 1
        if line1 != line4:
            c[2] += 1
        if line1 != line5:
            c[3] += 1
        if line1 != line6:
            c[4] += 1
    if c[0] == 0 or c[1] == 0:
        return 0
    else:
        minc = 1000
        for i in c:
            if i !=0 and minc >= i:
                minc = i
        #print(c)
        #print(corli,corli1,corli3,corli4,corli5)
        return minc

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
    counter2 = 0
    reco = 0
    counter3 = 0
    ckk = ""
    ck = ""
    rk = ""
    for key,value in incc.items():
        if key != a and counter < value:
            counter,ck = value , key
        elif key == a:
            ckk,counter2 = key,value
        elif counter2 != value and reco <= value:
            rk,reco = key,value
        else:
            counter3 += 1
    #print(ck,ckk)
    corli = []
    corli1 = []
    corli2 = []
    corli3 = []
    corli4 = []
    corli5 = []
    i = 10
    for line in ls_v:
        if i%2 == 0:
            corli.append(ckk)
            corli1.append(ck)
            corli2.append(rk)
            corli3.append(ck)
            corli4.append(rk)
            corli5.append(ckk)
        else:
            corli.append(ck)
            corli1.append(ckk)
            corli2.append(ck)
            corli3.append(rk)
            corli4.append(ckk)
            corli5.append(rk)
        i += 1
    cc,c1,c2,c3,c4 = 0,0,0,0,0
    c = [0,0,0,0,0]
    for (line1,line2,line3,line4,line5,line6) in zip(ls_v,corli1,corli2,corli3,corli4,corli5):
        if line1 != line2:
            c[0] += 1
        elif line1 != line3:
            c[1] += 1
        elif line1 != line4:
            c[2] += 1
        elif line1 != line5:
            c[3] += 1
        elif line1 != line6:
            c[4] += 1
    if c[0] == 0 or c[1] == 0:
        return 0
    else:
        minc = 1000
        for i in c:
            if i !=0 and minc >= i:
                minc = i
        return minc

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)
    corli=[]
    corli1=[]
    i = 10
    for line in ls_v:
        if i%2 == 0:
            corli.append(ckk)
            corli1.append(ck)
        else:
            corli.append(ck)
            corli1.append(ckk)
        i += 1
    c = 0
    cc = 0
    for (line1,line2) in zip(ls_v,corli1):
        if line1 != line2:
            cc += 1
    for (line1,line2) in zip(ls_v,corli):
        if line1 != line2:
            c += 1
    return min(c,cc)

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 (ls_v[0] == ckk and ls_v[1] == ck and counter == counter2) or\
       (ls_v[1] == ckk and ls_v[0] == ck and counter == counter2):
        return 0
    k = 10
    z = 0
    for line in ls_v:
        if (k%2 == 0 and line != ckk) and (k%2 == 0 and line != ck)or\
           (k%2 == 0 and line != ck) and (k%2 == 0 and line != ckk):
            z += 1
        if (k%2 != 0 and line != ckk) and (k%2 != 0 and line != ck)or\
            (k%2 != 0 and line != ck) and (k%2 != 0 and line != ckk):
            z += 1
        elif z == 0 and counter3 == 0:
            return counter2 - counter
        k += 1
    return z
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 (ls_v[0] == ckk and ls_v[1] == ck and counter == counter2) or\
       (ls_v[1] == ckk and ls_v[0] == ck and counter == counter2):
        return 0
    k = 10
    z = 0
    for line in ls_v:
        if (k%2 == 0 and line != ckk) and (k%2 == 0 and line != ck):
            z += 1
        if (k%2 != 0 and line != ckk) and (k%2 != 0 and line != ck):
            z += 1
        k += 1
    return z
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[1] != ckk) and counter2 < counter:
        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] != ck and ls_v[1] != ckk) and counter2 > counter:
        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 ls_v[0] != ckk and ls_v[1] != ck and counter2 > counter :
        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 ls_v[0] != ckk and ls_v[1] != ck and counter2 < counter :
        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 counter + counter2 != N:
        return counter3
    else:
        return N-(counter+counter2)

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[1] != ckk) and counter2 < counter:
        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] != ck and ls_v[1] != ckk) and counter2 > counter:
        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 ls_v[0] != ckk and ls_v[1] != ck and counter2 < counter :
        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 ls_v[0] != ckk and ls_v[1] != ck and counter2 > counter :
        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 counter + counter2 != N:
        return counter3
    else:
        return N-(counter+counter2)

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[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
    else:
        return N-(counter+counter2)

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