Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
K = int(input())
ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            ans += np.gcd.reduce([a, b, c])
print(ans)


Fixed submission:
from math import gcd
K = int(input())
ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            ans += gcd(gcd(a, b), c)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

ac_list = [0] * (N + 1)
wa_list = [0] * (M + 1)
a = 0
w = 0
for i in range(M):
    l = input().split()
    if ac_list[int(l[0])]!='AC':
        if l[1] == 'AC':
            ac_list[int(l[0])] = 'AC'
            a += 1
            w += wa_list[int(l[0])]
        else:
            wa_list[int(l[0])] += 1

print('{} {}'.format(a, w))


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

ac_list = [0] * (N + 1)
wa_list = [0] * (N + 1)
a = 0
w = 0
for i in range(M):
    l = input().split()
    if ac_list[int(l[0])]!='AC':
        if l[1] == 'AC':
            ac_list[int(l[0])] = 'AC'
            a += 1
            w += wa_list[int(l[0])]
        else:
            wa_list[int(l[0])] += 1

print('{} {}'.format(a, w))

Buggy python submission (verdict: Runtime Error):
import sys
s = sys.stdin.readlines()

c = res.append
a = 0
b = 0
c = 0
N, M = map(int, s[0].split())
for e in s[1:M + 1]:
  p, S = e.split()
  if p not in c:
    if S == 'AC':
        c(p)
        a += 1
        c = b
    else:
        b += 1

print('{} {}'.format(a, c)) 


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

ac_list = [0] * (N + 1)
wa_list = [0] * (N + 1)
a = 0
w = 0
for i in range(M):
    l = input().split()
    if ac_list[int(l[0])]!='AC':
        if l[1] == 'AC':
            ac_list[int(l[0])] = 'AC'
            a += 1
            w += wa_list[int(l[0])]
        else:
            wa_list[int(l[0])] += 1

print('{} {}'.format(a, w))

Buggy python submission (verdict: Runtime Error):
import sys
def main():  
    s = sys.stdin.readlines()

    c = []
    a = 0
    b = 0
    N, M = map(int, s[0].split())
    for e in s[1:M + 1]:
    p, S = e.split()
    if p not in c:
        if S == 'AC':
            c.append(p)
            a += 1
        else:
            b += 1

    print('{} {}'.format(a, b)) 


if __name__ == '__main__':
    main()

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

ac_list = [0] * (N + 1)
wa_list = [0] * (N + 1)
a = 0
w = 0
for i in range(M):
    l = input().split()
    if ac_list[int(l[0])]!='AC':
        if l[1] == 'AC':
            ac_list[int(l[0])] = 'AC'
            a += 1
            w += wa_list[int(l[0])]
        else:
            wa_list[int(l[0])] += 1

print('{} {}'.format(a, w))

Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    s = sys.stdin.readlines()

    c = []
    a = 0
    b = 0
    N, M = map(int, s[0].split())
    for e in s[1:M + 1]:
    p, S = e.split()
    if p not in c:
        if S == 'AC':
            c.append(p)
            a += 1
        else:
            b += 1

    print('{} {}'.format(a, b)) 


if __name__ == '__main__':
    main()

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

ac_list = [0] * (N + 1)
wa_list = [0] * (N + 1)
a = 0
w = 0
for i in range(M):
    l = input().split()
    if ac_list[int(l[0])]!='AC':
        if l[1] == 'AC':
            ac_list[int(l[0])] = 'AC'
            a += 1
            w += wa_list[int(l[0])]
        else:
            wa_list[int(l[0])] += 1

print('{} {}'.format(a, w))
Buggy python submission (verdict: Runtime Error):
s, t = input().split()
print("{}{}".format(t, s)

Fixed submission:
s, t = input().split()
print("{}{}".format(t, s))
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print(a*b//math.gcd(a, b))

Fixed submission:
import fractions
a, b = map(int, input().split())
print(a*b//fractions.gcd(a, b))
Buggy python submission (verdict: Runtime Error):
r = input()
ans = r * r
print(ans)


Fixed submission:
r = int(input())
ans = r * r
print(ans)

Buggy python submission (verdict: Runtime Error):
r = input()
print(r * r)

Fixed submission:
r = int(input())
ans = r * r
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 10**12
for i in range(1, int(ns**0.5)+1):
    if n%i==0:
        ans = min(ans, i+n//i)
print(ans-2)

Fixed submission:
n = int(input())

ans = 10**12
for i in range(1, int(n**0.5)+1):
    if n%i==0:
        ans = min(ans, i+n//i)
print(ans-2)

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

ans = 10**12
for i in range(1, int(ns**0.5)+1):
    print(n%i)
    if n%i==0:
        ans = min(ans, i+n//i)
print(ans-2)

Fixed submission:
n = int(input())

ans = 10**12
for i in range(1, int(n**0.5)+1):
    if n%i==0:
        ans = min(ans, i+n//i)
print(ans-2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

ans = []
for i in range(1, n+1):
    ans.append(str(a.index(i)+1))

print(' '.join(ans))

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

ans = [0]*n

for i in range(n):
    ans[a[i]-1] = str(i+1)

print(' '.join(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
c = [int(z) for z in input().split()]

total = 0
pre = 0
for i in range(N):
    total += b[a[i]-1]
    if a[i] == pre+1:
        total += c[a[i]]
    pre = a[i]
print(total)

Fixed submission:
N = int(input())
a = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
c = [int(z) for z in input().split()]

total = 0
pre = 999
for i in range(N):
    total += b[a[i]-1]
    if a[i] == pre+1:
        total += c[pre-1]
    pre = a[i]
print(total)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
c = [int(z) for z in input().split()]

total = 0
pre = 0
for i in a:
    total += b[i-1]
    if i-1 == pre:
        total += c[pre]
    pre = i
print(total)

Fixed submission:
N = int(input())
a = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
c = [int(z) for z in input().split()]

total = 0
pre = 999
for i in range(N):
    total += b[a[i]-1]
    if a[i] == pre+1:
        total += c[pre-1]
    pre = a[i]
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import itertools

n = int(input())
a = []
ans = 0
for i in range(n):
    s = list(input())
    s.sort()
    S = ''.join(s)
    a.append(S)

c = collections.Counter(a)
for i in c.values():
    ans += len(list(itertools.combinations(range(i), 2)))
print(ans)


Fixed submission:
n = int(input())
a = {}
ans = 0
for i in range(n):
    s = list(input())
    s.sort()
    S = ''.join(s)
    if S in a:
        a[S] += 1
    else:
        a[S] = 1

for j in a.values():
    ans += j * (j-1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import *
a, b, c, d = map(int, input().split())
a -= 1
B = b - (b//c + b//d)+b//(c*d//gcd(c, d))
A = a - (a//c + a//d)+a//(c*d//gcd(c, d))

print(B - A)


Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
a -= 1
B = b - (b//c + b//d)+b//(c*d//fractions.gcd(c, d))
A = a - (a//c + a//d)+a//(c*d//fractions.gcd(c, d))

print(B - A)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

MOD = 10**9+7

step = [0] * (n+1)
step[0] = 1
step[1] = 1

for i in range(n+1):
    if i == 0 or i == 1:
        if i in a:
            step[i] = 0
    else:
        step[i] = step[i-1] + step[i-2]
        if i in a:
            step[i] = 0
        step[i] %= MOD

print(step[-1])


Fixed submission:
n, m = map(int, input().split())
a = [0]*(n+1)
for j in range(m):
    pos = int(input())
    a[pos] = 1

MOD = 10**9+7

step = [0] * (n+1)
step[0] = 1
step[1] = 1

for i in range(n+1):
    if a[i] == 1:
        step[i] = 0
    else:
        if i != 0 and i != 1:
            step[i] = (step[i-1] + step[i-2]) % MOD

print(step[-1])
Buggy python submission (verdict: Runtime Error):
A, B, T = map(int, input().split())
print((T//A)*B)20

Fixed submission:
A, B, T = map(int, input().split())
print((T//A)*B)
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
C = 0
for i in range(min(A, B), 1, -1):
    if A%i == 0 and B%i == 0:
        C += 1
        if C == K:
            break
print(i)

Fixed submission:
A, B, K = map(int, input().split())
c = []

for i in range(1, 101):
    if A % i == 0 and B % i == 0:
        c.append(i)
print(c[-K])
Buggy python submission (verdict: Runtime Error):
X = int(input())

for i in range(X):
    for j in range(2, X):
        if X >= i**j:
            ans = i**j
        else:
            break
print(ans)

Fixed submission:
X = int(input())
ans = 1
for b in range(1,X):
    for p in range(2, X):
        if X < b**p:
            break
        if ans < b**p:
            ans = b**p
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, X = map(int, input().split())
if A > X:
    print('NO')
else:
    if X >= A + B:
    print('NO')
    else:
        print('YES')


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

Fixed submission:
print('Yes' if '9' in list(input()) else 'No')
Buggy python submission (verdict: Runtime Error):
import functools
import fractions
n = int(input())
t = [int(input()) for _ in range(n)]

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
    
ans = functools.reduce(lcm, t)
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline().rstrip
n = input()
print('Yes' if n == n[::-1] else 'No')

Buggy python submission (verdict: Runtime Error):
import functools
n = int(input())
t = [int(input()) for _ in range(n)]

def lcm(x, y):
    return (x * y) // functools.gcd(x, y)
    
ans = functools.reduce(lcm, t)
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline().rstrip
n = input()
print('Yes' if n == n[::-1] else 'No')
Buggy python submission (verdict: Runtime Error):
import math
import functools
n = int(input())
t = [int(input()) for _ in range(n)]

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
    
ans = functools.reduce(lcm, t)
print(str(ans))

Fixed submission:
import functools
import fractions
n = int(input())
t = [int(input()) for _ in range(n)]

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
    
ans = functools.reduce(lcm, t)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
import functools
n = int(input())
t = [int(input()) for _ in range(n)]

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
ans = functools.reduce(lcm, t)
print(ans)

Fixed submission:
import functools
import fractions
n = int(input())
t = [int(input()) for _ in range(n)]

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
    
ans = functools.reduce(lcm, t)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
ans = 10**10
suma = sum(a)
for i in range(1, n):
    x = sum(a[:i])
    s = abs(x-(suma-x))
    if s < ans:
        ans = s
print(ans)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

x = a[0]
y = sum(a[1:])
ans = abs(x-y)

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
ans = 10**10
for i in range(1, n):
    x = a[:i]
    y = a[i:]
    s = abs(sum(x)-sum(y))
    if s < ans:
        ans = s
print(ans)


Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

x = a[0]
y = sum(a[1:])
ans = abs(x-y)

for i in range(1, n-1):
    x += a[i]
    y -= a[i]
    ans = min(ans, abs(x-y))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
b = []

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

Fixed submission:
n = int(input())
a = input().split()
a_odd = a[1::2]
a_even = a[0::2]

if n % 2 == 0:
    a_odd.reverse()
    ans = a_odd + a_even
else:
    a_even.reverse()
    ans = a_even + a_odd
print(' '.join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
b = []
for i in a:
    b.append(i)
    b = b[::-1]
print(' '.join(map(str, b)))

Fixed submission:
n = int(input())
a = input().split()
a_odd = a[1::2]
a_even = a[0::2]

if n % 2 == 0:
    a_odd.reverse()
    ans = a_odd + a_even
else:
    a_even.reverse()
    ans = a_even + a_odd
print(' '.join(ans))
Buggy python submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())

N = math.factorial(n)
M = math.factorial(m)
INF = 10**9 + 7

if abs(n-m) > 1:
    print(0)
elif abs(n-m) == 1:
    print(N*M%INF)
else:
    print(2*N*M%INF)

Fixed submission:
x, a, b = map(int, input().split())
ans = 'dangerous'
if b-a <= 0:
    ans = 'delicious'
elif (b-a) <= x:
    ans = 'safe'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
INF = 10**9+7

ans = 1
for i in range(1, n+1):
    ans *= i
print(ans%INF)

Fixed submission:
n = int(input())
INF = 10**9+7

ans = 1
for i in range(1, n+1):
    ans = (i * ans)%INF 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                ans += 1
print(ans)

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

ans = 0
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s - x - y <= k:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
n = int(n[1:])

if n == 0:
    print(0)
else:
    print(1000-n)

Fixed submission:
n = int(input())
n = n % 1000
print(1000 - n if n != 0 else 0)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    l = []
    b = [0]*n
    for i in range(1, n+1):
        x = i-a[i-1]-0.5
        y = i+a[i-1]+0.5
        l.append([x, y])
    for j in range(1, n+1):
        for x, y in l:
            if x <= j <= y:
                b[j-1] += 1
    a = b
print(' '.join(map(str, b)))

Fixed submission:
s = input()
print(s[:3])
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

f = factorization(n)
ans = 0
for i, j in f:
    ans += int((-1+pow(1+8*j,0.5))/2)
print(ans)

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

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

Fixed submission:
a, b = map(int, input().split())
print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
x = 10**18
ans = 1
for i in range(n):
    if 0 in a:
        print(0)
        exit()
    elif ans > x:
        print(-1)
        exit()
    ans = ans * a[i]

print(-1 if ans > x else ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
x = 10**18
ans = 1

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

for i in range(n):
    ans = ans * a[i]
    if ans > x:
        print(-1)
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools

h, n = map(int, input().split())
a = list(map(int, input().split()))

s = [sum(c) for c in list(itertools.combinations(a, 2))]

f = False
for i in range(n):
    if s[i] >= h:
        f = True
        break

print('Yes' if f == True else 'No')

Fixed submission:
h, n = map(int, input().split())
a = list(map(int, input().split()))
print('Yes' if sum(a) >= h else 'No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(n):
    sp = input().split()
    l.append((sp[0], int(sp[1]), i+1))

a = sorted(l, key=lambda i: (i[0], -l[1]))

for i in range(n):
    print(a[i][2])

Fixed submission:
n = int(input())
l = []
for i in range(n):
    sp = input().split()
    l.append((sp[0], int(sp[1]), i+1))

a = sorted(l, key=lambda i: i[1], reverse=True)
a = sorted(a, key=lambda i: i[0])

for i in range(n):
    print(a[i][2])
Buggy python submission (verdict: Runtime Error):
s = input()
l = []
cnt = 0
for c in s:
    if c == 'A' or c =='C' or c == 'G' or c == 'T':
        cnt += 1
    else:
        l.append(cnt)
        cnt = 0

print(max(l))

Fixed submission:
s = input()

cnt = 0
li = []
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        cnt += 1
    else:
        li.append(cnt)
        cnt = 0

li.append(cnt)
print(max(li))

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

c = 0
cnt = []
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        c += 1
    else:
        cnt.append(c)
        c = 0

print(max(cnt))

Fixed submission:
s = input()

cnt = 0
li = []
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        cnt += 1
    else:
        li.append(cnt)
        cnt = 0

li.append(cnt)
print(max(li))
Buggy python submission (verdict: Runtime Error):
x, y = int(input().split())
print(x + (y//2))

Fixed submission:
x, y = map(int, input().split())
print(x + (y//2))
Buggy python submission (verdict: Runtime Error):
a, b = int(input())
for c in range(1, 4):
    if (a * b * c) % 2 == 1:
        print('Yes')
        exit()
print('No')

Fixed submission:
a, b = map(int, input().split())
for c in range(1, 4):
    if (a * b * c) % 2 == 1:
        print('Yes')
        exit()
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
a = [s[i+1:].count('E') + s[:i].count('W') for i in range(n)]
print(min(a))

Fixed submission:
n = int(input())
s = input()
left = 0
right = s[1:].count('E')
cnt = [left + right]

for i in range(1, n):
    if s[i-1] == 'W':
        left += 1
    if s[i] == 'E':
        right -= 1
    cnt.append(left + right)

print(min(cnt))
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [input().split() for i in range(H)]
F = [[0]*(W+2) for i in range(H+2)]
D = [(-1,0), (0,1), (0, -1), (1, 0)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            for d in D:
                F[i+1+d][j+1+d] == '#'

print('Yes' if F[1:H+1][1:W+1] == S else 'No')

Fixed submission:
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == '#' and s[i - 1][j] != '#' and s[i][j - 1] != '#' and s[i + 1][j] != '#' and s[i][j + 1] != '#':
            print('No')
            exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
ab = list(range(a, b+1))
for i in ab:
    if i <= k or i >= b - k:
        print(i)

Fixed submission:
a, b, k = map(int, input().split())
if b-a+1 < k*2:
    for i in range(a, b+1):
        print(i)
else:
    for j in range(a, a+k):
        print(j)
    for k in range(b-k+1 , b+1):
        print(k)

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
ab = list(range(a, b+1))
ans = sorted(set(ab[:k]+ab[-k:]))
for i in ans:
  print(i)

Fixed submission:
a, b, k = map(int, input().split())
if b-a+1 < k*2:
    for i in range(a, b+1):
        print(i)
else:
    for j in range(a, a+k):
        print(j)
    for k in range(b-k+1 , b+1):
        print(k)
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())
y //= 1000

for a in range(n + 1):
    for b in range(n + 1):
        c = n - a - b
        if 10*a + 5*b + c == y:
            print(a, b, c)
            exit()

print(-1, -1, -1)

Fixed submission:
s = input()
print(s.replace('2017/', '2018/'))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = 0
for i in range(1, n+1):
    if i % (i**0.5) == 0:
        if i > a:
            a = i
print(a)

Fixed submission:
n = int(input())
for i in reversed(range(1, n+1)):
    if i % (i**0.5) == 0:
        print(i)
        exit()
Buggy python submission (verdict: Runtime Error):
# numpyを使用した場合
import numpy as np

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
f = np.zeros((h+2, w+1), dtype='int64')
d = np.ones((3, 3), dtype='int64')

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            f[i:i+3, j:j+3] += d 

for i in range(h):
    ans = ''
    for j in range(w):
        if s[i][j] == '#':
            ans += '#'
        else:
            ans += str(f[i+1, j+1])
    print(ans)

Fixed submission:
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
n = [[0]*(W+2) for i in range(H+2)]
dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1)]

for h in range(H):
  for w in range(W):
    if s[h][w] == '#':
      for i in dxy:
        n[h + 1 + i[0]][w + 1 + i[1]] += 1

for i in range(H):
  for j in range(W):
    if s[i][j] == '#':
      n[i + 1][j + 1] = '#'
    else:
      n[i + 1][j + 1] = str(n[i + 1][j + 1])

for a in n[1:H+1]:
    print(''.join(a[1:W+1]))
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
a = list(map(int, input().split()))
s =set(a)
ans = []

for x in s:
    x -= 1
    for _ in range(2):
        l = []
        x += 1
        for i in a:
            if i == x - 1:
                l.append(i+1)
            elif i == x:
                l.append(i)
            elif i == x + 1:
                l.append(i-1)
                
        c = collections.Counter(l).most_common(1)
        ans.append(c[0][1])

print(max(ans))

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
sa =set(a)
ca = Counter(a)
ans = 0

for x in sa:
    # カウンタオブジェクトは存在しない要素に０を返す
    tmp = ca[x-1] + ca[x] + ca[x+1]
    if ans < tmp:
        ans = tmp

print(ans)
Buggy python submission (verdict: Runtime Error):
x, a, b = map(int, input().split())
if a <= b:
    print('delicious')
else:
    if b - a <= x:
    print('safe')
    else:
        print('dangerous')

Fixed submission:
x, a, b = map(int, input().split())
if b <= a:
    print('delicious')
elif b - a <= x:
    print('safe')
else:
    print('dangerous')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
x = len(a) // n
l = []
for i in range(n):
    for j in range(x):
        ll.append(a[i+j::x-1])
      
ans = 0
for i in range(n):
    ans += l[i][1]
print(ans)

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0

for i in range(n):
    ans += a[i * 2 + 1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = 1
for i in range(1, n+1):
    p *= i

print(p % (10**9+7))

Fixed submission:
n = int(input())
p = 1

for i in range(1, n+1):
    p = p * i % 1000000007

print(p)