Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np

L, R = map(int, input().split())

tmp = 0
ans = 2019

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp
if (L + 2019 - L%2019) + 1 <= R:
	i =  L + 2019 - L % 2019
	j = i+1
	tmp = (i * j) % 2019
		if tmp < ans:
			ans = tmp

i = L
j = i+1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

j = R
i = j-1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

print(ans)


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

Buggy python submission (verdict: Runtime Error):
import numpy as np

L, R = map(int, input().split())

tmp = 0
ans = 2019

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i =  L + 2019 - L % 2019
j = i+1
tmp = (i * j) % 2019
	if tmp < ans:
		ans = tmp

i = L
j = i+1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

j = R
i = j-1
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

i = L
j = R
tmp = (i * j) % 2019
if tmp < ans:
	ans = tmp

print(ans)


Fixed submission:
l,r = map(int,input().split())
ans = 2019
mod = 2019
 
for i in range(l,r):
  for j in range(i+1,r+1):
    ans = min(ans,(i*j)%mod)
    if ans == 0:
      print(0)
      exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
li = input().split()
A = int(li[0])
B = int(li[1])
C = int(li[2])
D = int(li[3])

lcm=C*D
#print(A, B-A+1)
ans = []

for i in range(A, B+1):
	#print(i)
	if i%C != 0 and i%D != 0:
		#print('warikirenai')
		ans.append(i)

print(len(ans))


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

A -= 1
lcm=C*D // fractions.gcd(C, D)

ex = A - (A // C + A // D - A // lcm)
num = B - (B // C + B // D - B // lcm)


print(num-ex)
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
 
#print(listA)
 
listB = sorted(listA)
#print(listB)
listC = sorted(listB, key=itemgetter(1))
#print(listC)
flag = 0
time = 0
 
for i in range(N):
	time += listC[i][0]
	#print(time)
	listC.pop(0)
	if time > listC[i][1]:
		flag = 1
		break
 
if flag==0:
	print('Yes')
elif flag==1:
	print('No')

Fixed submission:
from operator import itemgetter
import sys
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
 
#print(listA)
 
listB = sorted(listA)
la = sorted(listB, key=itemgetter(1))
 
t = 0
for i in range(N):
	s = la[i][1]
	t += la[i][0]
	if t > s:
		print("No")
		sys.exit()
 
print('Yes')

Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
import sys
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
 
#print(listA)
 
listB = sorted(listA)
la = sorted(listB, key=itemgetter(1))
t = 0
 
t = 0
for i in range(n):
	s = la[i][1]
	t += la[i][0]
	if t > s:
		print("No")
		sys.exit()
 
print('Yes')



Fixed submission:
from operator import itemgetter
import sys
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
 
#print(listA)
 
listB = sorted(listA)
la = sorted(listB, key=itemgetter(1))
 
t = 0
for i in range(N):
	s = la[i][1]
	t += la[i][0]
	if t > s:
		print("No")
		sys.exit()
 
print('Yes')
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = [int(i) for i in input().split()] 
Acnt = 0
for i in range(N):
	if A[i] < 0:
		Acnt += 1
res = np.sum(np.abs(A)) - np.min(np.abs(A))*2
print(res)


Fixed submission:
a, b, t = (int(i) for i in input().split())  
print(int(t/a)* b)

Buggy python submission (verdict: Runtime Error):
a, b, t = (int(i) for i in input().split())  
print(int(t/a* b)

Fixed submission:
a, b, t = (int(i) for i in input().split())  
print(int(t/a)* b)
Buggy python submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,input().split()))	
count = 0

while:
	for i in range(N):
		if li[i]%2!=0:
			break
	count += 1
print(count)

Fixed submission:
N = int(input())
li = list(map(int,input().split()))	
count = 0
flag = True

while flag==True:
	for i in range(N):
		if li[i]%2!=0:
			flag=False
		else:
			li[i] = li[i] // 2
	if flag==True:
		count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, a, b = map(int, input().split())
    a_count = 0
    a_amari = 0
    while True:
        n = n - a
        if n < 0:
            a_amari = a + n
            break
        a_count += 1
        n = n - b
        if n <= 0:
            break

    print(a_count*a + a_amari)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n, a, b = map(int, input().split())
    count = n // (a + b)
    amari = n % (a + b)

    if amari - a < 0:
        print(count*a + amari)
    else:
        print((count + 1) * a)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    vals = list(map(int, input().split()))
    flg = 0
    for i in vals:
        if vals.count(i) > 1:
            flg += 1
            break
    if flg == 0:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    vals = list(map(int, input().split()))
    flg = 0

    vals.sort()
    for i in range(n-1):
        if vals[i] == vals[i + 1]:
            flg += 1
            break
    if flg == 0:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
# result_list = [0]*n
result_count = 0

for i in range(n):
    for j in range(i):
        if p[i] > p[j]:
            # result_list[i] = 1
            result_count += 1
            break

# print(result_list.count(0))
print(n - result_count)


Fixed submission:
n = int(input())
p = list(map(int, input().split()))
# result_list = [0]*n
result = 1
com_val = p[0]

for i in range(1, n):
    if com_val < p[i]:
        continue
    else:
        result += 1
        com_val = p[i]

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
result_list = [0]*n

for i in range(n):
    for j in range(i):
        if p[i] > p[j]:
            result_list[i] = 1
            break

print(result_list.count(0))


Fixed submission:
n = int(input())
p = list(map(int, input().split()))
# result_list = [0]*n
result = 1
com_val = p[0]

for i in range(1, n):
    if com_val < p[i]:
        continue
    else:
        result += 1
        com_val = p[i]

print(result)
Buggy python submission (verdict: Runtime Error):
d=input()
d=-(d-25)
c="Chrismas"
e="Eve"
for i in range(0,4):
    if d==i:
        print(c,end="")
        if i>0:
            for j in range(i-1):
                print(" "+e)
        print()
        

Fixed submission:
d=int(input())
d=-(d-25)
c="Christmas"
e="Eve"
for i in range(0,4):
    if d==i:
        print(c,end="")
        if i>0:
            for j in range(i):
                print(" "+e,end="")
        print()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=input().split()
for i in range(n):
    c=[]
    for j in range(n):
        if i!=j:
            c.append(a[j])
    sum=0
    for k in range(n):
        if k==0:
            sum+=abs(int(c[k]))
        elif k==n-1:
            sum+=abs(int(c[k-1]))
        else:
            sum+=abs(int(c[k-1])-int(c[k]))
    print(sum)

Fixed submission:
n=int(input())
a=[0]+input().split()+[0]
sum=0
for i in range(n+1):
    sum+=abs(int(a[i])-int(a[i+1]))
for j in range(n):
    print(sum-(abs(int(a[j])-int(a[j+1]))+abs(int(a[j+1])-int(a[j+2]))-abs(int(a[j])-int(a[j+2]))))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = []
b = []
for _ in range(m):
    a_, b_ = map(int, input().split())
    a_ -= 1
    b_ -= 1
    a.append(a_)
    b.append(b_)
good = list(range(n))
for a_, b_ in zip(a, b):
    if h[a_] == h[b_]:
        if a_ in good:
            good.remove(a_)
        if b_ in good:
            good.remove(b_)
    elif h[a_] < h[b_]:
        if a_ in good:
            good.remove(a_)
    else:
        if b_ in good:
            good.remove(b_)
print(len(good))

Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))

good = set(range(n))
for _ in range(m):
    a_, b_ = map(int, input().split())
    a_ -= 1
    b_ -= 1
    if h[a_] == h[b_]:
        if a_ in good:
            good.remove(a_)
        if b_ in good:
            good.remove(b_)
    elif h[a_] < h[b_]:
        if a_ in good:
            good.remove(a_)
    else:
        if b_ in good:
            good.remove(b_)
print(len(good))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools


x = int(input())
for a in itertools.count():
    for b in itertools.count(a):
        a5b5 = a**5 + b**5
        if a5b5 == x:
            print(a, -b)
            sys.exit(0)
        if x < a5b5:
            break

Fixed submission:
import sys
import itertools


x = int(input())
for b in itertools.count():
    for a in itertools.count(b):
        a5b5 = a**5 + b**5
        if a5b5 == x:
            print(a, -b)
            sys.exit(0)
        a5b5 = a**5 - b**5
        if a5b5 == x:
            print(a, b)
            sys.exit(0)
        if x < a5b5:
            break

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools


x = int(input())
for a in itertools.count():
    for b in itertools.count():
        a5b5 = a**5 + b**5
        if a5b5 == x:
            print(a, -b)
            sys.exit(0)
        if x < a5b5:
            break

Fixed submission:
import sys
import itertools


x = int(input())
for b in itertools.count():
    for a in itertools.count(b):
        a5b5 = a**5 + b**5
        if a5b5 == x:
            print(a, -b)
            sys.exit(0)
        a5b5 = a**5 - b**5
        if a5b5 == x:
            print(a, b)
            sys.exit(0)
        if x < a5b5:
            break
Buggy python submission (verdict: Runtime Error):
import math

a, b, n = map(int, input().split())

max_ans = math.floor(a*n/b) - a*math.floor(n/b)
for x in range(n, 1, -1):
    ans = math.floor(a*x/b) - a*math.floor(x/b)
    if max_ans <= ans:
        print(ans)
        break
else:
    print(ans)

Fixed submission:
import math

a, b, n = map(int, input().split())

if n < b:
    ans = math.floor(a*n/b) - a * math.floor(n/b)
    print(ans)
else:
    ans = a - (a-1) // b - 1
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
D = int(input())
if N % (2*D+1) == 0:
    print(N // (2*D+1))
else:
    print(N// (2*D+1) + 1)

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

if N % (2*D+1) == 0:
    print(N // (2*D+1))
else:
    print(N// (2*D+1) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

Colors = []
Colors.append(A[0])

for i in range(1, N):
    if Colors[-1] >= A[i]:
        Colors.append(A[i])
    else:
        j = 0
        while True:
            if Colors[j] < A[i]:
                Colors[j] = A[i]
                break
            j += 1
print(len(Colors))



Fixed submission:
from collections import deque
import bisect
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

Colors = deque()
Colors.append(A[0])

for i in range(1, N):
    if Colors[0] >= A[i]:
        Colors.appendleft(A[i])
    else:
        idx = bisect.bisect_left(Colors, A[i])
        Colors[idx-1] = A[i]
print(len(Colors))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

C = N-K+1
D = 1
for i in range(1, K+1):
    if N-K+1 < i:
        print(0)
    else:
        ans = (C*D)%(10**9+7)
        print(ans)
    #print(C,D)
    C = C*(N-K-i+1)//(i+1)
    D = D*(K-i)//i


Fixed submission:
S = list(input())
for i in range(4):
    if not S.count(S[i]) == 2:
        print('No')
        exit()

print('Yes')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

C = N-K+1
D = 1
for i in range(1, K+1):
    if N-K+1 < i:
        print(0)
    else:
        ans = (int(C*D))%(10**9+7)
        print(ans)
    #print(C,D)
    C = C*(N-K-i+1)/(i+1)
    D = D*(K-i)/i


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

C = N-K+1
D = 1
for i in range(1, K+1):
    if N-K+1 < i:
        print(0)
    else:
        ans = (C*D)%(10**9+7)
        print(ans)
    #print(C,D)
    C = C*(N-K-i+1)//(i+1)
    D = D*(K-i)//i
Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(float, input().split())

print(H*W/2)

if x = W/2 and y = H/2:
    print(1)
else:
    print(0)


Fixed submission:
W, H, x, y = map(float, input().split())

print(H*W/2)

if x == W/2 and y == H/2:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
status = [True]*(N+2)
for _ in range(M):
    status[int(input())] = False

dp = [0]*(N+2)
dp[0] = 1
for i in range(N):
    if status[i+1]:
        dp[i+1] += dp[i]
    if status[i+2]:
        dp[i+2] += dp[i]
print(dp[N])


Fixed submission:
P, Q, R = map(int, input().split())
print(min(P+Q, Q+R, R+P))
Buggy python submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
S = list(input())
S[A-1] = '#'; S[B-1] = '#'
S.extend(['#']*2)
def dfs(a = A, b = B):
    if a == C and b == D:
        return 'Yes'

    if S[a] == '.':
        S[a] = '#'; S[a-1] = '.'
        return dfs(a+1, b)
    if S[a+1] == '.':
        S[a+1] = '#'; S[a-1] = '.'
        return dfs(a+2, b)
    if S[b] == '.':
        S[b] = '#'; S[b-1] = '.'
        return dfs(a, b+1)
    if S[b+1] == '.':
        S[b+1] = '#'; S[b-1] = '.'
        return dfs(a, b+2)
    return 'No'
print(dfs())


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

N, A, B, C, D = map(int, input().split())
S = list(input())
S[A-1] = '#'; S[B-1] = '#'
S.extend(['#']*3)
def dfs(a = A, b = B):
    if a == C and b == D:
        return 'Yes'

    if S[a] == '.' and a != C:
        S[a] = '#'; S[a-1] = '.'
        return dfs(a+1, b)
    if S[a+1] == '.' and a != C:
        S[a+1] = '#'; S[a-1] = '.'
        return dfs(a+2, b)
    if S[b] == '.' and b != D:
        S[b] = '#'; S[b-1] = '.'
        return dfs(a, b+1)
    if S[b+1] == '.' and b != D:
        S[b+1] = '#'; S[b-1] = '.'
        return dfs(a, b+2)
    return 'No'
print(dfs())
Buggy python submission (verdict: Runtime Error):
A, B = map(int,input().split())
print(B if A >= 13)
print(0 if A <= 5 else b//2)


Fixed submission:
A, B = map(int,input().split())
if A >= 13:
    print(B)
elif A <= 5:
    print(0)
else:
    print(B//2)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
keys = set()
for i in range(1, N+1):
    keys.add(i)
for _ in range(M):
    akey = set()
    l, r = map(int, input().split())
    for i in range(l, r+1):
        akey.add(i)
    keys = keys & akey
print(len(keys))


Fixed submission:
N, M = map(int, input().split())
L, R = map(int, input().split())
if M == 1:
    print(R - L + 1)
    exit()
for _ in range(M-1):
    l, r = map(int, input().split())
    if l <= R and L <= r:
        L = max(L, l)
        R = min(R, r)
    else:
        print(0)
        exit()
print(R - L + 1)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int,input().split())
cnt = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        x = N - R*r - G*g
        if x >= 0 and x % B == 0:
            cnt += 1
print(cnt)


Fixed submission:
R, G, B, N = map(int,input().split())
cnt = 0
for r in range(N//R + 1):
    for g in range((N-R*r)//G + 1):
        x = N - R*r - G*g
        if x >= 0 and x % B == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
R, G, B, N = map(int,input().split())
cnt = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        x = (N - R*r - G*g) / B
        if isinstance(x, int)
            cnt += 1
print(cnt)


Fixed submission:
R, G, B, N = map(int,input().split())
cnt = 0
for r in range(N//R + 1):
    for g in range((N-R*r)//G + 1):
        x = N - R*r - G*g
        if x >= 0 and x % B == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int,input().split())
cnt = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        x = (N - R*r - G*g) / B
        x = float(x)
        if x.is_integer() and x >= 0:
            cnt += 1
print(cnt)


Fixed submission:
R, G, B, N = map(int,input().split())
cnt = 0
for r in range(N//R + 1):
    for g in range((N-R*r)//G + 1):
        x = N - R*r - G*g
        if x >= 0 and x % B == 0:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
S = [input() for i in range(n)]
cnt = 0
a = 0
b = 0
ba = 0
for i in range(n):
    cnt += S[i].count("AB")
    if S[i].startswith("B") and S[i].endswith("A")
        ba += 1
    elif S[i].startswith("B"):
        a += 1
    elif S[i].endswith("A"):
        b += 1
if ba >= 1:
    cnt += ba - 1
if a >= 1:
    cnt += 1
if b >= 1:
    cnt += 1
print(cnt)


Fixed submission:
n = int(input())
S = [input() for i in range(n)]
cnt = 0
a = 0
b = 0
ba = 0
for i in range(n):
    cnt += S[i].count("AB")
    if S[i].startswith("B") and S[i].endswith("A"):
        ba += 1
    elif S[i].startswith("B"):
        b += 1
    elif S[i].endswith("A"):
        a += 1
if ba >= 1:
    cnt += ba - 1
    if a >= 1:
        cnt += 1
        a -= 1
    if b >= 1:
        cnt += 1
        b -= 1
    cnt += min(a, b)
elif a >= 1 and b >= 1:
    cnt += min(a, b)
print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
S = [input() for i in range(n)]
cnt = 0
a = 0
b = 0
ba = 0
for i in range(n):
    cnt += S[i].count("AB")
    if S[i].startswith("B") and S[i].endswith("A")
        ba += 1
    elif S[i].startswith("B"):
        a += 1
    elif S[i].endswith("A"):
        b += 1
if ba >= 1
    cnt += ba - 1
if a >= 1:
    cnt += 1
if b >= 1:
    cnt += 1
print(cnt)


Fixed submission:
n = int(input())
S = [input() for i in range(n)]
cnt = 0
a = 0
b = 0
ba = 0
for i in range(n):
    cnt += S[i].count("AB")
    if S[i].startswith("B") and S[i].endswith("A"):
        ba += 1
    elif S[i].startswith("B"):
        b += 1
    elif S[i].endswith("A"):
        a += 1
if ba >= 1:
    cnt += ba - 1
    if a >= 1:
        cnt += 1
        a -= 1
    if b >= 1:
        cnt += 1
        b -= 1
    cnt += min(a, b)
elif a >= 1 and b >= 1:
    cnt += min(a, b)
print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
S = [input() for i in range(n)]
cnt = 0
a = 0
b = 0
ba = 0
for i in range(n):
    cnt += S[i].count("AB")
    if S[i].startswith("B") and S[i].endswith("A")
        ba += 1
    elif S[i].startswith("B"):
        a += 1
    elif S[i].endswith("A"):
        b += 1
cnt += ba - 1
if a >= 1:
    cnt += 1
if b >= 1:
    cnt += 1
print(cnt)


Fixed submission:
n = int(input())
S = [input() for i in range(n)]
cnt = 0
a = 0
b = 0
ba = 0
for i in range(n):
    cnt += S[i].count("AB")
    if S[i].startswith("B") and S[i].endswith("A"):
        ba += 1
    elif S[i].startswith("B"):
        b += 1
    elif S[i].endswith("A"):
        a += 1
if ba >= 1:
    cnt += ba - 1
    if a >= 1:
        cnt += 1
        a -= 1
    if b >= 1:
        cnt += 1
        b -= 1
    cnt += min(a, b)
elif a >= 1 and b >= 1:
    cnt += min(a, b)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H, W = map(int,input().split())
A = [list(input()) for _ in range(H)]
p = deque()
for i, Ai in enumerate(A):
    for j, Aij in enumerate(Ai):
        if Aij == "#":
            p.append([i, j, 0])

while p:
    y, x, cnt = p.popleft()
    for dx, dy in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        if 0 <= y + dy < H and 0 <= x + dx < W and A[y + dy][x + dx] == ".":
            p.append([y + dy, x + dx, cnt + 1])
            A[y + dy][x + dx] = "#"
print(cnt)


Fixed submission:
from collections import deque

H, W = map(int,input().split())
A = [list(input()) for _ in range(H)]
p = deque()
for i, Ai in enumerate(A):
    for j, Aij in enumerate(Ai):
        if Aij == "#":
            p.append([i, j, 0])

while p:
    y, x, cnt = p.popleft()
    for dx, dy in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        if 0 <= y + dy < H and 0 <= x + dx < W and A[y + dy][x + dx] == ".":
            p.append([y + dy, x + dx, cnt + 1])
            A[y + dy][x + dx] = "#"
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H, W = map(int,input().split())
A = []
X = deque(); Y = deque()
for l in range(H):
    a = list(input())
    addX = [n for n, i in enumerate(a) if i == "#"]
    X.extend(addX); Y.extend([l] * len(addX))
    A.append(a)

cntList = deque()
cntList.extend([0] * len(X))

while X and Y:
    x = X.popleft(); y = Y.popleft(); cnt = cntList.popleft()
    for dx, dy in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        if 0 <= y + dy < H and 0 <= x + dx < W and A[y + dy][x + dx] == ".":
            X.append(x + dx); Y.append(y + dy); cntList.append(cnt + 1)
            A[y + dy][x + dx] = "#"
print(cnt)


Fixed submission:
from collections import deque

H, W = map(int,input().split())
A = [list(input()) for _ in range(H)]
p = deque()
for i, Ai in enumerate(A):
    for j, Aij in enumerate(Ai):
        if Aij == "#":
            p.append([i, j, 0])

while p:
    y, x, cnt = p.popleft()
    for dx, dy in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        if 0 <= y + dy < H and 0 <= x + dx < W and A[y + dy][x + dx] == ".":
            p.append([y + dy, x + dx, cnt + 1])
            A[y + dy][x + dx] = "#"
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
gcd_list = []
max_element = max(A)

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

for i in range(n):
    y = A[i]
    for j in range(1, max_element + 1):
        A[i] = j
        x = A[0]
        for k in range(1, n):
            x = gcd(x, A[k])
        gcd_list.append(x)
    A[i] = y
print(max(gcd_list))


Fixed submission:
from math import floor
a, b, t = map(int,input().split())
num = floor(t / a)
print(num * b)

Buggy python submission (verdict: Runtime Error):
n = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
goods_list = []
for i in range (n):
    x = V[i] - C[i]
    if x > 0:
        goods_list.append(x)
print(sum(goods_list))


Fixed submission:
from math import floor
a, b, t = map(int,input().split())
num = floor(t / a)
print(num * b)