Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
rows, columns = map(int, input().split(' '))

result = 0
for row in range(rows):
    for column in range(columns):
        target_time = 0

        inc_column = column + 1 < columns
        dec_column = 0 <= column - 1
        inc_row = row + 1 < rows
        dec_row = 0 <= row - 1

        if inc_column:
            if inc_row:
                target_time += 1
            if dec_row:
                target_time += 1
        if dec_column:
            if inc_row:
                target_time += 1
            if dec_row:
                target_time += 1

        if dec_column:
            target_time += 1
        if inc_column:
            target_time += 1
        if inc_row:
            target_time += 1
        if dec_row:
            target_time += 1

        if target_time % 2 == 0:
            result += 1

print(result)

Fixed submission:
rows, columns = map(int, input().split(' '))

if rows == 1 and columns == 1:
    print(1)
    exit()

if rows == 1:
    print(columns - 2)
    exit()

if columns == 1:
    print(rows - 2)
    exit()

print(rows * columns - 2 * rows - 2 * columns + 4)

Buggy python submission (verdict: Time Limit Exceeded):
rows, columns = map(int, input().split(' '))

result = 0
for row in range(rows):
    for column in range(columns):
        target_time = 0
        if column + 1 < columns and row + 1 < rows:
            target_time += 1
        if column + 1 < columns and 0 <= row - 1:
            target_time += 1
        if 0 <= column - 1 and row + 1 < rows:
            target_time += 1
        if 0 <= column - 1 and 0 <= row - 1:
            target_time += 1

        if 0 <= column - 1:
            target_time += 1
        if column + 1 < columns:
            target_time += 1
        if row + 1 < rows:
            target_time += 1
        if 0 <= row - 1:
            target_time += 1

        if target_time % 2 == 0:
            result += 1

print(result)

Fixed submission:
rows, columns = map(int, input().split(' '))

if rows == 1 and columns == 1:
    print(1)
    exit()

if rows == 1:
    print(columns - 2)
    exit()

if columns == 1:
    print(rows - 2)
    exit()

print(rows * columns - 2 * rows - 2 * columns + 4)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A1 = [[int(i) for i in input().split(" ")], [int(i) for i in input().split(" ")]]

sum_point = A1[0][0] + A1[1][N - 1]
for i in range(N):
    if sum(A1[0][i + 1:]) <= sum(A1[1][i: N - 1]):
        sum_point += sum(A1[1][i: N - 1])
        break
    else:
        sum_point += A1[0][i + 1]

print(sum_point)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())

print((x - a) % b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

CSFs = [list(map(int, input().split(' '))) for i in range(N - 1)]

for i in range(0, N - 1):
    initial_move_time = CSFs[i][0] + CSFs[i][1]

    for j in range(i + 1, N - 1):
        if initial_move_time <= CSFs[j][1]:
            initial_move_time = CSFs[j][1]

        elif initial_move_time % CSFs[j][2] == 0:
            initial_move_time = initial_move_time

        else:
            k = 1
            while True:
                tmp = CSFs[j][1] + CSFs[j][2] * k
                if initial_move_time <= tmp:
                    initial_move_time = tmp
                    break
                k += 1
        initial_move_time += CSFs[j][0]

    print(initial_move_time)
    
print(0)

Fixed submission:
N = int(input())

CSFs = [list(map(int, input().split(' '))) for i in range(N - 1)]

for i in range(0, N - 1):
    initial_move_time = CSFs[i][0] + CSFs[i][1]
    for j in range(i + 1, N - 1):
        if initial_move_time <= CSFs[j][1]:
            initial_move_time = CSFs[j][1]
        elif initial_move_time % CSFs[j][2] == 0:
            initial_move_time = initial_move_time
        else:
            initial_move_time = initial_move_time + CSFs[j][2] - initial_move_time % CSFs[j][2]
        initial_move_time += CSFs[j][0]
    print(initial_move_time)
print(0)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
count = 0
for i in range(16):
  if count == 0:
    A -= 1
  else:
    B -= 1
if A <= 0 and B <= 0:
	print(Yay!)
else:
  print(:()

Fixed submission:
A, B = map(int, input().split())
count = 0
for i in range(16):
  if count == 0:
    A -= 1
    count += 1
  else:
    count -= 1
    B -= 1
if A <= 0 and B <= 0:
	print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max([A*B, A+B, A-B])

Fixed submission:
A, B = map(int, input().split())
print(max([A*B, A+B, A-B]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
result = 0
for b in range(n):
  for p in range(n):
    if b**p => n and result < b**p:
      result = b**p
      break

print(int(result))

Fixed submission:
n = int(input())
result = pow(int(n**(1/2)), 2)
for b in range(1, n):
  for p in range(2, n):
    if b**p > n:
        break
    elif b**p > result:
        result = b**p

print(int(result))
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
  numbers = list(map(int, input().split()))
  k = int(input())
  sum = 0
  for i in range(3):
    if i == numbers.index(max(numbers)):
      sum += max(numbers) * pow(2, k)
    else:
      sum += numbers[i]
  print(sum)

Fixed submission:
a, b = map(int,input().split())
if a <= b:
  print(a)
elif a > b:
  print(a-1)

Buggy python submission (verdict: Runtime Error):
numbers = list(map(int, input().split()))
k = int(input())
sum = 0
for i in range(3):
  if i == numbers.index(max(numbers)):
    sum += max(numbers) * pow(2, k)
  else:
    sum += numbers[i]
print(sum)

Fixed submission:
a, b = map(int,input().split())
if a <= b:
  print(a)
elif a > b:
  print(a-1)

Buggy python submission (verdict: Runtime Error):
numbers = list(map(int, input().split()))
k = int(input())
sum = 0
for i in range(3):
  if i == numbers.index(max(numbers)):
    sum += max(numbers) * (2 ** k) 
  else:
    sum += numbers[i]
print(sum)

Fixed submission:
a, b = map(int,input().split())
if a <= b:
  print(a)
elif a > b:
  print(a-1)

Buggy python submission (verdict: Runtime Error):
numbers = list(map(int, input().split()))
k = int(input())
sum = 0
for i in range(3):
  if i == numbers.index(max(numbers)):
    sum += max(numbers) * (2 ^ k) 
  else:
    sum += numbers[i]
print(sum)

Fixed submission:
a, b = map(int,input().split())
if a <= b:
  print(a)
elif a > b:
  print(a-1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
As = list(map(int, input().split()))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = [0]*n
for idx, b in enumerate(Bs):
    cnt[idx] = len(Cs) - bisect.bisect_right(Cs, b)

print(sum([sum(cnt[bisect.bisect_right(Bs, a):]) for a in As]))


Fixed submission:
import bisect
n = int(input())
As = list(map(int, input().split()))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = [0]*(n+1)
v = 0
for idx, b in enumerate(Bs[::-1]):
    v += len(Cs) - bisect.bisect_right(Cs, b)
    cnt[n-1-idx] = v

print(sum([cnt[bisect.bisect_right(Bs, a)] for a in As]))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
As = list(map(int, input().split()))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = 0
for a in As:
    cntB = bisect.bisect_right(Bs, a)
    for b in Bs[cntB:]:
        cnt += len(Cs) - bisect.bisect_right(Cs, b)
print(cnt)


Fixed submission:
import bisect
n = int(input())
As = list(map(int, input().split()))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = [0]*(n+1)
v = 0
for idx, b in enumerate(Bs[::-1]):
    v += len(Cs) - bisect.bisect_right(Cs, b)
    cnt[n-1-idx] = v

print(sum([cnt[bisect.bisect_right(Bs, a)] for a in As]))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = 0
for a in As:
    cntB = bisect.bisect_right(Bs, a)
    for b in Bs[cntB:]:
        cnt += len(Cs) - bisect.bisect_right(Cs, b)
print(cnt)


Fixed submission:
import bisect
n = int(input())
As = list(map(int, input().split()))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = [0]*(n+1)
v = 0
for idx, b in enumerate(Bs[::-1]):
    v += len(Cs) - bisect.bisect_right(Cs, b)
    cnt[n-1-idx] = v

print(sum([cnt[bisect.bisect_right(Bs, a)] for a in As]))
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())


count = 0
for i in range(K+1):
  for j in range(K+1):
    left = S-(i+j)
    low = 0
    high = K

    while low <= high:
      n = (low + high) // 2
      if left == n:
        count += 1
        break
      elif left < n:
        high = n - 1
      elif left > n:
        low = n + 1

print(count)

Fixed submission:
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-(i+j) <=k:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())


count = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k == S:
                count += 1

print(count)

Fixed submission:
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-(i+j) <=k:
            count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
K,S = map(int,input().split())


count = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k = S:
                count += 1
                
print(count)

Fixed submission:
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-(i+j) <=k:
            count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
K,S = map(int,input().split())

count = 0
for i in range(K+1):
  for j in range(K+1):
    if 0 <= S-(i+j) <= K
      count += 1
print(count)

Fixed submission:
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-(i+j) <=k:
            count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
K,S = map(int,input().split())

count = 0
for i in range(K):
  for j in range(K):
    for l in range(K):
      if i+j+l = S:
        count += 1

print(count)

Fixed submission:
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-(i+j) <=k:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i+j+l == s:
                count += 1
print(count)


Fixed submission:
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-(i+j) <=k:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
a,b,h=[int(i) for i in input()]
print((a+b)*h/2)

Fixed submission:
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
D,G=map(int,input().split(" "))
Problem=[]
Comp={}
n=0
for i in range(D):
  p,c=map(int,input().split(" "))
  n+=p
  [Problem.append(100*(i+1)) for _ in range(p)]
  Comp[i+1]=[p,c]
Min=1000000000
for i in range(2**(n)):
  score=0
  Clear=[]
  for j in range(n):
    if ((i>>j)&1):
      score+=Problem[j]
      Clear.append("○")
    else:
      Clear.append("×")
  No=1
  Count=0
  mark_count=0
  for bin in Clear:
    if bin=="○":
      mark_count+=1
    Count+=1
    if Count==Comp[No][0]:
      if mark_count==Comp[No][0]:
      	score+=Comp[No][1]
      No+=1
      Count=0
      mark_count=0
  Mark_all=Clear.count("○")
  if score>=G:
    Mark_all=Clear.count("○")
    Min=min([Min,Mark_all])
print(Min)

Fixed submission:
#coding:utf-8
D,G=map(int,input().split(" "))
Comp={}
for i in range(D):
  p,c=map(int,input().split(" "))
  Comp[i]=[p,c]
Min=1000000000
for i in range(2**(D)):
  answer=0
  score=0
  Clear=[]
  for j in range(D):
    if ((i>>j)&1):
      score+=(j+1)*100*Comp[j][0]
      score+=Comp[j][1]
      answer+=Comp[j][0]
      Clear.append(j+1)
  No=D
  Count=0
  while score<G and No>=1:
    if No in Clear or Count==Comp[No-1][0]:
      Count=0
      No-=1
    score+=100*No
    Count+=1
    answer+=1
  if score>=G:
    Min=min(Min,answer)
print(Min)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-

N=int(input())
S=input()
S=list(S)
number=0
ans=[]
for i in range(N):
  Left=S[:i]
  Right=S[i+1:]
  number+=Left.count('W')
  number+=Right.count('E')
  ans.append(number) 
  number=0
print(min(ans))

Fixed submission:
n = int(input())
s = input()
e = s.count("E")
w = s.count("W")
cnt1 = 0
cnt2 = 0
ans = 10e9
for i in s:
    if i=="E":
        cnt1 += 1
        ans = min(ans,cnt2+e-cnt1)
    else:
        ans = min(ans,cnt2+e-cnt1)
        cnt2 += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
raw_input = input().split()[2:]
W = len(raw_input[0])
H = len(raw_input)
added_input = [row + '.' for row in raw_input] + ['.' * len(raw_input[0])]
for y in range(H):
    for x in range(W):
        if added_input[y][x] == '#' and added_input[y+1][x] \
        == added_input[y-1][x] == added_input[y][x+1] == added_input[y][x-1] == '.':
            print('NO')
            break
else:
    print('YES')

Fixed submission:
H,W=map(int, input().split())
S=["."+input()+"." for _ in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
ans="Yes"
for i in range(H):
  for j in range(W):
    if S[i][j]=="#" and S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
      ans="No"
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
H,W=map(int,input().split())
nx=[1,0,-1,0]
ny=[0,1,0,-1]

field=[]
for i in range(H):
  field.append(list(input()))

for n in range(W):
  for m in range(H):
    if field[n][m]=='.':
      continue
    
    hope=0
    for j in range(4):
      x=n+nx[j]
      y=m+ny[j]
      
      if x<0 or W<=x or y<0 or H<=y:
        continue

      if field[x][y]=='#':
        hope=1
      
    if hope==0:
      print('No')
      exit()

print('Yes')

Fixed submission:
H,W=map(int, input().split())
S=["."+input()+"." for _ in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
ans="Yes"
for i in range(H):
  for j in range(W):
    if S[i][j]=="#" and S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
      ans="No"
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
H,W=map(int,input().split())
nx=[1,0,-1,0,1,1,-1,-1]
ny=[0,1,0,-1,1,-1,1,-1]

field=[]
for i in range(H):
  field.append(list(input()))

for n in range(W):
  for m in range(H):
    if field[n][m]=='.':
      continue
    
    hope=0
    for j in range(8):
      x=n+nx[j]
      y=m+ny[j]
      
      if x<0 or W<=x or y<0 or H<=y:
        continue

      if field[x][y]=='#':
        hope=1
      
    if hope==0:
      print('No')
      exit()

print('Yes')

Fixed submission:
H,W=map(int, input().split())
S=["."+input()+"." for _ in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
ans="Yes"
for i in range(H):
  for j in range(W):
    if S[i][j]=="#" and S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
      ans="No"
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
H,W=map(int,input().split())
nx=[1,0,-1,0,1,1,-1,-1]
ny=[0,1,0,-1,1,-1,1,-1]

field=[]
for i in range(H):
  field.append(list(split()))

for n in range(W):
  for m in range(H):
    if field[n][m]=='.':
      continue
      
    for j in range(8):
      x=n+nx[j]
      y=m+ny[j]

      if field[x][y]=='.':
        print('No')
        exit()
      else:
        pass
print('Yes')
      
  
  

Fixed submission:
H,W=map(int, input().split())
S=["."+input()+"." for _ in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
ans="Yes"
for i in range(H):
  for j in range(W):
    if S[i][j]=="#" and S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
      ans="No"
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import sys
N=int(input())
List_1=[map(int,input()split())]
List_2=[map(int,input()split())]

answer=[]
for i in range(N):
  score+=sum(List_1[:i])
  score+=sum(List_2[i:])
  answer.append(score)
  score=0

print(max(answer))

Fixed submission:
# -*- coding:utf-8 -*-
import sys
N=int(input())
List_1=list(map(int,input().split()))
List_2=list(map(int,input().split()))

answer=[]
score=0
for i in range(N):
  score+=sum(List_1[:i+1])
  score+=sum(List_2[i:])
  answer.append(score)
  score=0

print(max(answer))
Buggy python submission (verdict: Runtime Error):
#coding: utf-8
N,Y=map(int,input().split(" "))
for x in range(N+1):
  for y in range(N+1-x):
	z=N-x-y
    if 10000*x+5000*y+1000*z==Y:
      print(str(x)," ",str(y)," ",str(z))
      exit()
print("-1 -1 -1")

Fixed submission:
#coding: utf-8
N,Y=map(int,input().split(" "))
for x in range(N+1):
  for y in range(N+1-x):
    z=N-x-y
    if 10000*x+5000*y+1000*z==Y:
      print(str(x)," ",str(y)," ",str(z))
      exit()
print("-1 -1 -1")
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
S=input()
sign=[+-]
for i in range(2):
  for j in range(2):
    for n in range(2):
      if eval(S[0]+sign[i]+S[1]+sign[j]+S[2]+sign[n]+S[3])==7:
        print(str(S[0]+sign[i]+S[1]+sign[j]+S[2]+sign[n]+S[3])+'=7')
        exit()

Fixed submission:
# -*- coding:utf-8 -*-
X=list(input())
A,B,C,D=map(int,X)
if A+B+C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'+'+B+'+'+C+'+'+D+'=7')
  exit()
elif A+B+C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'+'+B+'+'+C+'-'+D+'=7')
  exit()
elif A+B-C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'+'+B+'-'+C+'+'+D+'=7')
  exit()
elif A-B+C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'-'+B+'+'+C+'+'+D+'=7')
  exit()
elif A-B-C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'-'+B+'-'+C+'+'+D+'=7')
  exit()
elif A+B-C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'+'+B+'-'+C+'-'+D+'=7')
  exit()
elif A-B+C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'-'+B+'+'+C+'-'+D+'=7')
  exit()
elif A-B-C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'-'+B+'-'+C+'-'+D+'=7')
  exit()
else:
  print('None')

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
X=list(input())
A,B,C,D=map(int,X)
if A+B+C+D==7:
  print(A+'+'+B+'+'+C+'+'+D+'=7')
  exit()
if A+B+C-D==7:
  print(A+'+'+B+'+'+C+'-'+D+'=7')
  exit()
if A+B-C+D==7:
  print(A+'+'+B+'-'+C+'+'+D+'=7')
  exit()
if A-B+C+D==7:
  print(A+'-'+B+'+'+C+'+'+D+'=7')
  exit()
if A-B-C+D==7:
  print(A+'-'+B+'-'+C+'+'+D+'=7')
  exit()
if A+B-C-D==7:
  print(A+'+'+B+'-'+C+'-'+D+'=7')
  exit()
if A-B+C-D==7:
  print(A+'-'+B+'+'+C+'-'+D+'=7')
  exit()
if A-B-C-D==7:
  print(A+'-'+B+'-'+C+'-'+D+'=7')
  exit()

  

Fixed submission:
# -*- coding:utf-8 -*-
X=list(input())
A,B,C,D=map(int,X)
if A+B+C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'+'+B+'+'+C+'+'+D+'=7')
  exit()
elif A+B+C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'+'+B+'+'+C+'-'+D+'=7')
  exit()
elif A+B-C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'+'+B+'-'+C+'+'+D+'=7')
  exit()
elif A-B+C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'-'+B+'+'+C+'+'+D+'=7')
  exit()
elif A-B-C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'-'+B+'-'+C+'+'+D+'=7')
  exit()
elif A+B-C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'+'+B+'-'+C+'-'+D+'=7')
  exit()
elif A-B+C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'-'+B+'+'+C+'-'+D+'=7')
  exit()
elif A-B-C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+'-'+B+'-'+C+'-'+D+'=7')
  exit()
else:
  print('None')
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
H,W=map(int,input().split())
boxes=list()
boxes[0]=[0]*W
boxes[H+1]=[0]*W
for i in range(H):
  boxes[i+1]=list()
  boxes[i+1][0]=0
  bowes[i+1][W+1]=0
  x=input()
  for j in range(W):
    if x[j]=='.':
      boxes[i+1][j+1]=0
    elif x[j]=='#':
      boxes[i+1][j+1]=1
answer=list()
for n in range(H):
  answer[n]=list()
  for k in range(W):
    count=0
    if boxes[n][k]==1:
      count+=1
    if boxes[n][k+1]==1:
      count+=1
    if boxes[n][k+2]==1:
      count+=1
    if boxes[n+1][k]==1:
      count+=1
    if boxes[n+1][k+2]==1:
      count+=1
    if boxes[n+2][k]==1:
      count+=1
    if boxes[n+2][k+1]==1:
      count+=1
    if boxes[n+2][k+2]==1:
      count+=1
    if count==0:
      answer[n][k]='#'
	else:
      answer[n][k]=str(count)
 for v in range(H):
  answe=''.join(answer[v])
  print(answe)

Fixed submission:
# -*- coding:utf-8 -*-
H,W=map(int,input().split())
boxes=list()
pad=[0]*(W+2)
boxes.insert(0,pad)
for i in range(H):
  x=input()
  box=list()
  box.append(0)
  for j in range(W):
    if x[j]=='.':
      box.append(0)
    elif x[j]=='#':
      box.append(1)
  box.append(0) 
  boxes.insert(i+1,box)
boxes.insert(H+1,pad)
answers=list()
padd=[0]*W
for n in range(H):
  answer=list()
  for k in range(W):
    count=0
    if boxes[n][k]==1:
      count+=1
    if boxes[n][k+1]==1:
      count+=1
    if boxes[n][k+2]==1:
      count+=1
    if boxes[n+1][k]==1:
      count+=1
    if boxes[n+1][k+2]==1:
      count+=1
    if boxes[n+2][k]==1:
      count+=1
    if boxes[n+2][k+1]==1:
      count+=1
    if boxes[n+2][k+2]==1:
      count+=1
    if boxes[n+1][k+1]==1:
      count='#'
    else:
      count=str(count)
    answer.insert(k,count)
  answers.insert(n,answer)
for v in range(H):
  answe=''.join(answers[v])
  print(answe)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import sys

a=[int(i)-1 for i in sys.stdin]
N=l[0]+1
a=a[1:]

done=[False]*N

ans=0
i=0

while True:
  if done[i]==False:
    done[i]=True
    ans+=1
    if a[i]==1:
      break
    i=a[i]

  
  else:
    ans=-1
    break
    
print(ans)
    

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

a=[int(i)-1 for i in sys.stdin]
N=a[0]+1
a=a[1:]

done=[False]*N

ans=0
i=0

while True:
  if done[i]==False:
    done[i]=True
    ans+=1
    if a[i]==1:
      break
    i=a[i]

  
  else:
    ans=-1
    break
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
N=int(input())
button=[]
for i in range(N):
  button.append(int(input()))

number=0
count=0
footprint=[0]
while number!=1:
  number=button[number]-1
  count+=1
  if number in footprint:
    print(-1)
    exit()
  footprint.append(number)
print(count)

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

a=[int(i)-1 for i in sys.stdin]
N=a[0]+1
a=a[1:]

done=[False]*N

ans=0
i=0

while True:
  if done[i]==False:
    done[i]=True
    ans+=1
    if a[i]==1:
      break
    i=a[i]

  
  else:
    ans=-1
    break
    
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
N=int(input())
button=[]
for i in range(N):
  button.append(int(input()))

number=0
count=0
footprint=[0]
while number!=1:
  number=button[number]-1
  count+=1
    if number in footprint:
      print(-1)
      exit()
  footprint.append(number)
print(count)

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

a=[int(i)-1 for i in sys.stdin]
N=a[0]+1
a=a[1:]

done=[False]*N

ans=0
i=0

while True:
  if done[i]==False:
    done[i]=True
    ans+=1
    if a[i]==1:
      break
    i=a[i]

  
  else:
    ans=-1
    break
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#-*- coding:utf-8 -*-

N=int(input())
power=1
for i in range(N):
  power*=(i+1)

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

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

N=int(input())
power=1
for i in range(N):
  power*=(i+1)
  power%=(10**9+7)
  
print(power)