Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S, T = map(input().split())
A, B = map(int, input().split())
U = input()

print("A-1 B" if U == S else "A B-1")


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

print(A-1, B) if U == S else print(A, B-1)

Buggy python submission (verdict: Runtime Error):
S, T = map(input().split())
A, B = map(int, input().split())
U = input()

print(A-1 B if U == S else A B-1)


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

print(A-1, B) if U == S else print(A, B-1)

Buggy python submission (verdict: Runtime Error):
S, T = map(input().split())
A, B = map(int, input().split())
U = input()

print("A-1 B" if U == S else "A B")


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

print(A-1, B) if U == S else print(A, B-1)

Buggy python submission (verdict: Runtime Error):
S, T = map(input().split())
A, B = map(int, input().split())
U = input()

print(A-1 B if U == S else A B)


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

print(A-1, B) if U == S else print(A, B-1)

Buggy python submission (verdict: Runtime Error):
S, T = map(input().split())
A, B = map(int, input().split())
U = input()

print("S-1 T" if U == S else "S T-1")


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

print(A-1, B) if U == S else print(A, B-1)

Buggy python submission (verdict: Runtime Error):
S, T = map(input().split())
A, B = map(int, input().split())
U = input()

print(S-1 T if U == S else S T-1)

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

print(A-1, B) if U == S else print(A, B-1)
Buggy python submission (verdict: Runtime Error):
import math
H, A = map(int, input().split())
print(math.ceil(H,A))


Fixed submission:
import math
H, A = map(int, input().split())
print(math.ceil(H/A))
Buggy python submission (verdict: Runtime Error):
K, X = map(int, input().split())
print("Yes" if 500*K > = X else "No")


Fixed submission:
K, X = map(int, input().split())
print("Yes" if 500*K >= X else "No")

Buggy python submission (verdict: Runtime Error):
K, X = map(int, input().split())
print("Yes" if 500*K > = 2000 else "No")

Fixed submission:
K, X = map(int, input().split())
print("Yes" if 500*K >= X else "No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
print("Yes" if N[0:N/2-1] == N[N/2+1:] else "No")

Fixed submission:
N = int(input())
S = input()
if N%2 != 0:
  print("No")
elif S[:int(N/2)] == S[int(N/2):]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(((N//2)+1)/2N if N%2 != 0 else "0.5" )


Fixed submission:
N = int(input())
print(((N//2)+1)/N if N%2 != 0 else "0.5" )

Buggy python submission (verdict: Runtime Error):
N = int(input())
print(((N//2)+1)/2N if N%2 != 0 else 0.5 )


Fixed submission:
N = int(input())
print(((N//2)+1)/N if N%2 != 0 else "0.5" )

Buggy python submission (verdict: Runtime Error):
N = int(input())
print((N//2)+1/2N if N%2 != 0 else "0.5" )


Fixed submission:
N = int(input())
print(((N//2)+1)/N if N%2 != 0 else "0.5" )

Buggy python submission (verdict: Runtime Error):
N = int(input())
print((N//2)+1/2N if N%2 != 0 else 0.5 )


Fixed submission:
N = int(input())
print(((N//2)+1)/N if N%2 != 0 else "0.5" )

Buggy python submission (verdict: Runtime Error):
N = int(input())
print((N+1)/2N if N%2 != 0 else 0.5 )

Fixed submission:
N = int(input())
print(((N//2)+1)/N if N%2 != 0 else "0.5" )
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
List = list(map(int, input().split()))
count = 0
for i in List:
  if i>=K:
    count +=
print(count)

Fixed submission:
N, K = map(int, input().split())
List = list(map(int, input().split()))
count = 0
for i in List:
  if i>=K:
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
S = input()
print("No" if "L" in "S[0::2] or "R" in S[1::2] else "Yes")

Fixed submission:
S = input()
print("No" if "L" in S[0::2] or "R" in S[1::2] else "Yes")
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(math.ceil(B/A)))

Fixed submission:
import math
A, B = map(int, input().split())
print(math.ceil((B-1)/(A-1)))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print((A+B)//2 if (A+B)% == 0 else "IMPOSSIBLE")

Fixed submission:
A, B = map(int, input().split())
print((A+B)//2 if (A+B)% 2 == 0 else "IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
import math
N, D = map(int, input().split())
print(math.ceil(N/(2D+1)))

Fixed submission:
import math
N, D = map(int, input().split())
print(math.ceil(N/(2*D+1)))
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input())
h, w = map(int, input())
print((H-h)*(W-w))

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w))
Buggy python submission (verdict: Runtime Error):
S = input()
if S[5] == "1":
  print("TBD")
  elif int(S[6]) > 4:
    print("TBD")
  else:
    print("Heisei")


Fixed submission:
S = input()
if S[5] == "1":
  print("TBD")
elif int(S[6]) > 4:
  print("TBD")
else:
  print("Heisei")

Buggy python submission (verdict: Runtime Error):
S = input()
if S[5] == "1":
  print("TBD")
  elif int(S[6]) > 4:
    print("TBD")
else:
  print("Heisei")


Fixed submission:
S = input()
if S[5] == "1":
  print("TBD")
elif int(S[6]) > 4:
  print("TBD")
else:
  print("Heisei")

Buggy python submission (verdict: Runtime Error):
S = input()
if S[5] == "1":
  print("TBD")
  elif S[6] > "4":
    print("TBD")
else:
  print("Heisei")

Fixed submission:
S = input()
if S[5] == "1":
  print("TBD")
elif int(S[6]) > 4:
  print("TBD")
else:
  print("Heisei")
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
print(x*y/2)


Fixed submission:
x, y, z = map(int, input().split())
print(x*y//2)

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
print(x*y//2)


Fixed submission:
x, y, z = map(int, input().split())
print(x*y//2)

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input())
print(x*y//2)

Fixed submission:
x, y, z = map(int, input().split())
print(x*y//2)

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
print(x*y/2)

Fixed submission:
x, y, z = map(int, input().split())
print(x*y//2)
Buggy python submission (verdict: Runtime Error):
X = int(input())
if X in "753":
  print("YES")
else:
  print("NO")

Fixed submission:
X = input()
if X in "753":
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())))
print(A[N+-]-A[0])

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
print(A[N-1]-A[0])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())))
print(A[N+1]-A[0])

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
print(A[N-1]-A[0])
Buggy python submission (verdict: Runtime Error):
A, B, X = map(int, inpput().split())
print("YES" if A <= X and A+B >= X else "NO")


Fixed submission:
A, B, X = map(int, input().split())
print("YES" if A <= X and A+B >= X else "NO")

Buggy python submission (verdict: Runtime Error):
A, B, X = map(int, inpput().split())
print("YES" if A+B >= X else "NO")

Fixed submission:
A, B, X = map(int, input().split())
print("YES" if A <= X and A+B >= X else "NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
if 9 in N:
  print("Yes")
else:
  print("No")

Fixed submission:
N = input()
print("Yes" if "9" in N else "No")
Buggy python submission (verdict: Runtime Error):
a, b = int(input().split())
print((a-1)*(b-1))

Fixed submission:
a, b = map(int, input().split())
print((a-1)*(b-1))
Buggy python submission (verdict: Runtime Error):
c = str(input())
if "a", "e", "i", "o", "u" in c:
  print("vowel")
else:
  print("consonant")

Fixed submission:
c = str(input())
if c in "aiueo":
  print("vowel")
else:
  print("consonant")
Buggy python submission (verdict: Runtime Error):
abc = sorted(list(int, input().split()))
print("Yes" if abc[0] + abc[1] == abc[2] else "No")

Fixed submission:
abc = sorted(list(map(int, input().split())))
print("Yes" if abc[0] + abc[1] == abc[2] else "No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(input().split())
A = [int(i) for i in A]
B = len(A)+1

for i in range(B):
    print(A.count(i+1))

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


R = int(input())
PI = math.pi

ans = 2 * R * PI
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=input().split()
n=int(n)
m=int(m)
s=0
for i in input().split():
  s=s+ int(i)
if s>n:
  print("-1")
else:
  print(n-s)

Fixed submission:
a=int(input())
print(2*3.14*a)

Buggy python submission (verdict: Runtime Error):
a=float(input())
b=2*3.14.a
print(b)

Fixed submission:
a=int(input())
print(2*3.14*a)

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=2*3.14.a
print(b)

Fixed submission:
a=int(input())
print(2*3.14*a)
Buggy python submission (verdict: Runtime Error):
n,m=int(input.split())
s=0
for i in input.split():
  s=s+i
if s>n:
  print("-1")
else:
  print(n-s)



Fixed submission:
n,m=map(int, input().split())
s=0
for i in input().split():
    s=s+int(i)
if s>n:
    print("-1")
else:
    print(n-s)
Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())

output = 0

for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			output += math.gcd(i,math.gcd(j,k))

print(output)



Fixed submission:
import math
 
K = int(input())
 
output = 0
 
for i in range(1,K+1):
	for j in range(1,K+1):
		gcd_ij = math.gcd(i,j)
		for k in range(1,K+1):
			output += math.gcd(gcd_ij,k)
 
print(output)
Buggy python submission (verdict: Runtime Error):
l=[list(map(int,input().split())) for _ in range(2)]
homework=0
for i in range(l[0][1]):
    homework=homework+l[1][i]
free=l[0][0]-homework
if free<0:
    print(-1)
else:
    print(free)

Fixed submission:
import math
R=int(input())
print(2*math.pi*R)
Buggy python submission (verdict: Runtime Error):
l=list(map(int,input().split()))
homework=0
for i in range(l[1]):
    homework=homework+l[i+2]
free=l[0]-homework
if free<0:
    print(-1)
else:
    print(free)

Fixed submission:
l=[list(map(int,input().split())) for _ in range(2)]
homework=0
for i in range(l[0][1]):
    homework=homework+l[1][i]
free=l[0][0]-homework
if free<0:
    print(-1)
else:
    print(free)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding utf-8 -*-
n, k = map(int, input().split())
while n >= k:
    n = n - k

x = -1*(n-k)
if n<x:
    print(n)
else:
    print(x)


Fixed submission:
# -*- coding utf-8 -*-
n, k = map(int, input().split())
if k==1:
    print(0)
    exit()
n = n%k
if n <=k/2:
    print(n)
else:
    print(-1*(n-k))
Buggy python submission (verdict: Runtime Error):
# -*- coding utf-8 -*-
hash = {'SUN':7, 'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2,'STA':1}
s = input()
print(hash[s])


Fixed submission:
# -*- coding utf-8 -*-
hash = {'SUN':7, 'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2,'SAT':1}
s = input()
print(hash[s])
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
x = c - (a - b)
print(x if x > 0 else 0)4

Fixed submission:
a,b,c = [int(x) for x in input().split()]
i = c - (a - b)
if i < 0:
  print(0)
else :
  print(i)

Buggy python submission (verdict: Runtime Error):
a,b,c = [int(x) for x input().split()]
i = c - (a - b)
if i < 0:
  print(0)
else :
  print(i)

Fixed submission:
a,b,c = [int(x) for x in input().split()]
i = c - (a - b)
if i < 0:
  print(0)
else :
  print(i)
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
i=1
list=[]

while a>i and b>i:
    if a%i==0 and b%i==0:
        list.append(i)
    i+=1

print(list[k-1])

Fixed submission:
a,b,k=map(int,input().split())
i=1
list=[]

while a>=i and b>=i:
    if a%i==0 and b%i==0:
        list.append(i)
    i+=1

print(list[len(list)-k])
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if 
if a>9 and b>9:
  print(":(")
else:
  print("yay!")

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

if a<9 and b<9:
  print("Yay!")
elif a>8 or b>8:
  print(":(")

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a>9 0r b>9:
  print(":(")
else:
  print("yay!")

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

if a<9 and b<9:
  print("Yay!")
elif a>8 or b>8:
  print(":(")
Buggy python submission (verdict: Runtime Error):
number_1 = int(input())
number_2 = int(input())
if number_1>9 or number_2>9:
  print(-1)
else:
  print(number_1*number_2)

Fixed submission:
S = input()
li = S.split(" ")
A = int(li[0])
B = int(li[1])
if A>9 or B>9:
    print(-1)
else:
    print(A*B)

Buggy python submission (verdict: Runtime Error):
number_1 = int(input())
number_2 = int(input())
if number_1>9 or number_2>9:
  print("-1")
else:
  print(str(number_1*number_2))

Fixed submission:
S = input()
li = S.split(" ")
A = int(li[0])
B = int(li[1])
if A>9 or B>9:
    print(-1)
else:
    print(A*B)

Buggy python submission (verdict: Runtime Error):
number_1 = int(input())
number_2 = int(input())
if number_1>9 or number_2>9:
  print(-1)
else:
  print(number_1*number_2)

Fixed submission:
S = input()
li = S.split(" ")
A = int(li[0])
B = int(li[1])
if A>9 or B>9:
    print(-1)
else:
    print(A*B)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
n = round(N**0.5)
answer = 0
for num in range(n,N+1):
  if N%num==0:
    a = num
    b = int(N/num)
    answer = a+b-2
    break
print(answer)

Fixed submission:
N = int(input())
n = round(N**0.5)
a = 0
b = 0
for i in range(n):
    if N%(n-i)==0:
        a = n-i
        b = int(N/a)
        break
print(a+b-2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
 
org_sum = 1/2 * N * (N+1)
div3 = N // 3
sum3 = 3/2 * div3 * (div3+1)
div5 = N // 5
sum5 = 5/2 * div5 * (div5+1)
div15 = N // 15
sum15 = 15/2 * div15 * (div15+1)
 
return org_sum - sum3 - sum5 + sum15

Fixed submission:
N = int(input())
 
org_sum = 1 * N * (N+1) // 2
div3 = N // 3
sum3 = 3 * div3 * (div3+1) //2
div5 = N // 5
sum5 = 5 * div5 * (div5+1) // 2
div15 = N // 15
sum15 = 15 * div15 * (div15+1) // 2
 
print(org_sum - sum3 - sum5 + sum15)

Buggy python submission (verdict: Runtime Error):
N = input()
 
org_sum = 1/2 * N * (N+1)
div3 = N // 3
sum3 = 3/2 * div3 * (div3+1)
div5 = N // 5
sum5 = 5/2 * div5 * (div5+1)
div15 = N // 15
sum15 = 15/2 * div15 * (div15+1)
 
return org_sum - sum3 - sum5 + sum15

Fixed submission:
N = int(input())
 
org_sum = 1 * N * (N+1) // 2
div3 = N // 3
sum3 = 3 * div3 * (div3+1) //2
div5 = N // 5
sum5 = 5 * div5 * (div5+1) // 2
div15 = N // 15
sum15 = 15 * div15 * (div15+1) // 2
 
print(org_sum - sum3 - sum5 + sum15)

Buggy python submission (verdict: Runtime Error):
N = input()
 
org_sum = 1/2*N*(N+1)
div3 = N // 3 * 3
div5 = N // 5 * 5
div15 = N // 15 * 15
 
return org_sum - div3 - div5 + div15

Fixed submission:
N = int(input())
 
org_sum = 1 * N * (N+1) // 2
div3 = N // 3
sum3 = 3 * div3 * (div3+1) //2
div5 = N // 5
sum5 = 5 * div5 * (div5+1) // 2
div15 = N // 15
sum15 = 15 * div15 * (div15+1) // 2
 
print(org_sum - sum3 - sum5 + sum15)

Buggy python submission (verdict: Runtime Error):
N = input()

org_sum = 1/2*N*(N+1)
div3 = N // 3
div5 = N // 5
div15 = N // 15

return org_sum - div3 - div5 + div15

Fixed submission:
N = int(input())
 
org_sum = 1 * N * (N+1) // 2
div3 = N // 3
sum3 = 3 * div3 * (div3+1) //2
div5 = N // 5
sum5 = 5 * div5 * (div5+1) // 2
div15 = N // 15
sum15 = 15 * div15 * (div15+1) // 2
 
print(org_sum - sum3 - sum5 + sum15)
Buggy python submission (verdict: Time Limit Exceeded):
'''
着想：大きいaほど左右の端に移動したい、小さいaを先に端にやるより必ず大きくなるから
問題：単純に貪欲に大きいaから左端(x-1)と右端(N-x)の大きい方に移動すると、
      残りのaの組み合わせ的に最適でない場合がある
      アイテムの左右端の単純な割り振りはO(2^N)
解決策の着想：大きい順のk個を(k=L+R)となる
    　　左L個右R個にどのように割り振っても(k+1)個目の最適な割り振り方は変わらない
解決策：アイテムk個左右に割り振る状態をdp[L][R]で保存O(N^2)
'''

N = int(input())
A = [[a, i] for a,i in zip(map(int, input().split()), range(N))]
A.sort(key=lambda a: a[0], reverse=True)

dp = [[0]*(N+1) for _ in range(N+1)] # 左からxマス右からyマス埋める
for i in range(0,N):
  a, l = A[i]
  for x in range(0,i+1):
    y = i - x # 合計x+y=iマス既に埋まっている、次にi+1マス目を考える
    dp[x+1][y] = max(dp[x+1][y], dp[x][y] + a * abs(l - x))
    dp[x][y+1] = max(dp[x][y+1], dp[x][y] + a * abs(l - (N-y-1)))

print(max(dp[N-i][i] for i in range(N+1)))

Fixed submission:
'''
着想：大きいaほど左右の端に移動したい、小さいaを先に端にやるより必ず大きくなるから
問題：単純に貪欲に大きいaから左端(x-1)と右端(N-x)の大きい方に移動すると、
      残りのaの組み合わせ的に最適でない場合がある
      アイテムの左右端の単純な割り振りはO(2^N)
解決策の着想：大きい順のk個を(k=L+R)となる
    　　左L個右R個にどのように割り振っても(k+1)個目の最適な割り振り方は変わらない
解決策：アイテムk個左右に割り振る状態をdp[L][R]で保存O(N^2)
'''

def solve():
  N = int(input())
  A = [[a, i] for a,i in zip(map(int, input().split()), range(N))]
  A.sort(key=lambda a: a[0], reverse=True)

  dp = [[0]*(N+1) for _ in range(N+1)] # 左からxマス右からyマス埋める
  for i in range(0,N):
    a, l = A[i]
    for x in range(0,i+1):
      y = i - x # 合計x+y=iマス既に埋まっている、次にi+1マス目を考える
      dp[x+1][y] = max(dp[x+1][y], dp[x][y] + a * abs(l - x))
      dp[x][y+1] = max(dp[x][y+1], dp[x][y] + a * abs(l - (N-y-1)))

  print(max(dp[N-i][i] for i in range(N+1)))
  
solve()
Buggy python submission (verdict: Runtime Error):
k = int(input())
lunluns = list(map(str, range(1,10)))
new = list(map(str, range(1,10)))
new_fueta = 9
end = False
while len(lunluns) < k:
  new_new_fueta = 0
  for x in lunluns[-new_fueta:]:
    str_x = str(x)
    if str_x[-1] == '0':
      lunluns += [int(str_x+'0'),int(str_x+'1')]
      new_new_fueta += 2
    elif str_x[-1] == '9':
      lunluns += [int(str_x+'8'),int(str_x+'9')]
      new_new_fueta += 2
    else:
      l = int(str_x[-1])
      lunluns += [int(str_x+str(l-1)), int(str_x+str(l)), int(str_x+str(l+1))]
      new_new_fueta += 3
  if end:
    break
  new_fueta = new_new_fueta
print(lunluns[k-1])

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

def solve_dp(s):
  dp = [0]*(n+2)
  for i in range(n):
    if i <= c and s[i] == 'o':
      dp[i+1] = 1
    else:
      if s[i] == 'o':
        dp[i+1] = max(dp[i], dp[i-c]+1)
      else:
        dp[i+1] = dp[i]
  return dp

mae = solve_dp(s)
ushiro = solve_dp(s[::-1])[::-1]

for i in range(1,n+1):
  if mae[i-1] + ushiro[i+1] < k:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N, x, y = map(int, input().split())
x -= 1
y -= 1
dist = [0] * (N-1)

for i in range(N-1):
  for j in range(i+1,N):
    d = min([abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)])
    dist[d-1] += 1

for i in range(N-1):
  print(dist[i])

Fixed submission:
N, x, y = map(int, input().split())
x -= 1
y -= 1
dist = [0] * (N)

for i in range(N-1):
  for j in range(i+1,N):
    d = min([abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)])
    dist[d] += 1

for i in range(1,N):
  print(dist[i])

Buggy python submission (verdict: Time Limit Exceeded):
N, x, y = map(int, input().split())
x -= 1
y -= 1

for n in range(1,N):
  ans = 0
  for i in range(N-1):
    for j in range(i+1,N):
      if n == min([abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)]):
        ans += 1
  print(ans)

Fixed submission:
N, x, y = map(int, input().split())
x -= 1
y -= 1
dist = [0] * (N)

for i in range(N-1):
  for j in range(i+1,N):
    d = min([abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)])
    dist[d] += 1

for i in range(1,N):
  print(dist[i])
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
#S = ['#'*(W+2)] + ['#'+input()+'#' for _ in range(H)] + ['#'*(W+2)]
S = [input() for _ in range(H)]

cost = [[10000]*W for _ in range(H)]

def dfs(i, j, c):
  if i >= H or j >= W:
    return
  else:
    cost[i][j] = min(cost[i][j], c+1 if S[i][j]=='#' else c)
    dfs(i+1, j, cost[i][j])
    dfs(i, j+1, cost[i][j])

dfs(0, 0, 0)
print(cost[-1][-1])

Fixed submission:
import sys
sys.setrecursionlimit(100000)

H, W = map(int, input().split())
S = [input() for _ in range(H)]
cost = [[0]*W for _ in range(H)]
cost[0][0] = 1 if S[0][0] == '#' else 0
for w in range(1,W):
  if S[0][w-1] == '.' and S[0][w] == '#':
    cost[0][w] = cost[0][w-1] + 1
  else:
    cost[0][w] = cost[0][w-1]
for h in range(1,H):
  if S[h-1][0] == '.' and S[h][0] == '#':
    cost[h][0] = cost[h-1][0] + 1
  else:
    cost[h][0] = cost[h-1][0]

for h in range(1,H):
  for w in range(1,W):
    if S[h-1][w] == '.' and S[h][w] == '#':
      ch = cost[h-1][w] + 1
    else:
      ch = cost[h-1][w]
    if S[h][w-1] == '.' and S[h][w] == '#':
      cw = cost[h][w-1] + 1
    else:
      cw = cost[h][w-1]
    cost[h][w] = min(ch, cw)

print(cost[-1][-1])
Buggy python submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))
for i in range(1,1010):
  if int(i*8/100)==A and if int(i/10)==B:
    print(i)
    break
else:
  print(-1)

Fixed submission:
import math
 
A, B = list(map(int, input().split()))
x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  for x in range(max(x_minA, x_minB), min(x_maxA, x_maxB)+1):
    if int(x * 8 / 100) == A and int(x / 10)==B:
      print(x)
      break
  else:
    print(-1)

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

x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:x_min = max(x_minA, x_minB)
  x_max = min(x_maxA, x_maxB)
  tansaku = np.array(range(max(x_minA, x_minB), min(x_maxA, x_maxB)+1))
  insert_index_a = bisect.bisect_left(tansaku*8/100-A,1)
  insert_index_b = bisect.bisect_left(tansaku/10-B,1)
  print(int(tansaku[min(insert_index_a, insert_index_b)]))

Fixed submission:
import math
 
A, B = list(map(int, input().split()))
x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  for x in range(max(x_minA, x_minB), min(x_maxA, x_maxB)+1):
    if int(x * 8 / 100) == A and int(x / 10)==B:
      print(x)
      break
  else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
import math

A, B = list(map(int, input().split()))
x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  x = max(x_minA, x_minB)
  while (x * 8 / 100 - A >= 1) or (x / 10 - B >= 1):
    print(x, x * 8 / 100, x / 10)
    x += 1
  
  print(x)

Fixed submission:
import math
 
A, B = list(map(int, input().split()))
x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  for x in range(max(x_minA, x_minB), min(x_maxA, x_maxB)+1):
    if int(x * 8 / 100) == A and int(x / 10)==B:
      print(x)
      break
  else:
    print(-1)

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

x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  x = max(x_minA, x_minB)
  while (x * 8 / 100 - A >= 1) or (x / 10 - B >= 1):
    print(x, x * 8 / 100, x / 10)
    x += 1
  print(x)

Fixed submission:
import math
 
A, B = list(map(int, input().split()))
x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  for x in range(max(x_minA, x_minB), min(x_maxA, x_maxB)+1):
    if int(x * 8 / 100) == A and int(x / 10)==B:
      print(x)
      break
  else:
    print(-1)