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

Fixed submission:
n, q = map(int, input().split())
s = input()

query = [list(input().split()) for _ in range(q)]

# 左に落ちる。leftから左(leftを含む)は左に落ちて、rightから右は左に落ちない。
left = -1
right = n
while right - left > 1:
    mid = (left + right) // 2
    index = mid
    for w, dir in query:
        if s[index] != w:
            continue
        if dir == 'R':
            index += 1
        elif dir == 'L':
            index -= 1

        if index == n:
            right = mid
            break
        elif index == -1:
            left = mid
            break
    if index != -1:
        right = mid
c1 = left + 1

# 右に落ちる。leftから左(leftを含む)は右に落ちず、rightから右は右に落ちる。
left = -1
right = n
while right - left > 1:
    mid = (left + right) // 2
    index = mid
    for w, dir in query:
        if s[index] != w:
            continue
        if dir == 'R':
            index += 1
        elif dir == 'L':
            index -= 1

        if index == n:
            right = mid
            break
        elif index == -1:
            left = mid
            break
    if index != n:
        left = mid

c2 = n - 1 - left

print(n - c1 - c2)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()

query = [list(input().split()) for _ in range(q)]

# 左に落ちる (1から, leftで判断(leftは落ちる個数))
left = 0
right = n+1
while right - left > 1:
    mid = (left + right) // 2
    index = mid - 1
    for w, dir in query:
        if s[index] != w:
            continue
        if dir == 'R':
            index += 1
        elif dir == 'L':
            index -= 1

        if index == n:
            right = mid
            break
        elif index == -1:
            left = mid
            break
    if index != -1:
        right = mid
c1 = left

# 右 (leftで判断(leftが落ちないギリギリ。最大はn-1, 最小は-1))
left = -1
right = n+1
while right - left > 1:
    mid = (left + right) // 2
    index = mid
    for w, dir in query:
        if s[index] != w:
            continue
        if dir == 'R':
            index += 1
        elif dir == 'L':
            index -= 1

        if index == n:
            right = mid
            break
        elif index == -1:
            left = mid
            break
    if index != n:
        left = mid

c2 = n - 1 - left

print(n - c1 - c2)
Problem p03091 (python)

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

n, m = map(int, input().split())

v = [0] * n
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    v[a] += 1
    v[b] += 1
    g[a].append(b)
    g[b].append(a)

for i in range(n):
    if v[i] % 2 == 1:
        print("No")
        exit()

v4 = 0
for i in range(n):
    if v[i] >= 6:
        print("Yes")
        exit()
    if v[i] == 4:
        v4 += 1

if v4 == 0:
    print("No")
    exit()
if v4 == 1:
    print("No")
    exit()
if v4 >= 3:
    print("Yes")
    exit()


memo = [0] * n
ord = [0] * n
lowlink = [0] * n
articulation = [0] * n

def dfs(v, p, k):
    memo[v] = 1
    ord[v] = k
    lowlink[v] = ord[v]
    isArticulation = False
    count = 0
    for nv in g[v]:
        if memo[nv] == 0:
            count += 1
            dfs(nv, v, k+1)
            lowlink[v] = min(lowlink[v], lowlink[nv])
            if p != -1 and ord[v] <= lowlink[nv]:
                isArticulation = True
        elif nv != p:
            lowlink[v] = min(lowlink[v], ord[nv])

    if p == -1 and count > 1:
        isArticulation = True
    if isArticulation:
        articulation[v] = 1

dfs(0, -1, 0)

count = 0
for i in range(n):
    if v[i] == 4 and articulation[i] == 1:
        count += 1

if count >= 2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

v = [0] * n
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    v[a] += 1
    v[b] += 1
    g[a].append(b)
    g[b].append(a)

for i in range(n):
    if v[i] % 2 == 1:
        print("No")
        exit()

v4 = 0
for i in range(n):
    if v[i] >= 6:
        print("Yes")
        exit()
    if v[i] == 4:
        v4 += 1

if v4 == 0:
    print("No")
    exit()
if v4 == 1:
    print("No")
    exit()
if v4 >= 3:
    print("Yes")
    exit()


memo = [0] * n
ord = [0] * n
lowlink = [0] * n
articulation = [0] * n

def dfs(v, p, k):
    memo[v] = 1
    ord[v] = k
    lowlink[v] = ord[v]
    isArticulation = False
    count = 0
    for nv in g[v]:
        if memo[nv] == 0:
            count += 1
            dfs(nv, v, k+1)
            lowlink[v] = min(lowlink[v], lowlink[nv])
            if p != -1 and ord[v] <= lowlink[nv]:
                isArticulation = True
        elif nv != p:
            lowlink[v] = min(lowlink[v], ord[nv])

    if p == -1 and count > 1:
        isArticulation = True
    if isArticulation:
        articulation[v] = 1

dfs(0, -1, 0)

count = 0
for i in range(n):
    if v[i] == 4 and articulation[i] == 1:
        count += 1

if count >= 2:
    print("Yes")
else:
    print("No")
Problem p03112 (python)

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

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

INF = float('inf')
for _ in range(q):
    x = int(input())
    if x > s[a-1]:
        sl = x - s[a-1]
        sr = INF
    elif x < s[0]:
        sl = INF
        sr = s[0] - x
    else:
        si = bisect.bisect_right(s, x)
        sl = x - s[si-1]
        sr = s[si] - x

    if x > t[b-1]:
        tl = x - t[b-1]
        tr = INF
    elif x < t[0]:
        tl = INF
        tr = t[0] - x
    else:
        ti = bisect.bisect_right(t, x)
        tl = x - t[ti-1]
        tr = t[ti] - x

    ans = min(max(sl, tl), max(sr, tr))

    ans = min(ans, sr*2+tl)
    ans = min(ans, sr+tl*2)
    ans = min(ans, sl*2+tr)
    ans = min(ans, sl+tr*2)

    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

INF = float('inf')
for _ in range(q):
    x = int(input())
    if x > s[a-1]:
        sl = x - s[a-1]
        sr = INF
    elif x < s[0]:
        sl = INF
        sr = s[0] - x
    else:
        si = bisect.bisect_right(s, x)
        sl = x - s[si-1]
        sr = s[si] - x

    if x > t[a-1]:
        tl = x - t[a-1]
        tr = INF
    elif x < t[0]:
        tl = INF
        tr = t[0] - x
    else:
        ti = bisect.bisect_right(t, x)
        tl = x - t[ti-1]
        tr = t[ti] - x

    ans = min(max(sl, tl), max(sr, tr))

    ans = min(ans, sr*2+tl)
    ans = min(ans, sr+tl*2)
    ans = min(ans, sl*2+tr)
    ans = min(ans, sl+tr*2)

    print(ans)
Problem p03164 (python)

Fixed submission:
n, w = map(int, input().split())

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

INF = float('inf')
num = 10**5 + 10
dp = [[INF]*(10**5+10) for _ in range(110)]

dp[0][0] = 0
for i in range(n):
    for v in range(10**5+1):
        if v + nap[i][1] <= 10**5+1:
            dp[i+1][v+nap[i][1]] = min(dp[i+1][v+nap[i][1]], dp[i][v] + nap[i][0])
        dp[i+1][v] = min(dp[i+1][v], dp[i][v])

for v in reversed(range(10**5+1)):
    if dp[n][v] <= w:
        print(v)
        exit()

Buggy submission (verdict: Runtime Error):
n, w = map(int, input().split())

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

INF = float('inf')
num = 10**5 + 10
dp = [[INF]*num for _ in range(110)]

dp[0][0] = 0
for i in range(n):
    for v in range(num):
        if v + nap[i][1] <= num:
            dp[i+1][v+nap[i][1]] = min(dp[i+1][v+nap[i][1]], dp[i][v] + nap[i][0])
        dp[i+1][v] = min(dp[i+1][v], dp[i][v])

for v in reversed(range(num)):
    if dp[n][v] <= w:
        print(v)
        exit()

Buggy submission (verdict: Runtime Error):
n, w = map(int, input().split())

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

INF = float('inf')
num = 10**5 + 10
dp = [[INF]*(num) for _ in range(110)]

dp[0][0] = 0
for i in range(n):
    for v in range(num):
        if v + nap[i][1] <= num:
            dp[i+1][v+nap[i][1]] = min(dp[i+1][v+nap[i][1]], dp[i][v] + nap[i][0])
        dp[i+1][v] = min(dp[i+1][v], dp[i][v])

for v in reversed(range(num)):
    if dp[n][v] <= w:
        print(v)
        exit()
Problem p03165 (python)

Fixed submission:
s = input()
t = input()

dp = [[0] * 3010 for _ in range(3010)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

i = len(s)
j = len(t)
res = ""
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        res += s[i-1]
        i -= 1
        j -= 1

ans = ""
for i in reversed(range(len(res))):
    ans += res[i]

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

len_s = len(s)
len_t = len(t)
INF = float('inf')

dp = [[-INF] * (len_t+1) for _ in range(len_s+1)]

dp[0][0] = 0

memo = [[] * (len_t+1) for _ in range(len_s+1)]

for i in range(len_s+1):
    for j in range(len_t+1):
        if i+1 <= len_s and j <= len_t and dp[i+1][j] <= dp[i][j]:
            dp[i+1][j] = dp[i][j]
            memo[i+1][j] = [i, j]
        if i <= len_s and j+1 <= len_t and dp[i][j+1] <= dp[i][j]:
            dp[i][j+1] = dp[i][j]
            memo[i][j+1] = [i, j]
        if i+1 <= len_s and j+1 <= len_t and s[i] == t[j] and dp[i+1][j+1] <= dp[i][j]+1:
            dp[i+1][j+1] = dp[i][j] + 1
            memo[i+1][j+1] = [i, j]

i = len_s
j = len_t
ans = ""
while i > 0 and j > 0:
    pre_i, pre_j = memo[i][j][0], memo[i][j][1]
    if i == pre_i + 1 and j == pre_j + 1:
        ans += s[i-1]
    i = pre_i
    j = pre_j

print(ans[::-1])

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

len_s = len(s)
len_t = len(t)

dp = [[0] * len_t for _ in range(len_s)]

for i in range(len_s):
    for j in range(len_t):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

i = len_s
j = len_t
res = ""
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        res += s[i-1]
        i -= 1
        j -= 1

print(res[::-1])
Problem p03170 (python)

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

dp = [0] * (k+1)

for i in range(1, k+1):
    for a in A:
        if i - a < 0:
            break
        if dp[i-a] == 0:
            dp[i] = 1

if dp[k] == 1:
    print("First")
else:
    print("Second")

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))

memo = [-1] * (k+1)
def rec(x):
    if memo[x] >= 0:
        return memo[x]
    flag = 0
    for i in range(n):
        if x - a[i] < 0:
            continue
        if rec(x - a[i]) == 0:
            flag = 1
    if flag == 1:
        memo[x] = 1
        return 1
    else:
        memo[x] = 0
        return 0

if rec(k) == 1:
    print("First")
else:
    print("Second")
Problem p03171 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

dp = [[0] * (n+1) for _ in range(n+1)]

for l in range(1, n+1):
    for i in range(n - l + 1):
        j = i + l
        if (n - l) % 2 == 0:
            dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1])
        else:
            dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1])

print(dp[0][n])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

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

if n > 2000 or m > 2000:
    exit()

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

q = int(input())
if q > 2000:
    exit()

query = [list(map(int, input().split())) for _ in range(q)]

color = [0] * n

def dfs(node, dist, dist_max, col, pre_node):
    if dist > dist_max:
        return
    if color[node] == 0:
        color[node] = col
    if dist == dist_max:
        return
    for next_node in g[node]:
        if next_node == pre_node:
            continue
        dfs(next_node, dist+1, dist_max, col, node)

for v, d, c in query[::-1]:
    v -= 1
    dfs(v, 0, d, c, -1)

for co in color:
    print(co)
Problem p03175 (python)

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

n = int(input())
graph = [[] for _ in range(n)]

for _ in range(n-1):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    graph[x].append(y)
    graph[y].append(x)

mod = 10**9 + 7

memo = [0] * n
# dp[v][0]:= 頂点vを白に塗ったときの、vを親とする部分木の塗り方の総数
# dp[v][1]:= 頂点vを黒に塗ったときの、vを親とする部分木の塗り方の総数
dp = [[0, 0] for _ in range(n+1)]


def dfs(v):
    if memo[v] != 0:
        return
    memo[v] = 1
    dp[v][0] = 1
    dp[v][1] = 1
    for nv in graph[v]:
        if memo[nv] != 0:
            continue
        dfs(nv)
        dp[v][0] *= (dp[nv][0] + dp[nv][1])
        dp[v][0] %= mod

        dp[v][1] *= dp[nv][0]
        dp[v][1] %= mod

dfs(0)
print((dp[0][0] + dp[0][1]) % mod)

Buggy submission (verdict: Runtime Error):
n = int(input())
graph = [[] for _ in range(n)]

for _ in range(n-1):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    graph[x].append(y)
    graph[y].append(x)

mod = 10**9 + 7

memo = [0] * n
# dp[v][0]:= 頂点vを白に塗ったときの、vを親とする部分木の塗り方の総数
# dp[v][1]:= 頂点vを黒に塗ったときの、vを親とする部分木の塗り方の総数
dp = [[0, 0] for _ in range(n+1)]


def dfs(v):
    if memo[v] != 0:
        return
    memo[v] = 1
    dp[v][0] = 1
    dp[v][1] = 1
    for nv in graph[v]:
        if memo[nv] != 0:
            continue
        dfs(nv)
        dp[v][0] *= (dp[nv][0] + dp[nv][1])
        dp[v][0] %= mod

        dp[v][1] *= dp[nv][0]
        dp[v][1] %= mod

dfs(0)
print((dp[0][0] + dp[0][1]) % mod)
Problem p03244 (python)

Fixed submission:
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

list0 = []
list1 = []
for i, a in enumerate(v):
    if i % 2 == 0:
        list0.append(a)
    else:
        list1.append(a)

c0 = Counter(list0)
c1 = Counter(list1)

c0_most_common = c0.most_common(2)
c1_most_common = c1.most_common(2)

if c0_most_common[0][0] != c1_most_common[0][0]:
    print(n - (c0_most_common[0][1] + c1_most_common[0][1]))
else:
    if len(c0_most_common) >= 2 and len(c1_most_common) >= 2:
        print(min(n - (c0_most_common[0][1] + c1_most_common[1][1]), n - (c0_most_common[1][1] + c1_most_common[0][1])))
    elif len(c0_most_common) == 1 and len(c1_most_common) >= 2:
        print(n - (c0_most_common[0][1]) + c1_most_common[1][1])
    elif len(c1_most_common) == 1 and len(c0_most_common) >= 2:
        print(n - (c1_most_common[0][1]) + c0_most_common[1][1])
    else:
        print(n - (c1_most_common[0][1]))

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

n = int(input())
v = list(map(int, input().split()))

list0 = []
list1 = []
for i, a in enumerate(v):
    if i % 2 == 0:
        list0.append(a)
    else:
        list1.append(a)

c0 = Counter(list0)
c1 = Counter(list1)

c0_most_common = c0.most_common(2)
c1_most_common = c1.most_common(2)

if c0_most_common[0][0] != c1_most_common[0][0]:
    print(n - (c0_most_common[0][1] + c1_most_common[0][1]))
else:
    print(min(n - (c0_most_common[0][1] + c1_most_common[1][1]), n - (c0_most_common[1][1] + c1_most_common[0][1])))
Problem p03266 (python)

Fixed submission:
n, k = map(int, input().split())
num = n // k
if k == 1:
    print(num ** 3)
else:
    num2 = n // (k // 2) - num

    if k % 2 == 0:
        print(num ** 3 + num2 ** 3)
    else:
        print(num ** 3)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())

num = n // k
num2 = n // (k//2) - num

if k % 2 == 0:
    print(num ** 3 + num2 ** 3)
else:
    print(num ** 3)
Problem p03331 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(1, 6):
    if n == 10 ** i:
        ans = 1

if ans == 1:
    print(10)
else:
    num = 0
    for i in range(1, 6):
        num += n % 10
        n = n // 10
    print(num)

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

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

nmemo = [0 for i in range(n+1)]
def permutation(n):
    if nmemo[n] != 0:
        return nmemo[n]
    if n == 0:
        return 1
    nmemo[n] = n * permutation(n-1)
    return nmemo[n]


memo = []
ans = 0

for i in range(n + 1):
    knum = k - b * i
    if k < 0:
        break
    if knum % a == 0:
        if knum//a + i <= 2 * n:
            memo.append([knum // a, i])

for i in memo:
    nmin = min(i[0], i[1])
    jmin = 0
    if i[0] + i[1] > n:
        jmin = i[0] + i[1] - n
    for j in range(jmin, nmin+1):
        if (i[0] + i[1] - j) <= n:
            ans += permutation(n) // (permutation(i[0] - j) * permutation(i[1] - j)
                                      * permutation(j) * (permutation(n - (i[0] - j + i[1]))))

if k == 0:
    print(1)
else:
    print(ans % 998244353)
Problem p03340 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

i = 1
j = 0
c = a[0]
ans = n
num = 0

while i <= n-1:
    if c ^ a[i] == c + a[i]:
        c = c ^ a[i]
        num += 1
        ans += num
        i += 1
    else:
        c = c & ~a[j]
        j += 1
        num -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = []

for i in range(n):
    b.append(a[i])

i = 1
j = 0
c = b[0]
ans = n
num = 0

while i < n-1 or j < n-1:
    if b[j] ^ b[i] == b[j] | b[i]:
        c = b[j] | b[i]
        num += 1
        ans += num
        i += 1
    else:
        c -= b[j]
        j += 1

print(ans)
Problem p03363 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

b = []
bn = 0
for i in range(n):
    bn += a[i]
    b.append(bn)
b.append(0)

b.sort()
num = []
i = 0
count = 0
for j in range(1, n+1):
    if b[i] == b[j]:
        count += 1
        if j == n:
            num.append(count)
    else:
        i = j
        num.append(count)
        count = 0

ans = 0
for i in num:
    ans += ((i+1) * i // 2)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [input() for _ in range(n)]

ans = 0
a = 0
for b in range(n):
    flag = 0
    for i in range(n):
        if flag == 1:
            break
        for j in range(n):
            if s[(i+a)%n][(j+b)%n] != s[(j+a)%n][(i+b)%n]:
                flag = 1
                break
    else:
        ans += n

print(ans)
Problem p03380 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
m = a[0]
ans = a[0]
if a[0]%2 == 0:
    b = a[0]//2
    for i in range(n):
        if m >= abs(b-a[i]):
            m = abs(b-a[i])
            ans = a[i]
    print(a[0], ans)

else:
    b = a[0]//2 + 0.5
    for i in range(n):
        if m >= abs(b-a[i]):
            m = abs(b-a[i])
            ans = a[i]
    print(a[0], ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
m = a[0]
ans = a[0]
if a[0]%2 == 0:
    b = a[0]//2
    for i in range(n):
        if m >= abs(b-a[i]):
            m = abs(b-a[i])
            ans = a[i]
    print(a[0], ans)

else:
    b = a[0]//2 + 0.5
    for i in a:
        if m >= abs(b-a[i]):
            m = abs(b-a[i])
            ans = a[i]
    print(a[0], ans)
Problem p03394 (python)

Fixed submission:
n = int(input())

if n == 3:
    print(2, 5, 63)
elif n == 4:
    print(2, 5, 20, 63)
elif n == 5:
    print(2, 5, 20, 30, 63)
else:
    a = []
    count = 0
    for i in range(2, 30001):
        if i % 2 == 0 or i % 3 == 0:
            a.append(i)
            count += 1
        if count == n:
            break
    sum_a = sum(a)
    if sum_a % 6 == 0:
        print(*a)
    elif sum_a % 6 == 2:
        a[4] = 30000
        print(*a)
    elif sum_a % 6 == 3:
        a[5] = 30000
        print(*a)
    else:
        a[5] = 29998
        print(*a)

Buggy submission (verdict: Runtime Error):
n = int(input())

a = [-1 for i in range(n)]

a[0] = 1
a[1] = 3
a[2] = 2

if n <= 10000:
    for i in range(3, n):
        a[i] = (i-1) * 3
    print(*a)
else:
    if n<20000:
        for i in range(3, 10000):
            a[i] = (i - 1) * 3
        if n % 2 == 0:
            for i in range((n - 10000) // 2):
                a[10000 + 2 * i] = i * 6 + 4
                a[10000 + 2 * i + 1] = i * 6 + 8
        if n % 2 == 1:
            for i in range((n - 10000) // 2):
                a[10000 + 2 * i] = i * 6 + 4
                a[10000 + 2 * i + 1] = i * 6 + 8
            a[10000 + 2 * (((n - 10000) // 2) + 1)] = (((n - 10000) // 2) + 1) * 6 + 4
            a[3] = (((n - 10000) // 2) + 1) * 6 + 8
    else:
        for i in range(3, 10000):
            a[i] = (i - 1) * 3
        if n % 2 == 0:
            for i in range((n - 10000) // 2-1):
                a[10000 + 2 * i] = i * 6 + 4
                a[10000 + 2 * i + 1] = i * 6 + 8
            a[n-2] = 5
            a[n-1] = 7
    print(*a)
Problem p03415 (python)

Fixed submission:
c = []

for i in range(3):
    a = input()
    c.append(a[i])


print(c[0]+c[1]+c[2])

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

count = 0
for i in range(10):
    for j in range(10):
        for k in range(1, 10):
            num = i * 100 + j * 1010 + k * 10001
            if num >= a and num <= b:
                count += 1

print(count)
Problem p03423 (python)

Fixed submission:
n = int(input())

count = 0

if n <= 2:
    print(count)
else:
    while n >= 3:
        n -= 3
        count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())

s = input().split()
color = "Three"

for i in s:
    if i == "Y":
        color = "Four"
        break
print(color)
Problem p03469 (python)

Fixed submission:
s = input()

a = s[0:3] + "8" + s[4:]
print(a)

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

a = -1
b = -1
c = -1

for i in range(n+1):
    for j in range(n+1-i):
        if i*1000 + j*5000 + (n-i-j)*10000 == y:
            a, b, c = i, j, n-i-j
            break
print(c, b, a)
Problem p03565 (python)

Fixed submission:
s = input()
t = input()

ans = "UNRESTORABLE"

memo = -1

for i in range(len(s) - len(t) + 1):
    count = 0
    for j in range(len(t)):
        if s[i+j] == t[j] or s[i+j] == "?":
            count += 1
        else:
            break
        if count == len(t):
            ans = t
            memo = i

if ans == "UNRESTORABLE":
    print(ans)
else:
    ans1 = ""
    for word in s:
        if word == "?":
            ans1 += "a"
        else:
            ans1 += word
    ans2 = ans1[0:memo] + ans + ans1[memo+len(t):]
    print(ans2)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

ans = "UNRESTORABLE"

memo = -1

for i in range(len(s)):
    for j in range(len(t)):
        count = 0
        if s[i+j] == t[j] or t[j] == "?":
            count += 1
        else:
            count = 0
            break
        if count == len(t):
            ans = s[i:i+len(t)]
            memo = i
            count = 0

if ans == "UNRESTORABLE":
    print(ans)
else:
    ans1 = ""
    for word in t:
        if word == "?":
            ans1 += "a"
        else:
            ans1 += word
    ans1[memo:memo+len(t)] = ans
    print(ans1)