Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def GCD(a, b):
	if b > a:
		tmp = a
		a = b
		b = tmp
	if a % b == 0:
		return b
	return GCD(b, a % b)

def LCM(a, b):
	return a * b / GCD(a, b)

def judge():
	N, M = map(int, raw_input().split())
	S = raw_input()
	T =raw_input()
	L = LCM(N, M)
	good_str = ["*"] * L
	for i in range(N):
		idx = i * L/N
		good_str[idx] = S[i]
	for i in range(M):
		idx = i * L/M
		if good_str[idx] == "*" or good_str[idx] == T[i]:
			pass
		else:
			return -1
	return L

print judge()


Fixed submission:
def GCD(a, b):
	if b > a:
		tmp = a
		a = b
		b = tmp
	if a % b == 0:
		return b
	return GCD(b, a % b)

def LCM(a, b):
	return a * b / GCD(a, b)

def judge():
	N, M = map(int, raw_input().split())
	S = raw_input()
	T =raw_input()
	L = LCM(N, M)
	S_pos = [0] * N
	T_pos = [0] * M
	for i in range(N):
		S_pos[i] = i * L/N
	for i in range(M):
		T_pos[i] = i * L/M
	i = 0
	j = 0
	while i < N and j < M:
		if S_pos[i] == T_pos[j]:
			if S[i] != T[j]:
				return -1
			i += 1
			j += 1
		elif S_pos[i] < T_pos[j]:
			i += 1
		else:
			j += 1
	return L

print judge()
Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())

res = 1
for i in range(1, M + 1):
	if i * i > M:
		break
	if M % i != 0:
		continue
	j = M / i
	if long(i) * N <= M:
		res = max(res, i)
	if long(j) * N <= M:
		res = max(res, j)
print res


Fixed submission:
import math
N, M = map(int, raw_input().split())

MAX_RES = int(math.sqrt(M))
res = 1
for i in range(1, MAX_RES + 1):
	if i * i > M:
		break
	if M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res

Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())

res = 1
for i in range(1, N + 1):
	if i > M * M:
		break
	iif M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res


Fixed submission:
import math
N, M = map(int, raw_input().split())

MAX_RES = int(math.sqrt(M))
res = 1
for i in range(1, MAX_RES + 1):
	if i * i > M:
		break
	if M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res

Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())

res = 0
for i in range(1, N + 1):
	if i > M * M:
		break
	iif M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res


Fixed submission:
import math
N, M = map(int, raw_input().split())

MAX_RES = int(math.sqrt(M))
res = 1
for i in range(1, MAX_RES + 1):
	if i * i > M:
		break
	if M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res
Buggy python submission (verdict: Time Limit Exceeded):
S = raw_input()
T = raw_input()

CS = [S.count(s) for s in S]
TS = [T.count(t) for t in T]

if False in [CS[i] == TS[i] for i in range(len(CS))]:
	print 'No'
else:
	print 'Yes'


Fixed submission:
S = raw_input()
T = raw_input()

CS = {}
for s in S:
	if s not in CS:
		CS[s] = 1
	else:
		CS[s] += 1
TS = {}
for t in T:
	if t not in TS:
		TS[t] = 1
	else:
		TS[t] += 1

if False in [CS[S[i]] == TS[T[i]] for i in range(len(T))]:
	print 'No'
else:
	print 'Yes'
Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, raw_input().split())
L = []
R = []
for i in range(M):
	_l, _r = map(int, raw_input().split())
	L.append(_l)
	R.append(_r)

p = []
q = []
for i in range(Q):
	_p, _q = map(int, raw_input().split())
	p.append(_p)
	q.append(_q)


start_end_mat = [[0] * (N + 1) for i in range(N + 1)]

for i in range(M):
	start = L[i]
	end = R[i]
	for j in range(start, -1, -1):
		for k in range(end, N + 1):
			start_end_mat[j][k] += 1


for i in range(Q):
	start = p[i]
	end = q[i]
	print(start_end_mat[start][end])



Fixed submission:
N, M, Q = map(int, raw_input().split())
L = []
R = []
for i in range(M):
	_l, _r = map(int, raw_input().split())
	L.append(_l)
	R.append(_r)

p = []
q = []
for i in range(Q):
	_p, _q = map(int, raw_input().split())
	p.append(_p)
	q.append(_q)


start_end_mat = [[0] * (N + 1) for i in range(N + 1)]

for i in range(M):
	start_end_mat[L[i]][R[i]] += 1

for i in range(1, N + 1):
	for j in range(1, N + 1):
		start_end_mat[i][j] += start_end_mat[i-1][j]
		start_end_mat[i][j] += start_end_mat[i][j-1]
		start_end_mat[i][j] -= start_end_mat[i-1][j-1]

for i in range(Q):
	res = start_end_mat[N][q[i]]
	res -= start_end_mat[p[i] - 1][q[i]]
	print(res)
Buggy python submission (verdict: Runtime Error):
import sys

A = map(int, sys.argv[1::])
A.sort()
print(A[2] - A[1] + A[1] - A[0])



Fixed submission:
A = map(int, raw_input().split())
A.sort()
print(A[2] - A[1] + A[1] - A[0])
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def cost(N, A, b):
	return sum([abs(A[i] - b - i - 1) for i in range(N)])

N = input()
A = map(int, raw_input().split())

res = float("inf")
b = 0
if cost(N, A, b) <= cost(N, A, b - 1) and  cost(N, A, b) <= cost(N, A, b + 1):
	print cost(N, A, b)
	sys.exit()
elif cost(N, A, b) < cost(N, A, b + 1):
	delta = -1
else:
	delta = 1
b += delta
pre_delta = delta
while pre_delta == delta:
	if cost(N, A, b) < cost(N, A, b + delta):
		break
	b += delta
print cost(N, A, b)


Fixed submission:
import sys

N = input()
A = map(int, raw_input().split())
A = [A[i] - i - 1 for i in range(N)]
A.sort()
b = A[N / 2]
print sum([abs(a - b) for a in A])
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, raw_input().split())

if abs(a - b) < d and abs(b - c) < d or abs(a - c) < d:
	


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

if abs(a - b) <= d and abs(b - c) <= d or abs(a - c) <= d:
	print 'Yes'
else:
	print 'No'
Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
if a <= b:
	print a
else:
	print a - 1



Fixed submission:
S = raw_input()
res = 700
for i in range(3):
	if S[i] == 'o':
		res += 100
print res
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
X = map(int, raw_input().split())
pair = [(v, i) for i, v in enumerate(X)]
pair.sort()
X = [v[0] for v in pair]
res = {}
for i, v in enumerate(pair):
    key = v[1]
    val = v[0]
    res[key] = (X[:i] + X[i + 1:])[(N - 1) / 2]
for i in range(N):
    print res[i]


Fixed submission:
N = input()
X = map(int, raw_input().split())
med = sorted(X)[N / 2 - 1:N / 2 + 1]
for v in X:
    if v <= med[0]:
        print med[1]
    else:
        print med[0]

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
X = map(int, raw_input().split())
pair = [(v, i) for i, v in enumerate(X)]
pair.sort()
X.sort()
res = {}
for i, v in enumerate(pair):
    key = v[1]
    val = v[0]
    res[key] = (X[:i] + X[i + 1:])[(N - 1) / 2]
for i in range(N):
    print res[i]


Fixed submission:
N = input()
X = map(int, raw_input().split())
med = sorted(X)[N / 2 - 1:N / 2 + 1]
for v in X:
    if v <= med[0]:
        print med[1]
    else:
        print med[0]

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
X = map(int, raw_input().split())
for i in range(N):
    print sorted(X[:i] + X[i + 1:])[(N - 1) / 2]


Fixed submission:
N = input()
X = map(int, raw_input().split())
med = sorted(X)[N / 2 - 1:N / 2 + 1]
for v in X:
    if v <= med[0]:
        print med[1]
    else:
        print med[0]
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, raw_input().split())
AB = range(A, B + 1)
if B - A + 1 > 2 * K:
	for i in AB[:K]:
		print i
	for i in AB[-K:]:
		print i
else:
	for i in AB:
		print i


Fixed submission:
A, B, K = map(int, raw_input().split())
if B - A + 1 > 2 * K:
	for i in range(A, A + K):
		print i
	for i in range(B - K + 1, B + 1):
		print i
else:
	for i in range(A, B + 1):
		print i

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, raw_input().split())
AB = range(A, B + 1)
if len(AB) > 2 * K:
	for i in AB[:K]:
		print i
	for i in AB[-K:]:
		print i
else:
	for i in AB:
		print i


Fixed submission:
A, B, K = map(int, raw_input().split())
if B - A + 1 > 2 * K:
	for i in range(A, A + K):
		print i
	for i in range(B - K + 1, B + 1):
		print i
else:
	for i in range(A, B + 1):
		print i

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, raw_input().split())
AB = range(A, B + 1)
if len(AB) > 2 * K:
	for i in AB[:K]:
		print i
for i in AB[-K:]:
	print i


Fixed submission:
A, B, K = map(int, raw_input().split())
if B - A + 1 > 2 * K:
	for i in range(A, A + K):
		print i
	for i in range(B - K + 1, B + 1):
		print i
else:
	for i in range(A, B + 1):
		print i

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, raw_input().split())
AB = range(A, B + 1)
for i in AB[:K]:
	print i
for i in AB[-K:]:
	print i


Fixed submission:
A, B, K = map(int, raw_input().split())
if B - A + 1 > 2 * K:
	for i in range(A, A + K):
		print i
	for i in range(B - K + 1, B + 1):
		print i
else:
	for i in range(A, B + 1):
		print i
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, raw_input().split())
print min(A, C) + min(B, D)


Fixed submission:
A = input()
B = input()
C = input()
D = input()
print min(A, B) + min(C, D)
Buggy python submission (verdict: Runtime Error):
N = raw_input()
MIN_GNUM = 3
print N / MIN_GNUM



Fixed submission:
N = input()
MIN_GNUM = 3
print N / MIN_GNUM
Buggy python submission (verdict: Runtime Error):
N = input()
A = input()

rest = N % A
if rest <= A:
	print "Yes"
else:
	print "No"


Fixed submission:
N = input()
A = input()

rest = N % 500
if rest <= A:
	print "Yes"
else:
	print "No"
Buggy python submission (verdict: Runtime Error):
if a * b % 2 == 0:
	print "Even"
else:
	print "Odd"


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

if a * b % 2 == 0:
	print "Even"
else:
	print "Odd"
Buggy python submission (verdict: Runtime Error):
S = raw_input()
MISSED_IDX = 3
S[MISSED_IDX] = 8

print S


Fixed submission:
S = raw_input()
MISSED_IDX = 3
res = list(S)
res[MISSED_IDX] = '8'

print "".join(res)
Buggy python submission (verdict: Runtime Error):
import sys<
N, Y = map(int, raw_input().split())<
for i in range(N + 1):<
    for j in range(N + 1 - i):<
        k = N - i - j<
        if i * 10000 + j * 5000 + k * 1000 == Y:
            print i, j, k<
            sys.exit()<
print "-1 -1 -1"<


Fixed submission:
import sys
N, Y = map(int, raw_input().split())
for i in range(N + 1):
    for j in range(N + 1 - i):
        k = N - i - j
        if i * 10000 + j * 5000 + k * 1000 == Y:
            print i, j, k
            sys.exit()
print "-1 -1 -1"
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = input()
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())
A.sort()
B.sort()
C.sort()

BC_type_num = []
for b in B:
    upper_bound = bisect.bisect_right(C, b)
    BC_type_num.append(N - upper_bound)

ABC_type_num = []
for a in A:
    upper_bound = bisect.bisect_right(B, a)
    ABC_type_num.append(sum(BC_type_num[upper_bound:]))

print sum(ABC_type_num)

Fixed submission:
import bisect
N = input()
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())
A.sort()
B.sort()
C.sort()

BC_type_num = []
pre = 0
for b in reversed(B):
    upper_bound = bisect.bisect_right(C, b)
    BC_type_num.append(pre + N - upper_bound)
    pre += N - upper_bound
BC_type_num.reverse()

res = 0
for a in A:
    upper_bound = bisect.bisect_right(B, a)
    if upper_bound < N:
        res += BC_type_num[upper_bound]

print res
Buggy python submission (verdict: Runtime Error):
H, W = map(int, raw_input().split())
S = [raw_input() for i in range(H)]
C = [[0] * W for i in range(H)]
for i in range(H):
    for j in range(W):
        for di in range(-1, 1):
            if i + di < 0 or H <= i + di:
                continue
            for dj in range(-1, 1):
                if j + dj < 0 or W <= j + dj:
                    continue
                C[i][j] += 1 if S[i][j] == "#" else -1
for i in range(H):
    print "".join(C[i])




Fixed submission:
import sys
H, W = map(int, raw_input().split())
S = [raw_input() for i in range(H)]
C = [[0] * W for i in range(H)]
for i in range(H):
    for j in range(W):
        for di in range(-1, 2):
            if i + di < 0 or H <= i + di:
                continue
            for dj in range(-1, 2):
                if j + dj < 0 or W <= j + dj:
                    continue
                C[i][j] += 1 if S[i + di][j + dj] == "#" else 0
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            sys.stdout.write("#")
        else:
            sys.stdout.write(str(C[i][j]))
    print ""
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
d = {}
for _ in range(N):
    a = input()
    if str(a) not in d.keys():
        d[str(a)] = 1
    else:
        d[str(a)] ^= 1

print sum(d.values())

Fixed submission:
N = input()
d = {}
for _ in range(N):
    a = input()
    d[str(a)] = d.get(str(a), 0)
    d[str(a)] ^= 1

print sum(d.values())
Buggy python submission (verdict: Runtime Error):
def not_found_minchar(S):
    sorted_S = sorted(set(S))
    idx = 0
    for o in range(ord('a'), ord('z') + 1):
        if o < ord(sorted_S[idx]):
            return chr(o)
        idx += 1
    return "None"

S = raw_input()
print not_found_minchar(S)


Fixed submission:
def not_found_minchar(S):
    for o in range(ord('a'), ord('z') + 1):
        if chr(o) not in S:
            return chr(o)
    return "None"

S = raw_input()
print not_found_minchar(S)

Buggy python submission (verdict: Runtime Error):
def not_found_minchar(S):
    sorted_S = sorted(list(set(S)))
    idx = 0
    for o in range(ord('a'), ord('z') + 1):
        if o < ord(sorted_S[idx]):
            return chr(o)
        idx += 1
    return "None"

S = raw_input()
print not_found_minchar(S)


Fixed submission:
def not_found_minchar(S):
    for o in range(ord('a'), ord('z') + 1):
        if chr(o) not in S:
            return chr(o)
    return "None"

S = raw_input()
print not_found_minchar(S)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = map(int, raw_input().split())

res = []
for i in range(n):
  if i % 2 == 0:
    res = [a[i]] + res
  else:
    res = res + [a[i]]
if n % 2 == 0:
  print ' '.join(map(str, res[::-1]))
else:
  print ' '.join(map(str, res))

Fixed submission:
from collections import deque
n = input()
a = map(int, raw_input().split())

res = deque()

for i in range(n):
  if i % 2 == 0:
    res.appendleft(a[i])
  else:
    res.append(a[i])
if n % 2 == 0:
  print ' '.join(map(str, reversed(res)))
else:
  print ' '.join(map(str, res))

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = map(int, raw_input().split())

res = []
for i in range(n):
  res += [a[i]]
  res.reverse()
print ' '.join(map(str, res))

Fixed submission:
from collections import deque
n = input()
a = map(int, raw_input().split())

res = deque()

for i in range(n):
  if i % 2 == 0:
    res.appendleft(a[i])
  else:
    res.append(a[i])
if n % 2 == 0:
  print ' '.join(map(str, reversed(res)))
else:
  print ' '.join(map(str, res))
Buggy python submission (verdict: Runtime Error):
X, A, B = map(int, raw_input().split())

print "delicisous" if A - B >= 0  "safe" if X >= B - A else "dangerous"


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

print "delicious" if A - B >= 0 else "safe" if X >= B - A else "dangerous"
Buggy python submission (verdict: Runtime Error):
A, B = map(int, raw_input().split()
print (A + B) % 24


Fixed submission:
A, B = map(int, raw_input().split())
print (A + B) % 24

Buggy python submission (verdict: Runtime Error):
A, B = map(int, raw_input().split()
print (A + B) % 23


Fixed submission:
A, B = map(int, raw_input().split())
print (A + B) % 24
Buggy python submission (verdict: Runtime Error):
N = input()
print 800 * N 200 * (N // 15)


Fixed submission:
N = input()
print 800 * N - 200 * (N // 15)
Buggy python submission (verdict: Runtime Error):
print "Yes" if (a + b + c) % 2 == 0 else "No"


Fixed submission:
a, b, c = map(int, raw_input().split())
print "Yes" if (a + b + c) % 2 == 0 and (a + b + c) // 2 in [a, b, c] else "No"
Buggy python submission (verdict: Runtime Error):
i = int(input().split()[1])
s = input()
print("{}{}{}".format(s[:i], s[i].lower(), s[i+1:]))

Fixed submission:
i = int(input().split()[1]) - 1
s = input()
print("{}{}{}".format(s[:i], s[i].lower(), s[i+1:]))
Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]

def l2c(x):
	c = 1 / n
    while x < k:
		x = x * 2
        c = c / 2
    return c
  
print(sum([l2c(i) for i in range(1, n+1)])

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

def l2c(x):
	c = 1 / n
	while x < k:
		x = x * 2
		c = c / 2
	return c

print(sum([l2c(i) for i in range(1, n+1)]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
total = for i in range(n):
    total += i

print(total)

Fixed submission:
n = int(input())
total = n
for i in range(n):
    total += i

print(total)
Buggy python submission (verdict: Runtime Error):
s = input()
print("Heisei") if s[5:7] =< 4 else print("TBD")

Fixed submission:
s = input()
print("Heisei") if s[5:7] == "01" or s[5:7] == "02" or s[5:7] == "03" or s[5:7] == "04"  else print("TBD")
Buggy python submission (verdict: Runtime Error):
N = int(input())
number_list = []
for i in map(int, input().split()):
    number_list += [i]

for i in range(N-1):
    for j in range(N):
        if i < j:
            if number_list[i] > number_list[j]:
                a = number_list[i]
                number_list[i] = number_list[j]
                number_list[j] = a

sum = 0
for i in range(N-1):
    sum+=number_list[i]

if sum > number_list[N]:
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())
number_list = []
for i in map(int, input().split()):
    number_list += [i]

for i in range(N-1):
    for j in range(N):
        if i < j:
            if number_list[i] > number_list[j]:
                a = number_list[i]
                number_list[i] = number_list[j]
                number_list[j] = a

sum = 0
for i in range(N-1):
    sum+=number_list[i]

if sum > number_list[N-1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,inpu().split())
print(a*b/2)

Fixed submission:
a,b,c=map(int,input().split())
print(int(a*b/2))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()
count=0
while 1:
  if s==t:
    print("Yes")
    break
  if count==len(s):
    print("No")
    break
  s=s[1:]+s[0]

Fixed submission:
s=input()
t=input()
count=0
while 1:
  if s==t:
    print("Yes")
    break
  if count==len(s):
    print("No")
    break
  s=s[1:]+s[0]
  count+=1
Buggy python submission (verdict: Runtime Error):
s=input()
result=0
for i in s:
  result+=1 if i=="+" else result-=1
print(result)

Fixed submission:
s=input()
result=0
for i in s:
    if i=="+" : result+=1
    else : result-=1
print(result)
Buggy python submission (verdict: Runtime Error):
n=input()
a=0
for i in n:
  a+=int(n[i])
print("Yes") if int(n)%a==0 else print("No")

Fixed submission:
n=input()
a=0
for i in n:
  a+=int(i)
print("Yes") if int(n)%a==0 else print("No")

Buggy python submission (verdict: Runtime Error):
n=input()
a=0
for i in n:
  a+=int(n[i])
print("Yes") if int(n)//a else print("No")

Fixed submission:
n=input()
a=0
for i in n:
  a+=int(i)
print("Yes") if int(n)%a==0 else print("No")

Buggy python submission (verdict: Runtime Error):
n=input()
a=0
for i in n:
  a+=int(n[i])
print("Yes") if int(n)//a else prit("No")

Fixed submission:
n=input()
a=0
for i in n:
  a+=int(i)
print("Yes") if int(n)%a==0 else print("No")
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
for i in range(a,b+1):
    if i-a<k or b-i<k:print(i)

Fixed submission:
a,b,k=map(int,input().split())
if b-a+1<=2*k:
    for i in range(a,b+1):print(i)
else:
    for i in range(a,a+k):print(i)
    for i in range(b-k+1,b+1):print(i)
Buggy python submission (verdict: Runtime Error):
n=int(input())
blue=[]
for i in range(n):
    blue.append(input())
m=int(input())
red=[]
for i in range(m):
    red.append(input())
max=0
for i in blue:
    b=blue.count(i)
    r=red.count(i)
    max=max(b-r,max)
print(max)

Fixed submission:
n=int(input())
blue=[]
for i in range(n):
    blue.append(input())
m=int(input())
red=[]
for i in range(m):
    red.append(input())
max=0
for i in blue:
    b=blue.count(i)
    r=red.count(i)
    if b-r>max:max=b-r
print(max)
Buggy python submission (verdict: Runtime Error):
N=input()
a=0
for i in N:
  a+=int(i)
print("Yes") if N%a==0 else print("No")

Fixed submission:
N=input()
a=0
for i in N:
  a+=int(i)
print("Yes") if int(N)%a==0 else print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
for i in range(10**9):
    if i**2>n:print((i-1)**2)

Fixed submission:
n=int(input())
for i in range(10**9):
    if i**2>n:
        print((i-1)**2)
        break
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
masu=[]
up=1
down=1
left=1
right=1
for i in range(h):
    masu.append([i for i in input()])
for i in range(h):
    for j in range(w):
        bakudan=0
        if masu[i][j]==".":
            if i==0:up=0
            elif i==h-1:down=0
            if j==0:left=0
            elif j==w-1:right=0
            if up:
                if masu[i-1][j]=="#":bakudan+=1
            if up and left:
                if masu[i-1][j-1]=="#":bakudan+=1
            if up and right:
                if masu[i-1][j+1]=="#":bakudan+=1
            if left:
                if masu[i][j-1]=="#":bakudan+=1
            if left and down:
                if masu[i+1][j-1]=="#":bakudan+=1
            if down:
                if masu[i+1][j]=="#":bakudan+=1
            if down and right:
                if masu[i+1][j+1]=="#":bakudan+=1
            if right:
                if masu[i][j+1]=="#":bakudan+=1
            masu[i][j]=str(bakudan)
        up=1
        down=1
        left=1
        right=1

for i in masu:
    s=''.join(i)
    print(s)

Fixed submission:
h,w=map(int,input().split())
masu=[]
up=1
down=1
left=1
right=1
for i in range(h):
    masu.append([i for i in input()])
for i in range(h):
    for j in range(w):
        bakudan=0
        if masu[i][j]==".":
            if i==0:up=0
            if i==h-1:down=0
            if j==0:left=0
            if j==w-1:right=0
            if up:
                if masu[i-1][j]=="#":bakudan+=1
            if up and left:
                if masu[i-1][j-1]=="#":bakudan+=1
            if up and right:
                if masu[i-1][j+1]=="#":bakudan+=1
            if left:
                if masu[i][j-1]=="#":bakudan+=1
            if left and down:
                if masu[i+1][j-1]=="#":bakudan+=1
            if down:
                if masu[i+1][j]=="#":bakudan+=1
            if down and right:
                if masu[i+1][j+1]=="#":bakudan+=1
            if right:
                if masu[i][j+1]=="#":bakudan+=1
            masu[i][j]=str(bakudan)
        up=1
        down=1
        left=1
        right=1

for i in masu:
    s=''.join(i)
    print(s)
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split
print("YES") if a[-1]==b[0] and b[-1]==c[0] else print("NO")

Fixed submission:
a,b,c=input().split()
print("YES") if a[-1]==b[0] and b[-1]==c[0] else print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=1
for i in range(1,n+1):
    a*=i
print(a%(10**9+7))

Fixed submission:
a=1
for i in range(1,int(input())+1):
    a=(i*a)%(10**9+7)
print(a)
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split(".")
print(a,b,c)

Fixed submission:
a,b,c=input().split(",")
print(a,b,c)
Buggy python submission (verdict: Time Limit Exceeded):
x=input()
judge = True
while judge:
    for i in range(len(x)):
        if x[i:i+2] == "ST" :
            x=x[:i] + x[i+2:]
            break
    if "ST" not in x : 
        judge=False
        print(len(x))

Fixed submission:
x=input()
n=len(x)
s_count=0
t_count=0
for i in x:
    if i == "S" : s_count+=1
    else:
        if s_count>0 : 
            s_count-=1
            n-=2
print(n)