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



Sample input:
3
#.#


Sample output:
1

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

n = readInt()
s = sys.stdin.readline().strip()

w = 0
b = 0
for c in s:
    w += int(c == '.')
    b += int(c == '#')


wc = 0
bc = 0
ret = 1 << 64
for c in s:
    wc += int(c == '.')
    bc += int(c == '#')

    ret = min(ret, bc + (w - wc))
print(ret)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
cnt = 0
for i in range(N):
    if S[i-1] == "#" and S[i] == ".":
        cnt +=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
s = [S[i: i + 1] for i in range(N)]
ans = 0
bflag = 0
for i, st in enumerate(s):
    if bflag == 1:
        if st == '.':
            ans += 1
        else:
            bflag = 0
    else:
        if st == '#':
            bflag = 1
wflag = 0
ans2 = 0
for i in range(1, N + 1):
    if wflag == 1:
        if s[-i] == '#':
            ans2 += 1
        else:
            wflag == 0
    else:
        if s[-i] == '.':
            wflag = 1
print(min(ans, ans2))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

cnt = 0
for i in range(0, n-1):
  if s[i] == '#' and s[i+1] =='.':
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
t=list(s)
s.append("0")
t.append("0")
ans1=0
ans2=0
for i in range(n):
  if s[i]=="#" and s[i+1]==".":
    s[i+1] = "#"
    ans1 += 1
for j in range(n):
  if t[n-1-j]=="." and t[n-2-j]=="#":
    t[n-2-j]="."
    ans2 += 1  
print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
n=int(input())
S=input()
sflag=0
a=0
b=0
c=0
for i in S:
    if i=="#" and sflag==0:
        sflag=1
    if sflag==1:
        if i==".":
            a+=1
        #else:
        #    b+=1



a2=0
sflag=0
for i in S[::-1]:
    if i=="." and sflag==0:
        sflag=1
    if sflag==1:
        if i=="#":
            a2+=1
        #else:
        #    b2+=1

print(min(a,a2))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
h=0
b=0
for i in range(len(s)):
    if s[i]=="#":
        b+=1
    if s[i]=="." and b!=0:
        h+=1
if s[n-1]=="#":
    b-=1
print(min(h,b))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

ans = 0

if len(S) == 1:
    print(ans)
elif len(S) == 2:
    if S == '.#':
        print(ans)
else:
    for i in range(len(S)-2):
        if S[i] == '#' and S[i+1] == '.':
            if S[i+2] == '.':
                S[i] = '.'
            else:
                S[i+1] = '#'
            ans += 1
    print(ans)

Submission status: Wrong Answer

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

W=S.count('.')
B=N-W
ans_1=min(W,B)

first_b=S.find('#')
if first_b == -1:
  ans_2 = 0
else:
  S_w = S[0:first_b]
  S_b = S[first_b:N]
  ans_2 = S_w.count('#')+S_b.count('.')

print(min(ans_1,ans_2))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()

a=s.count("#")
b=s.count(".")
if a<b:
    if s[n-1]=="#":
        print(a-1)
    else:
        print(a)
else:
    if s[n-1]==".":
        print(b-1)
    else:
        print(b)

Submission status: Wrong Answer

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

for n in range(N):
	if S[n:n+2] == "#." :
		M = n+1
		break
	else:
		M = len(S)+1

print( S[M:].count("."))

Submission status: Wrong Answer

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


def m():
    ans = 0
    left, right = 0, N
    for i in range(N):
        if S[i] == '#':
            left = i
            break
    for i in reversed(range(N)):
        if S[i] == '.':
            right = i
            break
    tmp = S[left:right+1]
    black = tmp.count('#')
    white = tmp.count('.')
    ans = min(black,white)
    return ans

print(m())

Submission status: Wrong Answer

Solution code:
N=  int(input())
A = input()
A = list(A)
l = [0]
s = []
for i in range(N-1):
    if A[i] != A[i+1]:
        l.append(i+1)
        s.append(l[len(l)-1]-l[len(l)-2])
l.append(N)
s.append(l[len(l)-1]-l[len(l)-2])
sum = 0
if A[0]=="#":
    if len(s)%2==1:
        s.append(0)
    for i in range(0,len(s)-1,2):
        sum += min(s[i],s[i+1])
else:
    if (len(s)-1)%2==1:
        s.append(0)
    for i in range(1,len(s)-1,2):
        sum += min(s[i],s[i+1])
print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
if s.count('#') == 0:
    print('0')
    exit()
ssp = s.split('.')
num = s[s.find('#'):].count('.')
num = min(num,s.count('#') - len(ssp[-1]))
print(num)

Submission status: Wrong Answer

Solution code:
from itertools import groupby
N = int(input())
S = input()
b = 0
w = 0
x = ""
n = len(list(groupby(S)))
for i, (k, v) in enumerate(groupby(S)):
  if i == 0:
    if k == ".":
      continue
  if i == n-1:
    if k == "#":
      break
  v = len(list(v))
  if k == "#":
    b += v
  else:
    w += v
  x += k
print(min(b,w))

Submission status: Wrong Answer

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

cnt = 0
for s in S:
    if s == ".":
        cnt += 1
    else:
        break
ws = S[cnt:]
w = ws.count(".")
bs = S[::-1]
cnt = 0
for s in bs:
    if s == ".":
        cnt += 1
    else:
        break
bs = bs[cnt:]
b = bs.count("#")
print(min(w, b))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(input())

cnt = 0
for i in range(1,n):
    if (l[i-1] == "#")&(l[i-1] != l[i]):
        cnt += 1
    else:
        continue
print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = input()

    first_hash = N
    for i in range(N):
        if S[i] == '#':
            first_hash = i
            break

    all_hash = '#' * N
    all_dot = '.' * N
    medium = '.' * i + '#' * (N-i)

    count1 = 0
    for i in range(N):
        if S[i] != all_hash[i]:
            count1 += 1

    count2 = 0
    for i in range(N):
        if S[i] != all_dot[i]:
            count2 += 1

    count3 = 0
    for i in range(N):
        if S[i] != medium[i]:
            count3 += 1

    print(min(count1, count2, count3))

    
main()

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(str(input()))
cnt = 0
for i in range(0,N-1):
    if S[i] == "#" and S[i+1] == ".":
        S[i] == "."
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
k = 0
ans = 0

for i in range(N):
    if S[i] == "#":
        k = i
        break

for i in range(i+1,N):
    if S[i] == ".":
        ans += 1


print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
N=int(input())
S=list(input()[:-1])
b=S.count(".")
w=N-b
j= "#" if w>b else "."
c=0
for i in range(1,N):
  if (S[i-1]==j)and(S[i-1]!=S[i]):
    S[i]=j
    c+=1
print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input().rstrip()
index = S.find("#")
answer = 0
if index == -1:
    print(0)
    exit()
else:
    answer = S[index:].count(".")
index = S.rfind(".")
answer = S[:index].count("#") if S[index:].count("#")<answer else answer
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
l = -1
count = 0
for i in range(n):
    if s[i:i+1] == "#":
        if l == -1:  
            l = i
        count += 1
if l == -1:
    print(0)
else:
    ans = 0
    for i in range(l,n):
        if s[i:i+1] == ".":
            ans += 1
    print(min(count,ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
N = input()
S = input()

if S.count('#') > S.count('.'):
    print(S.count('.'))
else:
    print(S.count('#'))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())
# ".": 白
# "#": 黒
# 黒い石のすぐ右に白い石があるような箇所がないように
ans=0
for i in range(N-1):
    if S[i]=="#" and S[i+1]==".":
        S = S[:i] + "#" + S[i+1:]
        ans=ans+1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
l = ["#"]*N
L=[]
ans=10**9
for i in range(N):
    count=0
    l[i]="."
    for j in range(N):
        if l[j]!=S[j]:
            count+=1
        #print(count)
    ans=min(ans,count)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
n = int(input())
s = input()[:-1]
flag_w = 0
flag_b = 0
w = 0
b = 0
for i in range(n):
    if s[i] == '#':
        flag_b = 1
    else:
        if flag_b > 0:
            b += 1
    if s[-i-1] == '.':
        flag_w = 1
    else:
        if flag_w > 0:
            w += 1
if flag_w > 0 and flag_b > 0:
    print(min(w, b))
else:
    if flag_b == 0:
        print(w)
    else:
        print(b)

Submission status: Wrong Answer

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

cnt = 0
black = False
for i in range(N):
    if S[i] == '#':
        black = True
    if S[i] == '.' and black == True:
        cnt = cnt + 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

ans = 0
for i in range(n-1):
    if s[i] == '#' and s[i+1] == '.':
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    N = makeInt(input_string[0])
    S = input_string[1].rstrip()
    if len(S) == 1:
        return 0
    if S == "#.":
        return 1
    S = list("."+S)
    w = "."
    b = "#"
    c = 0
    for i in range(N):
        if S[i] == b:
            if S[i-1] == w and S[i+1] == w:
                S[i] = w
                c += 1
    i = N
    if i == N:
        #print("a")
        #print(S)
        #print(S[i])
        if S[i-1] == b and S[i] == w:
            S[i] = b
            c += 1
    return c


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

cnt = 0
flg = 0
for i in range(N-1):
    if flg and S[i+1] == '.':
        cnt += 1
    elif S[i] == '#' and S[i+1] == '.':
        flg = 1
        cnt += 1
    else:
        flg = 0

print(cnt)

Submission status: Wrong Answer

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

white = S.count('.')
bluck = S.count('#')
count = 0
for s in S:
    if s == '.':
        count += 1
    else:
        break
print(min(white - count,bluck))

Submission status: Wrong Answer

Solution code:
N = int(input())
S=input()
cnt1 = 0
cnt2 = 0
for idx,s in enumerate(S):
    if s != "." and idx != N-1:
        cnt1 += 1
    elif s!="#":
        cnt2+=1
print(min([cnt1,cnt2]))

Submission status: Wrong Answer

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

black_count = 0
white_count = 0
right_white_pos=0
for i in range(N):
    if(S[i]=="."):
        white_count+=1
        right_white_pos=i
    else:
        black_count+=1

counter = 0
for i in range(N):
    if(i<=right_white_pos):
        if(S[i]=="#"):
            counter +=1
    else:
        if(i!=right_white_pos):
            if(S[i]=="."):
                counter+=1

print(min(white_count, black_count, counter))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def main():
    input()
    s = input()

    # 最初に黒い石が出現した後に出現した"."と"#"のそれぞれの総数のうち、最小のものを返す
    b_num = 0
    w_num = 0
    is_start = False
    for c in s:
        if not is_start and c == "#":
            is_start = True
            continue
        if is_start and c == ".":
            b_num += 1
        if is_start and c == "#":
            w_num += 1

    return min(w_num, b_num)


print(main())

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
c = 0

def check():
  for i in range(n-1):
    j = i + 1
    if s[i] == "#":
      if s[j] == ".":
        return True
  return False

while check():
    for i in range(n-1):
      j = i + 1
      if s[i] == "#":
        if s[j] == ".":
          s[j] = "#"
          c += 1

print(c)

Submission status: Wrong Answer

Solution code:
import re

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

pattern = '#.'
match = re.findall(pattern, S)
print(len(match))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
li = []
for i in range(n):
    if s[i] == "#":
        li.append(i)
sum = 0
if len(li) == 0:
    print(0)
else:
    for i in range(len(li)-1):
        sum += li[i+1]-li[i]-1
    sum += len(s) - li[-1] -1 
    print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

cand = [j for j in range(len(s)-1) if s[j] =="#" and s[j+1] !="#"]
print(len(cand))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

start = len(s)
i = 0
while(i<len(s)):
    if(s[i]=="#"):
        start = i
        i = len(s)
    else:
        i += 1

if(start == len(s)):
    print("0")
else:
    kuro = 1
    shiro = 0
    for i in range(len(s)-start-1):
        if(s[i+start+1]=="."):
            shiro += 1
        else:
            kuro += 1
    if(kuro<=shiro):
        if(s[len(s)-1]=="#"):
            print(kuro-1)
        else:
            print(kuro)
    else:
        print(shiro)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

num = 0
result = 0

for i in range(N-1,-1,-1):
    if S[i] == "." :
        #print(i)
        num = i+1
        break

white = S[0:num].count('.')
black = S[0:num].count('#')
if white < black:
    result = white
else:
    result = black
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
try:
  leftb = s.index('#')
except:
  leftb = -1

if leftb >= 0:
  ans = s[leftb:].count('.')
else:
  ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
 
le=N
 
ans = 0
for i in range(le-1):
  if S[i]=="#" and S[i+1]==".":
    ans += 1
    S = S[:i] + "#" + S[i+1:]
  
if 2*ans < N:
  print(ans)
 
else:
  print(le-ans)

Submission status: Wrong Answer

Solution code:
# c
import copy

N = int(input())
S = list(input())
S = S[::-1]
Ss = copy.deepcopy(S)
ans0 = 0
ans1 = 0

for i in range(1, N):
    if S[i-1] == "." and S[i] == "#":
        ans0 += 1
        S[i] = "."

for i in range(1, N):
    if Ss[i-1] == "." and Ss[i] == "#":
        ans1 += 1
        Ss[i-1] = "#"

print(min(ans0, ans1))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
s = input()

cnt_start = False
cnt = 0

for c in s:
    if c == '.':
        cnt_start = True
        continue

    if not cnt_start:
        continue
    else:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
if "." in s:
    a = [i for i, x in enumerate(s) if x == '.'][-1]
    ans1 = s[:a+1].count("#")
else:
    ans1 = 0
if "#" in s:
    b = [i for i, x in enumerate(s) if x == '#'][0]
    ans2 = s[b:].count(".")
else:
    ans2 = 0
print(min(ans1, ans2))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
 
res = 0
for i in range(len(S)-1):
    if S[i] == '#' and S[i+1] == '.':
        if i+2 <= len(S)-1:
            if S[i+1] == '.':
                S[i] == '.'
                res += 1
                continue
        res += 1
        S[i+1] == '#'

print(res)

Submission status: Wrong Answer

Solution code:
import sys
import random
input = sys.stdin.readline
n = int(input())
s = input()
num = -1
bl = 0
for i in range(n):
    if s[i] == "#":
        if bl == 0:
            num = i
        bl += 1
if num >= 0 and bl > n - num - bl:
    print(n-num-bl)
else:
    while (n > 0 and s[n-1] == "#"):
        bl -= 1
        n -= 1
    print(bl)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(str, input()))

count = 0
for i in range(0, len(s)-1):
    if s[i] == "#" and s[i+1] == ".":
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:

n = int(input())

s = input()

idx = s.find(".#")
ans = 0
if idx == -1:
  ans = 0
else:
  if idx != 0:
      if s[idx-1] == "#":#左がbならwは置けない
        ans = s[idx:].count(".")
      else:
        ans = min(s[idx:].count("."), s[idx:].count("#"))
  else:
    ans = min(s.count("."), s.count("#"))

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())
result = 0
max_len_s = len(s) - 1
for i in range(max_len_s):
    if s[i] + s[i + 1] == "#.":
        result += 1
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
s1 = '#'
i = 0
slis = []

for s in S:
  if s == s1:
    i += 1
  if s != s1:
    slis.append(i + 1)
    s1 = s
    i = 0

if i != 0:
  slis.append(i+1)

if S.startswith('.'):
  sum1 = sum(slis[2::2])
  sum2 = sum(slis[3::2])
else:
  sum1 = sum(slis[0::2])
  sum2 = sum(slis[1::2])

print(min(sum1, sum2))

Submission status: Wrong Answer

Solution code:

def main():
    N=int(input())
    line = list(input())
    flag = False
    cnt_W = 0
    cnt_B = 0
    for i in line:
        if i =="#":
            flag = True
        if flag == True:
            if i ==".":
                cnt_W +=1
            else:
                cnt_B +=1

    return min(cnt_W,cnt_B)

print(main())

Submission status: Wrong Answer

Solution code:
from sys import exit

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

stack = []


for i in range(N):
    if S[i] == '.':
        stack.append(i)
        j = i

if stack:
    if j - (len(stack) - 1) < len(stack):
        ans = j - (len(stack) - 1)
    else:
        ans = len(stack)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
N = ni()
S = ns()

#最初のBが出てくるまでを数える
fastB = False
fastW = False
w0,w1,b0,b1 = 0,0,0,0

for s in S:
    if(s=="."):
        #print("w")
        if(fastB and fastW):
            w1+=1
        else:
            fastW=True
            w0+=1
    elif(s=="#"):
        #print("b")
        if(fastB and fastW):
            b1+=1
        else:
            fastB=True
            b0+=1

#print(b0+b1,w0+w1,w1)
#print(b0,b1,w0,w1)

print(min(b0+b1,w0+w1,w1))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
print(min(S.count("."), S.count("#")))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

now = s[0]
count=0
for i in range(0,n-1):
    if now == "#" and s[i+1]==".":
        if i > 0 and s[i-1]==".":
            count+=1
            now = "."
            continue
        count+=1
        continue
    now = s[i+1]
print(count)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N = int(input())
    S = input()
    count = 0
    keepColor = False
    for t in S:
        if t == "#":
            keepColor = True
        if keepColor and t == ".":
            count += 1
    count2 = 0
    keepColor = False
    for t in S[::-1]:
        if t == ".":
            keepColor = True
        if keepColor and t == "#":
            count2 += 1
    print(min(count,count2))

Submission status: Wrong Answer

Solution code:
n = int(input())
s =input()

print(min(s[s.find('#'):].count('#.'),s[s.find('#'):].count('.')))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

count_1 = 0
count_2 = 0
for i in range(N-1):
  if S[i] == "#" and S[i+1] == ".":
    count_1 += 1
for i in range(N-1):
  if S[N - i - 1] == "." and S[N - i - 2] == "#":
    count_2 += 1
    
print(min(count_1, count_2))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
ans = 0

for i in range(N):
    if S[i:i+3] == ['#', '.', '#']:
        S[i:i+3] = ['#', '#', '#']
        ans += 1
    elif S[i:i+3] == ['#', '.', '.']:
        S[i:i+3] = ['.', '.', '.']
        ans += 1
    elif S[i:i+3] == ['#', '#', '.']:
        S[i:i+3] = ['#', '#', '#']
        ans += 1
    elif S[i:i+3] == ['.', '#', '.']:
        S[i:i+3] = ['.', '.', '.']
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
p=0
count=0
#左から黒をカウントして、黒を返すだけで済むならそっちを採用する、
#そうでないなら特定の黒より右で、少ない方に応じて色を変える
#黒がシャープ白がドット
for i in range(N):
    if S[i]=='#':
        count=S[i:].count('#')
        p=i
        break
    else:
        pass
print(min(count,N-p-count))

Submission status: Wrong Answer

Solution code:
def main(word):
    strs = list(word)

    count = 0
    for i, _ in enumerate(strs):
        if i == 0:
            continue
        if strs[i] == "." and strs[i-1] == "#":
            count += 1

    return count


if __name__ == "__main__":
    input()
    word = input()
    print(main(word))

Submission status: Wrong Answer

Solution code:
SIRO = '.'
KURO = '#'
N = int(input())
S = input()
ans = 0
bFlg = False
for j in range(N):
    for i in range(0, N - 1):
        if S[i] == KURO:
            if S[i + 1] == SIRO:
                S[i]
                ans += 1
                bFlg = True
    if bFlg:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
k = 0
ans = 0

for i in range(N):
    if S[i] == "#":
        k = i
        break

for i in range(i+1,N):
    if S[i] == ".":
        ans += 1


print(ans)
print(k)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

finded_black = False
answer1 = 0

for c in s:
    if finded_black:
        if c == '#':
            continue
        else:
            answer1 += 1

    if not finded_black:
        if c == '.':
            continue
        else:
            finded_black = True


black_count = 0

for c in s:
    if c == '#':
        black_count += 1

print(min(answer1, black_count))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
s = [S[i: i + 1] for i in range(N)]
ans = 0
bflag = 0
for i, st in enumerate(s):
    if bflag == 1:
        if st == '.':
            ans += 1
        else:
            bflag = 0
    else:
        if st == '#':
            bflag = 1
wflag = 0
ans2 = 0
for i in range(1, N + 1):
    print(s[-i])
    if wflag == 1:
        if s[-i] == '#':
            ans2 += 1
        else:
            wflag == 0
    else:
        if s[-i] == '.':
            wflag = 1
print(min(ans, ans2))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
B_C = 0
W_C = 0
if S[0] == "#":
  K = 1
  for i in range(N-1):
    if S[i] == "#" and S[i+1] == "#":
      K += 1
    else:
      break
  for i in range(N-K):
      if S[i] == ".":
          W_C += 1
      elif S[i] == "#":
          B_C += 1
  #print(W_C,B_C)
  print(min(W_C,B_C))
else:
  K = 1
  for i in range(N-1):
    if S[i] == "." and S[i+1] == ".":
      K += 1
    else:
      break
  S = S[K:]
  for i in range(N-K):
    if S[i] == ".":
        W_C += 1
    elif S[i] == "#":
        B_C += 1
  #print(K,W_C,B_C)
  print(min(W_C,B_C))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N =  input()
S =  input()

n = S.find("#")
ans =  S[n:].count(".") if n >= 0 else 0

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
count=0
for i in range(N):
    if S[0] == S[i] :
        continue
    else:
        count +=1
if (N / 2) < count:
    print(N - count)
else:
    print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
s = np.array(list(input())) == '.'

if s.sum() == 0:
    print(0)
    exit()

index = np.where(s[::-1])[0][0]

if index == 0:
    check_list = s
else:
    check_list = s[:-index]

print(min(check_list.sum(), np.logical_not(check_list).sum()))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = input()

    print(S.count('#.'))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
s=input()
s=[s[i] for i in range(N)]
hit=0
count=0
for i in s:
    if i=="#":
        hit = 1
    if hit==1 and i==".":
        count=count+1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
s += [0]

b = 0
w = 0
p = 0
for i in range(n):
    if s[i] == "#":
        b += 1
    if b > 0:
        if s[i] == ".":
            w += 1
            if s[i+1] == "#" or s[i+1] == 0:
                p += min(b,w)
                b = 0
                w = 0

print(p)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(input())
b=a.copy()

sum=0

for i in range(1,n):
  if (a[-i] == "." and a[-i-1] == "#"):
    a[-i-1] = "."
    sum += 1

if b.count(".") < sum:
  sum = b.count(".")
    
print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(1, N):
  if S[i-1] == "#" and S[i] == ".":
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
dp = [0 for i in range(N)]
b = 0
w = 0
for i in range(N):
    if S[i] == '.':
        dp[i] = b
    else:
        b += 1

for i in reversed(range(N)):
    if S[i] == '#':
        dp[i] = w
    else:
        w += 1
ans = float('inf')
for i in range(N-1):
    if S[i] == '.' and S[i+1] == '#':
        ans = min(ans,dp[i]+dp[i+1])
if ans == float('inf'):
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
fK = N
ansSK = 0
ansSS = 0
for i in range(N):
    if S[i] == '#':
        fK = i
        break
for j in range(fK,N):
    if S[j] == '.':
        ansSK += 1
    else:
        if j == N-1:
            break
        ansSS += 1
print(min(ansSK,ansSS))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
first = n
for i in range(n):
  if (s[i] == '#'):
    first = i
    break
if (first < n): 
  print(min(s[first:].count('.'), s[first:].count('#')))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(str(input()))
for i in range(n):
  if s[0] == ".":
    del s[0]
  else:
    break
sb = s.count("#")
sw = s.count(".")
if sb>sw:
  print(sw)
else:
  print(sb)

Submission status: Wrong Answer

Solution code:
#!/snap/bin/pypy3

def sharpcounter(string):
    for i, char in enumerate(string):
        if char != '#':
            return i


def main():
    N = int(input())
    S = input()

    count = 0
    tmp_sharp = 0
    for i, char in enumerate(S):
        if char == '#':
            tmp_sharp += 1
        else:
            if i + 1 < N and S[i+1] == '#':
                count += 1
            elif i + 1 == N:
                count += int(tmp_sharp > 0)
            else:
                count += min(tmp_sharp, sharpcounter(S[i+1:]))
                tmp_sharp = 0 

    print(count)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())	
s2 = s[:]

l=[0]
cnt1=0
for i in range(len(s)):
    if(s[i] == "#"):
        cnt1 +=1
    l.append(cnt1)
ansl=[]
for i in range(len(s)):
    ansl.append(n-i-cnt1+2*l[i])



print(min(ansl))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

kurodeta = False
cnt = 0
for stone in S:
    if not kurodeta and stone == ".":
        continue

    if stone == "#":
        kurodeta = True

    if stone == ".":
        cnt += 1


shirodeta = False
kurocount = 0
for stone in reversed(S):
    if not shirodeta and stone == "#":
        continue

    if stone == ".":
        shirodeta = True

    if stone == "#":
        kurocount += 1


print(min(cnt, kurocount))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

if s.count(".") == n:
  print(0)
  exit()

c = [0]
cc = [0]
for i in range(n):
  if s[i] == ".":
    c.append(c[-1]+1)
    cc.append(cc[-1])
  else:
    c.append(c[-1])
    cc.append(cc[-1]+1)
c = c[1:]
cc = cc[1:]

a = cc.count(0)
print(min(c[-1]-a, cc[-1]-a))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
black = S.count('#')
white = S.count('.')
count = 0
if black > white:
    for i in range(0,N-1):
        if S[i]=='#' and S[i+1]=='.':
            S[i+1]='#'
            count += 1
else:
    for i in range(0,N-1):
        if S[i]=='#' and S[i+1]=='.':
            S[i+1]='.'
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

a = list(input())
su = 0
co = 0
if a[-1] == "#":
	co = 2
for i in range(n-1):
	if co == 1:
		if a[-(i+2)] == "#":
			su += 1
	if a[-(i+2)] == "#" and co != 2:
		co = 1
		if i == n-2:
			su += 1
	elif a[-(i+2)] == ".":
		co = 0
print(su)

Submission status: Wrong Answer

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
n = ip()                                     #入力整数1つ
#a,b,c= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#k = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(3)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
rb = 0
rw = 0
s = n
for i in range(n):
    if a[i] == '#':rb+=1
    else : rw+=1
lb = 0
lw = 0
for i in range(n):
    if a[i] == '#':
        lb+=1
        rb-=1
    else :
        lw+=1
        rw-=1
    s = min(s,lb+rw)
print(s)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import re

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

S = re.sub(r'^\.+', '', S)

num_white = 0
num_black = 0
ans = 0
for i in range(len(S)):
    if S[i] == '.':
        ans = num_black
        num_white += 1
    else:
        num_black += 1

print(min([ans, num_white]))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
pass_flag = False
count = 0
for i in range(N-1):
    if pass_flag:
        pass_flag = False
        continue

    if S[i] == '#' and S[i+1] == '.':
        count += 1
        pass_flag = True
print(count)