Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split)
print(A*B)

Fixed submission:
A, B = map(int, input().split())
print(A*B)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]


import logging
import sys
import unittest
from io import StringIO

logging.basicConfig(level=logging.DEBUG)


def resolve():
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

def MII_split(): return map(int, input().split())

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

def LII_split(): return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

N=input_int()
N%=10
if N==3:
    ans = 'bon'
elif N in [0, 1, 6, 8]:
    ans = 'pon'
else:
    ans = 'hon'
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N = input_int()
N %= 10
if N == 3:
    ans = 'bon'
elif N in [0, 1, 6, 8]:
    ans = 'pon'
else:
    ans = 'hon'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from itertools import combinations
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N, K = MII_split()

# dp = list(set(sum(n) for n in combinations(range(0, N + 1), K))) # K個選んだときの和の組み合わせ
# for k in range(K+1, N+2):
#     dp = dp + list(set(sum(n) for n in combinations(range(0, N + 1), k)))

# return
# nums = []
count = 0
for num_nums in range(K, N + 2):
    tmp_nums = []
    for n in combinations(range(0, N + 1), num_nums):
        s = sum(n)
        if s not in tmp_nums:
            tmp_nums.append(s)
    count += len(tmp_nums)
    # for i in tmp_nums:
    #     nums.append((num_nums, i))
# print(len(nums))
print(count)

Fixed submission:
import sys
from itertools import combinations
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N, K = MII_split()

count = 0
p_min_sum = 0
p_max_sum = 0
for num_nums in range(K, N + 2):
    # 実は，すべての和を実際に計算する必要はない．
    # M個の数字を選んだ場合，和の最小値は小さい方からM個，最大値は大きい方からM個だが，
    # 最小値と最大値の間の数は ---全て作ることができる---
    # 和は和の公式か尺取法か累積和を使って求める
    # --- 尺取法？ ---
    if num_nums == K:
        p_min_sum = sum(range(num_nums))
        p_max_sum = sum(range(N - num_nums + 1, N + 1))
    else:
        p_min_sum += num_nums - 1
        p_max_sum += N - num_nums + 1

    # （等差数列の）和の公式
    # p_min_sum = num_nums * (num_nums - 1) // 2
    # p_max_sum = num_nums * (2 * N - num_nums + 1) // 2
    #
    count += p_max_sum - p_min_sum + 1

    # すべての和の計算（TLE）
    # tmp_nums = []
    # for n in combinations(range(0, N + 1), num_nums):
    #     s = sum(n)
    #     tmp_nums.append(s)
    # count += len(set(tmp_nums))

print(int(count % (1e9 + 7)))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import OrderedDict

sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


def map_int_input():
    return map(int, input())


MII = map_int_input


def MII_split():
    return map(int, input().split())


def MII_to_index():
    return map(to_index, input())


def MII_split_to_index():
    return map(to_index, input().split())


# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))


LII = list_int_inputs


def LII_split():
    return list(map(int, input().split()))


# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]


def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]


N, X, Y = MII_split()

dists = []
for start_node in range(N - 1):

    dists_from_start = OrderedDict()

    for i in range(start_node, N):
        dists_from_start[i] = i - start_node
    # if X - 1 >= start_node:
    #     dists_from_start[Y - 1] = dists_from_start[X - 1] + 1
    #     for i in range(start_node, N):
    #         dists_from_start[i] = dists_from_start[Y - 1] + abs(i - (Y - 1))
    # else:
    back_s = abs(start_node - (X - 1))
    for i in range(start_node, N):
        dist_t = back_s + 1 + abs(Y - 1 - i)
        dists_from_start[i] = min(dist_t, dists_from_start[i])

    dists += dists_from_start.values()

for k in range(1, N):
    print(dists.count(k))


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N, X, Y = MII_split()

dist_counts = {}
for start_node in range(N - 1):
    back_s = abs(start_node - (X - 1))
    for i in range(start_node, N):
        dist_t = back_s + 1 + abs(Y - 1 - i)
        dist = min(dist_t, i - start_node)
        if dist in dist_counts:
            dist_counts[dist] += 1
        else:
            dist_counts[dist] = 1

for k in range(1, N):
    print(dist_counts[k] if k in dist_counts else 0)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

def MII_split(): return map(int, input().split())

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

def LII_split(): return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

X, Y, A, B, C = MII_split()
p_list = LII_split()
q_list = LII_split()
r_list = LII_split()

prices = p_list + q_list + r_list
prices = prices.sort()
print(sum(prices[0:X + Y]))

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

def MII_split(): return map(int, input().split())

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

def LII_split(): return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

X, Y, A, B, C = MII_split()
p_list = LII_split()
q_list = LII_split()
r_list = LII_split()

prices = sorted(p_list, reverse=True)[0:X] + sorted(q_list, reverse=True)[0:Y] + r_list
prices = sorted(prices, reverse=True)
# print(prices)
print(sum(prices[0:X + Y]))
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())

# コーナーケースに注意！1行 or 1列の時は動けないよ！
if H == 1 or W == 1:
    print(1)
    return

if H % 2 == 0:
    ans = (H / 2) * W
else:
    ans = (H // 2) * W + W // 2
    if W % 2 != 0:
        ans += 1

print(int(ans))

Fixed submission:
H, W = map(int, input().split())

# コーナーケースに注意！1行 or 1列の時は動けないよ！
if H == 1 or W == 1:
    print(1)
    exit()

if H % 2 == 0:
    ans = (H / 2) * W
else:
    ans = (H // 2) * W + W // 2
    if W % 2 != 0:
        ans += 1

print(int(ans))
Buggy python submission (verdict: Runtime Error):
S = input()

if len(S) < 2:
    print('No')
    return

s = S.replace('hi', '')

# print(S)
print('Yes' if len(s) < 1 else 'No')

Fixed submission:
S = input()

if len(S) < 2:
    print('No')
    exit()

s = S.replace('hi', '')

# print(S)
print('Yes' if len(s) < 1 else 'No')
Buggy python submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

ans = min(a_list) + min(b_list)
for discount in sys.stdin:
    x, y, c = map(int, discount.split())
    ans = min(ans, a_list[x - 1] + b_list[y - 1] - c)
print(ans)

Fixed submission:
import sys
A, B, M = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

ans = min(a_list) + min(b_list)
for discount in sys.stdin:
    x, y, c = map(int, discount.split())
    ans = min(ans, a_list[x - 1] + b_list[y - 1] - c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
A, B, M = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
# discounts = list(list(map(int, input().split())) for _ in )

discounts = dict()
for discount in sys.stdin:
    x, y, c = discount.split()
    c = int(c)
    if x in discounts:
        if y in discounts[x]:
            if discounts[x][y] < c:
                discounts[x][y] = c
        else:
            discounts[x][y] = c
    else:
        discounts[x] = {y: c}

min = -1
for i in range(len(a_list)):
    b_line_prices = []
    for j in range(len(b_list)):
        price = a_list[i] + b_list[j]
        x = str(i + 1)
        y = str(j + 1)
        if x in discounts:
            if y in discounts[x]:
                price -= discounts[x][y]
        if min == -1 or price < min:
            min = price
print(min)

Fixed submission:
import sys
A, B, M = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

ans = min(a_list) + min(b_list)
for discount in sys.stdin:
    x, y, c = map(int, discount.split())
    ans = min(ans, a_list[x - 1] + b_list[y - 1] - c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

b_count = 0
n_count = 0
while n_count < N:
    if n_count + A < N:
        b_count += A
    else:
        b_count += N - n_count
        break
    n_count += A + B
print(b_count)

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

division = N // (A + B)
count = division * A

count += N - division * (A + B) if A > N - division * (A + B) else A
print(count)

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

boals = ''
while len(boals) < N:
    boals += 'b' * A + 'r' * B
print(boals.count('b', 0, N))

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

division = N // (A + B)
count = division * A

count += N - division * (A + B) if A > N - division * (A + B) else A
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

boals = []
roop = 0
for _ in range(N):
    if roop < A:
        boals.append('B')
        roop += 1
    elif roop < A + B - 1:
        boals.append('R')
        roop += 1
    else:
        boals.append('R')
        roop = 0
print(boals.count('B'))


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

division = N // (A + B)
count = division * A

count += N - division * (A + B) if A > N - division * (A + B) else A
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

boals = []
roop = 0
for _ in range(N):
    if roop < A:
        boals.append('B')
        roop += 1
    elif roop < A + B - 1:
        boals.append('R')
        roop += 1
    else:
        boals.append('R')
        roop = 0
print(boals.count('B'))

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

division = N // (A + B)
count = division * A

count += N - division * (A + B) if A > N - division * (A + B) else A
print(count)
Buggy python submission (verdict: Runtime Error):

    N, M = map(int, input().split())
    s_list = list()
    c_list = list()
    for _ in range(M):
        s, c = input().split()
        s_list.append(s)
        c_list.append(c)

    out = '-1'
    exists = True

    num = 'd' * N

    for index in range(len(s_list)):
        if num[int(s_list[index]) - 1] == 'd' or num[int(s_list[index]) - 1] == c_list[index]:
            # num[int(s_list[index])] = c_list[index]
            num_tmp = num[:int(s_list[index]) - 1]
            num_tmp += c_list[index] + num[int(s_list[index]):]
            num = num_tmp

        else:
            exists = False
            break

    if exists:
        out = num.replace('d', '0')
        if out[0] == '0' and N > 1:
            out = '-1'

    print(out)

Fixed submission:
N, M = map(int, input().split())
s_list = list()
c_list = list()
for _ in range(M):
    s, c = input().split()
    s_list.append(s)
    c_list.append(c)

out = '-1'
exists = True

num = 'd' * N

for index in range(len(s_list)):
    if num[int(s_list[index]) - 1] == 'd' or num[int(s_list[index]) - 1] == c_list[index]:
        # num[int(s_list[index])] = c_list[index]
        num_tmp = num[:int(s_list[index]) - 1]
        num_tmp += c_list[index] + num[int(s_list[index]):]
        num = num_tmp

    else:
        exists = False
        break

if num[0] == '0' and N > 1:  # 0から始まる2桁以上を排除
    exists = False

if exists:
    out = num.replace('d', '0')
    if out[0] == '0' and N > 1:  # '00'→'10'等
        out = '1' + out[1:]

print(out)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X_list = list(map(int, input().split()))

hp_list = []
for p in range(int(min(X_list)), int(max(X_list))):
    hp = 0
    for x in X_list:
        hp += abs(x - p) ** 2
    hp_list.append(hp)

print(min(hp_list))


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

hp_list = []
for p in range(int(min(X_list)), int(max(X_list))):
    hp = 0
    for x in X_list:
        hp += abs(x - p) ** 2
    hp_list.append(hp)

print(min(hp_list) if len(hp_list) > 0 else 0)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
war_pairs = []
for _ in range(M):
    a, b = map(int, input().split())
    war_pairs.append((a, b))

# 取り除く橋についてbit全探索
bridge_cnt = N - 1
for i in range(2 ** bridge_cnt):

    bridges = [True] * bridge_cnt
    for j in range(bridge_cnt):
        if (i >> j) & 1:
            bridges[bridge_cnt - 1 - j] = False

    # war_pairs間でたどり着けないか確認
    is_unreachable_all = True
    for (a, b) in war_pairs:
        bridges_between_ab = bridges[a - 1:b - 1]
        if all(bridges_between_ab):
            is_unreachable_all = False

    if is_unreachable_all:
        print(bridges.count(False))
        exit()


Fixed submission:
N, M = map(int, input().split())
pairs = []
for _ in range(M):
    i, j = map(int, input().split())
    pairs.append([i, j])

pairs.sort(key=lambda x: x[1])  # 終端が早い順に並び替え

# 重複区間除去(greedy)
current = 0
bag = []
for pair in pairs:
    if pair[0] >= current:
        bag.append(pair)
        current = pair[1]

print(len(bag))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
war_pairs = []
for _ in range(M):
    a, b = map(int, input().split())
    war_pairs.append((a, b))

# 取り除く橋についてbit全探索
bridge_cnt = N - 1
for i in range(2 ** bridge_cnt):

    bridges = [True] * bridge_cnt
    for j in range(bridge_cnt):
        if (i >> j) & 1:
            bridges[bridge_cnt - 1 - j] = False

    # war_pairs間でたどり着けないか確認
    is_unreachable_all = True
    for (a, b) in war_pairs:
        bridges_between_ab = bridges[a - 1:b - 1]
        if all(bridges_between_ab):
            is_unreachable_all = False

    if is_unreachable_all:
        print(bridges.count(False))
        exit()


Fixed submission:
N, M = map(int, input().split())
pairs = []
for _ in range(M):
    i, j = map(int, input().split())
    pairs.append([i, j])

pairs.sort(key=lambda x: x[1])  # 終端が早い順に並び替え

# 重複区間除去(greedy)
current = 0
bag = []
for pair in pairs:
    if pair[0] >= current:
        bag.append(pair)
        current = pair[1]

print(len(bag))
Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())

out = '-1 -1 -1'
is_found = False


def price(t_thousand_num, f_thousand_num, thousand_num):
    return t_thousand_num * 10000 + f_thousand_num * 5000 + thousand_num * 1000


def sum_of_bills(t_thousand_num, f_thousand_num, thousand_num):
    return t_thousand_num + f_thousand_num + thousand_num


def is_over(t_thousand_num, f_thousand_num, thousand_num):
    return price(t_thousand_num, f_thousand_num, thousand_num) > Y or \
           sum_of_bills(t_thousand_num, f_thousand_num, thousand_num) > N


def is_match(t_thousand_num, f_thousand_num, thousand_num):
    return price(t_thousand_num, f_thousand_num, thousand_num) == Y and \
           sum_of_bills(t_thousand_num, f_thousand_num, thousand_num) == N


for t_thousand_num in range(N + 1):

    if is_over(t_thousand_num, 0, 0) or is_found:
        break
    elif is_match(t_thousand_num, 0, 0):
        out = '{} {} {}'.format(t_thousand_num, 0, 0)
        break

    for f_thousand_num in range(N + 1):
        if is_over(t_thousand_num, f_thousand_num, 0) or is_found:
            break
        elif is_match(t_thousand_num, f_thousand_num, 0):
            out = '{} {} {}'.format(t_thousand_num, f_thousand_num, 0)
            is_found = True
            break
        for thousand_num in range(N + 1):
            if is_over(t_thousand_num, f_thousand_num, thousand_num):
                break
            elif is_match(t_thousand_num, f_thousand_num, thousand_num):
                out = '{} {} {}'.format(t_thousand_num, f_thousand_num, thousand_num)
                is_found = True
                break

print(out)


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

out = '-1 -1 -1'
is_found = False


def price(t_thousand_num, f_thousand_num, thousand_num):
    return t_thousand_num * 10000 + f_thousand_num * 5000 + thousand_num * 1000


def sum_of_bills(t_thousand_num, f_thousand_num, thousand_num):
    return t_thousand_num + f_thousand_num + thousand_num


def is_over(t_thousand_num, f_thousand_num, thousand_num):
    return price(t_thousand_num, f_thousand_num, thousand_num) > Y or \
           sum_of_bills(t_thousand_num, f_thousand_num, thousand_num) > N


def is_match(t_thousand_num, f_thousand_num, thousand_num):
    return price(t_thousand_num, f_thousand_num, thousand_num) == Y and \
           sum_of_bills(t_thousand_num, f_thousand_num, thousand_num) == N


for t_thousand_num in range(N + 1):

    if is_over(t_thousand_num, 0, 0) or is_found:
        break
    elif is_match(t_thousand_num, 0, 0):
        out = '{} {} {}'.format(t_thousand_num, 0, 0)
        break

    for f_thousand_num in range(N + 1):
        thousand_num = N - f_thousand_num - t_thousand_num
        if is_over(t_thousand_num, f_thousand_num, thousand_num) or is_found or thousand_num < 0:
            break
        elif is_match(t_thousand_num, f_thousand_num, thousand_num):
            out = '{} {} {}'.format(t_thousand_num, f_thousand_num, thousand_num)
            is_found = True
            break

print(out)