alexjercan/bugnet huggingface dataset:
Problem p03353 (Python) — buggy submission, verdict: Runtime Error

import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

S = sys.stdin.readline().rstrip()
K = int(sys.stdin.readline())

s = set()
for k in range(1, K + 1):
    for i in range(len(S)):
        s.add(S[i : i + k])

s = list(sorted(list(s)))
print(s[K - 1])


Error: 0

Fixed submission:

import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

S = sys.stdin.readline().rstrip()
K = int(sys.stdin.readline())


def prune(it):
    hist = set()
    ret = []
    for s, l in it:
        if s not in hist:
            hist.add(s)
        if len(hist) > K:
            break
        ret.append((s, l))
    return ret


collections = prune(sorted([(c, L) for L, c in enumerate(S)]))
for size in range(1, len(S)):
    threshold, _ = collections[-1]
    for s, left in collections:
        r = left + size + 1
        if len(s) == size and r <= len(S):
            t = S[left:r]
            if t <= threshold:
                collections.append((t, left))
    collections = prune(sorted(collections))

strings = list(set([s for s, _ in collections]))
strings.sort()
print(strings[K - 1])
Problem p03354 (Python) — buggy submission, verdict: Time Limit Exceeded

# UnionFindで参考にしたページ
# http://www.geocities.jp/m_hiroi/light/pyalgo61.html


# 集合の代表を求める
def find(x):
    if link[x] < 0:
        return x
    else:
        # 経路の圧縮
        link[x] = find(link[x])
        return link[x]


# 併合
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if link[s1] >= link[s2]:
            # 小さいほうが個数が多い
            link[s1] += link[s2]
            link[s2] = s1
        else:
            link[s2] += link[s1]
            link[s1] = s2
        return True
    return False


N, M = map(int, input().split())
p = list(map(int, input().split()))
link = [-1 for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    union(x, y)

cnt = 0
for i in range(1, N + 1):
    if find(i) == find(p[i - 1]):
        cnt += 1
print(cnt)


Error: TLE

Fixed submission:

# UnionFindで参考にしたページ
# http://www.geocities.jp/m_hiroi/light/pyalgo61.html


# 集合の代表を求める
def find(x):
    while link[x] >= 0:
        x = link[x]
    return x


# 併合
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if link[s1] >= link[s2]:
            # 小さいほうが個数が多い
            link[s1] += link[s2]
            link[s2] = s1
        else:
            link[s2] += link[s1]
            link[s1] = s2
        return True
    return False


N, M = map(int, input().split())
p = list(map(int, input().split()))
link = [-1 for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    union(x, y)

cnt = 0
for i in range(1, N + 1):
    a = find(i)
    b = find(p[i - 1])
    if a == b:
        cnt += 1
print(cnt)
Problem p03354 (Python) — buggy submission, verdict: Runtime Error

n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]


def root(x):
    if x == par[x]:
        return x
    par[x] = root(par[x])  # 経路圧縮
    return par[x]


def is_same(x, y):
    return root(x) == root(y)


def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1


for x, y in xy:
    unite(x - 1, y - 1)


count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i - 1) else 0
print(count)


Error: RecursionError: maximum recursion depth exceeded in comparison
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 40, in <module>
    count += 1 if is_same(i, p_i - 1) else 0
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 17, in is_same
    return root(x) == root(y)
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 12, in root
    par[x] = root(par[x])  # 経路圧縮
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 12, in root
    par[x] = root(par[x])  # 経路圧縮
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 12, in root
    par[x] = root(par[x])  # 経路圧縮
  [Previous line repeated 994 more times]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 10, in root
    if x == par[x]:
RecursionError: maximum recursion depth exceeded in comparison


Fixed submission:

n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]


def root(x):
    if x == par[x]:
        return x
    par[x] = root(par[x])  # 経路圧縮
    return par[x]


def is_same(x, y):
    return root(x) == root(y)


def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
    par[x] = y


for x, y in xy:
    unite(x - 1, y - 1)


count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i - 1) else 0
print(count)
Problem p03354 (Python) — buggy submission, verdict: Runtime Error

n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]


def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]


def is_same(x, y):
    return root(x) == root(y)


def union(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[y] == rank[x]:
            rank[x] += 1


for x, y in xy:
    union(x, y)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i) else 0
print(count)


Error: 0

Fixed submission:

n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]


def root(x):
    if par[x] == x:
        return x
    par[x] = root(x)
    return par[x]


def is_same(x, y):
    return par[x] == par[y]


def union(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[y] == rank[x]:
            rank[x] += 1


for x, y in xy:
    union(x, y)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i) else 0
print(count)
Problem p03354 (Python) — buggy submission, verdict: Runtime Error

n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]


def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]


def is_same(x, y):
    return root(x) == root(y)


def union(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1


for x, y in xy:
    union(x, y)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i) else 0
print(count)


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s721322256.py", line 3, in <module>
    xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(n)]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s721322256.py", line 3, in <listcomp>
    xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(n)]
EOFError: EOF when reading a line


Fixed submission:

n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(n)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]


def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]


def is_same(x, y):
    return root(x) == root(y)


def union(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1


for x, y in xy:
    union(x, y)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i) else 0
print(count)
Problem p03354 (Python) — buggy submission, verdict: Runtime Error

import sys

sys.setrecursionlimit(2 * 10**5)

N, M = map(int, input().split())
p = [0] + list(map(int, input().split()))
x, y = zip(*(map(int, input().split()) for _ in range(M)))
E = [[] for _ in range(N + 1)]
for a, b in zip(x, y):
    E[a].append(b)
    E[b].append(a)
v = [True for _ in range(N + 1)]


def f(i, P, Q):
    v[i] = False
    P.add(i)
    Q.add(p[i])
    for a in E[i]:
        if v[a]:
            f(a, P, Q)


ans = 0
for i in range(1, N + 1):
    if v[i]:
        P = set()
        Q = set()
        f(i, P, Q)
        ans += len(P & Q)
print(ans)


Error: 0

Fixed submission:

N, M = map(int, input().split())
p = [0] + list(map(int, input().split()))
x, y = zip(*(map(int, input().split()) for _ in range(M)))
E = [[] for _ in range(N + 1)]
for a, b in zip(x, y):
    E[a].append(b)
    E[b].append(a)
v = [True for _ in range(N + 1)]


def f(i, P, Q):
    v[i] = False
    P.add(i)
    Q.add(p[i])
    for a in E[i]:
        if v[a]:
            f(a, P, Q)


ans = 0
for i in range(1, N + 1):
    if v[i]:
        P = set()
        Q = set()
        f(i, P, Q)
        ans += len(P & Q)
print(ans)
Problem p03355 (Python) — buggy submission, verdict: Time Limit Exceeded

if __name__ == "__main__":
    s = input()

    K = int(input())

    subsrings = [s[i : i + K + 1] for i in range(len(s))]
    subsrings.sort()

    first = set()

    for s in subsrings:

        for i in range(1, len(s) + 1):
            if s[:i] not in first:
                first.add(s[:i])
                if len(first) == K:
                    print(s[:i])
                    break


Error: TLE

Fixed submission:

if __name__ == "__main__":
    s = input()
    subsrings = []
    K = int(input())
    for i in range(len(s)):
        subsrings.append(s[i:])
    subsrings.sort()

    first = set()

    for s in subsrings:
        for i in range(1, len(s) + 1):
            if s[:i] not in first:
                first.add(s[:i])
                if len(first) == K:
                    print(s[:i])
                    break
Problem p03355 (Python) — buggy submission, verdict: Time Limit Exceeded

S = input()
K = int(input())
n = len(S)

ans = []
st = set()

for i in range(n):
    for j in range(i + 1, min(n + 1, i + 1 + K)):
        sub = S[i:j]
        # print(sub)
        if sub in st:
            continue
        st.add(sub)
        ans.append(sub)
        ans.sort()
        # print(ans)
        if len(ans) > K:
            ans = ans[:K]

print(ans[-1])


Error: TLE

Fixed submission:

S = input()
K = int(input())
n = len(S)

ans = []
st = set()

for i in range(n):
    for j in range(i + 1, n + 1):
        sub = S[i:j]
        # print(sub)
        if sub in st:
            continue
        st.add(sub)
        ans.append(sub)
        ans.sort()
        # print(ans)
        if len(ans) > K:
            ans = ans[:K]

print(ans[-1])
Problem p03355 (Python) — buggy submission, verdict: Time Limit Exceeded

s = input()
K = int(input())
s_dic = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
for i, c in enumerate(s):
    s_dic[c].append(i)
substrings = set()
for indices in s_dic.values():
    for i in indices:
        for j in range(i + 1, i + K + 1):
            substrings.add(s[i:j])
print(sorted(list(substrings))[K - 1])


Error: TLE

Fixed submission:

s = input()
K = int(input())
s_dic = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
for i, c in enumerate(s):
    s_dic[c].append(i)
substrings = set()
for lc in "abcdefghijklmnopqrstuvwxyz":
    for i in s_dic[lc]:
        for j in range(i + 1, len(s) + 1):
            substrings.add(s[i:j])
    if len(substrings) >= K:
        break
print(sorted(list(substrings))[K - 1])
Problem p03355 (Python) — buggy submission, verdict: Time Limit Exceeded

S = input()
N = len(S)
K = int(input())
ans = set()
for c in "abcdefghijklmnopqrstuvwxyz":
    for i in range(N):
        if S[i] == c:
            for j in range(i + 1, i + K + 1):
                ans.add(S[i:j])
    if len(ans) >= K:
        break
print(sorted(list(ans))[K - 1])


Error: TLE

Fixed submission:

S = input()
N = len(S)
K = int(input())
ans = set()
for c in "abcdefghijklmnopqrstuvwxyz":
    for i in range(N):
        if S[i] == c:
            for j in range(i + 1, N + 1):
                ans.add(S[i:j])
    if len(ans) >= K:
        break
print(sorted(list(ans))[K - 1])
Problem p03355 (Python) — buggy submission, verdict: Time Limit Exceeded

s = input()
k = int(input())

n = len(s)
array = []

for i in range(n):
    for j in range(i + 1, i + 6):
        end = min(n, j)
        ss = s[i:end]
        array.append(ss)

array = set(array)
array = sorted(array)
print(array[k - 1])


Error: TLE

Fixed submission:

s = input()
k = int(input())

array = set()
n = len(s)

for i in range(n):
    for j in range(i + 1, n + 1):
        ss = s[i:j]
        array.add(ss)
        if len(array) > k:
            array = sorted(array)
            array.pop()
            array = set(array)

array = sorted(array)
print(array[k - 1])
Problem p03356 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
ps = list(map(int, input().split()))
uf = UnionFind(n + 1)
for _ in range(m):
    x, y = map(int, input().split())
    uf.unite(x, y)
print(sum([uf.same(i + 1, p) for i, p in enumerate(ps)]))


Error: TLE

Fixed submission:

#!/usr/bin/env python


class UnionFind:
    def __init__(self, size):
        self.table = list(range(size))

    def find(self, x):
        return self.table[x]

    def union(self, x, y):
        x1 = self.find(x)
        y1 = self.find(y)
        if x1 == y1:
            return False
        for i in range(len(self.table)):
            if self.table[i] == y1:
                self.table[i] = x1
        return True


n, m = map(int, input().split())
ps = list(map(int, input().split()))
uf = UnionFind(n)
for _ in range(m):
    x, y = map(int, input().split())
    uf.union(x - 1, y - 1)
print(sum([uf.find(i) == uf.find(p - 1) for i, p in enumerate(ps)]))
Problem p03359 (Python) — buggy submission, verdict: Runtime Error

a, b = map(int, input().split())

if b >= a:
    print(a)
else:
    print(a - 1)


Error: ValueError: invalid literal for int() with base 10: '5 5'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03359/Python/s441621370.py", line 1, in <module>
    a, b = int(input())
ValueError: invalid literal for int() with base 10: '5 5'


Fixed submission:

a, b = int(input())

if b >= a:
    print(a)
else:
    print(a)
Problem p03359 (Python) — buggy submission, verdict: Runtime Error

a, b = map(int, input().split())
print(a if a <= b else a - 1)


Error: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03359/Python/s022785363.py", line 1, in <module>
    a, b = int(input().split())
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'


Fixed submission:

a, b = int(input().split())
print(a if a <= b else a - 1)
Problem p03360 (Python) — buggy submission, verdict: Runtime Error

def f(a, b, c, k):
    abc = sorted([a, b, c])
    if k != 0:
        abc[2] *= 2**k
    print(sum(abc))


a, b, c = map(int, input().split())
k = int(input())
f(a, b, c, k)


Error: TypeError: f() missing 2 required positional arguments: 'c' and 'k'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03360/Python/s048419312.py", line 7, in <module>
    f(map(int, input().split()), int(input()))
TypeError: f() missing 2 required positional arguments: 'c' and 'k'


Fixed submission:

def f(a, b, c, k):
    abc = sorted([a, b, c])
    abc[2] *= 2 * k
    print(sum(abc))


f(map(int, input().split()), int(input()))
Problem p03360 (Python) — buggy submission, verdict: Runtime Error

A, B, C = map(int, input().split())
K = int(input())
result = sum([A, B, C])
t = max(A, B, C)
result += (t << K) - t
print(result)


Error: TypeError: sum() takes at most 2 arguments (3 given)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03360/Python/s848836757.py", line 3, in <module>
    result = sum(A, B, C)
TypeError: sum() takes at most 2 arguments (3 given)


Fixed submission:

A, B, C = map(int, input().split())
K = int(input())
result = sum(A, B, C)
t = max(A, B, C)
result += (t << K) - t
print(result)
Problem p03360 (Python) — buggy submission, verdict: Runtime Error

a, b, c = map(int, input().split())
k = int(input())

m = max(a, b, c)
ans = a + b + c - m + (2**k) * m

print(ans)


Error: TypeError: sum() takes at most 2 arguments (3 given)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03360/Python/s177658372.py", line 5, in <module>
    ans = sum(a, b, c) - m + (2**k) * m
TypeError: sum() takes at most 2 arguments (3 given)


Fixed submission:

a, b, c = map(int, input().split())
k = int(input())

m = max(a, b, c)
ans = sum(a, b, c) - m + (2**k) * m

print(ans)
Problem p03361 (Python) — buggy submission, verdict: Runtime Error

def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    if len(field) == 1:
        if len(field[0]) == 1:
            return "No"

    for i, row in enumerate(field):
        for j, _ in enumerate(row):
            available = False
            if field[i][j] == ".":
                continue
            if i - 1 >= 0:
                available |= field[i - 1][j] == "#"

            if j - 1 >= 0:
                available |= field[i][j - 1] == "#"
            if j + 1 < len(row):
                available |= field[i][j + 1] == "#"

            if i + 1 < len(field):
                available |= field[i + 1][j] == "#"
            if not available:
                return "No"

    return "Yes"


if __name__ == "__main__":
    [N, _] = map(lambda x: int(x), input().split())
    ret = solve(inputs(N))
    print(ret)


Error: 0

Fixed submission:

def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    if len(field) == 1:
        if len(field[0]) == 1:
            return "No"

    for i, row in enumerate(field):
        for j, _ in enumerate(row):
            available = False
            if field[i][j] == ".":
                continue
            if i - 1 >= 0:
                available |= field[i - 1][j] == "#"

            if j - 1 >= 0:
                available |= field[i][j - 1] == "#"
            if j + 1 < len(row):
                available |= field[i][j + 1] == "#"

            if i + 1 < len(row):
                available |= field[i + 1][j] == "#"
            if not available:
                return "No"

    return "Yes"


if __name__ == "__main__":
    [N, _] = map(lambda x: int(x), input().split())
    ret = solve(inputs(N))
    print(ret)
Problem p03361 (Python) — buggy submission, verdict: Runtime Error

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

d = [(-1, 0), (1, 0), (0, -1), (0, 1)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            continue

        flag = False
        for dx, dy in d:
            i2, j2 = i + dx, j + dy
            if not (0 <= i2 < H and 0 <= j2 < W):
                continue

            if S[i2][j2] == "#":
                flag = True

        if not flag:
            print("No")
            exit()
print("Yes")


Error: 0

Fixed submission:

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

ds = [(1, 0), (-1, 0), (0, 1), (0, -1)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            continue

        flag = False
        for dx, dy in ds:
            x, y = i + dx, j + dy
            if x < 0 or W <= x or y < 0 or H <= y:
                continue

            if S[x][y] == "#":
                flag = True
                break

        if not flag:
            print("No")
            exit()
print("Yes")
Problem p03362 (Python) — buggy submission, verdict: Runtime Error

N = int(input())

sosuu = []


def next_sosuu():
    if len(sosuu) == 0:
        sosuu.append(2)
        return 2
    if len(sosuu) == 1:
        sosuu.append(3)
        return 3
    curr = sosuu[-1] + 2

    while True:
        flag = True
        for s in sosuu:
            if curr % s == 0:
                flag = False
                break
        if flag:
            sosuu.append(curr)
            return curr
        curr += 2


results = []
while len(results) < N:
    n = next_sosuu()
    if n % 5 == 1:
        results.append(n)

txt = ""
for r in results:
    txt += str(r) + " "
txt = txt[0:-1]
print(txt)


Error: WA

Fixed submission:

N = int(input())

out = [i * 2 for i in range(1, N + 1)]

print(*out, " ")
Problem p03362 (Python) — buggy submission, verdict: Time Limit Exceeded

def is_prime(n):
    if n < 2:
        return False
    else:
        for p in range(2, n):
            if n % p == 0:
                return False
        else:
            return True


# input
N = int(input())

# check
prime_nums = []
append = prime_nums.append
for n in range(2, 55555):
    if is_prime(n) and n % 5 == 1:
        append(n)
        if len(prime_nums) == N:
            break

res = " ".join([str(num) for num in prime_nums])
print(res)
exit(0)


Error: TLE

Fixed submission:

from itertools import combinations


def is_prime(n):
    if n < 2:
        return False
    elif n == 2:
        return True
    else:
        for p in range(2, n):
            if n % p == 0:
                return False
        else:
            return True


# input
N = int(input())

# check
prime_nums = [n for n in range(2, 55555) if is_prime(n)]
for case in combinations(prime_nums, N):
    fl = True
    for check_case in combinations(case, 5):
        if is_prime(sum(check_case)):
            fl = False
            break
    if fl:
        res = " ".join([str(num) for num in case])
        print(res)
        exit(0)