Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
# import math
# sys.setrecursionlimit(10**8)
# INF = float('inf')
# PI = math.pi()
# from functools import lru_cache
# @lru_cache(maxsize=None)

n = int(input())
# a, b = map(int, input().split())
a = list(map(int, input().split()))
# s = [list(map(int,list(input()))) for i in range(h)]

ans = 1
for item in a:
    ans=ans*item
if ans>10**18:
    print(-1)
    sys.exit()
print(ans)


Fixed submission:
#!/usr/bin/env python3

import sys
import numpy as np

n = int(input())
aa = list(map(int, input().split()))

if 0 in aa:
    print(0)
    sys.exit()

a = [s for s in aa if s != 1]
a.sort(reverse=True)

# keta = 0
# for item in a:
#     k = len(str(item))
#     keta += k-1
#     if keta>18:
#         print(-1)
#         sys.exit()

prod = 1
for item in a:
    prod*=item
    if prod>10**18:
        print(-1)
        sys.exit()

# arr = np.array(a)
# ans = arr.prod()
# if ans>10**18:
#     print(-1)
#     sys.exit()

print(prod)
Buggy python submission (verdict: Runtime Error):
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)

Fixed submission:
K = int(input())
A, B = map(int, input().split())
flag=0
for i in range(A,B+1):
  if i%K==0:
    print('OK')
    flag=1
    break
if flag==0:
	print('NG')
Buggy python submission (verdict: Runtime Error):
A, B, N = map(int, input().split())
Y = A*x//B - A*(x//B)
print(Y)

Fixed submission:
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)

Buggy python submission (verdict: Runtime Error):
A, B, N = map(int, input().split())
print(A*x//B - A*(x//B))

Fixed submission:
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  for i in range(N,N-2*B,-1):
    if i<0:
      break
    x = i+1
    Y = int(A*x//B) - A*(x//B)
    if Y>Ymax:
      Ymax = Y
  print(Ymax)

Fixed submission:
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  for i in range(B):
    x = i+1
    Y = int(A*x//B) - A*(x//B)
    if Y>Ymax:
      Ymax = Y
  print(Ymax)

Fixed submission:
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
Ymax=0

if N<B:
  L = N
else:
  L = B

for i in range(L):
  x = i+1
  Y = int(A*x//B) - A*(x//B)
  if Y>Ymax:
    Ymax = Y
print(Ymax)

Fixed submission:
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
Ymax=0

if N<B:
  L = N
else:
  L = B

for i in range(L):
  x = i+1
  Y = int(float(A*x)//float(B)) - A*(x//B)
  if Y>Ymax:
    Ymax = Y
print(Ymax)

Fixed submission:
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
Ymax=0
for i in range(N):
  x = i+1
  Y = int(float(A)*float(x)/float(B)) - A * int(float(x)/float(B))
  if Y>Ymax:
    Ymax = Y
print(Ymax)

Fixed submission:
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = (int(item) for item in input().split())

m=2020
ii=0
jj=0
for i in range(L,R+1):
  for j in range(i+1,R+1):
    if m > (i*j % 2019):
      m = (i*j % 2019)
      ii=i
      jj=j      
print(m)

Fixed submission:
L, R = (int(item) for item in input().split())

m=2020
if R-L > 2020:
  print(0)
else:
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      mm = i*j % 2019
      if m > mm:
        m = (i*j % 2019)
  print(m)
Buggy python submission (verdict: Runtime Error):
S = input()
S=str(S)

if S[0]==S[1]:
  if S[2]==S[3]:
    if S[0] != S[2]:
    	print('Yes')
    else:
      print('No')
  else:
  	print('No')
elif S[0]==S[2]:
  if S[1]==S[3]:
    if S[0] != S[1]:
    	print('Yes')
    else:
      print('No')
  else:
  	print('No')
elif S[0]==S[3]:
  if S[1]==S[2]:
    if S[0] != S[1]:
    print('Yes')
    else:
      print('No')
  else:
  	print('No')
else:
	print('No')

Fixed submission:
S = input()
S=str(S)

if S[0]==S[1]:
  if S[2]==S[3]:
    if S[0] != S[2]:
      print('Yes')
    else:
      print('No')
  else:
  	print('No')
elif S[0]==S[2]:
  if S[1]==S[3]:
    if S[0] != S[1]:
      print('Yes')
    else:
      print('No')
  else:
  	print('No')
elif S[0]==S[3]:
  if S[1]==S[2]:
    if S[0] != S[1]:
      print('Yes')
    else:
      print('No')
  else:
  	print('No')
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
n = input()
nums = input().split()

cnt=0

for i in range(1,len(nums)-1):
  if nums[i-1] == nums[i] and nums[i+1] < nums[i]:
    cnt += 1
  elif nums[i+1] == nums[i] and nums[i-1] < nums[i]:
    cnt += 1  
  elif nums[i-1] < nums[i] and nums[i] < nums[i+1]
    cnt += 1  
  elif nums[i+1] < nums[i] and nums[i] < nums[i-1]:
    cnt += 1
      
print(cnt)
  

Fixed submission:
n = input()
nums = input().split(' ')

nums = [int(num) for num in nums]
cnt=0

for i in range(1,len(nums)-1):
  if nums[i-1] < nums[i] and nums[i] < nums[i+1]:
    cnt += 1
  if nums[i+1] < nums[i] and nums[i] < nums[i-1]:
    cnt += 1
      
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import re
s = input()

while(True):
    l = len(s)
    s = re.sub('(dream($|er$))|(erase($|r$))','',s)
    if len(s) == l:
        if len(s)==0:
            print('YES')
        else:
            print('NO')
        exit()


Fixed submission:
#!/usr/bin/env python3
import re
s = input()


while True:
    # s = re.sub('dream$|dreamer$|erase$|eraser$','',s)

    l = len(s)
    if s.rfind('dream') == l-5:
        s = s[:-5]
    elif s.rfind('dreamer') == l-7:
        s = s[:-7]
    elif s.rfind('erase') == l-5:
        s = s[:-5]
    elif s.rfind('eraser') == l-6:
        s = s[:-6]
    else:
        break
        
if len(s)==0:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
    # -*- coding: utf-8 -*-
    import math
     
    ###
    # main
    if(__name__ == '__main__'):
        # input
        r = int(input())
     
        pi = 3.141592
        ans = pi * r * 2.0
        print(ans)
     
    # else:
        # do nothing

Fixed submission:
# -*- coding: utf-8 -*-
import math

###
# main
if(__name__ == '__main__'):
    # input
    r = int(input())

    pi = 3.141592
    ans = pi * r * 2.0
    print(ans)

# else:
    # do nothing
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

def abc161e(n, k, c, s):
    num_cluster_f = 0
    start = []
    cursor = 0
    while cursor < n:
        if s[cursor] == "x":
            cursor += 1
            continue
        else:
            num_cluster_f += 1
            start.append(cursor)
            cursor += c+1

    if k < num_cluster_f:
        return []

    num_cluster_b = 0
    end = []
    cursor = n-1

    while 0 <= cursor:
        if s[cursor] == "x":
            cursor -= 1
            continue
        else:
            num_cluster_b += 1
            end.insert(0, cursor)
            cursor -= c+1

    if k < num_cluster_b:
        return []

    ans = []
    if num_cluster_b < num_cluster_f:
        num_cluster_f = num_cluster_b
    for s, e in zip(start, end):
        if s == e:
            ans.append(s+1)

    return ans

###
# main
if(__name__ == '__main__'):
    # input
    n, k, c = map(int, input().split(" "))
    s = input()
    
    ans = abc161e(n, k, c, s)
    
    # output
    for a in ans:
        print(a)
# else:
    # do nothing


Fixed submission:
# -*- coding: utf-8 -*-

def abc161e(n, k, c, s):
    num_cluster_f = 0
    start = []
    cursor = 0
    while cursor < n:
        if s[cursor] == "x":
            cursor += 1
            continue
        else:
            num_cluster_f += 1
            start.append(cursor)
            cursor += c+1

    if k < num_cluster_f:
        return []

    num_cluster_b = 0
    end = []
    cursor = n-1

    while 0 <= cursor:
        if s[cursor] == "x":
            cursor -= 1
            continue
        else:
            num_cluster_b += 1
            end.append(cursor)
            cursor -= c+1

    if k < num_cluster_b:
        return []

    ans = []
    if num_cluster_b < num_cluster_f:
        num_cluster_f = num_cluster_b
    for s, e in zip(start, end[::-1]):
        if s == e:
            ans.append(s+1)

    return ans

###
# main
if(__name__ == '__main__'):
    # input
    n, k, c = map(int, input().split(" "))
    s = input()
    
    ans = abc161e(n, k, c, s)
    
    # output
    for a in ans:
        print(a)
# else:
    # do nothing
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

min_char = "abcdefghij"

def dtype_tree(tree, start, num):
    for i in range(start+1):
        if num > 0:
            tgt_tree = [i]
            new_tree = dtype_tree([], i+1, num-1)
            tgt_tree.append(new_tree)
            if tree == None:
                tree = tgt_tree
            else:
                tree.append(tgt_tree)
        else:
            tree.append([i])
    return tree

def print_tree(tree, prefix):
    new_prefix = prefix
    if len(tree) == 1:
        print(prefix + min_char[tree[0]])
    else:
        for elem in tree:
            if type(elem) != list:
                new_prefix += min_char[elem]
#                print(new_prefix)
            else:
                print_tree(elem, new_prefix)

    return


def abc_XXX(num):
    tree = dtype_tree(None, 0, num-1)
#    print(tree)
    print_tree(tree, "")
    return

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    
    abc_XXX(n)
    
    # output

# else:
    # do nothing


Fixed submission:
# -*- coding: utf-8 -*-

min_char = "abcdefghij"

def dtype_tree(tree, max, num):
    for i in range(max+1):
        tgt_tree = [i]
        if num > 0:
            new_max = max
            if new_max < i+1:
                new_max = i+1
            new_tree = dtype_tree([], new_max, num-1)
            tgt_tree.append(new_tree)

        if tree == None:
            tree = tgt_tree
        else:
            tree.append(tgt_tree)
    return tree

def print_tree(tree, prefix):
    new_prefix = prefix
    if len(tree) == 1:
        print(prefix + min_char[tree[0]])
    else:
        for elem in tree:
            if type(elem) != list:
                new_prefix += min_char[elem]
#                print(new_prefix)
            else:
                print_tree(elem, new_prefix)

    return


def abc_XXX(num):
    tree = dtype_tree(None, 0, num-1)
#    print(tree)
    print_tree(tree, "")
    return

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    
    abc_XXX(n)
    
    # output

# else:
    # do nothing
Buggy python submission (verdict: Runtime Error):
a,b = map(str,input().split())
b.replace(".")
print(a*b//100)

Fixed submission:
a,b=map(str,input().split())
a = int(a)
b = list(b)
del b[1]
b = int(''.join(b))
print(a*b//100)
Buggy python submission (verdict: Runtime Error):
s = input()
if s == 'ABC:
	print('ARC')
else:
	print('ABC')  

Fixed submission:
s = input()
if s == 'ABC':
	print('ARC')
else:
	print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):

def gcd(a,b):
    if a < b:
        a, b = b, a
    if mem[a][b]:
        return mem[a][b]
    if b == 0:
        return a
    mem[a][b] = gcd(b, a % b)
        
    return mem[a][b]

k = int(input())
ans = 0
mem = [[0 for a in range(k+1)]for b in range(k+1)]
n = k+1
for i in range(1,n):
    for j in range(1,n):
        for k in range(1,n):
            ans += gcd(gcd(i,j),k)
print(ans)


Fixed submission:
def gcd(a,b):
    if a < b:
        a, b = b, a
    if mem[a][b]:
        return mem[a][b]
    if b == 0:
        return a
    mem[a][b] = gcd(b, a % b)
    return mem[a][b]

k = int(input())
ans = 0
mem = [[0 for a in range(k+1)]for b in range(k+1)]
n = k+1
for i in range(1,n):
    for j in range(1,n):
        d = gcd(i,j)
        for k in range(1,n):
            ans += gcd(d,k)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

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

k = int(input())
ans = 0
mem = [[[0 for a in range(k+1)]for b in range(k+1)] for c in range(k+1)]
n = k+1
for i in range(1,n):
    for j in range(1,n):
        for k in range(1,n):
            a = max([i,j,k])
            b = min([i,j,k])
            c = sum([i,j,k]) - a - b
            if mem[a][b][c]:
                ans += mem[a][b][c]
            else:
                d = gcd(gcd(k,j),i)
                ans += d
                mem[a][b][c] = d
            # print("aaaaaa",i,j,k,ans)
print(ans)


Fixed submission:
def gcd(a,b):
    if a < b:
        a, b = b, a
    if mem[a][b]:
        return mem[a][b]
    if b == 0:
        return a
    mem[a][b] = gcd(b, a % b)
    return mem[a][b]

k = int(input())
ans = 0
mem = [[0 for a in range(k+1)]for b in range(k+1)]
n = k+1
for i in range(1,n):
    for j in range(1,n):
        d = gcd(i,j)
        for k in range(1,n):
            ans += gcd(d,k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    x = a[i]
    a[i] = (x*(x+1))/2/x
for i in range(n-k+1):
    ans = max(ans,sum(a[i:i+k]))
print(ans)

Fixed submission:

n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
r = [0 for _ in range(n+1)]
ans = 0
for i in range(1,n+1):
    x = a[i-1]
    r[i] = r[i-1] + (x*(x+1))/2/x #期待値
    if i+1 >=k:
        ans = max(ans,r[i]-r[i-k])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n ,m= list(map(int,input().split()))
kagi = [[]for _ in range(m)] 
#a円　b種類開けられる
for i in range(m):
    a,b =  list(map(int,input().split()))
    X =  list(map(int,input().split()))
    bit = 0
    for x in X:
        bit |= 2**(x-1)
    kagi[i] = [a,bit]

ok = 2**n-1#全部空いたらこれ
kagi.sort(key=lambda x: x[1])

dp = [float('inf')]*int(2**n+1)
dp[0] = 0
for i in range(2**n):
    for j in range(m):
        s = i|kagi[j][1]
        # print(s)
        dp[s] = min(dp[s],dp[i] + kagi[j][0])
if dp[2**n-1] == float('inf'):
    print(-1)
else:
    print(dp[2**n-1])

Fixed submission:
n ,m= list(map(int,input().split()))
kagi = [[]for _ in range(m)] 
#a円　b種類開けられる
for i in range(m):
    a,b =  list(map(int,input().split()))
    X =  list(map(int,input().split()))
    bit = 0
    for x in X:
        bit |= 2**(x-1)
    kagi[i] = [a,bit]

ok = 2**n-1#全部空いたらこれ
kagi.sort(key=lambda x: x[1])
zenkai = 2**n
dp = [float('inf')]*int(zenkai+1)
dp[0] = 0
for i in range(2**n):
    if dp[i] == float('inf'):
        continue
    for j in range(m):
        s = i|kagi[j][1]
        # print(s)
        dp[s] = min(dp[s],dp[i] + kagi[j][0])
# print(dp)
if dp[zenkai-1] == float('inf'):
    print(-1)
else:
    print(dp[zenkai-1])
Buggy python submission (verdict: Runtime Error):
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r and l != 0:#同じものがある&更新できる色がないなら追加
        lis2 = list(lis)
        lis=deque(lis2[0:r]+[a]+lis[l:])

        
    elif l == 0:#最小値追加
        lis.appendleft(a)
    else:#最大値更新
        lis[r-1] = a
print(len(lis))

Fixed submission:
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r :#同じものがある
        if l > 0:#他の色の最大値が上書きできる
            lis[l-1]=a
        elif r ==  len(lis):#全部の色の最大値とaが同じなら追加
            lis.append(a)
        else:#どこかの中に挿入
            lis.appendleft(a)
    elif l == 0:#最小値追加
        lis.appendleft(a)
    else:#最大値更新
        lis[r-1] = a
print(len(lis))

Buggy python submission (verdict: Runtime Error):
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r and l != 0:#同じものがある&更新できる色がないなら追加
        lis.insert(r,a)
        
    elif l == 0:#最小値追加
        lis.appendleft(a)
    else:#最大値更新
        lis[r-1] = a
print(len(lis))

Fixed submission:
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r :#同じものがある
        if l > 0:#他の色の最大値が上書きできる
            lis[l-1]=a
        elif r ==  len(lis):#全部の色の最大値とaが同じなら追加
            lis.append(a)
        else:#どこかの中に挿入
            lis.appendleft(a)
    elif l == 0:#最小値追加
        lis.appendleft(a)
    else:#最大値更新
        lis[r-1] = a
print(len(lis))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w = list(map(int,input().split()))
f = []
q = deque()
for i in range(h):
    a = list(input())
    for j in range(w):
        if a[j] == '#':
            q.append([0,i,j])
    f.append(a)

ans =0
dxy = [0,1,0,-1,0]
while(len(q)):
    c,y,x = q.popleft()
    for i in range(4):
        ny = y+dxy[i]
        nx = x+dxy[i+1]
        if nx >= w or ny >= h or nx <0 or ny <0:
            continue
        if f[ny][nx] == '.':
            f[ny][nx] = c+1
            q.append([c+1,ny,nx])
            ans = max(ans,c+1)
        elif f[ny][nx] != '#' and f[ny][nx] > c+1:
            f[ny][nx] = c+1
            q.append([c+1,ny,nx])
            ans = max(ans,c+1)

print(ans)


Fixed submission:
from collections import deque
h,w = list(map(int,input().split()))
f = []
q = deque()
for i in range(h):
    a = list(input())
    for j in range(w):
        if a[j] == '#':
            q.append([0,i,j])
    f.append(a)

ans =0
dxy = [0,1,0,-1,0]
while(len(q)):
    c,y,x = q.popleft()
    for i in range(4):
        ny = y+dxy[i]
        nx = x+dxy[i+1]
        if nx >= w or ny >= h or nx <0 or ny <0:
            continue
        if f[ny][nx] == '.':
            f[ny][nx] = c+1
            q.append([c+1,ny,nx])
            ans = max(ans,c+1)
        elif f[ny][nx] != '#' and f[ny][nx] > c+1:
            f[ny][nx] = c+1
            q.append([c+1,ny,nx])
            ans = max(ans,c+1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w = list(map(int,input().split()))
f = []
q = deque()
for i in range(h):
    a = list(input())
    for j in range(w):
        if a[j] == '#':
            q.append([0,i,j])
    f.append(a)

ans =0
dxy = [0,1,0,-1,0]
while(len(q)):
    c,y,x = q.popleft()
    for i in range(4):
        ny = y+dxy[i]
        nx = x+dxy[i+1]
        if nx >= w or ny >= h or nx <0 or ny <0:
            continue
        if f[ny][nx] == '.':
            f[ny][nx] = c+1
            q.append([c+1,ny,nx])
        elif f[ny][nx] != '#' and f[ny][nx] > c+1:
            f[ny][nx] = c+1
            q.append([c+1,ny,nx])

for i in range(h):
    for j in range(w):
        if f[i][j] != '#':
            ans = max(ans,f[i][j])
print(ans)


Fixed submission:
from collections import deque
h,w = list(map(int,input().split()))
f = []
q = deque()
for i in range(h):
    a = list(input())
    for j in range(w):
        if a[j] == '#':
            q.append([0,i,j])
    f.append(a)

ans =0
dxy = [0,1,0,-1,0]
while(len(q)):
    c,y,x = q.popleft()
    for i in range(4):
        ny = y+dxy[i]
        nx = x+dxy[i+1]
        if nx >= w or ny >= h or nx <0 or ny <0:
            continue
        if f[ny][nx] == '.':
            f[ny][nx] = c+1
            q.append([c+1,ny,nx])
            ans = max(ans,c+1)
        elif f[ny][nx] != '#' and f[ny][nx] > c+1:
            f[ny][nx] = c+1
            q.append([c+1,ny,nx])
            ans = max(ans,c+1)

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    sa = a[i] - (i+1)
    b[i] = sa
b.sort()
idx = int(n/2) -  (n%2)^1

p = b[idx]
ans = 0
for i in range(n):
    ans += abs(i+1+p-a[i])
print(ans)




Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    sa = a[i] - (i+1)
    b[i] = sa
b.sort()
idx = int(n/2) 

p = b[idx]
ans = 0
for i in range(n):
    ans += abs(i+1+p-a[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
X = tuple(map(int,input().split()))
for i in range(n):
    b = list(X)
    del b[i]
    b.sort()
    print(b[int(n/2-1)])

Fixed submission:
import bisect
n = int(input())
X = tuple(map(int,input().split()))
Xs = list(X)
Xs.sort()
for x in X:
    a = bisect.bisect_left(Xs,x)
    if a >= n/2:
        print(Xs[int(n/2)-1])
    else:
        print(Xs[int(n/2)])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 1

limit = pow(10,18)

f = 0
for i in range(N):
    if A[i] != 0:
        ans *= A[i]
    else:
        print(0)
        exit()

    if ans > limit:
        f = 1

if f == 1:
    print(-1)
else:
    print(ans)


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

limit = pow(10,18)

f = 0
for i in range(N):
    if A[i] != 0 and f == 0:
        ans *= A[i]
    elif A[i] != 0:
        pass
    else:
        print(0)
        exit()

    if ans > limit:
        f = 1

if f == 1:
    print(-1)
else:
    print(ans)

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

f = 0
for i in range(N):
    if A[i] != 0:
        ans *= A[i]
    else:
        print(0)
        exit()

    if ans > pow(10,18):
        f = 1

if f == 1:
    print(-1)
else:
    print(ans)


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

limit = pow(10,18)

f = 0
for i in range(N):
    if A[i] != 0 and f == 0:
        ans *= A[i]
    elif A[i] != 0:
        pass
    else:
        print(0)
        exit()

    if ans > limit:
        f = 1

if f == 1:
    print(-1)
else:
    print(ans)

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

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

for i in range(N):
    ans *= A[i]
    if ans > pow(10,18):
        ans = -1

print(ans)

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

limit = pow(10,18)

f = 0
for i in range(N):
    if A[i] != 0 and f == 0:
        ans *= A[i]
    elif A[i] != 0:
        pass
    else:
        print(0)
        exit()

    if ans > limit:
        f = 1

if f == 1:
    print(-1)
else:
    print(ans)