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

Fixed submission:
n = int(input())
lis = list(map(int,input().split()))
ans = 10 ** 9
le = 0
ri = sum(lis)
ans = sum(lis)
for num in lis:
  le += num
  ri -= num
  ans = min(ans,abs(ri-le))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
lis = list(map(int,input().split()))
le = 0
ri = sum(lis)
ans = sum(lis)
cou = 0
for i in range(1,101):
  while lis[cou] == i:
    le += lis[cou]
    ri -= lis[cou]
    cou += 1
  ans = min(ans,abs(le-ri))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
lis = list(map(int,input().split()))
le = 0
ri = sum(lis)
ans = sum(lis)
cou = 0
for i in range(1,101):
  while lis[cou] == i:
    ri += lis[cou]
    le -= lis[cou]
    cou += 1
  ans = min(ans,abs(le-ri))
print(ans)
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
lis = [int(input()) for i in range(m)]
dp = [0 for i in range(n+2)]
lis.append(0)
dp[0] = 1
cou = 0
co = 0
if lis[0] == 1:co += 1
for i in range(n):
  if i+1 != lis[cou]:
    dp[i+1] += dp[i]
    dp[i+1] %= 10 ** 9+7
  else:
    cou +=1
  if i+2 != lis[co]:
    dp[i+2] += dp[i]
    dp[i+2] %= 10 ** 9 + 7
  else:
    co += 1
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
lis = [int(input()) for i in range(m)]
dp = [0 for i in range(n+2)]
dp[0] = 1
cou = 0
co = 0
for i in range(n):
  if i+1 != lis[cou]:
    dp[i+1] += dp[i]
    dp[i+1] %= 10 ** 9+7
  else:
    cou +=1
  if i+2 !=  lis[co]:
    dp[i+2] += dp[i]
    dp[i+2] %= 10 ** 9 + 7
  else:
    co += 1
print(dp[n])
Problem p03041 (python)

Fixed submission:
n,m = map(int,input().split())
s = str(input())
print(s[:m-1]+chr(ord(s[m-1])-ord("A")+ord("a"))+s[m:])

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

Fixed submission:
import copy
from collections import deque
def main():
  H, W = map(int, input().split())
  M = [['#' == x for x in input()] for _ in range(H)]

  black = deque([(i, j) for i in range(H) for j in range(W) if M[i][j]])

  ans = 0
  while True:
    ans += 1
    next_black = deque()
    while black:
      bi, bj = black.popleft()
      if bi > 0 and not M[bi - 1][bj]:
        M[bi - 1][bj] = True
        next_black.append((bi - 1, bj))
      if bj > 0 and not M[bi][bj - 1]:
        M[bi][bj - 1] = True
        next_black.append((bi, bj - 1))
      if bi < H - 1 and not M[bi + 1][bj]:
        M[bi + 1][bj] = True
        next_black.append((bi + 1, bj))
      if bj < W - 1 and not M[bi][bj + 1]:
        M[bi][bj + 1] = True
        next_black.append((bi, bj + 1))
    if next_black:
       black = copy.copy(next_black)
    else:
       break
  print(ans - 1)
  
if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
n,w = map(int,input().split())
lis = []
s = [str(input()) for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      lis.append([i,j])
ans = 0
for i in range(h):
  for j in range(w):
    num = 10 ** 7
    for x,y in lis:
      num = min(num,abs(i-x)+abs(j-y))
    ans = max(ans,num)
print(ans)
Problem p03073 (python)

Fixed submission:
s = str(input())
w1,w2,b1,b2 = 0,0,0,0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      w1 += 1
    else:
      b1 += 1
  else:
    if s[i] == "0":
      w2 += 1
    else:
      b2 += 1
print(min(w1+b2,w2+b1))

Buggy submission (verdict: Runtime Error):
s = str(input())
w1,w2,b1,b2 = 0,0,0,0
for i in range(len(s)):
  if i % 2 == 0:
  	if s[i] == "0":
      w1 += 1
    else:
      b1 += 1
  else:
    if s[i] == "0":
      w2 += 1
    else:
      b2 += 1
print(min(w1+b2,w2+b1))
Problem p03077 (python)

Fixed submission:
n = int(input())
lis = [int(input()) for i in range(5)]
key = 0
if n % min(lis) == 0:key = 1
print(5 + n//min(lis)-key)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
lis = [int(input()) for i in range(n)]
print(5 + math.ceil(n/min(lis))-1)
Problem p03221 (python)

Fixed submission:
from operator import itemgetter
n,m = map(int,input().split())
lis = []
ans = [0 for i in range(m)]
num = [0 for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  lis.append([i,a,b])
lis.sort(key=itemgetter(2))
for i in range(m):
  num[lis[i][1]-1] += 1
  cou = max(0,5-(lis[i][1] // 10))
  co = max(0,5-(num[lis[i][1]-1] // 10))
  ans[lis[i][0]] = format(lis[i][1],'06d') + format(num[lis[i][1]-1],'06d')
for i in range(m):print(ans[i])

Buggy submission (verdict: Runtime Error):
n,m =map(int,input().split())
lis = [list(map(int,input().split())) for i in range(m)]
for i in range(n):
    lis[i].append(i)
lis.sort()
cnt = 1
ans = []
ans.append([lis[0][-1],format(lis[0][0]).zfill(6)+format(1).zfill(6)])
for i in range(m-1):
    if lis[i][0] == lis[i+1][0]:
        cnt += 1
        ans.append([lis[i+1][-1],format(lis[i+1][0]).zfill(6)+format(cnt).zfill(6)])
    else:
        cnt = 1
        ans.append([lis[i+1][-1],format(lis[i+1][0]).zfill(6)+format(cnt).zfill(6)])
ans.sort(key = lambda x:x[0])
for i,x in ans:
    print(x)
Problem p03329 (python)

Fixed submission:
n = int(input())

lis = [1, 6, 36, 216, 1296, 7776, 46656,
     9, 81, 729, 6561, 59049]
m = len(lis)

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

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < lis[i]:
            continue
        else:
            temp.append(dp[j-lis[i]]+1)
    dp[j] = min(temp)

print(dp[n])

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

lis = [1, 6, 36, 216, 1296, 7776, 46656,
     9, 81, 729, 6561, 59049]
m = len(c)

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

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < lis[i]:
            continue
        else:
            temp.append(dp[j-lis[i]]+1)
    dp[j] = min(temp)

print(dp[n])

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

lis = [1, 6, 36, 216, 1296, 7776, 46656,
     9, 81, 729, 6561, 59049]
m = len(c)

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

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < c[i]:
            continue
        else:
            temp.append(dp[j-lis[i]]+1)
    dp[j] = min(temp)

print(dp[n])
Problem p03426 (python)

Fixed submission:
import math
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
lis = [[0,0] for i in range(h * w)]
num = [[0] * math.ceil((h * w) // d + 1) for i in range(d)]

for i in range(h):
    for j in range(w):
        lis[a[i][j]-1] = [i,j]

for i in range(h * w-d):
    num[i%d][i//d+1] = num[i%d][i//d]+abs(lis[i][0]-lis[i+d][0])+abs(lis[i][1]-lis[i+d][1])

q = int(input())
for _ in range(q):
    now,goal = map(int,input().split())
    if now % d == 0:
        print(num[now%d-1][(goal-now%d)//d-1]-num[now%d-1][(now-now%d)//d-1])
    else:
        print(num[now%d-1][(goal-now%d)//d]-num[now%d-1][(now-now%d)//d])

Buggy submission (verdict: Runtime Error):
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
lis = [[0,0] for i in range(h * w)]
num = [[0] * math.ceil((h * w) // d + 1) for i in range(d)]
for i in range(h):
    for j in range(w):
        lis[a[i][j]-1] = [i,j]
for i in range(h * w-d):
    num[i%d][i//d+1] = num[i%d][i//d]+abs(lis[i][0]-lis[i+d][0])+abs(lis[i][1]-lis[i+d][1])
q = int(input())
for _ in range(q):
    now,goal = map(int,input().split())
    if now % d == 0:
        print(num[now%d-1][(goal-now%d)//d-1]-num[now%d-1][(now-now%d)//d-1])
    else:
        print(num[now%d-1][(goal-now%d)//d]-num[now%d-1][(now-now%d)//d])
Problem p03618 (python)

Fixed submission:
n = str(input())
lis = [0 for i in range(26)]
ans = 1
for i in range(len(n)):
  ans += i
  lis[ord(n[i])-ord("a")] += 1
for i in range(26):
  for k in range(lis[i]-1):
    ans -= (k+1)
print(ans)

Buggy submission (verdict: Runtime Error):
n = str(input())
lis = [0 for i in range(26)]
ans = 1
for i in range(1,len(n)+1):
  ans += i
  lis[ord(n[i])-"a"] += 1
for i in range(26):
  for k in range(lis[i]-1):
    ans -= (k+1)
print(ans)
Problem p03631 (python)

Fixed submission:
N = input()
A = int(N[0])
B = int(N[1])
C = int(N[2])
if A==C:
 print("Yes")
else:
 print("No")

Buggy submission (verdict: Runtime Error):
a = input()
A = a[0]
B = a[2]
if A == B:
 print(Yes)
else:
 print(No)

Buggy submission (verdict: Runtime Error):
a = input()
b = int(a[0])
c = int(a[2])
if b = c:
 print("Yes")
else:
 print("No")

Buggy submission (verdict: Runtime Error):
a = input()
b = int(a[0])
c = int(a[2])
if b = c:
print("Yes")
else:
print("No")

Buggy submission (verdict: Runtime Error):
a = input()
b = a[0]
c = a[2]
if b = c:
print("Yes")
else:
print("No")

Buggy submission (verdict: Runtime Error):
a = (input())
b = a[0]
c = a[2]
if b = c:
print("Yes")
else:
print("No")

Buggy submission (verdict: Runtime Error):
a = input().split()
A = int(a[0])
B = int(a[1])
C = int(a[2])
if A == C:
 print("Yes")
else:
 print("No")
Problem p03724 (python)

Fixed submission:
from collections import Counter

n, q = map(int, input().split())
c = Counter()
for _ in range(q):
    u, v = map(int, input().split())
    c[u] += 1
    c[v] += 1

safe = all(c[x] % 2 == 0 for x in c)
print('YES' if safe else 'NO')

Buggy submission (verdict: Runtime Error):
from collections import Counter
n,m = map(int,input().split())
lis = []
il = set()
key = 0
for i in range(n):
    a,b = map(int,input().split())
    lis.append(a)
    lis.append(b)
    il.add(a)
    il.add(b)
for h in range(len(il)):
    try:
        if lis.count(h+1) % 2 == 1:
            print("NO")
            key = 1
            break
    except:
        continue
if key == 0:
    print("YES")
Problem p03834 (python)

Fixed submission:
a = input()
A =a[0]+a[1]+a[2]+a[3]+a[4]
B =a[6]+a[7]+a[8]+a[9]+a[10]+a[11]+a[12]
C =a[14]+a[15]+a[16]+a[17]+a[18]
print(A,B,C)

Buggy submission (verdict: Runtime Error):
a,b,c = map(str(input().split(",")))
print(a,b,c)

Buggy submission (verdict: Runtime Error):
a = input()
a[5] = " "
a[13] = " "
print(a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9]+a[10]+a[11]+a[12]+a[13]+a[14]+a[15]+a[16]+a[17]+a[18])
Problem p03835 (python)

Fixed submission:
k, s = map(int,input().split())
x = 0
y = 0
z = 0
ans = 0
for i in range(k+1):
    for n in range(k+1):
        z = s - (i + n)
        if 0 <= z and z <= k:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
k, s = map(int,input().split())
ans = 0
x = 0
y = 0
z = 0
for i in range(k):
    for n in range(k):
        for m in range(k):
            if x + y + z = s:
                ans += 1
            z += 1
        y += 1
    x += 1
print(ans)
Problem p02580 (python)

Fixed submission:
import random
import time
start=time.time()
h,w,m=map(int,input().split())
hh=[[0,i]for i in range(h)]
ww=[[0,i]for i in range(w)]
hw=set()
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  hh[a][0]+=1
  ww[b][0]+=1
  hw.add((a,b))
ww.sort(reverse=1)
s=ww[0][0]
w=[]
for x,j in ww:
  if x==s:w.append(j)
hh.sort(reverse=1)
t=hh[0][0]
hhh=[]
for x,i in hh:
  if x==t:hhh.append((x,i))
ans=[]
random.shuffle(w)
for j in w:
  for x,i in hhh:
    if (i,j) in hw:
      ans.append(s+x-1)
    else:
      exit(print(s+x))
  if time.time()-start>=1.7:
    m=ans[0]
    if h-50000<=len(hhh)<=h-random.randint(1,30):m+=1
    exit(print(m))
print(ans[0])

Buggy submission (verdict: Runtime Error):
import random
import time
start=time.time()
h,w,m=map(int,input().split())
hh=[[0,i]for i in range(h)]
ww=[[0,i]for i in range(w)]
hw=set()
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  hh[a][0]+=1
  ww[b][0]+=1
  hw.add((a,b))
ww.sort(reverse=1)
s=ww[0][0]
w=[]
for x,j in ww:
  if x==s:w.append(j)
hh.sort(reverse=1)
t=hh[0][0]
hhh=[]
for x,i in hh:
  if x==t:h.append((x,i))
ans=[]
random.shuffle(w)
for j in w:
  for x,i in hhh:
    if (i,j) in hw:
      ans.append(s+x-1)
    else:
      exit(print(s+x))
  if time.time()-start>=1.7:
    m=ans[0]
    if h-50000<=len(hhh)<=h-random.randint(1,30):m+=1
    exit(print(m))
print(ans[0])
Problem p02634 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
mod=998244353
dp=[(d+1)*[0]for _ in range(c+1)]
for i in range(a,c+1):
  for j in range(b,d+1):
    if i==a and j==b:
      dp[i][j]=1
      continue
    if i==a:
      dp[i][j]=dp[i][j-1]*i%mod
      continue
    if j==b:
      dp[i][j]=dp[i-1][j]*j%mod
      continue
    dp[i][j]=(dp[i-1][j]*j+dp[i][j-1]*i-dp[i-1][j-1]*(i-1)*(j-1))%mod
print(dp[c][d])

Buggy submission (verdict: Runtime Error):
#wrong sample.
a,b,c,d=map(int,input().split())
mod=998244353
f=[1]
for i in range(10000):f+=[f[-1]*(i+1)%mod]
def comb(a,b):return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod
dp=[(d+1)*[0]for _ in range(c+1)]
dp[a][b]=1
def dfs(x,y):
  if dp[x][y]!=0:return dp[x][y]
  if x!=a and y!=b:
    ans=(dfs(x-1,y-1)*comb(x+y-1,2))%mod
    if (x-a)+(y-b)-1>=2:
      ans=(ans+comb(x-a+y-b-1,2))%mod
  elif x!=a:
    ans=(dfs(x-1,y)*y)%mod
  elif y!=b:
    ans=(dfs(x,y-1)*x)%mod
  else:
    ans=1
  dp[x][y]=ans
  return ans
print(dfs(c,d))
#for i in dp:print(i)
Problem p02695 (python)

Fixed submission:
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split()))for _ in range(q)]
ans=0
for i in itertools.combinations_with_replacement(range(m),n):
  anss=0
  for a,b,c,d in abcd:
    if i[b-1]-i[a-1]==c:anss+=d
  ans=max(ans,anss)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import*;n,m,q=map(int,input().split());l=[list(map(int,input().split()))for _ in[0]*q];print(max(sum(d for a in l if i[b-1]-i[a-1]==c)for i in itertools.combinations_with_replacement(range(m),n)))

Buggy submission (verdict: Runtime Error):
import itertools;n,m,q,*l=map(int,open(0).read().split());print(max(sum(d for a in[l[j*4:j*4+4]for j in range(q)]if i[b-1]-i[a-1]==c)for i in itertools.combinations_with_replacement(range(m),n)))

Buggy submission (verdict: Runtime Error):
import itertools;n,m,q,*l=map(int,open(0).read().split());print(max(sum(d for a,b,c,d in l[::4]if i[b-1]-i[a-1]==c)for i in itertools.combinations_with_replacement(range(m),n)))
Problem p02781 (python)

Fixed submission:
n=input()
k=int(input())
dp=[[(k+1)*[0]for _ in range(2)]for _ in range(len(n))]
#dp[i][flag][j]...i文字目までみて0以外がj個あるパターン数
#flag...True(n[])
dp[0][0][0]=1
dp[0][1][1]=1
dp[0][0][1]=int(n[0])-1
for i in range(1,len(n)):
  for j in range(k+1):dp[i][1][j]=dp[i-1][1][j]
  if n[i]!="0":dp[i][1]=[0]+dp[i][1][:k]
  for j in range(k+1):dp[i][0][j]=dp[i-1][0][j]
  for j in range(k):
    dp[i][0][j+1]+=dp[i-1][0][j]*9
    if n[i]!="0":
      dp[i][0][j+1]+=dp[i-1][1][j]*(int(n[i])-1)
      dp[i][0][j+1]+=dp[i-1][1][j+1]
print(dp[-1][0][-1]+dp[-1][1][-1])
#for i in dp:print(*i)

Buggy submission (verdict: Runtime Error):
n=input()
l=len(n)
k=int(input())
def f(n,k):
  l=len(n)
  if n[0]=="0":return f(n[1:],k)
  if l<k:return 0
  if k==1:
    ans=((l-1)*9)+int(n[0])
  if k==2:
    ans=((l-1)*(l-2)//2)*81+(int(n[0])-1)*((l-1)*9)
    ans+=f(n[1:],k-1)
  if k==3:
    ans=(int(n[0])-1)*((l-1)*(l-2)//2)*81+((l-1)*(l-2)*(l-3)//6)*9*9*9
    ans+=f(n[1:],k-1)
  return ans
print(f(n,k))

Buggy submission (verdict: Runtime Error):
n=input()
if n[0]=="0"ans=1/0
l=len(n)
k=int(input())
if l<6:
  n=int(n)
  ans=0
  for i in range(1,n+1):
    if len(str(i))-str(i).count("0")==k:ans+=1
  print(ans)
  exit()
if k==1:
  ans=((l-1)*9)+int(n[0])
  print(ans)
if k==2:
  ans=((l-1)*(l-2)//2)*81
  ans+=(int(n[0])-1)*((l-1)*9)
  ans+=int(n[1])
  ans+=(l-2)*9
  print(ans)
if k==3:
  ans=int(n[2])+(l-3)*9
  ans+=(int(n[1])-1)*((l-2)*9)
  ans+=((l-2)*(l-3)//2)*81
  ans+=(int(n[0])-1)*((l-1)*(l-2)//2)*81
  ans+=((l-1)*(l-2)*(l-3)//6)*9*9*9
  print(ans)
Problem p02892 (python)

Fixed submission:
n=int(input())
b=[[]for _ in range(n)]
d=[]
inf=float('inf')
inf=float('inf')
for i in range(n):
  s=input()
  c=[]
  for j in range(n):
    if s[j]=="1":
      b[i]+=[(i,j)]
    c.append(1 if s[j]=="1" else inf)
  d.append(c)
def warshall_floyd(d):
    for i in range(n):d[i][i]=0
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
d=warshall_floyd(d)
x=[-1]*n
x[0]=0
Q=b[0]
while Q:
  p=[]
  for i,j in Q:
    if x[j]<0:
      x[j]=x[i]^1
      p+=b[j]
    elif x[i]==x[j]:print(-1);exit()
  Q=p
z=0
for i in d:
  for j in i:
    if j!=float("inf"):z=max(j,z)
print(z+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
b=[[]for _ in range(n)]
d=[]
inf=float('inf')
for i in range(n):
  s=input()
  c=[]
  for j in range(n):
    if s[j]=="1":
      b[i]+=[(i,j)]
    c.append(1 if s[j]=="1" else inf)
  d.append(c)
from scipy.sparse.csgraph import bellman_ford
d=bellman_ford(d)
x=[-1]*n
x[0]=0
Q=b[0]
while Q:
  p=[]
  for i,j in Q:
    if x[j]<0:
      x[j]=x[i]^1
      p+=b[j]
    elif x[i]==x[j]:print(-1);exit()
  Q=p
print(int(max(map(max,*d)))+1)
Problem p03003 (python)

Fixed submission:
mod=10**9+7
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[(m+1)*[1]for _ in range(n+1)]
for i in range(n):
  for j in range(m):
    if s[i]==t[j]:dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]
    else:dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j]
    dp[i+1][j+1]%=mod
print(dp[-1][-1])

Buggy submission (verdict: Runtime Error):
mod=10**9+7
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp1=[1]*(m+1)
dp2=[1]*(m+1)
for i in range(n):
  for j in range(m):
    if s[i]==t[i]:dp1[j+1]=dp2[j+1]+dp1[j]
    else:dp1[j+1]=dp2[j+1]+dp1[j]-dp2[j]
    dp1[j+1]%=mod
  dp2=dp1
  dp1=[1]*(m+1)
print(dp2[-1])
Problem p03011 (python)

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

Buggy submission (verdict: Runtime Error):
p,g,r=map(int,input().split())
print(min(p+q,q+r,r+p))
Problem p03012 (python)

Fixed submission:
n,w=int(input()),list(map(int,input().split()))
a=[w[0]]
for i in w[1:]:a.append(a[-1]+i)
ans=a[-1]
for i in a:
  if ans>abs((a[-1]-i)-i):ans=abs((a[-1]-i)-i)
print(ans)

Buggy submission (verdict: Runtime Error):
n,w=int(input()),list(map(int,input().split()))
a=w[0]
for i in w[1:]:a.append(a[-1]+i)
ans=a[-1]
for i in a:
  if ans>max(i,ans-i):ans=a[-1]-i
print(ans)
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
dp=[0]*(n+1)
dp[0]=1
a=b=0
if b<m:a=int(input())
for i in range(1,n+1):
  if i==a:
    b+=1
    if b<m:a=int(input())
  else:
    dp[i]=dp[i-1]
    if i>1:dp[i]+=dp[i-2]
  dp[i]%=(10**9+7)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=%10**9+7
dp=[0]*(n+7)
dp[0]=1
a=[int(input())for _ in range(m)]
a=set(a)
for i in range(n):
  if i+1 not in a:
    dp[i+2]+=dp[i]
    dp[i+1]+=dp[i]
  dp[i+2]%=mod
print(dp[n]%mod)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
dp=[0]*(n+7)
dp[0]=1
a=list(map(int,input().split()))
a=set(a)
for i in range(n):
  if i+1 not in a:
    dp[i+2]+=dp[i]
    dp[i+1]+=dp[i]
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
dp=[0]*(n+1)
dp[0]=1
a=int(input())
b=0
for i in range(1,n+1):
  if i==a:
    b+=1
    if b<m:a=int(input())
  else:
    dp[i]=dp[i-1]
    if i>1:dp[i]+=dp[i-2]
  dp[i]%=(10**9+7)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
dp=[0]*(n+1)
dp[0]=1
a=int(input())
b=0
for i in range(1,n+1):
  if i==a:
    b+=1
    if b<m:a=int(input())
  else:dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[-1])
Problem p03053 (python)

Fixed submission:
from collections import deque
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
d=deque()
dc=0
b=[]
for i in range(h):
  t=[]
  s=input()
  for j in range(w):
    if s[j]=="#":d.append((i,j));dc+=1;t.append(1)
    else:t.append(0)
  b.append(t)
count=0
while dc!=0:
  ld=dc
  dc=0
  for i in range(ld):
    x=d.popleft()
    if x[0]<h-1:
      if b[x[0]+1][x[1]]==0:b[x[0]+1][x[1]]=1;d.append((x[0]+1,x[1]));dc+=1
    if 0<x[0]:
      if b[x[0]-1][x[1]]==0:b[x[0]-1][x[1]]=1;d.append((x[0]-1,x[1]));dc+=1
    if x[1]<w-1:
      if b[x[0]][x[1]+1]==0:b[x[0]][x[1]+1]=1;d.append((x[0],x[1]+1));dc+=1
    if 0<x[1]:
      if b[x[0]][x[1]-1]==0:b[x[0]][x[1]-1]=1;d.append((x[0],x[1]-1));dc+=1
  count+=1
print(count-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
d=deque()
b=[]
for i in range(h):
  s=input()
  for j in range(w):
    if s[j]=="#":d.append([i,j])
  b.append(list(s))
count=0
while len(d)!=0:
  for i in range(len(d)):
    x=d.popleft()
    if x[0]<h-1:
      if b[x[0]+1][x[1]]==".":b[x[0]+1][x[1]]=count;d.append([x[0]+1,x[1]])
    if 0<x[0]
      if b[x[0]-1][x[1]]==".":b[x[0]-1][x[1]]=count;d.append([x[0]-1,x[1]])
    if x[1]<w-1
      if b[x[0]][x[1]+1]==".":b[x[0]][x[1]+1]=count;d.append([x[0],x[1]+1])
    if 0<x[1]
      if b[x[0]][x[1]-1]==".":b[x[0]][x[1]-1]=count;d.append([x[0],x[1]-1])
  count+=1
print(count-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
d=deque()
for i in range(h):
  s=input()
  for j in range(w):
    if s[j]=="#":d.append([i,j])
  b.append(list(s))
count=0
while len(d)!=0:
  for i in range(len(d)):
    x=d.popleft()
    if x[0]<h-1:
      if b[x[0]+1][x[1]]==".":b[x[0]+1][x[1]]=count;d.append([x[0]+1,x[1]])
    if 0<x[0]
      if b[x[0]-1][x[1]]==".":b[x[0]-1][x[1]]=count;d.append([x[0]-1,x[1]])
    if x[1]<w-1
      if b[x[0]][x[1]+1]==".":b[x[0]][x[1]+1]=count;d.append([x[0],x[1]+1])
    if 0<x[1]
      if b[x[0]][x[1]-1]==".":b[x[0]][x[1]-1]=count;d.append([x[0],x[1]-1])
  count+=1
print(count-1)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a,s=[],[["x"for i in range(w+2)]]
for i in range(h):
  t,tt=input(),[]
  for j in range(w):
    if t[j]=="#":a.append([i+1,j+1])
    tt.append(t[j])
  s.append(["x"]+tt+["x"])
s.append(["x"for i in range(w+2)])
f=1
while 1:
  b=[]
  for k in a:
    i,j=k[0],k[1]
    if s[i-1][j]==".":s[i-1][j]=f;b.append([i-1,j])
    if s[i+1][j]==".":s[i+1][j]=f;b.append([i+1,j])
    if s[i][j-1]==".":s[i][j-1]=f;b.append([i,j-1])
    if s[i][j+1]==".":s[i][j+1]=f;b.append([i,j+1])
  a=b.copy()
  f+=1
  if len(a)==0:break
print(f-2)
Problem p03072 (python)

Fixed submission:
n,h=int(input()),list(map(int,input().split()));m,a=0,0
for i in range(n):
  if m<=h[i]:
    a+=1
    m=h[i]
print(a)

Buggy submission (verdict: Runtime Error):
n,h=int(input());list(map(int,input().split()));m,a=0,0
for i in range(n):
  if m<=h[i]:
    a+=1
    m=h[i]
print(a)
Problem p03075 (python)

Fixed submission:
a,b,c,d,e=int(input()),int(input()),int(input()),int(input()),int(input())
k=int(input())
print("Yay!"if e-a<=k else":(")

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k=map(int,input().split())
if e-a>k:print(":(")
else:print("Yey!")

Buggy submission (verdict: Runtime Error):
a=[int(input())for _ in range(5)]
k=int(input())
if e-a<=k:print("Yay!")
else:print(":(")
Problem p03221 (python)

Fixed submission:
n,m = map(int,input().split())
py = []
for i in range(m):
    py.append(list(map(int,input().split())))
    py[i].append(i)
py.sort(key=lambda x:x[1])
py.sort(key=lambda x:x[0])
x = py[0][0]
j=0
for i in range(m):
    if x != py[i][0]:
        j = 1
        x = py[i][0]
    else:
        j+=1
    s = str(py[i][0]).zfill(6) + str(j).zfill(6)
    py[i].append(s)
py.sort(key=lambda x:x[2])
for i in range(m):
    print(py[i][3])

Buggy submission (verdict: Runtime Error):
def pypri(p,y):print(str(p).zfill(6)+str(y).zfill(6))
n,m=map(int,input().split())
a=[[]for _ in range(n)]
b=[]
for i in range(m):
  p,y=map(int,input.split())
  b.append(p-1)
  a[p-1].append([y,len(a[p-1])+1])
for i in range(n):
  a[i].sort()
  for j in range(len(a[i])):
    a[i][j]=[a[i][j][1],j]
    a.sort()
for i in b:
  pypri(i+1,a[i][0][1]+1)
  del a[i][0]
Problem p03250 (python)

Fixed submission:
a=list(map(int,input().split()));print(sum(a)+max(a)*9)

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split));print(sum(a)+max(a)*9)