Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = ""
for i in range(0, H):
    temp = input().replace("#", "0")
    l_bit = temp.replace(".", "1")
    s = s + l_bit

route1 = []
route = [[]]
for j in range(0, W-1):
    route[0].append(j)
print(route)
count = len(route)

#k :0~W-1
best = (H - 1) + (W - 1)
for k in range(0, W-1):    
    for num in range(0, count):
        for p in range(0, (H*W)-(W-k)):
            route1 = route[num]
            route1[W-2-k] = route1[W-1-k-1] + p
            if W > 2:
                if route1[W-k-3] % W <= route1[W-k-2] % W: 
                    route.append(route1) 
                    count += 1
                    block = (H - 1) + (W - 1)
                    print(route1)
                    for q in range(0, len(route1)):
                        if q+1 != len(route1)+1:
                            print(q)
                            if s[route1[q+1]] == s[route1[q]] and ((route1[q+1] == route1[q] + 1) or (route1[q] % W == (route1[q] + 1) % W)):
                                block = block - 1
                                best = min([best, block])
            else:
                route.append(route1) 
                count += 1
                block = (H - 1) + (W - 1)
                print(route1)
                for q in range(0, len(route1)):
                    if q+1 != len(route1):
                        if s[route1[q+1]] == s[route1[q]] and ((route1[q+1] == route1[q] + 1) or (route1[q] % W == (route1[q] + 1) % W)):
                            block = block - 1
                best = min([best, block])

print(best)

Fixed submission:
import numpy as np

H, W = map(int, input().split())
temp = [list(input().replace("#","0").replace(".","1")) for i in range(H)]
masu = [[int(temp[i][j]) for j in range(W)] for i in range(H)]

dp = np.zeros((H, W))
if masu[0][0] == 0:
    dp[0][0] = 1

for i in range(0,H):
    for j in range(0,W):
        if i == 0:
            a = 100000
        else:
            if masu[i][j] == 0 and masu[i-1][j] == 1:
                a = dp[i-1][j] + 1
            else:
                a = dp[i-1][j]
        if j == 0:
            b = 100000
        else:
            if masu[i][j] == 0 and masu[i][j-1] == 1:
                b = dp[i][j-1] + 1
            else:
                b = dp[i][j-1]
        if a != 100000 or b != 100000:
            dp[i][j] = min([a, b])
print(int(dp[H-1][W-1]))

Buggy python submission (verdict: Runtime Error):
                    route.append(route1) 
                    count += 1
                    block = (H - 1) + (W - 1)
                    print(route1)
                    for q in range(0, len(route1)):
                        if q+1 != len(route1):
                            if s[route1[q+1]] == s[route1[q]] and ((route1[q+1] == route1[q] + 1) or (route1[q] % W == (route1[q] + 1) % W)):
                                block = block - 1
                    best = min([best, block])

Fixed submission:
import numpy as np

H, W = map(int, input().split())
temp = [list(input().replace("#","0").replace(".","1")) for i in range(H)]
masu = [[int(temp[i][j]) for j in range(W)] for i in range(H)]

dp = np.zeros((H, W))
if masu[0][0] == 0:
    dp[0][0] = 1

for i in range(0,H):
    for j in range(0,W):
        if i == 0:
            a = 100000
        else:
            if masu[i][j] == 0 and masu[i-1][j] == 1:
                a = dp[i-1][j] + 1
            else:
                a = dp[i-1][j]
        if j == 0:
            b = 100000
        else:
            if masu[i][j] == 0 and masu[i][j-1] == 1:
                b = dp[i][j-1] + 1
            else:
                b = dp[i][j-1]
        if a != 100000 or b != 100000:
            dp[i][j] = min([a, b])
print(int(dp[H-1][W-1]))