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

Fixed submission:
n,k=map(int,input().split())
d=dict()
for i in map(int,input().split()):
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
m=list(d.values())
m.sort()
a=len(m)-k
ans=0
for i in m:
  if a<=0:
    break
  a-=1
  ans+=i
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=dict()
for i in map(int,input().split()):
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
m=list(d.keys())
m.sort()
n-=k
for i in m:
  if n<=0:
    break
  n-=d[i]
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=dict()
for i in map(int,input().split()):
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
m=d.keys()
m.sort()
n-=k
for i in m:
  if n<=0:
    break
  n-=d[i]
  ans+=1
print(ans)
Problem p03523 (python)

Fixed submission:
s=input()
ans=1

i=0
if i<len(s) and s[i]=="A":
  i+=1
if i<len(s) and s[i]=="K":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="I":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="H":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="A":
  i+=1
if i<len(s) and s[i]=="B":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="A":
  i+=1
if i<len(s) and s[i]=="R":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="A":
  i+=1
if i!=len(s):
  ans=0

if ans:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
s=input()
ans=1

i=0
if s[i]=="A":
  i+=1
if s[i]=="K":
  i+=1
else:
  ans=0
if s[i]=="I":
  i+=1
else:
  ans=0
if s[i]=="H":
  i+=1
else:
  ans=0
if s[i]=="A":
  i+=1
if s[i]=="B":
  i+=1
else:
  ans=0
if s[i]=="A":
  i+=1
if s[i]=="R":
  i+=1
else:
  ans=0
if s[i]=="A":
  i+=1
if i!=len(s):
  ans=0

if ans:
  print("YES")
else:
  print("NO")
Problem p03559 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
i,j,k=0,0,0
m1=[]
while k<n and i<n:
  if b[i]>a[k]:
    j+=1
    k+=1
  else:
    m1.append(j)
    i+=1
for t in range(len(m1),len(b)):
  m1.append(j)
i,j,k=0,0,0
m2=[]
while k<n and i<n:
  if c[i]>b[k]:
    j+=m1[k]
    k+=1
  else:
    m2.append(j)
    i+=1
for t in range(len(m2),len(c)):
  m2.append(j)
print(sum(m2))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
i,j=0,0
m1=[]
for k in a:
  if b[i]>k:
    j+=1
  else:
    m1.append(j)
for t in range(len(m1),len(b)):
  m1.append(j)
i,j=0,0
m2=[]
for k in range(n):
  if c[i]>k:
    j+=m1[b[k]]
  else:
    m2.append(j)
for t in range(len(m2),len(c)):
  m2.append(j)
print(sum(m2))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a=list(set(a))
b=list(set(b))
c=list(set(c))
a.sort()
b.sort()
c.sort()
i,j=0,0
d1=dict()
for k in a:
  if b[i]>k:
    j+=1
  else:
    d1[b[i]]=j
    i+=1
for t in range(i,len(b)):
  d1[b[t]]=j
i,j=0,0
d2=dict()
for k in b:
  if c[i]>k:
    j+=d1[k]
  else:
    d2[c[i]]=j
    i+=1
for t in range(i,len(c)):
  d2[c[t]]=j
print(sum(d2.values()))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a=list(set(a))
b=list(set(b))
c=list(set(c))
a.sort()
b.sort()
c.sort()
i,j=0,0
d1=dict()
for k in a:
  if b[i]>k:
    j+=1
  else:
    d1[b[i]]=j
    i+=1
for t in range(i,n):
  d1[b[t]]=j
i,j=0,0
d2=dict()
for k in b:
  if c[i]>k:
    j+=d1[k]
  else:
    d2[c[i]]=j
    i+=1
for t in range(i,n):
  d2[c[t]]=j
print(sum(d2.values()))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
i,j=0,0
d1=dict()
for k in a:
  if b[i]>k:
    j+=1
  else:
    d1[b[i]]=j
    i+=1
    j=0
i,j=0,0
d2=dict()
for k in b:
  if c[i]>k:
    j+=d1[k]
  else:
    d2[c[i]]=j
    i+=1
    j=0
print(sum(d2.values()))
Problem p03567 (python)

Fixed submission:
print('YNeos'[not'AC'in input()::2])

Buggy submission (verdict: Runtime Error):
print('YNeos'['AC'in input()::2]
Problem p03578 (python)

Fixed submission:
n=int(input())
d=dict()
for a in map(int,input().split()):
  if a not in d:
    d[a]=1
  else:
    d[a]+=1
m=int(input())
t=dict()
for a in map(int,input().split()):
  if a not in t:
    t[a]=1
  else:
    t[a]+=1
  if a not in d:
    d[a]=0
ans="YES"
for i in t.keys():
  if not t[i]<=d[i]:
    ans="NO"
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=dict()
for a in map(int,input().split()):
  if a not in d:
    d[a]=1
  else:
    d[a]+=1
m=int(input())
t=dict()
for a in map(int,input().split()):
  if a not in t:
    t[a]=1
  else:
    t[a]+=1
ans="YES"
for i in t.keys():
  if not t[i]==d[i]:
    ans="NO"
print(ans)
Problem p03591 (python)

Fixed submission:
print('YNeos'[input()[:4]!='YAKI'::2])

Buggy submission (verdict: Runtime Error):
print('YNEOS'[if input()[:4]!='YAKI'::2])
Problem p03597 (python)

Fixed submission:
print(int(input())**2-int(input()))

Buggy submission (verdict: Runtime Error):
print(int(input)**2-int(input()))
Problem p03598 (python)

Fixed submission:
n=int(input())
k=int(input())
ans=0
for a in map(int,input().split()):
  ans+=min(a,k-a)
print(ans+ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
ans=0
for _ in map(int,input().split()):
  a=int(input())
  ans+=min(a,k-a)
print(ans+ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
ans=0
for _ in map(int,input()):
  a=int(input())
  ans+=min(a,k-a)
print(ans+ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
ans=0
for _ in range(n):
  a=int(input())
  ans+=min(a,k-a)
print(ans)
Problem p03605 (python)

Fixed submission:
if '9' in input():
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if '9'.in input():
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if '9'.in(input()):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if input().in('9'):
  print("Yes")
else:
  print("No")
Problem p03624 (python)

Fixed submission:
s=input()
m=[0 for i in range(26)]
for i in range(len(s)):
  m[ord(s[i])-97]=1
a=0
for i in range(26):
  if m[i]==0:
    print(chr(i+97))
    a=1
    break
if a==0:
  print("None")

Buggy submission (verdict: Runtime Error):
s=input()
m=[0 for i in range(26)]
for i in range(len(s)):
  m[ord(s[i])-97]=1
a=0
for i in range(len(s)):
  if m[i]==0:
    print(chr(i+97))
    a=1
    break
if a==0:
  print("None")

Buggy submission (verdict: Runtime Error):
s=input()
m=[0 for i in range(26)]
for i in range(len(s)):
  m[ord(s[i])-97]=1
for i in range(len(s)):
  if m[i]==0:
    print(chr(i+97))
    break
Problem p03627 (python)

Fixed submission:
n=int(input())
d=dict()
for i in map(int,input().split()):
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
ans=[0,0]
for i in d.keys():
  for _ in range(d[i]//2):
    ans.append(i)
ans.sort(reverse=1)
print(ans[0]*ans[1])

Buggy submission (verdict: Runtime Error):
n=int(input())
d=dict()
for i in map(int,input().split()):
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
ans=[]
for i in d.keys():
  for _ in range(d[i]//2):
    ans.append(i)
ans.sort(reverse=1)
print(ans[0]*ans[1])
Problem p03633 (python)

Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

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

ans=1
for i in T:
    ans = lcm(ans,i)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for _ in range(N)]
def gcd(a, b):
	while b:
        a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd(a, b)
l = 1
for i in T:
    l = lcm(l, i)
print(l)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(input() for _ in range(N))]

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

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

ans=1
for i in range(T):
    ans = lcm(ans,i)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(input() for _ in range(N))]

def gcd(a,b):
    while b:
        a,b=b,a%b
    return b

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

ans=1
for i in range(T):
    ans = lcm(ans,i)
    
print(ans)
Problem p03639 (python)

Fixed submission:
n=int(input())
m=list(map(int,input().split()))
for i in range(n):
  a=0
  while m[i]%2==0:
    m[i]//=2
    a+=1
  if a>2:
    a=2
  m[i]=a
if m.count(2)>=m.count(0):
  print("Yes")
elif m.count(0)==0:
  print("Yes")
elif m.count(1)==0 and m.count(2)>=m.count(0)-1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
m=list(map(int,input().split()))
for i in range(n):
  a=0
  for m[i]>1:
    m[i]//=2
    a+=1
  if a>2:
    a=2
  m[i]=a
if m.count(2)>m.count(1):
  print("Yes")
else:
  print("No")
Problem p03658 (python)

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=1)
print(sum(l[:k]))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=[int(input())for i in range(n)]
l.sort(reverse=1)
print(sum(l[:k]))
Problem p03665 (python)

Fixed submission:
n,p=map(int,input().split())
l=list(map(lambda x:int(x)%2,input().split()))
a,b=0,0
for i in l:
  if i>0:
    a+=1
  else:
    b+=1
if a==0:
  if p==0:
    print(2**n)
  else:
    print(0)
else:
  print(2**(n-1))

Buggy submission (verdict: Runtime Error):
n,p=map(int,input().split())
l=list(map(lambda x:int(x)%2,input().split()))
a,b=0,0
for i in l:
  if l%2>0:
    a+=1
  else:
    b+=1
if a==0:
  if p==0:
    print(2**n)
  else:
    print(0)
else:
  print(2**(n-1))
Problem p03673 (python)

Fixed submission:
n=int(input())
a=input().split()
ans=""
for i in range(n-1,-1,-2):
  ans+=a[i]+" "
for i in range(n%2,n,2):
  ans+=a[i]+" "
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=input()
ans=""
for i in range(n-1,-1,-2):
  ans+=a[i]
for i in range(n%a,n,2):
  ans+=a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=input().split()
ans=""
for i in range(n-1,-1,-2):
  ans+=a[i]
for i in range(n%a,n,2):
  ans+=a[i]
print(ans)
Problem p03680 (python)

Fixed submission:
n=int(input())
d=[int(input())-1for i in range(n)]
s=set()
s.add(0)
ans=0
b=0
while 1>0:
  if d[b] in s:
    ans=-1
    break
  b=d[b]
  s.add(b)
  ans+=1
  if b==1:
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=[int(input())-1for i in range(n)]
s=set(0)
ans=0
b=0
while 1>0:
  if d[b] in s:
    ans=-1
    break
  b=d[b]
  s.add(b)
  ans+=1
  if b==1:
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=[int(input())-1for i in range(n)]
s=set(0)
ans=0
b=0
while 1>0:
  if d[b] in s:
    ans=-1
    break
  b=d[b]
  s+=d[b]
  ans+=1
  if b==1:
    break
print(ans)
Problem p03697 (python)

Fixed submission:
a,b=map(int,input().split())
if a+b>9:
  print("error")
else:
  print(a+b)

Buggy submission (verdict: Runtime Error):
a,b=wap(int,input().split())
if a+b>9:
  print("error")
else:
  print(a+b)
Problem p03698 (python)

Fixed submission:
s=input()
a=set()
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a.add(s[i])
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
a={}
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a.add(s[i])
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
a={}
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a=a|{s[i]}
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
a={}
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a+={s[i]}
print(ans)
Problem p03733 (python)

Fixed submission:
n,t=map(int,input().split())
ans=0
k=1000000000
for i in map(int,input().split()):
  ans+=min(t,max(i-k,0))
  k=i
ans+=t
print(ans)

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
k=1000000000
for i in map(int,input().split()):
  ans+=min(t,max(i-k,0))
  k=i
ans+=t
print(ans)
Problem p03830 (python)

Fixed submission:
n=int(input())
d=dict()
for i in range(1,n+1):
  for j in range(1,i+1):
    if j==1:
      continue
    while i%j==0:
      if j not in d:
        d[j]=1
      else:
        d[j]+=1
      i//=j
ans=1
for i in d.values():
  ans*=i+1
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=dict()
m=[2,3,5,7,11,13,17,19,23,29,31]
for i in m:
  d[i]=0
  nn=n
  while nn:
    d[i]+=nn//i
    nn//=i
ans=1
for i in dict.values():
  ans*=i+1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=dict()
if n==1:
  print(1)
else:
  for i in range(2,n+1):
    for j in range(2,i+1):
      if i%j==0:
        if j not in d:
          d[i]=1
        else:
          d[i]+=1
  ans=1
  for i in d.values():
    ans*=i+1
  print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=dict()
if n==1:
  print(1)
else:
  for i in range(2,n+1):
    for j in range(2,i+1):
      if i%j==0:
        if j not in d:
          d[i]=1
        else:
          d[i]+=1
  ans=1
  for i in d.values():
    ans*=i+1
Problem p03848 (python)

Fixed submission:
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  if m[i]!=2:
    ans=0
if m[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  if d[i]!=2:
    ans=0
if d[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  d[i]!=2:
    ans=0
if d[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)
Problem p03919 (python)

Fixed submission:
h,w=map(int,input().split())
for i in range(h):
  a=input()
  if 'snuke' in a:
    b=a.find('snuke')
    break
print(chr(ord('A')+b//6)+str(i+1))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
for i in range(h):
  a=input()
  if 'snuke' in a:
    b=a.find('snuke')
    break
print(chr(ord('A')+b)+str(a+1))
Problem p03958 (python)

Fixed submission:
k,t=map(int,input().split())
l=list(map(int,input().split()))
if len(l)==1:
  print(k-1)
else:
  if k%2==0:
    print(max(0,(max(l)-k//2)*2-1))
  else:
    print(max(0,(max(l)-k//2-1)*2))

Buggy submission (verdict: Runtime Error):
k,t=map(int,input().split())
l=list(map(int,input().split()))
if len(l)==n:
  print(n-1)
else:
  print(max(0,max(l)//2-n))

Buggy submission (verdict: Runtime Error):
k,t=wap(int,input().split())
l=list(map(int,input().split()))
print(max(0,max(l)//2-n))
Problem p03999 (python)

Fixed submission:
n=input()
m=[[]for _ in range(len(n))]
m[0]+=[[0,int(n[0])]]
for i in range(1,len(n)):
  a=int(n[i])
  for m0,m1 in m[i-1]:
    m[i]+=[[m0+m1,a]]
    m[i]+=[[m0,m1*10+a]]
ans=0
for m0,m1 in m[len(n)-1]:
  ans+=m0+m1
print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
m=[[]for _ in range(n)]
m[0]+=[[0,int(n[0])]]
for i in range(1,len(n)):
  a=int(n[i])
  for m0,m1 in m[i-1]:
    m[i]+=[[m0+m1,a]]
    m[i]+=[[m0,m1*10+a]]
ans=0
for m0,m1 in m[len(n)-1]:
  ans+=m0+m1
print(ans)
Problem p04025 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
s=sum(l)/n
if s-int(s)<int(s)+1-s:
  s=int(s)
else:
  s=int(s)+1
ans=0
for i in l:
  ans+=(s-i)**2
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(input()) for i in range(n)]
s=sum(l)/n
if s-int(s)<int(s)+1-s:
  s=int(s)
else:
  s=int(s)+1
ans=0
for i in l:
  ans+=(s-i)**2
print(ans)
Problem p04033 (python)

Fixed submission:
a,b=map(int,input().split())
if a*b<=0:
  print("Zero")
else:
  if a>0 or (b-a)%2>0:
    print("Positive")
  else:
    print("Negative")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a*b<=0::
  print("Zero")
else:
  if a>0 or (b-a)%2>0:
    print("Positive")
  else:
    print("Negative")
Problem p04044 (python)

Fixed submission:
n,l=map(int,input().split())
s =[]
for _ in range(n):
    t = input()
    s +=[t]

s.sort()

ans =""
for x in s:
    ans +=x

print(ans)

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
s =[]
for _ in range(n):
    t = input()
    s +=[t]

def dic(a,b):
    for i in range(l):
        if ord(a[i])<ord(b[i]):
            c =0
            break
        if ord(b[i])<ord(a[i]):
            c =1
            break
    return c

for i in range(1,n):
    for j in range(i):
        j = i - j
        if dic(s[j-1],s[j]):
            s[j],s[j-1]=s[j-1],s[j]
        else:
            break       

ans =""
for x in s:
    ans +=x

print(ans)
Problem p04045 (python)

Fixed submission:
n,k=map(int,input().split())
m=list(map(int,input().split()))
for i in range(n,100000):
  k=1
  for a in str(i):
    if int(a) in m:
      k=0
  if k:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in range(10):
  if i not in a:
    m.append(i)
k=0
for a in m:
  for b in m:
    for c in m:
      for d in m:
        for e in m:
        num=a*10000+b*1000+c*100+d*10+e
        if k==0 and num>=n:
          print(num)
          k=1

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in range(10):
  if i not in a:
    m.append(i)
k=0
for a in m:
  for b in m:
    for c in m:
      for d in m:
        num=a*1000+b*100+c*10+d
        if k==0 and num>=n:
          ans=num
          k=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in [0,1,2,3,4,5.6,7,8,9]:
  if i not in a:
    m.append(i)
k=0
for a in m:
  for b in m:
    for c in m:
      for d in m:
        num=a*1000+b*100+c*10+d
        if k==0 and num>=n:
          ans=num
          k=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in [0,1,2,3,4,5.6,7,8,9]:
  if i not in a:
    m.append(i)
k=0
for a in m:
  for b in m:
    for c in m:
      for d in m:
        if k:
          break
        num=a*1000+b*100+c*10+d
        if num>=n:
          ans=num
          k=1
print(ans)
Problem p02727 (python)

Fixed submission:
import heapq
 
X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
heapq.heapify(P)
heapq.heapify(Q)
i = 0
while(True):
    if P[0] >= R[i] and Q[0] >= R[i]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[i]:
            heapq.heappop(Q)
            heapq.heappush(Q, R[i])
    else:
        if P[0] < R[i]:
            heapq.heappop(P)
            heapq.heappush(P, R[i])
    i += 1
    if i == len(R):
        break
print(sum(P) + sum(Q))

Buggy submission (verdict: Runtime Error):
 
X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
heapq.heapify(P)
heapq.heapify(Q)
i = 0
while(True):
    if P[0] >= R[i] and Q[0] >= R[i]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[i]:
            heapq.heappop(Q)
            heapq.heappush(Q, R[i])
    else:
        if P[0] < R[i]:
            heapq.heappop(P)
            heapq.heappush(P, R[i])
    i += 1
    if i == len(R):
        break
print(sum(P) + sum(Q))

Buggy submission (verdict: Runtime Error):
 
X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
heapq.heapify(P)
heapq.heapify(Q)
i = 0
while(True):
    if P[0] >= R[i] and Q[0] >= R[i]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[i]:
            heapq.heappop(Q)
            heapq.heappush(Q, R[i])
    else:
        if P[0] < R[i]:
            heapq.heappop(P)
            heapq.heappush(P, R[i])
    i += 1
    if i == len(R):
        break
print(sum(P) + sum(Q))

Buggy submission (verdict: Runtime Error):
import heapq

X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
heapq.heapify(P)
heapq.heapify(Q)

while(True):
    if P[0] >= R[0] and Q[0] >= R[0]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[0]:
            heapq.heappop(Q)
            heapq.heappush(Q, R[0])
    else:
        if P[0] < R[0]:
            heapq.heappop(P)
            heapq.heappop(P, R[0])
    R = R[1:]
    if len(R) == 0:
        break
print(sum(P) + sum(Q))
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
tmp = None
for i,j in enumerate(S):
    if not j == "1":
        tmp = i+1
        break
if tmp == None:
    print("1")
elif K < tmp:
    print("1")
else:
    print(j)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
for i,j in enumerate(S):
    if not j == "1":
        tmp = i+1
        break
if K < tmp:
    print("1")
else:
    print(j)
Problem p03289 (python)

Fixed submission:
S = input()
flag = False
if S[0] == "A":
    count = 0
    for i,j in enumerate(S[2:-1]):
        if j == "C":
            count+=1
            ind = i+2
    if count == 1:
        tmp = S[1:ind]+S[ind+1:]
        if tmp == tmp.lower():
            flag = True
            
if flag:
    print("AC")
else:
    print("WA")

Buggy submission (verdict: Runtime Error):
S = input()
flag = False
if S[0] == "A":
    count = 0
    for i,j in enumerate(S[2:-1]):
        if j == "C":
            count+=1
            ind = i+2
    if count == 1:
        tmp = S[1:ind]+A[ind+1:]
        if tmp == tmp.lower():
            flag = True
            
if flag:
    print("AC")
else:
    print("WA")
Problem p03294 (python)

Fixed submission:
from fractions import gcd
def lcm(a, b):return a * b // gcd(a,b)
N = int(input())
A = [int(i) for i in input().split()]
B = lcm(A[0],A[1])
ans = 0
for i in A:
    B = lcm(B,i)
for i in A:
    ans += (B-1)%i
print(ans)

Buggy submission (verdict: Runtime Error):
from fraction import gcd
def lcm(a, b):return a * b // gcd(a,b)
N = int(input())
A = [int(i) for i in input().split()]
B = lcm(A[0],A[1])
ans = 0
for i in A:
    B = lcm(B,i)
for i in A:
    ans += (B-1)%i
print(ans)
Problem p03323 (python)

Fixed submission:
A,B = [int(i) for i in input().split()]
if A<9 and B<9:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
from collections import deque
N = int(input())
A = [int(i) for i in input().split()]

d = deque(A)
c = 0
while(len(d)>0):
    tmp = d.pop()
    if tmp%2==0:
        c+=1
        d.append(tmp//2)
print(c)
Problem p03325 (python)

Fixed submission:
from collections import deque
N = int(input())
A = [int(i) for i in input().split()]

d = deque(A)
c = 0
while(len(d)>0):
    tmp = d.pop()
    if tmp%2==0:
        c+=1
        d.append(tmp//2)
print(c)

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

d = deque(A)
c = 0
while(len(d)>0):
    tmp = d.pop()
    if tmp%2==0:
        c+=1
        d.append(tmp//2)
print(c)

Buggy submission (verdict: Runtime Error):
from collections import deque
from collections import namedtuple

N = int(input())
A = [int(i) for i in input().split()]
Prog = namedtuple("Prog","p,c")
d = deque([(deque(A),0)])
ans = 0
while(len(d)>0):
    tmp = d.pop()
    tmp2 = deque()
    for i in gen(tmp[0]):
        tmp2.appendleft(i.p)
    tmp2.pop()
    if len(tmp2) < 1:
        if ans < tmp[1]:
            ans = tmp[1]
    else:
        for i in tmp2:
            d.appendleft((i,tmp[1]+1))
print(ans)