Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
L = [0] * N
for i in range(N):
    if S[i] == "#":
        # white
        L[i] = 1
    else:
        L[i] = 0
# L = np.array(L, dtype=np.int8)
L2 = np.zeros(N, dtype=np.int16)
# ans = np.abs((L - L2)).sum()
# for i in range(N):
#     L2[N-1-i] = 1
#     ans_tmp = np.abs((L - L2)).sum()
#     ans = min(ans, ans_tmp)
# print(ans)
all_whitedist = np.abs((L - L2)).sum()
dist = np.zeros(N, dtype=np.int16)
dist[0:] = all_whitedist
dist[0] = all_whitedist
for i in range(N):
    if L[N-1-i] == 1:
        dist[i:] -= 1
    else:
        dist[:i] -= 1
indx = np.where(dist == dist.min())[0][0]
L3 = np.zeros(N, dtype=np.int16)
L3[indx:] = 1
ans_tmp = np.abs((L - L3)).sum()
print(min(all_whitedist, ans_tmp))

Fixed submission:
N = int(input())
S = input()
L = [0] * N
for i in range(N):
    if S[i] == "#":
        L[i] = 1
    else:
        L[i] = 0

leftblack = 0
rightwhite = len([x for x in L if x == 0])
ans = leftblack + rightwhite

for i in range(N):
    if S[i] == "#":
        leftblack += 1
    else:
        rightwhite -=1
    ans = min(ans, leftblack + rightwhite)
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
S = input()
L = [0] * N
for i in range(N):
    if S[i] == "#":
        # white
        L[i] = 1
    else:
        L[i] = 0
L = np.array(L, dtype=np.int8)
L2 = np.zeros(N, dtype=np.int8)
ans = np.abs((L - L2)).sum()
for i in range(N):
    L2[N-1-i] = 1
    ans_tmp = np.abs((L - L2)).sum()
    ans = min(ans, ans_tmp)
print(ans)

Fixed submission:
N = int(input())
S = input()
L = [0] * N
for i in range(N):
    if S[i] == "#":
        L[i] = 1
    else:
        L[i] = 0

leftblack = 0
rightwhite = len([x for x in L if x == 0])
ans = leftblack + rightwhite

for i in range(N):
    if S[i] == "#":
        leftblack += 1
    else:
        rightwhite -=1
    ans = min(ans, leftblack + rightwhite)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
S = input()
L = [0] * N
for i in range(N):
    if S[i] == "#":
        # white
        L[i] = 1
    else:
        L[i] = 0
L = np.array(L, dtype=np.int8)
L2 = np.zeros(N, dtype=np.int8)

ans = np.abs((L - L2)).sum()
for i in range(N):
    L2[N-1-i] = 1
    ans_tmp = np.abs((L - L2)).sum()
    ans = min(ans, ans_tmp)
print(ans)

Fixed submission:
N = int(input())
S = input()
L = [0] * N
for i in range(N):
    if S[i] == "#":
        L[i] = 1
    else:
        L[i] = 0

leftblack = 0
rightwhite = len([x for x in L if x == 0])
ans = leftblack + rightwhite

for i in range(N):
    if S[i] == "#":
        leftblack += 1
    else:
        rightwhite -=1
    ans = min(ans, leftblack + rightwhite)
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
S = input()
L = [0] * N
for i in range(N):
    if S[i] == "#":
        # white
        L[i] = 1
    else:
        L[i] = 0
L = np.array(L, dtype=np.int8)
a = np.zeros((N+1, N), dtype=np.int8)
for i in range(N):
    a[i, :i] = 1
a[N] = 1

ans = (a - L)**2
ans = ans.sum(axis=1).min()
print(ans)

Fixed submission:
N = int(input())
S = input()
L = [0] * N
for i in range(N):
    if S[i] == "#":
        L[i] = 1
    else:
        L[i] = 0

leftblack = 0
rightwhite = len([x for x in L if x == 0])
ans = leftblack + rightwhite

for i in range(N):
    if S[i] == "#":
        leftblack += 1
    else:
        rightwhite -=1
    ans = min(ans, leftblack + rightwhite)
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
S = input()

a = np.zeros((N+1, N))

for i in range(N):
    a[i, :i] = 1
a[N] = 1
L = [0] * N
for i in range(N):
    if S[i] == ".":
        # white
        L[i] = 0
    else:
        L[i] = 1
L = np.array(L)
ans = (a - L)**2
ans = ans.sum(axis=1).min()
print(int(ans))

Fixed submission:
N = int(input())
S = input()
L = [0] * N
for i in range(N):
    if S[i] == "#":
        L[i] = 1
    else:
        L[i] = 0

leftblack = 0
rightwhite = len([x for x in L if x == 0])
ans = leftblack + rightwhite

for i in range(N):
    if S[i] == "#":
        leftblack += 1
    else:
        rightwhite -=1
    ans = min(ans, leftblack + rightwhite)
print(ans)