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

Fixed submission:
a,b,c,d =map(int, input().split())
ans="No"
if abs(a-c)<=d:
  ans ="Yes"
if a<=b<=c or c<=b<=a:
  if abs(a-b)<=d and abs(c-b)<=d:
    ans="Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,d =map(int, input().split())
if abs(a-c)<=d:
  print("Yes")
  return
if a<=b<=c or c<=b<=a:
  if abs(a-b)<=d and abs(c-b)<=d:
    print("Yes")
    return
print("No")
Problem p03399 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a,b)+min(c,d))

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int, input().split())
print(min(a,b)+min(c,d))
Problem p02718 (python)

Fixed submission:
mn = input().split()
ob = input().split()

n = int(mn[0])
m = int(mn[1])

votes = 0

for i in range(n):
    ob[i] = int(ob[i])
    votes += ob[i]

ob.sort(reverse = True)

line = votes/4/m

ans = 0

for i in range(m):
    if ob[i] < line:
        ans += 1

if ans == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
mn = input().split()
ob = input().split()

n = int(mn[0])
m = int(mn[1])

votes = 0

for i in range(n):
    ob[i] = int(ob[i])
    votes += ob[i]

ob.sort(reverse=true)

line = votes/4/m

ans = 0

for i in range(m):
    if ob[i] <= line:
        ans += 1

if ans == 0:
    print("Yes")
else:
    print("No")
Problem p02687 (python)

Fixed submission:
i = input()
if i == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
i = input()
if i = "ABC":
  print("ARC")
else:
  print("ABC")
Problem p02924 (python)

Fixed submission:
n=int(input())
print(int(n*(n-1)//2))

Buggy submission (verdict: Runtime Error):
n=int(input())
ls=[None]*n
ls2=[None]*n
for i in range(n):
  ls[i]=i+1
  ls2[i]=i+2
ls2[-1]=1
ans = 0
for i in range(n):
  ans += ls[i]%ls2[i]
print(ans)
Problem p02945 (python)

Fixed submission:
a,b=map(int,input().split())
print(max([a+b,a-b,a*b]
          ))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max([a+b,a-b,a×b]
          ))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max(a+b,a-b,a×b))
Problem p02946 (python)

Fixed submission:
k,x=map(int,input().split())
t=[str(i) for i in range(x-k+1,x+k)]
print(" ".join(t))

Buggy submission (verdict: Runtime Error):
k,x=map(int,input().split())
t=[i for i in range(x-k+1,x+k-1)]
print(" ".join(t))
Problem p02957 (python)

Fixed submission:
A,B = map(int,input().split())
k=(A**2-B**2)/(2*A-2*B)
if k == int(k):
  print(int(k))
else:
  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
k=(A**2-B**2)/(2*A-2*B)
if k == int(k):
  print(int(k))
else:
  print(IMPOSSIBLE)
Problem p02971 (python)

Fixed submission:
import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
a_=sorted(a)
m=max(a)
for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(a_[-2])

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
m=max(a)
for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(max(a[:n].extend(a[n+1:])))

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
  print(max(a[:n]+a[n+1:])
Problem p02982 (python)

Fixed submission:
import numpy as np

n,d=map(int,input().split())
arr=[]
for i in range(n):
  arr.append(list(map(int,input().split())))
arr =np.array(arr)
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=0.5
    if k==int(k):
      ans +=1
print(ans)

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

n,d=map(int,input().split())
arr=np.array((n,d))
for i in range(n):
  arr[i]=np.array(list(map(float,input().split())))
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=np.nan
    if k==int(k):
      ans +=1
print(ans)

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

n,d=map(int,input().split())
arr=np.array(n)
for i in range(n):
  arr[i]=np.array(list(map(float,input().split())))
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=np.nan
    if k==int(k):
      ans +=1
print(ans)
Problem p02993 (python)

Fixed submission:
import sys
i = input()
i = list(map(int,list(i)))
for k in range(3):
  if i[k] == i[k+1]:
    print("Bad")
    sys.exit()
print("Good")

Buggy submission (verdict: Runtime Error):
import sys
i = int(input())
i = list(i)
for k in range(3):
  if i[k] == i[k+1]:
    print("Bad")
    sys.exit()
print("Good")
Problem p03060 (python)

Fixed submission:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
_ = 0
for j in range(N):
  if V[j] > C[j]:
    _ += V[j] - C[j]
print(_)

Buggy submission (verdict: Runtime Error):
N = int(input())
V = [int(input()) for i in range(N)]
C = [int(input()) for i in range(N)]
_ = 0
for j in range(N):
  if V[j] > C[j]:
    _ += V[j] - C[j]
print(_)
Problem p03069 (python)

Fixed submission:
N = int(input())
S = list(input())
S.insert(0,0)
# b = S.count("#")
w = S.count(".")
black = 0
white = w
ans = 2e5
for i in range(N+1):
    if S[i] == "#":
        black += 1
    elif S[i] == ".":
        white -= 1
    # print(black,white)
    ans = min(black + white, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
n_sharp = S.count("#")
n_period = S.count(".")
temp = [[], []]
k = 0
for i in range(N - 1):
    if S[i] == "#" and S[i + 1] == ".":
        temp[0].append(S[:i + 1].count("#"))
        # print(S[:i + 1], S[i + 1:])
        temp[1].append(S[i + 1:].count("."))
        k += 1
        if k == 1:
            ans = min(temp[0], temp[1])[0]
            # print((ans))
        elif k > 1:
            ans += min(abs(temp[0][k-1] - temp[0][k - 2]), abs(temp[1][k-1] - temp[1][k - 2]))

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
n_sharp = S.count("#")
n_period = S.count(".")
temp = [[], []]

for i in range(N - 1):
    if S[i] == "#" and S[i + 1] == ".":
        temp[0].append(S[:i + 1].count("#"))
        temp[1].append(S[i + 1:].count("."))
_ = len(temp[0])
ans = min(temp[0])
for i in range(_ -1):
    ans += min(abs(temp[0][i + 1] - temp[0][i]), abs(temp[1][i + 1] - temp[1][i]))
print(ans)
Problem p03101 (python)

Fixed submission:
import numpy as np

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
print((ipt[0]-cr[0])*(ipt[1]-cr[1]))

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

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
array = np.ones((ipt[0],ipt[1]),int)
for i in range(cr[0]):
  array[i] = array[i] * 0
for j in range(cr[1]):
  array[:,j] = array[:,i] * 0
print(array[array==1].sum())

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

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
array = np.ones((ipt[0],ipt[1]),int)
for i in range(cr[0]):
  array[i] = array[i] * 0
for j in range(cr[1]):
  array[:,i] = array[:,i] * 0
print(array[array==1].sum())
Problem p03494 (python)

Fixed submission:
n = int(input())
a_n = list(map(int,input().split(" ")))
k = 0
t = 0
while True:
  for i in range(len(a_n)):
    if a_n[i] % 2 == 0:
      a_n[i] = a_n[i] / 2
    else:
      t = -1
      break
  if t == -1:
    break
  k += 1
print(k)

Buggy submission (verdict: Runtime Error):

def factorization(n):
    arr = []
    temp = n
    for i in range(2,3):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)


    return arr

n=int(input())
num=list(map(factorization,list(map(int,input().split()))))
print(min(num)[0])
Problem p02812 (python)

Fixed submission:
import math

n = int(input())

s = input()
count = 0
for i in range(2, n):
    if (s[i-2] == 'A' and s[i - 1] == 'B' and s[i] == 'C'):
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())

s = input()
count = 0
for i in range(n):
    if (s[i] == 'A' and s[i + 1] == 'B' and s[i+2] == 'C'):
        count += 1

print(count)
Problem p03129 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
if n==1 and k==1:
  print('YES')
elif n <= k:
  print('NO')
elif n < ((k-1)*2+1) :
  print('NO')
else:
  print('YES')

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
k,a,b = map(int, input().split())

if a >= b:
  print(k+1)
elif k==1:
  print(b)
elif k==2:
  print(b)
elif k<=a:
  print(k+1)
else:
  t=((k+1)//(a+2))
  r=(k+1)-t*(a+2)
  if a < (b-a):
    nn = (k+1)-a
    print(nn//2*(b-a)+a+((k+1)-a)%2) 
  else:
    print(max(t*b+r,k+1))
Problem p03229 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
a=[]
for i in range(0,n):
  a.append(int(input()))
a.sort()

l = a[0]
r = a[0]

li=1
ri=len(a)-1

res = 0

while ri>=li:
  ln = abs(l-a[li])
  lx = abs(l-a[ri])
  rn = abs(r-a[li])
  rx = abs(r-a[ri])

  x = max(ln, max(lx, max(rn, rx)))
  
  if x == ln:
    res = res + ln
    l=a[li]
    li=li+1
  elif x == lx:
    res = res + lx
    l=a[ri]
    ri=ri-1
  elif x == rn:
    res = res + rn
    r=a[li]
    li=li+1
  else:
    res = res + rx
    r=a[ri]
    ri=ri-1

print(res)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import deque
n=int(input())
a=[]
for i in range(0,n):
  a.append(int(input()))
a.sort()

d = [a[0]]
a=a[1:]
b = deque(d)

f=True
while len(a)>0:
  la=len(a)-1
  lb=len(b)-1
  ln = abs(b[0]-a[0])
  lx = abs(b[0]-a[la])
  rn = abs(b[lb]-a[0])
  rx = abs(b[lb]-a[la])

  x = max(ln, max(lx, max(rn, rx)))
  
  if x == ln:
    b.insert(0,a[0])
    a=a[1:]
  elif x == lx:
    b.insert(0,a.pop())
  elif x == rn:
    b.append(a[0])
    a=a[1:]
  else:
    b.append(a.pop())
#print(b)

res=0
for i in range(0,len(b)-1):
  res=res+abs(b[i]-b[i+1])
print(res)
Problem p03633 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
l = []
for i in range(0,n):
  l.append(int(input()))
  

def gcd(x, y):
  while y:
    x, y = y, x % y
  return x
def lcm(x, y):
  return (x * y) // gcd(x, y)

res=l[0]
for i in range(1,n):
  res=lcm(res,l[i])
print(res)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
n=int(input())
l = []
for i in range(0,n):
  l.append(int(input()))
  

def lcm(x, y):
  return (x * y) // math.gcd(x, y)

res=l[0]
for i in range(1,n):
  res=lcm(res,l[i])
print(res)
Problem p03838 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 数値の読み込み
x,y = [int(i) for i in input().split()]

res = 0


if abs(y) > abs(x):
    # |x| < |y|
    if x < 0:
        res = res + 1
    if y < 0:
        res = res + 1
    res = res + abs(abs(y)-abs(x))
else :
    # x > y
    if x > 0:
        res = res + 1
    if y > 0:
        res = res + 1
    res = res + abs(abs(y)-abs(x))


print(res)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 数値の読み込み
x = int(input())
y = int(intpu())

res = 0
if x < 0:
    res = res + 1
if y < 0:
    res = res + 1

res = res + (abs(y)-abs(x))

print(res)
Problem p04031 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
n = int(input())
a = list(map(int, input().split()))

c1 = 0
c2 = 0
t1 = int(math.ceil(sum(a)/n))
t2 = int(sum(a)//n)
for i in range(0,n):
  if a[i]!=t1:
    c1=c1+(t1-a[i])*(t1-a[i])
  if a[i]!=t2:
    c2=c2+(t2-a[i])*(t2-a[i])

print(min(c1,c2))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

c = 0
t = int(sum(a)//n)
for i in range(0,N):
  if a[i]!=t:
    c=abs(t-a[i])

print(c)
Problem p03031 (python)

Fixed submission:
n,m = list(map(int,input().split()))
l_list = [list(map(int,input().split())) for i in range(m)] 
p = list(map(int,input().split()))
output = 0

for i in range(2 ** n):
  lights = []
  for j in range(n+1):
    if ((i >> j) & 1):
      lights.append(j+1)
      
  for inde, l in enumerate(l_list):
    if len(set(l[1:]) & set(lights)) % 2 != p[inde]:
      break
  else:
    output += 1
print(output)

Buggy submission (verdict: Runtime Error):
n,m = list(map(int,input().split()))
l_list = [list(map(int,input().split())) for i in range(m)] 
p = list(map(int,input().split()))
output = 0

for i in range(2 ** n):
  lights = []
  for j in range(n+1):
    if ((i >> j) & 1):
      lights.append(j+1)
      
  for l in l_list:
    if len(set(l[1:]) & set(lights)) % 2 != p[l[0]-1] or len(set(l[1:]) & set(lights)) ==0:
      break
  else:
    output += 1
print(output)

Buggy submission (verdict: Runtime Error):
n,m = list(map(int,input().split()))
l_list = [list(map(int,input().split())) for i in range(m)] 
p = list(map(int,input().split()))
output = 0

for i in range(2 ** n):
  lights = []
  for j in range(n+1):
    if ((i >> j) & 1):
      lights.append(j+1)
      
  for l in l_list:
    if len(set(l[1:]) & set(lights)) % 2 != p[l[0]-1]:
      break
  else:
    output += 1
print(output)
Problem p03449 (python)

Fixed submission:
n=int(input())
a_1 = [int(i) for i in input().split()]
a_2 = [int(i) for i in input().split()]

output = 0
for i in range(1,n+1):
    tmp = sum(a_1[:i]) + sum(a_2[i-1:])
    if tmp > output:
        output = tmp

print(output)

Buggy submission (verdict: Runtime Error):

n=input()
a_1 = [int(i) for i in input().split()]
a_2 = [int(i) for i in input().split()]

output = 0
for i in range(1,n+1):
    tmp = sum(a_1[:i]) + sum(a_2[i-1:])
    if tmp > output:
        output = tmp

print(output)
Problem p03815 (python)

Fixed submission:
x = int(input())
#2回で3~11を作れる
count = 0
if x == 7:
  count=2
  x = 0
count += (x//11)*2
x = x%11
if x==0:
  count += 0
elif x>6:
  count+=2
else:
  count += 1
print(count)

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

#2回で3~11を作れる
count = 0
if x = 7:
  print(2)

count += (x//11)*2
x = x%11
if x<7:
  count += 1
elif x>7:
  count+=2
else:
  count += 3


print(count)
Problem p03854 (python)

Fixed submission:
s = input()

import re
output ="NO"
s = re.sub('eraser', '', s)
s = re.sub('erase', '', s)
s = re.sub('dreamer', '', s)
s = re.sub('dream', '', s)
if s == "":
    output = "YES"
print(output)

Buggy submission (verdict: Runtime Error):
import re
output ="NO"
s = re.sub('dreamer', '', s)
s = re.sub('dream', '', s)
s = re.sub('eraser', '', s)
s = re.sub('erase', '', s)
if s == "":
    output = "YES"
print(output)
Problem p02658 (python)

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

s=1
if min(A) == 0:
    s = 0
    print(s)
elif max(A) > 10**18:
    s = -1
    print(s)
else:
    for i in range(N):
        s = s*A[i]
        if s > 10**18:
            s = -1
            print('-1')
            break
    if s != -1:
        print(s)

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

s=1
for i in range(N):
    s = s*A[i]
    if s > 10**18:
        s = -1
        print('-1')
        break
if s != -1:
    print(s)
Problem p02801 (python)

Fixed submission:
C = str(input())

a = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for i in range(len(a)):
    if a[i] == C:
        print(a[i+1])

Buggy submission (verdict: Runtime Error):
C = str(input())

a = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for i in len(a):
    if a[i] == C:
        print(a[i+1])
Problem p02582 (python)

Fixed submission:
s=input()
n=len(s)
c=0
li=[]
for i in range(n):
  if(s[i]=='R'):
    c=c+1
  else:
    li.append(c)
    c=0
li.append(c)
print(max(li))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
li=[]
c=0
for i in range(n):
	if(s[i]=='R'):
		c=c+1
    else:
		li.append(c)
		c=0
li.append(c)
print(max(li))
Problem p02613 (python)

Fixed submission:
n = int(input())
d = {'AC':0,'WA':0,'TLE':0,'RE':0}
for j in range(n):
    i = input()
    d[i] += 1

for i in ['AC','WA','TLE','RE']:
    print('%s x %d' % (i, d[i]))

Buggy submission (verdict: Runtime Error):
n = int(input())
d = {'AC':0,'WA':0,'TLE':0,'Re':0}
for j in range(n):
    i = input()
    d[i] += 1

for i in ['AC','WA','TLE','Re']:
    print('%s x %d' % (i, d[i]))
Problem p02630 (python)

Fixed submission:
from collections import Counter
n = int(input())
la = list(map(int, input().split()))
s = sum(la)
d = dict(Counter(la))

q = int(input())
for _ in range(q):
    b,c = map(int, input().split())
    if b in d:
        nb = d.pop(b)
    else:
        nb = 0
    delta = (c-b)*nb
    s += delta
    print(s)
    if nb > 0:
        if c in d:
            d[c] += nb
        else:
            d[c] = nb

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
la = list(map(int, input().split()))
s = sum(la)
d = dict(Counter(la))

q = int(input())
for _ in range(q):
    b,c = map(int, input().split())
    nb = d.pop(b)
    delta = (c-b)*nb
    s += delta
    print(s)
    if c in d:
        d[c] += nb
    else:
        d[c] = nb
Problem p02641 (python)

Fixed submission:
x,n = map(int, input().split())
l = list(map(int, input().split()))
l_dis = [num - x for num in l]

def s_func(x):
    if x < 0:
        return abs(x) - 0.5
    else:
        return abs(x)
    
l_dis = sorted(l_dis, key=s_func)
if len(l_dis)==0:
    print(x)
elif l_dis[0] != 0:
    print(x)
else:
    i = 1
    j = 1
    b = -1
    while True:
        if i > len(l_dis)-1 or l_dis[i] != j*b:
            print(x + j*b)
            break
        i += 1
        b *= -1
        if i > len(l_dis)-1 or l_dis[i] != j*b:
            print(x + j*b)
            break
        i += 1
        b *= -1
        j += 1

Buggy submission (verdict: Runtime Error):
x,n = map(int, input().split())
l = list(map(int, input().split()))
l_dis = [num - x for num in l]

def s_func(x):
    if x < 0:
        return abs(x) - 0.5
    else:
        return abs(x)
    
l_dis = sorted(l_dis, key=s_func)
if not l_dis:
    print(x)
elif l_dis[0] != 0:
    print(x)
else:
    i = 1
    j = 1
    b = -1
    while True:
        if l_dis[i] != j*b:
            print(x + j*b)
            break
        i += 1
        b *= -1
        if l_dis[i] != j*b:
            print(x + j*b)
            break
        i += 1
        b *= -1
        j += 1
Problem p02678 (python)

Fixed submission:
n, m = map(int,input().split())
p = [[] for x in range(n)]
r = [-2] + [-1] * (n - 1)
for _ in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    p[a].append(b)
    p[b].append(a)

from collections import deque
dq = deque()
dq.append(0)

def bfs(room):
    l = []
    global r
    for iroom in p[room]:
        if r[iroom] == -1:
            r[iroom] = room
            l.append(iroom)
    return l

while len(dq) > 0:
    c = dq.popleft()
    ll = bfs(c)
    dq.extend(ll)

if -1 in r:
    print('No')
else:
    print('Yes')
    for i in r[1:]:
        print(i+1)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
p = [[] for x in range(n)]
r = [-2] + [-1] * (n - 1)
for _ in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    p[a].append(b)
    p[b].append(a)
def bfs(room):
    global r
    l = []
    for iroom in p[room]:
        if r[iroom] == -1:
            r[iroom] = room
            l.append(iroom)
    for iroom in l:
        bfs(iroom)
bfs(0)

if -1 in r:
    print('No')
else:
    print('Yes')
    for i in r[1:]:
        print(i+1)
Problem p02727 (python)

Fixed submission:
x,y,a,b,c = map(int,input().split())
lst_r = list(map(int,input().split()))
lst_g = list(map(int,input().split()))
lst_n = list(map(lambda x:int(x)*(-1),input().split()))
from heapq import *

heapify(lst_r)
for i in range(a-x):
    _ = heappop(lst_r)

heapify(lst_g)
for i in range(b-y):
    _ = heappop(lst_g)
    
heapify(lst_n)

while len(lst_n)>0:
    flg = lst_r > lst_g
    cur = -1 * heappop(lst_n)
    if flg and cur > lst_g[0]:
        _ = heappushpop(lst_g,cur)
    elif (not flg) and cur > lst_r[0]:
        _ = heappushpop(lst_r,cur)
    else:
        break
print(sum(lst_g)+sum(lst_r))

Buggy submission (verdict: Runtime Error):
x,y,a,b,c = map(int,input().split())
lst_r = list(map(int,input().split()))
lst_g = list(map(int,input().split()))
lst_n = list(map(int,input().split()))
lst_r = sorted(lst_r, ascending=False)[:x]
lst_g = sorted(lst_g, ascending=False)[:y]
lst_all = sorted(lst_r + lst_g + lst_n, ascending=False)[:x+y]
print(sum(lst_all))

Buggy submission (verdict: Runtime Error):
x,y,a,b,c = map(int,input().split())
lst_r = list(map(int,input().split()))
lst_g = list(map(int,input().split()))
lst_n = list(map(lambda x:int(x)*(-1),input().split()))
from heapq import *

heapify(lst_r)
for i in range(a-x):
    _ = heappop(lst_r)

heapify(lst_g)
for i in range(b-y):
    _ = heappop(lst_g)
    
heapify(lst_n)

flg = lst_r > lst_g


while len(lst_n)>=0:
    cur = -1 * heappop(lst_n)
    if flg and cur > lst_g[0]:
        _ = heappushpop(lst_g,cur)
        flg = lst_r > lst_g
    elif (not flg) and cur > lst_r[0]:
        _ = heappushpop(lst_r,cur)
        flg = lst_r > lst_g
    else:
        break
print(sum(lst_g)+sum(lst_r))
Problem p02812 (python)

Fixed submission:
n = input()
s = input()
print(s.count('ABC'))

Buggy submission (verdict: Runtime Error):
n,s = input().split()
print(s.count('ABC'))
Problem p02814 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

def lcm(a,b):
    return a*b//gcd(a,b)

n,m = map(int,input().split())
l = list(map(int,input().split()))

lh = list(map(lambda x:x//2, l))
lcm = reduce(lcm,lh)
res = 0
times = [(lcm//x)%2==1 for x in lh]

if all(times):
    res = ((m // lcm) +1) // 2

print(res)

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

n,m = map(int,input().split())
l = list(map(int,input().split()))

lh = list(map(lambda x:x//2, l))
lcm = np.lcm.reduce(np.array(lh))
res = 0
times = [(lcm//x)%2==1 for x in lh]

if all(times):
    res = ((m // lcm) +1) // 2

print(res)

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

st = set()

for i in range(1,m+1):
    if test1(st,i):
        lst = [i%x==x/2 for x in a]
        if all(lst):
            st.add(i)
            break
            
f = (((m // i) - 1) //2)
print(len(st) + f)
Problem p02642 (python)

Fixed submission:
def main():

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

    A = sorted(A)
    Amax = A[-1]
    count = [0 for _ in range(Amax+1)]

    for a in A:
        for i in range(1, Amax//a+1):
            count[i*a] += 1

    ans = 0
    for i in range(N):
        a = A[i]
        if count[a] == 1:
#            print(i)                                                                                                                                            
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

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

    A = sorted(A)

    ans = 0

    for i in range(N):
        Ai = A[i]
        is_divisible = False
        for j in range(i):
            Aj = A[j]
            if Aj**2 > Ai:
                break
            if Ai%Aj == 0:
                is_divisible = True
                break
        if not is_divisible:
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()