Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline

N, *ab = map(int, read().split())
graph = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)
    graph[b].append(a)

k0 = list(range(3, N + 1, 3))
k1 = list(range(1, N + 1, 3))  # 1番多い
k2 = list(range(2, N + 1, 3))

start = ab[0]
color = 1  # 1が黒
queue = deque([(start, color)])
answer = [0] * (N + 1)
answer[start] = k1.pop()
while queue:
    V, c = queue.popleft()
    c = -c
    for v in graph[V]:
        if answer[v] == 0:
            if c == 1:
                if k1:
                    answer[v] = k1.pop()
                else:
                    answer[v] = k0.pop()
            else:
                if k2:
                    answer[v] = k2.pop()
                else:
                    answer[v] = k0.pop()
            queue.append((v, c))

print(' '.join(map(str, answer[1:])))


Fixed submission:
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline

N, *ab = map(int, read().split())

if N == 2:
    print(1, 2)
    exit()

graph = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)
    graph[b].append(a)

k0 = list(range(3, N + 1, 3))
k1 = list(range(1, N + 1, 3))  # 1番多い
k2 = list(range(2, N + 1, 3))

start = ab[0]
color = 1  # 1が黒
queue = deque([(start, color)])
colors = [0] * (N + 1)
colors[start] = 1
while queue:
    V, c = queue.popleft()
    c = -c
    for v in graph[V]:
        if colors[v] == 0:
            colors[v] = c
            queue.append((v, c))

black = colors.count(1)
white = N - black
three = (N - 3) // 3 + 1
if black <= three:
    b = k0[:black]
    w = k1 + k2 + k0[black:]
    answer = [b.pop() if i == 1 else w.pop() for i in colors[1:]]
    print(' '.join(map(str, answer)))
elif white <= three:
    w = k0[:white]
    b = k1 + k2 + k0[white:]
    answer = [b.pop() if i == 1 else w.pop() for i in colors[1:]]
    print(' '.join(map(str, answer)))
else:
    answer = [0] * (N + 1)
    for i in range(1, N + 1):
        if colors[i] == 1:
            if k1:
                answer[i] = k1.pop()
            else:
                answer[i] = k0.pop()
        else:
            if k2:
                answer[i] = k2.pop()
            else:
                answer[i] = k0.pop()
    print(' '.join(map(str, answer[1:])))
Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter

read = sys.stdin.read

N, *S = map(str, read().split())
s = Counter(S)
n = max(s.values())
answer = [i for i, j in s if j == n]
answer.sort()
print('\n'.join(answer))


Fixed submission:
import sys
from collections import Counter

read = sys.stdin.read

N, *S = map(str, read().split())
s = Counter(S).most_common()
n = s[0][1]
answer = [i for i, j in s if j == n]
answer.sort()
print('\n'.join(answer))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

read = sys.stdin.read

H, N, *AB = map(int, read().split())

INF = 10 ** 10
dp = [INF] * (H + 1)
r = INF
dp[0] = 0

for a, b in zip(*[iter(AB)] * 2):
    for i in range(a, H + 1):
        dp[i] = min(dp[i], dp[i - a] + b)
    r = min(r, min(dp[-a:]) + b)

print(min(r, dp[-1]))


Fixed submission:
import sys

read = sys.stdin.read

H, N, *AB = map(int, read().split())

INF = 10 ** 10
dp = [INF] * (H + 1)
r = INF
dp[0] = 0

for a, b in zip(*[iter(AB)] * 2):
    for i in range(a, H + 1):
        dp[i] = min(dp[i], dp[i - a] + b)
    r = min(r, min(dp[-a:]) + b)

print(min(r, dp[-1]))

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

read = sys.stdin.read

H, N, *AB = map(int, read().split())

INF = 10 ** 10
dp = [INF] * (H + 2)
dp[0] = 0

for a, b in zip(*[iter(AB)] * 2):
    for i in range(a, H + 1):
        dp[i] = min(dp[i], dp[i - a] + b)

    dp[-1] = min(dp[-1], min(dp[-a - 1:]) + b)

print(min(dp[-2], dp[-1]))


Fixed submission:
import sys

read = sys.stdin.read

H, N, *AB = map(int, read().split())

INF = 10 ** 10
dp = [INF] * (H + 1)
r = INF
dp[0] = 0

for a, b in zip(*[iter(AB)] * 2):
    for i in range(a, H + 1):
        dp[i] = min(dp[i], dp[i - a] + b)
    r = min(r, min(dp[-a:]) + b)

print(min(r, dp[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

read = sys.stdin.read

N, D, A, *XH = map(int, read().split())
X = np.array(XH[::2], np.int64)
H = np.array(XH[1::2], np.int64)
D *= 2

arg = np.argsort(X)
X = X[arg]
H = H[arg]

answer = 0
for i in range(N):
    if H[i] <= 0:
        continue
    h = H[i]
    cnt = h // A + min(1, h % A)
    n = np.searchsorted(X, X[i] + D, side='right')
    H[i:n] -= A * cnt
    answer += cnt

print(answer)


Fixed submission:
import sys
from bisect import bisect_right

read = sys.stdin.read

N, D, A, *XH = map(int, read().split())
X = XH[::2]
H = XH[1::2]
D *= 2
X, H = zip(*sorted(zip(X, H)))

damage = [0] * (N + 1)
answer = H[0] // A + min(1, H[0] % A)
damage[0] += A * answer
damage[bisect_right(X, X[0] + D)] -= A * answer

for i in range(1, N):
    damage[i] += damage[i - 1]
    h = H[i]
    x = X[i]
    if damage[i] >= h:
        continue
    else:
        h -= damage[i]

    cnt = h // A + min(1, h % A)
    answer += cnt
    damage[i] += A * cnt
    damage[bisect_right(X, x + D)] -= A * cnt

print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

read = sys.stdin.read
N, M, *A = map(int, read().split())
A = np.array(A, np.int64)

a = A[None, :] + A[:, None]
a = a.flatten()

a.sort()
print(a[-M:].sum())

Fixed submission:
import sys
import numpy as np

read = sys.stdin.read
N, M, *A = map(int, read().split())

A.sort()
A_as = np.array(A, np.int64)
A_rev = np.array(A[::-1], np.int64)
a = A_rev.cumsum()
a_max = a[-1]

left = 0
right = A[-1] * 2 + 1
while right - left > 1:
    mid = (right + left) // 2
    n = N - np.searchsorted(A_as, mid - A_as)
    n[n < 0] = 0
    m = n.sum()
    if m >= M:
        left = mid
    else:
        right = mid

threshold = left

n = N - np.searchsorted(A_as, threshold - A_as, side='right')
n[n < 0] = 0
answer = a[n[n > 0] - 1].sum() + (A_as * n).sum()
if n.sum() != M:
    answer -= threshold * (n.sum() - M)

print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
from itertools import islice
read = map(int, sys.stdin.read().split())

N = next(read)
candidates = [format(i, 'b').zfill(N) for i in range(2 ** N)]
A = [0] * 3
xy = [[] for _ in range(N)]
for i in range(N):
    A[i] = next(read)
    xy[i].extend(list(islice(read, A[i] * 2)))

answer = 0

for candidate in candidates:
    tmp = 0
    truth = set()
    false = set()
    for k in range(N):
        if candidate[k] == '1':
            truth.add(k)
            for i, j in zip(*[iter(xy[k])] * 2):
                i -= 1
                if j == 1:
                    if i in false:
                        break
                    truth.add(i)
                else:
                    if i in truth:
                        break
                    false.add(i)
            else:
                continue
            break
        else:
            if k in truth:
                break
            false.add(k)
    else:
        if len(truth) > answer:
            answer = len(truth)

print(answer)

Fixed submission:
import sys
from itertools import islice
read = map(int, sys.stdin.read().split())

N = next(read)
candidates = [format(i, 'b').zfill(N) for i in range(2 ** N)]
A = [0] * N
xy = [[] for _ in range(N)]
for i in range(N):
    A[i] = next(read)
    xy[i].extend(list(islice(read, A[i] * 2)))

answer = 0

for candidate in candidates:
    tmp = 0
    truth = set()
    false = set()
    for k in range(N):
        if candidate[k] == '1':
            if k in false:
                break
            truth.add(k)
            for i, j in zip(*[iter(xy[k])] * 2):
                i -= 1
                if j == 1:
                    if i in false:
                        break
                    truth.add(i)
                else:
                    if i in truth:
                        break
                    false.add(i)
            else:
                continue
            break
        else:
            if k in truth:
                break
            false.add(k)
    else:
        if len(truth) > answer:
            answer = len(truth)

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read

N, *A = map(int, read().split())
mod = 10 ** 9 + 7
answer = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        answer += A[i] ^ A[j]
        answer %= mod

print(answer)

Fixed submission:
import sys
import numpy as np

read = sys.stdin.read

N, *A = map(int, read().split())
a = np.array(A, np.int64)
mod = 10 ** 9 + 7
answer = 0
for i in range(60):
    bit = np.count_nonzero(a & 1)
    answer += 2 ** i * bit * (N - bit)
    answer %= mod
    a >>= 1

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
read = sys.stdin.read

N, *ab = map(int, read().split())
graph = [[] for _ in range(N + 1)]

for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)

color = [0] * (N + 1)
queue = deque([1])
color_v = [[] for _ in range(N + 1)]

while queue:
    V = queue.popleft()
    number = 1
    for v in graph[V]:
        if number in color_v[V]:
            number += 1
        color[v] = number
        color_v[V].append(number)
        color_v[v].append(number)
        queue.append(v)
        number += 1

print(max(color))
for a, b in zip(*[iter(ab)] * 2):
    print(color[b])

Fixed submission:
import sys
from collections import deque
read = sys.stdin.read

N, *ab = map(int, read().split())
graph = [[] for _ in range(N + 1)]

for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)

color = [0] * (N + 1)
queue = deque([1])
color_v = [set() for _ in range(N + 1)]

while queue:
    V = queue.popleft()
    number = 1
    for v in graph[V]:
        if number in color_v[V]:
            number += 1
        color[v] = number
        color_v[V].add(number)
        color_v[v].add(number)
        queue.append(v)
        number += 1

print(max(color))
for a, b in zip(*[iter(ab)] * 2):
    print(color[b])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
read = sys.stdin.read

N, *ab = map(int, read().split())
graph = [[] for _ in range(N + 1)]

for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)

color = [0] * (N + 1)
root = 1
queue = deque([root])
color_v = [[] for _ in range(N + 1)]

while queue:
    V = queue.popleft()
    number = 1
    for v in graph[V]:
        while number in color_v[V]:
            number += 1
        color[v] = number
        color_v[V].append(number)
        color_v[v].append(number)
        queue.append(v)

print(max(color))
for a, b in zip(*[iter(ab)] * 2):
    print(color[b])

Fixed submission:
import sys
from collections import deque
read = sys.stdin.read

N, *ab = map(int, read().split())
graph = [[] for _ in range(N + 1)]

for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)

color = [0] * (N + 1)
queue = deque([1])
color_v = [set() for _ in range(N + 1)]

while queue:
    V = queue.popleft()
    number = 1
    for v in graph[V]:
        if number in color_v[V]:
            number += 1
        color[v] = number
        color_v[V].add(number)
        color_v[v].add(number)
        queue.append(v)
        number += 1

print(max(color))
for a, b in zip(*[iter(ab)] * 2):
    print(color[b])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from operator import itemgetter
import numpy as np
read = sys.stdin.read

N, M, *LRC = map(int, read().split())
dp = np.full(N + 1, np.inf)
dp[1] = 0

for L, R, C in sorted(list(zip(*[iter(LRC)] * 3)), key=itemgetter(0, 1)):
    dp[L + 1:R + 1] = np.minimum(dp[L + 1:R + 1], np.minimum.accumulate(dp[L:R + 1] + C)[1:])

if dp[N] == np.inf:
    print(-1)
else:
    print(int(dp[N]))

Fixed submission:
import sys
from heapq import heapify, heappush, heappop
read = sys.stdin.read


def main():
    N, M, *LRC = map(int, read().split())
    graph = [[(0, i - 1)] for i in range(N + 1)]
    graph[1] = []

    for L, R, C in zip(*[iter(LRC)] * 3):
        graph[L].append((C, R))

    distance = [-1] * (N + 1)
    queue = []
    heapify(queue)
    heappush(queue, (0, 1))

    while queue:
        cost, node = heappop(queue)
        if distance[node] == -1:
            distance[node] = cost
            for add_cost, next_node in graph[node]:
                if distance[next_node] == -1:
                    heappush(queue, (cost + add_cost, next_node))

    print(distance[-1])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from operator import itemgetter
import numpy as np
read = sys.stdin.read

N, M, *LRC = map(int, read().split())
dp = np.full(N + 1, np.inf)
dp[1] = 0

for L, R, C in sorted(list(zip(*[iter(LRC)] * 3)), key=itemgetter(0, 1)):
    dp[L + 1:R + 1] = np.minimum(dp[L + 1:R + 1], dp[L] + C)
    dp[L + 1:R + 1] = np.minimum(dp[L + 1:R + 1], np.minimum.accumulate(dp[L + 1:R + 1] + C))

if dp[N] == np.inf:
    print(-1)
else:
    print(int(dp[N]))

Fixed submission:
import sys
from heapq import heapify, heappush, heappop
read = sys.stdin.read


def main():
    N, M, *LRC = map(int, read().split())
    graph = [[(0, i - 1)] for i in range(N + 1)]
    graph[1] = []

    for L, R, C in zip(*[iter(LRC)] * 3):
        graph[L].append((C, R))

    distance = [-1] * (N + 1)
    queue = []
    heapify(queue)
    heappush(queue, (0, 1))

    while queue:
        cost, node = heappop(queue)
        if distance[node] == -1:
            distance[node] = cost
            for add_cost, next_node in graph[node]:
                if distance[next_node] == -1:
                    heappush(queue, (cost + add_cost, next_node))

    print(distance[-1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from math import atan, degrees

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

if x > a * a * b // 2:
    print(90 - degrees(atan(a / (2 * (b - x / a ** 2)))))
else:
    print(90 - degrees(atan((2 * x / (a * b)) / b)))

Fixed submission:
from math import atan, degrees

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

if a * a * b == x:
    print(0)
elif x > a * a * b // 2:
    print(90 - degrees(atan(a / (2 * (b - x / a ** 2)))))
else:
    print(90 - degrees(atan((2 * x / (a * b)) / b)))
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heapify, heappop, heappush

N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)
af = tuple(zip(A, F))

v = [i * j for i, j in af]

heap = list(zip([-i for i in v], A, F))
heapify(heap)

for _ in range(K):
    a, b, c = heappop(heap)
    a = -a
    new = (a - 1) * b
    heappush(heap, (-(b - 1) * c, b - 1, c))

a, b, c = heappop(heap)
print(-a)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)
A.sort()
F.sort()
F = F[::-1]
dig = A.sum()


def judge(x):
    return dig - np.minimum(A, x // F).sum() <= K


l = -1
r = 10 ** 18 + 1

while l + 1 < r:
    test = (l + r) // 2
    if judge(test):
        r = test
    else:
        l = test

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from bisect import bisect_left

N = int(input())
A = list(map(int, input().split()))
a = list(Counter(A).values())
a.sort()
s = sum(a)

for i in range(1, N + 1):
    if i == 1:
        print(s)
    elif len(a) < i:
        print(0)
    else:
        n = s // i
        for j in reversed(range(1, n + 1)):
            t = bisect_left(a, j)
            if j * i <= sum(a[:t]) + (len(a) - t) * j:
                print(j)
                break

Fixed submission:
from collections import Counter
from bisect import bisect_left
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
a = list(Counter(A).values())
a.sort()
b = list(accumulate(a + [0]))
s = sum(a)
length = len(a)

for i in range(1, N + 1):
    if i == 1:
        print(s)
    elif len(a) < i:
        print(0)
    else:
        n = s // i
        for j in reversed(range(1, n + 1)):
            t = bisect_left(a, j)
            if j * i <= b[t - 1] + (length - t) * j:
                print(j)
                break
Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B = map(int, input().split())
ans = 1


def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


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


for i in cf(A, B):
    ans += is_prime(i)

print(ans)

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


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


a = set(prime_decomposition(A))
b = set(prime_decomposition(B))

print(len(a & b) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
INF = float('inf')
p = 2 ** N
dp = [INF] * p
dp[0] = 0

for _ in range(M):
    a, b = map(int, input().split())
    c = sum([1 << (i - 1) for i in map(int, input().split())])
    for i in range(p):
        dp[i | c] = min(dp[i] + a, dp[i | c])

if dp[-1] != INF:
    print(dp[-1])
else:
    print(-1)

Fixed submission:
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
INF = 10 ** 10
p = 2 ** N
dp = [INF] * p
dp[0] = 0

for _ in range(M):
    a, b = map(int, input().split())
    c = sum([2 ** (i - 1) for i in map(int, input().split())])
    for i in range(p):
        dp[i | c] = min(dp[i] + a, dp[i | c])

if dp[-1] != INF:
    print(dp[-1])
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
INF = float('inf')
p = 2 ** N
dp = [INF] * p
dp[0] = 0

for _ in range(M):
    a, b = map(int, input().split())
    c = sum([2 ** (i - 1) for i in map(int, input().split())])
    for i in range(p):
        dp[i | c] = min(dp[i] + a, dp[i | c])

if dp[-1] != INF:
    print(dp[-1])
else:
    print(-1)

Fixed submission:
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
INF = 10 ** 10
p = 2 ** N
dp = [INF] * p
dp[0] = 0

for _ in range(M):
    a, b = map(int, input().split())
    c = sum([2 ** (i - 1) for i in map(int, input().split())])
    for i in range(p):
        dp[i | c] = min(dp[i] + a, dp[i | c])

if dp[-1] != INF:
    print(dp[-1])
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque

read = sys.stdin.read

N, M = map(int, input().split())
if M != 0:
    AB = list(map(int, read().split()))
else:
    print(-1)
    exit()

graph = [[] for _ in range(N + 1)]
A = AB[::2]
B = AB[1::2]
A_s = set(A)
# 出次数が0の頂点はいらない。
needless = set(range(1, N + 1)) - A_s

for i, j in zip(A, B):
    if j not in needless:
        graph[i].append(j)

for i in A_s:
    if not graph[i]:
        print(-1)
        exit()

stack = [i for i in range(1, N + 1) if len(graph[i]) == 1]
answer = []
while stack:
    v = stack.pop()
    queue = deque([(v, [v])])
    while queue:
        v_1, route = queue.popleft()
        for i in graph[v_1]:
            if i in route:
                route = route[route.index(i):]
                answer.append((len(route), route))
            else:
                queue.append((i, route + [i]))

K, a = min(answer)
print(K)
print('\n'.join(map(str, a)))

Fixed submission:
import sys

read = sys.stdin.read

N, M = map(int, input().split())
if M != 0:
    AB = list(map(int, read().split()))
else:
    print(-1)
    exit()

graph = [[] for _ in range(N + 1)]
A = AB[::2]
B = AB[1::2]
A_s = set(A)
# 出次数が0の頂点はいらない。
needless = set(range(1, N + 1)) - A_s

for i, j in zip(A, B):
    if j not in needless:
        graph[i].append(j)


# cycleを少なくとも一つ検出する
def dfs(original_stack):
    checked = [False] * (N + 1)
    while original_stack:
        start = original_stack.pop()
        if checked[start]:
            continue
        checked[start] = True
        stack = [(start, [start])]
        while stack:
            v, route = stack.pop()
            for i in graph[v]:
                if i in route:
                    return route[route.index(i):]
                else:
                    stack.append((i, route + [i]))
                    checked[i] = True


v = dfs([i for i in range(1, N + 1) if graph[i]])
if not v:
    print(-1)
    exit()

while True:
    v_s = set(v)
    length = len(v)
    for i, (v_i, v_j) in enumerate(zip(v, v[1:] + [v[0]])):
        for j in graph[v_i]:
            if j != v_j and j in v_s:
                idx = v.index(j)
                if i < idx:
                    v = v[:i + 1] + v[idx:]
                else:
                    v = v[idx:i + 1]
                break
        else:
            continue
        break
    else:
        print(len(v))
        print('\n'.join(map(str, v)))
        exit()
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[A.index(max(A))] //= 2

print(sum(A))

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
a = []
for i in A:
    heapq.heappush(a, -i)

for i in range(M):
    heapq.heappush(a, -(-heapq.heappop(a) // 2))

print(-sum(a))

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

for i in range(M):
    A[0] //= 2
    A.sort(reverse=True)

print(sum(A))

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
a = []
for i in A:
    heapq.heappush(a, -i)

for i in range(M):
    heapq.heappush(a, -(-heapq.heappop(a) // 2))

print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(int, input().split()))

S.sort()

parents = [S.pop()]

for _ in range(N):
    parents.sort(reverse=True)
    for i in parents[:]:
        not_use = []

        while S:
            tmp = S.pop()
            if tmp < i:
                parents.append(tmp)
                break
            else:
                not_use.append(tmp)
        else:
            print('No')
            exit()

        S.extend(not_use[::-1])
else:
    print('Yes')

Fixed submission:
N = int(input())
S = list(map(int, input().split()))
INF = float('inf')

S.sort()

parents = [S[-1]]
S[-1] = INF

for _ in range(N):
    checking = 2
    parents.sort(reverse=True)
    for i in parents[:]:
        while True:
            if S[-checking] < i:
                parents.append(S[-checking])
                S[-checking] = INF
                break
            else:
                checking += 1
            if checking == 2 ** N + 1:
                print('No')
                exit()
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
n = np.array([i + 1 for i in range(N)])
ans = 0

print(N * (N - 1) // 2)



Fixed submission:
#import numpy as np
N = int(input())
#n = np.array([i + 1 for i in range(N)])
ans = 0

print(N * (N - 1) // 2)