Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)

Buggy python submission (verdict: Runtime Error):

    n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)
    ans="No"
    break
print(ans)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=map(int,input().split())
ans="Yes"
for i in range(n:0:-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)
    
    

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1,0,-1):
  if h[i-1]<=h[i]:
    continue
  elif h[i-1]==h[i]+1:
    h[i-1]=h[i-1]-1
  else:
    ans="No"
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = 10**5
keta = 17
S = list(input())
n = len(S)
npE = np.eye(n)
A = [[0]*n for i in range(n)]
for i in range(n):
  if S[i]=="R":
    A[i][i+1]=1
  else:
    A[i][i-1]=1
npA = np.array(A)
ans = npE
for i in range(keta):
  if N >> i & 1:
    ans = np.dot(ans,npA)
  npA = np.dot(npA, npA)
aa=ans.T
aaa = []
for i in range(n):
  aaa.append(int(sum(list(aa[i]))))
print(*aaa)

Fixed submission:
S = input()
S = (S.replace('LR','L R')).split()
def subans(SR):
  rl =len(SR) 
  r = SR.count('R')
  l = rl-r
  r1 = rl//2
  r2 = rl-r1
  ret = [0]*rl
  if r%2==0:
    ret[r-1],ret[r] = r1,r2
  else:
    ret[r-1],ret[r] = r2,r1
  return ret
ans = []
for _ in S:
  ans += subans(_)
print(*ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = 10**100
keta = 333
S = list(input())
n = len(S)
npE = np.eye(n)
A = [[0]*n for i in range(n)]
for i in range(n):
  if S[i]=="R":
    A[i][i+1]=1
  else:
    A[i][i-1]=1
npA = np.array(A)
ans = npE
for i in range(keta):
  if N >> i & 1:
    ans = np.dot(ans,npA)
  npA = np.dot(npA, npA)
aa=ans.T
aaa = []
for i in range(n):
  aaa.append(int(sum(list(aa[i]))))
print(*aaa)

Fixed submission:
S = input()
S = (S.replace('LR','L R')).split()
def subans(SR):
  rl =len(SR) 
  r = SR.count('R')
  l = rl-r
  r1 = rl//2
  r2 = rl-r1
  ret = [0]*rl
  if r%2==0:
    ret[r-1],ret[r] = r1,r2
  else:
    ret[r-1],ret[r] = r2,r1
  return ret
ans = []
for _ in S:
  ans += subans(_)
print(*ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = 10**100
keta = 334
S = list(input())
n = len(S)
npE = np.eye(n)
A = [[0]*n for i in range(n)]
for i in range(n):
  if S[i]=="R":
    A[i][i+1]=1
  else:
    A[i][i-1]=1
npA = np.array(A)
ans = npE
for i in range(keta):
  if N >> i & 1:
    ans = np.dot(ans,npA)
  npA = np.dot(npA, npA)
aa=ans.T
aaa = []
for i in range(n):
  aaa.append(int(sum(list(aa[i]))))
print(*aaa)

Fixed submission:
S = input()
S = (S.replace('LR','L R')).split()
def subans(SR):
  rl =len(SR) 
  r = SR.count('R')
  l = rl-r
  r1 = rl//2
  r2 = rl-r1
  ret = [0]*rl
  if r%2==0:
    ret[r-1],ret[r] = r1,r2
  else:
    ret[r-1],ret[r] = r2,r1
  return ret
ans = []
for _ in S:
  ans += subans(_)
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9 + 7
s = input()
n = len(s)
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
for i, si in enumerate(s):
  if si == '?':
    for ss in range(10):
      for j in range(13):
        dp[i+1][(j*10+ss)%13] += dp[i][j]
        dp[i+1][(j*10+ss)%13] %= mod
  else:
    ss = int(si)
    for j in range(13):
      dp[i+1][(j*10+ss)%13] += dp[i][j]
      dp[i+1][(j*10+ss)%13] %= mod
#print(dp)
print(dp[n][5])

Fixed submission:
mod = 10**9 + 7
s = input()
n = len(s)
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
for i, si in enumerate(s):
  if si == '?':
    for ss in range(10):
      for j in range(13):
        dp[i+1][(j*10+ss)%13] += dp[i][j]
        dp[i+1][(j*10+ss)%13] %= mod
  else:
    ss = int(si)
    for j in range(13):
      dp[i+1][(j*10+ss)%13] += dp[i][j]
      dp[i+1][(j*10+ss)%13] %= mod
#print(dp)
print(dp[n][5])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
B=['0']*N
ret1=0
ret2=''
for i in range(N, 0, -1):
  Bit='0'*i+('0'*(i-1)+'1')*(N//i)
  Bit=int(Bit[:N], 2)
  BBit=int(''.join(B), 2)
  if bin(BBit & Bit).count('1')%2 ^ A[i-1]:
    ret1+=1
    B[i-1]='1'
    ret2=str(i)+' '+ret2
print(ret1)
print(ret2)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
ret = []
for i in range(N, 0, -1):
  if (sum(B[i-1::i])%2) != A[i-1]:
    B[i-1]= 1
    ret.append(i)
print(sum(B))
print(*ret)
Buggy python submission (verdict: Runtime Error):
L,R=map(int, input().split())
from itertools import permutations, combinations,combinations_with_replacement,product
for 
if (R+1-L)<2019:
  LR = range(L,R+1)
  LRA = []
  for i in LR:
    LRA.append(i%2019)
  LRAA = set(LRA)
  C = combinations(LRAA, 2)
  Ret = 2019
  for i in list(C):
    Ret = min(Ret,(i[0]*i[1])%2019)
else:
  Ret = 0
print(Ret)

Fixed submission:
L,R=map(int, input().split())
LR = range(L,R+1)
from itertools import permutations, combinations,combinations_with_replacement,product
if (R+1-L)<2019:
  C = combinations(LR, 2)
  Ret = 2019
  for i in list(C):
    Ret = min(Ret,(i[0]*i[1])%2019)
else:
  Ret = 0
print(Ret)

Buggy python submission (verdict: Runtime Error):
L,R=map(int, input().split())
LR = range(L,R+1)
from itertools import permutations, combinations,combinations_with_replacement,product
C = combinations(LR, 2)
Ret = 2019
for i in C:
  Ret = min(Ret,(i[0]*i[1])%2019)
print(Ret)

Fixed submission:
L,R=map(int, input().split())
LR = range(L,R+1)
from itertools import permutations, combinations,combinations_with_replacement,product
if (R+1-L)<2019:
  C = combinations(LR, 2)
  Ret = 2019
  for i in list(C):
    Ret = min(Ret,(i[0]*i[1])%2019)
else:
  Ret = 0
print(Ret)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
k=N//2
D=list(map(int,input().split()))
DD=D[:]+D[:]
T=sum(D)
ret=[0]*N
for i in range(N):
  ret[i]=T-2*sum(DD[i+1:i+2*k:2])
print(*ret)

Fixed submission:
N=int(input())
k=N//2
D=list(map(int,input().split()))
DD=D[:]+D[:]
DS=[0]*(2*N+1)
for i in range(0,2*N-2,2):
  DS[i+2]=DS[i]+DD[i]
  DS[i+3]=DS[i+1]+DD[i+1]
T=sum(D)
ret=[0]*N
for i in range(N):
#  print(sum(DD[i+1:i+2*k:2]))
#  print(DS[i+1+2*k]-DS[i+1])
#  ret[i]=T-2*sum(DD[i+1:i+2*k:2])
  ret[i]=T-2*(DS[i+1+2*k]-DS[i+1])
print(*ret)
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[]
for i in L:
  D.append(D[-1]+i)
  if D[-1]>X:
    print(len(D)-1)
    break

Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[0]
cnt=0
for i in L:
  D.append(D[-1]+i)
for i in D:
  if i<=X:
    cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if (W/x) == 2 and (H/y)==2:
  R = 1
else:
  R = 0
print(D, R)


Fixed submission:
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if W == 2*x and H==2*y:
  R = 1
else:
  R = 0
print(D, R)

Buggy python submission (verdict: Runtime Error):
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if W//x==2 and H//y==2:
  R = 1
else:
  R = 0
print(D, R)


Fixed submission:
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if W == 2*x and H==2*y:
  R = 1
else:
  R = 0
print(D, R)

Buggy python submission (verdict: Runtime Error):
W,H,x,y=map(int, input().split())
  D = 0.5*H*W
  if W//x==2 and H//y==2:
    R = 1:
  else:
    R = 0
print(D, R)


Fixed submission:
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if W == 2*x and H==2*y:
  R = 1
else:
  R = 0
print(D, R)

Buggy python submission (verdict: Runtime Error):
W,H,x,y=map(int, input().split())
if W-x < x:x = W-x
if H-y < y:y = H-y
D1 = x*H
D2 = y*W
if x !=0 and y!=0:
  D = max(D1,D2)
  if x==y:
    R = 1
  else
    R = 0
else:
  D = 0.5*H*W
  R = 0
print(D, R)


Fixed submission:
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if W == 2*x and H==2*y:
  R = 1
else:
  R = 0
print(D, R)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
if y = 1:
  print(0)
else:
  print(x-y)

Fixed submission:
x,y=map(int,input().split())
if y == 1:
  print(0)
else:
  print(x-y)
Buggy python submission (verdict: Runtime Error):
N =int(input())
S = map(int,input().split())
TT = sum(TT)
T1 = 0
Ans = TT
for i in range(N):
  T1 += S[i]
  Ans = min(Ans,ABS(TT-T1-T1))
print(Ans)

Fixed submission:
N =int(input())
S = list(map(int,input().split()))
TT = sum(S)
T1 = 0
Ans = TT
for i in range(N):
  T1 += S[i]
  Ans = min(Ans,abs(TT-T1-T1))
print(Ans)

Buggy python submission (verdict: Runtime Error):
N =inptut()
S = map(int,imput().split())
TT = sum(TT)
T1 = 0
Ans = TT
for i in range(N):
  T1 += S[i]
  Ans = min(Ans,ABS(TT-T1-T1))
print(Ans)

Fixed submission:
N =int(input())
S = list(map(int,input().split()))
TT = sum(S)
T1 = 0
Ans = TT
for i in range(N):
  T1 += S[i]
  Ans = min(Ans,abs(TT-T1-T1))
print(Ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
mod = 10**9+7
fram = [1]
for i in range(1,N+1):
  fram.append(fram[-1]*i%mod)

#def framod(n, mod, a=1):
#    for i in range(1,n+1):
#        a = a * i % mod
#    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=fram[n]
    b=fram[k]
    c=fram[n-k]
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

def cnt(n):
  s = sum([comb(n-i,i,mod)%mod for i in range(n//2+1)])
  s = s%mod
  return s

A0 = 0
ans = 1
for i in range(M):
  A1 = int(input()) - 1
  ans = (ans * cnt(A1-A0))%mod
  A0 = A1+2
ans = (ans * cnt(N-A0))%mod
print(ans)


Fixed submission:
N,M=map(int,input().split())
S = []
for i in range(M):
  S.append(list(map(int,input().split())))
P = list(map(int,input().split()))

def check(num, i, P):
  SS = S[i]
  PP = P[i]
  on = 0
  for j in range(1,1+SS[0]):
    on += num>>(SS[j]-1) & 1
    on = on%2
  if on == PP:
    return True
  else:
    return False
cnt = 0
for nu in range(2**N):
  ck = True
  for i in range(M):
    ck = ck and check(nu,i,P)
    if ck == False:
      break
  if ck == True:
    cnt +=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np
from bisect import bisect_left, bisect_right
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A = np.array(A)
for i in range(M):
  B,C = map(int,input().split())
  if C <= A[0]:
    continue
  else:
    l = bisect_left(A,C)
    if l>=B:
      A[:l-B] = A[B:l]
      A[l-B:l] = C
    else:
      A[:l] = C
print(sum(A))

Fixed submission:
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
from collections import Counter
A = list(map(int,input().split()))
A=Counter(A)
cnt = [(0,0) for _ in range(len(A)+M)]
i = 0
for _ in A.most_common():
  cnt[i]=_
  i+=1
for j in range(M):
  B,C = map(int,input().split())
  cnt[i]=(C, B)
  i+=1
cnt.sort(key=lambda x:x[0],reverse=True)
nn = 0
ans = 0
for k in range(len(cnt)):
  d = min(N-nn,cnt[k][1])
  nn += d
  ans += d * cnt[k][0]
  if nn == N:
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from bisect import bisect_left, bisect_right
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A = np.array(A)
for i in range(M):
  B,C = map(int,input().split())
  if C <= A[0]:
    continue
  else:
    l = bisect_left(A,C)
    if l>=B:
      A[:l-B] = A[B:l]
      A[l-B:l] = C
    else:
      A[:l] = C
print(sum(A))

Fixed submission:
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
from collections import Counter
A = list(map(int,input().split()))
A=Counter(A)
cnt = [(0,0) for _ in range(len(A)+M)]
i = 0
for _ in A.most_common():
  cnt[i]=_
  i+=1
for j in range(M):
  B,C = map(int,input().split())
  cnt[i]=(C, B)
  i+=1
cnt.sort(key=lambda x:x[0],reverse=True)
nn = 0
ans = 0
for k in range(len(cnt)):
  d = min(N-nn,cnt[k][1])
  nn += d
  ans += d * cnt[k][0]
  if nn == N:
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
N,b=map(int,input().split())
S=input()
S[b-1]=S[b-1].lower()
print(S)

Fixed submission:
N,b=map(int,input().split())
S=input()
S=S[:b-1]+S[b-1].lower()+S[b:]
print(S)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if c in list(range(min(a,b),max(a,b)):
  print('Yes')
else:
  print('No')

Fixed submission:
a,b,c=map(int,input().split())
if c in list(range(min(a,b),max(a,b))):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(input())
ks=S[int(input())+1]
for i in range(N):
  if S[i]!=ks:
    S[i]='*'
print(ks)

Fixed submission:
N=int(input())
S=list(input())
ks=S[int(input())-1]
for i in range(N):
  if S[i]!=ks:
    S[i]='*'
print(''.join(S))
Buggy python submission (verdict: Runtime Error):
S = input()
Ans =[]
dic = ["A","T","G","C"]
rmp =""
for i in range(len(S)):
  if S[i] in dic:
    rmp += S[i]
  else:
    Ans.append(len(rmp))
    rmp = ""
print(max(Ans))

Fixed submission:
S = input()
S=S.replace("T","A")
S=S.replace("G","A")
S=S.replace("C","A")
for i in range(10,-1,-1):
  if S.find("A"*i) != -1:
    print(i)
    break
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
h,w=map(int,input().split())
print((H-h)*（W-w）)

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
print((H-h)*(W-w))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
H = [0]+H+[0]
for i in range(N,0,-1):
  if H[i-1]<=H[i]<=H[i+1]:
    H.pop(i)
  if H[i-1]>=H[i]>=H[i+1]:
    H.pop(i)
cnt = 0
flg = True
while flg:
  m = max(H)
  if m == 0:
    break
  i = H.index(m)
  d = min(H[i]-H[i+1], H[i]-H[i-1])
  cnt += d
  H[i+1]=max(0,H[i+1]-d)
  H[i-1]=max(0,H[i-1]-d)
  H.pop(i)
print(cnt)

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
H = [0]+H+[0]
def trm(li):
  for i in range(len(li)-2,0,-1):
    if li[i-1]<=li[i]<=li[i+1]:
      li.pop(i)
    elif li[i-1]>=li[i]>=li[i+1]:
      li.pop(i)
  return H
H = trm(H)
cnt = 0
for i in range(max(H),0,-1):
  flg = False
  for j in range(len(H)):
    if H[j]==i:
      if not flg:
        cnt +=1
        flg = True
      H[j]=H[j]-1
    else:
      flg = False
print(cnt)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import sys

def cost(n, h):
    if n == 1:
        return 0
    elif n == 2:
        return abs(h[1]-h[0])
    else:
        ret1 = cost(n-2, h)+abs(h[n-1]-h[n-3])
        ret2 = cost(n-1, h)+abs(h[n-1]-h[n-2])
        return min(ret1, ret2)

def main():
    input = sys.stdin.readline
    N = int(input())
    H = list(map(int, input().split()))
    print(cost(N, H))

if __name__=='__main__':
    main()


Fixed submission:
N = int(input())
H = list(map(int,input().split()))
DP = [0]*(N+1)  #DP[i]に来るための最小コスト
def dH(i,j):
  return abs(H[i-1] - H[j-1])
DP[2] = dH(1,2)
for i in range(3,N+1):
  DP[i] = min( DP[i-2] + dH(i-2, i) , DP[i-1] + dH(i-1, i) )
print(DP[N])
Buggy python submission (verdict: Runtime Error):
max_Vi = 10**3
max_Wi = W
import sys
input = sys.stdin.readline
import numpy as np
N,W=map(int,input().split())
dp=[0]+[max_Wi+1]*(N*max_Vi)
dp=np.array(dp)
for i in range(N):
  wi,vi=map(int,input().split())
  dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N,W=map(int,input().split())
dp=np.ones(10**5+1, dtype='int64')
dp[0]=0
dp[1:]=dp[1:]*(10**9+1)
for i in range(N):
  wi,vi=map(int,input().split())
  dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
N,W=map(int,input().split())
max_Vi = 10**3
max_Wi = W
dp=[max_Wi+1]*(N*max_Vi+1)
dp[0]=0
for i in range(N):
  wi,vi=map(int,input().split())
  dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N,W=map(int,input().split())
dp=np.ones(10**5+1, dtype='int64')
dp[0]=0
dp[1:]=dp[1:]*(10**9+1)
for i in range(N):
  wi,vi=map(int,input().split())
  dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int)
for n in range(1,N+1):
  wn, vn = map(int, input().split())
  dp[wn:]=np.maximum(dp[wn:], dp[:-wn]+vn)
print(dp[W])

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N,W=map(int,input().split())
dp=np.ones(10**5+1, dtype='int64')
dp[0]=0
dp[1:]=dp[1:]*(10**9+1)
for i in range(N):
  wi,vi=map(int,input().split())
  dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

H, W = map(int,input().split())
sth, stw = 0, 0
glh, glw = H-1, W-1

INF = 0
Gmap = [list(input()) for _ in range(H)]
Dist = [[INF]*W for _ in range(H)]
Seen = [[INF]*W for _ in range(H)]
direc = {(1,0), (0,1)}
init_q =[]
mod = 10**9+7

from collections import deque

def bfs(init):
    next_q = deque([])
    for i in init:
        next_q.append(i)
        Dist[i[0]][i[1]] = 1

    while len(next_q)!=0:
        #キュー取り出し(先頭)
        h,w = next_q.popleft()
        if Seen[h][w]==1:
            continue
        Seen[h][w]=1
        for d in direc:
            hs, ws = h + d[0], w + d[1]
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.':
                next_q.append([hs,ws])
                Dist[hs][ws] += Dist[h][w]
                Dist[hs][ws] %= mod
    return Dist

def main():
    #固定
    init_q.append([sth, stw])

    ret = bfs(init_q)
    print(ret[glh][glw])


if __name__ == '__main__':
    main()

Fixed submission:
from collections import deque
mod=10**9+7
H,W = map(int,input().split())
Gd = [list(input()) for _ in range(H)]
INF = 0
direc = [[1,0],[0,1]]
def dfs(start):
  Dis = [[INF]*W for _ in range(H)]
  Dis[start[0]][start[1]]=1
  q = deque([])# スタック
  q.append(start)
  while len(q)!=0:
    h,w = q.popleft()# スタック取りだし（先頭）
    for d in direc:
      hs, ws = h + d[0], w + d[1]
      if not (0<=hs<H and 0<=ws<W):
        continue
      if Gd[hs][ws]=='.':
        if Dis[hs][ws]==INF:
          q.append([hs,ws])
        Dis[hs][ws] = (Dis[hs][ws] + Dis[h][w])%mod
  return Dis[H-1][W-1]
print(dfs([0,0]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(float, input().split()))
import numpy as np
def prob_ret():
  prob = [0.0]*(N+1)
  prob[0] = 1
  prob=np.array(prob)
  for n in range(N):
    p = prob[:n]*P[n]
    prob[:n] = prob[:n] * (1-P[n])
    prob[1:] = prob[1:] + p
  return sum(prob[N//2+1:])
print(prob_ret())


Fixed submission:
N = int(input())
P = list(map(float, input().split()))
import numpy as np
def prob_ret():
  prob = [0.0]*(N+1)
  prob[0] = 1
  prob=np.array(prob)
  for n in range(N):
    p = prob[:N]*P[n]
    prob = prob * (1-P[n])
    prob[1:] = prob[1:] + p
  return sum(prob[N//2+1:])
print(prob_ret())

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    P = list(map(float, input().split()))

    dp = [0.0]*(N+1)
    dp[0] = 1.0
    for i in range(N):
        dp_ = [0.0]*(N+1)
        for j in range(i+1,-1,-1):
            dp_[j]+=dp[j-1]*P[i]
            dp_[j-1]+=dp[j-1]*(1-P[i])
        dp=dp_.copy()
    print(sum(dp[N//2+1:]))

if __name__ == '__main__':
    main()

Fixed submission:
N = int(input())
P = list(map(float, input().split()))
import numpy as np
def prob_ret():
  prob = [0.0]*(N+1)
  prob[0] = 1
  prob=np.array(prob)
  for n in range(N):
    p = prob[:N]*P[n]
    prob = prob * (1-P[n])
    prob[1:] = prob[1:] + p
  return sum(prob[N//2+1:])
print(prob_ret())

Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(float, input().split()))
prob_memo = [[-1]*(N+1) for _ in range(N+1)]
prob_memo[0] = [1] + [0]*N

def prob(n,k):
  if prob_memo[n][k]==-1:
    prob_memo[n][k] = prob(n-1,k-1)*P[n-1] + prob(n-1,k)*(1-P[n-1])
  return prob_memo[n][k]

def prob_ret():
  ret = 0
  for k in range(N//2+1,N+1):
    ret += prob(N,k)
  return ret

print(prob_ret())

Fixed submission:
N = int(input())
P = list(map(float, input().split()))
import numpy as np
def prob_ret():
  prob = [0.0]*(N+1)
  prob[0] = 1
  prob=np.array(prob)
  for n in range(N):
    p = prob[:N]*P[n]
    prob = prob * (1-P[n])
    prob[1:] = prob[1:] + p
  return sum(prob[N//2+1:])
print(prob_ret())
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans = h[-1]
for i in range(n-k+1):
  ans = min(ans, max(h[i:i+k])-min(h[i:i+k]))
print(ans)

Fixed submission:
n,k=map(int, input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans = h[-1]
for i in range(n-k+1):
  ans = min(ans, h[i+k-1]-h[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
t=sum(a)
for i in range(N):
  A[i]=abs(A[i]*N-t)
dif = min(A)
for i in range(N):
  if dif==A[i]:
    print(i)
    break

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
t=sum(A)
for i in range(N):
  A[i]=abs(A[i]*N-t)
dif = min(A)
for i in range(N):
  if dif==A[i]:
    print(i)
    break