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

Fixed submission:
def resolve():
    n,m=map(int,input().split())
    py=[[0]*3 for _ in range(m)]
    for i in range(m):
        p,y=map(int,input().split())
        py[i][0],py[i][1],py[i][2]=p,y,i
    py.sort()
    ans=[[''] for _ in range(m)]
    cnt=[0]*(n+1)
    for p,y,i in py:
        cnt[p]+=1
        ans[i]='0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(cnt[p])))+str(cnt[p])
    for i in ans:
        print(i)


if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    n,m=map(int,input().split())
    py=[[0]*3 for _ in range(m)]
    for i in range(m):
        p,y=map(int,input().split())
        py[i][0],py[i][1],py[i][2]=p,y,i
    py.sort()
    ans=[[''] for _ in range(m)]
    cnt=[0]*n
    for p,y,i in py:
        cnt[p]+=1
        ans[i]='0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(cnt[p])))+str(cnt[p])
    for i in ans:
        print(i)


if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
py=[[0]*3 for _ in range(m)]
for i in range(m):
    p,y=map(int,input().split())
    py[i][0],py[i][1],py[i][2]=p,y,i
py.sort()
ans=[[''] for _ in range(m)]
cnt=[0]*m
for p,y,i in py:
    cnt[p]+=1
    ans[i]='0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(cnt[p])))+str(cnt[p])
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
py=[[0]*3 for _ in range(m)]
for i in range(m):
    p,y=map(int,input().split())
    py[i][0],py[i][1],py[i][2]=p,y,i
py.sort()
ans=[[''] for _ in range(m)]
cnt=[0]*m
for p,y,i in py:
    cnt[p]+=1
    ans[i]='0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(cnt[p])))+str(cnt[p])
ans.sort()
for i in ans:
    print(i)
Problem p03634 (python)

Fixed submission:
from collections import deque
n=int(input())
e=[[] for _ in range(n+1)]
dist=[-1]*(n+1)
for i in range(n-1):
    a,b,c=map(int,input().split())
    e[a].append((b,c))
    e[b].append((a,c))
q,k=map(int,input().split())
a=deque()
a.append((k,0))
while a:
    x,d=a.popleft()
    dist[x]=d
    for j,nc in e[x]:
        if dist[j]!=-1:
            continue
        else:
            a.append((j,d+nc))
ans=[]
for i in range(q):
    x,y=map(int,input().split())
    ans.append(dist[x]+dist[y])
print(*ans,sep="\n")

Buggy submission (verdict: Runtime Error):
from collections import deque
n=int(input())
e=[[] for _ in range(n+1)]
l=[[0]*(n+1) for _ in range(n+1)]
dist=[-1]*(n+1)
for i in range(n-1):
    a,b,c=map(int,input().split())
    e[a].append(b)
    e[b].append(a)
    l[a][b]=c
    l[b][a]=c
q,k=map(int,input().split())
a=deque()
a.append((k,0))
while a:
    x,d=a.popleft()
    dist[x]=d
    for j in e[x]:
        if dist[j]!=-1:
            continue
        else:
            a.append((j,d+l[x][j]))
ans=[]
for i in range(q):
    x,y=map(int,input().split())
    ans.append(dist[x]+dist[y])
print(*ans,sep="\n")
Problem p02829 (python)

Fixed submission:
A = int(input())
B = int(input())
print(list(set(range(1, 3 + 1)) - {A, B})[0])

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
print((set(range(1, 3 + 1)) - {A, B})[0])
Problem p03127 (python)

Fixed submission:
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a

N = int(input())
A = list(map(int, input().split()))
d = gcd(A[0], A[1])
for i in range(2, N):
    d = gcd(d, A[i])
print(d)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))
d = math.gcd(A[0], A[1])
for i in range(2, N):
    d = math.gcd(d, A[i])
print(d)

Buggy submission (verdict: Runtime Error):
from math import gcd

N = int(input())
A = list(map(int, input().split()))
d = gcd(A[0], A[1])
for i in range(2, N):
    d = gcd(d, A[i])
print(d)
Problem p02580 (python)

Fixed submission:
h,w,m=map(int,input().split())
hlist=[0]*(h+1)
wlist=[0]*(w+1)
cnt=set()


for i in range(m):
  a,b=map(int,input().split())
  hlist[a]+=1
  wlist[b]+=1
  cnt.add((a,b))


hcnt,wcnt=max(hlist),max(wlist)


hhh=[i for i,v in enumerate(hlist) if v==hcnt]
www=[i for i,v in enumerate(wlist) if v==wcnt]


for i in hhh:
  for j in www:
    if not (i,j) in cnt:
      print(hcnt+wcnt)
      exit()


print(hcnt+wcnt-1)

Buggy submission (verdict: Runtime Error):
h,w,m=map(int,input().split())
hlist=[0]*(h+1)
wlist=[0]*(w+1)

cnt=[[False]*(w+1) for i in range(h+1)]
for i in range(m):
  a,b=map(int,input().split())
  hlist[a]+=1
  wlist[b]+=1
  cnt[a][b]=True
  
hcnt,wcnt=0,0
for i in range(1,h+1):
  hcnt=max(hcnt,hlist[i])
  
for i in range(1,w+1):
  wcnt=max(wcnt,wlist[i])

hh,ww=[],[]

for i in range(1,h+1):
  if hlist[i]==hcnt:
    hh+=[i]

for i in range(1,h+1):
  if wlist[i]==wcnt:
    ww+=[i]

ans=0

for i in hh:
  for j in ww:
    if cnt[i][j]==False:
      print(hcnt+wcnt)
      exit()
  
print(hcnt+wcnt-1)

Buggy submission (verdict: Runtime Error):
h,w,m=map(int,input().split())
hlist=[0]*(h+1)
wlist=[0]*(w+1)

cnt=[[False]*(w+1) for i in range(h+1)]
for i in range(m):
  a,b=map(int,input().split())
  hlist[a]+=1
  wlist[b]+=1
  cnt[a][b]=True
  
hcnt,wcnt=0,0
for i in range(1,h+1):
  hcnt=max(hcnt,hlist[i])
  
for i in range(1,w+1):
  wcnt=max(wcnt,wlist[i])

hh,ww=[],[]

for i in range(1,h+1):
  if hlist[i]==hcnt:
    hh+=[i]

for i in range(1,h+1):
  if wlist[i]==wcnt:
    ww+=[i]

ans=0

for i in hh:
  for j in ww:
    if cnt[i][j]==True:
      print(hcnt+wcnt-1)
      exit()
  
print(hcnt+wcnt)
Problem p02596 (python)

Fixed submission:
k=int(input())
ans='-1'
a=7
for i in range(1,10**6+1):
  if a%k==0:
    ans=i
    break

  a=((10*a)+7)%k
    
print(ans)

Buggy submission (verdict: Runtime Error):
k=int(input())
if k%2==0:
  print(-1)
  exit()
  
ans=1
pin=7
mod=k

for i in range(1000000):
  if pin%k==0:
    print(ans)
    exit()
    
  cnt+=1
  pin*=10
  pin+=7
  pin%=mod
  

print('-1')

Buggy submission (verdict: Runtime Error):
k=int(input())
if k%2==0:
  print(-1)
  exit()
  
ans=1
pin=7
mod=k

for i in range(1000000):
  if pin%k==0:
    print(ans)
    exit()
    
  cnt+=1
  pin*=10
  pin+=7
  

print('-1')
Problem p02597 (python)

Fixed submission:
n=int(input())
s=list(input())
x=[]
y=[]

for i in range(n):
  if s[i]=='R':
    x+=[i]
  elif s[i]=='W':
    y+=[i]
    
ans=0


while True:
    if len(y)==0:
      print(ans)
      break
    elif len(x)==0:
      print(ans)
      break
    elif x[-1]>y[0]:
      x.pop()
      y.pop(0)
      ans+=1
      continue
    
    else:
      print(ans)
      break

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
x=[]
y=[]

for i in range(n):
  if s[i]=='R':
    x+=[i]
  elif s[i]=='W':
    y+=[i]
    
ans=0

while True:
    if len(y)==0:
      print(ans)
      break
    elif x[-1]>y[0]:
      x.pop()
      y.pop(0)
      ans+=1
      continue
    
    else:
      print(ans)
      break

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
x=[]
y=[]

for i in range(n):
  if s[i]=='R':
    x+=[i]
  elif s[i]=='W':
    y+=[i]
    
ans=0
if y==[]:
  print(ans)
else:
  while True:
    if x[-1]>y[0]:
      x.pop()
      y.pop(0)
      ans+=1
      continue
    
    else:
      print(ans)
      break
Problem p02624 (python)

Fixed submission:
n=int(input())
ans=0
for i in range(1,n+1):
  j=n//i
  ans+=i*j*(j+1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(n):
  j=n//i
  ans+=j*(j+1)//2
print(ans)
Problem p02627 (python)

Fixed submission:
s=input()
if s==s.upper():
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
a=int(input())
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
a,b=input().split()
a=Decimal(a)
b=Decimal(b)
print((a*b)//1)

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
a,b=input().split()
a=decimal(a)
b=decimal(b)
print(a*b)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(a*b//1)
Problem p02688 (python)

Fixed submission:
n,k=map(int,input().split())
lst=[_ for _ in range(1,n+1)]
for i in range(k):
  x=int(input())
  a=list(map(int,input().split()))
  b=set(a)
  for j in b:
    if j in lst:
      lst.remove(j)
print(len(lst))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
lst=[for _ in range(1,n+1)]
for i in range(k):
  x=int(input())
  a=list(map(int,input().split()))
  b=set(a)
  for j in b:
    lst.remove(j)
print(len(lst))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
list=[1:n+1]
for i in range(k):
  d=int(input())
  a=list(map(int,input.split()))
  list.remove(a)
print(count(list))
Problem p02693 (python)

Fixed submission:
k=int(input())
a,b=map(int,input().split())
ans='NG'
if b-a-1>=k:
  ans='OK'
else:
  for i in range(a,b+1):
    if i%k==0:
      ans='OK'
      break
print(ans)

Buggy submission (verdict: Runtime Error):
k=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
  if i%k==0:
    print 'OK'
  
  else:
    print 'NG'
Problem p02711 (python)

Fixed submission:
n=input()
if '7' in n:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
if 7 in n:
  print 'Yes'
else:
  print'No'

Buggy submission (verdict: Runtime Error):
n=int(input())
if n[0]==7 or n[1]==7 or n[2]==7:
  print ('Yes')
else:
  print ('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
if n[0]==7 or n[1]==7 or n[2]==7:
  print 'Yes'
else:
  print 'No'
Problem p02712 (python)

Fixed submission:
n=int(input())
sum=0

for i in range(1,n+1):
  if i%3!=0 and i%5!=0:
    sum+=i
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
sum=0

for i in range[n+1]:
  if i%3==1 or i%3==2:
    if i%5==1 or i%5==2 or i%5==3 or i%5==4:
      sum+=i
print sum

Buggy submission (verdict: Runtime Error):
n=int(input())
sum=0

for i in range(n+1):
  if i%3==1 or i%3==2:
    if i%5==1 or i%5==2 or i%5==3 or i%5==4:
      sum+=i
print sum
Problem p02723 (python)

Fixed submission:
s=input()

if s[2]==s[3] and s[4]==s[5]:
  print ('Yes')

else:
  print('No')

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

if s[2]==s[3] and s[4]=s[5]:
  print ('Yes')

else:
  print('No')
Problem p02729 (python)

Fixed submission:
n,m=map(int,input().split())
print(((n*(n-1))+(m*(m-1)))//2)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
print(n/(2n-4)+m/(2m-4))
Problem p02753 (python)

Fixed submission:
s=input()
if s=='AAA' or s=='BBB':
  print ('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
s=input()
if s=='AAA' or s=='BBB':
  print ('No')
else ('Yes')

Buggy submission (verdict: Runtime Error):
s=input()
if s='AAA' or 'BBB':
  print ('No')
else ('Yes')
Problem p02754 (python)

Fixed submission:
n,a,b=map(int,input().split())
x=(n//(a+b))*a
y=min(a,n%(a+b))
print(x+y)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
x=n//(a+b)
y=n%(a+b)

if y<=a:
  print(x*b)
else:
  z=(x*b)+(y-a)
  print z
Problem p02759 (python)

Fixed submission:
import math
n=int(input())
print(math.ceil(n/2))

Buggy submission (verdict: Runtime Error):
import math
print(math.ceil(int(input()/2)))

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2==0:
  print (n/2)
else:
  a=(n//2+1)
  print a
Problem p02766 (python)

Fixed submission:
n,k=map(int,input().split())
count=1
while n>=k:
  n=n/k
  count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
sum=0
while n>=1:
  n=n/k
  sum+=1
  
print sum

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
sum=0
while n>=1:
  n=n/k
  sum+=1
  
return sum

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
sum=0
while n>1:
  n=n/k
  sum+=1
  
return sum
Problem p02773 (python)

Fixed submission:
n=int(input())
dict={}
xs=[]
for i in range(n):
  s=input()
  xs+=[s]
  if s not in dict:
    dict[s]=1
  else:
    dict[s]+=1
pin=0
xs=list(set(xs))
for i in xs:
  pin=max(pin,dict[i])
ans=[]
for i in xs:
  if dict[i]==pin:
    ans+=[i]
ans.sort()
for i in ans:
  print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
dict={}
xs=[]
for i in range(n):
  s=input()
  xs+=[s]
  if s not in dict:
    dict[s]=1
  else:
    dict[s]+=1
pin=0
xs=list(set(xs))
for i in xs:
  pin=max(pin,dict[i])
ans=[]
for i in xs:
  if dict[i]==pin:
    ans*=[i]
ans.sort()
for i in ans:
  print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
dict={}
xs=[]
for i in range(n):
  s=input()
  xs+=[s]
  if s not in dict:
    dict[s]=1
  else:
    dict[s]+=1
pin=0
xs=list(set(xs))
for i in xs:
  pin=max(pin,dict[xs])
ans=[]
for i in xs:
  if dict[i]==pin:
    ans*=[i]
ans.sort()
for i in ans:
  print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[input() for i in range(n)]
xs=list(set(lst))
ans=[]
for i in xs:
  cnt=lst.count(i)
  ans,append([i,cnt])
ans.sort(key=lambda x:x[1])
pin=ans[-1][1]
ans2=[]
for i in ans:
  if i[1]==pin:
    ans2.append(i[0])
ans2.sort()
for i in ans2:
  print(i)
Problem p02777 (python)

Fixed submission:
s,t=input().split()
a,b=map(int,input().split())
u=input()

if s==u:
  print (a-1,b)
elif t==u:
  print(a,b-1)

Buggy submission (verdict: Runtime Error):
s,t=input().split()
a,b=(int,input().split())
u=input()

if s==u:
  print (a-1,b)
elif t==u:
  print(a,b-1)
Problem p02785 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<=k:
  print('0')
else:
  h.sort()
  for i in range(k):
    h.pop()
  print(sum(h))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<=k:
  print('0')
else:
  h.sort()
  h.pop([n-k:])
  print(sum(h))
Problem p02829 (python)

Fixed submission:
x='123'
for _ in range(2): 
  x=x.replace(input(),'')
print(x)

Buggy submission (verdict: Runtime Error):
x='123'
for _ in range(2): 
  x=x.remove(input())
print(x)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
x=[1,2,3]
x.remove(a)
x.remove(b)
return(*x)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
x=[1,2,3]
x.remove(a)
x.remove(b)
return(x)
Problem p02831 (python)

Fixed submission:
from fractions import gcd 
a,b=map(int,input().split())
print(a*b//gcd(a,b))

Buggy submission (verdict: Runtime Error):
from math import lcm
a,b=map(int,input().split())
print(lcm(a,b))
Problem p02836 (python)

Fixed submission:
s=input()
cnt=0
for i in range(len(s)//2):
  if s[i]!=s[(i*(-1))-1]:
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
s=input()
cnt=0
for i in range(len(s)//2):
  if s[i]!=s[(i*(-1))-1]
  cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
sum=0

for i in range(n):
  if s(i)!=s(n-i-1):
    sum+=1
    print(sum//2)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
sum=0

for i in range(n):
  if s(i)!=s(n-i):
    sum+=1
    print(sum//2)
Problem p02860 (python)

Fixed submission:
n=int(input())
s=input()
ans='No'
if n%2==0:
  if s[:n//2]==s[n//2:]:
    ans='Yes'
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
ans='No'
if n%2==0:
  if s[:n//2]=s[n//2:]:
    ans='Yes'
print(ans)

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

if n%2==0:
  if s[:(n//2)]==s[(n//2):n]:
    print('Yes')
  else:
    print('No')
    
else('No')

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

if n%2==0:
  if s[:n//2]==s[n//2:n]:
    print('Yes')
  else:
    print('No')
    
else('No')
Problem p02862 (python)

Fixed submission:
mod=10**9+7

x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
  exit()
  
if x*2<y or y*2<x:
  print(0)
  exit()
  
z=(x+y)//3

x-=z
y-=z

n=x+y
r=x

if x==0 or y==0:
  print(1)
  exit()
  

lst=[0]+[1]
for i in range(2,n+10):
  lst.append((lst[-1]*i)%mod)


xxx=lst[n]
xxx*=pow(lst[n-r],10**9+5,mod)
xxx%=mod
xxx*=pow(lst[r],10**9+5,mod)
xxx%=mod

print(xxx)

Buggy submission (verdict: Runtime Error):
mod=10**9+7

x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
  exit()
  
z=(x+y)//3

x-=z
y-=z

n=x+y
r=x


lst=[0]+[1]
for i in range(2,n+10):
  lst.append((lst[-1]*i)%mod)


xxx=lst[n]
xxx*=pow(lst[n-r],10**9+5,mod)
xxx%=mod
xxx*=pow(lst[r],10**9+5,mod)
xxx%=mod

print(xxx)

Buggy submission (verdict: Runtime Error):
mod=10**9+7

x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
  exit()
  
z=(x+y)//3

x-=z
y-=z

n=x+y
r=x

xxx=lst[n]
xxx*=pow(lst[n-r],10**9+5,mod)
xxx%=mod
xxx*=pow(lst[r],10**9+5,mod)
xxx%=mod

print(xxx)
Problem p02879 (python)

Fixed submission:
a,b=map(int,input().split())
if a<10 and b<10:
  print(a*b)
  
else:
  print('-1')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for x in range(1,10):
  for y in range(1,10):
    a=a.append(x*y)
if n in a:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b=(int,input().split())
if a<10 and b<10:
  print(a*b)
  
else:
  print('-1')

Buggy submission (verdict: Runtime Error):
a,b=(int,input().split())
if a<10 and b<10:
  print(a*b)
  
else:
  print(-1)
Problem p02880 (python)

Fixed submission:
n=int(input())
ans='No'
for i in range(1,10):
  if n%i==0:
    if 1<=n//i<=9:
      ans='Yes'
      break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for x in range(1,10):
  for y in range(1,10):
    a+=x*y
if n in a:
  print('Yes')
else:
  print('No')
Problem p02916 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=sum(b)
for i in range(len(a)-1):
  if a[i+1]-a[i]==1:
    d=a[i]
    x+=c[d-1]
print(x)

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()))
x=sum(b)
for i in range(len(a)-1):
  if a[i+1]-a[i]==1:
    d=a[i-1]
    x+=c[d]
print(x)

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()))
x=sum(b)
for i in range(len(a)-1):
  if a[i+1]-a[i]==1:
    x+=c[a[i]]
print(x)
Problem p02951 (python)

Fixed submission:
a,b,c=map(int,input().split())
if (c+b-a)>0:
  print(c+b-a)
else:
  print('0')

Buggy submission (verdict: Runtime Error):
n=int(input())
if n<=9:
  print(n)
elif n<=99:
  print(9)
elif n<=999:
  print(n-90)
elif n<=9999:
  print(909)
elif n==100000:
  print(90909)
else:
  print(n-9090)
Problem p02959 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=sum(b)
for i in range(n):
  s=a[i]+a[i+1]
  t=b[i]
  x-=max(0,t-s)
  a[i+1]-=max(0,b[i]-a[i])
  a[i+1]=max(a[i+1],0)
print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input()split()))
b=list(map(int,input()split()))
x=sum(a)
for i in range(n):
  if a[i]>=b[i]:
    a[i]-=b[i]
  else:
    a[i]=0
    a[i+1]-=b[i]-a[i]
print(x-sum(a))
Problem p02990 (python)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n,k=map(int,input().split())
mod=10**9+7

red=n-k
sep=red+1


for i in range(1,1+k):
    if i>sep:
        print(0)
        continue
    blue=k-i
    ans=cmb(i+blue-1,blue)*cmb(sep,i)%mod
    print(ans)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n,k=map(int,input().split())
mod=10**9+7

red=n-k
sep=red+1


for i in range(1,k+1):
    blue=k-i
    ans=cmb(i+blue-1,blue)*cmb(sep,i)%mod
    print(ans)
Problem p03012 (python)

Fixed submission:
from itertools import accumulate
n=int(input())
w=list(map(int,input().split()))
w=list(accumulate(w))
for i in range(n):
  if w[i]*2==w[-1]:
    print(0)
    break
  elif w[i]*2>w[-1]:
    print(min((w[i]*2-w[-1]),(w[-1]-w[i-1]*2)))
    break

Buggy submission (verdict: Runtime Error):
n=int(input())
w=list(map(int,input().split()))
x=0
for i in range(n):
  s=abs(sum(w(0,i+1))-sum(w(i+1,n+1)))
  if x==0 or x<s:
    x=s
print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
w=list(map(int,input().split()))
x=0
for i in range(n):
  s=abs(w[:i+1]-w[i+1:])
  if x==0 or x<s:
    x=s
print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
w=list(map(int,input().split()))
x=0
for i in range(n):
  s=abs(w[:i+1]-w[i+1:])
  if s.count()==0 or x<s:
    x=s
print(x)
Problem p03036 (python)

Fixed submission:
r,d,x=map(int,input().split())
for i in range(10):
  x=r*x-d
  print(x)

Buggy submission (verdict: Runtime Error):
r,d,x=map(int,input().split())
for i in range(10)
  x=r*x-d
  print(x)
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()
print(s[:k-1]+s[k-1].lower()+s[k:])

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
s[b-1]=s[b-1].lower()
print(s)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s[k-1]=s[k-1].lower()
print(s)
Problem p03042 (python)

Fixed submission:
s=input()
if int(s[2:])!=0 and int(s[2:])<=12:
  if int(s[:2])!=0 and int(s[:2])<=12:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  if int(s[:2])!=0 and int(s[:2])<=12:
    print('MMYY')
  else:
    print('NA')

Buggy submission (verdict: Runtime Error):
s=input()
if int(s[2:])!=0 and int(s[2:])<=12:
  if int(s[:2])!=0 int(s[:2])<=12:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  if int(s[:2])!=0 int(s[:2])<=12:
    print('MMYY')
  else:
    print('NA')

Buggy submission (verdict: Runtime Error):
s=input()
if str(s[2:])!=0 and str(s[2:])<=12:
  if str(s[:2])!=0 str(s[:2])<=12:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  if str(s[:2])!=0 str(s[:2])<=12:
    print('MMYY')
  else:
    print('NA')