Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02939 (python)

Fixed submission:
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    try:
        if data[i] != memory:
            memory=data[i]
            i+=1             
        else:
            memory=data[i:i+2]
            i+=2
    except:
        break
    k+=1
    
print(k)

Buggy submission (verdict: Runtime Error):
input_data = []
data = input()



i=0
k=0

#最後二つが同じなら削除
inv_data=data[::-1]
memory=inv_data[0]
count=1
for ch in inv_data[1:]:
    if ch==memory:
        count+=1
    else:
        break
if count>=2:
    if count%2!=0:
        count-=1

    k+=count//2
    
    data=data[:len(data)-count] 


memory="first"
max_len=len(data)
while max_len!=i:
    if data[i] != memory:
        memory=data[i]
        i+=1             
    else:
   
        memory=data[i:i+2]
        i+=2
    k+=1
    
print(k)

Buggy submission (verdict: Runtime Error):
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    if data[i] != memory:
        memory=data[i]
        i+=1             
    else:
   
        memory=data[i:i+2]
        i+=2
    k+=1
    
print(k)

Buggy submission (verdict: Runtime Error):
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    if data[i] == memory:
        memory=data[i:i+2]
        i+=2
    else:
        memory=data[i]
        i+=1        
    k+=1
    
print(k)

Buggy submission (verdict: Runtime Error):
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    if data[i] == memory:
        memory=data[i:i+2]
        print(memory)
        i+=2
    else:
        memory=data[i]
        i+=1        
    k+=1
    
print(k)
Problem p02953 (python)

Fixed submission:
N=int(input())
matchNums=input().split(" ")
matchNums=list(map(int, matchNums))
plus_flgs=[-1]

if len(matchNums)==1:
    print("Yes")
    
else:
    check_array=[]
    check_array_all=[]
    
    for i in range(len(matchNums)-1):
        check_array.append((matchNums[i+1] - matchNums[i]))
    
#     for i in range(len(check_array)-1):
#         check_array_all.append((check_array[i+1] + check_array[i]))
    #プラスとプラスの間を足す
    #プラスのinedex取得
    for i,val in enumerate(check_array):
        if val > 0:
            plus_flgs.append(i)
    
    # 最後がマイナスで終わるとき対策
    plus_flgs.append(len(check_array))
#     print(plus_flgs)
#     print(check_array)
    for i in range(len(plus_flgs)-1):
        check_array_all.append(sum(check_array[plus_flgs[i]+1: plus_flgs[i+1]]))
#     print(check_array_all)
    # プラスとプラスの間の和が-2の物があったらＮＧ
    if min(check_array_all)<-1:
        print("No")
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
N=int(input())
matchNums=input().split(" ")
matchNums=list(map(int, matchNums))
plus_flgs=[]

if len(matchNums)==1:
    print("Yes")
    
else:
    check_array=[]
    check_array_all=[]
    
    for i in range(len(matchNums)-1):
        check_array.append((matchNums[i+1] - matchNums[i]))
    
#     for i in range(len(check_array)-1):
#         check_array_all.append((check_array[i+1] + check_array[i]))
    #プラスとプラスの間を足す
    #プラスのinedex取得
    for i,val in enumerate(check_array):
        if val > 0:
            plus_flgs.append(i)
    
    # 最後がマイナスで終わるとき対策
    plus_flgs.append(len(check_array))
    for i in range(len(plus_flgs)-1):
        check_array_all.append(sum(check_array[plus_flgs[i]+1: plus_flgs[i+1]]))
    
    # 微分値が-2の物があったらＮＧ
    if min(check_array_all)<-1:
        print("No")
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
N=int(input())
matchNums=input().split(" ")
matchNums=list(map(int, matchNums))
plus_flgs=[]

if len(matchNums)==1:
    print("Yes")
    
else:
    check_array=[]
    check_array_all=[]
    
    for i in range(len(matchNums)-1):
        check_array.append((matchNums[i+1] - matchNums[i]))
    
#     for i in range(len(check_array)-1):
#         check_array_all.append((check_array[i+1] + check_array[i]))
    #プラスとプラスの間を足す
    #プラスのinedex取得
    for i,val in enumerate(check_array):
        if val > 0:
            plus_flgs.append(i)
    
    # 最後がマイナスで終わるとき対策
    plus_flgs.append(len(check_array))
    for i in range(len(plus_flgs)-1):
        check_array_all.append(sum(check_array[plus_flgs[i]+1: plus_flgs[i+1]]))
    
    # 微分値が2の物があったらＮＧ
    if max(check_array[:-1])>1 or min(check_array[:-1])<-1:
        print("No")
    else:
        if min(check_array_all)<-1:
            print("No")
        else:
            print("Yes")
Problem p02960 (python)

Fixed submission:

N=input()

lists = []
temp=[i for i in range(10)]

MOD=10**9+7

dic={0:1}

for i in N:
    new_dic={}
    hoge=list(dic.items())
    if i == "?":
        for amari,count in hoge:
            amari*=10
            for num in temp:
                a = (amari + num) % 13
                if a in new_dic:
                    new_dic[a]+=count
                else:
                    new_dic[a]=count
    else:
        num=int(i)
        for amari,count in hoge:
            a = (amari*10 + num)%13
            if a in new_dic:
                new_dic[a]+=count
            else:
                new_dic[a]=count
    for key in new_dic:
        new_dic[key] %= MOD
    dic = new_dic

try:
    print(dic[5])
except:
    print(0)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=input()

lists = []
temp=[i for i in range(10)]

MOD=10**9+7

dic={0:1}

for i in N:
    new_dic={}
    hoge=list(dic.items())
    if i == "?":
        for amari,count in hoge:
            amari*=10
            for num in temp:
                a = (amari + num) % 13
                if a in new_dic:
                    new_dic[a]+=count
                else:
                    new_dic[a]=count
    else:
        num=int(i)
        for amari,count in hoge:
            a = (amari*10 + num)%13
            if a in new_dic:
                new_dic[a]+=count
            else:
                new_dic[a]=count
    for key in new_dic:
        new_dic[key] %= MOD
    dic = new_dic

try:
    print(dic[5])
except:
    print(0)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=input()

lists = []
temp=np.asarray([i for i in range(10)])

dic={0:1}

for i in N:
    new_dic={}
    hoge=list(dic.items())
    if i == "?":
        for amari,count in hoge:
            amari*=10
            for num in temp:
                a = (amari + num) % 13
                if a in new_dic:
                    new_dic[a]+=count
                else:
                    new_dic[a]=count
    else:
        num=int(i)
        for amari,count in hoge:
            a = (amari*10 + num)%13
            if a in new_dic:
                new_dic[a]+=count
            else:
                new_dic[a]=count
    dic = new_dic

try:
    print(dic[5]%(10**9 + 7))
except:
    print(0)

Buggy submission (verdict: Runtime Error):
N=input()

lists = []
temp=[i for i in range(10)]

dic={0:1}

for i in N:
    new_dic={}
    if i == "?":
        for amari,count in list(dic.items()):
            amari*=10
            for num in temp:
                a = (amari + num) % 13
                if a in new_dic:
                    new_dic[a]+=count
                else:
                    new_dic[a]=count
    else:
        for amari,count in list(dic.items()):
            a = (amari*10 + num)%13
            if a in new_dic:
                new_dic[a]+=count
            else:
                new_dic[a]=count
    dic = new_dic

try:
    print(dic[5]%(10**9 + 7))
except:
    print(0)
Problem p02963 (python)

Fixed submission:
import math
n=int(input())
x1,y1=0,0
x2,y2=10**9,1
y3 = n//x2 +1
if y3>x2:
    y3=x2
x3 = y3*x2 - n


output=[x1,y1,x2,y2,x3,y3]
output=list(map(str,output))
    
print(" ".join(output))

Buggy submission (verdict: Runtime Error):
x1,y1=0,0
x2,y2=10**9,1
y3 = n//x2 +1
if y3>x2:
    y3=x2
x3 = y3*x2 - n


output=[x1,y1,x2,y2,x3,y3]
output=list(map(str,output))
    
print(" ".join(output))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())

x1,y1=0,0
x2,y2=10**9,1
end = n%x2

for x3 in range(1,end+1):
    y3 = (n+x3)/x2
    if float.is_integer(y3):
        x3 =  x2*y3 -n
        break
        
output=[x1,y1,x2,y2,x3,y3]
output=list(map(str,output))
    
print(" ".join(output))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())

x,y=0,0
maxs=10**9
start = n%(10**8) if n>maxs else 1

for i in range(start, int(n**0.5)+1,2):
    if n % i == 0:
        if maxs>=i and maxs>=(n//i):
            x=i
            y=n//i
            break
print("0 0 0 "+str(x)+" "+str(y)+" 0")
Problem p02972 (python)

Fixed submission:
N=int(input())
a = list(map(int,input().split()))[::-1]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

# Nの倍数の数を格納する辞書
baisuu = {i:0 for i in range(1,N+1)}
M=0
out_list=[]

half=N//2

for i,ai in enumerate(a):
    now_index=N-i
    if now_index > half:
        if ai==1:
            soinsuu = make_divisors(now_index)
            out_list.append(now_index)
            M+=1
            for so in soinsuu:
                baisuu[so]+=1
    else:
        if baisuu[now_index]%2!=ai:
            out_list.append(now_index)
            M+=1
            soinsuu = make_divisors(now_index)
            for so in soinsuu:
                baisuu[so]+=1

print(M)
if M>0:
    out_list=sorted(out_list)
    print(" ".join(list(map(str, out_list))))

Buggy submission (verdict: Runtime Error):
# Nの倍数の数を格納する辞書
baisuu = {i:0 for i in range(1,N+1)}
M=0
out_list=[]

a=listA

half=N//2

for i,ai in enumerate(a):
    now_index=N-i
    if now_index > half:
        if ai==1:
            soinsuu = factorization(now_index)
            out_list.append(now_index)
            M+=1
            for so in soinsuu:
                baisuu[so]+=1
    else:
        if baisuu[now_index]%2!=int(ai):
            out_list.append(now_index)
            M+=1
            soinsuu = factorization(now_index)
            for so in soinsuu:
                baisuu[so]+=1

print(M)
if M>0:
    out_list=sorted(out_list)
    print(" ".join(list(map(str, out_list))))
Problem p02993 (python)

Fixed submission:
matchNums=input()

flg=False
for i in range(len(matchNums)-1):
    if matchNums[i] == matchNums[i+1]:
        flg = True
if flg:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
matchNums=input()

flg=False
for i in range(len(matchNums)-1):
    if matchNums[i] == matchNums[i+1]:
        flg = True
if flg:
    print("Bad")
else
    print("Good")
Problem p02995 (python)

Fixed submission:
import fractions

A,B,C,D = map(int,input().split())

# CとDの最小公倍数算出
bi = C*D//fractions.gcd(D,C)

A-=1
Bbi =B//bi
Abi =A//bi
sa = Bbi -Abi
# print(B-A-sa)

Bc = B//C
Bd = B//D

Ac = A//C
Ad = A//D

print(int( B-A - ((Bc-Ac) + (Bd-Ad) - sa)  ))

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
bi = C*D/math.gcd(D,C)
A-=1
Bbi =B//bi
Abi =A//bi
sa = Bbi -Abi
Bc = B//C
Bd = B//D
Ac = A//C
Ad = A//D
print(int( B-A - ((Bc-Ac) + (Bd-Ad) - sa)  ))

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D = map(int,input().split())

# CとDの最小公倍数算出
bi = C*D/math.gcd(D,C)

A-=1
Bbi =B//bi
Abi =A//bi
sa = Bbi -Abi
# print(B-A-sa)

Bc = B//C
Bd = B//D

Ac = A//C
Ad = A//D

print(int( B-A - ((Bc-Ac) + (Bd-Ad) - sa)  ))
Problem p03029 (python)

Fixed submission:
a,p=map(int,input().split())
print((3*a+p)//2)

Buggy submission (verdict: Runtime Error):
a,p=map(int,inqut().sprit())
print((3*a+p)//2)
Problem p03043 (python)

Fixed submission:
N,K=map(int,input().split())

import math
sums = 0
for i in range(1,N+1):
    num=int(math.log(K/i,2)+1)
    
    if i>K-1:
        sums +=(1/N)
    else:
        if i*2**(num)>=K>i*2**(num-1):
            sums += 1/(N * math.pow(2,num))
        else:
            sums += 1/(N * math.pow(2,num-1))

print(sums)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())

import math
sums = 0
for i in range(1,N+1):
    num=int(math.log(K//i,2)+1)
#     if num>int(num):
#         num=int(num)+1
    if i>K-1:
        sums +=(1/N)
    else:
        sums += 1/(N * math.pow(2,num))

print(sums)
Problem p03044 (python)

Fixed submission:
import sys

sys.setrecursionlimit(100000)

N=int(input())
tree_dict={i:0 for i in range(N)}
tree_map=[[] for i in range(N)]
start=set([i for i in range(N)])

edge=[]

#数字の若いほうから見ていくとする
for i in range(N-1):
    u,v,w = map(int, input().split())
    tree_map[u-1].append([v-1,w])
    tree_map[v-1].append([u-1,w])

def fill(index, now_color, dist):
    for v,w in tree_map[index]:
        
        if tree_dict[v] == 0:
            if w%2==0:
                tree_dict[v] = now_color
                fill(v, tree_dict[v], w)
            else:
                tree_dict[v] = -1*now_color
                fill(v, tree_dict[v],w)


now_color=1
tree_dict[0]=now_color
fill(0,now_color, 0)

for i in tree_dict.values():
    if i==-1:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
N=int(input())
tree_dict={i:-1 for i in range(N)}
tree_map=[[] for i in range(N)]
start=set([i for i in range(N)])

edge=[]

#数字の若いほうから見ていくとする
for i in range(N-1):
    u,v,w = map(int, input().split())
    tree_map[u-1].append([v-1,w])

def fill(index, now_color, dist):
    for v,w in tree_map[index]:
        
        if tree_dict[v] == -1:
#             if w%2==0:
#                 tree_dict[v] = now_color
#                 fill(v, tree_dict[v], w)
#             else:
#                 tree_dict[v] = -1*now_color
#                 fill(v, tree_dict[v],w)
            tree_dict[v] = (dist+w)%2
            fill(v, tree_dict[v],w)

now_color=1
tree_dict[start]=now_color
fill(0,now_color, 0)

for i in tree_dict.values():
    if i==-1:
        print(0)
    else:
        print(1)
Problem p03061 (python)

Fixed submission:
N =int(input())
A = list(map(int,input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

A = sorted(A)
from collections import Counter
check = Counter(A)
for c,k in check.items():
    if k>=N-1:
        A=[c]



def del_dicts(dicts,i):
    del_list=[]
    for k,v in dicts.items():
        if v<i:
            del_list.append(k)
    for d in del_list:
        del dicts[d]
    return dicts

dicts = {}

for i in range(len(A)):
    if i<=2:
        for num in make_divisors(A[i]):
            if num in dicts:
                dicts[num]+=1
            else:
                dicts[num]=1
    
    else:
        del_list=[]
        
        for k in dicts.keys():
            if A[i]%k == 0:
                dicts[k]+=1
    dicts = del_dicts(dicts,i)
print(max(dicts.keys()))

Buggy submission (verdict: Runtime Error):
N =int(input())
A = list(map(int,input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

A = sorted(A)

dicts = {}

if len(A) <=2:
    for i in A:
        for num in make_divisors(i):
            if num in dicts:
                dicts[num]+=1
            else:
                dicts[num]=1
    max_value=0
    for k,v in dicts.items():
        if v>=N-1 and max_value<k:
            max_value=k

    print(max_value)
else:
    for i in range(3):
        for num in make_divisors(A[i]):
            if num in dicts:
                dicts[num]+=1
            else:
                dicts[num]=1
    
    #
    new_list=[]
    for k,v in dicts.items():
        if v>=2:
            new_list.append(k)
    new_set=set(new_list)
    for i in range(3,len(A)):
        for num in new_set:
            if A[i]%num!=0:
                new_set-=set([num])
    print(max(new_set))
Problem p03079 (python)

Fixed submission:
DATA=list(map(int, input().split(" ")))
DATA=sorted(DATA)
if DATA[0] == DATA[-1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
DATA=list(map(int, input().split(" ")))
DATA=sorted(DATA)
if DATA[0] == DATA[-1]:
    print("Yes")
else;
    print("No")
Problem p03089 (python)

Fixed submission:
import copy

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


root=[]
string = copy.deepcopy(a)
while len(string)!=0:
    temp=[]
    for i,s in enumerate(string):
        if i+1 == s:
            temp.append(i+1)
    if len(temp)==0:
        break
    
    if temp[0]==1 and len(temp)==1:
        string.pop(0)
        root.append(1)
    else:
        if 1 in temp:
            temp.remove(1)
        root.append(temp[-1])
        string.pop(temp[-1]-1)
        
if len(string)!=0:
    print(-1)
else:
    for i in root[::-1]:
        print(i)

Buggy submission (verdict: Runtime Error):
root=[]
string = copy.deepcopy(a)
while len(string)!=0:
    temp=[]
    for i,s in enumerate(string):
        if i+1 == s:
            temp.append(i+1)
    if len(temp)==0:
        break
    
    if temp[0]==1 and len(temp)==1:
        string.pop(0)
        root.append(1)
    else:
        if 1 in temp:
            temp.remove(1)
        for i in temp[-1]:
            root.append(i)
            string.pop(i-1)
        
if len(string)!=0:
    print(-1)
else:
    for i in root[::-1]:
        print(i)
Problem p03110 (python)

Fixed submission:
def input_int():
    return map(int, input().split())

def input_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=input_int()



dicts={}
dicts["JPY"]=0
dicts["BTC"]=0

for i in range(N):
    x, u = input().split()
    dicts[u] += float(x)

sums = dicts["JPY"] + dicts["BTC"] * 380000.0

print(sums)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N=input_int()



dicts={}
dicts["JPY"]=0
dicts["BTC"]=0

for i in range(N):
    x, u = input().split()
    dicts[u] += float(x)

sums = dicts["JPY"] + dicts["BTC"] * 380000.0

print(sums)
Problem p03125 (python)

Fixed submission:
DATA=input()
DATA=DATA.split(" ")
A=int(DATA[0])
B=int(DATA[1])

if B%A==0:
    print(A+B)
else:
    print(B-A)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if B%A==0:
    print(A+B)
else:
    print(B-A)

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
if B%A==0:
    print(A+B)
else:
    print(B-A)

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
if A%B==0:
    print(A+B)
else:
    print(B-A)
Problem p03163 (python)

Fixed submission:
N,W=map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]



dp = [[0 for i in range(W+1)] for j in range(N+1)]


for i in range(N):
    for w in range(W+1):
        if w>=A[i][0]:
            dp[i+1][w] = max([dp[i][w-A[i][0]]+A[i][1], dp[i][w]])
        else:
            dp[i+1][w] = dp[i][w]
        
print(int(dp[N][W]))

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]



dp=np.zeros((N+1,W+1))


for i in range(N):
    for w in range(W+1):
        if w>=A[i][0]:
            dp[i+1][w] = max([dp[i][w-A[i][0]]+A[i][1], dp[i][w]])
        else:
            dp[i+1][w] = dp[i][w]
        
print(int(dp[N][W]))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,W=map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]



dp=np.zeros((N+1,W+1))


for i in range(N):
    for w in range(W+1):
        if w>=A[i][0]:
            dp[i+1][w] = max([dp[i][w-A[i][0]]+A[i][1], dp[i][w]])
        else:
            dp[i+1][w] = dp[i][w]
        
print(int(dp[N][W]))
Problem p03164 (python)

Fixed submission:
N,W=map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]



max_sum = sum([i[1] for i in A])

max_value=10**10
dp = [[max_value for i in range(max_sum+1) ] for j in range(N+1)]
dp[0][0]=0

for i in range(N):
    for v in range(max_sum+1):
        if v>=A[i][1]:
            dp[i+1][v] = min([dp[i][v-A[i][1]]+A[i][0], dp[i][v]])

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

#ここでindexは価値と同値、複数あることを考慮して反転後indexで最も価値のある個所を取得
# try:
#     print(max_sum-dp[N][::-1].index(W))
# except:
#     print(max_sum-dp[N][::-1].index(W))
for i,w in enumerate(dp[N][::-1]):
    if w <=W:
        print(max_sum-i)
        break
#     print(int(dp[N][W]))

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]



max_sum = sum([i[1] for i in A])

max_value=1000001
dp = [[max_value for i in range(max_sum+1) ] for j in range(N+1)]
dp[0][0]=0

for i in range(N):
    for v in range(max_sum+1):
        if v>=A[i][1]:
            dp[i+1][v] = min([dp[i][v-A[i][1]]+A[i][0], dp[i][v]])

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

#ここでindexは価値と同値、複数あることを考慮して反転後indexで最も価値のある個所を取得
print(max_sum-dp[N][::-1].index(W))
#     print(int(dp[N][W]))
Problem p03244 (python)

Fixed submission:
import heapq

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

one = V[::2]
two = V[1:][::2]

one,two

one_count={}
one_len=len(one)
for o in one:
    if o in one_count:
        one_count[o] += 1
    else:
        one_count[o] = 1

for k,v in one_count.items():
    one_count[k] = one_len-v
one_count[10**6]=one_len
temp = [[k,v] for k,v in one_count.items()]
one = heapq.nsmallest(3,temp, key=lambda x: x[1])


two_len=len(two)
two_count={}

for t in two:
    if t in two_count:
        two_count[t] += 1
    else:
        two_count[t] = 1

for k,v in two_count.items():
    two_count[k] = two_len-v
two_count[10**6]=two_len
temp = [[k,v] for k,v in two_count.items()]
two = heapq.nsmallest(3,temp, key=lambda x: x[1])

mins = 1000000

for [one_key, one_value] in one:
    for [two_key, two_value] in two:
        if one_key != two_key:
            if (one_value + two_value) < mins:
                mins = one_value + two_value
print(mins)

Buggy submission (verdict: Runtime Error):
import heapq



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

one = V[::2]
two = V[1:][::2]

one_count={}
one_len=len(one)
values={}
for o in one:
    if o in values:
        values[o] += 1
    else:
        values[o] = 1

one_count[10**6]=one_len
for k,v in values.items():
    one_count[k] = one_len-v


    
two_len=len(two)
two_count={}
values={}

for t in two:
    if o in values:
        values[t] += 1
    else:
        values[t] = 1

two_count[10**6]=two_len
for k,v in values.items():
    two_count[k] = two_len-v




keys = list(set(V))
mins = 1000

for one_key, one_value in one_count.items():
    for two_key, two_value in two_count.items():
        if one_key != two_key:
            if one_value + two_value < mins:
                mins = one_value + two_value
print(mins)