Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d  = map(int, input().split())

def divide(n):
    return (b // n) - ((a-1) // n)

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

ans = b - a + 1

ans -= divide(c)

ans -= divide(d)

ans += divide(lcm(c,d))

print(ans)

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

def divide(n):
    return (b // n) - ((a-1) // n)

def gcd(a,b):
    if ( b==0 ):
        return a
    else:
        return (gcd(b, a%b))

def lcm(x, y):
    return (x * y) // gcd(x, y)

ans = b - a + 1

ans -= divide(c)

ans -= divide(d)

ans += divide(lcm(c,d))

print(ans)

Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d  = map(int, input().split())

def divide(n):
    return (b // n) - ((a-1) // n)

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

ans = b - a + 1

ans -= divide(c)

ans -= divide(d)

ans += divide(lcm(c,d))

print(ans)

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

def divide(n):
    return (b // n) - ((a-1) // n)

def gcd(a,b):
    if ( b==0 ):
        return a
    else:
        return (gcd(b, a%b))

def lcm(x, y):
    return (x * y) // gcd(x, y)

ans = b - a + 1

ans -= divide(c)

ans -= divide(d)

ans += divide(lcm(c,d))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

h, w = map(int, input().split())

maze = [input() for i in range(h)]

cnt = [[0] * w for i in range(h)]

for y in range(h):
    total = 0
    for x in range(w):
        if maze[y][x] == "#":
            total = 0
        elif maze[y][x] == ".":
            total += 1
            cnt[y][x] += total

for x in range(w):
    total = 0
    for y in range(h):
        if maze[y][x] == "#":
            total = 0
        
        elif maze[y][x] == ".":
            total += 1
            cnt[y][x] += total

for y in range(h):
    total = 0
    for x in range(w-1,-1,-1):
        if maze[y][x] == "#":
            total = 0
        elif maze[y][x] == ".":
            total += 1
            cnt[y][x] += total

for x in range(w):
    total = 0
    for y in range(h-1,-1,-1):
        if maze[y][x] == "#":
            total = 0
        
        elif maze[y][x] == ".":
            total += 1
            cnt[y][x] += total

cnt = np.array(cnt)

print(np.max(cnt)-3)

Fixed submission:
## code borrowed from "maspy"

import numpy as np
import sys
buf = sys.stdin.buffer
 
H,W = map(int,buf.readline().split())
# 周りに壁を、0,1化、壁を0で持つ
grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:] = (np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'.').reshape((H,W+1))
 
# x軸方向の集計
def F(transpose):
  x = grid
  if transpose:
    x = (x.T).copy()
  x = np.ravel(x) # to 1D array
  L = len(x)
  
  left_zero = np.where(x,0,-np.arange(L)) # 左の壁のindexの-1倍
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = np.where(x[::-1],0,np.arange(L)) # 逆順ソートした上で左の壁のindex
  np.maximum.accumulate(right_zero, out=right_zero)
  
  y = left_zero
  y += L-right_zero[::-1]
  
  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)
  
answer = (F(False) + F(True)).max()-5
print(answer)
Buggy python submission (verdict: Runtime Error):
# inputを高速化する。
import sys
import numpy as np

input = sys.stdin.readline

N,K = map(int, input().split())
blocks = list(map(int, input().split()))

route = [0] * N

blocks = np.array(blocks)

for i in range(1, N):
    count = max(0, i-K)
    route[i] = min(route[count:i] + np.abs(blocks[count:i] - blocks[i]))

print(route[-1])

Fixed submission:
N = int(input())

blocks = list(map(int, input().split()))

route = [0] * N

for i in range(N):
    if i == 0:
        continue
    elif i == 1:
        route[1] = abs(blocks[1] - blocks[0]) 

    else:
        first = abs(blocks[i] - blocks[i-1]) + route[i-1]
        second = abs(blocks[i] - blocks[i-2]) + route[i-2]
        route[i] = min(first, second)

print(route[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
# inputを高速化する。
import sys
import numpy as np

input = sys.stdin.readline

N,K = map(int, input().split())
blocks = list(map(int, input().split()))

route = [0] * N

blocks = np.array(blocks)

for i in range(1, N):
    count = max(0, i-K)
    route[i] = min(route[count:i] + np.abs(blocks[count:i] - blocks[i]))

print(route[-1])

Fixed submission:
# inputを高速化する。
import sys
import numpy as np

input = sys.stdin.readline

N,K = map(int, input().split())
blocks = list(map(int, input().split()))

route = np.zeros(N, dtype=int)

blocks = np.array(blocks)

for i in range(1, N):
    count = max(0, i-K)
    route[i] = min(route[count:i] + np.abs(blocks[count:i] - blocks[i]))

print(route[-1])

Buggy python submission (verdict: Time Limit Exceeded):
# inputを高速化する。
import sys
import numpy as np

input = sys.stdin.readline

N,K = map(int, input().split())

blocks = list(map(int, input().split()))

route = [10 ** 9] * N
route[0] = 0

blocks = np.array(blocks)

for i in range(1, N):
    count = max(0, i-K)
    route[i] = min(route[count:i] + np.abs(blocks[count:i] - blocks[i]))

print(route[-1])

Fixed submission:
# inputを高速化する。
import sys
import numpy as np

input = sys.stdin.readline

N,K = map(int, input().split())
blocks = list(map(int, input().split()))

route = np.zeros(N, dtype=int)

blocks = np.array(blocks)

for i in range(1, N):
    count = max(0, i-K)
    route[i] = min(route[count:i] + np.abs(blocks[count:i] - blocks[i]))

print(route[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())

blocks = list(map(int, input().split()))

route = [10 ** 9] * N
route[0] = 0

for i in range(N):
    if i >= 1:
        k = 1
        while i - k >= 0 and k <= K:
            count = abs(blocks[i] - blocks[i-k]) + route[i-k]
            route[i] = min(count, route[i])
            k += 1

print(route[N-1])

Fixed submission:
# inputを高速化する。
import sys
import numpy as np

input = sys.stdin.readline

N,K = map(int, input().split())
blocks = list(map(int, input().split()))

route = np.zeros(N, dtype=int)

blocks = np.array(blocks)

for i in range(1, N):
    count = max(0, i-K)
    route[i] = min(route[count:i] + np.abs(blocks[count:i] - blocks[i]))

print(route[-1])
Buggy python submission (verdict: Time Limit Exceeded):
# inputを高速化する。
import sys
input = sys.stdin.readline

N,W = map(int, input().split())

dp = [0] * (W+1)

for i in range(N):
    w,v = map(int, input().split())
    for j in reversed(range(0,W+1)):
        if j + w <= W:
            dp[j+w] = max(dp[j+w], (dp[j]+v))
        

print(dp[-1])

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

N,W = map(int, input().split())

dp = np.zeros(W+1 , np.int64)


for i in range(N):
    w,v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:] , dp[:-w] + v)

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right
import numpy as np

n = int(input())

top = map(int, input().split())
mid = map(int, input().split())
bot = map(int, input().split())
top = np.array(sorted(top))
mid = np.array(sorted(mid))
bot = np.array(sorted(bot))

ans = 0
for i in top:
    for j in mid[bisect_right(mid,i):]:
        ans += len(bot[bisect_right(bot,j):])

print(ans)

Fixed submission:
from bisect import bisect_right, bisect_left
import numpy as np

n = int(input())

top = map(int, input().split())
mid = map(int, input().split())
bot = map(int, input().split())
top = np.array(sorted(top))
mid = np.array(sorted(mid))
bot = np.array(sorted(bot))

ans = 0
for i in mid:
    top_num = len(top[:bisect_left(top,i)])
    bot_num = len(bot[bisect_right(bot,i):])
    ans += top_num * bot_num

print(ans)
Buggy python submission (verdict: Runtime Error):
def check(c,t):
    if len(c) < len(t):
        return False
    for i in range(len(t)):
        if c[i] != "?" and c[i] != t[i]:
            return False

    return True
        

i = 0 
Has = False
ans = ""
while i < len(s):
    if (s[i] == "?" or s[i] == t[0]) and not Has:
        if check(s[i:],t):
            Has = True
            ans += t
            i += len(t)
        else:
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
            i += 1

    elif s[i] == "?":
        i += 1
        ans += "a"
    else:
        ans += s[i]
        i += 1

if Has:
    print(ans[::-1])
else:
    print('UNRESTORABLE')

Fixed submission:
s = input()[::-1]
t = input()[::-1]
 
def check(c,t):
    if len(c) < len(t):
        return False
    for i in range(len(t)):
        if c[i] != "?" and c[i] != t[i]:
            return False
 
    return True
        
 
i = 0 
Has = False
ans = ""
while i < len(s):
    if (s[i] == "?" or s[i] == t[0]) and not Has:
        if check(s[i:],t):
            Has = True
            ans += t
            i += len(t)
        else:
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
            i += 1
 
    elif s[i] == "?":
        i += 1
        ans += "a"
    else:
        ans += s[i]
        i += 1
 
if Has:
    print(ans[::-1])
else:
    print('UNRESTORABLE')
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int, input().split())

ans = 0
for i in range(min(s,k)+1):
    for j in range(min(s-i,k)+1):
        for l in range(min(s-i-j,k)+1):
            if i + j + l == s:
                ans += 1

print(ans)

Fixed submission:
k,s = map(int, input().split())

ans = 0
for i in range(min(s,k)+1):
    for j in range(i,min(s-i,k)+1):
        l = s - i - j
        if k >= l >= j: 
            if i == j and j == l:
                ans += 1
            elif i != j and j!= l and i != l:
                ans += 6
            else:
                ans += 3

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int, input().split())

ans = 0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l == s:
                ans += 1

print(ans)

Fixed submission:
k,s = map(int, input().split())

ans = 0
for i in range(min(s,k)+1):
    for j in range(i,min(s-i,k)+1):
        l = s - i - j
        if k >= l >= j: 
            if i == j and j == l:
                ans += 1
            elif i != j and j!= l and i != l:
                ans += 6
            else:
                ans += 3

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

vocabs = ["dream","dreamer","erase","eraser"]

cnt = 0
t = ""
while cnt <= len(s) - 7:
    if s[cnt] == "d":
        if s[cnt+5] == "d":
            cnt += 5
            t += vocabs[0]
        elif s[cnt+5] == "e":
            if s[cnt+7] == "a":
                cnt += 5
                t += vocabs[0]
            else:
                cnt += 7
                t += vocabs[1]
        else:
            break
    elif s[cnt] == "e":
        if s[cnt+5] == "r":
            cnt += 6
            t += vocabs[3]
        else:
            cnt += 5
            t += vocabs[2]
    else:
        break

if s[cnt:] == vocabs[0]:
    t+= vocabs[0]
elif s[cnt:] == vocabs[1]:
    t+= vocabs[1]
elif s[cnt:] == vocabs[2]:
    t+= vocabs[2]
elif s[cnt:] == vocabs[3]:
    t+= vocabs[3]


if s == t:
    print("YES")
else:
    print("NO")

Fixed submission:
s = input()

vocabs = ["dream","dreamer","erase","eraser"]

cnt = 0
t = ""
while cnt <= len(s) - 8:
    if s[cnt] == "d":
        if s[cnt+5] == "d":
            cnt += 5
            t += vocabs[0]
        elif s[cnt+5] == "e":
            if s[cnt+7] == "a":
                cnt += 5
                t += vocabs[0]
            else:
                cnt += 7
                t += vocabs[1]
        else:
            break
    elif s[cnt] == "e":
        if s[cnt+5] == "r":
            cnt += 6
            t += vocabs[3]
        else:
            cnt += 5
            t += vocabs[2]
    else:
        break

if s[cnt:] == vocabs[0]:
    t+= vocabs[0]
elif s[cnt:] == vocabs[1]:
    t+= vocabs[1]
elif s[cnt:] == vocabs[2]:
    t+= vocabs[2]
elif s[cnt:] == vocabs[3]:
    t+= vocabs[3]


if s == t:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
import sys


#torf = [[None for _ in range(m)]for _ in range(n)]
#print(torf)
#print(torf[0][0])
#print(torf[1][0])

s = input()
ans =""
if len(s)==1:
    if s[0]=="?":
        print("D")
        sys.exit()
    else:
        print(s[0])
        sys.exit()

if s[0]=="?":
    if s[1]=="D" or s[1]=="?":
        ans = ans+"P"
    else:
        ans = ans + "D"
else :
    ans = ans + s[0]

for i in range(1,len(s)):
    if s[i]=="?":
        if ans[i-1]=="P":
            ans = ans + "D"
        elif ans[i-1]=="D":
            if i<len(s):
                if s[i+1]=="P":
                    ans = ans + "D"
                else:
                    ans= ans + "P"
            else:
                ans = ans + "P"
        else:
            ans = ans + "P"    
    else:
        ans = ans + s[i]
    

print(ans)


Fixed submission:
import sys


#torf = [[None for _ in range(m)]for _ in range(n)]
#print(torf)
#print(torf[0][0])
#print(torf[1][0])

s = input()
ans =""
if len(s)==1:
    if s[0]=="?":
        print("D")
        sys.exit()
    else:
        print(s[0])
        sys.exit()

if s[0]=="?":
    if s[1]=="D" or s[1]=="?":
        ans = ans+"P"
    else:
        ans = ans + "D"
else :
    ans = ans + s[0]

for i in range(1,len(s)):
    if s[i]=="?":
        if ans[i-1]=="P":
            ans = ans + "D"
        elif ans[i-1]=="D":
            if i<len(s)-1:
                if s[i+1]=="P":
                    ans = ans + "D"
                else:
                    ans= ans + "P"
            else:
                ans = ans + "D"
        else:
            ans = ans + "P"    
    else:
        ans = ans + s[i]
    

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys


#torf = [[None for _ in range(m)]for _ in range(n)]
#print(torf)
#print(torf[0][0])
#print(torf[1][0])

s = input()
ans =""

if s[0]=="?":
    if s[1]=="D":
        ans = ans+"P"
    else:
        ans = ans + "D"
else :
    ans = ans + s[0]

for i in range(1,len(s)):
    if s[i]=="?":
        if ans[i-1]=="P":
            ans = ans + "D"
        else:
            ans = ans + "P"
    else:
        ans = ans + s[i]
    

print(ans)


Fixed submission:
import sys


#torf = [[None for _ in range(m)]for _ in range(n)]
#print(torf)
#print(torf[0][0])
#print(torf[1][0])

s = input()
ans =""
if len(s)==1:
    if s[0]=="?":
        print("D")
        sys.exit()
    else:
        print(s[0])
        sys.exit()

if s[0]=="?":
    if s[1]=="D" or s[1]=="?":
        ans = ans+"P"
    else:
        ans = ans + "D"
else :
    ans = ans + s[0]

for i in range(1,len(s)):
    if s[i]=="?":
        if ans[i-1]=="P":
            ans = ans + "D"
        elif ans[i-1]=="D":
            if i<len(s)-1:
                if s[i+1]=="P":
                    ans = ans + "D"
                else:
                    ans= ans + "P"
            else:
                ans = ans + "D"
        else:
            ans = ans + "P"    
    else:
        ans = ans + s[i]
    

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

n,k = (int(i) for i in input().split())

d = [None]*k
a = [None]*n

syugou = []
for i in range(k):
    d[i] = int(input())
    a[i] = [int(j) for j in input().split()]

    syugou = syugou+a[i]

num = set(syugou)

print(n-len(num))

Fixed submission:
import sys

n,k = (int(i) for i in input().split())

d = [None]*k
a = [None]*k

syugou = []
for i in range(k):
    d[i] = int(input())
    a[i] = [int(j) for j in input().split()]

    syugou = syugou+a[i]

num = set(syugou)

print(n-len(num))

Buggy python submission (verdict: Runtime Error):
import sys

n,k = (int(i) for i in input().split())

d = [None]*k
a = [None]*n

syugou = []
for i in range(k):
    d[i] = int(input())
    a[i] = [int(j) for j in input().split()]

    syugou = syugou+a[i]
    ans = set(syugou)

num = list(ans)

print(n-len(num))

Fixed submission:
import sys

n,k = (int(i) for i in input().split())

d = [None]*k
a = [None]*k

syugou = []
for i in range(k):
    d[i] = int(input())
    a[i] = [int(j) for j in input().split()]

    syugou = syugou+a[i]

num = set(syugou)

print(n-len(num))
Buggy python submission (verdict: Time Limit Exceeded):
import sys


a,b,n = (int(i) for i in input().split())


ans =0

for i in range(1,n+1):
    temp = a*i//b-a*(i//b)
    if temp > ans:
        ans = temp


print(ans)


Fixed submission:
import sys


a,b,n = (int(i) for i in input().split())


if n < b-1:
    ans = (a*n//b)

else:
    ans = ((b-1)*a)//b



print(ans)
Buggy python submission (verdict: Runtime Error):
    import sys
     
    s,w =(int(n) for n in input().split())
     
    if (s <= w):
        print("unsafe")
        sys.exit()
    else:
        print("safe")

Fixed submission:

import sys
     
s,w =(int(n) for n in input().split())
     
if (s <= w):
        print("unsafe")
        sys.exit()
else:
        print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())

p = [int(i) for i in input().split()]

max = 0


for i in range(n):
    sum=0
    kitai=0
    if i+k<=n:
        for j in range(i,i+k):
         sum = sum + p[j]*(p[j]+1)/2
         kitai = kitai + sum/p[j]
         sum=0
    if kitai > max:
        max = kitai

print(max)


Fixed submission:
n,k=(int(i) for i in input().split())

p = [int(i) for i in input().split()]

max = 0

kitai = [float((p[j]+1)/2) for j in range(n)]

max=0
ans=0
for i in range(k):
    max=max+kitai[i]
ans=max
for i in range(1,n):
    if i+k-1<n:
        max=max-kitai[i-1]+kitai[i+k-1]
        if max>ans:
            ans=max


print(ans)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
#a,b = int(input()),int(input())

if 6<=a<=12 :
    ans = b/2

elif 6 > a :
    ans = 0

else :
    ans = b

print(ans)


Fixed submission:
a,b=(int(i) for i in input().split())
#外側はタプルを表してるんだね。
#a,b = int(input()),int(input())

if 6<=a<=12 :
    ans = b/2

elif 6 > a :
    ans = 0

else :
    ans = b

print(int(ans))

Buggy python submission (verdict: Runtime Error):
"""a=int(input())
b=int(input())"""
a,b = int(input()),int(input())

if 6<=a<=12 :
    ans = b/2

elif 6 > a :
    ans = 0

else :
    ans = b

print(ans)


Fixed submission:
a,b=(int(i) for i in input().split())
#外側はタプルを表してるんだね。
#a,b = int(input()),int(input())

if 6<=a<=12 :
    ans = b/2

elif 6 > a :
    ans = 0

else :
    ans = b

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in A:
    ans *= i

if 10 ** 18 < ans:
    print("-1")
else:
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()

ans = 1
for i in A:
    ans *= i
    if 10 ** 18 < ans:
        print("-1")
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

print(int(A * B / math.gcd(A, B)))

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


def gcd(A, B):
    a = A
    b = B
    while b != 0:
        a, b = b, a % b
    return a


print(A * B // gcd(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

result = 0

for i in range(1000):
    if i < 10:
        temp = "00" + str(i)
    elif i < 100:
        temp = "0" + str(i)
    else:
        temp = str(i)

    cur = 0
    for j in range(N):
        if S[j] == temp[cur]:
            cur += 1
        if cur == 3:
            result += 1
            break

print(result)

Fixed submission:
N = int(input())
S = input()

result = 0

for i in range(1000):
    if i < 10:
        temp = "00" + str(i)
    elif i < 100:
        temp = "0" + str(i)
    else:
        temp = str(i)

    cur = 0
    for j in range(3):
        if temp[j] in S[cur:]:
            cur += S[cur:].index(temp[j]) + 1
            if j == 2:
                result += 1
        else:
            break

print(result)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a <= 9 and b <= 9:
  return a * b
else:
  return -1

Fixed submission:
a, b = map(int, input().split())
if a <= 9 and b <= 9:
  print(a*b)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
a = int(input())
if a <= 81:
    for i in range(8):
        if ((a % (i+2)) == 0) and ((a / (i+2)) <= 9):
            print("Yes")
            b = False

if b:
    print("No")

Fixed submission:
a = int(input())
for i in range(1, 10):
    for j in range(1, 10):
        if i*j == a:
            print("Yes")
            exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = []
for i in range(N):
    ans.append(str(A.index(i + 1) + 1))
print(" ".join(ans))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [None for _ in range(N)]
for i, j in enumerate(A):
    ans[j-1] = str(i + 1)
print(" ".join(ans))
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
graph = []
for _ in range(H):
    graph.append(input())

dist = [[0 for _ in range(W)] for _ in range(H)]

que = [[0, 0]]
distance = 0
while True:
    h, w = que.pop(0)
    if h == H - 1 and w == W - 1:
        distance = dist[h][w]
        break
    for a, b in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
        ht, wt = h + a, w + b
        if 0 <= ht < H and 0 <= wt < W and graph[ht][wt] == "." and dist[ht][wt] == 0:
            dist[ht][wt] = dist[h][w] + 1
            que.append([ht, wt])

total = W * H - 1
for g in graph:
    total -= g.count("#")
print(total - distance)

Fixed submission:
H, W = map(int, input().split())
graph = []
for _ in range(H):
    graph.append(input())

dist = [[0 for _ in range(W)] for _ in range(H)]

que = [[0, 0]]
distance = 0
while len(que) > 0:
    h, w = que.pop(0)
    if h == H - 1 and w == W - 1:
        distance = dist[h][w]
        break
    for a, b in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
        ht, wt = h + a, w + b
        if 0 <= ht < H and 0 <= wt < W and graph[ht][wt] == "." and dist[ht][wt] == 0:
            dist[ht][wt] = dist[h][w] + 1
            que.append([ht, wt])

if distance == 0:
    print(-1)
    exit()

total = W * H - 1
for g in graph:
    total -= g.count("#")
print(total - distance)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = list(map(int,input().split()))
b = sorted(a)
d = []
for i in range (len(a)):
  c = a.index(b[i])
  print(c+1)
  

Fixed submission:
n=int(input())
a = list(map(int,input().split()))
enumerate(a,1)
b=sorted(range(len(a)), key=lambda k: a[k])
for i in range(len(a)):
  print(b[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
r = min(r,l+4038)
mini = 2018
for i in range(l,r+1):
  for j in range(i+1,r+1):
    ans = ( i*j )% 2019
    mini = min(ans,mini)
print(mini)


Fixed submission:
l,r = map(int,input().split())
if (r-l)>=2019:
  print(0)
else:
  mini = 2018
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      ans = ( i*j )% 2019
      mini = min(ans,mini)
  print(mini)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
r = min(r,l+2019*2)
mini = 2018
for i in range(l,r):
  for j in range(i+1,r+1):
    ans = ( i*j )% 2019
    mini = min(ans,mini)
print(mini)


Fixed submission:
l,r = map(int,input().split())
if (r-l)>=2019:
  print(0)
else:
  mini = 2018
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      ans = ( i*j )% 2019
      mini = min(ans,mini)
  print(mini)
Buggy python submission (verdict: Runtime Error):
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  int n,k;
  string s;
  cin >> n >> s >> k;
  
  for(int i=0;i<n;i++){
    if(s[k-1]!=s[i]){
      s[i] = '*';
  }
  }
  cout << s << endl;
  return 0;
}

Fixed submission:
n=int(input())
s=input()
char_list=list(s)
k=int(input())
for i in range(n):
	if(char_list[k-1]!=char_list[i]):
  		char_list[i] = "*"
str = ''.join(char_list)
print(str)