Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
T = [[] for i in range(N)]
for i in range(N):
    a = list(input())
    T[i] = a
num = 0
for i in range(N):
    flag = True
    for j in range(N):
        for k in range(N):
            q = k + i
            p = j + i
            if q >= N:
                q -= N
            if p >= N:
                p -= N
            if j == q:
                continue
            if T[j][q] != T[k][p]:
                flag = False

    if flag:
        num += 1

print(num * N)

Fixed submission:
N = int(input())
T = [[] for i in range(N)]
for i in range(N):
    a = list(input())
    T[i] = a
num = 0
for i in range(N):
    flag = True
    for j in range(N):
        for k in range(N):
            q = k + i
            p = j + i
            if q >= N:
                q -= N
            if p >= N:
                p -= N
            if j == q:
                continue
            if T[j][q] != T[k][p]:
                flag = False

    if flag:
        num += 1

print(num * N)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
t = sorted(x)
for i in range(n):
    j = t.index(x[i])
    s = t[:j] + t[j + 1:]
    print(s[n // 2 - 1])

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
t = sorted(x)
mid1, mid2 = t[n // 2 - 1], t[n // 2]
for i in range(n):
    if x[i] <= mid1:
        print(mid2)
    else:
        print(mid1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
for i in range(n):
    t = x[:i] + x[i + 1:]
    t = sorted(t)
    print(t[n // 2 - 1])

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
t = sorted(x)
mid1, mid2 = t[n // 2 - 1], t[n // 2]
for i in range(n):
    if x[i] <= mid1:
        print(mid2)
    else:
        print(mid1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
T = [[0] * (2 * K + 5) for i in range(2 * K + 5)]
for i in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c == 'W':
        y += K
    T[x % (2 * K) + 1][y % (2 * K) + 1] += 1

for i in range(1, 2 * K + 1):
    for j in range(1, 2 * K + 1):
        T[i][j] += T[i][j - 1]


for j in range(1, 2 * K + 1):
    for i in range(1, 2 * K + 1):
        T[i][j] += T[i - 1][j]


num = 0
for i in range(K + 1):
    for j in range(K + 1):
        d = T[i][j]
        d += T[i + K][j + K] - T[i][j + K] - T[i + K][j] + T[i][j]
        d += T[2 * K][j] - T[i + K][j]
        d += T[i][2 * K] - T[i][j + K]
        d += T[2 * K][2 * K] - T[2 * K][j + K] - T[i + K][2 * K] + T[i + K][j + K]
        num = max(num, d)
        num = max(num, N - d)

print(num)


Fixed submission:
N, K = map(int, input().split())
T = [[0] * (2 * K + 5) for i in range(2 * K + 5)]
for i in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c == 'W':
        y += K
    T[x % (2 * K) + 1][y % (2 * K) + 1] += 1

for i in range(1, 2 * K + 1):
    for j in range(1, 2 * K + 1):
        T[i][j] += T[i][j - 1]


for j in range(1, 2 * K + 1):
    for i in range(1, 2 * K + 1):
        T[i][j] += T[i - 1][j]


num = 0
for i in range(K + 1):
    for j in range(K + 1):
        d = T[i][j]
        d += T[i + K][j + K] - T[i][j + K] - T[i + K][j] + T[i][j]
        d += T[2 * K][j] - T[i + K][j]
        d += T[i][2 * K] - T[i][j + K]
        d += T[2 * K][2 * K] - T[2 * K][j + K] - T[i + K][2 * K] + T[i + K][j + K]
        num = max(num, d)
        num = max(num, N - d)

print(num)
Buggy python submission (verdict: Time Limit Exceeded):
Q = int(input())

n = 10 ** 5
is_prime = [True for i in range(n)]

is_prime[0], is_prime[1] = False, False
for i in range(2, n):
    if is_prime[i]:
        j = 2 * i
        while j < n:
            is_prime[j] = False
            j += i

for i in range(Q):
    l, r = map(int, input().split())
    rec = 0
    for j in range(l, r + 1):
        if is_prime[j] and is_prime[(j + 1) // 2]:
            rec += 1
    print(rec)


Fixed submission:
Q = int(input())

n = 10 ** 5
is_prime = [True for i in range(n)]
is_prime[0], is_prime[1] = False, False
for i in range(2, n):
    if is_prime[i]:
        j = 2 * i
        while j < n:
            is_prime[j] = False
            j += i

like_num = [0 for i in range(n)]
rec = 0
for i in range(1, n, 2):
    if is_prime[i] and is_prime[(i + 1) // 2]:
        rec += 1
    like_num[i] = rec

for i in range(Q):
    l, r = map(int, input().split())
    if l == 1:
        print(like_num[r])
    else:
        print(like_num[r] - like_num[l - 2])
Buggy python submission (verdict: Runtime Error):
s = input()
x, y = map(int, input().split())
dic = {"U": (1, 0), "R": (0, 1), "D": (-1, 0), "L": (0, -1)}
rec = []


def dfs(x1, y1, pos, k):
    if k == len(s):
        if (x1, y1) not in rec:
            rec.append((x1, y1))
        return
    else:
        if s[k] == "F":
            nx, ny = x1 + dic[pos][0], y1 + dic[pos][1]
            dfs(nx, ny, pos, k + 1)
        else:
            if pos == "U" or pos == "D":
                dfs(x1, y1, "R", k + 1)
                dfs(x1, y1, "L", k + 1)
            else:
                dfs(x1, y1, "U", k + 1)
                dfs(x1, y1, "D", k + 1)


dfs(0, 0, "R", 0)
if (y, x) in rec:
    print("Yes")
else:
    print("No")

Fixed submission:
S = input()
x, y = map(int, input().split())

T = S.split("T")
u, v = [len(T[0])], [0]
dp = [u, v]
for i in range(1, len(T)):
    s = set()
    k = len(T[i])
    if i % 2 != 0:
        Q = dp[1]
        for j in Q:
            s.add(j - k)
            s.add(j + k)
        dp = [dp[0], list(s)]
    else:
        Q = dp[0]
        for j in Q:
            s.add(j - k)
            s.add(j + k)
        dp = [list(s), dp[1]]
if x in dp[0] and y in dp[1]:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s = input()
x, y = map(int, input().split())
sx, sy = 0, 0
dic = {"U":(1,0), "R":(0, 1), "D":(-1,0), "L":(0, -1)}
rec = []


def dfs(x1, y1, pos, k):
    if k == len(s):
        rec.append((x1, y1))
        return
    else:
        if s[k] == "F":
            nx, ny = x1 + dic[pos][0], y1 + dic[pos][1]
            dfs(nx, ny, pos, k + 1)
        else:
            if pos == "U" or pos == "D":
                dfs(x1, y1, "R", k + 1)
                dfs(x1, y1, "L", k + 1)
            else:
                dfs(x1, y1, "U", k + 1)
                dfs(x1, y1, "D", k + 1)


dfs(0, 0, "R", 0)
if (y, x) in rec:
    print("Yes")
else:
    print("No")



Fixed submission:
S = input()
x, y = map(int, input().split())

T = S.split("T")
u, v = [len(T[0])], [0]
dp = [u, v]
for i in range(1, len(T)):
    s = set()
    k = len(T[i])
    if i % 2 != 0:
        Q = dp[1]
        for j in Q:
            s.add(j - k)
            s.add(j + k)
        dp = [dp[0], list(s)]
    else:
        Q = dp[0]
        for j in Q:
            s.add(j - k)
            s.add(j + k)
        dp = [list(s), dp[1]]
if x in dp[0] and y in dp[1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
d = []
for i in range(N):
    h, p = map(int, input().split())
    d.append((h, p))

d = sorted(d, key=lambda x: x[0] + x[1])
INF = float('inf')
dp = [[INF] * (N + 1) for i in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
    for j in range(N + 1):
        dp[i][j] = dp[i - 1][j]
        if j == 0:
            continue
        if dp[i - 1][j - 1] > d[i - 1][0]:
            continue
        dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + d[i - 1][1])

for i in range(N, -1, -1):
    if dp[N][i] < INF:
        print(i)
        exit()


Fixed submission:
N = int(input())
d = []
for i in range(N):
    h, p = map(int, input().split())
    d.append((h, p))

d = sorted(d, key=lambda x: x[0] + x[1])
INF = float('inf')
dp1 = [INF] * (N + 1)
dp2 = [INF] * (N + 1)
dp1[0] = 0
for i in range(1, N + 1):
    for j in range(N + 1):
        dp2[j] = dp1[j]
        if j == 0:
            continue
        if dp1[j - 1] > d[i - 1][0]:
            continue
        dp2[j] = min(dp2[j], dp1[j - 1] + d[i - 1][1])
    dp1, dp2 = dp2, dp1

for i in range(N, -1, -1):
    if dp1[i] < INF:
        print(i)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop
K = int(input())
INF = float("inf")
d = [INF] * K
G = [[] for i in range(K)]
for i in range(K):
    G[i].append(((i + 1) % K, 1))
    G[i].append(((10 * i) % K, 0))

d[1] = 0
que = [(1, 0)]
while que:
    v, cost = heappop(que)
    if d[v] < cost:
        continue

    for w, c in G[v]:
        if d[w] > d[v] + c:
            d[w] = d[v] + c
            heappush(que, (w, d[w]))

print(d[0] + 1)


Fixed submission:
from heapq import heappush, heappop
K = int(input())
INF = float("inf")
d = [INF] * K
G = [[] for i in range(K)]
for i in range(K):
    G[i].append(((i + 1) % K, 1))
    G[i].append(((10 * i) % K, 0))

d[1] = 0
que = [(1, 0)]
while que:
    v, cost = heappop(que)
    if d[v] < cost:
        continue

    for w, c in G[v]:
        if d[w] > d[v] + c:
            d[w] = d[v] + c
            heappush(que, (w, d[w]))

print(d[0] + 1)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
rec = []
for i in range(len(S)):
    flag = True
    Z = S
    for j in range(len(T)):
        if Z[i] == T[j]:
            for e in range(i - j):
                if Z[e] == "?":
                    Z = Z.replace("?", "a", 1)
            for k in range(len(T)):
                if Z[i + k - j] == T[k]:
                    continue
                elif Z[i + k - j] == "?":
                    Z = Z.replace("?", T[k], 1)
                    print(Z)
                else:
                    flag = False
            if flag:
                Z = Z.replace("?", "a")
                rec.append(Z)
if rec == []:
    print("UNRESTORABLE")
else:
    print(rec[-1])

Fixed submission:
N = int(input())
G = int(input())
print(2*G-N)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
INF = float('inf')
dp = [INF] * N
dp[0] = 0
dp2 = {}
dp2[0] = 0
bits = [1 << i for i in range(26)]
x = 0

for i in range(N):
    x = x ^ bits[ord(S[i]) - ord('a')]
    tmp = INF
    if x not in dp2:
        dp2[x] = INF
    tmp = min(tmp, dp2[x])

    for b in bits:
        k = x ^ b
        if k not in dp2:
            dp2[k] = INF
        tmp = min(tmp, dp2[k])

    dp2[x] = min(dp2[x], tmp + 1)
    dp[i] = tmp + 1

print(dp[N - 1])

Fixed submission:
S = input()
N = len(S)
INF = float('inf')
dp = [INF] * N
dp[0] = 0
dp2 = {}
dp2[0] = 0
bits = [1 << i for i in range(26)]
x = 0

for i in range(N):
    x = x ^ bits[ord(S[i]) - ord('a')]
    tmp = INF
    if x not in dp2:
        dp2[x] = INF
    tmp = min(tmp, dp2[x])

    for b in bits:
        k = x ^ b
        if k not in dp2:
            dp2[k] = INF
        tmp = min(tmp, dp2[k])

    dp2[x] = min(dp2[x], tmp + 1)
    dp[i] = tmp + 1

print(dp[N - 1])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
X, Y = [], []
D = []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    D.append((x, y))

X = sorted(X)
Y = sorted(Y)
num = float("inf")
for i in range(N - 1):
    for j in range(i + 1, N):
        for k in range(N - 1):
            for l in range(k + 1, N):
                tmp = 0
                for m in range(N):
                    if X[i] <= D[m][0] <= X[j] and Y[k] <= D[m][1] <= Y[l]:
                        tmp += 1
                if tmp >= K:
                    num = min(num, (X[j] - X[i]) * (Y[l] - Y[k]))

print(num)


Fixed submission:
N, K = map(int, input().split())
X, Y = [], []
D = []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    D.append((x, y))

X = sorted(X)
Y = sorted(Y)
num = float("inf")
for i in range(N - 1):
    for j in range(i + 1, N):
        for k in range(N - 1):
            for l in range(k + 1, N):
                tmp = 0
                for m in range(N):
                    if X[i] <= D[m][0] <= X[j] and Y[k] <= D[m][1] <= Y[l]:
                        tmp += 1
                if tmp >= K:
                    num = min(num, (X[j] - X[i]) * (Y[l] - Y[k]))

print(num)
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
num = None
rec = 0
for a in range(101):
    for b in range(101):
        if a * A * 100 + b * B * 100 > F:
            break
        for c in range(100):
            if a * A * 100 + b * B * 100 + c * C > F:
                break
            for d in range(100):
                q = a * A * 100 + b * B * 100
                p = C * c + D * d
                if p > E * (a * A + b * B):
                    continue
                if p + q == 0:
                    continue
                if p + q <= F:
                    if rec < 100 * p / (p + q):
                        rec = 100 * p / (p + q)
                        num = (p + q, p)
                else:
                    break
print(num[0], num[1])

Fixed submission:
a, b, c, d, e, f = map(int, input().split())
rec = (0, 0)
ma = 0
for i in range(31):
    for j in range(31):
        for k in range(100):
            t = i * a * 100 + j * b * 100 + c * k
            if t > f:
                break
            for l in range(100):
                s = i * a * 100 + j * b * 100 + c * k + d * l
                if s > f:
                    break
                if c * k + d * l > (a * i + b * j) * e:
                    break
                if (i * a + j * b + c * k + d * l) == 0:
                    continue
                q = (c * k + d * l) / (100 * i * a + 100 * j * b + c * k + d * l) * 100
                if q >= ma:
                    ma = q
                    rec = (s, c * k + d * l)

print(rec[0], rec[1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [[] for i in range(N)]
for i in range(N):
    a = list(map(int, input().split()))
    A[i] = a


num = 0

for i in range(N):
    for j in range(i + 1, N):
        flag = True
        for k in range(N):
            if i == k or k == j:
                continue
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            elif A[i][j] == A[i][k] + A[k][j]:
                flag = False

        if flag:
            num += A[i][j]

print(num)

Fixed submission:
N = int(input())
A = [[] for i in range(N)]
for i in range(N):
    a = list(map(int, input().split()))
    A[i] = a


num = 0

for i in range(N):
    for j in range(i + 1, N):
        flag = True
        for k in range(N):
            if i == k or k == j:
                continue
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            elif A[i][j] == A[i][k] + A[k][j]:
                flag = False

        if flag:
            num += A[i][j]

print(num)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, m, R = map(int, input().split())
r = list(map(int, input().split()))
INF = float("inf")
G = [[INF] * n for i in range(n)]

for i in range(m):
    a, b, c = map(int, input().split())
    G[a - 1][b - 1] = c
    G[b - 1][a - 1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            G[i][j] = min(G[i][k] + G[k][j], G[i][j])

num = INF
for per in itertools.permutations(r):
    rec = 0
    pre = per[0] - 1
    for j in range(1, len(r)):
        rec += G[pre][per[j] - 1]
        pre = per[j] - 1

    num = min(rec, num)

print(num)

Fixed submission:
import itertools
n, m, R = map(int, input().split())
r = list(map(int, input().split()))
INF = float("inf")
G = [[INF] * n for i in range(n)]

for i in range(m):
    a, b, c = map(int, input().split())
    G[a - 1][b - 1] = c
    G[b - 1][a - 1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            G[i][j] = min(G[i][k] + G[k][j], G[i][j])

num = INF
for per in itertools.permutations(r):
    rec = 0
    pre = per[0] - 1
    for j in range(1, len(r)):
        rec += G[pre][per[j] - 1]
        pre = per[j] - 1
        if rec > num:
            break

    num = min(rec, num)

print(num)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
p = [0] * 100005
for i in range(100005):
    p[i] += a.count(i - 1)
    p[i] += a.count(i)
    p[i] += a.count(i + 1)

print(max(p))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
p = [0] * 100005
for i in a:
    p[i] += 1

num = 0
for i in range(1, 100000):
    num = max(num, sum(p[i - 1: i + 2]))

print(num)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [0] + list(map(int, input().split()))
num = 0
for i in range(1, n + 1):
    if i == p[i]:
        num += 1
        p[i], p[i + 1] = p[i + 1], p[i]

print(num)


Fixed submission:
n = int(input())
p = [0] + list(map(int, input().split()))
num = 0
for i in range(1, n + 1):
    if i == n:
        if i == p[i]:
            num += 1
            break
    if i == p[i]:
        num += 1
        p[i], p[i + 1] = p[i + 1], p[i]

print(num)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = [a[0]]
pre = 0
for i in range(1, n):
    if pre == 0:
        q.append(a[i])
        pre ^=1
    else:
        q.insert(0, a[i])
        pre ^= 1

if n % 2 == 0:
    print(" ".join(map(str, q[::-1])))
else:
    print(" ".join(map(str, q)))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
p = [a[i] for i in range(0, n, 2)]
q = [a[i] for i in range(1, n, 2)]

if n % 2 == 0:
    print(" ".join(map(str, q[::-1] + p)))
else:
    print(" ".join(map(str, p[::-1] + q)))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = [a[0]]
pre = 0
for i in range(1, n):
    if pre == 0:
        q.append(a[i])
        pre ^=1
    else:
        q.insert(0, a[i])
        pre ^= 1

if n % 2 == 0:
    print(" ".join(map(str, q[::-1])))
else:
    print(" ".join(map(str, q)))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
p = [a[i] for i in range(0, n, 2)]
q = [a[i] for i in range(1, n, 2)]

if n % 2 == 0:
    print(" ".join(map(str, q[::-1] + p)))
else:
    print(" ".join(map(str, p[::-1] + q)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
rec = {}
for i in range(n):
    a = int(input())
    rec[i + 1] = a

i = 1
rec2  = [1]
num = 0
while i != 2 and num < n:
    i = rec[i]
    if i not in rec2:
        rec2.append(i)
        num += 1
    else:
        num = -1
        break

if num == n:
    print(-1)
else:
    print(num)
    

Fixed submission:
n = int(input())
rec = {}
for i in range(n):
    a = int(input())
    rec[i + 1] = a

i = 1
rec2 = [1]
num = 0
while i != 2 and num < n:
    i = rec[i]
    num += 1

if num == n:
    print(-1)
else:
    print(num)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
rec = {}
for i in range(n):
    a = int(input())
    rec[i + 1] = a

i = 1
rec2  = [1]
num = 0
while i != 2:
    i = rec[i]
    if i not in rec2:
        rec2.append(i)
        num += 1
    else:
        num = -1
        break

print(num)

Fixed submission:
n = int(input())
rec = {}
for i in range(n):
    a = int(input())
    rec[i + 1] = a

i = 1
rec2 = [1]
num = 0
while i != 2 and num < n:
    i = rec[i]
    num += 1

if num == n:
    print(-1)
else:
    print(num)
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] - B * T > 0:
            num += (H[i] - B * T) // (A - B)
            num += int((H[i] - B * T) % (A - B) != 0)
    return T >= num


left, right = 0, 10 ** 9 + 1
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid):
        right = mid
    else:
        left = mid

print(right)

Fixed submission:
N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] - B * T > 0:
            num += (H[i] - B * T) // (A - B)
            num += int((H[i] - B * T) % (A - B) != 0)
    return T >= num


left, right = 0, 10 ** 9 + 1
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid):
        right = mid
    else:
        left = mid

print(right)

Buggy python submission (verdict: Runtime Error):
import math
N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] >= B * T:
            num += math.ceil((H[i] - B * T) / (A - B))
    return T > num


left, right = 1, max(H) // B + 1
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid):
        right = mid
    else:
        left = mid

print(mid)


Fixed submission:
N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] - B * T > 0:
            num += (H[i] - B * T) // (A - B)
            num += int((H[i] - B * T) % (A - B) != 0)
    return T >= num


left, right = 0, 10 ** 9 + 1
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid):
        right = mid
    else:
        left = mid

print(right)

Buggy python submission (verdict: Runtime Error):
import math
N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] >= B * i:
            num += math.ceil((H[i] - B * T) / (A - B))
    return T > num


left, right = 1, max(H) // B + 1
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid):
        right = mid
    else:
        left = mid

print(mid)

Fixed submission:
N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] - B * T > 0:
            num += (H[i] - B * T) // (A - B)
            num += int((H[i] - B * T) % (A - B) != 0)
    return T >= num


left, right = 0, 10 ** 9 + 1
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid):
        right = mid
    else:
        left = mid

print(right)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, inpput().split())
print((a + b) % 24)


Fixed submission:
a, b = map(int, input().split())
print((a + b) % 24)

Buggy python submission (verdict: Runtime Error):
a, b = map(it, inpput().split())
print((a + b) % 24)

Fixed submission:
a, b = map(int, input().split())
print((a + b) % 24)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)


def calc(x):
    if A[x] >= K:
        return True
    dp = [False] * K
    dp[0] = True
    ma = 0
    for i in range(N):
        if i == x:
            continue
        for k in range(ma, -1, -1):
            if k + A[i] >= K:
                continue
            dp[k + A[i]] |= dp[k]
        ma = min(K - 1, ma + A[i])

    return sum(dp[K - A[x]:K])


l, r = 0, N - 1
if not calc(N - 1):
    print(N)
    exit()
if calc(0):
    print(0)
    exit()
while r - l > 1:
    mi = (l + r) // 2
    if calc(mi):
        r = mi
    else:
        l = mi

print(r)


Fixed submission:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)


def calc(x):
    if A[x] >= K:
        return True
    dp = [False] * K
    dp[0] = True
    ma = 0
    for i in range(N):
        if i == x:
            continue
        for k in range(ma, -1, -1):
            if k + A[i] >= K:
                continue
            dp[k + A[i]] |= dp[k]
        ma = min(K - 1, ma + A[i])

    return sum(dp[K - A[x]:K])


l, r = 0, N - 1
if not calc(N - 1):
    print(N)
    exit()
if calc(0):
    print(0)
    exit()
while r - l > 1:
    mi = (l + r) // 2
    if calc(mi):
        r = mi
    else:
        l = mi

print(r)