Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
prev = 0
cnt = 1
l = 0
for i in range(len(L)):
    if L[i] == prev:
        cnt += 1
    else:
        c[l] = cnt
        l += 1
        cnt = 1
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

Fixed submission:
n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
prev = L[0]
cnt = 1
l = 0
for i in range(1, len(L)):
    if L[i] == prev:
        cnt += 1
    else:
        c[l] = cnt
        l += 1
        cnt = 1
        prev = L[i]
c[-1] = cnt
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = [input() for _ in range(n)]
s = sorted(set(L))
c = [0] * len(s)
for i in range(len(s)):
    c[i] = L.count(s[i])
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

Fixed submission:
n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
prev = L[0]
cnt = 1
l = 0
for i in range(1, len(L)):
    if L[i] == prev:
        cnt += 1
    else:
        c[l] = cnt
        l += 1
        cnt = 1
        prev = L[i]
c[-1] = cnt
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
for i in range(len(s)):
    c[i] = L.count(s[i])
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

Fixed submission:
n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
prev = L[0]
cnt = 1
l = 0
for i in range(1, len(L)):
    if L[i] == prev:
        cnt += 1
    else:
        c[l] = cnt
        l += 1
        cnt = 1
        prev = L[i]
c[-1] = cnt
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
M = 0
for i in range(n - k + 1):
    s = sum(p[i:i + k])
    M = max(M, s)
print((M + k) / 2)


Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split())) 
s = sum(p[:k])
M = s
for i in range(n - k):
    s += p[i + k] - p[i]
    M = max(M, s)
print((M + k) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
M = 0
for i in range(n - k + 1):
    s = 0
    for j in range(i, i + k):
        s += p[j]
    M = max(M, s)
print((M + k) / 2)


Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split())) 
s = sum(p[:k])
M = s
for i in range(n - k):
    s += p[i + k] - p[i]
    M = max(M, s)
print((M + k) / 2)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    H, N = map(int, input().split())
    magic = [list(map(int, input().split())) for _ in range((N))]
    dp = [float('inf')] * (H + 1)
    dp[0] = 0
    for h in range(H):
        for dmg, cst in magic:
            next = min(h + dmg, H)
            dp[next] = min(dp[next], dp[h] + cst)
    print(dp[h+1])
main()


Fixed submission:
def main():
    H, N = map(int, input().split())
    magic = [list(map(int, input().split())) for _ in range((N))]
    dp = [float('inf')] * (H + 1)
    dp[0] = 0
    for h in range(H):
        for dmg, cst in magic:
            next = min(h + dmg, H)
            dp[next] = min(dp[next], dp[h] + cst)
    print(dp[h+1])
main()

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
L = [list(map(int, input().split())) for _ in range((N))]
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H):
    for dmg, cst in L:
        next = min(h + dmg, H)
        dp[next] = min(dp[next], dp[h] + cst)
print(dp[-1])


Fixed submission:
def main():
    H, N = map(int, input().split())
    magic = [list(map(int, input().split())) for _ in range((N))]
    dp = [float('inf')] * (H + 1)
    dp[0] = 0
    for h in range(H):
        for dmg, cst in magic:
            next = min(h + dmg, H)
            dp[next] = min(dp[next], dp[h] + cst)
    print(dp[h+1])
main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if p[i] <= min(p[:i+1]):
        cnt += 1
print(cnt)


Fixed submission:
n = int(input())
p = list(map(int, input().split()))
cnt = 0
m = float('inf')
for i in range(n):
    m = min(p[i], m)
    if p[i] <= m:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
    for j in range(i + 1):
        if p[i] > p[j]:
            break
    else:
        cnt += 1
print(cnt)


Fixed submission:
n = int(input())
p = list(map(int, input().split()))
cnt = 0
m = float('inf')
for i in range(n):
    m = min(p[i], m)
    if p[i] <= m:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
L = [0] * n
for i in range(n):
    if i < k:
        L[i] = s
    else:
        if s != 10 ** 9
            L[i] = s + 1
        else:
            L[i] = s - 1
print(*L)


Fixed submission:
n, k, s = map(int, input().split())
L = [0] * n
for i in range(n):
    if i < k:
        L[i] = s
    else:
        if s != 10 ** 9:
            L[i] = s + 1
        else:
            L[i] = s - 1
print(*L)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
L = []
AC = []
cnt = 0
for _ in range(m):
    p, s = input().split()
    if p in AC:
        continue
    else:
        if s == 'AC':
            AC.append(p)
            cnt += L.count(p)
        else:
            L.append(p)
print(len(AC), cnt)


Fixed submission:
n, m = map(int, input().split())
d = {}
cnt_ac = 0
cnt_wa = 0
for _ in range(m):
    p, s = input().split()
    if p not in d:
        d[p] = [s]
    else:
        d[p].append(s)
for i in d:
    if 'AC' in d[i]:
        cnt_ac += 1
        cnt_wa += d[i].index('AC')
print(cnt_ac, cnt_wa)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
L = set()
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            L.add(s[i]+s[j]+s[k])
print(len(L))


Fixed submission:
n = int(input())
s = str(input())
cnt = 0
for i in range(1000):
    x = str(i).zfill(3)
    i1 = s.find(x[0])
    i2 = s[i1+1:].find(x[1])
    i3 = s[i1+i2+2:].find(x[2])
    if -1 not in (i1, i2, i3):
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
L =[]
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            L.append(s[i]+s[j]+s[k])
print(len(set(L)))


Fixed submission:
n = int(input())
s = str(input())
cnt = 0
for i in range(1000):
    x = str(i).zfill(3)
    i1 = s.find(x[0])
    i2 = s[i1+1:].find(x[1])
    i3 = s[i1+i2+2:].find(x[2])
    if -1 not in (i1, i2, i3):
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
C = [0] * n
C[0] = 3
ans = 1
for i in a:
    ans = ans * C[i] % MOD
    C[i] -= 1
    C[i+1] += 1
print(ans % MOD)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
C = [0] * (n + 1)
C[0] = 3
ans = 1
for i in a:
    ans = ans * C[i] % MOD
    C[i] -= 1
    C[i+1] += 1
print(ans % MOD)
Buggy python submission (verdict: Runtime Error):
n = int(input())
L = []
d = {}
for _ in range(n-1):
    a, b = map(int, input().split())
    L.append((a, b))
    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)
k = 0
for i in d.keys():
    tmp_k = len(d[i]) if i == 1 else len(d[i]) + 1
    k = max(k, tmp_k)
print(k)
dd = {1: 0}
ans = {}
for i, v in d.items():
    cnt = 1
    for j in v:
        if cnt != dd[i]:
            c = cnt
            cnt += 1
        else:
            c = cnt + 1
            cnt += 2
        ans[(i, j)] = c
        dd[j] = c
for a, b in L:
    print(ans[(a, b)])


Fixed submission:
n = int(input())
L = []
d = {}
for _ in range(n-1):
    a, b = map(int, input().split())
    L.append((a, b))
    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)
k = 0
for i in d.keys():
    tmp_k = len(d[i]) if i == 1 else len(d[i]) + 1
    k = max(k, tmp_k)
print(k)
key = sorted(d.keys())
dd = {1: 0}
ans = {}
for i in key:
    v = d[i]
    cnt = 1
    for j in v:
        if cnt != dd[i]:
            c = cnt
            cnt += 1
        else:
            c = cnt + 1
            cnt += 2
        ans[(i, j)] = c
        dd[j] = c
for a, b in L:
    print(ans[(a, b)])

Buggy python submission (verdict: Runtime Error):
n = int(input())
d = {}
k = 0
for _ in range(n-1):
    a, b = map(int, input().split())
    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)
for i in d.keys():
    tmp_k = len(d[i]) if i == 1 else len(d[i]) + 1
    k = max(k, tmp_k)
print(k)
dd = {1: 0}
for i, v in d.items():
    cnt = 1
    for j in v:
        if cnt != dd[i]:
            c = cnt
            cnt += 1
        else:
            c = cnt + 1
            cnt += 2
        print(c)
        dd[j] = c


Fixed submission:
n = int(input())
L = []
d = {}
for _ in range(n-1):
    a, b = map(int, input().split())
    L.append((a, b))
    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)
k = 0
for i in d.keys():
    tmp_k = len(d[i]) if i == 1 else len(d[i]) + 1
    k = max(k, tmp_k)
print(k)
key = sorted(d.keys())
dd = {1: 0}
ans = {}
for i in key:
    v = d[i]
    cnt = 1
    for j in v:
        if cnt != dd[i]:
            c = cnt
            cnt += 1
        else:
            c = cnt + 1
            cnt += 2
        ans[(i, j)] = c
        dd[j] = c
for a, b in L:
    print(ans[(a, b)])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 10 ** 10
for i in range(1, len(a)):
    ans = min(ans, abs(sum(a[:i]) - sum(a[i:])))
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
L = sum(a)
l = 0
i = 0
while l < L / 2:
    l += a[i]
    i += 1
print(min(abs(sum(a[:i - 1]) - sum(a[i - 1:])), abs(sum(a[:i]) - sum(a[i:]))))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
L = sorted(map(int, input().split()))
ans = 0
for i in range(n-2):
    a = L[i]
    for j in range(i+1, n-1):
        b = L[j]
        l = bisect.bisect(L[j+1:n], a+b-1)
        ans += l
print(ans)


Fixed submission:
import bisect

n = int(input())
L = sorted(map(int, input().split()))
ans = 0
for i in range(n):
    a = L[i]
    for j in range(i+1, n):
        b = L[j]
        k = bisect.bisect_left(L, a+b)
        if k > j:
            ans += k - j - 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = sorted(map(int, input().split()))
ans = 0
for i in range(n-2):
    a = L[i]
    for j in range(i+1, n-1):
        b = L[j]
        k = j + 1
        cnt = 0
        while k <= n - 1:
            if L[k] >= a + b:
                break
            k += 1
            cnt += 1
        ans += cnt
print(ans)


Fixed submission:
import bisect

n = int(input())
L = sorted(map(int, input().split()))
ans = 0
for i in range(n):
    a = L[i]
    for j in range(i+1, n):
        b = L[j]
        k = bisect.bisect_left(L, a+b)
        if k > j:
            ans += k - j - 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    a = L[i]
    for j in range(i+1, n-1):
        b = L[j]
        for k in range(j+1, n):
            c = L[k]
            if a < b + c and b < c + a and c < a + b:
                cnt += 1
print(cnt)


Fixed submission:
import bisect

n = int(input())
L = sorted(map(int, input().split()))
ans = 0
for i in range(n):
    a = L[i]
    for j in range(i+1, n):
        b = L[j]
        k = bisect.bisect_left(L, a+b)
        if k > j:
            ans += k - j - 1
print(ans)
Buggy python submission (verdict: Runtime Error):
H, W, A, B = map(int, input().split())
grid = [[0] * W for _ in range(H)]
cnt = [0] * W
w = 0
for h in range(H):
    if B != 0:
        if cnt[w] >= B:
            w += A
    for i in range(A):
        grid[h][w+i] = 1
        cnt[w+i] += 1
for row in grid:
    print(*row, sep='')


Fixed submission:
H, W, A, B = map(int, input().split())
for i in range(B):
    print('1' * A + '0' * (W - A))
for i in range(H - B):
    print('0' * A + '1' * (W - A))
Buggy python submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
score = [0] * n
for _ in range(q):
    i = int(input())
    score[i-1] += 1
for j in score:
    if score[j] > q - k:
        print('Yes')
    else:
        print('No')


Fixed submission:
n, k, q = map(int, input().split())
score = [0] * n
for _ in range(q):
    i = int(input())
    score[i-1] += 1
for j in range(len(score)):
    if score[j] > q - k:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
for i in range(m):
    a = A.pop() / 2
    bisect.insort(A, a)
ans = 0
for a in A:
    ans += a // 1
print(int(ans))


Fixed submission:
import heapq

n, m = map(int, input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(A)
for _ in range(m):
    tmp = heapq.heappop(A)
    tmp = int((-tmp / 2) // 1)
    heapq.heappush(A, -tmp)
print(-sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1, n):
    ans += i
print(ans)


Fixed submission:
n = int(input())
print(n * (n - 1) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
ans = 0
for k in range(1, max(p) + 1):
    abc = 0
    arc = 0
    for i in p:
        if i < k:
            abc += 1
        else:
            arc += 1
    if abc == arc:
        ans += 1
print(ans)


Fixed submission:
n = int(input())
p = sorted(list(map(int, input().split())))
a = int(len(p) / 2)
if p[a-1] == p[a]:
    print(0)
else:
    print(p[a] - p[a-1])
Buggy python submission (verdict: Time Limit Exceeded):
import math

def comb(a, b):
    return math.factorial(a) // (math.factorial(b) * math.factorial(a - b))

n, m = map(int, input().split())
ans = 1
p = 0
for _ in range(m):
    a = int(input())
    cnt = 0
    if a == p:
        print(0)
        exit()
    s = a - 1 - p
    for i in range(s // 2 + 1):
        cnt += comb(s - i, i)
    p = a + 1
    ans = (ans * cnt) % (10 ** 9 + 7)
s = n - p
cnt = 0
for i in range(s // 2 + 1):
    cnt += comb(s - i, i)
ans = (ans * cnt) % (10 ** 9 + 7)
print(ans)


Fixed submission:
n, m = map(int, input().split())
dp = [0] * (n + 1)
safe = [True] * (n + 1)
mod = 10 ** 9 + 7
for _ in range(m):
    a = int(input())
    safe[a] = False
dp[0] = 1
if safe[1] is True:
    dp[1] = 1 
for i in range(2, n+1):
    if safe[i-1] is True:
        dp[i] += dp[i-1]
    if safe[i-2] is True:
        dp[i] += dp[i-2]
    dp[i] %= mod
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
import math

def comb(a, b):
    return math.factorial(a) // (math.factorial(b) * math.factorial(a - b))

n, m = map(int, input().split())
ans = 1
p = 0
for _ in range(m):
    a = int(input())
    cnt = 0
    if a == p:
        print(0)
        exit()
    s = a - 1 - p
    for i in range(s // 2 + 1):
        cnt += comb(s - i, i)
    p = a + 1
    ans = (ans * cnt) % (10 ** 9 + 7)
s = n - p
cnt = 0
for i in range(s // 2 + 1):
    cnt += comb(s - i, i)
ans = (ans * cnt) % (10 ** 9 + 7)
print(ans)


Fixed submission:
n, m = map(int, input().split())
dp = [0] * (n + 1)
safe = [True] * (n + 1)
mod = 10 ** 9 + 7
for _ in range(m):
    a = int(input())
    safe[a] = False
dp[0] = 1
if safe[1] is True:
    dp[1] = 1 
for i in range(2, n+1):
    if safe[i-1] is True:
        dp[i] += dp[i-1]
    if safe[i-2] is True:
        dp[i] += dp[i-2]
    dp[i] %= mod
print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
for _ in range(m):
    b, c = map(int, input().split())
    for _ in range(b):
        tmp = heapq.heappop(a)
        if tmp >= c:
            heapq.heappush(a, tmp)
            break
        else:
            heapq.heappush(a, c)
print(sum(a))


Fixed submission:
n, m = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    d[a] = 1 if a not in d else d[a] + 1
for _ in range(m):
    b, c = map(int, input().split())
    d[c] = b if c not in d else d[c] + b
ans = 0
cnt = 0
L = sorted(d, reverse=True)
for k in L:
    if d[k] + cnt < n:
        ans += k * d[k]
        cnt += d[k]
    else:
        ans += k * (n - cnt)
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(m):
    b, c = map(int, input().split())
    a += [c] * b
a.sort(reverse=True)
print(sum(a[:n]))


Fixed submission:
n, m = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    d[a] = 1 if a not in d else d[a] + 1
for _ in range(m):
    b, c = map(int, input().split())
    d[c] = b if c not in d else d[c] + b
ans = 0
cnt = 0
L = sorted(d, reverse=True)
for k in L:
    if d[k] + cnt < n:
        ans += k * d[k]
        cnt += d[k]
    else:
        ans += k * (n - cnt)
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(m):
    b, c = map(int, input().split())
    a.extend([c] * b)
a.sort(reverse=True)
print(sum(a[:n]))


Fixed submission:
n, m = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    d[a] = 1 if a not in d else d[a] + 1
for _ in range(m):
    b, c = map(int, input().split())
    d[c] = b if c not in d else d[c] + b
ans = 0
cnt = 0
L = sorted(d, reverse=True)
for k in L:
    if d[k] + cnt < n:
        ans += k * d[k]
        cnt += d[k]
    else:
        ans += k * (n - cnt)
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())
cnt = 0
 
for i in range(N // R + 1):
    for j in range(N // G + 1):
        q, mod = divmod((N - R * i - G * j), B)
        if q >= 0 and mod == 0:
            cnt += 1
print(cnt)

Fixed submission:
n, k = map(int, input().split())
print(n-k+1)

Buggy python submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())
cnt = 0

for i in range(N // R + 1):
    for j in range(N // G + 1):
        if (N - R * i - G * j) % B == 0:
            cnt += 1
print(cnt)

Fixed submission:
n, k = map(int, input().split())
print(n-k+1)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
cnt = 0
for i in range(N // R + 1):
    for j in range(N // G + 1):
        q, mod = divmod((N - R * i - G * j), B)
        if q >= 0 and mod == 0:
            cnt += 1
print(cnt)


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

for i in range(N // R + 1):
    for j in range(N // G + 1):
        if (N - R * i - G * j) / B >= 0 and ((N - R * i - G * j) / B) % 1 == 0:
            cnt += 1
print(cnt)

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

for i in range(N // R + 1):
    for j in range(N // G + 1):
        if (N - R * i - G * j) / B >= 0 and ((N - R * i - G * j) / B) % 1 == 0:
            cnt += 1
print(cnt)

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

for i in range(N // R + 1):
    for j in range(N // G + 1):
        if (N - R * i - G * j) / B >= 0 and ((N - R * i - G * j) / B) % 1 == 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())
cnt = 0

for i in range(n // R + 1):
    for j in range(n // G + 1):
        if (N - R * i - G * j) / B >= 0 and ((N - R * i - G * j) / B) % 1 == 0:
            cnt += 1
print(cnt)

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

for i in range(N // R + 1):
    for j in range(N // G + 1):
        if (N - R * i - G * j) / B >= 0 and ((N - R * i - G * j) / B) % 1 == 0:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
ans = s.count('#')
for i in range(n):
    w = s[:i].count('#')
    b = s[i:].count('.')
    ans = min(ans, w + b)
print(ans)


Fixed submission:
n = int(input())
s = str(input())
ans = s.count('.')
L = [[0, s.count('.')]]
for i in range(n):
    if s[i] == '#':
        L.append([L[i][0]+1, L[i][1]])
    else:
        L.append([L[i][0], L[i][1]-1])
    ans = min(ans, L[-1][0] + L[-1][1])
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
d = Counter(s)
S = list(set(s))
ans = 1
for t in S:
    ans *= d[t] + 1
print(ans - 1)


Fixed submission:
from collections import Counter

n = int(input())
s = str(input())
d = Counter(s)
S = list(set(s))
ans = 1
for t in S:
    ans *= d[t] + 1
print((ans - 1) % (10** 9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
cnt = 0
prev = len(s)
while len(s) > 1:
    for i in range(len(s) - 1):
        if (s[i] == '0' and s[i + 1] == '1') or (s[i] == '1' and s[i + 1] == '0'):
            cnt += 2
            s = s[:i] + 'xx' + s[i + 2:]
    s = s.replace('xx', '')
    if len(s) == prev:
        break
    prev = len(s)
print(cnt)


Fixed submission:
s = str(input())
cnt = 0
prev = s[0]
stock = 1
for i in range(1, len(s)):
    if stock == 0:
        prev = s[i]
        stock += 1
    else:
        if s[i] != prev:
            cnt += 2
            stock -= 1
            if stock > 0:
                if s[i] == '0':
                    prev = '1'
                else:
                    prev = '0'
        else:
            prev = s[i]
            stock += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
cnt = 0
while len(s) > 1:
    for i in range(len(s) - 1):
        if s[i] != s[i + 1]:
            cnt += 2
            if i == len(s) - 1:
                break
            else:
                s = s[:i] + s[i + 2:]
                break
    else:
        break
print(cnt)


Fixed submission:
s = str(input())
cnt = 0
prev = s[0]
stock = 1
for i in range(1, len(s)):
    if stock == 0:
        prev = s[i]
        stock += 1
    else:
        if s[i] != prev:
            cnt += 2
            stock -= 1
            if stock > 0:
                if s[i] == '0':
                    prev = '1'
                else:
                    prev = '0'
        else:
            prev = s[i]
            stock += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
L_over = []
L_short = []
for i in range(n):
    c = A[i] - B[i]
    if c > 0:
        L_over.append(c)
    elif c < 0:
        L_short.append(-c)
L_over.sort(reverse=True)
if sum(L_over) < sum(L_short):
    print(-1)
else:
    cnt = len(L_short)
    p = 0
    for i in range(len(L_over)):
        if p >= sum(L_short):
            break
        p += L_over[i]
        cnt += 1
    print(cnt)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
over = []
short = 0
cnt = 0
for i in range(n):
    c = A[i] - B[i]
    if c > 0:
        over.append(c)
    elif c < 0:
        short -= c
        cnt += 1
if sum(over) < short:
    print(-1)
else:
    over.sort(reverse=True)
    s = 0
    i = 0
    while s < short:
        s += over[i]
        i += 1
    cnt += i
    print(cnt)