Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03040 (python)

Fixed submission:
import heapq


class PriorityQueue:
    def __init__(self):
        self.__heap = []
        self.__count = 0

    def empty(self) -> bool:
        return self.__count == 0

    def dequeue(self):
        if self.empty():
            raise Exception('empty')
        self.__count -= 1
        return heapq.heappop(self.__heap)

    def enqueue(self, v):
        self.__count += 1
        heapq.heappush(self.__heap, v)

    def __len__(self):
        return self.__count


def absolute_minima():
    Q = int(input())

    L, R = PriorityQueue(), PriorityQueue()
    sL, sR = 0, 0
    M = None
    B = 0
    N = 0

    for _ in range(Q):
        query = [int(s) for s in input().split()]

        if query[0] == 1:
            _, a, b = query
            B += b
            N += 1

            if M is None:
                M = a
            elif M < a:
                R.enqueue(a)
                sR += a
            else:
                L.enqueue(-a)
                sL += a

            while len(R)-len(L) > 1:
                L.enqueue(-M)
                sL += M

                M = R.dequeue()
                sR -= M

            while len(L) > len(R):
                R.enqueue(M)
                sR += M

                M = -L.dequeue()
                sL -= M

        else:
            s = - sL + sR + B
            if N % 2 == 0:
                s -= M
            print(M, s)


if __name__ == "__main__":
    absolute_minima()

Buggy submission (verdict: Runtime Error):
def absolute_minima():
    Q = int(input())

    L, R = [], []
    sL, sR = 0, 0
    M = None
    B = 0
    N = 0

    for _ in range(Q):
        query = map(int, input().split())

        if query[0] == 1:
            _, a, b = query
            N += 1
            B += b

            if M == None:
                M = a
            else:
                if M < a:
                    R.append(a)
                    sR += a
                else:
                    L.append(a)
                    sL += a

                while len(R)-len(L) > 1:
                    L.append(M)
                    sL += M

                    M = R[0]

                    R.remove(M)
                    sR -= M

                while len(L) > len(R):
                    R.append(M)
                    sR += M

                    M = L[0]

                    L.remove(M)
                    sL -= M

        else:
            s = - sL + sR + B
            if N & 1 == 0:
                s -= M
            print(M, s)


if __name__ == "__main__":
    absolute_minima()
Problem p03081 (python)

Fixed submission:
def snuke_the_wizard(N: int, Q: int, s: str, queries: list)->int:
    l, r = -1, N
    for t, d in reversed(queries):
        if d == 'R':
            if 0 <= r-1 and s[r-1] == t:
                r -= 1
            if 0 <= l and s[l] == t:
                l -= 1
        else:
            if l + 1 < N and s[l+1] == t:
                l += 1
            if r < N and s[r] == t:
                r += 1
    return r - l - 1 if l < r else 0


if __name__ == "__main__":
    Q = 0
    N, Q = map(int, input().split())
    s = input()
    queries = [tuple(input().split()) for _ in range(Q)]
    ans = snuke_the_wizard(N, Q, s, queries)
    print(ans)

Buggy submission (verdict: Runtime Error):
def snuke_the_wizard(N: int, Q: int, s: str, queries: list)->int:
    l, r = -1, N
    for t, d in reversed(queries):
        if d == 'R':
            if s[r-1] == t:
                r -= 1
            if 0 <= l and s[l] == t:
                l -= 1
        else:
            if s[l+1] == t:
                l += 1
            if r < N and s[r] == t:
                r += 1
    return r - l - 1 if l < r else 0


if __name__ == "__main__":
    Q = 0
    N, Q = map(int, input().split())
    s = input()
    queries = [tuple(input().split()) for _ in range(Q)]
    ans = snuke_the_wizard(N, Q, s, queries)
    print(ans)

Buggy submission (verdict: Runtime Error):
def snuke_the_wizard(N: int, Q: int, s: str, queries: list)->int:
    l, r = -1, N
    for t, d in reversed(queries):
        if d == 'R' and s[r-1] == t:
            r -= 1
        elif d == 'L' and s[l+1] == t:
            l += 1
    return r - l - 1 if l < r else 0


if __name__ == "__main__":
    Q = 0
    N, Q = map(int, input().split())
    s = input()
    queries = [tuple(input().split()) for _ in range(Q)]
    ans = snuke_the_wizard(N, Q, s, queries)
    print(ans)

Buggy submission (verdict: Runtime Error):
def snuke_the_wizard(N: int, Q: int, s: str, queries: list)->int:
    l, r = 0, N-1
    for t, d in reversed(queries):
        if d == 'R' and s[r] == t:
            r -= 1
        elif d == 'L' and s[l] == t:
            l += 1
    return r - l + 1 if l < r else 0


if __name__ == "__main__":
    Q = 0
    N, Q = map(int, input().split())
    s = input()
    queries = [tuple(input().split()) for _ in range(Q)]
    ans = snuke_the_wizard(N, Q, s, queries)
    print(ans)
Problem p03109 (python)

Fixed submission:
y, m, d = [int(s) for s in input().split('/')]

if y > 2019:
  print('TBD')
elif y < 2019:
  print('Heisei')
else: # y == 2019
  if m < 5:
    print('Heisei')
  else:
    print('TBD')

Buggy submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
      d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
  	  res = min(res, d1, d2)
  	  print(res)

Buggy submission (verdict: Runtime Error):
A, B, Q = [int(s) for s in input().split()]

# 配列の中身は(x座標, 次のポイントへの距離)
shrines = []
temples = []

for _ in range(A):
    s = int(input())
    shrines.append((s, 10**10))

# jinjas のインデックス
# temples の各点との距離を求めるのに使う
ji = 0
for _ in range(B):
    tp, tc = int(input()), 10**10
    sp, sc = shrines[ji]

    while abs(tp - sp) < tc:
        tc = abs(tp - sp)

        if abs(tp - sp) < sc:
            shrines[ji] = (sp, abs(tp - sp))

        if ji + 1 < A:
            ji += 1
            sp, sc = shrines[ji]
        else:
            break

    temples.append((tp, tc))

road = sorted(temples + shrines, key=lambda x: x[0])


def search(x):
    global A, B

    l, r = 0, A + B
    while r - l > 1:
        m = (l + r) // 2
        mp, mc = road[m]

        if mp < x:
            l = m
        else:
            r = m

    p1, c1 = road[l]
    if l == A + B - 1 or A + B == 1:
        return abs(x - p1) + c1

    p2, c2 = road[l+1]
    return min(abs(x-p1) + c1, abs(x-p2) + c2)


for _ in range(Q):
    q = int(input())

    y = search(q)
    print(y)
Problem p03112 (python)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)

    res = INF
    for S in s[b-1:b+1]:
        for T in t[d-1:d+1]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Buggy submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = min(bisect.bisect_right(s, x), A-1), min(bisect.bisect_right(t, x), B-1)
  a, c = max(b-1, 0), max(d-1, 0)
  
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
      d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
  	  res = min(res, d1, d2)
  	  print(res)

Buggy submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
      d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
  	  res = min(res, d1, d2)
  	  print(res)

Buggy submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
    d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
  	res = min(res, d1, d2)
  	print(res)

Buggy submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b - 1], s[b]]:
  for T in [t[d - 1], t[d]]:
  d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
  res = min(res, d1, d2)
  print(res)
Problem p03128 (python)

Fixed submission:
__MATCH = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6, ]
__INF = float('inf')


def match_matching(N: int, M: int, A: list) -> int:
    # dp で最大桁数を求める
    dp = [-__INF] * (N+1)
    dp[0] = 0
    for i in range(1, N+1):
        dp[i] = max([-__INF] +
                    [dp[i - __MATCH[a]] for a in A if i >= __MATCH[a]]) + 1

    # 各桁の数字を決める
    _A = sorted(A, reverse=True)
    used_matches = 0
    ans = 0
    for n in range(dp[N], 0, -1):
        for a in _A:
            used_matches += __MATCH[a]
            if used_matches <= N and dp[N-used_matches] == n - 1:
                ans = ans * 10 + a
                break
            used_matches -= __MATCH[a]

    return ans


if __name__ == "__main__":
    N, M = [int(s) for s in input().split()]
    A = [int(s) for s in input().split()]

    ans = match_matching(N, M, A)

    print(ans)

Buggy submission (verdict: Runtime Error):
__MATCH = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6, ]


def __select_use_num(N: int, A: list) -> list:
    if N == 0:
        return []

    for a in A:
        if N < __MATCH[a]:
            continue

        l = __select_use_num(N-__MATCH[a], A)
        if l is None:
            continue

        return [a] + l

    return None


def match_matching(N: int, M: int, A: list) -> int:
    _A = sorted(A, key=lambda x: __MATCH[x])
    nums = sorted(__select_use_num(N, _A), reverse=True)
    ans = ''.join(map(str, nums))
    return int(ans)


if __name__ == "__main__":
    N, M = [int(s) for s in input().split()]
    A = [int(s) for s in input().split()]

    ans = match_matching(N, M, A)

    print(ans)
Problem p03238 (python)

Fixed submission:
def programming_education(N: int) -> str:
    if N == 1:
        return 'Hello World'

    A = int(input())
    B = int(input())
    return str(A + B)


if __name__ == "__main__":
    N = int(input())
    ans = programming_education(N)
    print(ans)

Buggy submission (verdict: Runtime Error):
def pyramid(N: int, info: list) -> tuple:
    """
    """
    _info = sorted(info, key=lambda x: x[2], reverse=True)
    x, y, h = _info[0]
    candidtes = [
        (cx, cy, h + abs(cx - x) + abs(cy - y))
        for cx in range(100+1)
        for cy in range(100+1)]

    for x, y, h in _info[1:]:
        temp = []
        for cx, cy, H in candidtes:
            th = max(H - abs(cx - x)-abs(cy - y), 0)
            if th == h:
                temp.append((cx, cy, H))

        candidtes = temp

    return candidtes[0]

if __name__ == "__main__":
    N = int(input())
    info = [
        tuple(int(s) for s in input().split())
        for _ in range(N)]
    cx, cy, h = pyramid(N, info)
    print(cx, cy, h)

Buggy submission (verdict: Runtime Error):
def programming_education(N: int) -> str:
    if N == 1:
        return 'Hello World'

    A, B = map(int, input().split())
    return str(A + B)


if __name__ == "__main__":
    N = int(input())
    ans = programming_education(N)
    print(ans)
Problem p03240 (python)

Fixed submission:
def pyramid(N: int, info: list) -> tuple:
    """
    """
    _info = sorted(info, key=lambda x: x[2], reverse=True)
    x, y, h = _info[0]
    candidtes = [
        (cx, cy, h + abs(cx - x) + abs(cy - y))
        for cx in range(100+1)
        for cy in range(100+1)]

    for x, y, h in _info[1:]:
        temp = []
        for cx, cy, H in candidtes:
            th = max(H - abs(cx - x)-abs(cy - y), 0)
            if th == h:
                temp.append((cx, cy, H))

        candidtes = temp

    return candidtes[0]

if __name__ == "__main__":
    N = int(input())
    info = [
        tuple(int(s) for s in input().split())
        for _ in range(N)]
    cx, cy, h = pyramid(N, info)
    print(cx, cy, h)

Buggy submission (verdict: Runtime Error):
def pyramid(N: int, info: list) -> tuple:
    """
    """
    _info = sorted(info, reverse=True)
    x, y, h = _info[0]
    candidtes = [
        (cx, cy, h + abs(cx - x) + abs(cy - y))
        for cx in range(100+1)
        for cy in range(100+1)]

    for x, y, h in _info[1:]:
        temp = []
        for cx, cy, H in candidtes:
            th = max(H - abs(cx - x)-abs(cy - y), 0)
            if th == h:
                temp.append((cx, cy, H))

        candidtes = temp

    return candidtes[0]

if __name__ == "__main__":
    N = int(input())
    info = [
        tuple(int(s) for s in input().split())
        for _ in range(N)]
    cx, cy, h = pyramid(N, info)
    print(cx, cy, h)
Problem p03323 (python)

Fixed submission:
def happy_birthday(A: int, B: int) -> bool:
    return A <= 8 and B <= 8


if __name__ == "__main__":
    A, B = map(int, input().split())
    yes = happy_birthday(A, B)
    print('Yay!' if yes else ':(')

Buggy submission (verdict: Runtime Error):
def happy_birthday(A: int, B: int) -> bool:
    return A <= 8 and B <= 8:


if __name__ == "__main__":
    A, B = map(int, input().split())
    yes = happy_birthday(A, B)
    print('Yay!' if yes else ':(')
Problem p03338 (python)

Fixed submission:
def cut_and_count(N: int, S: str) -> int:
    l, r = {}, {}
    for c in S:
        if c not in r:
            r[c] = 1
        else:
            r[c] += 1

    max_len = 0
    for c in S:
        if c not in l:
            l[c] = 1
        else:
            l[c] += 1
        r[c] -= 1

        ls = set(k for k, v in l.items() if v > 0)
        rs = set(k for k, v in r.items() if v > 0)

        temp = len(ls & rs)
        max_len = max(max_len, temp)

    return max_len


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = cut_and_count(N, S)
    print(ans)

Buggy submission (verdict: Runtime Error):
def cut_and_count(N: int, S: str) -> int:
    l, r = set([]), set([])
    for c in S:
        r.add(c)

    max_len = 0
    for c in S:
        l.add(c)
        r.discard(c)

        temp = len(l & r)
        max_len = max(max, temp)

    return max_len


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = cut_and_count(N, S)
    print(ans)
Problem p03362 (python)

Fixed submission:
from math import sqrt


def is_prime(n: int) -> bool:
    sq = int(sqrt(n))
    if sq * sq == n:
        return False

    for i in range(2, sq+1):
        if n % i == 0:
            return False
    return True


def primes(n: int) -> list:
    res = []

    if n < 2:
        return res
    res.append(2)

    if n < 3:
        return res
    res.append(3)

    for i in range(6, n+1, 6):
        if is_prime(i-1):
            res.append(i-1)

        if i + 1 > n:
            break

        if is_prime(i+1):
            res.append(i+1)

    return res


def five_five_everywhere(N: int) -> list:
    res = []
    count = 0
    for p in primes(55555):
        if p % 5 != 1:
            continue

        res.append(p)
        count += 1
        if count == N:
            return res

    return None


if __name__ == "__main__":
    N = int(input())
    ans = five_five_everywhere(N)
    print(' '.join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
from math import sqrt


def is_prime(n: int) -> bool:
    sq = int(sqrt(n))
    if sq * sq == n:
        return False

    for i in range(2, sq+1):
        if n % i == 0:
            return False
    return True


def primes(n: int) -> list:
    res = []

    if n < 2:
        return res
    res.append(2)

    if n < 3:
        return res
    res.append(3)

    for i in range(6, n+1, 6):
        if is_prime(i-1):
            res.append(i-1)

        if i + 1 > n:
            break

        if is_prime(i+1):
            res.append(i+1)

    return res


def five_five_everywhere(N: int) -> list:
    res = []
    count = 0
    for p in primes(55555):
        if p % 5 != 1:
            continue

        res.append(p)
        count += 1
        if count == N:
            return res

    return None


if __name__ == "__main__":
    N = int(input())
    ans = five_five_everywhere(N)
    print(' '.join(ans))
Problem p03486 (python)

Fixed submission:
def two_anagrams(s: str, t: str) -> bool:
    '''s を並び替えた実現可能な最小の文字列 s' と t を並び替えて
    実現可能な最小の文字列 t' に関して、s' < t' が成り立てば良い。
    '''
    sn, tn = len(s), len(t)
    sd, td = sorted(s), sorted(t, reverse=True)

    idx = 0
    while idx < sn and idx < tn:
        # idx-1 番目の文字までは同じと仮定する。
        if sd[idx] < td[idx]:
            # この場合 sn < tn が成り立つ。
            return True
        if sd[idx] == td[idx]:
            # 次に持ち越し
            idx += 1
            continue
        if sd[idx] > td[idx]:
            # この場合 sn > tn が成り立つ。
            return False

    # min(sn, tn) 番目まで同じ。あとは長いほうが後ろ
    return sn < tn


if __name__ == "__main__":
    s = input()
    t = input()
    yes = two_anagrams(s, t)
    print('Yes' if yes else 'No')

Buggy submission (verdict: Runtime Error):
def two_anagrams(s: str, t: str) -> bool:
    '''s を並び替えた実現可能な最小の文字列 s' と t を並び替えて
    実現可能な最小の文字列 t' に関して、s' < t' が成り立てば良い。
    '''
    sn, tn = len(s), len(t)
    sd, td = sorted(s), sorted(t, reverse=True)

    idx = 0
    while idx < sn and idx < tn:
        # idx-1 番目の文字までは同じと仮定する。
        if sn[idx] < tn[idx]:
            # この場合 sn < tn が成り立つ。
            return True
        if sn[idx] == tn[idx]:
            # 次に持ち越し
            idx += 1
            continue
        if sn[idx] > tn[idx]:
            # この場合 sn > tn が成り立つ。
            return False

    # min(sn, tn) 番目まで同じ。あとは長いほうが後ろ
    return sn < tn


if __name__ == "__main__":
    s = input()
    t = input()
    yes = two_anagrams(s, t)
    print('Yes' if yes else 'No')
Problem p03674 (python)

Fixed submission:
def mod_inv(n: int, mod: int)->int:
    b, u, v = mod, 1, 0
    while b > 0:
        t = n // b

        n -= t * b
        u -= t * v

        n, b = b, n
        u, v = v, u

    return (u+mod) % mod


def _11(N: int, A: list)->list:
    MOD = 10**9 + 7

    d = {}
    l, r = 0, 0
    for i, a in enumerate(A):
        if a in d:
            l, r = d[a], N-i
        else:
            d[a] = i

    c1, c2 = [1]*(N+2), [1]*(N+2)
    for i in range(N+1):
        c1[i+1] = (c1[i] * (N+1-i) * mod_inv(i+1, MOD)) % MOD
        c2[i+1] = (c2[i] * (l+r-i) * mod_inv(i+1, MOD)) % MOD

    return [(c1[k+1]-c2[k]+MOD) % MOD for k in range(N+1)]


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = _11(N, A)
    print('\n'.join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
def mod_inv(n: int, mod: int)->int:
    b, u, v = mod, 1, 0
    while b > 0:
        t = n // b

        n -= t * b
        u -= t * v

        a, b = b, a
        u, v = v, u

    return (u+mod) % mod


def _11(N: int, A: list)->list:
    MOD = 10**9 + 7

    d = {}
    l, r = 0, 0
    for i, a in enumerate(A):
        if a in d:
            l, r = d[a], N-i
        else:
            d[a] = i

    c1, c2 = [1]*(N+2), [1]*(N+2)
    for i in range(N+1):
        c1[i+1] = (c1[i] * (N+1-i) * mod_inv(i+1, MOD)) % MOD
        c2[i+1] = (c2[i] * (l+r-i) * mod_inv(i+1, MOD)) % MOD

    return [(c1[k+1]-c2[k]+MOD) % MOD for k in range(N+1)]


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = _11(N, A)
    print('\n'.join(map(str, ans)))
Problem p03732 (python)

Fixed submission:
def simple_knapsack(N: int, W: int, items: list) -> int:
    w0 = items[0][0]
    d = {w0+i: [] for i in range(4)}
    for w, v in items:
        d[w].append(v)

    s = {}
    for k, values in d.items():
        s[k] = [0] * (len(values)+1)
        for i, v in enumerate(sorted(values, key=lambda x: -x)):
            s[k][i + 1] = s[k][i] + v

    w0, w1, w2, w3 = w0, w0 + 1, w0 + 2, w0 + 3

    max_value = 0
    for i1 in range(len(s[w0])):
        if W < w0 * i1:
            break
        for i2 in range(len(s[w1])):
            if W < w0 * i1 + w1 * i2:
                break
            for i3 in range(len(s[w2])):
                if W < w0 * i1 + w1 * i2 + w2 * i3:
                    break
                for i4 in range(len(s[w3])):
                    if W < w0 * i1 + w1 * i2 + w2 * i3 + w3 * i4:
                        break
                    max_value = max(
                        max_value, s[w0][i1] + s[w1][i2] + s[w2][i3] + s[w3][i4])

    return max_value


if __name__ == "__main__":
    N = 0
    N, W = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(N)]
    ans = simple_knapsack(N, W, items)
    print(ans)

Buggy submission (verdict: Runtime Error):
def simple_knapsack(N: int, W: int, items: list) -> int:
    # dp[n][w] は n~N 番目の品物を利用して重さが w 以下となるときの
    # 最大価値
    dp = [[0] * (W+1) for _ in range(N+1)]

    for i, (iw, iv) in enumerate(items):
        for w in range(W+1):
            if w < iw:
                dp[N-i-1][w] = dp[N-i][w]
            else:
                dp[N-i-1][w] = max(dp[N-i][w], dp[N-i][w-iw]+iv)
    return dp[0][W]


if __name__ == "__main__":
    N = 0
    N, W = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(N)]
    ans = simple_knapsack(N, W, items)
    print(ans)
Problem p03853 (python)

Fixed submission:
def thin(H: int, W: int, C: list)->list:
    return [C[h//2] for h in range(2*H)]


if __name__ == "__main__":
    H = 0
    H, W = map(int, input().split())
    C = [input() for _ in range(H)]
    ans = thin(H, W, C)
    print('\n'.join(ans))

Buggy submission (verdict: Runtime Error):
def thin(H: int, W: int, C: list)->list:
    return [[C[h//2][w] for w in range(W)] for h in range(2*H)]


if __name__ == "__main__":
    H = 0
    H, W = map(int, input().split())
    C = [input() for _ in range(H)]
    ans = thin(H, W, C)
    print('\n'.join(ans))