Buggy python submission (verdict: Runtime Error):
H,W= map(int,input().split())
mine = [list(input()) for i in range(H)]

def count(ch):
  return 1 if ch == '#' else 0

for i in range(H):
  for j in range(W):
    num = 0
    if mine[i][j] == '#':
      continue
    else:
      for k in range(-1,2):
        for l in range(-1,2):
          num += (1 if mine[i+k][j+l]=='#' else 0) 
      mine[i][j] = num
      
for i in range(1,H+1):
  for j in range(1,W+1):
    print(mine[i][j],end='')
  print()



Fixed submission:
H,W= map(int,input().split())
emp_H= [['.']*(W+2)]
mine = [['.']+list(input())+ ['.'] for i in range(H)]
mine = emp_H + mine + emp_H

def count(ch):
  return 1 if ch == '#' else 0

for i in range(1,H+1):
  for j in range(1,W+1):
    if mine[i][j] == '#':
      continue
    else:
      mine[i][j] = count(mine[i-1][j-1])+count(mine[i][j-1])+count(mine[i+1][j-1])+count(mine[i-1][j])+count(mine[i][j])+count(mine[i+1][j])+count(mine[i-1][j+1])+count(mine[i][j+1])+count(mine[i+1][j+1])
for i in range(1,H+1):
  for j in range(1,W+1):
    print(mine[i][j],end='')
  print()

Buggy python submission (verdict: Runtime Error):
H,W= map(int,input().split())
mine = [list(input()) for i in range(H)]

def count(ch):
  return 1 if ch == '#' else 0

for i in range(H):
  for j in range(W):
    num = 0
    if mine[i][j] == '#':
      continue
    else:
      for k in range(-1,2):
        for l in range(-1,2):
          num += (1 if mine[i+k][j+l]=='#' else 0) 
      
for i in range(1,H+1):
  for j in range(1,W+1):
    print(mine[i][j],end='')
  print()



Fixed submission:
H,W= map(int,input().split())
emp_H= [['.']*(W+2)]
mine = [['.']+list(input())+ ['.'] for i in range(H)]
mine = emp_H + mine + emp_H

def count(ch):
  return 1 if ch == '#' else 0

for i in range(1,H+1):
  for j in range(1,W+1):
    if mine[i][j] == '#':
      continue
    else:
      mine[i][j] = count(mine[i-1][j-1])+count(mine[i][j-1])+count(mine[i+1][j-1])+count(mine[i-1][j])+count(mine[i][j])+count(mine[i+1][j])+count(mine[i-1][j+1])+count(mine[i][j+1])+count(mine[i+1][j+1])
for i in range(1,H+1):
  for j in range(1,W+1):
    print(mine[i][j],end='')
  print()

Buggy python submission (verdict: Runtime Error):
H,W= map(int,input().split())
mine = [list(input()) for i in range(H)]

def count(ch):
  return 1 if ch == '#' else 0

for i in range(H):
  for j in range(W):
    if mine[i][j] == '#':
      continue
    else:
      num = 0
      if (i == 0):
        if(j == 0):
          mine[0][0] = count(mine[0][1]) + count(mine[1][1])+count(mine[1][0])
        elif(j == W-1):
          mine[0][W-1] = count(mine[0][W-2]) + count(mine[1][W-2])+count(mine[1][W-1])
        else:
          mine[0][j] = count(mine[0][j-1]) + count(mine[0][j+1])+count(mine[1][j-1])+count(mine[1][j])+count(mine[1][j+1])
      elif(i == H-1):
        if(j == 0):
          mine[H-1][0] = count(mine[H-1][1]) + count(mine[H-2][1])+count(mine[H-2][0])
        elif(j == W-1):
          mine[H-1][W-1] = count(mine[H-1][W-2]) + count(mine[H-2][W-2])+count(mine[H-2][W-1])
        else:
          mine[H-1][j] = count(mine[H-1][j-1]) + count(mine[H-1][j+1])+count(mine[H-2][j-1])+count(mine[H-2][j])+count(mine[H-2][j+1])
      elif(j == 0):
        mine[i][0] = count(mine[i-1][0]) + count(mine[i+1][0])+count(mine[i-1][1])+count(mine[i][1])+count(mine[i+1][1])
      elif(j == W-1):
        mine[i][W-1] = count(mine[i-1][W-1]) + count(mine[i+1][W-1])+count(mine[i-1][W-2])+count(mine[i][W-2])+count(mine[i+1][W-2])
      else:
        mine[i][j] = count(mine[i-1][j-1])+count(mine[i][j-1])+count(mine[i+1][j-1])+count(mine[i-1][j])+count(mine[i][j])+count(mine[i+1][j])+count(mine[i-1][j+1])+count(mine[i][j+1])+count(mine[i+1][j+1])
for i in range(H):
  for j in range(W):
    print(mine[i][j],end='')
  print()



Fixed submission:
H,W= map(int,input().split())
emp_H= [['.']*(W+2)]
mine = [['.']+list(input())+ ['.'] for i in range(H)]
mine = emp_H + mine + emp_H

def count(ch):
  return 1 if ch == '#' else 0

for i in range(1,H+1):
  for j in range(1,W+1):
    if mine[i][j] == '#':
      continue
    else:
      mine[i][j] = count(mine[i-1][j-1])+count(mine[i][j-1])+count(mine[i+1][j-1])+count(mine[i-1][j])+count(mine[i][j])+count(mine[i+1][j])+count(mine[i-1][j+1])+count(mine[i][j+1])+count(mine[i+1][j+1])
for i in range(1,H+1):
  for j in range(1,W+1):
    print(mine[i][j],end='')
  print()