Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, ma, mb = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(n)]

inf = 10 ** 9
lst = [[inf for _ in range(401)] for _ in range(401)]
lst[0][0] = 0
for a, b, c in abc:
    for i in range(400, -1, -1):
        if i - a < 0:
            break
        for j in range(400, -1, -1):
            if j - b < 0:
                break
            lst[i][j] = min(lst[i][j], lst[i - a][j - b] + c)

ans = inf
a = ma
b = mb
while 1:
    try:
        ans = min(ans, lst[a][b])
        a += ma
        b += mb
    except IndexError:
        break
if ans == inf:
    print(-1)
else:
    print(ans)

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

inf = 10 ** 9
lst = [[inf for _ in range(401)] for _ in range(401)]
lst[0][0] = 0
for a, b, c in abc:
    for i in range(400, -1, -1):
        if i - a < 0:
            break
        for j in range(400, -1, -1):
            if j - b < 0:
                break
            lst[i][j] = min(lst[i][j], lst[i - a][j - b] + c)

ans = inf
a = ma
b = mb
while 1:
    try:
        ans = min(ans, lst[a][b])
        a += ma
        b += mb
    except IndexError:
        break
if ans == inf:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import heapq

def dijkstra(n, s, edges):
    hq = [(0, s)]
    cost = [float('inf')] * n
    cost[s] = 0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]:
            continue
        for d, u in edges[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost[-1]

def main():
    xs, ys, xt, yt = map(int, input().split())
    n = int(input())
    circles = []
    circles.append([xs, ys, 0])
    for _ in range(n):
        circles.append(list(map(int, input().split())))
    circles.append([xt, yt, 0])
    edges = [[] for _ in range(n + 2)]
    for i in range(n + 2):
        for j in range(i + 1, n + 2):
            dx = circles[i][0] - circles[j][0]
            dy = circles[i][1] - circles[j][1]
            d = (dx ** 2 + dy ** 2) ** 0.5
            r = circles[i][2] + circles[j][2]
            edges[i].append([max(0, d - r), j])
            edges[j].append([max(0, d - r), i])

    ans = dijkstra(n + 2, 0, edges)
    print(ans)
    
main()

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

def dijkstra(n, s, edges):
    hq = [(0, s)]
    cost = [float('inf')] * n
    cost[s] = 0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]:
            continue
        for d, u in edges[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost[-1]

def main():
    xs, ys, xt, yt = map(int, input().split())
    n = int(input())
    circles = []
    circles.append([xs, ys, 0])
    for _ in range(n):
        circles.append(list(map(int, input().split())))
    circles.append([xt, yt, 0])
    edges = [[] for _ in range(n + 2)]
    for i in range(n + 2):
        for j in range(i + 1, n + 2):
            dx = circles[i][0] - circles[j][0]
            dy = circles[i][1] - circles[j][1]
            d = (dx ** 2 + dy ** 2) ** 0.5
            r = circles[i][2] + circles[j][2]
            edges[i].append([max(0, d - r), j])
            edges[j].append([max(0, d - r), i])

    ans = dijkstra(n + 2, 0, edges)
    print(ans)
    
main()
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
e = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    e[A].append(B)
    e[B].append(A)
# print(e)

def dfs(n, k):
    seen[n] = k
    # print(seen)
    for i in e[n]:
        if seen[i] != -1: continue
        dfs(i, k)

seen = [-1] * N
k = -1
for i in range(N):
    if seen[i] == -1:
        k += 1
        dfs(i, k)
# print(seen)
print(k)

Fixed submission:
import queue

N, M = map(int, input().split())
e = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    e[A].append(B)
    e[B].append(A)
# print(e)

seen = [-1] * N
k = -1
for i in range(N):
    if seen[i] == -1:
        k += 1
        seen[i] = k
        que = queue.Queue()
        que.put(i)
        while not que.empty():
            v = que.get()
            for nv in e[v]:
                if seen[nv] != -1: continue
                seen[nv] = k
                que.put(nv)
# print(seen)
print(k)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
e = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    e[A].append(B)
    e[B].append(A)
# print(e)

def dfs(n, k):
    seen[n] = k
    # print(seen)
    for i in e[n]:
        if seen[i] != -1: continue
        dfs(i, k)
    return

seen = [-1] * N
k = -1
for i in range(N):
    if seen[i] == -1:
        k += 1
        dfs(i, k)
# print(seen)
print(k)

Fixed submission:
import queue

N, M = map(int, input().split())
e = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    e[A].append(B)
    e[B].append(A)
# print(e)

seen = [-1] * N
k = -1
for i in range(N):
    if seen[i] == -1:
        k += 1
        seen[i] = k
        que = queue.Queue()
        que.put(i)
        while not que.empty():
            v = que.get()
            for nv in e[v]:
                if seen[nv] != -1: continue
                seen[nv] = k
                que.put(nv)
# print(seen)
print(k)
Buggy python submission (verdict: Time Limit Exceeded):
N, X, M = map(int, input().split())

ans = 0
roop_init = -1
roop_sum = 0
roop_len = 0
x = X
ans += x
flug = False    # 周期を数えるフラグ
for i in range(2, N+1):
    old_x = x
    x = old_x**2 % M
    if x == 0:
        print(ans)
        break
    if old_x**2 >= M and not flug:
        # print(old_x, x)
        flug = True
        roop_init = x
        roop_sum = x
        roop_len = 1
    elif x == roop_init and flug:
        # print(i)
        ans += (N - (i-1)) // roop_len * roop_sum
        for j in range((N - (i-1)) % roop_len):
            if j != 0:
                old_x = x
                x = old_x**2 % M
            ans += x
        print(ans)
        break
    elif flug:
        roop_len += 1
        roop_sum += x
    ans += x
else:
    print(ans)



Fixed submission:
N, X, M = map(int, input().split())

id_ = [-1] * M
a = []
len_ = 0
ans = 0
x = X
while id_[x] == -1:
    id_[x] = len_
    len_ += 1
    ans += x
    a.append(x)
    x = x**2 % M

c = len_ - id_[x]
s = 0
for i in range(id_[x], len_):
    s += a[i]

if len_ >= N:
    ans = 0
    for i in range(N):
        ans += a[i]
else:
    n = N
    n -= len_
    ans += s * (n // c)
    n %= c
    for i in range(n):
        ans += a[id_[x]+i]
print(ans)

Buggy python submission (verdict: Runtime Error):
N, X, M = map(int, input().split())

ans = 0
roop_init = 0
roop_sum = 0
roop_len = 0
x = X
ans += x
flug = False    # 周期を数えるフラグ
for i in range(2, N+1):
    old_x = x
    x = old_x**2 % M
    if x == 0:
        break
    if old_x**2 >= M and not flug:
        # print(old_x, x)
        flug = True
        roop_init = x
        roop_sum = x
        roop_len = 1
    elif x == roop_init:
        # print(i)
        ans += (N - (i-1)) // roop_len * roop_sum
        for j in range((N - (i-1)) % roop_len):
            if j != 0:
                old_x = x
                x = old_x**2 % M
            ans += x
        print(ans)
        break
    elif flug:
        roop_len += 1
        roop_sum += x
    ans += x
else:
    print(ans)
print(i, roop_init, roop_sum, roop_len)



Fixed submission:
N, X, M = map(int, input().split())

id_ = [-1] * M
a = []
len_ = 0
ans = 0
x = X
while id_[x] == -1:
    id_[x] = len_
    len_ += 1
    ans += x
    a.append(x)
    x = x**2 % M

c = len_ - id_[x]
s = 0
for i in range(id_[x], len_):
    s += a[i]

if len_ >= N:
    ans = 0
    for i in range(N):
        ans += a[i]
else:
    n = N
    n -= len_
    ans += s * (n // c)
    n %= c
    for i in range(n):
        ans += a[id_[x]+i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

H, W, K = map(int, input().split())
c = [[] for _ in range(H)]
for i in range(H):
    s = input()
    for j in s:
        if j == '.':
            c[i].append(0)
        else:
            c[i].append(1)

ans = 0
for bit in range(1 << (H+W)):
    red_array = np.full((H, W), False)
    cnt = 0
    for i in range(H+W):
        # print(bin(bit), i, bit>>i, bit>>i == 1, i<H, i-H)
        if (bit>>i)&1 == 1:
            if i < H:
                red_array[i,:] = True
            else:
                red_array[:,i-H] = True
    # print(bin(bit))
    # print(red_array)
    for y in range(H):
        for x in range(W):
            # print(bit, y, x, c[y][x], red_array[y,x],c[y][x] == 1 and not red_array[y, x])
            if c[y][x] == 1 and not red_array[y, x]:
                cnt += 1
    # print(cnt)
    if cnt == K:
        ans += 1
print(ans)

Fixed submission:
import numpy as np

H, W, K = map(int, input().split())
c = [[] for _ in range(H)]
for i in range(H):
    s = input()
    for j in s:
        if j == '.':
            c[i].append(0)
        else:
            c[i].append(1)

ans = 0
for bit in range(1 << (H+W)):
    red_array = np.full((H, W), False)
    cnt = 0
    for i in range(H+W):
        # print(bin(bit), i, bit>>i, bit>>i == 1, i<H, i-H)
        if (bit>>i)&1 == 1:
            if i < H:
                red_array[i,:] = True
            else:
                red_array[:,i-H] = True
    # print(bin(bit))
    # print(red_array)
    for y in range(H):
        for x in range(W):
            # print(bit, y, x, c[y][x], red_array[y,x],c[y][x] == 1 and not red_array[y, x])
            if c[y][x] == 1 and not red_array[y, x]:
                cnt += 1
    # print(cnt)
    if cnt == K:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
a = 1
flug = True
while flug:
    b = -119
    while b <= 118:
        if a ** 5 - b ** 5 == X:
            print(a, b)
            flug = False
            break
        else:
            b += 1


Fixed submission:
X = int(input())
a = 1
flug = True
while flug:
    b = -119
    while b <= 118:
        if a ** 5 - b ** 5 == X:
            print(a, b)
            flug = False
            break
        else:
            b += 1
    a += 1

Buggy python submission (verdict: Runtime Error):
X = int(input())
a = 1
while True:
    b = (a ** 5 - X) ** (1/5)
    if b.is_integer():
        b = int(b)
        break
    a += 1
print(a, b)

Fixed submission:
X = int(input())
a = 1
flug = True
while flug:
    b = -119
    while b <= 118:
        if a ** 5 - b ** 5 == X:
            print(a, b)
            flug = False
            break
        else:
            b += 1
    a += 1
Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())
abcd = []
for i in range(Q): abcd.append(list(map(int, input().split())))
ans = 0
per_lst = []
def make_per(lst, n, m):
    n_lst = lst.copy()
    n_lst.append(0)
    if n == 1:
        for i in range(1, m+1):
            n_lst = n_lst.copy()
            n_lst[-1] = i
            if len(n_lst) > 1:
                if i >= n_lst[-2]:
                    per_lst.append(n_lst)
            else:
                per_lst.append(n_lst)
    else:
        for i in range(1, m+1):
            n_lst[-1] = i
            if len(n_lst) > 1:
                if i >= n_lst[-2]:
                    make_per(n_lst, n-1, m)
            else:
                make_per(n_lst, n-1, m)

make_per([], N, M)
# for i in per_lst:
#     print(i)
maxi = 0
for per in per_lst:
    score = 0
    for i in range(Q):
        a, b, c, d = abcd[i][0], abcd[i][1], abcd[i][2], abcd[i][3]
        a -= 1
        b -= 1
        if (per[b] - per[a]) == c: score += d
    if score > maxi: maxi = score
print(maxi)

Fixed submission:
N, M, Q = map(int, input().split())
abcd = []
for i in range(Q): abcd.append(list(map(int, input().split())))
ans = 0
per_lst = []
def make_per(lst, n, m):
    n_lst = lst.copy()
    n_lst.append(0)
    if n == 1:
        for i in range(1, m+1):
            n_lst = n_lst.copy()
            n_lst[-1] = i
            if len(n_lst) > 1:
                if i >= n_lst[-2]:
                    per_lst.append(n_lst)
            else:
                per_lst.append(n_lst)
    else:
        for i in range(1, m+1):
            n_lst[-1] = i
            if len(n_lst) > 1:
                if i >= n_lst[-2]:
                    make_per(n_lst, n-1, m)
            else:
                make_per(n_lst, n-1, m)

make_per([], N, M)
# for i in per_lst:
#     print(i)
maxi = 0
for per in per_lst:
    score = 0
    for i in range(Q):
        a, b, c, d = abcd[i][0], abcd[i][1], abcd[i][2], abcd[i][3]
        a -= 1
        b -= 1
        if (per[b] - per[a]) == c: score += d
    if score > maxi: maxi = score
print(maxi)
Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
if K < 10:
    print(K)
    sys.exit()
lst = [[str(i)] for i in range(10)]
i = 9
while True:
    new_lst = [[] for j in range(10)]
    for j in range(10):     #0-9までについて
        for k in range(-1, 2):  #-1, 0, +1の3つについて
            if j == 0 and k == -1:
                continue
            if j == 9 and k == 1:
                break
            for l in lst[j+k]:
                tmp = str(j) + str(l)
                new_lst[j].append(tmp)
                # print(i, K , i == K)
                if j != 0:
                    i += 1
                    if i == K:
                        print(int(tmp))
                        sys.exit()
    # print(i, new_lst)
    lst = new_lst.copy()

Fixed submission:
import sys
K = int(input())
if K < 10:
    print(K)
    sys.exit()
lst = [[str(i)] for i in range(10)]
i = 9
while True:
    new_lst = [[] for j in range(10)]
    for j in range(10):     #0-9までについて
        for k in range(-1, 2):  #-1, 0, +1の3つについて
            if j == 0 and k == -1:
                continue
            if j == 9 and k == 1:
                break
            for l in lst[j+k]:
                tmp = str(j) + str(l)
                new_lst[j].append(tmp)
                # print(i, K , i == K)
                if j != 0:
                    i += 1
                    if i == K:
                        print(int(tmp))
                        sys.exit()
    # print(i, new_lst)
    lst = new_lst.copy()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
dct = {}
for i in range(n):
    if a[i] in dct:
        dct[a[i]] += 1
    else:
        dct[a[i]] = 1
tmp_dct = {}
tmp2_dct = {}
for key, value in dct.items():
    tmp_dct[key] = value * (value - 1) // 2
    tmp2_dct[key] = (value - 1) * (value - 2) // 2
# print(tmp_dct, tmp2_dct)
ans_dct = {}
for key, value in dct.items():
    cnt = 0
    for key2, value2 in dct.items():
        if key == key2:
            cnt += tmp2_dct[key2]
        else:
            cnt += tmp_dct[key2]
        # print(key, key2, cnt)
    ans_dct[key] = cnt
# print(ans_dct)
for i in range(n):
    print(ans_dct[a[i]])

Fixed submission:

def choose2(n):
    return n * (n-1) // 2

n = int(input())
a = list(map(int, input().split()))
dct = {}
for i in range(n):
    if a[i] in dct:
        dct[a[i]] += 1
    else:
        dct[a[i]] = 1
tot = 0
for key, value in dct.items():
    tot += choose2(value)
# print(tot)
for i in range(n):
    ans = tot
    ans -= choose2(dct[a[i]])
    ans += choose2(dct[a[i]]-1)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
dct = {}
for i in range(n):
    if a[i] in dct:
        dct[a[i]] += 1
    else:
        dct[a[i]] = 1
tmp_dct = {}
tmp2_dct = {}
for key, value in dct.items():
    tmp_dct[key] = value * (value - 1) // 2
    tmp2_dct[key] = (value - 1) * (value - 2) // 2
# print(tmp_dct, tmp2_dct)
ans_dct = {}
for key, value in dct.items():
    cnt = 0
    for key2, value2 in dct.items():
        if key == key2:
            cnt += tmp2_dct[key2]
        else:
            cnt += tmp_dct[key2]
        # print(key, key2, cnt)
    ans_dct[key] = cnt
# print(ans_dct)
for i in range(n):
    print(ans_dct[a[i]])

Fixed submission:

def choose2(n):
    return n * (n-1) // 2

n = int(input())
a = list(map(int, input().split()))
dct = {}
for i in range(n):
    if a[i] in dct:
        dct[a[i]] += 1
    else:
        dct[a[i]] = 1
tot = 0
for key, value in dct.items():
    tot += choose2(value)
# print(tot)
for i in range(n):
    ans = tot
    ans -= choose2(dct[a[i]])
    ans += choose2(dct[a[i]]-1)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
h, w = map(int, input().split())
map_lst = []
for i in range(h):
    map_lst.append(list(input()))
#0:下 1:右
lst = [i for i in range(h + w - 2)]
lst = list(itertools.combinations(lst,h-1))
ans = 200
for i in lst:
    rc_lst = [1] * (h + w - 2)
    for j in i:
        rc_lst[j] = 0
    bw_lst = []
    if map_lst[0][0] == '.': bw_lst.append(0)
    elif map_lst[0][0] == '#': bw_lst.append(1)
    r = 0
    c = 0
    cnt_b = 0
    # print(rc_lst)
    for j in range(h + w - 2):
        if rc_lst[j] == 0: r += 1
        elif rc_lst[j] == 1: c += 1
        if map_lst[r][c] == ".":
            if bw_lst[-1] == 1:
                cnt_b += 1
            bw_lst.append(0)
        elif map_lst[r][c] == "#":
            bw_lst.append(1)
    if map_lst[h-1][w-1] == '#': cnt_b += 1
    ans = min(ans, cnt_b)
    # print(rc_lst, bw_lst, cnt_b)
print(ans)

Fixed submission:
import itertools
h, w = map(int, input().split())
map_lst = []
for i in range(h):
    map_lst.append(list(input()))
dp = [[200] * (w) for i in range(h)]
if map_lst[0][0] == '.': dp[0][0] = 0
else: dp[0][0] = 1
# for i in dp:
#     print(i)
for c in range(w):
    for r in range(h):
        over = 0
        left = 0
        if r > 0:
            if map_lst[r-1][c] == '.' and map_lst[r][c] == '#':
                over = 1
        if c > 0:
            if map_lst[r][c-1] == '.' and map_lst[r][c] == '#':
                left = 1
        if r == 0 and c == 0:
            continue
        elif r == 0:
            dp[r][c] = dp[r][c-1] + left
        elif c == 0:
            dp[r][c] = dp[r-1][c] + over
        else:
            dp[r][c] = min(dp[r-1][c] + over, dp[r][c-1] + left)
# for i in dp:
#     print(i)
print(dp[-1][-1])
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c = map(int, input().split())
# print(a ** 0.5, b ** 0.5, c ** 0.5)
digit = 5000
right = (c - a - b) * (10 ** digit)
ab = a * b * (10 ** (digit * 2))
sqrt_ab = 0
ans = False
for i in range(10 ** 5):
    # print(i, i * i * (10 ** (digit * 2)), ab, (i - 1) * (10 ** digit))
    if i * i * (10 ** (digit * 2)) > ab:
        sqrt_ab += (i - 1) * (10 ** digit)
        break
# print(sqrt_ab)
for i in range(1, digit):
    # if int(sqrt_ab + 1) * 2 < right:
    #     ans = True
    #     break
    for j in range(1, 10):
        # print(i, j, sqrt_ab + j * (10 ** (digit - i)), )
        if (sqrt_ab + j * (10 ** (digit - i))) ** 2 > ab:
            sqrt_ab += (j - 1) * (10 ** (digit - i))
            break
        elif j == 9:
            sqrt_ab += j * (10 ** (digit - i))
            break
if 2 * sqrt_ab < right:
    print("Yes")
else:
    print("No")

Fixed submission:
a, b, c = map(int, input().split())
if c - a - b > 0 and 4 * a * b < ((c - a - b) ** 2):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c = map(int, input().split())
# print(a ** 0.5, b ** 0.5, c ** 0.5)
digit = 10000
right = (c - a - b) * (10 ** digit)
ab = a * b * (10 ** (digit * 2))
sqrt_ab = 0
ans = False
for i in range(10 ** 5):
    # print(i, i * i * (10 ** (digit * 2)), ab, (i - 1) * (10 ** digit))
    if i * i * (10 ** (digit * 2)) > ab:
        sqrt_ab += (i - 1) * (10 ** digit)
        break
# print(sqrt_ab)
for i in range(1, digit):
    # if int(sqrt_ab + 1) * 2 < right:
    #     ans = True
    #     break
    for j in range(1, 10):
        # print(i, j, sqrt_ab + j * (10 ** (digit - i)), )
        if (sqrt_ab + j * (10 ** (digit - i))) ** 2 > ab:
            sqrt_ab += (j - 1) * (10 ** (digit - i))
            break
        elif j == 9:
            sqrt_ab += j * (10 ** (digit - i))
            break
if 2 * sqrt_ab < right:
    print("Yes")
else:
    print("No")

Fixed submission:
a, b, c = map(int, input().split())
if c - a - b > 0 and 4 * a * b < ((c - a - b) ** 2):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a + b + 2 * (a * b) ** 0.5 < c
    print("Yes")
else:
    print("No")

Fixed submission:
a, b, c = map(int, input().split())
if c - a - b > 0 and 4 * a * b < ((c - a - b) ** 2):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
s_cnt = [0] * n
for i in range(n):
    temp = input()
    if not temp in s:
        s.append(temp)
    s_cnt[s.index(temp)] += 1
maxi = max(s_cnt)
ans_lst = []
for i in range(len(s)):
    if s_cnt[i] == maxi:
        ans_lst.append(s[i])
ans_lst.sort()
ans = ""
for i in range(len(ans_lst)):
    ans += ans_lst[i]
    if i != len(ans_lst) - 1:
        ans += "\n"
print(ans)

Fixed submission:
n = int(input())
s_dict = dict()
for i in range(n):
    a = input()
    if a in s_dict:
        s_dict[a] += 1
    else:
        s_dict.update({a : 1})
maxi = max(s_dict.values())
ans_lst = []
for key, value in s_dict.items():
    if value == maxi:
        ans_lst.append(key)
ans_lst.sort()
for i in ans_lst:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
s_cnt = [0] * n
for i in range(n):
    temp = input()
    if not temp in s:
        s.append(temp)
    s_cnt[s.index(temp)] += 1
maxi = max(s_cnt)
ans_lst = []
for i in range(n):
    if s_cnt[i] == maxi:
        ans_lst.append(s[i])
ans_lst.sort()
for i in ans_lst:
    print(i)

Fixed submission:
n = int(input())
s_dict = dict()
for i in range(n):
    a = input()
    if a in s_dict:
        s_dict[a] += 1
    else:
        s_dict.update({a : 1})
maxi = max(s_dict.values())
ans_lst = []
for key, value in s_dict.items():
    if value == maxi:
        ans_lst.append(key)
ans_lst.sort()
for i in ans_lst:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
lst = []
flug = True
for i in range(n):
    if a[i] in lst:
        flug = False
        break
    lst.append(a[i])
if flug: print("YES")
else: print("NO")

Fixed submission:
import time
start = time.time()

n = int(input())
a = list(map(int, input().split()))
# a = [i for i in range(n)]
st = set()
for i in range(n):
    st.add(a[i])
if len(st) == n: print("YES")
else: print("NO")

# print(time.time() - start)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

lst = [True] * N
for i in range(M):
    L, R = map(int, input().split())
    L -= 1
    R -= 1
    for j in range(0, L):
        lst[j] = False
    for j in range(R+1, N):
        lst[j] = False
ans = 0
for i in lst:
    if i:
        ans += 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    tmp = list(map(int, input().split()))
    L.append(tmp[0])
    R.append(tmp[1])

ans = min(R) - max(L) + 1
if ans < 0: ans = 0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

xy_sum = []
xy_dif = []
for i in range(n) :
    x, y = map(int, input().split())
    xy_sum.append(x + y)
    xy_dif.append(x - y)

max_dis = 0
for j in range(n) :
    for k in range(n - j) :
        dis = max(abs(xy_sum[j] - xy_sum[k]), abs(xy_dif[j] - xy_dif[k]))
        max_dis = max(max_dis, dis)
        
print(max_dis)

Fixed submission:
n = int(input())

xy_sum = []
xy_dif = []
for i in range(n) :
    x, y = map(int, input().split())
    xy_sum.append(x + y)
    xy_dif.append(x - y)

print(max(abs(max(xy_sum) - min(xy_sum)), abs(max(xy_dif) - min(xy_dif))))