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

Fixed submission:
a,b,c=map(int, input().split())
k=int(input())

ans="No"
for i in range(k+1):
  if a<b<c:
    ans="Yes"
  else:
    if a>=b:
      b*=2
    elif b>=c:
      c*=2


print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c=int(input())


k=int(input())

ans="no"
for i in range(k+1):
  if a<b<c:
    ans="yes"
  else:
    if a>=b:
      b*=2
    elif b>=c:
      c*=2
    else:
      c*=2

print(ans)
print(a)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
k=int(input())

ans="no"
for i in range(k+1):
  if a<b<c:
    ans="yes"
  else:
    if a>=b:
      b*=2
    elif b>=c:
      c*=2
    else:
      c*=2

print(ans)

Buggy submission (verdict: Runtime Error):
a=int(input("a?"))
b=int(input("b?"))
c=int(input("c?"))
k=int(input("k?"))

ans="no"
for i in range(k+1):
  if a<b<c:
    ans="yes"
  else:
    if a>=b:
      b*=2
    elif b>=c:
      c*=2
    else:
      c*=2

print(ans)
Problem p02602 (python)

Fixed submission:
n,k=map(int, input().split())
a=list(map(int, input().split()))

for i in range(n-k):

  if  a[i]<a[i+k]:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input("n?"))
k=int(input("k?"))
a=[int(input("a?")) for i in range(n)]
sei=[0]*(n-k+1)
for i in range(n-k+1):
  for j in range(i,i+k):
    sei[i]+=a[j]

for i in range(n-k):
  if sei[i]<sei[i+1]:
    print("yes")
  else:
    print("no")
Problem p02603 (python)

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
mon=1000
kai=0
for i in range(n-1):
  if a[i]>a[i+1]:
    mon+=kai*a[i]
    kai=0
  elif a[i]<a[i+1] and kai==0:
    kai=int(mon/a[i])
    mon-=kai*a[i]

mon+=kai*a[n-1]

print(mon)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
mon=1000
kai=0
for i in range(n-1):
  if a[i]>a[i+1] and a[i+1]>a[i+2]:
    mon+=kai*a[i]
    kai=0
  elif a[i]<a[i+1] and a[i+1]<a[i+2]:
    kai=int(mon/a[i])
    mon-=kai*a[i]

mon+=kai*a[n-1]

print(mon)

Buggy submission (verdict: Runtime Error):
k=int(input())
a=list(map(int, input().split()))
mon=1000
kai=0
for i in range(n-1):
  if a[i]>a[i+1] and a[i+1]>a[i+2]:
    mon+=kai*a[i]
    kai=0
  elif a[i]<a[i+1] and a[i+1]<a[i+2]:
    kai=int(mon/a[i])
    mon-=kai*a[i]

mon+=kai*a[n-1]

print(mon)

Buggy submission (verdict: Runtime Error):
n=int(input("n?"))
a=[int(input("a?")) for i in range(n)]
mon=1000
kai=0
for i in range(n-1):
  if a[i]>a[i+1]:
    mon+=kai*a[i]
    kai=0
  elif a[i]<a[i+1]:
    kai=int(mon/a[i])
    mon-=kai*a[i]

mon+=kai*a[n-1]

print(mon)
Problem p02640 (python)

Fixed submission:
x, y = map(int, input().split())

ans = "No"
crane = 0
while crane <= x:
  turtle = x - crane
  if 2 * crane + 4 * turtle == y:
    ans = "Yes"
  crane += 1

print(ans)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())

ans = "No"
i = 0
while i <= x:
  z = y - 2 * i
  if z == 0:
    ans = "Yes"
    break
  if z % ((x - i) * 4) == 0:
    ans = "Yes"
    break
  i += 1

print(ans)
Problem p02678 (python)

Fixed submission:
n, m = map(int, input().split())

to = [[] for _ in range(110000)]
ans = [0] * 110000
queue = []
passed = [0] * 110000
passed[1] = 1

def search(i):
  global queue
  global passed
  global ans
  for j in to[i]:
    if passed[j] == 0:
      queue.append(j)
      passed[j] = 1
      ans[j] = i
  


for _ in range(m):
  a, b = map(int, input().split())
  to[a].append(b)
  to[b].append(a)

search(1)
queue.append(1)

while queue:
  que = queue.pop(0)
  search(que)


print("Yes")
for i in ans[2:n + 1]:
  print(i)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

to = [[] for _ in range(110000)]
ans = [0] * 110000
queue = []
passed = [0] * 110000
passed[1] = 1

def search(i):
  global queue
  global passed
  global ans
  for j in to[i]:
    if passed[j] == 0:
      queue.append(j)
      passed[j] = 1
      ans[j] = i
  if queue:
    return search(queue.pop(0))
  


for _ in range(m):
  a, b = map(int, input().split())
  to[a].append(b)
  to[b].append(a)

search(1)

print("Yes")
for i in ans[2:n + 1]:
  print(i)
Problem p02582 (python)

Fixed submission:
n = 0
S = input()
for i in range(0,len(S)):
    if i==0:
        if S[i]=="R":
            n += 1
    if i==1:
        if S[i]=="R":
            n += 1
        else:
            n = 0
    if i==2:
        if S[i]=="R":
            n += 1
        else:
            continue
    if S == "RSS":
        n = 1
print(n)

Buggy submission (verdict: Runtime Error):
n = 0
S = Input()
for i in range(0,len(S)):
    if i==0:
        if S[i]=="R":
            n += 1
    if i==1:
        if S[i]=="R":
            n += 1
        else:
            n = 0
    if i==2:
        if S[i]=="R":
            n += 1
        else:
            continue
print(n)
Problem p02606 (python)

Fixed submission:
l,r,d = map(int,input().split())

cnt = 0
for i in range(l,r+1):
  if i % d == 0:
    cnt += 1
    
print(cnt)

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

for n in range(1,N+1):
  cnt = 0
  for x in range(1,int(n**0.5)):
    for y in range(1,int(n**0.5)):
      for z in range(1,int(n**0.5)):
        if x * x + y * y + z * z + x * y + y * z + z * x == n:
          cnt += 1
  print(cnt)
Problem p03164 (python)

Fixed submission:
n, w = map(int, input().split())

weights = [0]*n
values = [0]*n

for i in range(n):
    weights[i], values[i] = map(int, input().split())

v = sum(values)

dp = [[float('inf') for _ in range(v+1)] for _ in range(n+1)]

for i in range(n+1):
    dp[i][0] = 0

for i in range(1, n+1):
    for j in range(1, v+1):
        if values[i-1] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(weights[i-1] + dp[i-1][j-values[i-1]], dp[i-1][j])

for j in range(v,-1,-1):
    if dp[-1][j] <= w:
        print(j)
        break

Buggy submission (verdict: Runtime Error):
n, w = map(int, input().split())

weights = [0]*n
values = [0]*n

for i in range(n):
    weights[i], values[i] = map(int, input().split())

v = sum(values)

dp = [[float('inf') for _ in range(v+1)] for _ in range(n+1)]

for i in range(n+1):
    dp[i][0] = 0

for i in range(1, n+1):
    for j in range(1, v+1):
        if v[i] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(w[i] + dp[i-1][j-v[i]], dp[i-1][j])

for j in range(v+1):
    if dp[-1][j] == w:
        print(j)
Problem p03165 (python)

Fixed submission:
s = input()
t = input()
n, m = len(s), len(t)
dp = [[0]*(m+1) for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, m+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = n, m

ans = []

while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        ans.append(s[i-1])
        i -= 1
        j -= 1

print("".join(reversed(ans)))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
n, m = len(s), len(t)
dp = [[0]*(m+1) for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, m+1):
        if s[i] == t[j]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = n, m

ans = []

while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        ans.append(s[i])
        i -= 1
        j -= 1

print(reversed(ans))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
n, m = len(s), len(t)
dp = [[0]*(m+1) for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, m+1):
        if s[i] == t[j]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = n, m

ans = []

while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        ans.append(s[i])
        i -= 1
        j -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
def LCS(s, t):
    res = ''
    m, n = len(s), len(t)

    def rec(cur, i, j):
        nonlocal res, s, t, m, n
        if i == m or j == n:
            res = max(''.join(cur), res, key=len)
            return

        if s[i] == t[j]:
            cur.append(s[i])
            rec(cur, i+1, j+1)
            cur.pop()
        else:
            rec(cur, i+1, j)
            rec(cur, i, j+1)

    rec([], 0, 0)

    return res


if __name__ == '__main__':

    s = input()
    t = input()

    print(LCS(s, t))

Buggy submission (verdict: Runtime Error):
def LCS(s, t):
    res = ''
    m, n = len(s), len(t)

    def rec(cur, i, j):
        nonlocal res, s, t, m, n
        if i == m or j == n:
            res = max(''.join(cur), res, key=len)
            return

        if s[i] == t[j]:
            cur.append(s[i])
            rec(cur, i+1, j+1)
            cur.pop()
        else:
            rec(cur, i+1, j)
            rec(cur, i, j+1)

    rec([], 0, 0)

    return res


s = input()
t = input()

print(LCS(s, t))
Problem p04047 (python)

Fixed submission:
n = int(input())
 
arr = list(map(int, input().split()))

arr.sort()

res = 0
i=0
l = len(arr)
while i<l:
  res+=min(arr[i], arr[i+1])
  i+=2
  
print(res)

Buggy submission (verdict: Runtime Error):
from collections import Counter
 
n = int(input())
 
arr = list(map(int, input().split()))
 
counts = Counter(arr)
 
res = 0
 
for k,v in counts.items():
  if v>=2:
    res += v//2
    counts[k] = v%2
    
items = sorted(counts.items())
for i in range(len(items)-1):
  res+=min(items[i], items[i+1])
  
print(res)

Buggy submission (verdict: Runtime Error):
from collections import Counter

n = int(input())

arr = list(map(int, input().split()))

counts = Counter(arr)

res = 0

for k,v in counts.items():
  if v>=2:
    res += v//2
    counts[k] = v%2
    
items = sorted(counts.items())
for i in range(len(items)-1):
  res+=min(items[i], items[i+1])
  
return res
Problem p03161 (python)

Fixed submission:
N,K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')] * 10 ** 5

dp[0] = 0
for i in range(1, N):
  tmp = i
  if tmp > K:
    tmp = K
  for j in range(1,tmp + 1):
      dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]))

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

input = sys.stdin.readline

N,K = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [float('inf')] * N
h = np.array(h)

dp[0] = 0
for i in range(1, N):
  tmp = i
  if tmp > K:
    tmp = K
  for j in range(1,tmp + 1):
      dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]))

print(dp[N-1])
Problem p02885 (python)

Fixed submission:
num =input()
lst = num.split()
curtain = int(lst[1]) * 2
ans = int(lst[0]) - curtain

if(ans <= 0):
 print("0")
else:
 print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
num =input()
lst = num.split()
curtain = lst(1) * 2
ans = lst(0) - curtain

if(ans <= 0):
 print("0")
else:
 print(ans)
Problem p02657 (python)

Fixed submission:
a, b = map(int, input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
a = input()
n = list(map(int, input().split()))
import numpy as np
if np.prod(n) >= 10 ** 18:
  print('-1')
else:
  print(np.prod(n))

Buggy submission (verdict: Runtime Error):
a = input()
n = list(map(int, input().split()))
import numpy as np
if np.prod(n) =>10 ** 18:
  print('-1')
else:
  print(np.prod(n))
Problem p03671 (python)

Fixed submission:
import sys
a=0
b=0
c=0
x=3


v,y,z =[int(x) for x in input().split(" ")]

a = v+y
b = y+z
c = z+v

if a<b and a<c:
	print (a)

if b<c and b<a:
	print (b)

if c<b and c<a:
	print (c)

if a == b and b == c:
	print (a)

if a == b and b<c:
	print (a)

if a ==c and a<b:
	print (a)

if c==b and b<a:
	print (c)

Buggy submission (verdict: Runtime Error):
import sys
a=0
b=0
c=0
x=3


v,y,z =[int(x) for x in input().split(" ")]

a = v+y
b = y+z
c = z+v

if a<b and a<c:
	print (a)

if b<c and b<a:
	print (b)

if c<b and c<a:
	print (c)

if a=b and b=c:
	print (a)

if a=b and b<c:
	print (a)

if a=c and a<b:
	print (a)

if c=b and b<a:
	print (c)
Problem p03697 (python)

Fixed submission:
A, B = [int(x) for x in input().split(" ")]

ans= A + B

print("error" if ans >=10 else ans)

Buggy submission (verdict: Runtime Error):
import sys
i=0
j=0
k=0
t=0
m=0
s=0
lists=[]
lists2 =[]

#数値の数を受け取る
line = int(input())

#数値を受け取ってリストの作成
while i < line:
	a = int(input())
	#print (a)
	lists.insert(i,a)
	i +=1

#数値の足し合わせ
while j < line:
    s += lists[j]
    j +=1

#正しければ出力
if s%10 != 0:
	print(s)
else:
    #10の倍数以外のリスト作成
    while k < line:
        if lists[k]%10 != 0:
	        lists2.insert(m,lists[k])
	        m +=1
        k +=1
    t = min(lists2)
    print(s-t)

Buggy submission (verdict: Runtime Error):
A, B = [int(x) for x in input().split(" ")]

ans= A + B

print("error" if ans >=10 else ans)

Buggy submission (verdict: Runtime Error):
A, B = [int(x) for x in input().split(” ”)]

ans= A + B

print("error" if ans >=10 else ans)
Problem p03699 (python)

Fixed submission:
import sys
i=0
j=0
k=0
t=0
m=0
s=0
lists=[]
lists2 =[]

#数値の数を受け取る
line = int(input())

#数値を受け取ってリストの作成
while i < line:
	a = int(input())
	#print (a)
	lists.insert(i,a)
	i +=1

#数値の足し合わせ
while j < line:
    s += lists[j]
    j +=1

#正しければ出力
if s%10 != 0:
	print(s)
else:
    #10の倍数以外のリスト作成
    while k < line:
        if lists[k]%10 != 0:
	        lists2.insert(m,lists[k])
	        m +=1
        k +=1
    if lists2 !=[]:
        t = min(lists2)
        print(s-t)
    else:
    	print(0)

Buggy submission (verdict: Runtime Error):
import sys
i=0
j=0
k=0
t=0
m=0
s=0
lists=[]
lists2 =[]

#数値の数を受け取る
line = int(input())

#数値を受け取ってリストの作成
while i < line:
	a = int(input())
	#print (a)
	lists.insert(i,a)
	i +=1

#数値の足し合わせ
while j < line:
    s += lists[j]
    j +=1

#正しければ出力
if s%10 != 0:
	print(s)
else:
    #10の倍数以外のリスト作成
    while k < line:
        if lists[k]%10 != 0:
	        lists2.insert(m,lists[k])
	        m +=1
        k +=1
    t = min(lists2)
    print(s-t)

Buggy submission (verdict: Runtime Error):
import sys
i=0
j=0
k=0
t=0
m=0
s=0
lists=[]
lists2 =[]

#数値の数を受け取る
line = int(input())

#数値を受け取ってリストの作成
while i < line:
	a = int(input())
	#print (a)
	lists.insert(i,a)
	i +=1

#数値の足し合わせ
while j < line:
    s += lists[j]
    j +=1

#正しければ出力
if s%10 != 0:
	print(s)
else:
    #10の倍数以外のリスト作成
    while k < line:
        if lists[k]%10 != 0:
	        lists2.insert(m,lists[k])
	        m +=1
        k +=1
    t = min(lists2)
    print(s-t)
Problem p02584 (python)

Fixed submission:
XKD=list(input().split(' '))
X=int(XKD[0])
K=int(XKD[1])
D=int(XKD[2])
AX=abs(X)

if AX>K*D:
    print(AX-K*D)
else:
    K2=AX//D
    if (K-K2)%2==0:
        P=AX-K2*D
        print(P)
    else:
        P=abs(AX-(K2+1)*D)
        print(P)

Buggy submission (verdict: Runtime Error):
XKD=list(input().split(' '))
X=int(XKD[0])
K=int(XKD[1])
D=int(XKD[2])
AX=abs(X)

if AX>K*D:
    print(AX-K*D)
else:
    K2=AX//D
    if (K-K2)%2==0:
        P=AX-K2*D
    else:
        P=abs(AX-(K2+1)*D)
print(P)
Problem p02628 (python)

Fixed submission:
m, k = map(int, input().split())
array = list(map(int, input().split()))

array.sort()
print(sum(array[:k]))

Buggy submission (verdict: Runtime Error):
m, k = map(int, input(.split()))
array = list(map(int, input().split()))

array.sort()
print(sum(array[:k]))
Problem p02640 (python)

Fixed submission:
x, y = map(int, input().split())

for kame in range(0, x+1):
    tsuru = x - kame
    legs = kame * 4 + tsuru * 2
    if legs == y:
        print("Yes")
        break
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x, y = input().split()

for kame in range(0, x+1):
    tsuru = x - kame
    legs = kame * 4 + tsuru * 2
    if legs == y:
        print("Yes")
        break
else:
    print("No")
Problem p02700 (python)

Fixed submission:
heart_taka, power_taka, heart_aoki, power_aoki = map(int, input().split())

aliveTaka = True
aliveAoki = True
while (aliveTaka) and (aliveAoki):
    heart_aoki -= power_taka
    heart_taka -= power_aoki
    if heart_aoki <= 0:
        aliveAoki = False
    if heart_taka <= 0:
        aliveTaka = False

if aliveAoki == False:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
heart_taka, power_taka, heart_aoki, power_aoki = map(int, input().split())

aliveTaka = True
aliveAoki = True
while (aliveTaka) or (aliveAoki):
    heart_aoki -= power_taka
    heart_taka -= power_aoki
    if heart_aoki <= 0:
        aliveAoki = False
    if heart_taka <= 0:
        aliveTaka = False

if aliveAoki == False:
    return "Yes"
return "No"
Problem p02717 (python)

Fixed submission:
X,Y,Z=map(int,input().split(" "))
tmp=Y
Y=X
X=tmp
tmp=Z
Z=X
X=tmp
print(X,Y,Z,end=" ")

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split(" "))
if abs(N)%K==0:
  print(1)
else:
  M=abs(N)%K
  S=abs(M-K)
print(min(M,S))
Problem p02812 (python)

Fixed submission:
N=int(input())
S=input()
c=0
if len(S)>2:
  for i in range(1,N-1):
    if S[i-1]=="A" and S[i]=="B" and S[i+1]=="C":
      c+=1
print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
c=0
if len(S)>2:
  for i in range(1,N):
    if S[i-1]=="A" and S[i]=="B" and S[i+1]=="C":
      c+=1
print(c)

Buggy submission (verdict: Runtime Error):
#-*- coding:utf-8 -*-
N=int(input())
S=input()
c=0
for i in range(N):
  if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
c=0
for i in range(N):
  if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
    c+=1
print(c)
Problem p03126 (python)

Fixed submission:
import numpy as np
n, m = map(int, input().split())
A = []
for _ in range(n):
  __ = input().split()
  A.append(np.array(__, dtype=int))
ans = []
for i in range(m):
  ans.append(i+1)
_ans = ans.copy()
for a in A:
  for i in range(len(ans)):
    if not ans[i] in a[1:]:
      _ans.remove(ans[i])
  ans = _ans.copy()
  
print(len(_ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
n, m = map(int, input().split())
A = []
for _ in range(n):
  __ = input().split()
  A.append(np.array(__, dtype=int))
ans = []
for i in range(m):
  ans.append(i+1)
_ans = ans.copy()
for a in A:
  for i in range(len(ans)):
    if not ans[i] in a[1:]:
      _ans.remove(ans[i])
print(len(_ans))
Problem p02606 (python)

Fixed submission:
L,R,d = map(int,input().split())
print(int(R/d)-int((L-1)/d))

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i;
      if v<10050:
        ans[v]+=1

for i in range(n):
  print(ans[i+1])
Problem p02582 (python)

Fixed submission:
S = input()

if "RRR" in S:
    ans = 3

elif "RR" in S:
    ans = 2
    
elif "R" in S:
    ans = 1
else:
    ans = 0
    
print(ans)

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

if "RRR" in S:
    ans = 3

elif "RR" in S:
    ans = 2
    
elif "R" in S:
    ans = 1
    
print(ans)
Problem p02981 (python)

Fixed submission:
n,a,b = map(int,input().split())

print(min(n*a,b))

Buggy submission (verdict: Runtime Error):
n,a.b = map(int,input().split())

print(min(n*a,b))
Problem p03244 (python)

Fixed submission:
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)

lsacnt = sorted(acnt.items(), key=lambda x: x[1],reverse=True)
lsbcnt = sorted(bcnt.items(), key=lambda j: j[1],reverse=True)

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

if lsacnt[0][0] != lsbcnt[0][0]:
	ans = n - lsacnt[0][1] - lsbcnt[0][1]
elif lsacnt[0][0] == lsbcnt[0][0]:
	if lsacnt[0][1] > lsbcnt[0][1]:
		ans = n - lsacnt[0][1] - val(bcnt,lsbcnt)
	elif lsacnt[0][1] < lsbcnt[0][1]:
		ans = n - val(acnt,lsacnt) - lsbcnt[0][1]
	elif lsacnt[0][1] == lsbcnt[0][1]:
		ans = n - lsacnt[0][1] - max(val(acnt,lsacnt),val(bcnt,lsbcnt))

print(ans)

Buggy submission (verdict: Runtime Error):
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)

lsacnt = sorted(acnt.items(), key=lambda x: x[1],reverse=True)
lsbcnt = sorted(bcnt.items(), key=lambda j: j[1],reverse=True)

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

if lsacnt[0][0] != lsbcnt[0][0]:
	ans = n - lsacnt[0][1] - lsbcnt[0][1]
elif lsacnt[0][0] == lsbcnt[0][0]:
	if lsacnt[0][1] > lsbcnt[0][1]:
		ans = n - lsacnt[0][1] - val(bcnt,lsbcnt)
	elif lsacnt[0][1] < lsbcnt[0][1]:
		ans = n - val(acnt,lsacnt) - lsbcnt[0][1]
	elif lsacnt[0][1] == lsbcnt[0][1]:
		ans = n - lsacnt[0][1] - max(lsacnt[1][1],lsbcnt[1][1])

print(ans)

Buggy submission (verdict: Runtime Error):
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)

lsacnt = sorted(acnt.items(), key=lambda x: x[1])
lsbcnt = sorted(bcnt.items(), key=lambda y: y[1])

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

if lsacnt[0][0] != lsbcnt[0][0]:
	ans = n - lsacnt[0][1] - lsbcnt[0][1]
elif lsacnt[0][0] == lsbcnt[0][0]:
	if lsacnt[0][1] >= lsbcnt[0][1]:
		ans = n - lsacnt[0][0] - val(bcnt,lsbcnt)
	else:
		ans = n - val(acnt,lsbcnt) - lsbcnt[0][0]

print(ans)

Buggy submission (verdict: Runtime Error):
n = 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)
Problem p03282 (python)

Fixed submission:
s = list(map(int, input()))
k = int(input())

i=0

while i <= k-1:
	if s[i] == 1:
		ans = 1
		i += 1
	else:
		ans = s[i]
		break

print(ans)

Buggy submission (verdict: Runtime Error):
s = list(map(int, input()))
k = int(input())

ans = 1

for i in range(len(min(s,k))):
	if s[i] != 1:
		ans = s[i]
		break

print(ans)

Buggy submission (verdict: Runtime Error):
s = list(map(int, input()))
k = int(input())

ans = 1

for i in range(len(k)):
	if s[i] != 1:
		ans = s[i]
		break

print(ans)

Buggy submission (verdict: Runtime Error):
s = list(map(str, input()))
k = int(input())

i=0

while i <= k:
	if s[i] =='1':
		ans = 1
		i += 1
	else:
		ans = s[i]
		break

print(ans)