Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03698 (python)

Fixed submission:
l=list(input())
e=set(l)
if len(l)-len(e) == 0:
    print("yes")
else:
    print("no")

Buggy submission (verdict: Runtime Error):
s=list(input())
s.sort()
j=0
if len(s) == 1:j=0
else: j=1
for i in s:
    if j == len(s)-1:print("yes")
        break
    if i == s[j]:print("no")
        break
    j+=1
Problem p03067 (python)

Fixed submission:
a,b,c=map(int, input().split())
if a>c>b or b>c>a:
    print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
a=input(int())
b=input(int())
c=input(int())
if a>c>b or b>c>a:
    print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
a=input(int())
b=input(int())
c=input(int())
if a>c>b or b>c>a:
    print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
a=input(int())
b=input(int())
c=input(int())
if a>c or b>c:
    print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input())
if b>c:
    print("Yes")
else:print("No")
Problem p03337 (python)

Fixed submission:
A,B=map(int,input().split())
print(max(A+B,A-B,A*B))

Buggy submission (verdict: Runtime Error):
A=input(int())
B=input(int())
print(max(A+B,A-B,A*B))
Problem p03493 (python)

Fixed submission:
a,b,c=map(int,input())
print(a+b+c)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
 
ans = 0
 
while all(a % 2 == 0 for a in A):
    ans += 1
    for i in range(N):
        A[i] = int(A[i] / 2)
 
print(ans)
Problem p03632 (python)

Fixed submission:
A, B, C, D = map(int, input().split())
print(max(0, min(B, D) - max(A, C)))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
c,d=map(int,input().split())
if b>c:
    print(b-c)
elese:print("0")
Problem p03067 (python)

Fixed submission:
s = [int(i) for i in input().split(" ")]
count = 0

if s[0] < s[1]:
    for i in range(s[0], s[1]):
        if i == s[2]:
            print("Yes")
            count = 1
            break

else:
    for i in range(s[1], s[0]):
        if i == s[2]:
            print("Yes")
            count = 1
            break

if count == 0:
    print("No")

Buggy submission (verdict: Runtime Error):
a = int(input())
mozi = input()
b = int(input())

test = mozi[b]

ans = ""

for i in mozi:
    if i == test:
Problem p03067 (python)

Fixed submission:
x=input().split()
z=[int(v) for v in x]

if z[0]<z[2] and z[1]>z[2] :
  print("Yes")
elif z[0]>z[2] and z[1]<z[2] :
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()

if a<c and b>c :
  print("Yes")
elif a>c and b<c :
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()

if a<c and b>c :
  print("Yes")
elif a>c and b<c :
  print("Yes")
else:
  print("No)
Problem p03085 (python)

Fixed submission:
x=input()
if x=="A" :
    print("T")
elif x=="C" :
    print("G")
elif x=="G" :
    print("C")
else:
    print("A")

Buggy submission (verdict: Runtime Error):
x=input()
if x=="A" :
    print("T")
elif x=="C" :
    print("G")
elif x=="G" :
    print("C")
else:
    print(A)
Problem p03351 (python)

Fixed submission:
a,b,c,d = [int(i) for i in input().split()]
if abs(b-a)<=d and abs(c-b)<=d:
    print('Yes')
elif abs(c-a)<=d:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
X = int(input())
if X==1:
    print('1')
    sys.exit()
maxnum = 0
for i in range(2,int(np.sqrt(X))+1):
    num = i
    while num <= X:
        num *= i
        if num/i >maxnum:
            maxnum = num/i
print(int(maxnum))

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
X = int(input())
if X==1:
    print('1')
    sys.exit()
maxnum = 0
for i in range(2,int(np.sqrt(X))+1):
    num = i
    while num <= X:
        num *= i
        if num/i >maxnum:
            maxnum = num/i
print(int(maxnum))
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
field = [list(input()) for i in range(H)]
flag = []
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for i in range(H):
    for j in range(W):
        if field[i][j] == '#':
            inflag = [False] * 4
            for k in range(4):
                ni = i + dx[k]
                nj = j + dy[k]
                if ni < 0 or ni >= H or nj < 0 or nj >= W:
                    inflag[k] = False
                elif field[ni][nj] == '#':
                    inflag[k] = True
            flag.append(any(inflag))
        elif field[i][j] == '.':
            flag.append(True)

if all(flag):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
field = [list(input()) for i in range(H)]
flag = [[False] * H] * W
metaflag = []
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for i in range(H):
    for j in range(W):
        if field[i][j] == '#':
            inflag = [False] * 4
            for k in range(4):
                ni = i + dx[k]
                nj = j + dy[k]
                if ni < 0 or ni >= H or nj < 0 or nj >= W:
                    inflag[k] = False
                elif field[ni][nj] == '#':
                    inflag[k] = True
            flag[i][j] = any(inflag)
        elif field[i][j] == '.':
            flag[i][j] = True
        metaflag.append(flag[i][j])

if all(metaflag):
    print('Yes')
else:
    print('No')
Problem p03106 (python)

Fixed submission:
A,B,K = map(int, input().split())
A = [i for i in range(1, (A+1)) if A%i==0]
B = [i for i in range(1, (B+1)) if B%i==0]
common_list = []
for i in A:
        for j in B:
                if i == j:
                        common_list.append(i)
print(common_list[-K])

Buggy submission (verdict: Runtime Error):
A,B,K = map(int, input().split())
lista = []
listb = []
for i in range(1, (A + 1)):
        if A%i==0:
                lista.append(i)
for i in range(1, (B + 1)):
        if B%i==0:
                listb.append(i)
common_list = []
for i in lista:
        for j in listb:
                if i == j:
					common_list.append(i)
print(common_list[-K])
Problem p03145 (python)

Fixed submission:
AB, BC, CA = map(int, input().split())
print(AB * BC // 2)

Buggy submission (verdict: Runtime Error):
B,BC,CA=map(int,input().split())
print(AB*BC//2)
Problem p03239 (python)

Fixed submission:
N,T=map(int,input().split())
List=[list(input().split()) for i in range(N)]
List2=[]
List3=[]
for i in List:
        List2.append([int(s) for s in i])
for i in List2:
        if i[1] <= T:
                List3.append(i[0])
if List3 == []:
        print("TLE")
else:
        print(min(List3))

Buggy submission (verdict: Runtime Error):
N,T=map(int,input().split())
List=[list(input().split()) for i in range(N)]
List2=[]
List3=[]
for i in List:
        List2.append([int(s) for s in i])
for i in List2:
        if i[1] <= T:
                List3.append(i[0])
        else:
                List3.append("TLE")
print(min(List3))

Buggy submission (verdict: Runtime Error):
N,T=map(int,input().split())
List=[list(input().split()) for i in range(N)]
List2=[]
List3=[]
for i in List:
        List2.append([int(s) for s in i])
for i in List2:
        if i[1] <= T:
                List3.append(i[0])
print(min(List3))
Problem p03068 (python)

Fixed submission:
N=int(input())
S=input()
K=int(input())
count=0
for s in S:
    if s==S[K-1]:
        pass
    else:
        S=S[:count] + '*' + S[count+1:]
    count+=1
print(S)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
K=int(input())
count=0
for s in S:
    if s==S[K]:
        pass
    else:
        S=S[:count] + '*' + S[count+1:]
    count+=1
print(S)

Buggy submission (verdict: Runtime Error):
N=input()
S=input()
K=int(input())
count=0
for s in S:
    if s==S[K]:
        pass
    else:
        S=S[:count] + '*' + S[count+1:]
    count+=1
print(S)

Buggy submission (verdict: Runtime Error):
N=input()
S=input()
K=int(input())
count=0
for s in S:
    if s==S[k]:
        pass
    else:
        S=S[:count] + '*' + S[count+1:]
    count+=1
print(S)
Problem p03227 (python)

Fixed submission:
S=input()
if len(S)==2:
    print(S)
elif len(S)==3:
    print(S[::-1])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
count = 0
while count<K:
    if count%2==0:
        if A%2==0:
            A//=2
            B+=A
        else:
            A-=1
            A//=2
            B+=A
    else:
        if B%2==0:
            B//=2
            A+=B
        else:
            B-=1
            B//=2
            A+=B
    count+=1
print(A,B)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
K=int(input())
count = 0
while count<K:
    if count%2==0:
        if A%2==0:
            A//=2
            B+=A
        else:
            A-=1
            A//=2
            B+=A
    else:
        if B%2==0:
            B//=2
            A+=B
        else:
            B-=1
            B//=2
            A+=B
    count+=1
print(A,B)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
K=int(input())
count = 0
while count<K:
    if count%2==0:
        if A%2==0:
            A//=2
            B+=A
        else:
            A-=1
            A//=2
            B+=A
    else:
        if B%2==0:
            B//=2
            A+=B
        else:
            B-=1
            B//=2
            A+=B
    count+=1
print(A,B,count)

Buggy submission (verdict: Runtime Error):
if len(S)==2:
    print(S)
elif len(S)==3:
    print(S[::-1])
Problem p03228 (python)

Fixed submission:
A, B, K = map(int, input().split())
count = 0
while count<K:
    if count%2==0:
        if A%2==0:
            A//=2
            B+=A
        else:
            A-=1
            A//=2
            B+=A
    else:
        if B%2==0:
            B//=2
            A+=B
        else:
            B-=1
            B//=2
            A+=B
    count+=1
print(A,B)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
K=int(input())
count = 0
while count<K:
    if count%2==0:
        if A%2==0:
            A//=2
            B+=A
        else:
            A-=1
            A//=2
            B+=A
    else:
        if B%2==0:
            B//=2
            A+=B
        else:
            B-=1
            B//=2
            A+=B
    count+=1
print(A,B)
Problem p03068 (python)

Fixed submission:
#!/usr/bin/python
# coding: UTF-8

import re

len = int(input())
src = input()
t = int(input())
pt = "[^"+src[t-1]+"]"
print(re.sub(pt,"*",src))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python
# coding: UTF-8

import re

len = int(input())
src = input()
t = int(input())
pt = "[^"+src[t]+"]"
print(re.sub(pt,"*",src))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python
# coding: UTF-8


len = int(input())
src = input()
t = int(input())
pt = src[t]
print(src.replace(pt,"*"))
Problem p03067 (python)

Fixed submission:
a,b,c = map(int,input().split())
if (a<c and c<b) or (a>c and c>b):
       print("Yes")
else:
       print("No")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if (a<c and c<b) or (a>c and c>b):
　　print("Yes")
else:
　　print("No")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if (a<c and c<b) or (a>c and c>b):
print("Yes")
else:
print("No")
Problem p03085 (python)

Fixed submission:
b = input()
if b == "A":
  print("T")
elif b == "T":
  print("A")
elif b == "C":
  print("G")
else:
  print("C")

Buggy submission (verdict: Runtime Error):
b = input()
if b == A:
  print(T)
elif b == T:
  print(A)
elif b == C:
  print(G)
else:
  print(C)
Problem p03264 (python)

Fixed submission:
k = int(input())
if k%2 ==0:
  print((k//2)*(k//2))
else:
  print(((k+1)//2)*((k-1)//2))

Buggy submission (verdict: Runtime Error):
k = int(input())
if k%2 =0:
  print((k/2)**2)
else:
  print(((k+1)/2)*((k-1)/2))
Problem p03069 (python)

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

count_if_all_white = 0
for c in S:
    if c == "#":
        count_if_all_white += 1

l_count = 0
r_count = sum([1 for c in S if c == "."])
count_if_contain_black = l_count+r_count
for c in S:
    if c == "#":
        l_count += 1
    else:
        r_count -= 1
        
    count_if_contain_black = min(count_if_contain_black, l_count+r_count)

print(min(count_if_all_white, count_if_contain_black))

Buggy submission (verdict: Runtime Error):
l_count = 0
r_count = sum([1 for c in S if c == "."])
count_if_contain_black = l_count+r_count
count_if_all_white = 0
for c in S:
    if c == "#":
        l_count += 1
        count_if_all_white += 1
    else:
        r_count -= 1
        
    count_if_contain_black = min(count_if_contain_black, l_count+r_count)

print(min(count_if_all_white, count_if_contain_black))
Problem p03076 (python)

Fixed submission:
a=[]
for i in range(5):
    a.append(int(input()))
b=set(map(lambda x: x%10,a))
if 0 in b:
    b.remove(0)
    if len(b) == 0:
        b.add(10)
print(sum(map(lambda x:(x/10+1)*10 if x%10 != 0 else (x/10)*10,a))+min(b)-10)

Buggy submission (verdict: Runtime Error):
a=[]
for i in range(5):
    a.append(int(input()))
b=set(map(lambda x: x%10,a))
if 0 in b:
    b.remove(0)
print(sum(map(lambda x:(x/10+1)*10 if x%10 != 0 else (x/10)*10,a))+min(b)-10)
Problem p03076 (python)

Fixed submission:
import itertools

don = [int(input()) for i in range(5)]

final_time = float('inf')
for v in itertools.permutations(don):
  time = 0
  for j in v:
    while(time % 10 != 0):
      time += 1
    time += j
  final_time = min(final_time, time)
print(final_time)

Buggy submission (verdict: Runtime Error):
import itertools

don = [int(input()) for i in range(5)]

final_time = inf
for v in itertools.permutations(don):
  time = 0
  for j in v:
    while(time % 10 != 0):
      time += 1
    time += j
  final_time = min(final_time, time)
print(final_time)
Problem p03136 (python)

Fixed submission:
N = input()
a = list(map(int, input().split()))
amax = max(a)
a.remove(amax)
sum = 0
for i in a:
  sum += i
if amax < sum:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = input()
a = list(map(int, input().split()))
amax = max(a)
a.pop(amax)
sum = 0
for i in a:
  sum += i
if amax < sum:
  print("Yes")
else:
  print("No")
Problem p03436 (python)

Fixed submission:
from queue import Queue

inf = 10 ** 20

def bfs(H, W, s):
    d = [[inf for i in range(W)] for j in range(H)]
    q = Queue()

    d[0][0] = 1
    q.put([0, 0])

    dx = (0, -1, 1, 0)
    dy = (-1, 0, 0, 1)

    while not q.empty():
        p = q.get()
        x = p[0]
        y = p[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if(nx >= 0 and nx < H and ny >= 0 and ny < W):
                if(s[nx][ny] == '.' and d[x][y] + 1 < d[nx][ny]):
                    d[nx][ny] = d[x][y] + 1
                    q.put([nx, ny])

    return d[H-1][W-1]

H, W = map(int, input().split())
s = []
wnum = 0
for i in range(H):
    s.append(input())
    for j in range(W):
        if(s[i][j] == "."):
            wnum += 1
d = bfs(H, W, s)
if(d == inf):
    print("-1")
else:
    print(wnum - d)

Buggy submission (verdict: Runtime Error):
from queue import Queue

def bfs(H, W, s):
    inf = 10 ** 20
    d = [[inf for i in range(W)] for j in range(H)]
    q = Queue()

    d[0][0] = 1
    q.put([0, 0])

    dx = (0, -1, 1, 0)
    dy = (-1, 0, 0, 1)

    while not q.empty():
        p = q.get()
        x = p[0]
        y = p[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if(nx >= 0 and nx < H and ny >= 0 and ny < W):
                if(s[nx][ny] == '.' and d[x][y] + 1 < d[nx][ny]):
                    d[nx][ny] = d[x][y] + 1
                    q.put([nx, ny])

    return d[H-1][W-1]

H, W = map(int, input().split())
s = []
wnum = 0
for i in range(H):
    s.append(input())
    for j in range(W):
        if(s[i][j] == "."):
            wnum += 1
d = bfs(H, W, s)
if(d == INF):
    print("-1")
else:
    print(wnum - d)
Problem p03282 (python)

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

ans = 0
if len(S) == 1:
    ans = S[0]
else:
    i = 0
    for i in range(len(S)):
        if S[i] != '1' and i < K:
            ans = S[i]
            break
        else:
            ans = S[0]
   
print(ans)

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

ans = 0
if len(S) == 1:
    ans = S[0]
else:
    i = 0
    while S[i] == '1':
        i += 1
    ans = S[i]
print(ans)

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

if S[0] != '1':
    print(S[0])
else:
    print(S[1])
Problem p03309 (python)

Fixed submission:
import statistics
import math

N = int(input())
A = list(map(int, input().split(" ")))
A_i = [0]*N
K_1 = 0
K_2 = 0
K_3 = 0


for i in range(N):
    A_i[i] = A[i] - i - 1

try:
    b_1 = statistics.mode(A_i)
except:
    b_1 = int(statistics.mean(A_i))

b_2= int(statistics.mean(A_i))
b_3 = int(statistics.median(A_i))

for i in range(N):
    K_1 = K_1 + abs(A_i[i] - b_1)
    K_2 = K_2 + abs(A_i[i] - b_2)
    K_3 = K_3 + abs(A_i[i] - b_3)

print(min(K_1, K_2, K_3))

Buggy submission (verdict: Runtime Error):
import statistics
import math

N = int(input())
A = list(map(int, input().split(" ")))
A_i = [0]*N
K_1 = 0
K_2 = 0
K_3 = 0

for i in range(N):
    A_i[i] = A[i] - i - 1

b_0 = statistics.mode(A_i)

b_1 = int(b_0)
b_2 = b_1 - 1
b_3 = b_1 + 1

for i in range(N):
    K_1 = K_1 + abs(A_i[i] - b_1)
    K_2 = K_2 + abs(A_i[i] - b_2)
    K_3 = K_3 + abs(A_i[i] - b_3)

print(min(K_1, K_2, K_3))
Problem p03339 (python)

Fixed submission:
N = int(input())
direction = list(input())
change = [0]*(N+1)
# print(direction)
change[0] = direction.count("E")
# print(change)
for i in range(N):
    f_n = 0
    f_p = 0
    if direction[i] == "E":
        f_n = 1
    else:
        f_p = 1
    change[i+1] = change[i] - f_n + f_p
# print(change)
print(min(change))

Buggy submission (verdict: Runtime Error):
N = int(input())
direction = list(input())
change = [0]*N
change[0] = direction.count("E")
 
for i in range(1, N):
    f_n = 0
    f_p = 0
    if direction[i] == "E":
        f_n = 1
    if direction[i1] == "W":
        f_p = 1
    change[i] = change[i-1] - f_n + f_p
print(min(change))
Problem p03353 (python)

Fixed submission:
# coding: utf-8
# Your code here!

from functools import cmp_to_key
s = input()
K = int(input())
 
e = set([])
 
def cmp(a, b):
    if a == b: return 0
    return -1 if a < b else 1
    
def substring_sort(a,b):
    if len(a) != len(b):
        return cmp(len(a), len(b))
    else:
        return cmp(a,b)
 
for i in range(1,K+1):
    for j in range(len(s)):
    #     if len(e) < 5:
    #         e.add(s[j:j+i])
    #     if len(e) == 5:
    #         break
    # else:
    #     continue
    # break
        e.add(s[j:j+i])
# print(e)
# result = sorted(e,key=cmp_to_key(substring_sort),reverse=True)
result = sorted(e)
# print(result)
print(result[K-1])

Buggy submission (verdict: Runtime Error):

from functools import cmp_to_key
s = input()
K = int(input())
 
e = set([])
 
def cmp(a, b):
    if a == b: return 0
    return -1 if a < b else 1
    
def substring_sort(a,b):
    if len(a) != len(b):
        return cmp(len(a), len(b))
    else:
        return cmp(a,b)
 
for i in range(1,5):
    for j in range(len(s)):
    #     if len(e) < 5:
    #         e.add(s[j:j+i])
    #     if len(e) == 5:
    #         break
    # else:
    #     continue
    # break
        e.add(s[j:j+i])
# print(e)
# result = sorted(e,key=cmp_to_key(substring_sort),reverse=True)
result = sorted(e)
# print(result)
print(result[K-1])
Problem p03241 (python)

Fixed submission:
import math

N, M = map(int, input().split(" "))
div1 = []
div2 = []

for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        div1 += (i,)
        div2 += (M//i,)
for d in div2:
    if d * N <= M:
        print(d)
        break
else:
    div1 = div1[::-1]
    for d in div1:
        if d * N <= M:
            print(d)
            break

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
div1 = []
div2 = []

for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        div1 += (i,)
        div2 += (M//i,)
for d in div2:
    if d * N <= M:
        print(d)
        break
else:
    div1 = div1[::-1]
    for d in div1:
        if d * N <= M:
            print(d)
            break
Problem p03694 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))

print(max(a) - min(a))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

print(max(a) - min(a))
Problem p03068 (python)

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

for i in range(N):
    if(S[i] != S[K-1]):
        S[i] = '*'

S = "".join(S)

print(S)

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

 
for i in range(N):
    if(S[i] != S[K]):
        S[i] = '*'
 
S = "".join(S)
 
print(S)

Buggy submission (verdict: Runtime Error):

N = int(input())
S = list(input())
K = int(input())

print(S[K])

for i in range(N):
    if(S[i] != S[K]):
        S[i] = '*'

S = "".join(S)

print(S)
Problem p03433 (python)

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

res = N%500
if A >= res:
	print("Yes")
else:
	print("No")

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

res = N%500
if A=>res:
	print("Yes")
else:
	print("No")

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

res = N%500
if A=>res
	print("Yes")
else
	print("No")
Problem p03069 (python)

Fixed submission:
N = int(input())
S = input()
s = [S[i: i + 1] for i in range(N)]
bcount = 0
wcount = 0
for word in s:
    if word == '.':
        wcount += 1
ans = wcount
preans = ans
for word in s:
    if word == '#':
        preans += 1
    else:
        preans -= 1
    ans = min(ans, preans)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
s = [S[i: i + 1] for i in range(N)]
preans = 0
pew = 0
bflag = 0
b2w = 0
for i, word in enumerate(s):
    if bflag == 0:
        if word == '#':
            bflag = 1
    else:
        if word == '.':
            b2w = 1
    if b2w == 1:
        if word == '.':
            preans += 1
skip = 1
ans2 = 0
wcount = 0
bcount = 0
for i, word in enumerate(s):
    if b2w > skip:
        ans = min(preans, preans + bcount - wcount)
        preans = preans + bcount - wcount
        skip += 1
        wcount = 0
        bcount = 0

    if word == '#':
        bcount += 1

    if bflag == 0:
        if word == '#':
            bflag = 1
    else:
        if word == '.':
            b2w += 1
            bflag = 0

    if b2w == skip and word == '.':
        wcount += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
s = [S[i: i + 1] for i in range(N)]
preans = 0
pew = 0
bflag = 0
b2w = 0
for i, word in enumerate(s):
    if bflag == 0:
        if word == '#':
            bflag = 1
    else:
        if word == '.':
            b2w = 1
    if b2w == 1:
        if word == '.':
            preans += 1
skip = 1
ans2 = 0
for i, word in enumerate(s):
    if b2w > skip:
        ans = min(preans, preans + bcount - wcount)
        preans = preans + bcount - wcount
        skip += 1
        wcount = 0
        bcount = 0

    if word == '#':
        bcount += 1

    if bflag == 0:
        if word == '#':
            bflag = 1
        else:
    else:
        if word == '#':
        else:
            b2w += 1
            bflag = 0

    if b2w == skip and word == '.':
        wcount += 1
print(ans)

Buggy submission (verdict: Runtime Error):
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))