Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
s = [list(input()) for i in range(W)]
w = [1,0,0,-1]
h = [0,1,-1,0]
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            flag = False
            for k in range(4):
                if j+w[k] >= 0 and j+w[k] < H and i+h[k] >= 0 and i+h[k] < W:
                    if s[i+h[k]][j+w[k]] == '#':
                        flag = True
            
            if not flag:
                print('No')
                exit()

            
        
print('Yes')



Fixed submission:
H,W = map(int,input().split())

s=[list(str(input())) for _ in range(H)]

di=[1,-1,0,0]
dj=[0,0,1,-1]
for i in range(H):
    for j in range(W):
        if s[i][j]=='#':
            found=False
            for k in range(4):
                i2=i+di[k]
                j2=j+dj[k]
                if 0<=i2 and i2<H and 0<=j2 and j2<W:
                    if s[i2][j2]=='#':
                        found=True
            if not found:
                print('No')
                exit()

print('Yes')

Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
s = [list(input()) for i in range(W)]
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            if i == 0:
                if j == 0:
                    if s[i+1][j] != '#' and s[i][j+1] != '#':
                        print('No')
                        exit()
                elif j == W-1:
                    if s[i+1][j] != '#' and s[i][j-1] != '#':
                        print('No')
                        exit()
                else:
                    if s[i+1][j] != '#' and s[i][j-1] != '#' and s[i][j+1] != '#':
                        print('No')
                        exit()
            elif i == H-1:
                if j == 0:
                    if s[i-1][j] != '#' and s[i][j+1] != '#':
                        print('No')
                        exit()
                elif j == W-1:
                    if s[i-1][j] != '#' and s[i][j-1] != '#':
                        print('No')
                        exit()
                else:
                    if s[i-1][j] != '#' and s[i][j-1] != '#' and s[i][j+1] != '#':
                        print('No')
                        exit()
            else:
                if j == 0:
                    if s[i-1][j] != '#' and s[i][j+1] != '#' and s[i+1][j] != '#':
                        print('No')
                        exit()
                elif j == W-1:
                    if s[i-1][j] != '#' and s[i][j-1] != '#' and s[i+1][j] != '#':
                        print('No')
                        exit()
                else:
                    if s[i-1][j] != '#' and s[i][j-1] != '#' and s[i][j+1] != '#' and s[i+1][j] != '#':
                        print('No')
                        exit()
print('Yes')



Fixed submission:
H,W = map(int,input().split())

s=[list(str(input())) for _ in range(H)]

di=[1,-1,0,0]
dj=[0,0,1,-1]
for i in range(H):
    for j in range(W):
        if s[i][j]=='#':
            found=False
            for k in range(4):
                i2=i+di[k]
                j2=j+dj[k]
                if 0<=i2 and i2<H and 0<=j2 and j2<W:
                    if s[i2][j2]=='#':
                        found=True
            if not found:
                print('No')
                exit()

print('Yes')