Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += (lcm_ // A[i]) % mod

print(ans % mod)


Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += lcm_ // A[i]

print(ans % mod)

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
sum_A = 0
for i in range(N):
    lcm_ = lcm(lcm_, A[i])
    sum_A += 1 / A[i]

ans = lcm_ * sum_A % mod

print(int(ans % mod))

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += lcm_ // A[i]

print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += (lcm_ // A[i]) % mod

print(ans % mod)

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += lcm_ // A[i]

print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += (lcm_ // A[i]) % mod

print(ans % mod)

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += lcm_ // A[i]

print(ans % mod)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
mod = 10 ** 9 + 7

A.sort()
for i in range(N-K):
    fs = A[i+K] - A[i]
    ans += fs % mod

print(ans % mod)

Fixed submission:
c = input()
print(chr(ord(c)+1))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0
i = 0
while True:
    x = (2 * 5 * (5 ** i))
    if x <= N:
        ans += N // x
        i += 1

print(ans)

Fixed submission:
N = int(input())

ans = 0
if N % 2 == 0:
    i = 0
    while True:
        x = (2 * 5 * (5 ** i))
        if x > N:
            break
        ans += N // x
        i += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input())

y = X - X // 100 * 100
if y // (X // 100) < 5:
    print(1)
elif y // (X // 100) == 5 and y % (X // 100) == 0:
    print(1)
else:
    print(0)

Fixed submission:
X = int(input())

if X < 100:
    print(0)
else:
    y = X - X // 100 * 100

    if y // (X // 100) < 5:
        print(1)
    elif y // (X // 100) == 5 and y % (X // 100) == 0:
        print(1)
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())

ans = ""
for a in S:
    ans += chr((ord(a) + N) % 26 - ord("A"))

print(ans)

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

ans = ""
for a in S:
    ans += chr((ord(a) + N - ord("A")) % 26 + ord("A"))

print(ans)

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

ans = ""
for a in S:
    ans += chr((ord(a) + N) % 26 + ard("A"))

print(ans)

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

ans = ""
for a in S:
    ans += chr((ord(a) + N - ord("A")) % 26 + ord("A"))

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
else:
    D.sort()

    if D[1] == 0:
        print(0)
        break

    mod = 998244353
    ans = 1
    distance = 0
    prev = 1
    now = 0
    
    for i in range(N):
        if D[i] == distance:
            now += 1
        elif D[i] == distance + 1:
            ans = (ans % mod) * (prev ** now % mod) % mod
            prev = now+0
            now = 1
            distance += 1
        else:
            ans = 0
            break
    else:
        ans = (ans % mod) * (prev ** now % mod) % mod
    
    print(ans)

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

if D[0] != 0:
    print(0)
else:
    D.sort()

    if D[1] == 0:
        print(0)
    else:
        mod = 998244353
        ans = 1
        distance = 0
        prev = 1
        now = 0

        for i in range(N):
            if D[i] == distance:
                now += 1
            elif D[i] == distance + 1:
                ans = (ans % mod) * (prev ** now % mod) % mod
                prev = now+0
                now = 1
                distance += 1
            else:
                ans = 0
                break
        else:
            ans = (ans % mod) * (prev ** now % mod) % mod
        
        print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
else:
    mod = 998244353
    D.sort()
    ans = 1
    distance = 0
    prev = 1
    now = 0
    for i in range(len(D)):
        if D[i] == distance:
            now += 1
        elif D[i] == distance + 1:
            ans = ans * prev ** now % mod
            prev = now+0
            now = 1
            distance += 1
        else:
            ans = 0
            break
    else:
        ans = ans * prev ** now % mod

print(ans)

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

if D[0] != 0:
    print(0)
else:
    D.sort()

    if D[1] == 0:
        print(0)
    else:
        mod = 998244353
        ans = 1
        distance = 0
        prev = 1
        now = 0

        for i in range(N):
            if D[i] == distance:
                now += 1
            elif D[i] == distance + 1:
                ans = (ans % mod) * (prev ** now % mod) % mod
                prev = now+0
                now = 1
                distance += 1
            else:
                ans = 0
                break
        else:
            ans = (ans % mod) * (prev ** now % mod) % mod
        
        print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a, b, x = map(int, input().split())

y = b - (x / a**2)
z = (4 * y**2 + a**2)**0.5

cos = (a**2 - 4*y**2 - z**2) / (-4 * y * z)

theta = math.degrees(math.acos(cos))

print('{:.10f}'.format(90 - theta))

Fixed submission:
import math

a, b, x = map(int, input().split())

if x <= b * a**2 / 2:
    theta = math.degrees(math.atan2(b, 2*x/a/b))
else:
    theta = math.degrees(math.atan2(2*(a*b-x/a)/a, a))

print(theta)

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

a, b, x = map(float, input().split())

y = b - (x / a**2)
z = (4 * y**2 + a**2)**0.5

cos = (a**2 - 4*y**2 - z**2) / (-4 * y * z)

theta = math.degrees(math.acos(cos))

print(90 - theta)

Fixed submission:
import math

a, b, x = map(int, input().split())

if x <= b * a**2 / 2:
    theta = math.degrees(math.atan2(b, 2*x/a/b))
else:
    theta = math.degrees(math.atan2(2*(a*b-x/a)/a, a))

print(theta)

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

a, b, x = map(int, input().split())

y = b - (x / a**2)
z = (4 * y**2 + a**2)**0.5

cos = (a**2 - 4*y**2 - z**2) / (-4 * y * z)

theta = math.degrees(math.acos(cos))

print(90 - theta)

Fixed submission:
import math

a, b, x = map(int, input().split())

if x <= b * a**2 / 2:
    theta = math.degrees(math.atan2(b, 2*x/a/b))
else:
    theta = math.degrees(math.atan2(2*(a*b-x/a)/a, a))

print(theta)
Buggy python submission (verdict: Runtime Error):
N = int(input())
D = map(int, input().split())

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += D[i] * D[j]

print(ans)

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

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += D[i] * D[j]

print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split()))

ans = 0
for x in h:
    if h >= K:
        ans += 1

print(ans)

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

ans = 0
for x in h:
    if x >= K:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)[::-1]
a = 0
for i in range(M):
    A[a] = A[a] // 2
    if a > 0:
        if A[a-1] > A[a]:
            a -= 1
    if a+1 <= len(A)-1:
        if A[a] < A[a+1]:
            a += 1
            if A[a] < A[a+1]:
                a += 1
        if a+2 <= len(A)-1:
            if A[a] in [A[a+1], A[a+1]+1]:
                if A[a] < A[a+2]:
                    a += 2

print(sum(A))

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(len(A)):
    A[i] *= -1

heapq.heapify(A)
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print(-sum(A))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)[::-1]
a = 0
for i in range(M):
    A[a] = A[a] // 2
    if a > 0:
        if A[a-1] > A[a]:
            a -= 1
    if a+1 <= len(A)-1:
        if A[a] < A[a+1]:
            a += 1
            if A[a] < A[a+1]:
                a += 1
        if a+2 <= len(A)-1:
            if A[a] in [A[a], A[a]+1]:
                if A[a] < A[a+2]:
                    a += 2

print(sum(A))

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(len(A)):
    A[i] *= -1

heapq.heapify(A)
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
    A = sorted(A)
    A[-1] = A[-1] // 2

print(sum(A))

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(len(A)):
    A[i] *= -1

heapq.heapify(A)
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print(-sum(A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
a = 9999999
for i in range(N):
    ans += B[A[i]]
    if A[i] == a + 1:
        ans += C[a]
    a = A[i]

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
a = 9999999
for i in range(N):
    ans += B[A[i]-1]
    if A[i] == a + 1:
        ans += C[a-1]
    a = A[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
N , K = map(int, input().split())
A = list(map(int, input().split()))

cnt_all = 0
cnt_right = 0
cnt_minA_all = []
cnt_minA_right = []

for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            cnt_all += 1
            if i < j:
                cnt_right += 1
    else:
        cnt_minA_all.append(cnt_all)
        cnt_all = 0
        cnt_minA_right.append(cnt_right)
        cnt_right = 0

ans = sum(cnt_minA_right) * K % (10**9+7)
ans += (sum(cnt_minA_all) * K % (10**9+7)

print(ans)

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

whole = 0
right = 0
whole_list = []
right_list = []

for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            whole += 1
            if i < j:
                right += 1
    else:
        whole_list.append(whole)
        whole = 0
        right_list.append(right)
        right = 0

mod = 10 ** 9 + 7
ans = sum(right_list) * K
ans += sum(whole_list) * (K - 1) * K // 2

print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
N , K = map(int, input().split())
A = list(map(int, input().split()))

cnt_all = 0
cnt_right = 0
cnt_minA_all = []
cnt_minA_right = []


for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            cnt_all += 1
            if i < j:
                cnt_right += 1
    else:
        cnt_minA_all.append(cnt_all)
        cnt_all = 0
        cnt_minA_right.append(cnt_right)
        cnt_right = 0

ans = 0
for i in reversed(range(1, K+1)):
    ans += (sum(cnt_minA_all) * (K-i) % (10**9+7) + sum(cnt_minA_right)) % (10**9+7)

print(ans)

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

whole = 0
right = 0
whole_list = []
right_list = []

for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            whole += 1
            if i < j:
                right += 1
    else:
        whole_list.append(whole)
        whole = 0
        right_list.append(right)
        right = 0

mod = 10 ** 9 + 7
ans = sum(right_list) * K
ans += sum(whole_list) * (K - 1) * K // 2

print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input() for _ in range(N)]

ss = []
cnt = 0
for i in range(N):
    x = "".join(sorted(list(s[i])))
    if x in ss:
        cnt += ss.count(x)
    ss.append(x)

print(cnt)

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
 
ctr = Counter()
ans = 0
for s in S:
    a = ''.join(sorted(list(s)))
    if a in ctr:
        ans += ctr[a]
    ctr[a] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input() for _ in range(N)]

ss = []
cnt = 0
for i in range(N):
    x = list(s[i])
    x.sort()
    y = "".join(x)
    cnt += ss.count(y)
    ss.append(y)

print(cnt)

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
 
ctr = Counter()
ans = 0
for s in S:
    a = ''.join(sorted(list(s)))
    if a in ctr:
        ans += ctr[a]
    ctr[a] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input() for _ in range(N)]

ss = []
for i in range(N):
    x = list(s[i])
    x.sort()
    y = "".join(x)
    ss.append(y)

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        if ss[i] == ss[j]:
            cnt += 1

print(cnt)

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
 
ctr = Counter()
ans = 0
for s in S:
    a = ''.join(sorted(list(s)))
    if a in ctr:
        ans += ctr[a]
    ctr[a] += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N-1):
  print(max(A[:i]+A[i+1:]))
else:
  print(max(A[:N-1]))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
 
A2 = sorted(A)[::-1]
for a in A:
  if a == A2[0]:
    print(A2[1])
  else:
    print(A2[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())
AB = [set(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x:(x[1],x[0]), reverse=True)
time = 0
for A, B in AB:
    time += A
    if B > time:
        print("No")
else:
    print("Yes")


Fixed submission:
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x:(x[1],x[0]))
time = 0
for A, B in AB:
    time += A
    if B < time:
        print("No")
        break
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
LR = [list(map(int,input().split())) for _ in range(M)]

ans = [1] * (N+1)
for L,R in LR:
    ans[:L] = [0] * L
    ans[R+1:] = [0] * (N+1-R)

print(ans.count(1))

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

L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

if min(R)-max(L)+1 <= 0:
    print(0)
else:
    print(min(R)-max(L)+1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

P = 0
for i in range(1, N+1):
    if i < K:
        cnt = 0
        X = 0
        while True:
            X = i*2
            cnt += 1
            if X >= K:
                P += 1/2**cnt + 1/N
                break
    else:
        P += 1/N

print(P)

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

P = 0
for i in range(1, N+1):
    if i < K:
        cnt = 0
        while True:
            i *= 2
            cnt += 1
            if i >= K:
                P += 1 / (2 ** cnt)
                break
    else:
        P += 1

print(P / N)

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

probability = 0
X = 1
cnt = 0
while True:
    X *= 2
    cnt += 1
    if X >= K:
        break

for i in range(1, K+1):
    probability += 1/2**cnt
    cnt -= 1

print((probability + N - K) / N)

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

P = 0
for i in range(1, N+1):
    if i < K:
        cnt = 0
        while True:
            i *= 2
            cnt += 1
            if i >= K:
                P += 1 / (2 ** cnt)
                break
    else:
        P += 1

print(P / N)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int, input().split())

ans = 0
L = sorted([R,G,B], reverse=True)
for i in range(N//L[0]+1):
    if i*L[0] > N:
        break
    for j in range(N//L[1]+1):
        if i*L[0] + j*L[1] > N:
            break
        for k in range(N//L[2]+1):
            if i*L[0] + j*L[1] + k*L[2] > N:
                break
            elif i*L[0] + j*L[1] + k*L[2] == N:
                ans += 1

print(ans)

Fixed submission:
R,G,B,N = map(int, input().split())

ans = 0
L = sorted([R,G,B], reverse=True)
for i in range(N//L[0]+1):
    for j in range((N-i*L[0])//L[1]+1):
        if (N-i*L[0]-j*L[1])%L[2] == 0:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int, input().split())

ans = 0
L = sorted([R,G,B], reverse=True)
for i in range(N//L[0]+1):
    if i*L[0] > N:
        break
    for j in range(N//L[1]+1):
        if i*L[0] + j*L[1] > N:
            break
        for k in range(N//L[2]+1):
            if i*L[0] + j*L[1] + k*L[2] > N:
                break
            elif i*L[0] + j*L[1] + k*L[2] == N:
                ans += 1

print(ans)

Fixed submission:
R,G,B,N = map(int, input().split())

ans = 0
L = sorted([R,G,B], reverse=True)
for i in range(N//L[0]+1):
    for j in range((N-i*L[0])//L[1]+1):
        if (N-i*L[0]-j*L[1])%L[2] == 0:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int, input().split())

ans = 0
for i in range(N//R+1):
    if i*R > N:
        break
    for j in range(N//G+1):
        if i*R + j*G > N:
            break
        for k in range(N//B+1):
            if i*R + j*G + k*B > N:
                break
            elif i*R + j*G + k*B == N:
                ans += 1

print(ans)

Fixed submission:
R,G,B,N = map(int, input().split())

ans = 0
L = sorted([R,G,B], reverse=True)
for i in range(N//L[0]+1):
    for j in range((N-i*L[0])//L[1]+1):
        if (N-i*L[0]-j*L[1])%L[2] == 0:
                ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for _ in range(N)]

cnt = 0
b = 0
a = 0
ab = 0
for x in S:
    cnt += x.count('AB')
    if x[0] == 'B':
        b += 1
    if x[-1] == 'A':
        a += 1
    if x[0] == 'B' and x[-1] == 'A':
        ab += 1

if a+b >= 2:
    if a == ab and b == ab:
        a = 1
        b = 1
        ab -= 2
    if a > b:
        cnt += a//b + ab
    else:
        cnt += b//a + ab

print(cnt)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

cnt = 0
b = 0
a = 0
ab = 0
for x in S:
    cnt += x.count('AB')
    if x[0] == 'B' and x[-1] == 'A':
        ab += 1
        continue
    if x[0] == 'B':
        b += 1
    if x[-1] == 'A':
        a += 1
    

if (a>0 and b>0) or ab>=2:
    if a==0:
        a = 1
        ab -= 1
    if b==0:
        b = 1
        ab -= 1
    cnt += min(a,b) + ab

print(cnt)
Buggy python 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] = "*"

print("".join(S))

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

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

print("".join(S))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

if '#' not in S or '.' not in S:
    ans = 0
else:
    ans = 2*10**5
    for i in range(N):
        ans = min(S[:i].count('#') + S[i:].count('.'), ans)

print(ans)

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

white = S.count('.')
black = 0
ans = white + black

for x in S:
    if x == '.':
        white -= 1
    else:
        black += 1
    ans = min(ans, white+black)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

if '#' not in S or '.' not in S:
    print(0)
else:
    ans = []
    for i in range(N):
        if S[i] == '#':
            ans.append(S[:i].count('#') + S[i:].count('.'))
    else:
        print(min(ans))

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

white = S.count('.')
black = 0
ans = white + black

for x in S:
    if x == '.':
        white -= 1
    else:
        black += 1
    ans = min(ans, white+black)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

if '#' not in S:
    print(0)
else:
    ans = []
    for i in range(N):
        if S[i] == '#':
            ans.append(S[:i].count('#') + S[i:].count('.'))
    else:
        print(min(ans))

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

white = S.count('.')
black = 0
ans = white + black

for x in S:
    if x == '.':
        white -= 1
    else:
        black += 1
    ans = min(ans, white+black)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

if '#' not in S:
    ans = 0
else:
    ans = 2*10**5
    for i in range(N):
        if S[i] == '#':
            ans = min(S[:i].count('#') + S[i:].count('.'), ans)

print(ans)

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

white = S.count('.')
black = 0
ans = white + black

for x in S:
    if x == '.':
        white -= 1
    else:
        black += 1
    ans = min(ans, white+black)

print(ans)
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

cntli = []
for i in range(q):
    si = s[lr[i][0]-1:lr[i][1]]
    cnt = 0
    for j in range(len(si)-1):
        if si[j] == "A":
            if si[j+1] == "C":
                cnt += 1
    else:
        cntli.append(cnt)

for p in cntli:
    print(p)


Fixed submission:
b = input()
if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "C":
    print("G")
elif b == "G":
    print("C")
Buggy python submission (verdict: Runtime Error):
s = input()
li = ["A","T","C","G"]

cnt = 0
cntli = []
for i in range(len(s)):
    if s[i] in li:
        cnt += 1
    else:
        cntli.append(cnt)
        cnt = 0

print(max(cntli))

Fixed submission:
s = input()
li = ["A","T","C","G"]

cnt = 0
cntli = []
for i in range(len(s)):
    if s[i] in li:
        cnt += 1
    else:
        cntli.append(cnt)
        cnt = 0
else:
    cntli.append(cnt)

print(max(cntli))