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

Fixed submission:

def resolve():
    N = int(input())
    
    K = 0
    for i in range(1, 1000):
        if (i*(i-1)//2 == N):
            K = i
            break

    if K == 0:
        print("No")
        return
    else:
        S = [[] for _ in range(K)]
        cnt = 1
        for i in range(K):
            for j in range(i+1, K):
                S[i].append(cnt)
                S[j].append(cnt)
                cnt += 1

    print("Yes")
    print(K)
    for s in S:
        print(len(s), *s)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):

def resolve():
    N = int(input())
    K = -1
    for i in range(1, N+1):
        if (i*(i-1)//2 == N):
            K = i
            break

    if K == -1:
        print("No")
        return
    else:
        S = [[0] * (K-1) for _ in range(K)]
        a = 1
        for i in range(K-1):
            for j in range(i, K-1):
                S[i][j] = a
                S[j+1][i] = a
                a += 1

    print("Yes")
    print(K)
    for s in S:
        print(len(s), *s)

if __name__ == "__main__":
    unittest.main()
Problem p03239 (python)

Fixed submission:
n, t = map(int, input().split())
w_dic = {}
for i in range(n):
  w, w_t = map(int, input().split())
  if w_t <= t:
    w_dic[i+1] = w
if w_dic:
  print(min(w_dic.values()))
else:
  print("TLE")

Buggy submission (verdict: Runtime Error):
n, t = map(int, input().split())
w_dic = {}
for i in range(n):
  w, w_t = map(int, input().split())
  if w_t < t:
    w_dic[i+1] = w
print(min(w_dic, key=w_dic.get))
Problem p03244 (python)

Fixed submission:
from collections import Counter

n = int(input())
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))

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

n = input()
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))
Problem p03325 (python)

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

count = 0
for num in arr:
  while num%2 == 0:
    num = num//2
    count += 1

print(count)

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

count = 0
for num in [a, b, c]:
  while num%2 == 0:
    num = num//2
    count += 1

print(count)
Problem p03352 (python)

Fixed submission:
x = int(input())
ans = [b**p for b in range(1001) for p in range(2,10)
      if b**p <= x]
print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for b in range(33):
  for p in range(2,10):
    if b**p > x:
      break
    ans = max(ans, b**p)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for b in range(1001):
  for p in range(2,10):
    if b**p > x:
      break
    ans = max(ans, b**p)
print(ans)
Problem p03386 (python)

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

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

pre_arr = [i for i in range(a, min(a+k, b+1))]
back_arr = [i for i in range(max(b-k+1, a), b+1)]
arr_slice = set(pre_arr) | set(back_arr)
[print(i) for i in sorted(arr_slice)]

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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

arr = sorted([i for i in range(a, b+1)])
arr_slice = set(arr[:k] | arr[-k:])
[print(i) for i in sorted(arr_slice)]
Problem p03415 (python)

Fixed submission:
s1 = input()
s2 = input()
s3 = input()
print(s1[0],s2[1],s3[2], sep="")

Buggy submission (verdict: Runtime Error):
s1 = input()
s2 = input()
s3 = input()
print(s1[0][0],s2[0][1],s3[0][2], sep="")s1 = input()
s2 = input()
s3 = input()
print(s1[0],s2[1],s3[2], sep="")

Buggy submission (verdict: Runtime Error):
s1 = input()
s2 = input()
s3 = input()
print(s1[0][0],s2[0][1],s3[0][2], sep="")

Buggy submission (verdict: Runtime Error):
s1 = input()
s2 = input()
s3 = input()
print(s1[0][0],s2[1][1],s3[2][2], sep="")
Problem p03448 (python)

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

A=int(input())
B=int(input())
C=int(input())
X=int(input())

ans = 0
for i in range(A+1):
  for j in range(B+1):
    if 0 <= (X - 500*i - 100*j) // 50 <= C:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

A=int(input())
B=int(input())
C=int(input())
X=int(input())

ans = 0
for i in range(A+1):
  for j in range(B+1):
    if 0 <= (x - 500*i - 100*j) // 50 <= C:
      ans += 1
print(ans)
Problem p03449 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = max(sum(a[:i+1]) + sum(b[i:]) for i in range(n))
print(ans)

Buggy submission (verdict: Runtime Error):
# dp
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]

dp = [[0]*(N) for _ in range(N)]
dp[0][0] = A[0][0]
dp[1][0] = A[0][0] + A[1][0]
for i in range(1, N):
  dp[0][i] = dp[0][i-1] + A[0][i]
  dp[1][i] = max(dp[0][i],dp[1][i-1]) + A[1][i]
  
print(dp[1][-1])
Problem p03472 (python)

Fixed submission:
from math import ceil

N, H = map(int, input().split())
sword = [[int(x) for x in input().split()] for _ in range(N)]

max_swing = max(sword, key=lambda x:x[0])[0]

attack = 0
# 投げで攻撃
for i in sorted(sword, key=lambda x: x[1], reverse=True):
  if max_swing < i[1]:
    H -= i[1]
    attack += 1
    if H <= 0:
      break
# 残りを振りで攻撃      
if 0 < H:
  attack += ceil(H / max_swing)
print(attack)

Buggy submission (verdict: Runtime Error):
# 振るのは最強のやつだけ
# 投げるのは強い順
 
N,H = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N)]
A,B = zip(*AB)
 
a = max(A) # 振る
B = [b for b in B if b > a] # 投げる価値あり
B.sort(reverse = True)

attack_cnt = 0
 
for b in B:
  if H <= 0:
    break
  attack_cnt += 1
  H -= b
  
if hp > 0:
  attack_cnt += (H-1)//a + 1
  
print(attack_cnt)
Problem p03644 (python)

Fixed submission:
N = int(input())

max_count = 0
for i in range(1, N+1):
  n = i
  count = 0
  while n > 0 and n % 2 == 0:
    n = n//2
    count += 1
  if count == max(max_count, count):
    res = i
    max_count = count
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
even_A = list(range(2, N+1, 2))
dic = {}
for a in even_A:
  x = a
  cnt = 0
  while x%2 == 0:
    x /= 2
    cnt += 1
  dic[a] = cnt

ans = sorted(dic.items(), key=lambda x:x[1])[-1]

print(ans[0])
Problem p03699 (python)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

total = sum(A)
if total%10 == 0:
  A.sort()
  for a in A:
    if a%10 != 0:
      total -= a
      break
  else: # 全部が10の倍数
    total = 0
print(total)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array([int(input()) for _ in range(N)])

total = A.sum()
if total%10 == 0:
  if np.any(A%10 != 0):
    total -= A[A%10 != 0].min():
  else:
    total = 0
print(total)
Problem p03722 (python)

Fixed submission:
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford
from scipy.sparse.csgraph import connected_components

N,M = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in range(M)]

row, col, val = zip(*ABC)
# -1倍しておいて最短路問題にする
val = [-(x) for x in val]
graph = csr_matrix((val,(row,col)),(N+1,N+1))

# 強連結成分に制限。ここに負閉路があればinf～
find_component_graph = csr_matrix(([1]*(M+1),(row+(N,),col+(1,))),(N+1,N+1))
# n = 個数、label=各頂点が属する連結成分のラベル[0,0,1,1,1]
n, labels = connected_components(find_component_graph,connection = 'strong')
idx = (labels == labels[1]) # [False, False, True~]
graph = graph[idx,:][:,idx]

try:
  dist = bellman_ford(graph,indices = [0])[0].astype(int)
  answer = -dist[-1]
except:
  answer = 'inf'

print(answer)

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford
from scipy.sparse.csgraph import connected_components

N,M = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in range(N)]

row, col, val = zip(*ABC)
# -1倍しておいて最短路問題にする
val = [-(x) for x in val]
graph = csr_matrix((val,(row,col)),(N+1,N+1))

# 強連結成分に制限。ここに負閉路があればinf～
find_component_graph = csr_matrix(([1]*(M+1),(row+(N,),col+(1,))),(N+1,N+1))
# n = 個数、label=各頂点が属する連結成分のラベル[0,0,1,1,1]
n, labels = connected_components(find_component_graph,connection = 'strong')
idx = (labels == labels[1]) # [False, False, True~]
graph = graph[idx,:][:,idx]

try:
  dist = bellman_ford(graph,indices = [0])[0].astype(int)
  answer = -dist[-1]
except:
  answer = 'inf'

print(answer)
Problem p03760 (python)

Fixed submission:
o=list(input())
e=list(input())+[""]
for x,y in zip(o,e):print(x+y,end="")

Buggy submission (verdict: Runtime Error):
s1 = input()
s2 = input()
password = ''.join([i,j for i, j in zip(s1, s2)])
print(password)
Problem p03796 (python)

Fixed submission:
import math
n = int(input())
ans = math.factorial(n) % (10**9+7)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
ans = math.factorial(n) % (1e9+7)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
print(math.factorial(n) % (1e9+7))
Problem p03998 (python)

Fixed submission:
dic_S = {c: list(input()) for c in "abc"}
s = "a"
while dic_S[s]:
  s = dic_S[s].pop(0)
print(s.upper())

Buggy submission (verdict: Runtime Error):
dic_S = {c: list(input()) for c in "abc"}
s = "a"
while dic_S[s]:
  s = S[s].pop(0)
print(s.upper())
Problem p04013 (python)

Fixed submission:
N, A = map(int, input().split())
X = list(map(int, input().split()))
sum_X = sum(X)
dp = [[[0]*(sum_X+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
  for j in range(N):
    for k in range(sum_X):
      if dp[i][j][k] == 0: continue
      # not used
      dp[i+1][j][k] += dp[i][j][k]
      # used
      dp[i+1][j+1][k+X[i]] += dp[i][j][k]
ans = 0
for k in range(1, N+1):
  if k*A <= sum_X:
    ans += dp[N][k][k*A]
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, A = map(int, input().split())
X = list(map(int, input().split()))
sum_X = sum(X)
dp = np.zeros((N+1, N+1, sum_X+1), np.int64)
dp[0][0][0] = 1
for i in range(N):
  for j in range(N):
    for k in range(sum_X):
      if dp[i][j][k] == 0: continue
      # not used
      dp[i+1][j][k] += dp[i][j][k]
      # used
      dp[i+1][j+1][k+X[i]] += dp[i][j][k]
ans = 0
for i in range(1, N+1):
  ans += dp[N][i][i*A]
print(ans)
Problem p04045 (python)

Fixed submission:
from itertools import product

N, K = map(int, input().split())
D = map(int, input().split())
like_num = set(range(10)) ^ set(D)
length = len(str(N))

for i in range(length, length+2):
  for x in product(like_num,repeat=i):
        d=''.join(map(str,x))
        if int(d)>=N:
          print(d)
          exit()

Buggy submission (verdict: Runtime Error):
import bisect
from itertools import product

N, K = map(int, input().split())
D = map(int, input().split())
like_num = set(range(0,10)) ^ set(D)
length = len(str(N))
comb = [int("".join(map(str, a))) for a in product(like_num, repeat=length)]
ind = bisect.bisect_left(comb, N)
print(comb[ind])
Problem p02675 (python)

Fixed submission:
x = str(input())

if x[-1] == '3':
    print('bon')
elif x[-1] == '0' or x[-1] == '1' or x[-1] == '6' or x[-1] == '8':
    print('pon')
else:
    print('hon')

Buggy submission (verdict: Runtime Error):
x = int(input())
if x[-1] == 3:
  print('bon')
elif x[-1] == 0 or x[-1] == 1 or x[-1] == 6 or x[-1] == 8:
  print('pon')
else:
  print('hon')
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3 * r * r)

Buggy submission (verdict: Runtime Error):
r = int(intput())
print(3 * r * r)
Problem p03076 (python)

Fixed submission:
li = list()
li2 = list()
for _ in range(5):
    tmp = int(input())
    if(tmp % 10 == 0):
        li2.append(tmp)
    else:
        li.append(tmp)
li.sort(key=lambda x: x % 10, reverse=True)
li2.sort()
ans = sum(li2)
if(len(li)!=0):
    for i in range(len(li)-1):
        ans = ans + ((li[i] // 10 + 1) * 10)
    ans += li[-1]
print(ans)

Buggy submission (verdict: Runtime Error):
li = list()
li2 = list()
for _ in range(5):
    tmp = int(input())
    if(tmp % 10 == 0):
        li2.append(tmp)
    else:
        li.append(tmp)
li.sort(key=lambda x: x % 10, reverse=True)
li2.sort()
ans = sum(li2)
for i in range(len(li)-1):
    ans = ans + ((li[i] // 10 + 1) * 10)
ans += li[-1]
print(ans)
Problem p03239 (python)

Fixed submission:
n, t = map(int, input().split())
minCost = 1001
for i in range(n):
    cc, tt = map(int, input().split())
    if tt <= t and cc < minCost:
        minCost = cc
if minCost == 1001:
    print('TLE')
else:
    print(minCost)

Buggy submission (verdict: Runtime Error):
n, t = map(int, input().split())
minCost = 1001
for i range in n:
    cc, tt = map(int, input().split())
    if tt <= t and cc < minCost:
        minCost = cc
if minCost == 1001:
    print('TLE')
else:
    print(minCost)
Problem p03351 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
if abs(a - c) <= d:
	print('Yes')
else:
	if abs(a - b) <= d and abs(c - b) <= d:
		print('Yes')
	else:
		print('No')

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input()split())
if abs(a - c) <= d:
	print('Yes')
else:
	if abs(a - b) <= d and abs(c - b) <= d:
		print('Yes')
	else:
		print('No')
Problem p03477 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
if a + b > c + d:
	print('Left')
elif a + b < c + d:
	print('Right')
else:
	print('Balanced')

Buggy submission (verdict: Runtime Error):
1 7 6 4
Problem p03605 (python)

Fixed submission:
n = input()
if '9' in n:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
n = list(map(str, input().split()))
if n in '9':
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
if n in '9':
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
n = list(input().split())
if n in '9':
	print('Yes')
else:
	print('No')
Problem p03943 (python)

Fixed submission:
li = list(map(int, input().split()))
li.sort()
if li[0] + li[1] == li[2]:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
li = map(int, input().split())
li.sort()
if li[0] + li[1] == li[2]:
	print('Yes')
else:
	print('No')
Problem p02684 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math


def get_input() -> tuple:
    """
    標準入力の取得

    Returns:\n
        tuple: 標準入力
    """
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    return N, K, A


def main(N: int, K: int, A: list) -> None:
    """
    求解処理.

    Args:
        N (int): 町の数
        K (int): テレポーターの使用回数
        A (list): テレポーターの転送先
    """
    # タブリング表の作成
    to = [A]
    for i in range(math.ceil(math.log2(K))):
        to_i = to[i]
        to_next = []
        for j in range(N):
            to_next.append(to_i[to_i[j]-1])

        to.append(to_next)

    result = 1
    for i in range(math.ceil(math.log2(K))):
        if ((K >> i) & 1):
            result = to[i][result-1]

    print(result)


if __name__ == "__main__":
    N, K, A = get_input()
    main(N, K, A)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# モジュールのインポート
import math


def get_input() -> tuple:
    """
    標準入力の取得

    Returns:\n
        tuple: 標準入力
    """
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    return N, K, A


def main(N: int, K: int, A: list) -> None:
    """
    求解処理.

    Args:
        N (int): 町の数
        K (int): テレポーターの使用回数
        A (list): テレポーターの転送先
    """
    # タブリング表の作成
    to = [A]
    for i in range(math.ceil(math.log2(K))):
        to_i = to[i]
        to_next = []
        # 使用する場合のみ、要素を入れておく
        if ((K >> i) & 1):
            for j in range(N):
                to_next.append(to_i[to_i[j]-1])

        to.append(to_next)

    result = 1
    for i in range(math.ceil(math.log2(K))):
        if ((K >> i) & 1):
            result = to[i][result-1]

    print(result)


if __name__ == "__main__":
    N, K, A = get_input()
    main(N, K, A)
Problem p02690 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# モジュールのインポート
import itertools

# 標準入力の取得
X = int(input())

# 求解処理


def get_value(A: int, B: int) -> int:
    return A**5 - B**5


A_min, A_max = -118, 119
B_min, B_max = -119, 118
result = ""
for A, B in itertools.product(range(A_min, A_max+1), range(B_min, B_max+1)):
    value = get_value(A, B)
    if value == X:
        result = f"{A} {B}"
        break

# 結果出力
print(result)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 標準入力の取得
X = int(input())

# 求解処理
A = 0
while True:
    B = -1*(X-A**5)**(1/5)
    if B.is_integer():
        break
    A += 1

result = f"{int(A)} {int(B)}"

# 結果出力
print(result)
Problem p02861 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import itertools

# 標準入力を取得
N = int(input())
x, y = [], []
for n in range(N):
    x_n, y_n = list(map(int, input().split()))
    x.append(x_n)
    y.append(y_n)


def get_distance(i: int, j: int) -> float:
    return math.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)


def get_path_length(distance: dict, path: list) -> float:
    path_length = 0
    for n in range(N - 1):
        path_length += distance[(path[n], path[n + 1])]

    return path_length


# 求解処理
distance = {}
for i, j in itertools.product(range(N), range(N)):
    distance[(i, j)] = get_distance(i, j)

ans = 0
for path in itertools.permutations(range(N)):
    ans += get_path_length(distance, path)
ans /= math.factorial(N)

# 結果出力
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import itertools


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力を取得
    """
    N = int(input())
    x, y = [], []
    for n in range(N):
        x_n, y_n = list(map(int, input().split()))
        x.append(x_n)
        y.append(y_n)

    return N, x, y


def get_distance(x: list, y: list, i: int, j: int) -> float:
    """
    町iと町jの間の距離を取得する.

    Args:\n
        x (list): 町のx座標
        y (list): 町のy座標
        i (int): 町
        j (int): 町

    Returns:\n
        float: 町iと町jの間の距離
    """
    return math.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)


def get_path_length(N: int, distance: dict, path: list) -> float:
    """
    経路の長さを求める.

    Args:\n
        N (int): 町の数
        distance (dict): 町間の距離
        path (list): 経路

    Returns:\n
        float: 経路の長さ
    """
    path_length = 0
    for n in range(N - 1):
        path_length += distance[(path[n], path[n + 1])]

    return path_length


def main(N: int, x: list, y: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 町の数
        x (list): 町のx座標
        y (list): 町のy座標
    """
    # 事前に町間の距離情報を作っておく
    distance = {}
    for i, j in itertools.product(range(N), repeat=2):
        distance[(i, j)] = get_distance(i, j)

    # 求解処理
    ans = 0
    for path in itertools.permutations(range(N)):
        ans += get_path_length(distance, path)
    ans /= math.factorial(N)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, x, y = get_input()

    # メイン処理
    main(N, x, y)
Problem p02995 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# モジュールのインポート
from fractions import gcd

# 標準入力の取得
A, B, C, D = list(map(int, input().split()))


def lcm(x: int, y: int) -> int:
    return (x * y) // gcd(x, y)


# 求解処理
div_C = (B // C) - ((A - 1) // C)
div_D = (B // D) - ((A - 1) // D)
lcm_CD = lcm(C, D)
div_lcm_CD = (B // lcm_CD) - ((A - 1) // lcm_CD)
result = (B - A + 1) - div_C - div_D + div_lcm_CD

# 結果出力
print(result)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力の取得
A, B, C, D = list(map(int, input().split()))


def lcm(x: int, y: int) -> int:
    return (x * y) // math.gcd(x, y)


# 求解処理
div_C = (B // C) - ((A - 1) // C)
div_D = (B // D) - ((A - 1) // D)
lcm_CD = lcm(C, D)
div_lcm_CD = (B // lcm_CD) - ((A - 1) // lcm_CD)
result = (B - A + 1) - div_C - div_D + div_lcm_CD

# 結果出力
print(result)
Problem p03281 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())

# 求解処理
ans = 0
for n in range(1, N + 1, 2):
    divisors_count = 0
    for i in range(1, n + 1):
        if n % i == 0:
            divisors_count += 1
    if divisors_count == 8:
        ans += 1

# 結果出力
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# モジュールのインポート
import sympy as sp

# 標準入力を取得
N = int(input())

# 求解処理
ans = 0
for n in range(1, N + 1, 2):
    if sp.divisor_count(n) == 8:
        ans += 1

# 結果出力
print(ans)
Problem p03471 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# C - Otoshidama
# モジュールのインポート
import sys

# 定数の定義
YEN_10000 = 10000
YEN_5000 = 5000
YEN_1000 = 1000

# 標準入力の取得
N,Y = list(map(int, input().split()))

# 探索処理
is_correct = False
for n_10000 in range(N+1):
    for n_5000 in range(N+1-n_10000):
        n_1000 = N - n_10000 - n_5000
        amount = YEN_10000*n_10000 + YEN_5000*n_5000 + YEN_1000*n_1000
        if amount == Y:
            is_correct = True
            print(n_10000, n_5000, n_1000)
            sys.exit()

if not is_correct:
    print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# D - katana Thrower
# モジュールのインポート
import math

# 標準入力の取得
N,H = list(map(int, input().split()))
a,b = [],[]
for n in range(N):
    a_n,b_n = list(map(int, input().split()))
    a.append(a_n)
    b.append(b_n)

# 求解処理
"""
    すでに投げてしまった刀も振ることはできるとしても答えは変わらない。
    以下の攻撃手順を行う：
    0. a_1, a_2, ・・・, a_Nのうち最大値をa_maxとし、攻撃力がa_max以上の投げ刀を「強い投げ刀」とする。
    1. 強い投げ刀を攻撃力が高い順に投げていく。
    2. 強い投げ刀を使い果たしたら、攻撃力a_maxの振り刀を振り続ける。
"""
max_a = max(a)
sorted_b = reversed(sorted(b))
min_count = 0
for b_n in sorted_b:
    if (b_n < max_a) or (H <= 0):
        break
    H -= b_n
    min_count += 1

if H > 0:
    min_count += math.ceil(H / max_a)

# 結果出力
print(min_count)
Problem p02555 (python)

Fixed submission:
def main(S_: int):
    MOD = int(10**9+7)
    dp = [0] * 2001
    for s in range(3, S_+1):
        dp[s] = 1 #1分割はできる
        for r in range(3, s):
            dp[s] += dp[s-r]
            dp[s] %= MOD

    return dp[S_] % MOD


if __name__ == '__main__':
    S = int(input())
    ans = main(S)
    print(ans)

Buggy submission (verdict: Runtime Error):
#import numpy as np
#from collections import Counter
#import sys
#sys.setrecursionlimit(10000000)

def main(S_: int):
    MOD = int(10**9+7)
    dp = []
    for _ in range(2002):
        dp.append([0]*2002)
    #dp = np.full((2001, 2001), 0)
    # dp[s][p] = sをp通りに分割する方法
    dp[1][1] = 0
    dp[2][1] = 0
    #print(dp)
    for s in range(3, S+1):
        dp[s][1] = 1
        if s % 3 == 0:
            dp[s][s//3] = 1
        for r in range(2, (s//3)+1):  #s//3個までは分割可能
            #print(f's,r={s},{r}')
            #例えば
            # dp[8,2] = dp[5,1] + dp[4,1]+ dp[3,1] + ...
            # dp[11,3] = dp[8,2] + dp[7,2] + dp[6, 2] + dp[5,2] + ...
            for i in range(s-3+1):
                dp[s][r] += dp[i][r-1]
                dp[s][r] %= MOD
            #dp[s][r] = dp[:s-3+1, r-1].sum() % MOD
            
    for i in range(15):
        #print(dp[i][:15])
    ans = 0
    for i in range(len(dp[0])):
        ans += dp[S_][i]
        ans %= MOD
    return ans % MOD


if __name__ == '__main__':
    S = int(input())
    ans = main(S)
    print(ans)