Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

penals1 = []
tmp1 = 0
for s in S:
    if s == "#":
        tmp1 += 1
    penals1.append(tmp1)


penals2 = []
tmp2 = 0
for s in reversed(S):
    if s == ".":
        tmp2 += 1
    penals2.insert(0, tmp2)

#print(len(penals2))
#penals = [penals2[0]] + [penals1[i] + penals2[i+1] for i in range(1, N-1)] + [penals1[N-1]]

#min_val = min(penals)

min_val1 = min(penals2[0], penals1[N-1])
min_val2 = min([penals1[i] + penals2[i+1] for i in range(1, N-1)])
    
out = min(min_val1, min_val2)
print(out)

Fixed submission:
N = int(input())
S = input()

penals1 = []
tmp1 = 0
penals2 = []
tmp2 = 0

# 半分まで準備
N_even = (N % 2 == 0)
half_N = N // 2 if N_even else (N-1) // 2 

if N == 1:
    min_val = 0
else:
    for i in range(half_N):
        if S[i] == "#":
            tmp1 += 1
        penals1.append(tmp1)

        if S[N-1-i] == ".":
            tmp2 += 1
        penals2.append(tmp2)

    if N_even:
        min_val = penals1[half_N-1] + penals2[half_N-1] 

        j = 1
        for i in range(half_N, N):
            if S[i] == "#":
                tmp1 += 1
            #penals1.append(tmp1)
            val1 = tmp1 + penals2[half_N-1-j]

            if S[N-1-i] == ".":
                tmp2 += 1
            #penals2.append(tmp2)
            val2 = penals1[half_N-1-j] + tmp2

            min_val = min(min_val, val1, val2)
            j += 1

    else:
        first = True
        j = 0

        # N = (N-1) // 2 + (N-1) // 2 + 1
        for i in range(half_N, N):
            if S[i] == "#":
                tmp1 += 1
            val1 = tmp1 + penals2[half_N-1-j]

            if S[N-1-i] == ".":
                tmp2 += 1
            val2 = penals1[half_N-1-j] + tmp2

            if first:
                min_val = min(val1, val2)
                first = False
            else:
                min_val = min(min_val, val1, val2)
            j += 1

    if S[N-1] == "#":
        tmp1 += 1
    if S[0] == ".":
        tmp2 += 1

    min_val = min(tmp1, tmp2, min_val)
print(min_val)

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
N = int(input())
S = input()

#nums= np.zeros(N+1, dtype=int)
#for i, s in enumerate(S):
#    if s == ".":
#        nums[:i+1] += 1
#    else:
#        nums[i+1:] += 1
#
#out = nums.min()

nums = [0 for i in range(N+1)]

for i, s in enumerate(S):
    if s == ".":
        for j in range(0, i):
            nums[j] += 1
    else:
        for j in range(i+1, N+1):
            nums[j] += 1

out = min(nums)
print(out)

Fixed submission:
N = int(input())
S = input()

penals1 = []
tmp1 = 0
penals2 = []
tmp2 = 0

# 半分まで準備
N_even = (N % 2 == 0)
half_N = N // 2 if N_even else (N-1) // 2 

if N == 1:
    min_val = 0
else:
    for i in range(half_N):
        if S[i] == "#":
            tmp1 += 1
        penals1.append(tmp1)

        if S[N-1-i] == ".":
            tmp2 += 1
        penals2.append(tmp2)

    if N_even:
        min_val = penals1[half_N-1] + penals2[half_N-1] 

        j = 1
        for i in range(half_N, N):
            if S[i] == "#":
                tmp1 += 1
            #penals1.append(tmp1)
            val1 = tmp1 + penals2[half_N-1-j]

            if S[N-1-i] == ".":
                tmp2 += 1
            #penals2.append(tmp2)
            val2 = penals1[half_N-1-j] + tmp2

            min_val = min(min_val, val1, val2)
            j += 1

    else:
        first = True
        j = 0

        # N = (N-1) // 2 + (N-1) // 2 + 1
        for i in range(half_N, N):
            if S[i] == "#":
                tmp1 += 1
            val1 = tmp1 + penals2[half_N-1-j]

            if S[N-1-i] == ".":
                tmp2 += 1
            val2 = penals1[half_N-1-j] + tmp2

            if first:
                min_val = min(val1, val2)
                first = False
            else:
                min_val = min(min_val, val1, val2)
            j += 1

    if S[N-1] == "#":
        tmp1 += 1
    if S[0] == ".":
        tmp2 += 1

    min_val = min(tmp1, tmp2, min_val)
print(min_val)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
S = input()

nums= np.zeros(N+1, dtype=int)
for i, s in enumerate(S):
    if s == ".":
        nums[:i+1] += 1
    else:
        nums[i+1:] += 1

out = nums.min()
print(out)

Fixed submission:
N = int(input())
S = input()

penals1 = []
tmp1 = 0
penals2 = []
tmp2 = 0

# 半分まで準備
N_even = (N % 2 == 0)
half_N = N // 2 if N_even else (N-1) // 2 

if N == 1:
    min_val = 0
else:
    for i in range(half_N):
        if S[i] == "#":
            tmp1 += 1
        penals1.append(tmp1)

        if S[N-1-i] == ".":
            tmp2 += 1
        penals2.append(tmp2)

    if N_even:
        min_val = penals1[half_N-1] + penals2[half_N-1] 

        j = 1
        for i in range(half_N, N):
            if S[i] == "#":
                tmp1 += 1
            #penals1.append(tmp1)
            val1 = tmp1 + penals2[half_N-1-j]

            if S[N-1-i] == ".":
                tmp2 += 1
            #penals2.append(tmp2)
            val2 = penals1[half_N-1-j] + tmp2

            min_val = min(min_val, val1, val2)
            j += 1

    else:
        first = True
        j = 0

        # N = (N-1) // 2 + (N-1) // 2 + 1
        for i in range(half_N, N):
            if S[i] == "#":
                tmp1 += 1
            val1 = tmp1 + penals2[half_N-1-j]

            if S[N-1-i] == ".":
                tmp2 += 1
            val2 = penals1[half_N-1-j] + tmp2

            if first:
                min_val = min(val1, val2)
                first = False
            else:
                min_val = min(min_val, val1, val2)
            j += 1

    if S[N-1] == "#":
        tmp1 += 1
    if S[0] == ".":
        tmp2 += 1

    min_val = min(tmp1, tmp2, min_val)
print(min_val)