Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
num,total=[int(str) for str in input().split()]

if total>10000*num or total<1000*num or total%1000!=0:
    print("-1 -1 -1")


total_cal=[]
num_10000=0
num_5000=0
num_1000=0

if num<300:
    pass
else:
    for num_cal in range(num,200,-1):
        #print('total:',total)
        #print(num_cal)
        ave=total/num_cal
        diff=[abs(10000-ave),abs(5000-ave),abs(1000-ave)]
        if diff.index(min(diff))==0:
            total-=10000
            num_10000 += 1
        elif diff.index(min(diff))==1:
            total-=5000
            num_5000 += 1
        else:
            total-=1000
            num_1000 += 1

    num=num_cal-1
    #print(num)
    #print(total)

for i in range(num+1):
    for j in range(num+1):
        for k in range(num+1):
            total_cal.append({"nums":[i,j,k],'total':10000*i+5000*j+1000*k})

nums=[x["nums"] for x in total_cal if x['total']==total and sum(x['nums'])==num]


if total_cal!=0 and nums==[]:
    print("-1 -1 -1")
else:
    nums = [x + y for (x, y) in zip(nums[0], [num_10000, num_5000, num_1000])]
    print('{num_10000} {num_5000} {num_1000}'.format(num_10000=nums[0],num_5000=nums[1],num_1000=nums[2]))


Fixed submission:
num,total=[int(str) for str in input().split()]

#if total>10000*num or total<1000*num or total%1000!=0:
#    print("-1 -1 -1")


total_cal=[]
num_10000=0
num_5000=0
num_1000=0
limit=50

if num<limit:
    pass
else:
    for num_cal in range(num,limit,-1):
        #print('total:',total)
        #print(num_cal)
        ave=total/num_cal
        diff=[abs(10000-ave),abs(5000-ave),abs(1000-ave)]
        if diff.index(min(diff))==0:
            total-=10000
            num_10000 += 1
        elif diff.index(min(diff))==1:
            total-=5000
            num_5000 += 1
        else:
            total-=1000
            num_1000 += 1

    num=limit
    #print(num)
    #print(total)

for i in range(num+1):
    for j in range(num+1):
        for k in range(num+1):
            total_cal.append({"nums":[i,j,k],'total':10000*i+5000*j+1000*k})

nums=[x["nums"] for x in total_cal if x['total']==total and sum(x['nums'])==num]


if total_cal!=0 and nums==[]:
    print("-1 -1 -1")
else:
    nums = [x + y for (x, y) in zip(nums[0], [num_10000, num_5000, num_1000])]
    print('{num_10000} {num_5000} {num_1000}'.format(num_10000=nums[0],num_5000=nums[1],num_1000=nums[2]))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

clear_flag=0
tmp=0
tmp_x=0
tmp_y=0
for i in range(N):
  txy=list(map(int,input().split()))
  x=0
  y=0
  next_flag=0
  for x_plus in range(txy[0]-tmp+1):
    if next_flag==1:
      break
    for x_minus in range(txy[0]-tmp+1-x_plus):
      if next_flag==1:
        break
      for y_plus in range(txy[0]-tmp+1-x_plus-x_minus):
        y_minus=txy[0]-tmp-x_plus-x_minus-y_plus
        x=x_plus-x_minus+tmp_x
        y=y_plus-y_minus+tmp_y
        if x==txy[1] and y==txy[2]:
          next_flag=1
          clear_flag+=1
          tmp=txy[0]
          tmp_x=txy[1]
          tmp_y=txy[2]
          break
            
if clear_flag==N:
  print("Yes")
else:
  print("No")

Fixed submission:
N=int(input())

clear_flag=0
for i in range(N):
  txy=list(map(int,input().split()))
  if txy[0]>=(txy[1]+txy[2]) and (txy[0]+txy[1]+txy[2])%2==0:
    clear_flag+=1
  else:
    break
    
if clear_flag==N:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

clear_flag=0
for i in range(N):
  txy=list(map(int,input().split()))
  x=0
  y=0
  next_flag=0
  for x_plus in range(txy[0]+1):
    if next_flag==1:
      break
    for x_minus in range(txy[0]+1-x_plus):
      if next_flag==1:
        break
      for y_plus in range(txy[0]+1-x_plus-x_minus):
        y_minus=txy[0]-x_plus-x_minus-y_plus
        x=x_plus-x_minus
        y=y_plus-y_minus
        if x==txy[1] and y==txy[2]:
          next_flag=1
          clear_flag+=1
          break
            
if clear_flag==N:
  print("Yes")
else:
  print("No")

Fixed submission:
N=int(input())

clear_flag=0
for i in range(N):
  txy=list(map(int,input().split()))
  if txy[0]>=(txy[1]+txy[2]) and (txy[0]+txy[1]+txy[2])%2==0:
    clear_flag+=1
  else:
    break
    
if clear_flag==N:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

clear_flag=0
for i in range(N):
  txy=list(map(int,input().split()))
  x=0
  y=0
  next_flag=0
  for x_plus in range(txy[0]+1):
    if next_flag==1:
      break
    for x_minus in range(txy[0]+1-x_plus):
      if next_flag==1:
        break
      for y_plus in range(txy[0]+1-x_plus-x_minus):
        if next_flag==1:
          break
        for y_minus in range(txy[0]+1-x_plus-x_minus-y_plus):
          if x_plus+x_minus+y_plus+y_minus==txy[0]:
            #print(x_plus,x_minus,y_plus,y_minus)
            x=x_plus-x_minus
            y=y_plus-y_minus
            if x==txy[1] and y==txy[2]:
            	next_flag=1
            	clear_flag+=1
            	break
            
          
if clear_flag==N:
  print("Yes")
else:
  print("No")

Fixed submission:
N=int(input())

clear_flag=0
for i in range(N):
  txy=list(map(int,input().split()))
  if txy[0]>=(txy[1]+txy[2]) and (txy[0]+txy[1]+txy[2])%2==0:
    clear_flag+=1
  else:
    break
    
if clear_flag==N:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
from functools import reduce 
from operator import add
 
n = int(input())
arr = map(int, input().split())
 
pt_a = 0
pt_b = 0
 
arr.sort(reverse=True)
 
for ind, num in enumerate(arr):
  if ind % 2 == 0:
    pt_a += num
  else:
    pt_b += num
 
print(pt_a - pt_b)

Fixed submission:
from functools import reduce 
from operator import add
 
n = int(input())
arr = list(map(int, input().split()))
 
pt_a = 0
pt_b = 0
 
arr.sort(reverse=True)
 
for ind, num in enumerate(arr):
  if ind % 2 == 0:
    pt_a += num
  else:
    pt_b += num
 
print(pt_a - pt_b)

Buggy python submission (verdict: Runtime Error):
from functools import reduce 
from operator import add

n = int(input())
arr = map(int, input().split())

pt_a = 0
pt_b = 0

arr = arr.sort(reverse=True)

for ind, num in enumerate(arr):
  if ind % 2 == 0:
    pt_a += num
  else:
    pt_b += num

print(pt_a - pt_b)

Fixed submission:
from functools import reduce 
from operator import add
 
n = int(input())
arr = list(map(int, input().split()))
 
pt_a = 0
pt_b = 0
 
arr.sort(reverse=True)
 
for ind, num in enumerate(arr):
  if ind % 2 == 0:
    pt_a += num
  else:
    pt_b += num
 
print(pt_a - pt_b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
 
flg = True
t_ = 0
x_ = 0
y_ = 0

for i in range(n):
  t, x, y = map(int, input().split())
  t_ = abs(t - t_)
  x_ = abs(x - x_)
  y_ = abs(y - y_)
  
  if t_ - x_ - y_ < 0:
    print('No')
    flg = False
    break
  elif (t_ - x_ - y_) % 2 != 0:
    print('No')
    flg = False
    break
  t_ = t
  x_ = x
  y_ = y
 
if flg:
  print('Yes')

Fixed submission:
a, b = map(int, input().split())
 
if a % 2 == 1 and b % 2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
n = int(input())
 
flg = True
t_ = 0
x_ = 0
y_ = 0
for i in range(n):
  t, x, y = map(int, input().split())
  t_ -= t
  x_ -= x
  y_ -= y
  
  if (t_ - x_ - y_) % 2 != 0:
    print('No')
    flg = False
    break
 
if flg:
  print('Yes')

Fixed submission:
a, b = map(int, input().split())
 
if a % 2 == 1 and b % 2 == 1:
  print('Odd')
else:
  print('Even')
Buggy python submission (verdict: Runtime Error):
n = int(input())

flg = True
t_ = 0
x_ = 0
y_ = 0
for i in range(n):
  t, x, y = map(int, input().split())
  t_ -= t
  x_ -= x
  y_ -= y
  
  if (t_ - x_ - y_) % 2 != 0:
  	print('No')
  	flg = False
    break

if flg:
  print('Yes')

Fixed submission:
n = int(input())
 
flg = True
t_ = 0
x_ = 0
y_ = 0

for i in range(n):
  t, x, y = map(int, input().split())
  t_ = abs(t - t_)
  x_ = abs(x - x_)
  y_ = abs(y - y_)
  
  if t_ - x_ - y_ < 0:
    print('No')
    flg = False
    break
  elif (t_ - x_ - y_) % 2 != 0:
    print('No')
    flg = False
    break
  t_ = t
  x_ = x
  y_ = y
 
if flg:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
n, X = map(int, input().split())
 
for i in range(n+1):
  for j in range(n+1):
    if i+j > n:
      pass
    else:
      k = n-i-j
      otoshi = 10000*i + 5000*j + 1000*k
      if otoshi == X:
        print(i, j, k)
        break
  else:
    continue
  break

Fixed submission:
n = int(input())
s = {input() for i in range(n)}
 
print(len(s))

Buggy python submission (verdict: Runtime Error):
n = input()
s = {input() for i in range(3)}

print(len(s))

Fixed submission:
n = int(input())
s = {input() for i in range(n)}
 
print(len(s))
Buggy python submission (verdict: Runtime Error):

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

n_cond = 0
for i in range(n+1):
  i_str = str(i)
  order_sum = map(sum, i_str)
  if order_sum >= a and order_sum <= b:
    n_cond += 1

Fixed submission:
from functools import reduce 
from operator import add
n, a, b = map(int, input().split())

n_cond = 0

for i in range(1, n+1):
  i_str = str(i)

  if len(i_str) == 1:
    order_sum = i
    
  else:
    temp = list(map(int, i_str))
    order_sum = reduce(add, temp)
    
  if order_sum >= a and order_sum <= b:
    n_cond += i
print(n_cond)
Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int, input().split()))

num_dvd = 0
 
can_devide = True
temp_list = []
while can_devide:
  for num in nums:
    if num % 2 == 1:
      can_devide = False
      print(num_dvd)
      break
    else:
      temp_list.append(num // 2)
  num_dvd += 1
  nums, temp_list = temp_list, []

Fixed submission:
from collections import Counter
txt = input()

counter = Counter(txt)

print(counter['1'])

Buggy python submission (verdict: Runtime Error):
n = input()
nums = map(int, input().split())
 
num_dvd = 0

can_devide = True
temp_list = []
while can_devide == True:
  for num in nums:
    if num % 2 == 1:
      print(num_dvd)
      can_devide == False
    else:
      temp_list.append(num // 2)
  num_dvd += 1
  nums, temp_list = temp_list, []

Fixed submission:
from collections import Counter
txt = input()

counter = Counter(txt)

print(counter['1'])
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
nums = map(int, input().split())
 
num_dvd = 0
 
can_devide = True
temp_list = []
while can_devide is True:
  for num in nums:
    if num % 2 == 1:
      print(num_dvd)
      can_devide == False
    else:
      temp_list.append(num // 2)
  num_dvd += 1
  nums, temp_list = temp_list, []

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

num_dvd = 0
 
can_devide = True
temp_list = []
while can_devide:
  for num in nums:
    if num % 2 == 1:
      can_devide = False
      print(num_dvd)
      break
    else:
      temp_list.append(num // 2)
  num_dvd += 1
  nums, temp_list = temp_list, []

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
nums = map(int, input().split())
 
num_dvd = 0

can_devide = True
temp_list = []
while can_devide == True:
  for num in nums:
    if num % 2 == 1:
      print(num_dvd)
      can_devide == False
    else:
      temp_list.append(num // 2)
  num_dvd += 1
  nums, temp_list = temp_list, []

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

num_dvd = 0
 
can_devide = True
temp_list = []
while can_devide:
  for num in nums:
    if num % 2 == 1:
      can_devide = False
      print(num_dvd)
      break
    else:
      temp_list.append(num // 2)
  num_dvd += 1
  nums, temp_list = temp_list, []

Buggy python submission (verdict: Runtime Error):
n = input()
nums = map(int, input().split())
 
num_dvd = 0


temp_list = []
while can_devide == True:
  for num in nums:
    if num % 2 == 1:
      print(num_dvd)
      can_devide == False
    else:
      temp_list.append(num // 2)
  num_dvd += 1

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

num_dvd = 0
 
can_devide = True
temp_list = []
while can_devide:
  for num in nums:
    if num % 2 == 1:
      can_devide = False
      print(num_dvd)
      break
    else:
      temp_list.append(num // 2)
  num_dvd += 1
  nums, temp_list = temp_list, []
Buggy python submission (verdict: Time Limit Exceeded):
string = input()

flg = True
while len(string) > 0:
  if string.endswith('dream'):
    string = string[:-5]
  elif string.endswith('dreamer'):
    string = string[:-7]
  elif string.endswith('erase'):
    string = string[:-6]
  elif string.endswith('eraser'):
    string = string[:-6]
  else:
    print('NO')
    flg = False
if flg:
  print('YES')

Fixed submission:
string = input()
 
flg = True
while len(string) > 0:
  if string.endswith('dream'):
    string = string[:-5]
  elif string.endswith('dreamer'):
    string = string[:-7]
  elif string.endswith('erase'):
    string = string[:-5]
  elif string.endswith('eraser'):
    string = string[:-6]
  else:
    print('NO')
    flg = False
    break
if flg:
  print('YES')
Buggy python submission (verdict: Runtime Error):
N = int(input())
t0, x0, y0 = 0, 0, 0
flag=True
for i in range(N):
    t1,x1,y1 = [int(j) for j in input().split()]
    dt = t1 - t0
    dist = abs(x0-x1) + abs(y0-y1)

    if dist > dt:
        print('No')
        flag=False

    elif (dist%2==0 and dt%2==0) or  (dist%2==1 and dt%2==1):
        t0, x0, y0 = t1, x1, y1

    else:
        print('No')
        flag=False

if flag:
    print('Yes')

Fixed submission:
a, b = map(int, input().split())
if (a*b)%2. == 0:
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
print(input())print(input().count('1'))

Fixed submission:
print(input().count('1'))
Buggy python submission (verdict: Runtime Error):
s = input()

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

for i in range(len(str_list)):
    if len(str_list[i])==7 and s[-7:]=='dreamer':
	s = s[:-7]

    elif len(str_list[i])==6 and s[-6:]=='eraser':
	s = s[:-6]
	
    elif s[-5:]=='erase' or s[-5:]=='dream':
	s = s[:-5]

if s=='':
    print('YES')
else:
    print('NO')

Fixed submission:
s = input()
flag = True
while flag:
    if s=='':
        flag==False
    if s[-7:]=='dreamer':
        s = s[:-7]

    elif s[-6:]=='eraser':
        s = s[:-6]

    elif s[-5:]=='dream' or s[-5:]=='erase':
        s = s[:-5]

    else:
        break


if s=='':
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a*b)%2 == 0:
  print('Even')
  else:
    print('Odd')

Fixed submission:
a, b = map(int, input().split())
if (a*b)%2 == 0:
  print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
A = 'Yes'
N = int(input())
t = np.array([[0,0,0]])
for n in range(N):
     a = [[int(i) for i in input().split()]]
     t = np.append(t, np.array(a), axis=0)
     diff = t[n+1] -t[n]
     cond = np.abs(diff[1]) + np.abs(diff[2])
     if cond > diff[0]:
        A='No'
        break
     if np.sum(np.array(a)) % 2 ==1:
        A = 'No'
        break
print(A)

Fixed submission:
N = int(input())
t_list = [0]
x_list = [0]
y_list = [0]
A = 'Yes'
for i in range(N):
    ti, xi, yi = map(int, input().split())
    t_list.append(ti)
    x_list.append(xi)
    y_list.append(yi)
    if ((abs(x_list[i+1] - x_list[i]) + abs(y_list[i+1] - y_list[i]) > (t_list[i+1] - t_list[i]))):
        A = 'No'
        break
    if (x_list[i+1] + y_list[i+1] - t_list[i+1])%2 != 0:
        A = 'No'
        break
print(A)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
A = 'Yes'
N = int(input())
t = np.array([[0,0,0]])
for n in range(N):
     a = [[int(i) for i in input().split()]]
     t = np.append(t, np.array(a), axis=0)
     diff = t[n+1] -t[n]
     cond = np.abs(diff[1]) + np.abs(diff[2])
     if cond > diff[0]:
        A='No'
        break
     if np.sum(t[n+1]) % 2 ==1:
        A = 'No'
        break
print(A)

Fixed submission:
N = int(input())
t_list = [0]
x_list = [0]
y_list = [0]
A = 'Yes'
for i in range(N):
    ti, xi, yi = map(int, input().split())
    t_list.append(ti)
    x_list.append(xi)
    y_list.append(yi)
    if ((abs(x_list[i+1] - x_list[i]) + abs(y_list[i+1] - y_list[i]) > (t_list[i+1] - t_list[i]))):
        A = 'No'
        break
    if (x_list[i+1] + y_list[i+1] - t_list[i+1])%2 != 0:
        A = 'No'
        break
print(A)
Buggy python submission (verdict: Runtime Error):
a,b = input().split()

cross = int((a * b)/2)

if cross == 0:
    print("even")

if cross != 0:
    print("odd")


Fixed submission:
a,b = map(int, input().split())
if (a * b) % 2 == 0:
  print('Even')
else:
  print('Odd')

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

b = int(input())


cross = int((a * b)/2)

if cross == 0:
    print("even")

if cross != 0:
    print("odd")

Fixed submission:
a,b = map(int, input().split())
if (a * b) % 2 == 0:
  print('Even')
else:
  print('Odd')

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

b = int(input())


cross = int((a * b)/2)

if cross == 0:
    print("even")

if cross != 0:
    print("odd")


Fixed submission:
a,b = map(int, input().split())
if (a * b) % 2 == 0:
  print('Even')
else:
  print('Odd')

Buggy python submission (verdict: Runtime Error):

a = input()
aa = int(a)
b = input()
bb = int(b)

cross = int(aa * bb)

cd = int(cross / 2)

if cd == 0:
    print("even")

if cd != 0:
    print("odd")

Fixed submission:
a,b = map(int, input().split())
if (a * b) % 2 == 0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())



    #x = sum(l)
array = 0

for i in range(N+1):
    l =[int(x) for x in list(str(i))]
    f = sum(l)
    if f >= A and f <= B:
        array = array + i

print(array)

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


array = 0

for i in range(li[0]+1):
    l =[int(x) for x in list(str(i))]
    f = sum(l)
    if f >= li[1] and f <= li[2]:
        array = array + i

print(array)
Buggy python submission (verdict: Runtime Error):

s1, s2, s3 = map(int, input().split())

a = 0

if s1 =1 or s2 =1 or s3 = 1:
  a += 1
else:
  a += 0

print(a)

Fixed submission:
n = input()

def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return array

b = digitSum(n)
a = 0
c = len(b)
for i in range(c):
    if b[i] == 1:
        a+=1
    else:
        a+=0

print(a)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = input()
a,b = [int(i) for i in x.split()]
s = 0
for x in range(1,n+1):
  if a <= sum([int(i) for i in str(x)]) <= b:
    s+= x
print(s)

Fixed submission:
x = input()
n,a,b = [int(i) for i in x.split()]
s = 0
for x in range(1,n+1):
  if a <= sum([int(i) for i in str(x)]) <= b:
    s+= x
print(s)
Buggy python submission (verdict: Runtime Error):
dbflag=""

def debug(*args):
  if ""!=dbflag: print(*args)

if ""!=dbflag: _INDATA=open(dbflag)

def readline():
  if ""!=dbflag:return _INDATA.readline()
  else: return input()


result = -1

H, W = map(int, readline().split())

#２次元配列
import numpy as np

S= np.ndarray(shape=(H,W), dtype=object)

for i in range(0,H):
	S[i,0:W] =list(readline().rstrip())
	

wNum = S[S == "."].size
bNum = H * W - wNum

debug(H,W)
debug(S)
debug(wNum)



from collections import deque
queue = deque([])
#queue.append(A)
#queue.popleft()


depthS = np.full((H,W), -1, dtype=int)

depthS[0,0] = 0
queue.append((0,0))

while len(queue) > 0 and depthS[H-1,W-1]==-1:
	base = queue.popleft()
	baseDepth = depthS[base]

	debug("----")
	debug(base,baseDepth)
	debug("depthS")	
	debug(depthS)	


	neighbors = next(base)
	
	debug('depthS',depthS)
	for n in neighbors: depthS[n[0],n[1]]=baseDepth + 1

	debug('depthS2',depthS)
	debug('neighbors',neighbors)
	
	for n in neighbors:
		queue.append(n)
	debug("queue",queue)	


if depthS[H-1,W-1]!=-1:
	result = wNum - (depthS[H-1,W-1] + 1)
else:
	result = -1

print(result)


def next(b):
	result = []
	x,y = b
	if x -1 >= 0 and S[x-1,y]=='.' and depthS[x-1,y]== -1:
		result.append((x-1,y))
	if y -1 >= 0 and S[x,y-1]=='.' and depthS[x,y-1]== -1:
		result.append((x,y-1))
	if x +1 < H and S[x+1,y]=='.' and depthS[x+1,y]== -1:
		result.append((x+1,y))
	if y +1 < W and S[x, y+1]=='.' and depthS[x,y+1]== -1:
		result.append((x,y+1))
	
	return result



Fixed submission:
dbflag=""

def next(b):
	result = []
	x,y = b
	if x -1 >= 0 and S[x-1,y]=='.' and depthS[x-1,y]== -1:
		result.append((x-1,y))
	if y -1 >= 0 and S[x,y-1]=='.' and depthS[x,y-1]== -1:
		result.append((x,y-1))
	if x +1 < H and S[x+1,y]=='.' and depthS[x+1,y]== -1:
		result.append((x+1,y))
	if y +1 < W and S[x, y+1]=='.' and depthS[x,y+1]== -1:
		result.append((x,y+1))
	
	return result

  
def debug(*args):
  if ""!=dbflag: print(*args)

if ""!=dbflag: _INDATA=open(dbflag)

def readline():
  if ""!=dbflag:return _INDATA.readline()
  else: return input()


result = -1

H, W = map(int, readline().split())

#２次元配列
import numpy as np

S= np.ndarray(shape=(H,W), dtype=object)

for i in range(0,H):
	S[i,0:W] =list(readline().rstrip())
	

wNum = S[S == "."].size
bNum = H * W - wNum

debug(H,W)
debug(S)
debug(wNum)



from collections import deque
queue = deque([])
#queue.append(A)
#queue.popleft()


depthS = np.full((H,W), -1, dtype=int)

depthS[0,0] = 0
queue.append((0,0))

while len(queue) > 0 and depthS[H-1,W-1]==-1:
	base = queue.popleft()
	baseDepth = depthS[base]

	debug("----")
	debug(base,baseDepth)
	debug("depthS")	
	debug(depthS)	


	neighbors = next(base)
	
	debug('depthS',depthS)
	for n in neighbors: depthS[n[0],n[1]]=baseDepth + 1

	debug('depthS2',depthS)
	debug('neighbors',neighbors)
	
	for n in neighbors:
		queue.append(n)
	debug("queue",queue)	


if depthS[H-1,W-1]!=-1:
	result = wNum - (depthS[H-1,W-1] + 1)
else:
	result = -1

print(result)
Buggy python submission (verdict: Runtime Error):
dbflag="aaa.txt"

def debug(*args):
  if ""!=dbflag: print(*args)

if ""!=dbflag: _INDATA=open(dbflag)

def readline():
  if ""!=dbflag:return _INDATA.readline()
  else: return input()


result = -1

N = int(readline())



import numpy as np

A1 = [int(i) for i in readline().split(' ')]
A2 = [int(i) for i in readline().split(' ')]
data = np.zeros((2,N),dtype=int)
data[0,0:N]=A1
data[1,0:N]=A2

#np.reshape(data,[2,N])

memo = np.zeros((2,N), dtype=int)
score = np.zeros((2,N), dtype=int)


def getScore(i,j):
	if i < 0 or j < 0 : return 0
	
	if memo[i,j]: return score[i,j]
	
	result= data[i,j] + max(getScore(i-1,j) ,  getScore(i,j-1))
	memo[i,j]=1
	return result

result = getScore(1,N-1)
print(result)

Fixed submission:
dbflag=""

def debug(*args):
  if ""!=dbflag: print(*args)

if ""!=dbflag: _INDATA=open(dbflag)

def readline():
  if ""!=dbflag:return _INDATA.readline()
  else: return input()


result = -1

N = int(readline())



import numpy as np

A1 = [int(i) for i in readline().split(' ')]
A2 = [int(i) for i in readline().split(' ')]
data = np.zeros((2,N),dtype=int)
data[0,0:N]=A1
data[1,0:N]=A2

#np.reshape(data,[2,N])

memo = np.zeros((2,N), dtype=int)
score = np.zeros((2,N), dtype=int)


def getScore(i,j):
	debug(i,j,data[i,j])
	if i < 0 or j < 0 : return 0

	
	if memo[i,j]: return score[i,j]
	
	return data[i,j] + max(getScore(i-1,j) ,  getScore(i,j-1))

result = getScore(1,N-1)
print(result)