Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
cells = []
cells.append(['.']*(w+2))
for i in range(h):
    l = ['.']
    s = input().split()
    l+=list(s[0])
    l+=['.']
    cells.append(l)
cells.append(['.']*(w+2))

exist_sharp = False
for cell in cells:
    if '#' in cell:
        exist_sharp = True
if not exist_sharp:
    print("No")
    exit()
 
ans = True
for i in range(1,len(cells)-1):
    for j in range(1,len(cells)-1):
        if cells[i][j] == '#':
            if cells[i-1][j] != '#' and cells[i+1][j] != '#' and cells[i][j-1] != '#' and cells[i][j+1] != '#':
                ans = False

if ans: print("Yes")
else: print("No")

Fixed submission:
h, w = map(int, input().split())
cells = []
for i in range(h):
    s = input().split()
    cells.append(s[0])
ans = True
for i in range(1,h-1):
    for j in range(1,w-1):
        if cells[i][j] == '#':
            if cells[i-1][j] != '#' and cells[i+1][j] != '#' and cells[i][j-1] != '#' and cells[i][j+1] != '#':
                ans = False
                break
 
if ans: print("Yes")
else: print("No")

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
cells = []
cells.append(['.']*(w+2))
for i in range(h):
    l = ['.']
    s = input().split()
    l+=list(s[0])
    l+=['.']
    cells.append(l)
cells.append(['.']*(w+2))

ans = True
for i in range(1,len(cells)-1):
    for j in range(1,len(cells)-1):
        if cells[i][j] == '#':
            if cells[i-1][j] != '#' and cells[i+1][j] != '#' and cells[i][j-1] != '#' and cells[i][j+1] != '#':
                ans = False

if ans: print("Yes")
else: print("No")

Fixed submission:
h, w = map(int, input().split())
cells = []
for i in range(h):
    s = input().split()
    cells.append(s[0])
ans = True
for i in range(1,h-1):
    for j in range(1,w-1):
        if cells[i][j] == '#':
            if cells[i-1][j] != '#' and cells[i+1][j] != '#' and cells[i][j-1] != '#' and cells[i][j+1] != '#':
                ans = False
                break
 
if ans: print("Yes")
else: print("No")

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
cells = []
cells.append(['.']*(w+2))
for i in range(h):
    l = ['.']
    s = input().split()
    l+=list(s[0])
    l+=['.']
    cells.append(l)
cells.append(['.']*(w+2))

for i in range(1,len(cells)-1):
    for j in range(1,len(cells)-1):
        if cells[i][j] == '#':
            if cells[i-1][j] == '#':
                pass
            elif cells[i+1][j] == '#':
                pass
            elif cells[i][j-1] == '#':
                pass
            elif cells[i][j+1] == '#':
                pass
            else:
                print("No")
                exit()
print("Yes")

Fixed submission:
h, w = map(int, input().split())
cells = []
for i in range(h):
    s = input().split()
    cells.append(s[0])
ans = True
for i in range(1,h-1):
    for j in range(1,w-1):
        if cells[i][j] == '#':
            if cells[i-1][j] != '#' and cells[i+1][j] != '#' and cells[i][j-1] != '#' and cells[i][j+1] != '#':
                ans = False
                break
 
if ans: print("Yes")
else: print("No")

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
cells = []
cells.append(['0']*(w+2))
for i in range(h):
    l = [0]
    s = input().split()
    l+=list(s[0])
    l+=[0]
    cells.append(l)
cells.append([0]*(w+2))

is_ok = True
for i in range(1,len(cells)-1):
    for j in range(1,len(cells)-1):
        if cells[i][j] == '#':
            if cells[i-1][j] == '#':
                is_ok = True
            elif cells[i+1][j] == '#':
                is_ok = True
            elif cells[i][j-1] == '#':
                is_ok = True
            elif cells[i][j+1] == '#':
                is_ok = True
            else:
                is_ok = False
        if not is_ok:
            print("No")
            exit()
print("Yes")

Fixed submission:
h, w = map(int, input().split())
cells = []
for i in range(h):
    s = input().split()
    cells.append(s[0])
ans = True
for i in range(1,h-1):
    for j in range(1,w-1):
        if cells[i][j] == '#':
            if cells[i-1][j] != '#' and cells[i+1][j] != '#' and cells[i][j-1] != '#' and cells[i][j+1] != '#':
                ans = False
                break
 
if ans: print("Yes")
else: print("No")