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

Fixed submission:
N = 0
numbers = []

N = int(input())
numbers = [1/int(i) for i in input().split()]

print(1/sum(numbers))

Buggy submission (verdict: Runtime Error):
N = 0
numbers = array()

N = int(input())
numbers = input().split()
numbers = [1/int(i) for i in numbers]

print(1/sum(numbers))

Buggy submission (verdict: Runtime Error):
N = 0
numbers = array()

N = int(input())
numbers = [1/int(i) for i in input().split()]

print(1/sum(numbers))

Buggy submission (verdict: Runtime Error):
N = 0
numbers = array()

N = int(input())
numbers = [1/int(i) for i in input().split()]

print(sum(numbers))
Problem p02952 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n + 1):
	if len(str(i)) % 2 == 1:
		ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(1,n + 1):
	if len(int(i)) % 2 == 1:
		ans += 1
print(ans)
Problem p02936 (python)

Fixed submission:
import collections
N, Q = map(int, input().split())
counts = [0] * (N + 1)
T = [[] for _ in range(N + 1)]
for _ in range(N-1):
  a, b = map(int, input().split())
  T[a].append(b)
  T[b].append(a)
for _ in range(Q):
  p, x = map(int, input().split())
  counts[p] += x
visited = [0] * (N + 1)
queue = collections.deque()
queue.append(1)
while queue:
  v = queue.pop()
  visited[v] = 1
  x = counts[v]
  for child in T[v]:
    if visited[child] == 1:
      continue
    counts[child] += x
    queue.append(child)
print(*counts[1:])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
def add_to_subtree(tree, result_arr, idx, value):
  result_arr[idx] += value
  if len(tree[idx]) == 0:
    return
  for child in tree[idx]:
    add_to_subtree(tree, result_arr, child, value)

N, Q = map(int, input().split())
R = [0] * (N + 1)
T = [[] for _ in range(N + 1)]

for _ in range(N-1):
  a, b = sorted(map(int, input().split()))
  T[a].append(b)
for _ in range(Q):
  P, X = map(int, input().split())
  add_to_subtree(T, R, P, X)

print(*R[1:])

Buggy submission (verdict: Runtime Error):
def add_to_subtree(tree, result_arr, idx, value):
  result_arr[idx] += value
  if len(tree[idx]) == 0:
    return
  for child in tree[idx]:
    add_to_subtree(tree, result_arr, child, value)

N, Q = map(int, input().split())
R = [0] * (N + 1)
T = [[] for _ in range(N + 1)]

for _ in range(N-1):
  a, b = sorted(map(int, input().split()))
  T[a].append(b)
for _ in range(Q):
  P, X = map(int, input().split())
  add_to_subtree(T, R, P, X)

print(*R[1:])

Buggy submission (verdict: Runtime Error):
def add_to_subtree(tree, result_arr, idx, value):
  result_arr[idx] += value
  if len(tree[idx]) == 0:
    return
  for child in tree[idx]:
    add_to_subtree(tree, result_arr, child, value)

N, Q = map(int, input().split())
T = [[] for i in range(N + 1)]
R = [0] * (N + 1)
for _ in range(N-1):
  a, b = map(int, input().split())
  T[a].append(b)
for _ in range(Q):
  P, X = map(int, input().split())
  add_to_subtree(T, R, P, X)

print(" ".join(map(str, R[1:])))
Problem p02937 (python)

Fixed submission:
import bisect

def ctoi(char):
  return ord(char) - 97


#素材
ingredients = input()
ingredients_len = len(ingredients)
#つくりたいもの
recipe = input()
recipe_len = len(recipe)

alphabets = [[] for _ in range(26)]

# 素材のアルファベット分布リストをつくる
for i in range(ingredients_len):
  alpha_idx = ctoi(ingredients[i])
  alphabets[alpha_idx].append(i)

ingredients_counter = [0] * 26
for i in range(26):
  ingredients_counter[i] = len(alphabets[i])
  
ingredients_idx_list = []
flag = True
ingredients_pointer = -1

for i in range(recipe_len):
  alpha_idx = ctoi(recipe[i])
  if ingredients_counter[alpha_idx] == 0:
    flag = False
    break
  #今のingredients_pointerより右側に使える素材があるか探す
  pointer_candidate_idx = bisect.bisect_right(alphabets[alpha_idx], ingredients_pointer)
  #右側に無かった。ループして先頭のを使ってどうぞ
  if pointer_candidate_idx == ingredients_counter[alpha_idx]:
    ingredients_pointer = alphabets[alpha_idx][0]
  else:
    ingredients_pointer = alphabets[alpha_idx][pointer_candidate_idx]
  ingredients_idx_list.append(ingredients_pointer)

if flag == False:
  print(-1)
else: 
  loop = 0
  idx = ingredients_idx_list[0]
  #idxのリセット分ループを数える。左より右が小さかったらループ
  for i in range(1, recipe_len):
    if ingredients_idx_list[i] <= idx:
      loop += 1
    idx = ingredients_idx_list[i]
  # ループx素材の長さ + つくりたいものの最後の文字のインデックス(に、+１)
  print(loop * len(ingredients) + ingredients_idx_list[-1] + 1)

Buggy submission (verdict: Runtime Error):
import bisect

def ctoi(char):
  return ord(char) - 97

alphabets = [[] for _ in range(26)]

#素材
ingredients = input()
#つくりたいもの
recipe = input()

# 素材のアルファベット分布リストをつくる
for i in range(len(ingredients)):
  alpha_idx = ctoi(ingredients[i])
  alphabets[alpha_idx].append(i)

ingredients_counter = [0] * 26
for i in range(26):
  ingredients_counter[i] = len(alphabets[i])
ingredients_pointer = -1
ingredients_idx_list = []
flag = True
for i in range(len(recipe)):
  alpha_idx = ctoi(recipe[i])
  if ingredients_counter[alpha_idx] == 0:
    flag = False
    break
  #今のingredients_pointerより右側に使える素材があるか探す
  pointer_candidate_idx = \
  	bisect.bisect_right(alphabets[alpha_idx], ingredients_pointer)
  #右側に無かった。ループして先頭のを使ってどうぞ
  if pointer_candidate_idx == ingredientx_counter[alpha_idx]:
    ingredients_pointer = alphabets[alpha_idx][0]
  else:
    ingredients_pointer = alphabets[alpha_idx][pointer_candidate_idx]
  ingredients_idx_list.append(ingredients_pointer)

if flag == False:
  print(-1)
else: 
  loop = 0
  idx = ingredients_idx_list[0]
  #idxのリセット分ループを数える。左より右が小さかったらループ
  for i in range(1, len(ingredients_idx_list)):
    if ingredients_idx_list[i] < idx:
      loop += 1
    idx = ingredients_idx_list[i]
  # ループx素材の長さ + つくりたいものの最後の文字のインデックス(に、+１)
  print(loop * len(ingredients) + ingredients_idx_list[-1] + 1)
Problem p02945 (python)

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

print(sorted([A+B, A-B, A*B], reverse=True)[0])

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

print(max[A+B, A-B, A*B])
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
print(max(a+b, a-b, a*b))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A-B < A+B and A*B < A+B:
  print(A+B)
elif A+B < A-B and A*B < A-B:
  print(A-B)
else:
  print(A*B)
Problem p02957 (python)

Fixed submission:
a, b = map(int, input().split())
if (a+b)%2 == 0:
  print((a+b)//2)
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a+b)% == 0:
  print((a+b)//2)
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a+b)% == 0:
  print((a+b)/2)
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
a,b = map(int, input())
if k = (a+b)/2:
  print(k)
else:
  print('impossible')
Problem p02981 (python)

Fixed submission:
n, a, b= map(int, input().split())
if b < n*a:
  print(b)
else:
  print(n*a)

Buggy submission (verdict: Runtime Error):
n, a, b= map(int, input().split())
if b < na:
  print(b)
else:
  print(na)
Problem p03071 (python)

Fixed submission:
a,b = map(int, input().split())
print(max([2*a-1, a+b, 2*b-1]))

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
print(max([2*a-1, a+b, 2*b-1])
Problem p03101 (python)

Fixed submission:
H,W = map(int, input().split())
h,w = map(int, input().split())
print(H*W-h*W-H*w+h*w)

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())
h,w = map(int, input().split())
print(HW-hW-Hw+hw)
Problem p03109 (python)

Fixed submission:
a = int("".join(input().split("/")))
if a <= 20190430:
  print("Heisei")
else:
  print("TBD")

Buggy submission (verdict: Runtime Error):
a = int("".join(input().split("/"))))
if a <= 20190430:
  print("Heisei")
else:
  print("TBD")
Problem p03280 (python)

Fixed submission:
A,B = map(int,input().split())
S = (A-1)*(B-1)
print(S)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
print((A-1)*(B-1))
Problem p03323 (python)

Fixed submission:
#入力
A,B = map(int, input().split())
 
if A>8 or B>8:
    print(":(")
elif A<=8 and B<=8:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
#入力
A = int(input())
B = int(input())

if A>8 or B>8:
    print(":(")
elif A<=8 and B<=8:
    print("Yay!")
Problem p03633 (python)

Fixed submission:
#最大公約数を求める
def gcd(a,b):
    #a>bとなるように入れ替え
    if a < b:
        tmp = a
        a = b
        b = tmp
    
    #ユークリッドの互除法
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    
    return b

#最小公倍数を求める
def lcm(a,b):
    return int((a*b)//gcd(a,b))

#入力
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

#Tのリストの2数のlcmを求めて範囲を広げていく
tmp_lcm = 1 #現在の範囲までのlcm
for i in range(N):
    tmp_lcm = lcm(tmp_lcm,T[i])

print(tmp_lcm)

Buggy submission (verdict: Runtime Error):
#最大公約数を求める
def gcd(a,b):
    #a>bとなるように入れ替え
    if a < b:
        tmp = a
        a = b
        b = tmp
    
    #ユークリッドの互除法
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    
    return b

#最小公倍数を求める
def lcm(a,b):
    return int((a*b)/gcd(a,b))

#入力
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

#Tのリストの2数のlcmを求めて範囲を広げていく
tmp_lcm = 1 #現在の範囲までのlcm
for i in range(N):
    tmp_lcm = lcm(tmp_lcm,T[i])

print(tmp_lcm)
Problem p03037 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n,m = input().split()
n = int(n)
m = int(m)
l = 0
r = n+1
for i in range(m):
    l2,r2 = input().split()
    l2 = int(l2)
    r2 = int(r2)
    if l2 > l:
        l = l2
    if r2 < r:
        r = r2
if (r - l + 1) >= 0:
    print(r-l+1)
else:
    print("0")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m = input().split()
n = int(n)
m = int(m)
l = 0
r = n+1
a = input().split()
for i in range(m):
    l2,r2 = input().split()
    l2 = int(l2)
    r2 = int(r2)
    if l2 > l:
        l = l2
    if r2 < r:
        r = r2
if (r - l + 1) >= 0:
    print(r-l+1)
else:
    print("0")
Problem p03076 (python)

Fixed submission:
import sys
input = sys.stdin.readline
a = [0,0,0,0,0]
b = [[0,i] for i in range(5)]
for i in range(5):
    a[i] = int(input())
    b[i][0] = a[i] % 10
b.sort()
j = 0
while j < 5 and b[j][0] == 0:
    j += 1
time = 0
if j == 5:
    for i in range(5):
        time += a[i]
else:
    for i in range(5):
        if i != b[j][1]:
            if a[i] % 10 == 0:
                time += a[i]
            else:
                time += (a[i] + (10 - a[i] % 10))
    time += a[b[j][1]]
print(time)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
a = [0,0,0,0,0]
b = [[0,i] for i in range(5)]
for i in range(5):
    a[i] = int(input())
    b[i][0] = a[i] % 10
b.sort()
j = 0
while b[j][0] == 0:
    j += 1
time = 0
for i in range(5):
    if i != b[j][1]:
        if a[i] % 10 == 0:
            time += a[i]
        else:
            time += (a[i] + (10 - a[i] % 10))
time += a[b[j][1]]
print(time)
Problem p03280 (python)

Fixed submission:
a,b = input().split()
c = (int(a)-1) * (int(b)-1)
print(c)

Buggy submission (verdict: Runtime Error):
n,m,q = input().split()
list = []
for i in range(int(m)):
    l,r = input().split()
    list.append([int(l),int(r)])
for i in range(int(q)):
    p,q = input().split()
    count = 0
    for j in range(len(list)):
        if int(p) <= list[j][0] and int(q) >= list[j][1]:
            count += 1
    print(count)
Problem p03282 (python)

Fixed submission:
s = input()
k = input()
nlen = 0
i = 0
if s[i] != "1":
    print(s[i])
else:
    while s[i] == "1":
        if nlen == (int(k)-1):
            break
        i += 1
        nlen += 1
    print(s[i])

Buggy submission (verdict: Runtime Error):
s = input()
k = input()
M = 5000000000000000
nlen = 0
i = 0
if s[i] != "1":
    print(s[i])
else:
    while s[i] == "1":
        i += 1
        nlen += 1
        if nlen == (int(k)-1):
            break
    print(s[i])

Buggy submission (verdict: Runtime Error):
s = input()
k = input()
M = 5000000000000000
nlen = 0
i = 0
if s[i] != "1":
    print(s[i])
else:
    while s[i] == "1":
        i += 1
        nlen += 1
        if nlen == int(k):
            break
    print(s[i])
Problem p02995 (python)

Fixed submission:
import math
# 最大公約数gcd, 
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

# 最小公倍数lcm
def lcm(a, b):
    return (a*b) // gcd(a,b)

a, b, c, d = (int(i) for i in input().split())

cd = lcm(c,d)
r = b-a+1

min_c = a//c + (1 if a%c!=0 else 0)
max_c = b//c
min_d = a//d + (1 if a%d!=0 else 0)
max_d = b//d
min_cd = a//cd + (1 if a%cd!=0 else 0)
max_cd = b//cd

c_num = max_c-min_c+1
d_num = max_d-min_d+1
cd_num = max_cd-min_cd+1

print(r-c_num-d_num+cd_num)

Buggy submission (verdict: Runtime Error):
# 最大公約数gcd, 
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

# 最小公倍数lcm
def lcm(a, b):
    return (a*b) // gcd(a,b)

a, b, c, d = (int(i) for i in input().split())

cd = lcm(c,d)
r = b-a+1

min_c = math.ceil(a/c)
max_c = math.floor(b/c)
min_d = math.ceil(a/d)
max_d = math.floor(b/d)
min_cd = math.ceil(a/cd)
max_cd = math.floor(b/cd)

c_num = max_c-min_c+1
d_num = max_d-min_d+1
cd_num = max_cd-min_cd+1

print(r-c_num-d_num+cd_num)

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = (int(i) for i in input().split())

cd = c*d // math.gcd(c,d)
r = b-a+1

min_c = math.ceil(a/c)
max_c = math.floor(b/c)
min_d = math.ceil(a/d)
max_d = math.floor(b/d)
min_cd = math.ceil(a/cd)
max_cd = math.floor(b/cd)

c_num = max_c-min_c+1
d_num = max_d-min_d+1
cd_num = max_cd-min_cd+1

print(r-c_num-d_num+cd_num)
Problem p03001 (python)

Fixed submission:
W,H,x,y = (int(i) for i in input().split())

is_double = 0
if x == W/2 and y == H/2:
    is_double = 1

print("{} {}".format(H*W/2,is_double))

Buggy submission (verdict: Runtime Error):
W,H,x,y = (int(i) for i in input().split())

is_double = 0
if x == W/2 and y == H/2:
    is_double = 1

res = min(x*H,(W-x)*H)
res2 = min((H-y)*W,y*W)

print("{} {}".format(max([res,res2,res3]),is_double))

Buggy submission (verdict: Runtime Error):
W,H,x,y = (int(i) for i in input().split())

is_double = 0
if x == W//2 and y == H//2:
    is_double = 1

if x>=W//2:
    res = (W-x)*H
else:
    res = x*H

if y>=H//2:
    res2 = (H-y)*W
else:
    res2 = y*W

if x==y*W/H or x==(H-y)*W/H:
    res3 = H*W/2

print("{} {}".format(max([res,res2,res3]),is_double))
Problem p03007 (python)

Fixed submission:
n = int(input())
a = sorted([int(i) for i in input().split()])

if n == 2:
    print(a[1] - a[0])
    print("{} {}".format(a[1], a[0]))
    exit()

if a[0] <= 0 and 0 <= a[-1]:
    import bisect
    print(sum(map(lambda x: abs(x), a)))
    x0 = bisect.bisect_left(a,0)

    # 0以下から0以上をひいていく（一番大きいものを除く）
    if a[-2] >= 0:
        if x0 == 0:
            x0 += 1
        print("{} {}".format(a[0], a[x0]))
        res = a[0] - a[x0]

        for x in a[x0+1:-1]:
            print("{} {}".format(res, x))
            res -= x
    else:
        res = a[0]

    # 一番大きいものから上のものと負の数を引いていく
    print("{} {}".format(a[-1], res))
    res = a[-1] - res
    for x in a[1:x0]:
        print("{} {}".format(res,x))
        res -= x

elif a[0] > 0:
    print(sum(a) - 2*a[0])

    print("{} {}".format(a[0],a[1]))
    res = a[0] - a[1]
    for x in a[2:-1]:
        print("{} {}".format(res, x))
        res -= x
    
    print("{} {}".format(a[-1], res))
else:
    print(-sum(a) + 2*a[-1])

    print("{} {}".format(a[-1],a[-2]))
    res = a[-1] - a[-2]
    for x in a[:-2]:
        print("{} {}".format(res, x))
        res -= x

Buggy submission (verdict: Runtime Error):
n = int(input())
a = sorted([int(i) for i in input().split()])

if a[0] <= 0 and 0 < a[-1]:
    import bisect
    print(sum(map(lambda x: abs(x), a)))
    x0 = bisect.bisect_left(a,0)

    # 0以下から正をひいていく（一番大きいものを除く）
    print("{} {}".format(a[0], a[x0-1]))
    res = a[0] - a[x0+1]

    for x in a[x0+1:-2]:
        print("{} {}".format(res, x))
        res -= x

    # 一番大きいものから上のものと負の数を引いていく
    print("{} {}".format(a[-1], res))
    res = a[-1] - res
    for x in a[1:x0]:
        print("{} {}".format(res,x))
        res -= x

elif a[0] > 0:
    print(sum(a) - 2*a[0])

    print("{} {}".format(a[0],a[1]))
    res = a[0] - a[1]
    for x in a[2:-2]:
        print("{} {}".format(res, x))
        res -= x
    
    print("{} {}".format(a[-1], res))
else:
    print(-sum(a) + 2*a[-1])

    print("{} {}".format(a[-1],a[-2]))
    res = a[-1] - a[-2]
    for x in a[:-2]:
        print("{} {}".format(res, x))
        res -= x
Problem p03026 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(11000)

n = int(input())
ab = [[ (int(i)-1) for i in input().split()] for i in range(n-1)]
c = sorted([int(i) for i in input().split()], reverse=True)

if n==1:
    print(0)
    print(c[0])
    exit()

dic = {}
for i in range(n):
    dic[i] = []

cnt = [0]*n
for a,b in ab:
    dic[a].append(b)
    dic[b].append(a)
    cnt[a] += 1
    cnt[b] += 1

c_idx = 0
res = 0
res_arr = [""]*n
used = [0]*n
def f(idx):
    global c_idx, res, used
    used[idx] = 1
    res_arr[idx] = str(c[c_idx])
    for x in dic[idx]:
        if used[x] == 0:
            c_idx += 1
            res += c[c_idx]
            f(x)

f(cnt.index(1))
print(res)
print(" ".join(res_arr))

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

n = int(input())
ab = [[ (int(i)-1) for i in input().split()] for i in range(n-1)]
c = sorted([int(i) for i in input().split()], reverse=True)

if n==1:
    print(0)
    print(c[0])
    exit()
    
dic = {}
for i in range(n):
    dic[i] = []

cnt = [0]*n
for a,b in ab:
    dic[a].append(b)
    dic[b].append(a)
    cnt[a] += 1
    cnt[b] += 1

c_idx = 0
res = 0
res_arr = [""]*n
used = [0]*n
def f(idx):
    global c_idx, res, used
    used[idx] = 1
    res_arr[idx] = str(c[c_idx])
    for x in dic[idx]:
        if used[x] == 0:
            c_idx += 1
            res += c[c_idx]
            f(x)

f(cnt.index(1))
print(res)
print(" ".join(res_arr))

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

n = int(input())
ab = [[ (int(i)-1) for i in input().split()] for i in range(n-1)]
c = sorted([int(i) for i in input().split()], reverse=True)

dic = {}
for i in range(n):
    dic[i] = []

cnt = [0]*n
for a,b in ab:
    dic[a].append(b)
    dic[b].append(a)
    cnt[a] += 1
    cnt[b] += 1

c_idx = 0
res = 0
res_arr = [""]*n
used = [0]*n
def f(idx):
    global c_idx, res, used
    used[idx] = 1
    res_arr[idx] = str(c[c_idx])
    for x in dic[idx]:
        if used[x] == 0:
            c_idx += 1
            res += c[c_idx]
            f(x)

f(cnt.index(1))
print(res)
print(" ".join(res_arr))
Problem p03050 (python)

Fixed submission:
n = int(input())

if n==1:
    print(0)
    exit()
    
s = 0
for i in range(1, int(n**(1/2)+1) ):
    ans = (n-i) // i
    if n//ans == n%ans:
        s+=ans
print(s)

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

s = 0
for i in range(1, int(n**(1/2)+1) ):
    ans = (n-i) // i
    if n//ans == n%ans:
        s+=ans
print(s)
Problem p03078 (python)

Fixed submission:
x,y,z,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ab = []
for a_ in a:
    for b_ in b:
        ab.append(a_+b_)

res = []
for ab_ in sorted(ab, reverse=True)[:k]:
    for c_ in sorted(c, reverse=True)[:k]:
        res.append(ab_+c_)

for x in sorted(res, reverse=True)[:k]:
    print(x)

Buggy submission (verdict: Runtime Error):
x,y,z,k = (int(i) for i in input().split())
a = sorted([int(i) for i in input().split()],reverse=True)
b = sorted([int(i) for i in input().split()],reverse=True)
c = sorted([int(i) for i in input().split()],reverse=True)

sa = 1
sb = 1
sc = 1

al = [a[0]]
bl = [b[0]]
cl = [c[0]]

inf = 10**20

while True:

    a_ = a[0] - a[sa] if sa < x else inf
    b_ = b[0] - b[sb] if sb < y else inf
    c_ = c[0] - c[sc] if sc < z else inf
    m = min([a_,b_,c_])
    if a_ == m:
        al.append(a[sa])
        sa += 1
    if b_ == m:
        bl.append(b[sb])
        sb += 1
    if c_ == m:
        cl.append(c[sc])
        sc += 1

    if len(al) * len(bl) * len(cl) > k:
        break


da = list(map(lambda x:a[0]-x, a))
db = list(map(lambda x:b[0]-x, b))
dc = list(map(lambda x:c[0]-x, c))
d_ = al[-1] + bl[-1] + cl[-1]
for i in range(sa,x):
    if da[i] < d_:
        al.append(a[i])

for i in range(sb,y):
    if db[i] < d_:
        bl.append(b[i])

for i in range(sc,z):
    if dc[i] < d_:
        cl.append(c[i])

res = []
for a_ in al:
    for b_ in bl:
        for c_ in cl:
            res.append(a_+b_+c_)


for x in sorted(res, reverse=True)[:k]:
    print(x)
Problem p03095 (python)

Fixed submission:
import collections
n = int(input())
s = input()

c = collections.Counter(s)

res = 1
for x in c.values():
    res *= (x+1)

print( (res-1) % (10**9 + 7))

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

c = collections.Counter(s)

res = 1
for x in c.values():
    res *= (x+1)

print( (res-1) % (10**9 + 7))
Problem p03105 (python)

Fixed submission:
a, b, c = (int(i) for i in input().split())

result = b / a
result = int(min(result, c))
print(result)

Buggy submission (verdict: Runtime Error):
# UnionTreeクラス：グループ分けを木構造で管理する
class UnionFind():
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.size = [1] * N
        self.N = N

    # xのrootを返す
    def root(self, x):
        if self.par[x] == x:
            return x
        else: 
            self.par[x] = self.root(self.par[x])
            return self.root(self.par[x])

    # x, yが同じrootの場合true
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    # x,yのrootが違った場合、併合
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if self.size[rx] < self.size[ry]:
            self.par[rx] = ry
            self.size[ry] += self.size[rx]
        else:
            self.par[ry] = rx
            self.size[rx] += self.size[ry]

n, m = (int(i) for i in input().split())
input_arr = [[int(i) for i in input().split()] for i in range(m)] 

uf = UnionFind(n)
#input_arr = [[1,2],[3,4],[1,3],[2,3],[1,4]]

#print(output(uf))
result = [n*(n-1)/2]
for i in input_arr[::-1]:
    a = i[0]-1
    b = i[1]-1
    if not uf.same(a,b):
        x = uf.size[uf.root(a)] * uf.size[uf.root(b)]
        uf.unite(a,b)
        result.append(result[-1]-x)
    else:
        result.append(result[-1])

for i in result[::-1][1:]:
    print(i)

#print(uf.par)
Problem p03109 (python)

Fixed submission:
import datetime
a = input().split("/")

date1 = datetime.datetime(int(a[0]), int(a[1]), int(a[2]))
date2 = datetime.datetime(2019, 4, 30)

if date1 > date2:
    print("TBD")
else:
    print("Heisei")

Buggy submission (verdict: Runtime Error):
import datetime
a = input().split("/")

date1 = datetime.datetime(a[0], a[1], a[2])
date2 = datetime.datetime(2019, 4, 30)

if date1 > date2:
    print("TBD")
else:
    print("Heisei")
Problem p03111 (python)

Fixed submission:
n, A, B, C = (int(i) for i in input().split())  #a=1, b=3, c=5, d=7
l = [int(input()) for i in range(n)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == n:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)
    
print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
n, A, B, C = (int(i) for i in input().split())  #a=1, b=3, c=5, d=7
l = [int(input()) for i in range(n)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)
    
print(dfs(0, 0, 0, 0))