Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  n = int(input())
  s = input()
 
  ans = 10**15
  for i in range(n+1):
   s1 = s[0:i]
   s2 = s[i::]
   tp = s1.count('#')
   tp2 = s2.count(".")
   ans = min(ans,tp+tp2)
  print(ans)
solve()

Fixed submission:
def solve():
  n = int(input())
  s = input()
  
  leftblack = 0
  leftwhite = 0
  rightblack = s.count('#')
  rightwhite = s.count(".")
  
  ans = leftblack+rightwhite
  
  for i in range(n):
    if s[i] == "#":
      leftblack += 1
      rightblack -= 1
    else:
      leftwhite += 1
      rightwhite -= 1
    ans = min(ans,leftblack+rightwhite)
  
  print(ans)
solve()

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  n = int(input())
  s = input()

  ans = 10**15
  a = s.count(".")
  b = s.count("#")
  for i in range(n+1):
   s1 = s[0:i]
   s2 = s[i::]
   tp = s1.count('#')
   tp2 = s2.count(".")
   ans = min(ans,tp+tp2)
  print(ans)
solve()

Fixed submission:
def solve():
  n = int(input())
  s = input()
  
  leftblack = 0
  leftwhite = 0
  rightblack = s.count('#')
  rightwhite = s.count(".")
  
  ans = leftblack+rightwhite
  
  for i in range(n):
    if s[i] == "#":
      leftblack += 1
      rightblack -= 1
    else:
      leftwhite += 1
      rightwhite -= 1
    ans = min(ans,leftblack+rightwhite)
  
  print(ans)
solve()

Buggy python submission (verdict: Runtime Error):
def solve():
  n = int(input())
  s = input()

  ans = 10**15
  a = s.count(".")
  b = s.count("#")
  sharp = []
  dot = []
  tp = 1
  if a == n:
    print("0")
  else:
    for i in range(n-1):

        if s[i] == s[i+1]:
           tp += 1
               
        if s[i] != s[i+1]:
            if s[i]==".":
                dot.append(tp)
                sharp.append(0)
            else:
                dot.append(0)
                sharp.append(tp)
            tp = 1
        if i == n-2:
           if s[i+1]==".":
                dot.append(tp)
                sharp.append(0)
           else:
                dot.append(0)
                sharp.append(tp)
           tp = 1
    
    e = len(sharp)
    ans = min(b-sharp[-1],a-dot[0])
    #print(dot,sharp)
    #print(ans)
    for i in range(e):
      do = dot[i]
      sh = sharp[i]
      a += do
      b += sh
      ans = min(ans,min(b-sharp[-1],a-dot[0]))
      
        
    print(ans)
solve()

Fixed submission:
def solve():
  n = int(input())
  s = input()
  
  leftblack = 0
  leftwhite = 0
  rightblack = s.count('#')
  rightwhite = s.count(".")
  
  ans = leftblack+rightwhite
  
  for i in range(n):
    if s[i] == "#":
      leftblack += 1
      rightblack -= 1
    else:
      leftwhite += 1
      rightwhite -= 1
    ans = min(ans,leftblack+rightwhite)
  
  print(ans)
solve()

Buggy python submission (verdict: Runtime Error):
def solve():
  n = int(input())
  s = input()

  ans = 10**15
  a = s.count(".")
  b = s.count("#")
  sharp = []
  dot = []
  tp = 1
  if a == n:
    print("0")
  else:
    for i in range(n-1):

        if s[i] == s[i+1]:
           tp += 1
               
        if s[i] != s[i+1] or i+1 ==n-1:
            if s[i]==".":
                dot.append(tp)
                sharp.append(0)
            else:
                dot.append(0)
                sharp.append(tp)
            tp = 1
    e = len(sharp)
    ans = min(b-sharp[-1],a-dot[0])
    
    for i in range(e):
      do = dot[i]
      sh = sharp[i]
      a += do
      b += sh
      ans = min(ans,min(b-sharp[-1],a-dot[0]))
      
        
    print(ans)
solve()

Fixed submission:
def solve():
  n = int(input())
  s = input()
  
  leftblack = 0
  leftwhite = 0
  rightblack = s.count('#')
  rightwhite = s.count(".")
  
  ans = leftblack+rightwhite
  
  for i in range(n):
    if s[i] == "#":
      leftblack += 1
      rightblack -= 1
    else:
      leftwhite += 1
      rightwhite -= 1
    ans = min(ans,leftblack+rightwhite)
  
  print(ans)
solve()