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

board = [[0] * W for i in range(H)]

if S[0][0] == '#':
    board[0][0] = 1

if W > 1:
    for i in range(1, W):
        if S[0][i - 1] == '.' and S[0][i] == '#':
            board[0][i] = board[0][i - 1] + 1
        else:
            board[0][i] = board[0][i - 1]
if H > 1:
    for i in range(1, H):
        if S[i - 1][0] == '.' and S[i][0] == '#':
            board[i][0] = board[i - 1][0] + 1
        else:
            board[i][0] = board[i - 1][0]

if H > 1 and W > 1:
    for i in range(1, W):
        for j in range(1, H):
            if S[i][j] == '.':
                board[i][j] = min(board[i - 1][j], board[i][j - 1])
            else:
                if S[i - 1][j] == '.':
                    left = 1
                else:
                    left = 0
                if S[i][j - 1] == '.':
                    up = 1
                else:
                    up = 0
                board[i][j] = min(board[i - 1][j] + left, board[i][j - 1] + up)

print(board[H - 1][W - 1])


Fixed submission:
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

board = [[0] * W for i in range(H)]

if S[0][0] == '#':
    board[0][0] = 1

for i in range(1, W):
    if S[0][i - 1] == '.' and S[0][i] == '#':
        board[0][i] = board[0][i - 1] + 1
    else:
        board[0][i] = board[0][i - 1]

for i in range(1, H):
    if S[i - 1][0] == '.' and S[i][0] == '#':
        board[i][0] = board[i - 1][0] + 1
    else:
        board[i][0] = board[i - 1][0]

for i in range(1, H):
    for j in range(1, W):
        if S[i][j] == '.':
            board[i][j] = min(board[i - 1][j], board[i][j - 1])
        else:
            if S[i - 1][j] == '.':
                up = 1
            else:
                up = 0
            if S[i][j - 1] == '.':
                left = 1
            else:
                left = 0
            board[i][j] = min(board[i - 1][j] + up, board[i][j - 1] + left)

print(board[H - 1][W - 1])

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

board = [[0] * W for i in range(H)]

if S[0][0] == '#':
    board[0][0] = 1

for i in range(1, W):
    if S[0][i - 1] == '.' and S[0][i] == '#':
        board[0][i] = board[0][i - 1] + 1
    else:
        board[0][i] = board[0][i - 1]

for i in range(1, H):
    if S[i - 1][0] == '.' and S[i][0] == '#':
        board[i][0] = board[i - 1][0] + 1
    else:
        board[i][0] = board[i - 1][0]

for i in range(1, W):
    for j in range(1, H):
        if S[i][j] == '.':
            board[i][j] = min(board[i - 1][j], board[i][j - 1])
        else:
            if S[i - 1][j] == '.':
                left = 1
            else:
                left = 0
            if S[i][j - 1] == '.':
                up = 1
            else:
                up = 0
            board[i][j] = min(board[i - 1][j] + left, board[i][j - 1] + up)

print(board[H - 1][W - 1])


Fixed submission:
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

board = [[0] * W for i in range(H)]

if S[0][0] == '#':
    board[0][0] = 1

for i in range(1, W):
    if S[0][i - 1] == '.' and S[0][i] == '#':
        board[0][i] = board[0][i - 1] + 1
    else:
        board[0][i] = board[0][i - 1]

for i in range(1, H):
    if S[i - 1][0] == '.' and S[i][0] == '#':
        board[i][0] = board[i - 1][0] + 1
    else:
        board[i][0] = board[i - 1][0]

for i in range(1, H):
    for j in range(1, W):
        if S[i][j] == '.':
            board[i][j] = min(board[i - 1][j], board[i][j - 1])
        else:
            if S[i - 1][j] == '.':
                up = 1
            else:
                up = 0
            if S[i][j - 1] == '.':
                left = 1
            else:
                left = 0
            board[i][j] = min(board[i - 1][j] + up, board[i][j - 1] + left)

print(board[H - 1][W - 1])