Problem:
 Score : 300 points    Problem Statement There are N stones arranged in a row. Every stone is painted white or black.
A string S represents the color of the stones. The i -th stone from the left is white if the i -th character of S is . , and the stone is black if the character is # .  Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.
Find the minimum number of stones that needs to be recolored.      Constraints  1 \leq N \leq 2\times 10^5  S is a string of length N consisting of . and # .         Input Input is given from Standard Input in the following format:  N  S       Output Print the minimum number of stones that needs to be recolored.        Sample Input 1 3
#.#      Sample Output 1 1  It is enough to change the color of the first stone to white.       Sample Input 2 5
#.##.      Sample Output 2 2       Sample Input 3 9
.........      Sample Output 3 0

Solution (Python):

import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, S: str):
    stones = [1 if s == "
    acc = [0]+list(accumulate(stones))
    counter = 0
    m = INF
    for i in range(N+1):
        m = min(m, (acc[i]) + (N-i-(acc[N]-acc[i])))
    print(m)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = next(tokens)  
    solve(N, S)


if __name__ == '__main__':
    main()

Solution (Python):
a=int(input())
b=input()
c = 0
mx = 0
mxc = 0
for i in range(len(b)):
    if b[i] == ".":
        c += 1
        if mx < c:
            mx = c
            mxc = i+1
    else:
        c -= 1


print(int((mxc-mx)/2+(len(b)-mxc-mx+c)/2))

Solution (Python):
N=int(input())
S=input()
M=S.count(".")
ans=M
for i in range(N):
  if S[i]=="
    M+=1
  else:
    M-=1
  ans=min(ans,M)
print(ans)

Solution (Python):
N = int(input())
S = input()


r = S.count(".")
result = r
for i in range(N):
    if S[i] == "
        r += 1
    else:
        r -= 1
    result = min(result, r)

print(result)

Solution (Python):
n=int(input())
s=input()
cnt1=[0]*n
cnt2=[0]*n

if s[0]=="
if s[n-1]==".": cnt2[n-1]=1

for i in range(1,n):
    cnt1[i]=cnt1[i-1]
    if s[i]=="

for i in range(n-2,-1,-1):
    cnt2[i]=cnt2[i+1]
    if s[i]==".": cnt2[i]+=1

ans=10**18
for i in range(n-1):
    ans=min(ans,cnt1[i]+cnt2[i+1])
ans=min(ans,cnt1[n-1])
ans=min(ans,cnt2[0])
print(ans)