Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
input(); n = list(map(int, input().split()))
prod = 1
for i in n:
    prod *= i
print(-1 if prod > 10**18 else prod)

Fixed submission:
input(); n = list(map(int, input().split()))
if 0 in n:
    print(0); exit()
prod = 1
for i in n:
    prod *= i
    if prod > 10**18: prod = -1; break
print(prod)
Buggy python submission (verdict: Runtime Error):
n = int((input())
t = n % 10
if t == 0 or t == 1 or t == 6 or t == 8:
	print('pon')
elif t == 3:
	print('bon')
else:
	print('hon')

Fixed submission:
n = int(input())
t = n % 10
if t == 0 or t == 1 or t == 6 or t == 8:
	print('pon')
elif t == 3:
	print('bon')
else:
	print('hon')
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
print(n(n-1)//2 + m(m-1)//2)

Fixed submission:
n, m = map(int, input().split())
print(n*(n-1)//2 + m*(m-1)//2)

Buggy python submission (verdict: Runtime Error):
def nCr(n, r): 
  return (fact(n) / (fact(r)  
                * fact(n - r))) 
  
# Returns factorial of n 
def fact(n): 
  res = 1  
  for i in range(2, n+1): 
	res = res * i 
  return res
n, m = list(map(int, input().split()))

print(nCr(n + m, n) * nCr(n + m - 1, n - 1) + nCr(n + m, m) * nCr(n + m - 1, m - 1))

Fixed submission:
n, m = map(int, input().split())
print(n*(n-1)//2 + m*(m-1)//2)
Buggy python submission (verdict: Runtime Error):
l = int(input())
d = l/3
print(d^3)

Fixed submission:
l = int(input())
d = l/3
print(d**3)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))
i, j = 0, 1
while i < len(lst):
    if lst[i] != j:
        lst.pop(i)
    else:
        i += 1
        j += 1

if not lst:
    print(-1)
else:
    print(n - len(lst))


Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
i = 1
for j in lst:
    if i == j:
        i += 1

print(-1 if i == 1 else n - i + 1)
Buggy python submission (verdict: Runtime Error):
if ( a + b )%2 == 0:
	print((a+b)//2)
else:
	print('IMPOSSIBLE')

Fixed submission:
a,b = map(int, input().split())
if ( a + b )%2 == 0:
	print((a+b)//2)
else:
	print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
print(int(input()) * int(input()))

Fixed submission:
inputs = [int(i) for i in input().split()]
print(inputs[0] * inputs[1])
Buggy python submission (verdict: Runtime Error):
K = input()
S = input()
if len(s) > int(k):
  print(s[:k]+'...')
else:
  print(s)

Fixed submission:
K = int(input())
S = input()
if len(S) > K:
	print(S[:K] + '...')
else:
	print(S)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations
N, M, X = [int(i) for i in input().split()]
lines = [input().split() for i in range(N)]
flag = False
prices = []
for num_books in range(1, N + 1):
    for combo in combinations(lines, num_books):
        price = 0
        skills = [0 for i in range(M)]
        for book in combo:
            price += int(book[0])
            for ind, skill in enumerate(book[1:]):
                skills[ind] += int(skill)
        if not [i for i in skills if i < X]:
            flag = True
            prices.append(price)
            break
if not flag:
    print(-1)
else:
    print(min(prices))

Fixed submission:
daude1 = input()
daude2 = input()
if daude1 == daude2[:-1]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
daude = input()
daude1 = input()
return daude == daude1[:-1]

Fixed submission:
daude1 = input()
daude2 = input()
if daude1 == daude2[:-1]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(n):
    flg = True
    for j in range(i):
        if p[i] > p[j]:
            flg = False
    if flg:
        count += 1

print(count)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))

m = p[0]
count = 1
for i in range(1,n):
    if m >= p[i]:
        count += 1
    m = min(m, p[i])
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
flg = False

for i in range(10)[1:]:
  ans = n/i
  r = n%i
  if(ans<10 and r ==0):
    flg = True
    break
if(flg):
    print("Yes")
else:
    print("No")

Fixed submission:
ams = 0
a,b = map(int, input().split())
if (a >=10 or b >= 10):
  ans = -1
else:
  ans = a*b
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dic = {}; ans = []
for i in range(n+1)[1:]:
    dic.setdefault(a[i-1],[]).append(i)
heapq.heapify(a)
for i in range(n):
    res = heapq.heappop(a)
    ans.append(dic[res][0])
print(*ans)

Fixed submission:
import heapq
n = int(input())
a = list(map(int, input().split()))
dic = {}; ans = []
for i in range(n+1)[1:]:
    dic.setdefault(a[i-1],[]).append(i)
heapq.heapify(a)
for i in range(n):
    res = heapq.heappop(a)
    ans.append(dic[res][0])
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

def trial_division(n):
    f = 2
    d = {}
    while n > 1:
        if n % f == 0:
            d[f] = d.get(f,0) + 1
            n//=f
        else:
            f += 1
    return d

g = gcd(*map(int, input().split()))
ans = trial_division(g)
print(len(ans)+1)

Fixed submission:
from fractions import gcd
g = gcd(*map(int, input().split()))

f = 2
d = {}
while f**2 <= g:
    if g % f:
        f += 1
    else:
        d[f] = d.get(f,0) + 1
        g//=f

if g>1:
    d[g] =d.get(g,0) + 1

print(len(d)+1)

Buggy python submission (verdict: Runtime Error):
from math import gcd

def trial_division(n):
    f = 2
    d = {}
    while n > 1:
        if n % f == 0:
            d[f] = d.get(f,0) + 1
            n//=f
        else:
            f += 1
    return d

g = gcd(*map(int, input().split()))
ans = trial_division(g)
print(len(ans)+1)

Fixed submission:
from fractions import gcd
g = gcd(*map(int, input().split()))

f = 2
d = {}
while f**2 <= g:
    if g % f:
        f += 1
    else:
        d[f] = d.get(f,0) + 1
        g//=f

if g>1:
    d[g] =d.get(g,0) + 1

print(len(d)+1)
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
s = input().split()
ss = list(map(int, s))

for i in range(m):
    ss = sorted(ss, reverse = True)
    ss[0] = ss[0]//2

print(sum(ss))

Fixed submission:
s = input()
dict = {1:'Sunny', 2:'Cloudy', 3:'Rainy'}
for i in range(1,4):
    if s == dict[i]:
        if i < 3:
            print(dict[i+1])
            break
        else:
            print(dict[1])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
s = list(map(int, input().split()))
for i in range(m):
    idx = s.index(max(s))
    s[idx] = max(s)//2
print(sum(s))

Fixed submission:
import heapq

n, m = map(int,input().split())
s = list(map(int, input().split()))
s = list(map(lambda x: x * (-1), s))
heapq.heapify(s)

for i in range(m):
    mx = heapq.heappop(s) * (-1)
    mx = mx//2
    heapq.heappush(s, mx*(-1))
    
print(sum(s)*(-1))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
s = list(map(int, input().split()))
for i in range(m):
    s.sort()
    s[-1] = s[-1]//2
print(sum(s))

Fixed submission:
import heapq

n, m = map(int,input().split())
s = list(map(int, input().split()))
s = list(map(lambda x: x * (-1), s))
heapq.heapify(s)

for i in range(m):
    mx = heapq.heappop(s) * (-1)
    mx = mx//2
    heapq.heappush(s, mx*(-1))
    
print(sum(s)*(-1))

Buggy python submission (verdict: Time Limit Exceeded):
import math
n, m = map(int,input().split())
s = input().split()
ss = list(map(int, s))

for i in range(m):
    ss = sorted(ss, reverse = True)
    ss[0] = math.floor(ss[0]/2)

print(sum(ss))


Fixed submission:
import heapq

n, m = map(int,input().split())
s = list(map(int, input().split()))
s = list(map(lambda x: x * (-1), s))
heapq.heapify(s)

for i in range(m):
    mx = heapq.heappop(s) * (-1)
    mx = mx//2
    heapq.heappush(s, mx*(-1))
    
print(sum(s)*(-1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*p, = map(int,input().split())

ans = 0
for i in range(n-1):
    for j in range(n)[i+1:]:
        ans += sorted(p[i:j+1])[-2]

print(ans)

Fixed submission:
N = int(input())
*p, = map(int, input().split())

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

E = [(v,i+1) for i,v in enumerate(p)]
E.sort()

ans = 0
for v,i in E:
  r0 = RR[i]; r1 = RR[r0]
  l0 = LL[i]; l1 = LL[l0]
  RR[l0] = r0; LL[r0] = l0
  
  ans += ((r1 - r0)*(i-l0)+(r0-i)*(l0 - l1))*v

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for _ in range(N):
    S.append("".join(sorted(list(input()))))

ans = 0
memo = [x for x in range(N)]
for x in range(N-1):
    for y in range(1,N):
        if S[x] == S[y] and memo[x] != memo[y]:
            memo[y] = memo[x]

for x in range(N):
    con = memo.count(x)
    if con != 0:
        ans += con*(con-1)//2

print(ans)

Fixed submission:
dict = {}
ans = 0
for i in open(0):
    i = tuple(sorted(i))
    t = dict.get(i,0)
    dict[i] = t+1
    ans += t
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().sprit())
print(min(c, b//a))

Fixed submission:
a,b,c = map(int, input().split())
print(min(c, b//a))
Buggy python submission (verdict: Runtime Error):
k,s = map(int, input().split())

count = 0
for i in range(k+1):
    if s-i > k:
        rang = k
    else:
        rang = s-i
    for j in range(rang+1):
        if s-i-j < 0:
            continue
        elif s-i-j > k:
            rangg = k
        else:
            rang = s-i-j
        for h in range(rang+1):
            if i+j+h == s:
                count += 1

print(count)

Fixed submission:
print(str(input().replace(","," ")))

Buggy python submission (verdict: Runtime Error):
k,s = map(int, input().split())

count = 0
for i in range(k+1):
    for j in range(k+1):
        if s - (i+j) <= k:
            count += 1

print(count)

Fixed submission:
print(str(input().replace(","," ")))
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int, input().split())

count = 0
for i in range(k+1):
    if s-i > k:
        rang = k
    else:
        rang = s-i
    for j in range(rang+1):
        if s-i-j < 0:
            continue
        elif s-i-j > k:
            rangg = k
        else:
            rang = s-i-j
        for h in range(rang+1):
            if i+j+h == s:
                count += 1

print(count)

Fixed submission:
k,s = map(int, input().split())

count = 0
for i in range(k+1):
    for j in range(k+1):
        if s-i-j > k or s-i-j < 0:
            continue
        else:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int, input().split())

count = 0
for i in range(k+1):
    for j in range(k+1):
        for h in range(k+1):
            if i+j+h == s:
                count += 1

print(count)

Fixed submission:
k,s = map(int, input().split())

count = 0
for i in range(k+1):
    for j in range(k+1):
        if s-i-j > k or s-i-j < 0:
            continue
        else:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    n = int(read.input())
    a = list(map(int,read().split()))
    ans = 1
    flag = True
    for num in a:
      ans *= num
      if ans > 10**18:
        flag = False
        break
    print(ans if flag else -1)
 
if __name__ == "__main__":
    main()

Fixed submission:
import sys
#import cython
 
def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    n = int(read())
    a = list(map(int,read().split()))
    ans = 1
    flag = True
    iszero = any(num == 0 for num in a)
    if iszero: print(0)
    else:
        for num in a:
          ans *= num
          if ans > 10**18:
            flag = False
            break
        print(ans if flag else -1)
 
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
M=998244353
n,m,k=map(int,input().split())
p,c=[m]*n,[1]*n
for i in range(1,n):
  p[i]=p[i-1]*(m-1)%M
  c[i]=c[i-1]*(n-i)*pow(i,M-2,M)%M
print(sum(p[n-i-1]*c[i]%M for i in range(k+1))%M)

Fixed submission:
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    s = read()
    t = read()
    print("Yes" if t[:-1] == s else "No")
    #a, b, c = map(int,read().split())
    #l = [int(read()) for _ in range(5)]
    

 
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    A, B, C, K = map(int,read().split())
    t = [1]*A+[0]*B+[-1]*C
    print(sum(t[:K]))
    #a, b, c = map(int,read().split())
    #l = [int(read()) for _ in range(5)]
    

 
if __name__ == "__main__":
    main()


Fixed submission:
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    A, B, C, K = map(int,read().split())
    print(K if A >= K else A if K-A <= B else A-(K-A-B))
    #a, b, c = map(int,read().split())
    #l = [int(read()) for _ in range(5)]
    

 
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    A, B, C, K = map(int,read().split())
    t = [1]*A+[0]*B+[-1]*C
    print(sum(t[:K]))
    #a, b, c = map(int,read().split())
    #l = [int(read()) for _ in range(5)]
    

 
if __name__ == "__main__":
    main()

Fixed submission:
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    A, B, C, K = map(int,read().split())
    print(K if A >= K else A if K-A <= B else A-(K-A-B))
    #a, b, c = map(int,read().split())
    #l = [int(read()) for _ in range(5)]
    

 
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def get_keys(d, val):
    return [k for k, v in d.items() if v == val]
    
def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    N, K  = map(int,read().split())
    A = list(map(int,read().split()))
    
    g = collections.defaultdict(int)
    for i, val in enumerate(A):
        g[i + 1] = val
        
    v = collections.defaultdict(int)
    cnt = 0
    cur = 1
    p = 0
    mp = 0
    while True:
        if v[cur] > 0:
            p = cnt - v[cur]
            mp = v[cur]
            break
        v[cur] = cnt
        cnt += 1
        cur = g[cur]
    
    print(get_keys(v, (K-mp)%p + mp)[0] if K >= mp else get_keys(v, K)[0])


 
if __name__ == "__main__":
    main()

Fixed submission:
import sys
import collections
#import cython
def get_keys(d, val):
    return [k for k, v in d.items() if v == val]
    
def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    N, K  = map(int,read().split())
    A = list(map(int,read().split()))
    
    g = collections.defaultdict(int)
    for i, val in enumerate(A):
        g[i + 1] = val
        
    v = collections.defaultdict(int)
    cnt = 0
    cur = 1
    p = 0
    mp = 0
    while True:
        if v[cur] > 0 or cnt > 2*10**5:
            p = cnt - v[cur]
            mp = v[cur]
            break
        v[cur] = cnt
        cnt += 1
        cur = g[cur]
    
    print(get_keys(v, (K-mp)%p + mp)[0] if K >= mp else get_keys(v, K)[0])


 
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
h, a = map(int, input())
print(h//a+1 if h%a != 0 else h//a)

Fixed submission:
h, a = map(int, input().split())
print(h//a+1 if h%a != 0 else h//a)
Buggy python submission (verdict: Runtime Error):
K, X = map(int,input().split())
print("Yes" if 500*K >= X else "No")

Fixed submission:
K, X = map(int,input().split())
print("Yes" if 500*K >= X else "No")
Buggy python submission (verdict: Runtime Error):
T = input("")
S = input("")
print("T"+"S")

Fixed submission:
A, B = input().split()
print(B+A)

Buggy python submission (verdict: Runtime Error):
A, B = input().strip()
print(B+A)

Fixed submission:
A, B = input().split()
print(B+A)

Buggy python submission (verdict: Runtime Error):
A, B = input().strip()
print(A+B)

Fixed submission:
A, B = input().split()
print(B+A)

Buggy python submission (verdict: Runtime Error):
def isPrime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
  
num = input()
 
res = True
ans = 0
if num > 2 and num%2 == 0:
  num += 1
while(res):
  if isPrime(num):
    print(num)
    break
  num += 2

Fixed submission:
A, B = input().split()
print(B+A)
Buggy python submission (verdict: Runtime Error):
def isPrime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
  
num = input()
 
res = True
ans = 0
if num > 2 and num%2 == 0:
  num += 1
while(res):
  if isPrime(num):
    print(num)
    break
  num += 2

Fixed submission:
import math

def isPrime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
  
num = int(input())
 
res = True
ans = 0
if num > 2 and num%2 == 0:
  num += 1
while(res):
  if isPrime(num):
    print(num)
    break
  num += 2

Buggy python submission (verdict: Runtime Error):
def isPrime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
  
num = input()
 
res = True
ans = 0
if num > 2 and num%2 == 0:
  num += 1
while(res):
  if isPrime(num):
    return num
  num += 2

Fixed submission:
import math

def isPrime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
  
num = int(input())
 
res = True
ans = 0
if num > 2 and num%2 == 0:
  num += 1
while(res):
  if isPrime(num):
    print(num)
    break
  num += 2

Buggy python submission (verdict: Runtime Error):
def isPrime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
  
num = input()
 
res = True
ans = 0
if num > 2 and num%2 == 0:
  num += 1

Fixed submission:
import math

def isPrime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
  
num = int(input())
 
res = True
ans = 0
if num > 2 and num%2 == 0:
  num += 1
while(res):
  if isPrime(num):
    print(num)
    break
  num += 2

Buggy python submission (verdict: Runtime Error):
def isPrime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
  
num = input()

res = True
ans = 0
if num > 2 and num%2 == 0:
  num += 1
while(res):
  if isPrime(num):
    return num
  num += 2
  
  

Fixed submission:
import math

def isPrime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
  
num = int(input())
 
res = True
ans = 0
if num > 2 and num%2 == 0:
  num += 1
while(res):
  if isPrime(num):
    print(num)
    break
  num += 2
Buggy python submission (verdict: Runtime Error):
lis = [1,2,3]
print(lis.remove(input()).remove(input())[0])

Fixed submission:
print(6-int(input())-int(input()))

Buggy python submission (verdict: Runtime Error):
lis = [1,2,3]
print(lis.remove(input()).remove(input()))

Fixed submission:
print(6-int(input())-int(input()))
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
 
A, B =map(int,input().split())
print(lcm(A, B))

Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
A, B =map(int,input().split())
print(lcm(A, B))

Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B = a,b=map(int,input().split())
print(lcm(A, B))

Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
A, B =map(int,input().split())
print(lcm(A, B))
Buggy python submission (verdict: Runtime Error):
import sys
read = lambda: sys.stdin.readline().rstrip()

def counting_tree(N, D):
    tot = 1
    cnt = [0]*N
    # cnt = collections.Counter(D)
    for i in D:
        cnt[i]+=1
        
    for i in D[1:]:
        tot = tot*cnt[i-1]%998244353

    return tot if D[0]!=0 else 0

def main():
    
    N0 = int(read().split())
    D0 = tuple(map(int, read().split()))

    res = counting_tree(N0, D0)

    print(res)

if __name__ == "__main__":
    main()

Fixed submission:
import sys
read = lambda: sys.stdin.readline().rstrip()

def counting_tree(N, D):
    tot = 1
    
    # cnt = collections.Counter(D)
    cnt = [0]*N
    for i in D:
        cnt[i]+=1

    for i in D[1:]:
        tot = tot * cnt[i-1]%998244353

    return tot if D[0]==0 else 0

def main():
    
    N0 = int(read())
    D0 = tuple(map(int, read().split()))

    res = counting_tree(N0, D0)

    print(res)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

black_right, min_val = 0, 2000001
white_left = s.count('.')
ans = []

for moji in s:
    if moji == '.':
        white_left -=1
    else:
        black_right += 1
    ans.append[white_left+black_right]
    #min_val = min(min_val, white_left+black_right)

print(min(ans))

Fixed submission:
import sys
input = sys.stdin.readline
 
 
def main():
    N = int(input())
    S = input().strip()
    ans = 0
    x = 0
    for c in S:
        if c == "#":
            x += 1
        else:
            if x > 0:
                ans += 1
                x = max(x-1, 0)
    print(ans)
 
 
if __name__ == '__main__':
    main()

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

black_right, min_val = 0, 2000001
white_left = s.count('.')

for moji in range(s):
    if moji == '.':
        white_left -=1
    else:
        black_right += 1
    min_val = min(min_val, white_left+black_right)

print(min_val)

Fixed submission:
import sys
input = sys.stdin.readline
 
 
def main():
    N = int(input())
    S = input().strip()
    ans = 0
    x = 0
    for c in S:
        if c == "#":
            x += 1
        else:
            if x > 0:
                ans += 1
                x = max(x-1, 0)
    print(ans)
 
 
if __name__ == '__main__':
    main()