Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
people = input()

counts = []
mini = N
for n in range(N):
    count = 0
    for i in range(N):
        if i == n:
            continue
        if n<i and people[i]=='E':
            count +=1
        if n>i and people[i]=='W':
            count +=1
        if count >= mini:
            break
    mini = min([count, mini])
    counts.append(count)

print(min(counts))

Fixed submission:
N = int(input())
people = input()

count = 0
for i in range(1, N):
    if people[i] == 'E':
        count += 1

counts = [count]
for i in range(1, N):
    if people[i - 1] == 'W':
        count += 1
    if people[i]  == 'E':
        count -= 1
    counts.append(count)

print(min(counts))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
people = input()

counts = []
for n in range(N):
    count = 0
    for i in range(N):
        if i == n:
            continue
        if n<i and people[i]=='E':
            count +=1
        if n>i and people[i]=='W':
            count +=1
    counts.append(count)

print(min(counts))

Fixed submission:
N = int(input())
people = input()

count = 0
for i in range(1, N):
    if people[i] == 'E':
        count += 1

counts = [count]
for i in range(1, N):
    if people[i - 1] == 'W':
        count += 1
    if people[i]  == 'E':
        count -= 1
    counts.append(count)

print(min(counts))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

Xs = [i for i in range(K+1)]
Ys = Xs[:]
Zs = Xs[:]

count = 0
for x in Xs:
    for y in Ys:
        for z in Zs:
            if x+y+z == S:
                count += 1
print(count)

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

Xs = [i for i in range(K+1)]
Ys = Xs[:]

count = 0
for x in Xs:
    for y in Ys:
        if 0<= S - x - y <= K:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
import math
N,K = map(int, input().split())
a = list(map(int,input().split()))
l = 0
r = K - 1
Min = float("inf")
for i in range(N - K + 1):
    if(a[l]*a[r]<=0):#原点を跨ぐとき
        Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    elif(l==0):#左端の時
        if(a[r]*a[r+1]<0 or a[0]>0):
            Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    elif(r==N-1):#右端の時
        if(a[l-1]*a[l]<0 or a[l]>0):
            Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    else:
        if(a[r]*a[r+1]<0 or a[l-1]*a[l]<0):
            Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    l = l + 1
    r = r + 1
print(Min)


Fixed submission:
y = input().split()
print(int(y[0])-int(y[1])+1)
Buggy python submission (verdict: Runtime Error):
N=int(input())
Vs=str(input())
Cs=str(input())
ListV=Vs.split()
ListC=Cs.split()
for i in range(0,len(ListV),1):
  a=ListV.pop(0)
  ListV.insert(0,int(a))

for i in range(0,len(ListC),1):
  b=ListC.pop(0)
  ListC.insert(0,int(b))

ListI=[]
for i in range(0,len(ListV),1):
  c=ListV[i]-ListC[i]
  ListI.append(c)

Ans=0
for i in range(0,len(ListI),1):
  if ListI[i]>0:
    Ans+=ListI[i]

print(Ans)


Fixed submission:
N=int(input())
Vs=str(input())
Cs=str(input())
ListV=Vs.split()
ListC=Cs.split()
for i in range(0,len(ListV),1):
  a=ListV.pop(0)
  ListV.append(int(a))

for i in range(0,len(ListC),1):
  b=ListC.pop(0)
  ListC.append(int(b))

ListI=[]
for i in range(0,len(ListV),1):
  c=ListV[i]-ListC[i]
  ListI.append(c)

Ans=0
for i in range(0,len(ListI),1):
  if ListI[i]>0:
    Ans+=ListI[i]

print(Ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
Vs=str(input())
Cs=str(input())
ListV=Vs.split()
ListC=Cs.split()
for i in range(0,len(ListV),1):
  a=ListV.pop(0)
  ListV.insert(0,int(a))

for i in range(0,len(ListC),1):
  b=ListC.pop(0)
  ListC.insert(0,int(b))

ListI=[]
for i in range(0,len(ListV),1):
  c=ListV[i]-ListC[i]
  ListI.append(0)

Ans=0
for i in range(0,len(ListI),1):
  if ListI[i]>0:
    Ans+=ListI[i]

print(Ans)

Fixed submission:
N=int(input())
Vs=str(input())
Cs=str(input())
ListV=Vs.split()
ListC=Cs.split()
for i in range(0,len(ListV),1):
  a=ListV.pop(0)
  ListV.append(int(a))

for i in range(0,len(ListC),1):
  b=ListC.pop(0)
  ListC.append(int(b))

ListI=[]
for i in range(0,len(ListV),1):
  c=ListV[i]-ListC[i]
  ListI.append(c)

Ans=0
for i in range(0,len(ListI),1):
  if ListI[i]>0:
    Ans+=ListI[i]

print(Ans)
Buggy python submission (verdict: Runtime Error):
N=input()
S=str(input())
K=int(input())
Target=S[K]
Ans=""
for i in range(0,len(S),1):
  if S[i]==S[K]:
    Ans+=str(S[i])
  elif S[i]!=S[K]:
    Ans+="*"

print(Ans)


Fixed submission:
N=input()
S=str(input())
K=int(input())
Ans=""
for i in range(0,len(S),1):
  if S[i]==S[K-1]:
    Ans+=str(S[i])
  elif S[i]!=S[K-1]:
    Ans+="*"

print(Ans)
Buggy python submission (verdict: Runtime Error):
#下1桁が小さい(しかし0でない)物を最後に残す
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
S=a+b+c+d+e
A=a%10
B=b%10
C=c%10
D=d%10
E=e%10
ListN=[]
if A!=0:
  ListN.append(A)
if B!=0:
  ListN.append(B)
if C!=0:
  ListN.append(C)
if D!=0:
  ListN.append(D)
if E!=0:
  ListN.append(E)
ListN.sort()
if len(N)==0:
  print(S)
else:
  Listn=[]
  for i in range(0,len(N),1):
    q=10-int(ListN[i])
    S+=q
  print(S)


Fixed submission:
#下1桁が小さい(しかし0でない)物を最後に残す
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
S=a+b+c+d+e
A=a%10
B=b%10
C=c%10
D=d%10
E=e%10
ListN=[]
if A!=0:
  ListN.append(A)
if B!=0:
  ListN.append(B)
if C!=0:
  ListN.append(C)
if D!=0:
  ListN.append(D)
if E!=0:
  ListN.append(E)

if len(ListN)==0:
  print(S)
else:
  Listn=[]
  ListN.sort()
  for i in range(1,len(ListN),1):
    q=10-int(ListN[i])
    S+=q
  print(S)

Buggy python submission (verdict: Runtime Error):
#下1桁が小さい(しかし0でない)物を最後に残す
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
S=a+b+c+d+e
A=a%10
B=b%10
C=c%10
D=d%10
E=e%10
ListN=[]
ListN.append(A)
ListN.append(B)
ListN.append(C)
ListN.append(D)
ListN.append(E)
ListN.sort()
while ListN[0]==0:
  ListN.pop(0)
  ListN.append(0)
Listn=[]
for i in range(1,5,1):
  if ListN[i]!=0
    Listn.append(10-int(ListN[i]))

s=0
for i in range(1,5,1):
  s+=Listn[i]

S+=s
print(S)

Fixed submission:
#下1桁が小さい(しかし0でない)物を最後に残す
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
S=a+b+c+d+e
A=a%10
B=b%10
C=c%10
D=d%10
E=e%10
ListN=[]
if A!=0:
  ListN.append(A)
if B!=0:
  ListN.append(B)
if C!=0:
  ListN.append(C)
if D!=0:
  ListN.append(D)
if E!=0:
  ListN.append(E)

if len(ListN)==0:
  print(S)
else:
  Listn=[]
  ListN.sort()
  for i in range(1,len(ListN),1):
    q=10-int(ListN[i])
    S+=q
  print(S)
Buggy python submission (verdict: Runtime Error):
moji=str(input()) #文字列の入力
ListNum=[] #suuの各値を入れる
suu=0
for i in range(0,len(moji),1):
  if moji[i]=="A":
    suu+=1
  elif moji[i]=="T":
    suu+=1
  elif moji[i]=="G":
    suu+=1
  elif moji[i]=="C":
    suu+=1
  else:
    ListNum.append(suu)
    suu=0
print(max(ListNum))


Fixed submission:
S=str(input())  #文字列の入力
S=S.replace("A","x")
S=S.replace("T","x")
S=S.replace("G","x")
S=S.replace("C","x")
for i in range(0,2,1):
  if S.count("xxxxxxxxxx")!=0:
    print(10)
    break
  elif S.count("xxxxxxxxx")!=0:
    print(9)
    break
  elif S.count("xxxxxxxx")!=0:
    print(8)
    break
  elif S.count("xxxxxxx")!=0:
    print(7)
    break
  elif S.count("xxxxxx")!=0:
    print(6)
    break
  elif S.count("xxxxx")!=0:
    print(5)
    break
  elif S.count("xxxx")!=0:
    print(4)
    break
  elif S.count("xxx")!=0:
    print(3)
    break
  elif S.count("xx")!=0:
    print(2)
    break
  elif S.count("x")!=0:
    print(1)
    break
  else:
    print(0)
    break

Buggy python submission (verdict: Runtime Error):
moji=str(input()) #文字列の入力
ListNum=[] #suuの各値を入れる
suu=0
for i in range(0,len(moji),1):
  if moji[i]=="A":
    suu+=1
  elif moji[i]=="T":
    suu+=1
  elif moji[i]=="G":
    suu+=1
  elif moji[i]=="C":
    suu+=1
  else:
    ListNum.append(suu)
    suu=0
print(max(ListNum))

Fixed submission:
S=str(input())  #文字列の入力
S=S.replace("A","x")
S=S.replace("T","x")
S=S.replace("G","x")
S=S.replace("C","x")
for i in range(0,2,1):
  if S.count("xxxxxxxxxx")!=0:
    print(10)
    break
  elif S.count("xxxxxxxxx")!=0:
    print(9)
    break
  elif S.count("xxxxxxxx")!=0:
    print(8)
    break
  elif S.count("xxxxxxx")!=0:
    print(7)
    break
  elif S.count("xxxxxx")!=0:
    print(6)
    break
  elif S.count("xxxxx")!=0:
    print(5)
    break
  elif S.count("xxxx")!=0:
    print(4)
    break
  elif S.count("xxx")!=0:
    print(3)
    break
  elif S.count("xx")!=0:
    print(2)
    break
  elif S.count("x")!=0:
    print(1)
    break
  else:
    print(0)
    break
Buggy python submission (verdict: Runtime Error):
NK=int(input())
ListNK=NK.split() #ListNK[0]=N,[1]=K
N=int(ListNK[0])
K=int(ListNK[1])
Listh=[]
ListQ=[]
for i in range(0,N,1):
  hi=int(input())
  Listh.append(hi)

Listh.sort() #Listhの要素を小さい順に並べる
for i in range(0,N-K,1):
  Q=int(Listh[K+i-1]-Listh[i]) #hmax-hminの候補.Qminを求めればよい
  ListQ.append(Q)
ListQ.sort()
print(ListQ[0])


Fixed submission:
NK=input()
ListNK=NK.split() #ListNK[0]=N,[1]=K
N=int(ListNK[0])
K=int(ListNK[1])
Listh=[]
ListQ=[]
for i in range(0,N,1):
  hi=int(input())
  Listh.append(hi)

Listh.sort() #Listhの要素を小さい順に並べる
for i in range(0,N-K+1,1):
  Q=int(Listh[K+i-1]-Listh[i]) #hmax-hminの候補.Qminを求めればよい
  ListQ.append(Q)
ListQ.sort()
print(ListQ[0])

Buggy python submission (verdict: Runtime Error):
NK=int(input())
ListNK=NK.split() #ListNK[0]=N,[1]=K
N=ListNK[0]
K=ListNK[1]
Listh=[]
ListQ=[]
for i in range(0,N,1):
  hi=int(input())
  Listh.append(hi)

Listh.sort() #Listhの要素を小さい順に並べる
for i in range(0,N-K+1,1):
  Q=int(Listh[K+i-1]-Listh[i]) #hmax-hminの候補.Qminを求めればよい
  ListQ.append(Q)
ListQ.sort()
print(ListQ[0])


Fixed submission:
NK=input()
ListNK=NK.split() #ListNK[0]=N,[1]=K
N=int(ListNK[0])
K=int(ListNK[1])
Listh=[]
ListQ=[]
for i in range(0,N,1):
  hi=int(input())
  Listh.append(hi)

Listh.sort() #Listhの要素を小さい順に並べる
for i in range(0,N-K+1,1):
  Q=int(Listh[K+i-1]-Listh[i]) #hmax-hminの候補.Qminを求めればよい
  ListQ.append(Q)
ListQ.sort()
print(ListQ[0])
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split()) #Nは種類、Mは食べる個数
ListPPP=[]
ListPPM=[]
ListPMP=[]
ListMPP=[]
ListPMM=[]
ListMPM=[]
ListMMP=[]
ListMMM=[]
for i in range(0,N,1):
  x,y,z=map(int,input().split())
  ListPPP.append(x+y+z)
  ListPPM.append(x+y-z)
  ListPMP.append(x-y+z)
  ListMPP.append(-x+y+z)
  ListPMM.append(x-y-z)
  ListMPM.append(-x+y-z)
  ListMMP.append(-x-y+z)
  ListMMM.append(-x-y-z)

MAXList=[]
a=0;b=0;c=0;d=0;e=0;f=0;g=0;h=0


ListPPP.sort()
for i in range(0,M,1):
  a+=int(ListPPP[-1-i])
  
ListPPM.sort()
for i in range(0,M,1):
  b+=int(ListPPM[-1-i])

ListPMP.sort()
for i in range(0,M,1):
  c+=int(ListPMP[-1-i])

ListMPP.sort()
for i in range(0,M,1):
  d+=int(ListMPP[-1-i])

ListPMM.sort()
for i in range(0,M,1):
  e+=int(ListPMM[-1-i])


ListMPM.sort()
for i in range(0,M,1):
  f+=int(ListMPM[-1-i])


ListMMP.sort()
for i in range(0,M,1):
  g+=int(ListMMP[-1-i])

ListMMM.sort()
for i in range(0,M,1):
  h+=int(ListMMM[-1-i])
  
MAXList.append(a)
MAXList.append(b)
MAXList.append(c)
MAXList.append(d)
MAXList.append(e)
MAXList.append(f)
MAXList.append(g)
MAXList.append(h)
print(max(MAXList))

Fixed submission:
A,B=map(int,input().split())
if A<=8 and B<=8:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
import fractions

n_str = input()
n = int(n_str)
a_str = input().split()
a = []
for i in range(n):
    a.append(int(a_str[i]))
tmp1 = [0] * (n + 1)
tmp2 = [0] * (n + 1)
tmp = []
for i in range(n + 1):
    for j in range(i):
        if j == 0:
            tmp1[j + 1] = fractions.gcd(0, a[j])
        else:
            tmp1[j + 1] = fractions.gcd(tmp1[j], a[j])
    for j in range(n - 1, i, -1):
        if j == n - 1:
            tmp2[j] = fractions.gcd(0, a[j])
        else:
            tmp2[j] = fractions.gcd(tmp2[j + 1], a[j])
    if i == 0:
        tmp.append(fractions.gcd(0, tmp2[i + 1]))
    elif i == n:
        tmp.append(fractions.gcd(tmp1[i], 0))
    else:
        tmp.append(fractions.gcd(tmp1[i], tmp2[i + 1]))
print(max(tmp))


Fixed submission:
in_str = input()
str_num = in_str.split()
num = []
for i in range(3):
    num.append(int(str_num[i]))

bis = 0
i = 1

while True:
    if num[0] * i > num[2] + 0.5:
        break
    bis += num[1]
    i += 1

print(bis)
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
	n, m = map(int, raw_input().split())
	to1 = []
	toN = []

	for i in range(m):
		x, y = map(int, raw_input().split())
		if x == 1:
			to1.append(y)
		if x == n:
			toN.append(y)
		if y == 1:
			to1.append(x)
		if y == n:
			toN.append(x)

	for i in range(n):
		if i in to1 and i in toN:
			print "POSSIBLE"
			return
			
	print "IMPOSSIBLE"

solve()

Fixed submission:
from sets import Set

def solve():
	n, m = map(int, raw_input().split())
	to1 = Set()
	toN = Set()

	for i in range(m):
		x, y = map(int, raw_input().split())
		if x == 1:
			to1.add(y)
		if x == n:
			toN.add(y)
		if y == 1:
			to1.add(x)
		if y == n:
			toN.add(x)

	for i in range(n):
		if i in to1 and i in toN:
			print "POSSIBLE"
			return
			
	print "IMPOSSIBLE"

solve()

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
	n, m = map(int, raw_input().split())
	arr = [[0 for i in range(n+1)] for j in range(n+1)]

	for i in range(m):
		x, y = map(int, raw_input().split())
		arr[x][y] = arr[y][x] = 1

	for i in range(n):
		if arr[1][i] == 1 and arr[n][i] == 1:
			print "POSSIBLE"
			return
			
	print "IMPOSSIBLE"

solve()

Fixed submission:
from sets import Set

def solve():
	n, m = map(int, raw_input().split())
	to1 = Set()
	toN = Set()

	for i in range(m):
		x, y = map(int, raw_input().split())
		if x == 1:
			to1.add(y)
		if x == n:
			toN.add(y)
		if y == 1:
			to1.add(x)
		if y == n:
			toN.add(x)

	for i in range(n):
		if i in to1 and i in toN:
			print "POSSIBLE"
			return
			
	print "IMPOSSIBLE"

solve()
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
c = [tuple(map(int, input().split())) for _ in range(M)]
nums = []
for i in range(0, M):
    mi = list(range(c[i][0], c[i][1]+1))
    nums.append(mi)
ans = set(nums[0])
dim = nums[1:]
print(len(ans.intersection(*dim)))

Fixed submission:
N, M = map(int, input().split())
c = [tuple(map(int, input().split())) for _ in range(M)]
right = N
left = 1
for i in range(0, M):
    left = max(left, c[i][0])
    right = min(right, c[i][1])
print(len(range(left, right+1)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = eval("*".join(map(str, list(range(1, N+1)))))
ans = 1
for i in range (2, N + 1):
    num = 0
    while K % i == 0:
        num += 1
        K //= i
    ans *= (num + 1)
print(ans % (10**9 + 7))

Fixed submission:
A, B, C, D = map(int,input().split())
print(max(A*B, C*D))
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = eval("*".join(map(str,[*range(1, N+1)])))
ans = 1
for i in range (2, N + 1):
    num = 0
    while K % i == 0:
        num += 1
        K //= i
    ans *= (num + 1)

print(ans % (10**9 + 7))

Fixed submission:
N = int(input())
K = eval("*".join(map(str, list(range(1, N+1)))))
ans = 1
for i in range (2, N + 1):
    num = 0
    while K % i == 0:
        num += 1
        K //= i
    ans *= (num + 1)
print(ans % (10**9 + 7))

Buggy python submission (verdict: Runtime Error):
N = int(input())
f = lambda n: n*f(n-1) if n > 1 else 1
K = f(N)
ans = 1
for i in range (2, N + 1):
    num = 0
    while K % i == 0:
        num += 1
        K //= i
    ans *= (num + 1)

print(ans % (10**9 + 7))

Fixed submission:
N = int(input())
K = eval("*".join(map(str, list(range(1, N+1)))))
ans = 1
for i in range (2, N + 1):
    num = 0
    while K % i == 0:
        num += 1
        K //= i
    ans *= (num + 1)
print(ans % (10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
ans = 0
for X in range(K+1):
    for Y in range(K+1):
        for Z in range(K+1):
            if X+Y+Z == S:
                ans += 1
print(ans)

Fixed submission:
K, S = map(int, input().split())
ans = 0
for X in range(K+1):
    for Y in range(K+1):
        if K >= S-X-Y >= 0:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, _ = map(int, input().strip().split())
D = input().strip().split()
for ans in range(N, 100000):
    if len(set(str(ans)) & set(D)) == 0:
        print(ans)
        break

Fixed submission:
l = list(map(int, input().split()))
if (l.count(5) == 2) and (l.count(7) == 1):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
D = input().split()
ans = N
for i in range(N, 10000):
    for x in str(ans):
        if x in D:
            ans += 1
            break;
    if ans == i:
        print(ans)
        break

Fixed submission:
l = list(map(int, input().split()))
if (l.count(5) == 2) and (l.count(7) == 1):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
D = input().split()
ans = N
for i in range(N, 10000):
    for x in str(ans):
        if x in D:
            ans += 1
            break;
    else:
        print(ans)
        exit()

Fixed submission:
l = list(map(int, input().split()))
if (l.count(5) == 2) and (l.count(7) == 1):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
ans = 0
while True:
    end = 0
    for i in range(len(s) - 1):
        if len(s) == 0:
            end = 0
            break
        if s[i] != s[i + 1]:
            ans += 2
            end = 1
            del s[i:i + 2]
            break
    if end == 0:
        break
print(ans)

Fixed submission:
s = list(input())
n = len(s)
i = s.count("0")
print(min(i, n-i)*2)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
ans = 0
for i in range(s.count("W")):
    ans += s.index("W")
    s.pop(s.index("W"))
print(ans)

Fixed submission:
s = input()
ans = 0
count = 0
for i in range(len(s)):
    if s[i] == "W":
        ans += i - count
        count += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions
n, m = map(int, input().split())
s = list(input())
t = list(input())
l = n * m // fractions.gcd(n, m)
k = [""] * l
n = l // n
m = l//m
for i in range(l):
    if i % n == 0 and i % m == 0:
        if s[i//n] != t[i//m]:
            ans = -1
            break
else:
    ans = l
print(ans)

Fixed submission:
import fractions
n, m = map(int, input().split())
s = list(input())
t = list(input())
u = fractions.gcd(n, m)
l = n * m // u
n = n//u
m = m // u
for i in range(u):
    if s[i * n] != t[i * m]:
        l = -1
        break
print(l)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as bl
from bisect import bisect_right as br
n = int(input())
v = list(map(int, input().split()))
ev = []
od = []
for i in range(n):
    if i % 2 == 0:
        ev.append(v[i])
    else:
        od.append(v[i])
ev.sort()
od.sort()
m = 0
oo = [[0, 0]]
ii = [[0, 0]]
while True:
    oo.append([ev[m], br(ev, ev[m], 0, n//2)-bl(ev, ev[m], 0, n//2)])
    m += ev.count(ev[m])
    if m >= n//2:
        break
m = 0
while True:
    ii.append([od[m], br(od, od[m], 0, n//2)-bl(od, od[m], 0, n//2)])
    m += od.count(od[m])
    if m >= n//2:
        break
ii.sort(key=lambda x: x[1], reverse=True)
oo.sort(key=lambda x: x[1], reverse=True)
if ii[0][0] != oo[0][0]:
    print(n - oo[0][1] - ii[0][1])
else:
    print(min(n - oo[1][1] - ii[0][1], n - oo[0][1] - ii[1][1]))

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
ev = [0]*(max(v)+1)
od = [0]*(max(v)+1)
for i in range(n):
    if i % 2 == 0:
        ev[v[i]-1] += 1
    else:
        od[v[i] - 1] += 1
e = sorted(ev)
o = sorted(od)
if ev.index(e[-1]) == od.index(o[-1]) and e[-2] != e[-1] and o[-2] != o[-1]:
    print(n-max(e[-1]+o[-2], e[-2]+o[-1]))
else:
    print(n-e[-1]-o[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int, input().split()))
ev = []
od = []
for i in range(n):
    if i % 2 == 0:
        ev.append(v[i])
    else:
        od.append(v[i])
ev.sort()
od.sort()
m = 0
oo = [[0, 0]]
ii = [[0, 0]]
while True:
    oo.append([ev[m], ev.count(ev[m])])
    m += ev.count(ev[m])
    if m >= n//2:
        break
m = 0
while True:
    ii.append([od[m], od.count(od[m])])
    m += od.count(od[m])
    if m >= n//2:
        break
ii.sort(key=lambda x: x[1], reverse=True)
oo.sort(key=lambda x: x[1], reverse=True)
if ii[0][0] != oo[0][0]:
    print(n - oo[0][1] - ii[0][1])
else:
    print(min(n - oo[1][1] - ii[0][1], n - oo[0][1] - ii[1][1]))

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
ev = [0]*(max(v)+1)
od = [0]*(max(v)+1)
for i in range(n):
    if i % 2 == 0:
        ev[v[i]-1] += 1
    else:
        od[v[i] - 1] += 1
e = sorted(ev)
o = sorted(od)
if ev.index(e[-1]) == od.index(o[-1]) and e[-2] != e[-1] and o[-2] != o[-1]:
    print(n-max(e[-1]+o[-2], e[-2]+o[-1]))
else:
    print(n-e[-1]-o[-1])
Buggy python submission (verdict: Runtime Error):
from math import gcd
N, X = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(X)
kotae.sort()
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = gcd(t, abs(kotae[i + 1] - kotae[i]))
print(t)

Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(X)
kotae.sort()
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = gcd(t, abs(kotae[i + 1] - kotae[i]))
print(t)

Buggy python submission (verdict: Runtime Error):
import math
n, x = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(x)
kotae = sorted(kotae)
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = math.gcd(t, kotae[i + 1] - kotae[i])
print(t)

Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(X)
kotae.sort()
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = gcd(t, abs(kotae[i + 1] - kotae[i]))
print(t)

Buggy python submission (verdict: Runtime Error):
import math
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a = sorted(a)
t = 0
for i in range(n-1):
    if i == 0:
        t = a[1] - a[0]
    else:
        t = math.gcd(t, a[i + 1] - a[i])
print(t)

Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(X)
kotae.sort()
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = gcd(t, abs(kotae[i + 1] - kotae[i]))
print(t)

Buggy python submission (verdict: Runtime Error):
import math
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a.sort()
t = 0
for i in range(n):
    if i == 0:
        t = a[1] - a[0]
    else:
        t = math.gcd(t, a[i + 1] - a[i])
print(t)


Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(X)
kotae.sort()
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = gcd(t, abs(kotae[i + 1] - kotae[i]))
print(t)

Buggy python submission (verdict: Runtime Error):
import math
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a.sort()
for i in range(n):
    if i == 0:
        t = a[1] - a[0]
    else:
        t = math.gcd(t, a[i + 1] - a[i])
print(t)

Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(X)
kotae.sort()
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = gcd(t, abs(kotae[i + 1] - kotae[i]))
print(t)