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

Fixed submission:
import  fractions
from functools import reduce
import sys
input = sys.stdin.readline
def main():
    n=int(input())
    a=list(map(int,input().split()))
    # tmp = lcm(*a)
    mod=pow(10,9) + 7
    m=0
    ans=0
    tmp = a[0]
    for i in range(1,len(a)):
        tmp = (tmp*a[i]) // fractions.gcd(tmp,a[i])
    
    for i,v in enumerate(a):
        m=tmp//v
        ans+=m
    ans = ans % mod
    print(ans)


if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import  fractions
from functools import reduce
import sys
input = sys.stdin.readline
def main():
    n=int(input())
    a=list(map(int,input().split()))
    tmp = lcm(*a)
    mod=10**9 + 7
    m=0
    ans=0
    for i,v in enumerate(a):
        m=tmp//v
        ans+=m%mod
    ans = ans % mod
    print(ans)

def lcm_base(x, y):
    return (x * y) // math.fractions(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import  fractions
from functools import reduce
import sys
input = sys.stdin.readline
def main():
    n=int(input())
    a=list(map(int,input().split()))
    tmp = lcm(*a)
    mod=10**9 + 7
    m=0
    ans=0
    for i,v in enumerate(a):
        m=tmp//v
        ans+=m%mod
    ans = ans % mod
    print(ans)

def lcm_base(x, y):
    return (x * y) // math.fractions(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import  fructions
from functools import reduce
import sys
input = sys.stdin.readline
def main():
    n=int(input())
    a=list(map(int,input().split()))
    tmp = lcm(*a)
    mod=10**9 + 7
    m=0
    ans=0
    for i,v in enumerate(a):
        m=tmp//v
        ans+=m%mod
    ans = ans % mod
    print(ans)

def lcm_base(x, y):
    return (x * y) // math.fructions(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


if __name__=='__main__':
    main()

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

def main():
    n=int(input())
    a=list(map(int,input().split()))
    tmp = lcm(*a)
    mod=10**9 + 7
    m=0
    ans=0
    for i, v in enumerate(a):
        m=tmp//v
        ans+=m%mod
    ans = ans % mod
    print(ans)

def lcm_base(x, y):
    return (x * y) // fraction.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


if __name__=='__main__':
    main()
Problem p02831 (python)

Fixed submission:
import fractions
def main():
    a,b = map(int ,input().split())
    ans=a*b//fractions.gcd(a,b)
    print(ans)
if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
def main():
    a,b = map(int ,input().split())
    ans=a*b//math.gcd(a,b)
    print(ans)
if __name__=='__main__':
    main()
Problem p02951 (python)

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

print(max(0,c-a+b))

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

print(max(0,a-b-c))

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

print(max(0,a-b-c)
Problem p03017 (python)

Fixed submission:
def main():
    n, a, b, c, d = map(int,input().split())
    s = list(input())
    if c<d:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        print('Yes')
    else:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return

        for i in range(b-1,d):
            if s[i-1] == s[i] == s[i+1] and s[i] == '.':
                print('Yes')
                return


        print('No')



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, a, b, c, d = map(int,input().split())
    s = list(input())
    if c<d:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        print('Yes')
    else:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return

        for i in range(b-1,d-3):
            if s[i] == s[i+1] == s[i+2] and s[i] = '.':
                print('Yes')
                return
                

        print('No')



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, a, b, c, d = map(int,input().split())
    s = list(input())
    if c<d:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        print('Yes')
    else:
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        s[b-1] = '#'
        flg = True
        for i in range(len(s)):
            if s[i] == s[i+1] and s[i] == '#':
                flg = False
                break
        if flg:
            print('Yes')
            return
        flg = True
        s[b-1] = '.'
        s[d-1] = '#'
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                flg = False
                break
        if flg:
            print('Yes')
            return

        for i in range(a-1,c-3):
            if s[i] == s[i+1] == s[i+2] and s[i] == '.':
                print('Yes')
                return

        print('No')

if __name__ == '__main__':
    main()
Problem p03042 (python)

Fixed submission:
s=list(input())

# s1 = (int)(s[0] + s[1])
s1=int(s[0])*10+int(s[1])
s2=int(s[2])*10+int(s[3])

if s1<=12 and s2<=12 and s1>0 and s2>0:
    ans='AMBIGUOUS'
elif s1<=12 and  (s2>12 or s2 == 0)and s1>0:
    ans ='MMYY'
elif (s1>12 or s1==0) and s2<=12 and s2>0:
    ans ='YYMM'
else:
    ans='NA'
print(ans)

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

# s1 = (int)(s[0] + s[1])
s1=int(s[0])*10+int(s[1])
s2=int(s[2])*10+int(s[3])

if s1<=12 and s2<=12 and s1>0 and s2>0:
    ans='AMBIGUOUS'
elif s1<=12 and  (s2>12 or s2 == 0)and s1>0:
    ans ='MMYY'
elif (s1>12 s1==0) and s2<=12 and s2>0:
    ans ='YYMM'
else:
    ans='NA'
print(ans)

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

s1=s[0]*10+s[1]
s2=s[3]*10+s[4]

if s1<=12 and s2<=12:
    ans='AMBIGUOUS'
elif s1<=12 and s2>12:
    ans ='MMYY'
elif s1>12 and s2<=12:
    ans ='YYMM'
else:
    ans='NA'
Problem p03053 (python)

Fixed submission:
from collections import  deque
h,w = map(int,input().split())
mp = []
for _ in range(h):
    row = list(input())
    mp.append(row)

q = deque()
dist = [[-1] * w for _ in range(h)]

for col in range(h):
    for row in range(w):
        if mp[col][row] == '#':
            q.append((col,row))
            dist[col][row] = 0
ans = 0
while q:
    now_x,now_y = q.popleft()
    ans = dist[now_x][now_y]
    for x,y in ((1,0), (0,1), (-1,0), (0,-1)):
        next_x = now_x + x
        next_y = now_y + y
        if 0 <= next_x < h and 0 <= next_y < w :
            if dist[next_x][next_y] < 0:
                q.append((next_x, next_y))
                dist[next_x][next_y] = ans + 1

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import  deque
h,w = map(int,input().split())
mp = []
for _ in range(h):
    row = list(input())
    mp.append(row)

q = deque()
dist = [[-1] * w for _ in range(h)]

for col in range(h):
    for row in range(w):
        if mp[col][row] == '#':
            q.append((col,row))
            dist[col][row] = 0
ans = 0
while q:
    now_x,now_y = q.popleft()
    ans = dist[now_x][now_y]
    for x,y in ((1,0), (0,1), (-1,0), (0,-1)):
        next_x = now_x + x
        next_y = now_y + y
        if 0 <= next_x < h and 0 <= next_y < w :
            if dist[next_x][next_y] < 0:
                q.append((next_x, next_y))
                dist[next_x][next_y] = d + 1
                
print(ans)
Problem p03221 (python)

Fixed submission:
n,m = map(int,input().split())
py = []
p_y = [[] for i in range(n)]
for _ in range(m):
    p,y = map(int,input().split())
    py.append((p,y))
    p_y[p-1].append(y)
ans = {}
for i, tmp in enumerate(p_y):
    cnt = 1
    p_y[i] = tmp.sort()
    for j, jj in enumerate(tmp):

        ans[(i+1, jj)] = str(i+1).zfill(6) + str(j+1).zfill(6)


for i, tmp in enumerate(py):
    print(ans[tmp])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
py = []
p_y = [[0] * (10**5) for i in range(n)]
for _ in range(m):
    p,y = map(int,input().split())
    py.append((p,y))
    p_y[p-1][y-1] = 1

for i, tmp in enumerate(p_y):
    cnt = 1
    for j in range(len(tmp)):
        if tmp[j] == 0:
            continue
        else:
            p_y[i][j] = cnt
            cnt += 1

for i, tmp in enumerate(py):
    s = ''
    s += str(tmp[0]).zfill(6)
    s += str(p_y[tmp[0]-1][tmp[1]-1]).zfill(6)
    print(s)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
py = []
p_y = [[0] * (10**5) for i in range(n)]
for _ in range(m):
    p,y = map(int,input().split())
    py.append((p,y))
    p_y[p-1][y-1] = 1

for i, tmp in enumerate(p_y):
    cnt = 1
    for j in range(len(tmp)):
        if tmp[j] == 0:
            continue
        else:
            p_y[i][j] = cnt
            cnt += 1

for i, tmp in enumerate(py):
    s = ''
    s += str(tmp[0]).zfill(6)
    s += str(p_y[tmp[0]-1][tmp[1]-1]).zfill(6)
    print(s)
Problem p03785 (python)

Fixed submission:
from collections import deque
n,c,k = map(int,input().split())
t = []
for _ in range(n):
    tt = int(input())
    t.append(tt)
t.sort()
ans = deque([])
cnt = 0
for i, tt in enumerate(t):
    if i == 0:
        ans.append([tt+k,1])
        cnt += 1
    else:
        flg = False
        for i in range(len(ans)):
            tmp = ans.popleft()
            if tmp[0] < tt or tmp[1] == c:

                continue
            else:
                flg = True
                break
        if flg :
            tmp[1] += 1
            if tmp[1] != c:
                ans.appendleft(tmp)
        else:
            tmp = [tt+k,1]
            ans.append(tmp)
            cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,c,k = map(int,input().split())
t = []
for _ in range(n):
    tt = int(input())
    t.append(tt)
t.sort()
ans = deque([])
cnt = 0
for i, tt in enumerate(t):
    if i == 0:
        ans.append([tt+k,1])
        cnt += 1
    else:
        flg = False
        for i in range(len(ans)):
            tmp = ans.popleft()
            if tmp[0] < tt or tmp[1] == c:

                continue
            else:
                flg = True
                break
        if flg :
            tmp[1] += 1
            if tmp[1] != c:
                a.append(tmp)
                ans.appendleft(tmp)
        else:
            tmp = [tt+k,1]
            ans.append(tmp)
            cnt += 1
print(cnt)
Problem p02759 (python)

Fixed submission:
N=int(input())

if N%2==0:
    print(N//2)

else:
    print((N+1)//2)

Buggy submission (verdict: Runtime Error):
N=input()
N=int(N)
if N%2=0:
    print(N/2)
else:
    print((N+1)/2)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%2=0:
    print(N/2)
else:
    print((N+1)/2)

Buggy submission (verdict: Runtime Error):
N=int(Input())
if N%2=0:
    print(N/2)
else:
    print((N-1)/2)

Buggy submission (verdict: Runtime Error):
N=Input()
if N%2=0:
    print(N/2)
else:
    print((N+1)/2)
Problem p02831 (python)

Fixed submission:
def g(m,n):
    if m==0:
        return n
    elif n==0:
        return m
    elif m>n:
        m=m%n
        return g(m,n)
    else:
        n=n%m
        return g(m,n)

def h(m,n):
    return m*n//g(m,n)

A,B=map(int,input().split())

print(h(A,B))

Buggy submission (verdict: Runtime Error):
def g(m,n):
    if m>n:
        m=m%n
        return g(m,n)
    elif m==0:
        return n
    elif n==0:
        return m
    else:
        n=n%m
        return g(m,n)

def h(m,n):
    return m*n//g(m,n)

A,B=map(int,input().split())

print(h(A,B))
Problem p02847 (python)

Fixed submission:
S=["MON","TUE","WED","THU","FRI","SAT","SUN"]

a=input()
n=S.index(a)

if a=="SUN":
    print(7)
else:
    print(6-n)

Buggy submission (verdict: Runtime Error):
S=["MON","TUE","WED","THU","FRY","SAT","SUN"]

a=input()
n=S.index(a)

if a=="SUN":
    print(7)
else:
    print(6-n)
Problem p02951 (python)

Fixed submission:
A,B,C=map(int,input().split())

if C-(A-B)>=0:
    print(C-(A-B))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
A,B,C=input().split()

A=B+D

E=C-D

print(E)
Problem p02915 (python)

Fixed submission:
N=int(input())
print(N**3)

Buggy submission (verdict: Runtime Error):
n=input("Number")
if type(n)!=int:
  break
else:
  if n>10:
    break
  else:
    print(n**3)

Buggy submission (verdict: Runtime Error):
n=int(input("the number you can use",":"))
if n>10:
  break
  else:
    print(n**3)

Buggy submission (verdict: Runtime Error):
n=int(input("the number you can use",":"))

print(n**3)
Problem p02580 (python)

Fixed submission:
H,W,M=map(int,input().split())
dicti={}
dictj={}
bomb=set()
for i in range(M):
  h,w=map(int,input().split())
  bomb.add((h,w))
  if h in dicti:
    dicti[h]+=1
  if h not in dicti:
    dicti[h]=1
  if w in dictj:
    dictj[w]+=1
  if w not in dictj:
    dictj[w]=1
LI=sorted(dicti.items(),key=lambda x:x[1],reverse=True)
LJ=sorted(dictj.items(),key=lambda x:x[1],reverse=True)
Imax=LI[0][1]
Jmax=LJ[0][1]
I=0
J=0
IL=[]
JL=[]
for i in range(len(LI)):
  if LI[i][1]==Imax:
    IL.append(LI[i][0])
for i in range(len(LJ)):
  if LJ[i][1]==Jmax:
    JL.append(LJ[i][0])
  
ans=Imax+Jmax-1

for h in IL:
  for w in JL:
    if (h,w) not in bomb:
      ans=Imax+Jmax
      break
print(ans)

Buggy submission (verdict: Runtime Error):
H,W,M=map(int,input().split())
dicti={}
dictj={}
bomb=[]
for i in range(M):
  h,w=map(int,input().split())
  bomb.append((h,w))
  if h in dicti:
    dicti[h]+=1
  if h not in dicti:
    dicti[h]=1
  if w in dictj:
    dictj[w]+=1
  if w not in dictj:
    dictj[w]=1
LI=sorted(dicti.items(),key=lambda x:x[1],reverse=True)
LJ=sorted(dictj.items(),key=lambda x:x[1],reverse=True)
Imax=LI[0][1]
Jmax=LJ[0][1]
I=0
J=0
IL=[]
for i in range(len(LI)):
  if LI[i][1]==Imax:
    I+=1
for j in range(len(LJ)):
  if LJ[i][1]==Jmax:
    J+=1
pos=0
for i in range(M):
  if dicti[bomb[i][0]]==Imax and dictj[bomb[i][0]]==Jmax:
    pos+=1
if pos==I*J:
  print(Imax+Jmax)
else:
  print(Imax+Jmax-1)
Problem p02792 (python)

Fixed submission:
N=int(input())
A=[[0 for i in range(10)] for j in range(10)]
for i in range(1,N+1):
  i=str(i)
  ii=len(i)
  A[int(i[0])][int(i[ii-1])]+=1
ans=0
for i in range(10):
  for j in range(10):
    ans+=A[i][j]*A[j][i]
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
P=[0,0,0,0,0,0,0,0,0,0]
L=copy.deepcopy(P)
M=[L]*10
count=0
for i in range(1,N+1):
  a=int(str(i)[0])
  b=int(str(i)[-1])
  if L[b][a]!=0:
    count+=2*L[b][a]+1
  L[a][b]+=1

print(count)
Problem p02819 (python)

Fixed submission:
X=int(input())
if X==2:
  print(2)
else:
  for i in range(X,10**6):
    for j in range(2,i):
      if i%j==0:
        break
      if j==i-1:
        print(i)
        exit()

Buggy submission (verdict: Runtime Error):
X=int(input())
if x==2:
  print(2)
else:
  for i in range(X,10**6):
    for j in range(2,i):
      if i%j==0:
        break
      if j==i-1:
        print(i)
        exit()
Problem p02835 (python)

Fixed submission:
A1,A2,A3=map(int,input().split())
if A1+A2+A3>=22:
  print('bust')
else:
  print('win')

Buggy submission (verdict: Runtime Error):
A1,A2,A3=map(int,input.split())
if A1+A2+A3>=22:
  print('bust')
else:
  print('win')
Problem p02836 (python)

Fixed submission:
S=input()
n=len(str(S))
if n%2==1:
  count=0
  m=int((n-1)/2)
  for i in range(0,m):
    if S[i]!=S[n-i-1]:
      count+=1
else:
  count=0
  m=int(n/2)
  for i in range(0,m):
    if S[i]!=S[n-i-1]:
      count+=1
      
print(count)

Buggy submission (verdict: Runtime Error):
S=input()
n=len(str(S))
if n%2=1:
  count=0
  m=int((n-1)/2)
  for i in range(0,m):
    if S[i]!=S[n-i-1]:
      count+=1
else:
  count=0
  m=int(n/2)
  for i in range(0,m):
    if S[i]!=S[n-i-1]:
      count+=1
      
print(count)
Problem p02851 (python)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(1,N):
  A[i]+=A[i-1]
A=[(A[i]-i-1)%K for i in range(N)]
A=[0]+A
from collections import Counter
if K>N:
  a=Counter(A)
  ans=0
  for v in a.values():
    ans+=v*(v-1)/2
  print(int(ans))
else:
  ans=0
  d={}
  for i in range(K):
    if A[i] in d:
      ans+=d[A[i]]
      d[A[i]]+=1
    else:
      d[A[i]]=1
  for i in range(K,N+1):
    d[A[i-K]]-=1
    if A[i] in d:
      ans+=d[A[i]]
      d[A[i]]+=1
    if A[i] not in d or d[A[i]]==0:
      d[A[i]]=1
  print(ans)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
red=[]
blue=[]
for i in range(H):
  A=list(map(int,input().split()))
  red.append(A)
for i in range(H):
  B=list(map(int,input().split()))
  blue.append(B)
list=[[[0 for i in range(80*(j+k+1))] for j in range(W)] for k in range(H)]
list[0][0][abs(red[0][0]-blue[0][0])]=1
for i in range(H):
  for j in range(W):
    for k in range(len(list[i][j])):
      if list[i][j][k]==1:
        if i+1<H:
          if abs(k-abs(red[i+1][j]-blue[i+1][j]))<12801: 
            list[i+1][j][abs(k-abs(red[i+1][j]-blue[i+1][j]))]=1
          if abs(k+abs(red[i+1][j]-blue[i+1][j]))<12801: 
            list[i+1][j][abs(k+abs(red[i+1][j]-blue[i+1][j]))]=1
        if j+1<W:
          if abs(k-abs(red[i][j+1]-blue[i][j+1]))<12801: 
            list[i][j+1][abs(k-abs(red[i][j+1]-blue[i][j+1]))]=1
          if abs(k+abs(red[i][j+1]-blue[i][j+1]))<12801: 
            list[i][j+1][abs(k+abs(red[i][j+1]-blue[i][j+1]))]=1           
for i in range(12801):
  if list[H-1][W-1][i]==1:
    print(i)
    break
Problem p02862 (python)

Fixed submission:
X,Y=map(int,input().split())
mod=10**9+7
if (X+Y)%3!=0:
  print(0)
else:
  N=int((2*Y-X)/3)
  M=int((2*X-Y)/3)
  if N<0 or M<0:
    print(0)
  if N==0 or M==0:
    print(1)
  if N>0 and M>0:
    List=[0 for i in range(N+M)]
    List[0]=1
    for i in range(N+M-1):
      List[i+1]=List[i]*(i+2)%mod
    print(List[N+M-1]*pow(List[N-1],mod-2,mod)*pow(List[M-1],mod-2,mod)%mod)

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input().split())
mod=10**9+7
if (X+Y)%3!=0:
  print(0)
else:
  N=int((2*Y-X)/3)
  M=int((2*X-Y)/3)
  if N==0 or M==0:
    print(1)
  else:
    List=[0 for i in range(N+M)]
    List[0]=1
    for i in range(N+M-1):
      List[i+1]=List[i]*(i+2)%mod
    print(List[N+M-1]*pow(List[N-1],mod-2,mod)*pow(List[M-1],mod-2,mod)%mod)

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input().split())
mod=10**9+7
if (X+Y)%3!=0:
  print(0)
else:
  N=int((2*Y-X)/3)
  M=int((2*X-Y)/3)
  List=[0 for i in range(N+M)]
  List[0]=1
  for i in range(N+M-1):
    List[i+1]=List[i]*(i+2)%mod
  print(List[N+M-1]*pow(List[N-1],mod-2,mod)*pow(List[M-1],mod-2,mod)%mod)
Problem p02948 (python)

Fixed submission:
import heapq
n,m=map(int,input().split())
list=[[] for i in range(m)]
h=[]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    list[a-1].append(-b)
ans=0
for i in range(m):
  for j in list[i]:
    heapq.heappush(h,j)
  if h:
    ans+=-heapq.heappop(h)
  else:
    continue
print(ans)

Buggy submission (verdict: Runtime Error):
mport heapq
n,m=map(int,input().split())
list=[[] for i in range(m)]
h=[]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    list[a-1].append(-b)
ans=0
for i in range(m):
  for j in list[i]:
    heapq.heappush(h,j)
  if h:
    ans+=-heapq.heappop(h)
  else:
    continue
print(ans)
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
ans=[0 for i in range(N+1)]
true=[True for i in range(N+1)]
for i in range(M):
  a=int(input())
  true[a]=False
mod=10**9+7
ans[0]=1
ans[1]=1
for i in range(2,N+1):
  for j in range(i-2,i):
    if true[j]:
      ans[i]+=ans[j]%mod
print(ans[N]%mod)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
ans=[0 for i in range(N)]
for i in range(M):
  a=int(input())
  ans[a-1]=-1
mod=10**9+7
if ans[0]==-1 and ans[1]==-1:
  print(0)
  exit()
if ans[0]!=-1 and ans[1]==-1:
  ans[0]=1
if ans[0]==-1 and ans[1]!=-1:
  ans[1]=1
else:
  ans[0]=1
  ans[1]=2
for i in range(N-2):
  if ans[i+2]==-1:
    pass
  else:
    if ans[i]==-1 and ans[i+1]==-1:
      print(0)
      exit()
    if ans[i]==-1 and ans[i+1]!=-1:
      ans[i+2]=ans[i+1]
    if ans[i]!=-1 and ans[i+1]==-1:
      ans[i+2]=ans[i]
    if ans[i]!=-1 and ans[i+1]!=-1:
      ans[i+2]=(ans[i+1]+ans[i])%mod
print(ans[N-1])

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
ans=[0 for i in range(N)]
for i in range(M):
  a=int(input())
  ans[a-1]=-1
mod=10**9+7
if ans[0]==-1 and ans[1]==-1:
  print(0)
  exit()
if ans[0]!=-1 and ans[1]==-1:
  ans[0]=1
if ans[0]==-1 and ans[1]!=-1:
  ans[1]=1
else:
  ans[0]=1
  ans[1]=2
for i in range(N-2):
  if ans[i+2]==-1:
    pass
  else:
    if ans[i]==-1 and ans[i+1]==-1:
      ans[i+2]=0
    if ans[i]==-1 and ans[i+1]!=-1:
      ans[i+2]=ans[i+1]
    if ans[i]!=-1 and ans[i+1]==-1:
      ans[i+2]=ans[i]
    if ans[i]!=-1 and ans[i+1]!=-1:
      ans[i+2]=(ans[i+1]+ans[i])%mod
print(ans[N-1])
Problem p03038 (python)

Fixed submission:
N,M=map(int,input().split())
import heapq
A=list(map(int,input().split()))
heapq.heapify(A)
BC=[]
for i in range(M):
  B,C=map(int,input().split())
  BC.append((B,C))
BC.sort(key=lambda x:x[1],reverse=True)
import bisect
A.sort()
now=0
D=[0]*N
for i in range(M):
  B=BC[i][0]
  C=BC[i][1]
  for j in range(now,min(now+B,N)):
    D[j]=C
  now+=B
  if now>N-1:
    break

for i in range(N):
  a=A[i]
  d=D[i]
  if d>a:
    A[i]=d
  else:
    break
print(sum(A))

Buggy submission (verdict: Runtime Error):
     N,M=map(int,input().split())
import heapq
A=list(map(int,input().split()))
heapq.heapify(A)
BC=[]
for i in range(M):
  B,C=map(int,input().split())
  BC.append((B,C))
BC.sort(key=lambda x:x[1],reverse=True)
import bisect
A.sort()
now=0
D=[0]*N
for i in range(M):
  B=BC[i][0]
  C=BC[i][1]
  for j in range(now,min(now+B,N)):
    D[j]=C
  now+=B
  if now>N-1:
    break

for i in range(N):
  a=A[i]
  d=D[i]
  if d>a:
    A[i]=d
  else:
    break
print(sum(A))
Problem p03634 (python)

Fixed submission:
N=int(input())
tree=[[] for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  tree[a-1].append((b-1,c))
  tree[b-1].append((a-1,c))
from collections import deque
visited=[-1 for i in range(N)]
Q,K=map(int,input().split())
visited[K-1]=0
q=deque([])
q.append(K-1)
while q:
  u=q.popleft()
  for v,d in tree[u]:
    if visited[v]==-1:
      visited[v]=visited[u]+d
      q.append(v)
    
for i in range(Q):
  x,y=map(int,input().split())
  print(visited[x-1]+visited[y-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
tree=[[] for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  tree[a-1].append((b-1,c))
  tree[b-1].append((a-1,c))
depth=[0 for i in range(N)]
def dfs(v,p,d):
  depth[v]=d
  for vv,dd in tree[v]:
    if vv==p:
      continue
    dfs(vv,v,d+dd)
Q,K=map(int,input().split())
dfs(K-1,-1,0)
for i in range(Q):
  x,y=map(int,input().split())
  print(depth[x-1]+depth[y-1])