Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input()
q = int(input())
count = 0
top = ""
end = ""
ans = s
for i in range(q):
    tmp = input()
        count += 1
    else:
        _, f, c = map(str, tmp.split())
        if (count % 2 == 0 and f == "1") or (count % 2 == 1 and f == "2"):
            top = c + top
        else:
            end = end + c

ans = top + ans + end
ans = ans[::-1] if count % 2 == 1 else ans
print(ans)


Fixed submission:
s = input()
q = int(input())
count = 0
top = ""
end = ""
ans = s
for i in range(q):
    tmp = input()
    if tmp[0] == "1":
        count += 1
    else:
        _, f, c = map(str, tmp.split())
        if count % 2 == 0:
            if f == "1":
                top = c + top
            else:
                end = end + c
        else:
            if f == "1":
                end = end + c
            else:
                top = c + top

ans = top + ans + end
ans = ans[::-1] if count % 2 == 1 else ans
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
count = 0
ans = s
for i in range(q):
    tmp = input()
    if tmp[0] == "1":
        count += 1
    else:
        _, f, c = map(str, tmp.split())
        if count % 2 == 0:
            ans = (c + ans) if f == "1" else (ans + c)
        else:
            ans = (ans + c) if f == "1" else (c + ans)
ans = ans[::-1] if count % 2 == 1 else ans
print(ans)

Fixed submission:
s = input()
q = int(input())
count = 0
top = ""
end = ""
ans = s
for i in range(q):
    tmp = input()
    if tmp[0] == "1":
        count += 1
    else:
        _, f, c = map(str, tmp.split())
        if count % 2 == 0:
            if f == "1":
                top = c + top
            else:
                end = end + c
        else:
            if f == "1":
                end = end + c
            else:
                top = c + top

ans = top + ans + end
ans = ans[::-1] if count % 2 == 1 else ans
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
ans = s
for i in range(q):
    tmp = input()
    if tmp[0] == "1":
        ans = ans[::-1]
    else:
        _, f, c = map(str, tmp.split())
        ans = (c + ans) if f == "1" else (ans + c)
print(ans)

Fixed submission:
s = input()
q = int(input())
count = 0
top = ""
end = ""
ans = s
for i in range(q):
    tmp = input()
    if tmp[0] == "1":
        count += 1
    else:
        _, f, c = map(str, tmp.split())
        if count % 2 == 0:
            if f == "1":
                top = c + top
            else:
                end = end + c
        else:
            if f == "1":
                end = end + c
            else:
                top = c + top

ans = top + ans + end
ans = ans[::-1] if count % 2 == 1 else ans
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]

ans = -1
for i in range(10 ** (n - 1) - 1, 10 ** n):
    tmp = str(i)
    flg = False
    for l in lst:
        if tmp[l[0] - 1] == str(l[1]):
            flg = True
            break
    if flg == True:
        ans = i
        break

print(ans)

Fixed submission:
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
ans = -1
for i in range(10 ** n):
    tmp = str(i)
    if len(tmp) == n:
        flg = True
        for l in lst:
            if tmp[l[0] - 1] != str(l[1]):
                flg = False
                break
        if flg == True:
            ans = i
            break
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
import os
f = open("input.txt", "r")
sys.stdin = f

n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]

for i in range(m):
    for j in range(m):
        if i != j and lst[i][0] == lst[j][0] and lst[i][1] != lst[j][1]:
            print(-1)
            exit()

ans = "0" * n
for l in lst:
    if l[0] == 1 and l[1] == 0:
        print(-1)
        exit()
    ans = ans[: l[0] - 1] + str(l[1]) + ans[l[0]: ]

if ans[0] == "0":
    ans = "1" + ans[1: ]

print(ans)


Fixed submission:
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
ans = -1
for i in range(10 ** n):
    tmp = str(i)
    if len(tmp) == n:
        flg = True
        for l in lst:
            if tmp[l[0] - 1] != str(l[1]):
                flg = False
                break
        if flg == True:
            ans = i
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = [input() for _ in range(n)]

words = list(set(S))
words.sort()

num = len(words)
counter = [0] * num
for i in range(num):
    counter[i] = S.count(words[i])

max = max(counter)
for i in range(num):
    if counter[i] == max:
        print(words[i])

Fixed submission:
n = int(input())

words = []
dict = {}
for i in range(n):
    s = input()
    words.append(s)
    if s not in dict:
        dict[s] = 0
    dict[s] += 1

max = max(dict.values())
for s in sorted([d for d in dict if dict[d] == max]):
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
P = list(map(int, input().split()))

D = dict.fromkeys(P, 0)
for key in D.keys():
    D[key] = sum([j for j in range(1, key + 1)]) / key
C = [D[p] for p in P]
T = [sum(C[i: i + k]) for i in range(0, n - k + 1)]

print(max(T))

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

C = [(1 + p) / 2 for p in P]

ans = tmp = sum(C[: k])
for i in range(k, n):
    tmp += (C[i] - C[i - k])
    ans = max(tmp, ans)

print(ans)

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

D = dict.fromkeys(P, 0)
for key in D.keys():
    D[key] = sum([j for j in range(1, key + 1)]) / key

ans = 0.0
for i in range(0, n - k + 1):
    tmp = sum(D[t] for t in P[i: i + k])
    ans = max(tmp, ans)
    
print(ans)

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

C = [(1 + p) / 2 for p in P]

ans = tmp = sum(C[: k])
for i in range(k, n):
    tmp += (C[i] - C[i - k])
    ans = max(tmp, ans)

print(ans)

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

mx = max(P)
ans = 0.0
for i in range(0, n - k + 1):
    T = P[i: i + k]
    if mx in T:
        tmp = 0.0
        for t in T:
            M = [j for j in range(1, t + 1)]
            tmp += sum(M) / t
        ans = max(tmp, ans)
print(ans)

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

C = [(1 + p) / 2 for p in P]

ans = tmp = sum(C[: k])
for i in range(k, n):
    tmp += (C[i] - C[i - k])
    ans = max(tmp, ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
WA = [0] * n
AC = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    p = int(p) - 1
    if s == "AC":
        AC[p] = 1
    elif s == "WA" and AC[p] == 0:
        WA[p] += 1

WA = [WA[i] for i in range(m) if AC[i] >= 1]

print(sum(AC), sum(WA))

Fixed submission:
n, m = map(int, input().split())
WA = [0] * n
AC = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    p = int(p) - 1
    if s == "AC":
        AC[p] = 1
    elif s == "WA" and AC[p] == 0:
        WA[p] += 1

for i in range(n):
    WA[i] = 0 if AC[i] == 0 else WA[i]

print(sum(AC), sum(WA))
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print(int((a * b) / math.gcd(a, b)))

Fixed submission:
import fractions
a, b = map(int, input().split())
print(int((a * b) / fractions.gcd(a, b)))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
L = list(map(int, input().split()))

circle = list(itertools.combinations(L, 3))

count = 0
for c in circle:
    if c[0] < c[1] + c[2] and c[1] < c[2] + c[0] and c[2] < c[0] + c[1]:
        count += 1

print(count)

Fixed submission:
import bisect

n = int(input())
L = list(map(int, input().split()))
L.sort()

count = 0
for i in range(n):
    for j in range(i + 1, n):
        count += (bisect.bisect_left(L, L[i] + L[j]) - j - 1)

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
A = [int(input()) for _ in range(q)]
P = [k for _ in range(n)]

for i in range(q):
    for j in range(n):
        if (A[i] - 1) != j:
            P[j] -= 1

for i in range(n):
    print("Yes" if P[i] > 0 else "No")

Fixed submission:
n, k, q = map(int, input().split())
A = [int(input()) for _ in range(q)]
P = [k - q] * n

for i in range(q):
    P[A[i] - 1] += 1

for i in range(n):
    print("Yes" if P[i] > 0 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
H = list(map(int, input().split()))

ans = 0
for i in range(n):
    pos_h = H[i]
    count = 0
    for j in range(i + 1, n):
        if H[j] <= pos_h:
            count += 1
            pos_h = H[j]
        else:
            break
    ans = max(ans, count)

print(ans)

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

ans = 0
i = 0
while i < n:
    pos_h = H[i]
    count = 0
    j = i + 1
    while j < n and H[j] <= pos_h:
        count += 1
        pos_h = H[j]
        j += 1

    ans = max(ans, count)
    i = j

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
M = [i for i in range(n)]
print(sum(M))

Fixed submission:
n = int(input())
print(int(n * (n - 1) // 2))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
P = [i for i in range(1, n + 1)]
P = P[1:] + [P[0]]

M = [(i + 1) % P[i] for i in range(n)]
print(sum(M))

Fixed submission:
n = int(input())
print(int(n * (n - 1) // 2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]
for i in range(n):
    print(max(A[: i] + A[i + 1:]))

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]

high = sorted(A, reverse=True)[: 2]

for i in range(n):
    if A[i] == high[0]:
        ans = high[1]
    else:
        ans = high[0]
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

a -= 1
lcm = (c * d) // math.gcd(c, d)

divisible_c = (b // c) - (a // c)
divisible_d = (b // d) - (a // d)
divisible_cd = (b // lcm) - (a // lcm)

print((b - a) - (divisible_c + divisible_d - divisible_cd))

Fixed submission:
import fractions

a, b, c, d = map(int, input().split())

a -= 1
lcm = (c * d) // fractions.gcd(c, d)

divisible_c = (b // c) - (a // c)
divisible_d = (b // d) - (a // d)
divisible_cd = (b // lcm) - (a // lcm)

print((b - a) - (divisible_c + divisible_d - divisible_cd))
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
L = list(map(int, input().split()))

d, i = 0, 0
while d < x:
    d += L[i]
    i += 1

print(i)

Fixed submission:
import numpy as np

n, x = map(int, input().split())
L = list(map(int, input().split()))

CS_L = np.cumsum(L).tolist()
ans = len([l for l in CS_L if l <= x])
print(ans + 1)

Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
L = list(map(int, input().split()))

d, i = 0, 0
while d <= x:
    d += L[i]
    i += 1

print(i)

Fixed submission:
import numpy as np

n, x = map(int, input().split())
L = list(map(int, input().split()))

CS_L = np.cumsum(L).tolist()
ans = len([l for l in CS_L if l <= x])
print(ans + 1)

Buggy python submission (verdict: Runtime Error):
d, i = 0, 0
while d <= x:
    d += L[i]
    i += 1

print(i)

Fixed submission:
import numpy as np

n, x = map(int, input().split())
L = list(map(int, input().split()))

CS_L = np.cumsum(L).tolist()
ans = len([l for l in CS_L if l <= x])
print(ans + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
A = [int(input()) for _ in range(m)]

DP = [0] * (n + 1)
DP[0] = 1
for i in range(n):
    if i + 1 not in A:
        DP[i + 1] += DP[i]
    if i + 2 not in A and i + 2 <= n:
        DP[i + 2] += DP[i]

print(DP[-1] % 1000000007)

Fixed submission:
n, m = map(int, input().split())
denger = [False] * (n + 1)
for i in range(m):
    denger[int(input())] = True

DP = [0] * (n + 1)
DP[0] = 1
for i in range(n):
    if not denger[i + 1]:
        DP[i + 1] += DP[i]
    if i + 2 <= n and not denger[i + 2]:
        DP[i + 2] += DP[i]

print(DP[-1] % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

n = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(n):
    left, right = A[: i], A[i + 1: ]
    gcd_left, gcd_right = 0, 0
    for l in left:
        gcd_left = gcd(gcd_left, l)
    for r in right:
        gcd_right = gcd(gcd_right, r)

    ans = max(ans, gcd(gcd_left, gcd_right))

print(ans)

Fixed submission:
from fractions import gcd

n = int(input())
A = list(map(int, input().split()))

L, R = [0] * (n + 1), [0] * (n + 1)
for i in range(n):
    L[i + 1] = gcd(L[i], A[i])
    R[n - i - 1] = gcd(R[n - i], A[n - i - 1])
ans = 0
for i in range(n):
    ans = max(ans, gcd(L[i], R[i + 1]))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce

def gcd_list(nums):
    if len(nums) == 0:
        return 0
    return reduce(fractions.gcd, nums)

n = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(n):
    l, r = gcd_list(A[: i]), gcd_list(A[i + 1: ])
    ans = max(ans, fractions.gcd(l, r))

print(ans)

Fixed submission:
from fractions import gcd

n = int(input())
A = list(map(int, input().split()))

L, R = [0] * (n + 1), [0] * (n + 1)
for i in range(n):
    L[i + 1] = gcd(L[i], A[i])
    R[n - i - 1] = gcd(R[n - i], A[n - i - 1])
ans = 0
for i in range(n):
    ans = max(ans, gcd(L[i], R[i + 1]))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce

def gcd_list(nums):
    return reduce(fractions.gcd, nums)

n = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(n):
    B = A[: i] + A[i + 1: ]
    ans = max(ans, gcd_list(B))

print(ans)

Fixed submission:
from fractions import gcd

n = int(input())
A = list(map(int, input().split()))

L, R = [0] * (n + 1), [0] * (n + 1)
for i in range(n):
    L[i + 1] = gcd(L[i], A[i])
    R[n - i - 1] = gcd(R[n - i], A[n - i - 1])
ans = 0
for i in range(n):
    ans = max(ans, gcd(L[i], R[i + 1]))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n, k = map(int, input().split())
H = np.array(list(map(int, input().split())))

DP = np.full(n, float("inf"))
DP[0] = 0
DP[1] = abs(H[1] - H[0])
for i in range(2, n):
    ik = max(0, i - k)
    DP[i] = np.min(DP[ik: i] + np.abs(H[i] - H[ik: i]))

print(int(DP[-1]))

Fixed submission:
import numpy as np

n, k = map(int, input().split())
H = np.array(list(map(int, input().split())))
DP = np.zeros(n, dtype="int")
DP[1] = abs(H[1] - H[0])
for i in range(2, n):
    ik = max(0, i - k)
    DP[i] = np.min(DP[ik: i] + np.abs(H[i] - H[ik: i]))

print(DP[-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)

ans = 0
count = 0
for i in range(n):
    if s[i] == "W":
        ans += s[: i].count("B")

print(ans)


Fixed submission:
s = input()
n = len(s)

ans = 0
count = 0
for i in range(n):
    if s[i] == "W":
        ans += i - count
        count += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
H = sorted([int(input()) for _ in range(n)])

ans = 10e10
for i in range(n - k + 1):
    select = H[i: i + k]
    ans = min(ans, select[-1] - select[0])

print(ans)


Fixed submission:
n, k = map(int, input().split())
H = sorted([int(input()) for _ in range(n)])
ans = 10e10
for i in range(n - k + 1):
    ans = min(ans, H[i + k - 1] - H[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]

PY_sort = sorted(PY, key=lambda x: x[1])
PY_sort.sort(key=lambda x: x[0])

ID = {}
for i in range(1, n + 1):
    T = [py for py in PY_sort if py[0] == i]
    for i, v in enumerate(T):
        id = "%06d%06d"%(v[0], i + 1)
        ID[v[1]] = id

for p, y in PY:
    print(ID[y])


Fixed submission:
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]

PY_sort = sorted(PY, key=lambda x: x[1])
PY_sort.sort(key=lambda x: x[0])

ID = {}
i, p = 1, PY_sort[0][0]
for v in PY_sort:
    if v[0] != p:
        i, p = 1, v[0]
    id = "%06d%06d"%(p, i)
    ID[v[1]] = id
    i += 1

for p, y in PY:
    print(ID[y])
Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
A = list(map(int, input().split()))

A.sort()

max_cmb = 0
m = A[-1]
r = 0
for a in A[: -1]:
    cmb = math.factorial(m) // (math.factorial(m - a) * math.factorial(a))
    if max_cmb < cmb:
        max_cmb = cmb
        r = a

print(m, r)

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

A.sort()

m = A[-1]
M = [abs((m / 2) - a) for a in A[: -1]]
r = A[M.index(min(M))]

print(m, r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
for i in range(n):
    visit = A[:i ] + A[i + 1 :]
    visit = [0] + visit + [0]
    cost = [abs(visit[i] - visit[i - 1]) for i in range(1, len(visit))]
    print(sum(cost))

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
plan = [0] + A + [0]
cost = sum([abs(plan[i] - plan[i - 1]) for i in range(1, len(plan))])

for i in range(1, n + 1):
    diff = (abs(plan[i - 1] - plan[i]) + abs(plan[i] - plan[i + 1])) - abs(plan[i - 1] - plan[i + 1])
    print(cost - diff)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

count = 0
for i in range(n):
    for j in range(bisect.bisect(B, A[i]), n):
        k = bisect.bisect(C, B[j])
        if k < n:
            count += (n - k)

print(count)

Fixed submission:
import bisect

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

count = 0
for j in range(n):
    i = bisect.bisect_left(A, B[j])
    k = bisect.bisect(C, B[j])
    count += (i * (n - k))

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]

S = list(set(A))
count = 0
for s in S:
    if A.count(s) % 2 == 1:
        count += 1
print(count)

Fixed submission:
import itertools

n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()

count = 0
itrs = itertools.groupby(A)
for k, v in itrs:
    if len(list(v)) % 2 == 1:
        count += 1

print(count)

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

S = list(set(A))
count = [1 for s in S if A.count(s) % 2 == 1]

print(sum(count))

Fixed submission:
import itertools

n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()

count = 0
itrs = itertools.groupby(A)
for k, v in itrs:
    if len(list(v)) % 2 == 1:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

C = Counter(A)
C = [[k, v] for k, v in C.items() if v >= 2]
C.sort(key=lambda x:x[0], reverse=True)

ans = 0
if len(C) >= 1:
    if C[0][1] >= 4:
        ans = C[0][0] * C[0][0]
    elif len(C) >= 2:
        ans = C[0][0] * C[1][0]

print(ans)

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))

C = Counter(A)
C = [[k, v] for k, v in C.items() if v >= 2]
C.sort(key=lambda x:x[0], reverse=True)

ans = 0
if len(C) >= 1:
    if C[0][1] >= 4:
        ans = C[0][0] * C[0][0]
    elif len(C) >= 2:
        ans = C[0][0] * C[1][0]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]
sec = []
count, cur = 0, 1
while cur not in sec:
    sec.append(cur)
    if cur == 2:
        break
    cur = A[cur - 1]
    count += 1
print(count if 2 in sec else -1)

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
count, current = 0, 1
while current != 2:
    current = A[current - 1]
    count += 1
    if count > n:
        count = -1
        break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]
sec = []
count, cur = 0, 1
while cur not in sec:
    sec.append(cur)
    if cur == 2:
        break
    cur = A[cur - 1]
    count += 1
print(count if 2 in sec else -1)

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
count, current = 0, 1
while current != 2:
    current = A[current - 1]
    count += 1
    if count > n:
        count = -1
        break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]
sec = []
cur = 1
while cur not in sec:
    sec.append(cur)
    if cur == 2:
        break
    cur = A[cur - 1]
print(len(sec) - 1 if 2 in sec else -1)

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
count, current = 0, 1
while current != 2:
    current = A[current - 1]
    count += 1
    if count > n:
        count = -1
        break
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = map(int, input().split())
rate = [0] * 9
for a in A:
    rate[a // 400] += 1
color_min = 8 - rate[:-1].count(0)
color_max = color_min + (min(rate[-1], rate[:-1].count(0)) if rate[-1] > 0 else 0)
print(color_min, color_max)

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

rate = set()
free = 0
for a in A:
    if a < 3200:
        rate.add(a // 400)
    else:
        free += 1

if len(rate) == 0:
    color_min, color_max = 1, n
else:
    color_min, color_max = len(rate), len(rate) + free

print(color_min, color_max)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations_with_replacement

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

ans = 0
if n >= 2 and a <= b:
    cmbs = combinations_with_replacement([i for i in range(a, b + 1)], n - 2)
    D = [sum([a] + list(c) + [b]) for c in cmbs]
    ans = len(set(D))
    
elif n == 1 and a == b:
    ans = 1

print(ans)

Fixed submission:
n, a, b = map(int, input().split())

ans = 0
if n >= 2 and a <= b:
    lst_min = a * (n - 1) + b
    lst_max = a + b * (n - 1)
    
    ans = lst_max - lst_min + 1

elif n == 1 and a == b:
    ans = 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

ans = 0
for i in range(1, x + 1):
    L = [i for i in range(1, i + 1)]
    if sum(L) >= x:
        ans = i
        break
print(ans)

Fixed submission:
x = int(input())

ans, pos = 0, 0
for i in range(1, x + 1):
    pos += i
    if pos >= x:
        ans = i
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
lst = [i for i in range(a, b + 1)]

ans = ""
if a < 0 and b > 0:
    ans = "Zero"
elif a > 0:
    ans = "Positive"
else:
    ans = "Positive" if len(lst) % 2 == 0 else "Negative"

print(ans)

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

ans = ""
if a < 0 and b > 0:
    ans = "Zero"
elif a > 0:
    ans = "Positive"
else:
    ans = "Positive" if abs(a - b + 1) % 2 == 0 else "Negative"

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def sign(x):
    return (x > 0) - (x < 0)

a, b = map(int, input().split())
lst = [sign(i) for i in range(a, b + 1)]

num = 1
for l in lst:
    num *= int(l)

ans = ""
if num > 0:
    ans = "Positive"
elif num < 0:
    ans = "Negative"
else:
    ans = "Zero"
print(ans)

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

ans = ""
if a < 0 and b > 0:
    ans = "Zero"
elif a > 0:
    ans = "Positive"
else:
    ans = "Positive" if abs(a - b + 1) % 2 == 0 else "Negative"

print(ans)