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

n, k = map(int, input().split())
a = list(map(int, input().split()))
k, v = zip(*collections.Counter(a).most_common()[::-1])
v_list = [i for i in v]
diff = max(0, len(v_list - k))
ans = sum(v_list[:diff])
print(ans)

Fixed submission:
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))
a_cnt = collections.Counter(a).most_common()[::-1]
ans = 0
n = len(list(set(a)))
if n <= k:
    print(0)
    exit()
for v in range(n):
    ans += a_cnt[v][1]
    n -= 1
    if n <= k:
        print(ans)
        exit()
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# MOD = 10 ** 9 + 7
INF = float("inf")


def dijkstra(s, n, graph):
    dist = [INF] * n
    visited = [False] * n
    dist[s] = 0
    hq = [(0, s)]  # (重み，頂点)
    while hq:
        di, pi = heappop(hq)
        visited[pi] = True
        for dj, pj in graph[pi]:
            if visited[pj]:
                continue
            if dist[pj] > di + dj:
                dist[pj] = di + dj
                heappush(hq, (dist[pj], pj))
    return dist


def main():
    N, M = map(int, input().split())
    graph = [[] for _ in range(N)]
    edge = []
    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        graph[a].append((1, b))
        graph[b].append((1, a))
        edge.append((a, b))
    cnt = 0
    for a, b in edge:
        graph[a].remove((1, b))
        graph[b].remove((1, a))
        d = dijkstra(0, N, graph)
        if INF in d:
            cnt += 1
        graph[b].append((1, a))
        graph[a].append((1, b))
    print(cnt)


if __name__ == '__main__':
    main()

Fixed submission:
from collections import defaultdict, deque
import sys
input = sys.stdin.readline


def bfs(s, n, g):
    dist = [-1] * n
    dist[s] = 0
    que = deque([])
    que.append(s)
    while que:
        v = que.popleft()
        for nv in g[v]:
            if dist[nv] != -1:
                continue
            dist[nv] = dist[v] + 1
            que.append(nv)
    if -1 in dist:
        return True
    else:
        return False


def main():
    n, m = map(int, input().split())
    g = [[] for _ in range(n)]
    gg = []
    for _ in range(m):
        a, b = [int(i) - 1 for i in input().split()]
        g[a].append(b)
        g[b].append(a)
        gg.append((a, b))
    ans = 0
    for a, b in gg:
        g[a].remove(b)
        g[b].remove(a)
        if bfs(0, n, g):
            ans += 1
        g[a].append(b)
        g[b].append(a)
    print(ans)
    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# 二部グラフ判定
def dfs(u, c):
    color[u] = c  # 訪問したら指定の色で塗る
    for v in G[u]:  # uからつながっている頂点を順に取り出す
        if color[v] != -1:  # すでに訪問していた場合
            if color[v] == c:
                return False  # 隣接する頂点が同じ色のときはFalse
            else:
                continue
        else:  # 未訪問の時は色は違う色にしてDFSで再帰的に探索
            if not dfs(v, 1 - c):  # FalseだったらFalseを返す
                return False
    return True


# 頂点数と辺数を入力
N, M = map(int, input().split())
# グラフの入力
G = [[] for _ in range(N)]  # 頂点数Nだけ準備
color = [-1] * N  # 未訪問は-1とする
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
# 探索
flag = True
for i in range(N):
    if color[i] == -1:
        if not dfs(i, 0):
            flag = False
            break
if flag:
    ans = color.count(1) * color.count(0) - M
else:
    ans = N * (N - 1) // 2 - M
print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(1000000)

# 二部グラフ判定
def dfs(u, c):
    color[u] = c  # 訪問したら指定の色で塗る
    for v in G[u]:  # uからつながっている頂点を順に取り出す
        if color[v] != -1:  # すでに訪問していた場合
            if color[v] == c:
                return False  # 隣接する頂点が同じ色のときはFalse
            else:
                continue
        else:  # 未訪問の時は色は違う色にしてDFSで再帰的に探索
            if not dfs(v, 1 - c):  # FalseだったらFalseを返す
                return False
    return True


# 頂点数と辺数を入力
N, M = map(int, input().split())
# グラフの入力
G = [[] for _ in range(N)]  # 頂点数Nだけ準備
color = [-1] * N  # 未訪問は-1とする
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
# 探索
flag = True
for i in range(N):
    if color[i] == -1:
        if not dfs(i, 0):
            flag = False
            break
if flag:
    ans = color.count(1) * color.count(0) - M
else:
    ans = N * (N - 1) // 2 - M
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [int(input()) for _ in range(n)]
ans = [i for i in l if l.count(i) % 2 == 1]
print(len(ans))

Fixed submission:
n = int(input())
l = [int(input()) for _ in range(n)]
d = {}
for i in l:
    d[i] = d.get(i, 0) + 1
ans = 0
for v in d.values():
    if v % 2 == 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations


n = int(input())
a = list(map(int, input().split()))
ans = 0
a = [i for i in a if a.count(i) > 1]
b = [j for j in a if a.count(j) > 3]
a = set(a)
b = set(b)
a -= b
a = list(a)
b = list(b)
for v in combinations(a, 2):
    ans = max(ans, v[0] * v[1])
for s in range(len(b)):
    ans = max(ans, s ** 2)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
d = {}
for x in a:
    d[x] = d.get(x, 0) + 1
l = []
ans = 0
for num, cnt in sorted(d.items(), key=lambda x: x[0], reverse=True):
    if cnt > 3:
        if len(l) == 0:
            ans = num ** 2
            print(ans)
            exit()
        else:
            l.append(num)
            ans = l[0] * l[1]
            print(ans)
            exit()
    elif cnt > 1:
        l.append(num)
        if len(l) == 2:
            ans = l[0] * l[1]
            print(ans)
            exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
if n <= 1 or m <= 1:
    print(0)
else:
    print((n-1) * (m-1)

Fixed submission:
n, m = map(int,input().split())
if n <= 1 or m <= 1:
    print(0)
else:
    print((n-1) * (m-1))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
L = list(map(int, input().split()))
L.sort()
L.reverse()
print(L[0] + L[1] + L[2])

Fixed submission:
n, k = map(int, input().split())
L = list(map(int, input().split()))
new_list = sorted(L, reverse=True)
ans = 0
for i in range(k):
    ans += new_list[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(*b)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
odd = a[0::2]
even = a[1::2]
if n % 2 == 1:
    odd = odd[::-1]
    ans = odd + even
else:
    even = even[::-1]
    ans = even + odd
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]
B = []
cnt = 0
i = 0
while i != 1:
    i = A[i]-1
    B.append(i)
    cnt += 1
    if len(B) != len(set(B)):
        print(-1)
        exit()
print(cnt)


Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
B = []
cnt = 0
i = 0
while i != 1:
    i = A[i]-1
    B.append(i)
    cnt += 1
    if cnt > 10**5 + 1:
        print(-1)
        exit()
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = list(int(input()) for _ in range(n))
count = 0
x = L[0]
A = []
while True:
    if x == 2:
        count += 1
        print(count)
        break
    elif x in A:
        print(-1)
        break
    else:
        A.append(x)
        x = L[x-1]
        count += 1

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
B = []
cnt = 0
i = 0
while i != 1:
    i = A[i]-1
    B.append(i)
    cnt += 1
    if cnt > 10**5 + 1:
        print(-1)
        exit()
print(cnt)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
INF = float("inf")

def main():
    n = int(input())
    A = list(map(int, input().split()))
    color = [0] * 8
    god = 0
    for i in A:
        if i < 400:
            color['gray'] = 1
        elif i < 800:
            color['brown'] = 1
        elif i < 1200:
            color['green'] = 1
        elif i < 1600:
            color['light_blue'] = 1
        elif i < 2000:
            color['blue'] = 1
        elif i < 2400:
            color['yellow'] = 1
        elif i < 2800:
            color['orange'] = 1
        elif i < 3200:
            color['red'] = 1
        else:
            god += 1
    # print(color)
    print(len(color), len(color) + god)


if __name__ == '__main__':
    main()


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
color = [0] * 8
select = 0
for i in range(N):
    for j in range(8):
        if 400 * j <= A[i] < 400 * (j + 1):
            color[j] += 1
            break
        elif 400 * (j + 1) == 3200:
            select += 1
            break
ans = 0

for k in range(8):
    if color[k] != 0:
        ans += 1
print(max(ans, 1), ans + select)

Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque, Counter
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    n = int(input())
    A = list(map(int, input().split()))
    color = [0] * 8
    god = 0
    for i in A:
        if i < 400:
            color['gray'] = 1
        elif i < 800:
            color['brown'] = 1
        elif i < 1200:
            color['green'] = 1
        elif i < 1600:
            color['light_blue'] = 1
        elif i < 2000:
            color['blue'] = 1
        elif i < 2400:
            color['yellow'] = 1
        elif i < 2800:
            color['orange'] = 1
        elif i < 3200:
            color['red'] = 1
        else:
            god += 1
    # print(color)
    print(len(color), len(color) + god)


if __name__ == '__main__':
    main()


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
color = [0] * 8
select = 0
for i in range(N):
    for j in range(8):
        if 400 * j <= A[i] < 400 * (j + 1):
            color[j] += 1
            break
        elif 400 * (j + 1) == 3200:
            select += 1
            break
ans = 0

for k in range(8):
    if color[k] != 0:
        ans += 1
print(max(ans, 1), ans + select)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
l = []
for i in range(n):
    a, b = map(int, input().split())
    l += [a] * b
l.sort()
print(l[k-1])


Fixed submission:
n, k = map(int, input().split())
l = [0] * (10**5 + 1)
for i in range(n):
    a, b = map(int, input().split())
    l[a] += b
s = 0
for i, v in enumerate(l):
    s += v
    if s >= k:
        print(i)
        break

Buggy python submission (verdict: Time Limit Exceeded):
List = []
N, K = map(int, input().split())
for i in range(N):
    a, b = map(int, input().split())
    for j in range(b):
        List.append(a)
List.sort()
print(List[K-1])

Fixed submission:
n, k = map(int, input().split())
l = [0] * (10**5 + 1)
for i in range(n):
    a, b = map(int, input().split())
    l[a] += b
s = 0
for i, v in enumerate(l):
    s += v
    if s >= k:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, gcd, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    a, b, c = map(int, input().split())
    num = a
    for i in range(b):
        if num % b == c:
            print("YES")
            exit()
        num += a
    print("NO")


if __name__ == '__main_':
    main()

Fixed submission:
a, b, c = map(int, input().split())
num = a
for i in range(b):
    if num % b == c:
        print('YES')
        break
    num += a
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, gcd, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")

def main():
    a, b, c = map(int, input().split())
    num = a
    r = []
    while True:
        if num % b == c:
            print("YES")
            exit()
        if num % b in r:
            break
        r.append(num % b)
        num += a
    print('NO')

if __name__ == '__main__':
    main()

Fixed submission:
a, b, c = map(int, input().split())
num = a
for i in range(b):
    if num % b == c:
        print('YES')
        break
    num += a
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):

C = []
D = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
for j in range(m):
    c, d = map(int, input().split())
    C.append(c)
    D.append(d)
for i in range(n):
    v_min = float('inf')
    for j in range(m):
        v = abs(A[i] - C[j]) + abs(B[i] - D[j])
        if v_min > v:
            v_min = v
            ans = j + 1
    print(ans)

Fixed submission:
n, m = map(int, input().split())
A = []
B = []
C = []
D = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
for j in range(m):
    c, d = map(int, input().split())
    C.append(c)
    D.append(d)
for i in range(n):
    v_min = float('inf')
    for j in range(m):
        v = abs(A[i] - C[j]) + abs(B[i] - D[j])
        if v_min > v:
            v_min = v
            ans = j + 1
    print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(str, input.split())
if a == b:
    print('H')
else:
    print('D')

Fixed submission:
a, b = map(str, input().split())
if a == b:
    print('H')
else:
    print('D')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(1,n+1):
    ans *= i
print(ans % (10**9 + 7))

Fixed submission:
n = int(input())
ans = 1
for i in range(1, n+1):
    ans *= i
    ans %= (10**9 + 7)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
count = 0
while n >= 1 and m >=2:
    n -= 1
    m -= 2
    count += 1
if m == 0:
    print(count)
else:
    count += m//4
    print(count)

Fixed submission:
n, m = map(int, input().split())
if 2 * n > m:
    ans = m // 2
    print(ans)
else:
    ans = n
    m -= 2 * n
    ans += m//4
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
N = 1
for i in range(1, n + 1):
    N *= i
ans = 0
for j in range(1, N + 1):
    if N % j == 0:
        ans += 1
print(ans % (10 ** 9 + 7))

Fixed submission:
n = int(input())
mod = 10 ** 9 + 7
prime = [1] * 1001  # 素因数の個数の初期値を1に設定する
for num in range(2, n + 1):
    while num % 2 == 0:  # 偶数のとき
        prime[2] += 1  # 2で割れる回数を記録
        num //= 2  # 2で割っておく
    odd = 3
    while odd ** 2 <= num:  # 奇数の素因数を考える
        while num % odd == 0:  # ある奇数で割れた時
            prime[odd] += 1  # 奇数の素因数の個数を記録する
            num //= odd  # 奇数で割っておく
        odd += 2 # 次の奇数にする
    if num != 1:  # numが1でない時はそれ自身で割れるので1追加する
        prime[num] += 1
ans = 1  # ansの初期値を定義する
for i in range(1001):
    ans *= prime[i]  # 約数の個数を計算する
print(ans % mod)  # modで割った余りを出力する
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0
for i in range(S + 1):
    X = S - i
    for j in range(i + 1):
        Y = j
        Z = S - X - Y
        if K >= X >= 0 and K >= Y >= 0 and K >= Z >= 0:
            count += 1
print(count)


Fixed submission:
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        Z = S - i - j
        if K >= Z >= 0:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0
for i in range(S + 1):
    X = S - i
    for j in range(i + 1):
        Y = j
        Z = S - X - Y
        if K >= X >= 0 and K >= Y >= 0 and K >= Z >= 0:
            count += 1
print(count)


Fixed submission:
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        Z = S - i - j
        if K >= Z >= 0:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
W, H, N = map(int, input().split())
x_min = 0
x_max = W
y_min = 0
y_max = H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1 and x > x_min:
        x_min = x
    elif a == 2 and x < x_max:
        x_max = x
    elif a == 3 and y > y_min:
        y_min = y
    elif a == 4 and y < y_max:
        y_max = y
if (x_max - x_min) > 0 or (y_max - y_min) > 0:
    S = (x_max - x_min) * (y_max - y_min)
else:
    S = 0
print(S)

Fixed submission:
l = list(map(int, input().split()))
S = sum(l)
if l[0] + l[1] == l[2] or l[0] + l[2] == l[1] or l[2] + l[1] == l[0]:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
W, H, N = map(int, input().split())
x_min = 0
x_max = W
y_min = 0
y_max = H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1 and x > x_min:
        x_min = x
    elif a == 2 and x < x_max:
        x_max = x
    elif a == 3 and y > y_min:
        y_min = y
    elif a ==4 and y < y_max:
        y_max = y
if (x_max - x_min) <= 0 or (y_max - y_min) < 0:
    S = 0
else:
    S = (x_max - x_min) * (y_max - y_min)
print(S)

Fixed submission:
l = list(map(int, input().split()))
S = sum(l)
if l[0] + l[1] == l[2] or l[0] + l[2] == l[1] or l[2] + l[1] == l[0]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, gcd, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    qa = deque(input())
    qb = deque(input())
    qc = deque(input())
    s = qa.popleft()
    while qa or qb or qc:
        if s == 'a':
            s = qa.popleft()
            if not qa:
                print('A')
                exit()
        elif s == 'b':
            s = qb.popleft()
            if not qb:
                print('B')
                exit()
        else:
            s = qc.popleft()
            if not qc:
                print('C')
                exit()

if __name__ == '__main__':
    main()

Fixed submission:
A = list(input())
B = list(input())
C = list(input())
x = 'a'
while True:
    if x == 'a':
        if len(A) == 0:
            print('A')
            break
        x = A[0]
        A.remove(x)
    elif x == 'b':
        if len(B) == 0:
            print('B')
            break
        x = B[0]
        B.remove(x)
    else:
        if len(C) == 0:
            print('C')
            break
        x = C[0]
        C.remove(x)
Buggy python submission (verdict: Runtime Error):
K = input()
S = int(input())

if len(K) <= S:
    print(K)
else:
    print(K[0:S] + '...')

Fixed submission:
K = int(input())
S = input()

if len(S) <= K:
    print(S)
else:
    print(S[0:K] + '...')
Buggy python submission (verdict: Runtime Error):
X=int(input())
five=[i**5 for i in range(100) ]
flg=0
for i in range(len(five)):
    for j in range(len(five)):
        if five[i]+five[j]==X:
            flg=1
            ans_1=i
            ans_2=-j
        if five[i]-five[j]==X:
            ans_1=i
            ans_2=j
print(ans_1,ans_2)

Fixed submission:
X=int(input())
five=[i**5 for i in range(1000) ]
flg=0
for i in range(len(five)):
    for j in range(len(five)):
        if five[i]+five[j]==X:
            flg=1
            ans_1=i
            ans_2=-j
        if five[i]-five[j]==X:
            ans_1=i
            ans_2=j
print(ans_1,ans_2)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd,numbers)
Sum=0
K=int(input())
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
           
            Sum+=gcd(a,b,c)
print(Sum)


Fixed submission:
import math
from math import gcd
gcd_sum=[0]*201
ans =0 
k=int(input())
for i in range(1,k+1):
    for j in range(1,k+1):
        gcd_sum[i]+=gcd(i,j)


for a in range(1,k+1):
    for b in range(1,k+1):
            g=gcd(a,b)
            ans+=gcd_sum[g]
print(ans)

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

def gcd(*numbers):
    return reduce(math.gcd,numbers)
Sum=0
K=int(input())
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
           
            Sum+=gcd(a,b,c)
print(Sum)


Fixed submission:
import math
from math import gcd
gcd_sum=[0]*201
ans =0 
k=int(input())
for i in range(1,k+1):
    for j in range(1,k+1):
        gcd_sum[i]+=gcd(i,j)


for a in range(1,k+1):
    for b in range(1,k+1):
            g=gcd(a,b)
            ans+=gcd_sum[g]
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())


A=list(map(int,input().split()))
Sum=sum(A)
pop=[]
l=Sum/(4*M)
for i in range(N):
    if(A[i]>l):
        pop.append(A[i])
        
print("Yes" if len(pop)=M else "No")

Fixed submission:
A,B,C=map(int,input().split())
print(C,A,B)
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
 
ans = 1
 
 while N >= K:
    N = N // K
    ans += 1
    
print(ans)

Fixed submission:
N, K = map(int,input().split())
 
ans = 1

while N >= K:
    N = N // K
    ans += 1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[input() for _ in range(N)]
S_set=list(set(S))

S_count=[S.count(w) for w in S_set]
S_vests=[S_set[i] for i in range(len(S_count)) if S_count[i]==max(S_count)]
S_vests.sort()
for i in range(len(S_vests)):
    print(S_vests[i])

Fixed submission:
N=int(input())

d={}
for _ in range(N):
    S=input()
    if S in d:
        d[S]+=1
    else:
        d[S]=1
        
m=max(d.values())
for s in sorted(k for k in d if d[k]==m):
    print(s)
Buggy python submission (verdict: Runtime Error):
from math import gcd
N=int(input())
A=list(map(int,input().split()))
flg=1
for i in range(N):
    for j in range(i+1,N):
        if gcd(A[i],A[j])!=1:
            flg=0
print("YES" if flg else "NO")        
        

Fixed submission:
import sys
 
 
def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    for i in range(1, n):
        if a[i] == a[i-1]:
            print("NO")
            exit()
    print("YES")
 
 
if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
N=int(input())
P=list(map(int,input().split()))
cnt=0
for i in range(N):
    M=min(P[:i+1])
    if M==P[i]:
        cnt+=1
print(cnt)

Fixed submission:
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)
H_new=H[K:]
print(sum(H_new))