Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [list(input()) i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]
cnt = 0

for h in range(H):
  for w in range(W):
    # Check only black cell
    if s[h][w] == '.':
      continue
    for k in range(4):
      nh = h + dh[k]
      nw = w + dw[k]
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # ok
      if s[nh][nw] == '#':
        break
    # failed
    else:
      cnt += 1

if cnt == 0:
  print('Yes')
else:
  print('No')
      
    

Fixed submission:
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]
cnt = 0

for h in range(H):
  for w in range(W):
    # Check only black cell
    if s[h][w] == '.':
      continue
    for k in range(4):
      nh = h + dh[k]
      nw = w + dw[k]
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # ok
      if s[nh][nw] == '#':
        break
    # failed
    else:
      cnt += 1

if cnt == 0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [list(input()) i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]

for h in range(H):
  for w in range(W):
    # Don't check white cell
    if s[h][w] == '.':
      continue
    # check neighbor cell
    for k in range(4):
      nh = h + dh[k]
      nw = w + dw[k]
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # neighbor black is found => ok
      if s[nh][nw] == '#':
        break
    # There is independ black => failed
    else:
      print('No')
      break
  # ok
  else:
    continue
  # failed
  break
# ok
else:
  print('Yes')
    

Fixed submission:
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]
cnt = 0

for h in range(H):
  for w in range(W):
    # Check only black cell
    if s[h][w] == '.':
      continue
    for k in range(4):
      nh = h + dh[k]
      nw = w + dw[k]
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # ok
      if s[nh][nw] == '#':
        break
    # failed
    else:
      cnt += 1

if cnt == 0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [list(input()) i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]

for h in range(H):
  for w in range(W):
    # Don't check white cell
    if s[h][w] == '.':
      continue
    # check neighbor cell
    for k in range(4):
      nh = h + dh
      nw = w + dw
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # neighbor black is found => ok
      if s[nh][nw] == '#':
        break
    # There is independ black => failed
    else:
      print('No')
      break
  # ok
  else:
    continue
  # failed
  break
# ok
else:
  print('Yes')
    

Fixed submission:
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]
cnt = 0

for h in range(H):
  for w in range(W):
    # Check only black cell
    if s[h][w] == '.':
      continue
    for k in range(4):
      nh = h + dh[k]
      nw = w + dw[k]
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # ok
      if s[nh][nw] == '#':
        break
    # failed
    else:
      cnt += 1

if cnt == 0:
  print('Yes')
else:
  print('No')