Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

def main():
    INF = float("inf")

    N, *S = map(int, open(0).read().split())

    S.sort(reverse=True)

    P = [S[0]]
    S[0] = INF
    for _ in range(N):
        Q = P[:]
        while Q:
            q = heappop(Q)

            for i, s in enumerate(S):
                if s < q:
                    heappush(P, s)
                    S[i] = INF
                    break
            else:
                print("No")
                quit()

    print("Yes")


main()


Fixed submission:
INF = float("inf")

N, *S = map(int, open(0).read().split())
M = len(S)

S.sort(reverse=True)

Q = [S[0]]
S[0] = INF
for _ in range(N):
    Q.sort()
    T = Q[:]

    cur = 1
    while Q:
        p = Q.pop()
        while S[cur] >= p:
            cur += 1
            if cur == M:
                print("No")
                exit()
        T.append(S[cur])
        S[cur] = INF

    Q = T

print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

def main():
    INF = float("inf")

    N, *S = map(int, open(0).read().split())

    S.sort(reverse=True)

    P = [S[0]]
    for _ in range(N):
        Q = P[:]
        while Q:
            q = heappop(Q)

            for i, s in enumerate(S):
                if s < q:
                    heappush(P, s)
                    S[i] = INF
                    break
            else:
                print("No")
                quit()

    print("Yes")


main()


Fixed submission:
INF = float("inf")

N, *S = map(int, open(0).read().split())
M = len(S)

S.sort(reverse=True)

Q = [S[0]]
S[0] = INF
for _ in range(N):
    Q.sort()
    T = Q[:]

    cur = 1
    while Q:
        p = Q.pop()
        while S[cur] >= p:
            cur += 1
            if cur == M:
                print("No")
                exit()
        T.append(S[cur])
        S[cur] = INF

    Q = T

print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
INF = float("inf")

N, *S = map(int, open(0).read().split())

S.sort(reverse=True)

T = [S[0]]
for _ in range(N):
    T.sort()

    Q = T[:]
    while Q:
        q = Q.pop()

        for i, s in enumerate(S):
            if s < q:
                T.append(s)
                S[i] = INF
                break
        else:
            print("No")
            quit()

print("Yes")


Fixed submission:
INF = float("inf")

N, *S = map(int, open(0).read().split())
M = len(S)

S.sort(reverse=True)

Q = [S[0]]
S[0] = INF
for _ in range(N):
    Q.sort()
    T = Q[:]

    cur = 1
    while Q:
        p = Q.pop()
        while S[cur] >= p:
            cur += 1
            if cur == M:
                print("No")
                exit()
        T.append(S[cur])
        S[cur] = INF

    Q = T

print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
INF = float("inf")

N, *S = map(int, open(0).read().split())

S.sort(reverse=True)

T = [S[0]]
for _ in range(N):
    T.sort()

    Q = T[:]
    while Q:
        q = Q.pop()

        for i, s in enumerate(S):
            if s < q:
                T.append(s)
                S[i] = INF
                break
        else:
            print("No")
            quit()

print("Yes")


Fixed submission:
INF = float("inf")

N, *S = map(int, open(0).read().split())
M = len(S)

S.sort(reverse=True)

Q = [S[0]]
S[0] = INF
for _ in range(N):
    Q.sort()
    T = Q[:]

    cur = 1
    while Q:
        p = Q.pop()
        while S[cur] >= p:
            cur += 1
            if cur == M:
                print("No")
                exit()
        T.append(S[cur])
        S[cur] = INF

    Q = T

print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

INF = float("inf")

N, *S = map(int, open(0).read().split())

S.sort(reverse=True)

P = [S[0]]
for _ in range(N):
    Q = P[:]
    while Q:
        q = heappop(Q)

        for i, s in enumerate(S):
            if s < q:
                heappush(P, s)
                S[i] = INF
                break
        else:
            print("No")
            quit()

print("Yes")

Fixed submission:
INF = float("inf")

N, *S = map(int, open(0).read().split())
M = len(S)

S.sort(reverse=True)

Q = [S[0]]
S[0] = INF
for _ in range(N):
    Q.sort()
    T = Q[:]

    cur = 1
    while Q:
        p = Q.pop()
        while S[cur] >= p:
            cur += 1
            if cur == M:
                print("No")
                exit()
        T.append(S[cur])
        S[cur] = INF

    Q = T

print("Yes")