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

Fixed submission:
class UnionFind :
    def __init__(self, size) :
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        return self.size[self.root(index)]

    def getComponent(self) :
        return self.component

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for a, b in zip(sorted(A), sorted(B)):
    if a > b:
        print('No')
        exit()

# Bの昇順でAを並び替え
BA = list(zip(A, B))
BA.sort()

AI = [(a, i) for i, (_, a) in enumerate(BA)]
AI.sort()

tree = UnionFind(N)
for nessIndex, (_, originalIndex) in enumerate(AI):
    tree.union(nessIndex, originalIndex)

V = set()
for i in range(N):
    V.add(tree.root(i))

if len(V) > 1:  # サイクルが複数の場合
    print('Yes')
    exit()

if any(a <= b for a, b in zip(sorted(A)[1:], sorted(B)[:-1])):
    print('Yes')
    exit()

print('No')

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for a, b in zip(sorted(A), sorted(B)):
    if a > b:
        print('No')
        exit()

AI = [(a, i) for i, a in enumerate(A)]
BI = [(b, i) for i, b in enumerate(B)]
AI.sort()
BI.sort()

orderA = [-1] * N
orderB = [-1] * N

for k, ((_, i), (_, j)) in enumerate(zip(AI, BI)):
    orderA[i] = k
    orderB[j] = k

aToI = {a : i for i, a in enumerate(A)}

cnt = 0
visited = [False] * N
for i, a in enumerate(A):
    if visited[i]:
        continue
    visited[i] = True

    leng = 0
    now = i
    while True:
        b = B[i]
        now = aToI[b]
        if visited[now]:
            break
        leng += 1
        visited[now] = True
    cnt += leng

if cnt <= N - 2:
    print('Yes')
else:
    print('No')
Problem p02936 (python)

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

N, Q = map(int, input().split())

edges = [[] for _ in range(N)]
for _ in range(N - 1):
    fr, to = map(lambda a: int(a) - 1, input().split())
    edges[fr].append(to)
    edges[to].append(fr)

P = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    P[p - 1] += x

ans = [-1] * N
st = deque([(0, 0)])
while st:
    now, val = st.pop()

    if ans[now] >= 0:
        continue
    val += P[now]
    ans[now] = val

    for to in edges[now]:
        st.append((to, val))

print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

def sol():
    N, Q = map(int, input().split())
    edge = [[] for _ in range(N)]

    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)

    ans = [0 for _ in range(N)]

    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ans[p] += x

    def calc(now, parent):
        if parent != -1:
            ans[now] += ans[parent]
        for to in edge[now]:
            if to != parent:
                calc(to, now)
        return

    calc(0, -1)
    print(*ans)


sol()

Buggy submission (verdict: Runtime Error):
def sol():
    N, Q = map(int, input().split())
    edge = [[] for _ in range(N)]

    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)

    ans = [0 for _ in range(N)]

    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ans[p] += x

    def calc(now, parent):
        ans[now] += ans[parent]
        for to in edge[now]:
            if to != parent:
                calc(to, now)
        return

    calc(0, -1)
    print(*ans)


sol()
Problem p02937 (python)

Fixed submission:
from collections import defaultdict
from bisect import bisect_right

def sol():
    S = input()
    T = input()

    setS = set(S)
    setT = set(T)
    for t in setT:
        if not t in setS:
            print('-1')
            return

    posS = defaultdict(list)

    for i, s in enumerate(S):
        posS[s].append(i)

    for s in enumerate(S):
        posS[s].sort()

    prev = -1
    ans = 0
    N = len(S)

    for t in T:
        next = bisect_right(posS[t], prev)
        if next >= len(posS[t]):
            ans += N - prev
            ans += posS[t][0]
            prev = posS[t][0]
        else:
            ans += posS[t][next] - prev
            prev = posS[t][next]

    print(ans)

sol()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
 
S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)
Problem p02960 (python)

Fixed submission:
S = input()
MOD = 10**9 + 7
lenS = len(S)

dp = [[0 for _ in range(13)] for _ in range(lenS + 1)]  # dp[digit][d] = digit桁までの mod=d の数
dp[0][0] = 1

digitMask = 1

for digit in range(1, lenS + 1) :
    if(S[-digit] == '?') :
        for d in range(13) :
            for k in range(10) :
                dp[digit][d] = (dp[digit][d] + dp[digit - 1][(d - k * digitMask) % 13]) % MOD
    else :
        a = int(S[-digit])
        for d in range(13) :
            dp[digit][d] = (dp[digit][d] + dp[digit - 1][(d - a * digitMask) % 13]) % MOD
    digitMask *= 10
    digitMask %= 13

ans = (dp[len(S)][5]) % MOD
print(ans)

Buggy submission (verdict: Runtime Error):
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353

dp = [0] * (S + 1)

ans = 0
for a in A:
    dp[0] += 1
    for s in range(S + 1)[::-1]:
        if s + a <= S:
            dp[s + a] = (dp[s + a] + dp[s]) % MOD
    ans += dp[S]
    ans %= MOD

print(ans)
Problem p02972 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

ball = [0] * N
ans = []

for i in range(1, N+1) :
    ballCount = sum(ball[N-i::N-i+1])
    if ballCount % 2 == A[N-i] :
        pass
    else :
        ball[N - i] = 1
        ans.append(N - i + 1)
print(len(ans))
print(*ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

ball = [0] * N

for i in range(N-1, -1, -1) :
    for j in range(1, N) :
        if i * j >= N :
            break
        bit = (bit + ball[i * j]) % 2
    ball[i] = bit % 2

print(*ball)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

ball = [0] * N

for i in range(N-1, -1, -1) :
    bit = A[i]
    for j in range(i + 1, N) :
        bit = (ball + ball[i]) % 2
    ball[i] = bit % 2

print(*ball)
Problem p03026 (python)

Fixed submission:
from collections import deque

N = int(input())

edges = [[] for _ in range(N)]
edgeList = []
for _ in range(N - 1):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edges[to].append(fr)
    edgeList.append((fr, to))

C = list(map(int, input().split()))
C.sort()

M = sum(C) - C[-1]

values = [-1] * N
que = deque([0])

while que:
    now = que.popleft()
    values[now] = C.pop()
    for to in edges[now]:
        if values[to] == -1:
            que.append(to)

print(M)
print(*values)

Buggy submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
edges = [[] for _ in range(N)]

for _ in range(N - 1):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edges[to].append(fr)

C = Counter(map(int, input().split()))

def dfs(now, pr, prev):
    ret = 0
    for to in edges:
        if to == pr:
            continue
        for c, n in C.items():
            if n == 0:
                continue
            C[c] -= 1
            ret = max(ret, dfs(to, now, c) + min(prev, c))
            C[c] += 1
    return ret

print(dfs(0, -1, 0))
Problem p03029 (python)

Fixed submission:
A , P = map(int,input().split())

piece = 0
pie = 0

piece = A * 3 + P

print(int(piece / 2))

Buggy submission (verdict: Runtime Error):
N , K = map(int,input().split())
D = list(map(int,input().split()))

maxValue = 0

for i in range(min(N,K)+1):
    for j in range(min(N,K)-i+1):
        left = D[:i]
        right = D[N-j:]
        merge = (left + right + [0]).sort()

        index = 0

        for k in range(K-i-j):
            if (merge[0] < 0):
                index += 1
            else:
                break

        val = sum(merge[index:])
        if(maxValue < val):
            maxValue = val

print(maxValue)
Problem p03061 (python)

Fixed submission:
def gcd(a,b) :
    r = a % b
    if r == 0 :
        return b
    else :
        return gcd(b,r)

N = int(input())

A = list(map(int,input().split()))

L = [0] * N
R = [0] * N

for i in range(N) :  # iより左(右)
    if i == 0 :
        L[i] = A[i]
        R[-i-1] = A[-i-1]
    else :
        L[i] = gcd(L[i-1], A[i-1])
        R[-i-1] = gcd(R[-i],A[-i])

ans = 1

for i in range(N) :
    if i == 0 :
        new = R[i]
    elif i == N-1 :
        new = L[i]
    else :
        new = gcd(L[i],R[i])
    if ans < new :
        ans = new

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int,input().split()))

ans = 1

if N == 1 :
    ans = A[0]
else :
    for i in range(N) :
        B = A[:i-1] + A[i:] # i番目を除く
        stat = B[0]
        for b in B[1:] :
            stat = math.gcd(stat,b)
            if stat == 1:
                break
        else :
            ans = max(ans,stat)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int,input().split()))

ans = 1

if N == 1 :
    ans = A[0]
else :
    for i in range(N) :
        B = A[:i-1] + A[i:] # i番目を除く
        gcd = B[0]
        for b in B[1:] :
            gcd = math.gcd(gcd,b)
            if gcd == 1:
                break
        else :
            ans = max(ans,gcd)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int,input().split()))

ans = 1

for i in range(N) :
    B = A[:i-1] + A[i:]
    gcd = B[0]
    for b in B[1:] :
        gcd = math.gcd(gcd,b)
        if gcd == 1:
            break
    else :
        ans = max(ans,gcd)

print(ans)
Problem p03078 (python)

Fixed submission:
from heapq import heappop , heappush

X , Y , Z , K = map(int,input().split())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

# それぞれソート
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

# 処理済みフラグ
confilm = []

q = [(-(A[0] + B[0] + C[0]) , 0,0,0)]

for _ in range(K) :
    val , i , j , k = heappop(q)

    print(-val)

    t = (i+1,j,k)
    if i + 1 < X and not t in confilm :
        heappush(q,(-(A[i+1] + B[j] + C[k]),) + t)
        confilm.append(t)

    t = (i,j+1,k)
    if j + 1 < Y and not t in confilm :
        heappush(q,(-(A[i] + B[j+1] + C[k]),) + t)
        confilm.append(t)

    t = (i,j,k+1)
    if k + 1 < Z and not t in confilm :
        heappush(q,(-(A[i] + B[j] + C[k+1]),) + t)
        confilm.append(t)

Buggy submission (verdict: Runtime Error):
import heapq

X , Y , Z , K = map(int,input().split())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

# それぞれソート
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


# 処理済みフラグ
confilm = [[[False for _ in range(Z)] for _ in range(Y)] for _ in range(X)]

q = [(-(A[0] + B[0] + C[0]) , 0,0,0)]
confilm[0][0][0] = True

count = 0

while q :
    now = heapq.heappop(q)

    print(-now[0])
    count += 1
    if count >= K :
        break

    i , j , k = now[1] , now[2] , now[3]

    if not confilm[i+1][j][k] :
        heapq.heappush(q,(-(A[i+1] + B[j] + C[k]), i+1,j,k))
        confilm[i+1][j][k] = True
    if not confilm[i][j+1][k] :
        heapq.heappush(q,(-(A[i] + B[j+1] + C[k]), i,j+1,k))
        confilm[i][j+1][k] = True
    if not confilm[i][j][k+1] :
        heapq.heappush(q,(-(A[i] + B[j] + C[k+1]), i,j,k+1))
        confilm[i][j][k+1] = True
Problem p03086 (python)

Fixed submission:
S = input()
T = set(list('AGCT'))

ans = 0
for l in range(len(S)):
    for r in range(l + 1, len(S) + 1):
        if set(S[l: r]) <= T:
            ans = max(ans, r - l)

print(ans)

Buggy submission (verdict: Runtime Error):
<?php

$s = trim(fgets(STDIN));
$count = [0];

$replace = preg_replace('/[^ACGT]/',',',$s);
$matchs = array_filter(explode(',',$replace));

foreach ($matchs as $m) {
    $count[] = strlen($m);
}

print(max($count) . "\n");
Problem p03106 (python)

Fixed submission:
import fractions as fr

A , B , K = map(int,input().split()) # A,B <= 100

k = 0

R = int(max(fr.gcd(A,B),1))

for i in range(R,0,-1) :
    if A % i == 0 and B % i == 0 :
        k += 1
        if k >= K :
            print(i)
            break

Buggy submission (verdict: Runtime Error):
import math

A , B , K = map(int,input().split()) # A,B <= 100

k = 0

R = int(max(math.gcd(A,B),1))

for i in range(R,0,-1) :
    if A % i == 0 and B % i == 0 :
        k += 1
        if k >= K :
            print(i)
            break

Buggy submission (verdict: Runtime Error):
import math

A , B , K = map(int,input().split()) # A,B <= 100

k = 0

for i in range(math.gcd(A,B),0,-1) :
    if A % i == 0 and B % i == 0 :
        k += 1
        if k >= K :
            print(i)
            break
Problem p03128 (python)

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

A.sort(reverse=True)

match = [2,5,5,4,5,6,3,7,6]

dp = [-float('inf')] * (N + 1)

dp[0] = 0
for i in range(1, N+1) :
    maxDigit = -float('inf')
    for a in A :
        if i - match[a - 1] >= 0 :
            maxDigit = max(maxDigit, dp[i - match[a - 1]] + 1)
    dp[i] = maxDigit

maxDigit = dp[-1]

r = N

for _ in range(maxDigit) :
    for a in A :
        if r - match[a - 1] < 0 or r < 0 :
            continue
        if dp[r - match[a - 1]] == dp[r] - 1 :
            print(a, end='')
            r -= match[a - 1]
            break

print('')

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
N, M = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort(reverse=True)

matchNum = {
    1 : 2,
    2 : 5,
    3 : 5,
    4 : 4,
    5 : 5,
    6 : 6,
    7 : 3,
    8 : 7,
    9 : 6,
}

makeDigit = [0] * (N + 1)
for n in range(1, N + 1):
    d = makeDigit[n]
    for k in nums:
        cnt = n - matchNum[k]
        if cnt >= 0:
            d = max(d, makeDigit[cnt] + 1)
    if makeDigit[n] < d:
        makeDigit[n] = d

ans = []
for d in range(makeDigit[N])[:: -1]:
    for k in nums:
        cnt = N - matchNum[k]
        if makeDigit[cnt] == d:
            ans.append(k)
            N = cnt
            break

ans.sort(reverse=True)
print(int(''.join(map(str, ans))))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
N, M = map(int, input().split())
nums = list(map(int, input().split()))

matchNum = {
    1 : 2,
    2 : 5,
    3 : 5,
    4 : 4,
    5 : 5,
    6 : 6,
    7 : 3,
    8 : 7,
    9 : 6,
}

dp = [''] * (N + 1)
for n in range(1, N + 1):
    for k in nums:
        d = 0
        cnt = n - matchNum[k]
        if cnt >= 0 and (dp[cnt] != '' or (cnt == 0 and dp[n] <= dp[cnt] * 10)):
            oldVal = list(str(dp[cnt]))[:: -1]
            adder = bisect_left(oldVal, str(k))
            newVal = oldVal[:adder] + [str(k)] + oldVal[adder:]
            newVal = int(''.join(newVal[:: -1]))
            d = max(d, newVal)
        if d == 0:
            continue
        elif dp[n] == '':
            dp[n] = d
        else:
            dp[n] = max(dp[n], d)

print(dp[N])

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

A.sort(reverse=True)

match = [2,5,5,4,5,6,3,7,6]

dp = [-float('inf')] * (N + 1)

dp[0] = 0
for i in range(1, N+1) :
    maxDigit = -float('inf')
    for a in A :
        if i - match[a - 1] >= 0 :
            maxDigit = max(maxDigit, dp[i - match[a - 1]] + 1)
    dp[i] = maxDigit

maxDigit = dp[-1]

r = N

for _ in range(maxDigit) :
    for a in A :
        if dp[r - match[a - 1]] == dp[r] - 1 :
            print(a, end='')
            r -= match[a - 1]
            break

print('')
Problem p03142 (python)

Fixed submission:
from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())

parent = [[] for _ in range(N)]
child = [[] for _ in range(N)]

for _ in range(N - 1 + M):
    pr, ch = map(int, input().split())
    pr -= 1
    ch -= 1
    parent[ch].append(pr)
    child[pr].append(ch)

root = parent.index([])
ans = [-1] * N

# 葉からの検索を行う
@lru_cache(maxsize=None)
def search(now):
    if now == root:
        ans[now] = 0
        return 0
    ret = -1
    for pr in parent[now]:
        depth = search(pr)
        if depth > ret:
            ans[now] = pr + 1
            ret = depth
    return ret + 1

for i in range(N):
    search(i)

print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

N, M = map(int, input().split())

parent = [[] for _ in range(N)]
child = [[] for _ in range(N)]

for _ in range(N - 1 + M):
    pr, ch = map(int, input().split())
    pr -= 1
    ch -= 1
    parent[ch].append(pr)
    child[pr].append(ch)

root = parent.index([])
ans = [-1] * N

# 葉からの検索を行う
@lru_cache(maxsize=None)
def search(now):
    if now == root:
        ans[now] = 0
        return 0
    ret = -1
    for pr in parent[now]:
        depth = search(pr)
        if depth > ret:
            ans[now] = pr + 1
            ret = depth
    return ret + 1

for i in range(N):
    search(i)

print(*ans, sep='\n')
Problem p03147 (python)

Fixed submission:
from collections import deque

N = int(input())
h = list(map(int,input().split()))

stack = deque([])
prevPoint = -1

for i in range(N) :
    if h[i] == 0 :
        stack.append((prevPoint+1 , i))
        prevPoint = i
    elif i >= N - 1 :
        stack.append((prevPoint+1,N))

ans = 0

while stack :
    start , end = stack.pop()

    if start >= end :
        ans += h[start]
        h[start] = 0
        continue


    minus = min(h[start:end])
    ans += minus

    prevPoint = start - 1
    for i in range(start,end) :
        h[i] -= minus
        if h[i] == 0 :
            stack.append((prevPoint+1,i))
            prevPoint = i
        elif i >= end - 1 :
            stack.append((prevPoint+1,end))

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = 0

while max(H) > 0:
    grp = [[]]
    for i, h in enumerate(H):
        if h == 0:
            if len(grp[-1]) > 0:
                grp.append([])
        else:
            grp[-1].append((i, h))
    for g in grp:
        mi = min([h for _, h in g])
        ans += mi
        for i, _ in g:
            H[i] -= mi

print(ans)
Problem p03148 (python)

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

sushi = []

for _ in range(N) :
    t, d = map(int,input().split())
    sushi.append((t,d))

sushi.sort(key=lambda A : A[1], reverse=True)

# 美味しいものから順にK個選ぶ
nowSushi = []
sumTaste = 0
numKind = 0
take = [0] * N  # 種類は高々N

for i in range(K) :
    t, d = sushi[i]
    nowSushi.append((t,d))
    sumTaste += d
    if take[t-1] == 0 :
        numKind += 1
    take[t-1] += 1

addSushi = []  # 種類を増やせる寿司
for i in range(K,N) :
    t, d = sushi[i]
    if take[t-1] > 0 :  # すでに選択済み
        continue
    addSushi.append((t,d))
    take[t-1] += 1

ans = sumTaste + numKind**2
L = len(addSushi)
changeCount = 0

while nowSushi :
    removeSushiT, removeSushiD = nowSushi.pop()
    if take[removeSushiT-1] <= 1 :
        continue
    if changeCount >= L :
        break

    addSushiT, addSushiD = addSushi[changeCount]
    changeCount += 1

    sumTaste = sumTaste - removeSushiD + addSushiD
    numKind = numKind + 1

    if (sumTaste + numKind**2) > ans :
        ans = sumTaste + numKind**2

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

N, K = map(int, input().split())
TD = [tuple(map(int, input().split())) for _ in range(N)]

TD.sort(reverse=True, key=lambda a: a[1])

A = TD[:K]

B = []
V = set()
for t, d in TD:
    if t in V:
        continue
    B.append((t, d))
    V.add(t)

cntT = Counter([t for t, _ in A])
V = set(cntT.keys())
S = sum([d for _, d in A])
B = [(t, d) for t, d in B if not t in V]

C = []
for t, d in A[::-1]:
    if cntT[t] > 1:
        C.append((t, d))
        cntT[t] -= 1

C = C[::-1]
ans = S + len(V)**2
for t, d in B:
    _, less = C.pop()
    S -= less
    S += d
    V.add(t)
    ans = max(ans, S + len(V)**2)
print(ans)
Problem p03206 (python)

Fixed submission:
D = int(input())

if D == 25 :
  print('Christmas')
elif D == 24 :
  print('Christmas Eve')
elif D == 23 :
  print('Christmas Eve Eve')
elif D == 22 :
  print('Christmas Eve Eve Eve')

Buggy submission (verdict: Runtime Error):
D = int(intput())

if D == 25 :
  print('Christmas')
elif D == 24 :
  print('Christmas Eve')
elif D == 23 :
  print('Christmas Eve Eve')
elif D == 22 :
  print('Christmas Eve Eve Eve')
Problem p03343 (python)

Fixed submission:
N, K, Q = map(int, input().split())
A = list(map(int, input().split()))

def sol(y):
    B = [[]]
    for a in A:
        if a < y and len(B[-1]) > 0:
            B.append([])
        if a >= y:
            B[-1].append(a)

    C = []
    for grp in B:
        grp.sort()
        C += grp[:max(0, len(grp) - K + 1)]
    C.sort()

    return C[Q - 1] - y if len(C) >= Q and C[0] == y else 10**18

ans = 10**18
for y in A:
    ans = min(ans, sol(y))

print(ans)

Buggy submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = list(map(int, input().split()))

def getMinX(i, y):
    B = [[]]
    for j, a in enumerate(A):
        if i == j:
            continue
        if a < y and len(B[-1]) > 0:
            B.append([])
        if a >= y:
            B[-1].append(a)

    C = []
    for grp in B:
        grp.sort()
        C += grp[:len(grp) - K + 1]
    C.sort()
    return C[Q - 2] if len(C) >= Q - 1 else 10**18

ans = 10**18
for i, y in enumerate(A):
    ans = min(ans, getMinX(i, y) - y)
print(ans)
Problem p03394 (python)

Fixed submission:
N = int(input())

if N == 3:
    print('2 5 63')
else:
    A2 = [a for a in range(2, 30001, 2) if a % 6 != 0]
    A3 = [a for a in range(3, 30001, 6)]
    A6 = [a for a in range(6, 30001, 6)]

    a2 = min(10000, (N - 2) // 2 * 2)
    N -= a2
    a3 = min(5000, N // 2 * 2)
    a6 = N - a3

    ans = A2[: a2] + A3[: a3] + A6[: a6]
    print(*ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappop, heappush, heapify

N = int(input())

ans = []

que = [6, 10, 15]
heapify(que)

while N > 0:
    a = heappop(que)
    ans.append(a)
    N -= 1
    for p in [2, 3, 5]:
        if a % p != 0:
            heappush(que, a * p)

print(*ans)