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

Fixed submission:
def getter(starts, ends):
    while starts:
        if starts[-1][0] < ends[-1][1]:
            yield (starts.pop(), True)
        else:
            yield (ends.pop(), False)


def foo(C, targets):
    starts = sorted(targets, key=lambda x:x[0], reverse=True)
    ends = sorted(targets, key=lambda x: x[1], reverse=True)

    result = 0
    active = [0]*(C+1)
    for x, p in getter(starts, ends):
        if p:
            active[x[2]] += 1
        else:
            active[x[2]] -= 1
        result = max(result, sum(map(lambda x: 1 if x > 0 else 0 ,active)))
    return result


if __name__ == "__main__":
    n, C  = map(int, input().split())

    targets = []
    for i in range(n):
        s, t, c = list(map(int, input().split()))
        targets.append((s-1, t, c))
    print(foo(C, targets))

Buggy submission (verdict: Runtime Error):
def getter(starts, ends):
    while starts:
        if starts[-1][0] < ends[-1][1]:
            yield (starts.pop(), True)
        else:
            yield (ends.pop(), False)


def foo(targets):
    starts = sorted(targets, key=lambda x:x[0], reverse=True)
    ends = sorted(targets, key=lambda x: x[1], reverse=True)

    result = 0
    active = set()
    for x, p in getter(starts, ends):
        if p:
            active.add(x[2])
        else:
            active.remove(x[2])
        result = max(result, len(active))
    return result


if __name__ == "__main__":
    n,c  = map(int, input().split())

    targets = []
    for i in range(n):
        s, t, c = list(map(int, input().split()))
        targets.append((s-1, t, c))
    print(foo(targets))
Problem p03762 (python)

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

xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

MODULO = 10**9 +7

def MSum(x, y):
    return (x + y) % MODULO

def MPro(x, y):
    return (x * y) % MODULO

def foo(zs, k):
    s = 0
    for i in range(k):
       s = MSum(s, MPro(MPro(zs[i], k-i), i+1))
    return s

def diff(zs, k):
    previous = None
    rs = [0] * (k-1)
    for i, z in enumerate(zs):
        if i == 0:
            previous = z
            continue
        rs[i-1] = z - previous
        previous = z
    return rs

dx = diff(xs, n)
dy = diff(ys, m)

print(MPro(foo(dx, n-1), foo(dy, m-1)))

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

xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

MODULO = 10**9 +7

def MSum(x, y):
    return (x + y) % MODULO

def MPro(x, y):
    return (x * y) % MODULO

def foo(zs, k):
    s = 0
    for i in range(k):
       s = MSum(s, MPro(MPro(zs[i], k-i), i+1))
    return s

def diff(zs, k):
    previous = None
    rs = [0] * (k-1)
    for i, z in enumerate(zs):
        if i == 0:
            previous = z
            continue
        rs[i-1] = z - previous
        previous = z
    return rs

dx = diff(xs, n)
dy = diff(ys, n)

print(MPro(foo(dx, n-1), foo(dy, m-1)))
Problem p03469 (python)

Fixed submission:
a = input()
b = a.split("/")
b[0] = "2018"

c = ""
c = "/".join(b)
print(c)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N, Y = map(int, input().split())

a = 0
for x in range(N+1): 
    for y in range(N-x+1):
        if (10000*x + 5000*y + 1000*(N-x-y)) == Y:
            print(str(x)+" "+str(y)+" "+str(N-x-y))
            a = 1
            break
        if a == 1:
            break
    if a == 1:
        break

if a != 1:
    print("-1 -1 -1")
Problem p03469 (python)

Fixed submission:
S = input()

print(S.replace('2017', '2018'))

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

S_re = S.replace('2017', '2018')

print(S_re)
Problem p03469 (python)

Fixed submission:
S=input().split("/")
print("2018/"+S[1]+"/"+S[2])

Buggy submission (verdict: Runtime Error):
count=0
N=int(input())
d=[]
d=[int(input()) for i in range(N)]
for k in range (N-1):
    for j in range(k+1,N-1):
         dd1=d[k]
         dd2=d[j]
         if dd1==dd2 :break
    else:count+=1
print(count)

Buggy submission (verdict: Runtime Error):
count=0
N=int(input())
d=[]
d=[int(input()) for i in range(N)]
for k in range (N-1):
    for j in range(k+1,N-1):
         dd1=d[k]
         dd2=d[j]
         if dd1==dd2 :break
    else:count+=1
print(count)

Buggy submission (verdict: Runtime Error):
count=0
N=input()
d=[]
d=[int(input()) for i in range(int(N))]
for k in range (int(N)-1):
    dd1=d[k]
    dd2=d[k+1]
    if not dd1==dd2 :count+=1
print(count+1)
Problem p03493 (python)

Fixed submission:
import numpy as np
import pdb

def main():
    string = np.array(list(raw_input()))
    num1 = len(np.where(string == '1')[0])
    print num1

if __name__ == '__main__':
    main()

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

'''
From first element, look through the sequence
until you encounter first element that is smaller than
its predecessor.

Take the difference, and find the minimum number that can
one can add to make the sequence appropriate.

I was shooting for
O(N**2), nut no, not with this.

This probably works only if all elements are positive...


There is much easier way to go.
One can make everything positive by adding max to all
the numbers,
and accumulate the entries.

However, why is this minimal...?  Well, there is no gurantee.
The problem is asking for 'one' solution with number of steps being less than
or equal to 2N. Oh No....
'''


def main():
    N = int(raw_input())
    As = np.array(raw_input().split(' ')).astype(int)
    procedure = process2(As)
    #As = test(As, procedure)
    printprocedure(procedure)


def process2(As):
    oldmaxAs = np.max(As)
    oldminAs = np.min(As)
    procedure = []


    #Uniformization
    if oldmaxAs > 0 and oldminAs < 0:
        if np.abs(oldmaxAs) < np.abs(oldminAs):
            helper = np.where(As == oldminAs)[0][0]
            for k in range(len(As)):
                procedure += [[helper, k]]
            maxAs = oldmaxAs + oldminAs
            minAs = oldminAs + oldminAs
        else:
            helper =  np.where(As == oldmaxAs)[0][0]
            for k in range(len(As)):
                procedure += [[helper, k]]
            maxAs = oldmaxAs + oldmaxAs
            minAs = oldminAs + oldmaxAs
    else:
        maxAs = oldmaxAs
        minAs = oldminAs

    pdb.set_trace()
    #After uniformization
    #negative mode
    if maxAs < 0:
        for k in range(0, len(As) - 1):
            procedure += [[len(As)-1-k, len(As)-1-k-1]]

    #positive mode
    if minAs >= 0:
        for k in range(1, len(As)):
            procedure += [[k-1, k]]

    return procedure


def test(As, procedure):
    for k in range(len(procedure)):
        As[procedure[k][1]] += As[procedure[k][0]]
    return As


def process(As):
    procedure = []
    for k in range(1, len(As)):
        delta = As[k] - As[k - 1]
        while(delta < 0):
            problematic = k
            require = -delta
            candidate = 0
            candidatevalue = -np.inf
            missing = require - As

            if np.min(missing) > 0:
                candidate = np.where(missing == np.min(missing))[0][0]
            else:
                for i in range(len(As)):
                    if missing[i] <= 0 and candidatevalue < missing[i]:
                        candidate = i
                        candidatevalue = missing[candidate]

            procedure += [[candidate, k]]
            As[k] = As[k] + As[candidate]
            delta = As[k] - As[k - 1]

    return procedure


def printprocedure(procedure):
    for k in range(len(procedure)):
        print '%s %s'%(procedure[k][0] +1 ,procedure[k][1] + 1)





if __name__ == '__main__':
    main()
Problem p03469 (python)

Fixed submission:
s=input()
s=s[:3]+"8"+s[4:]
print(s)

Buggy submission (verdict: Runtime Error):
print("2018"+input[6:])

Buggy submission (verdict: Runtime Error):
print(input[:3]+"8"+input[6:])

Buggy submission (verdict: Runtime Error):
print(input[:3]+'8'+input[6:])

Buggy submission (verdict: Runtime Error):
S=input()
S=s[:3]+"8"+s[:6]
print(S)

Buggy submission (verdict: Runtime Error):
S=input()
print(s[:3]+8+s[:6])

Buggy submission (verdict: Runtime Error):
S=input()
new=S.split('2017')
print('2018'+new)

Buggy submission (verdict: Runtime Error):
new=S.split('2017')

Buggy submission (verdict: Runtime Error):
new=S.split('2017')
print('2018'+new)
Problem p03470 (python)

Fixed submission:
n=int(input())
print(len(list(set([int(input()) for x in range(n)]))))

Buggy submission (verdict: Runtime Error):
n=input()
n=n.remove(1)
n=list(n)
print(len(n))

Buggy submission (verdict: Runtime Error):
n=input()
n=del n[0]
n=list(n)
print(len(n))
Problem p03473 (python)

Fixed submission:
print(48-int(input()))

Buggy submission (verdict: Runtime Error):
print(M-input())

Buggy submission (verdict: Runtime Error):
M=input()
M=48-M
print(M)

Buggy submission (verdict: Runtime Error):
N=input()
print(48-N)

Buggy submission (verdict: Runtime Error):
N=input()
M=48-N
print(M)
Problem p03473 (python)

Fixed submission:
print(48-int(input()))

Buggy submission (verdict: Runtime Error):
def isprime(z):
    if z < 2:return False
    if z == 2:return True
    i = 2
    while i*i <= z:
        if z % i == 0:
            return False
        i+=1
    return True
n = int(input())
for i in range(n):
    l, r = map(int, input().split())
    c = 0
    for j in range(l, r+1):
        if isprime(j) and isprime((j+1)/2):
            c+=1
    print(c)

Buggy submission (verdict: Runtime Error):
def isprime(z):
    if z < 2:return False
    if z == 2:return True
    i = 2
    while i*i <= z:
        if z % i == 0:
            return False
        i+=1
    return True
n = int(input())
for i in range(n):
    l, r = map(int, input().split())
    c = 0
    for j in range(l, r+1):
        if isprime(j) and isprime((j+1)/2):
            c+=1
    print(c)
Problem p03469 (python)

Fixed submission:
inputs = input().split("/")
if inputs[0] is not '2018':
    inputs[0] = "2018"
print("/".join(inputs))

Buggy submission (verdict: Runtime Error):
def search(value, ten, five, one, num):
    global ans
    if ans or value < 0:
        return
    
    if value == 0 and (ten+five+one) == num:
        ans = (ten, five, one)
    search(value-10, ten+1,five,one, num)
    search(value-5, ten, five+1, one, num)
    search(value-1, ten, five,one+1,  num)

num, value = map(int, input().split())
value //= 1000
num_ten = 0
num_five = 0
num_one = 0
ans = None
if (num-1)*100 < value < num*100:
    print("-1 -1 -1")
else:
    search(value, num_ten, num_five, num_one, num)
    print(ans[0], ans[1], ans[2])
Problem p03469 (python)

Fixed submission:
print('2018' + input()[4:])

Buggy submission (verdict: Runtime Error):
n, h = (int(s) for s in input().split())

a = []
b = []

for i in range(n):
    a_i, b_i = (int(s) for s in input().split())
    a.append(a_i)
    b.append(b_i)

a_max = max(a)
b.sort(reverse=True)

for i, b_i in enumerate(b):
    if b_i > a_max:
        h -= b_i
        if h <= 0:
            print(i + 1)
            break
    else:
        print(i + (h - 1) // a_max + 1)
        break
else:
    print(len(b) + (h - 1) // a_max + 1)
Problem p03469 (python)

Fixed submission:
# -*- coding: utf-8 -*-
date = input()
# 出力
print("2018", date[4:], sep="")

Buggy submission (verdict: Runtime Error):
n = int(input())
mochi = [int(input()) for i in range(n)]
mochi.sort(reverse=True)

size = 0
max = 9999999999

for m in mochi:
    # print(m)
    if m < max:
        size += 1
        max = m
# 出力
print(size)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
date = input()
# 出力
print "2018" + date[4:]
Problem p03470 (python)

Fixed submission:
n = int(input())
mochi = [int(input()) for i in range(n)]
mochi.sort(reverse=True)

size = 0
max = 9999999999

for m in mochi:
    # print(m)
    if m < max:
        size += 1
        max = m
# 出力
print(size)

Buggy submission (verdict: Runtime Error):
n = int(input())
mochi = [int(input()) for i in range(n)]
mochi.sort(reverse=True)

size = 0
max = 9999999999

for m in mochi:
    //print(m)
    if m < max:
        size += 1
        max = m
# 出力
print(size)
Problem p03469 (python)

Fixed submission:
S = input()

dest = S.replace("2017", "2018")

print(dest)

Buggy submission (verdict: Runtime Error):
import math
N,H = map(int,input().split())

aList = []
bList = []
for count in range(0,N):
    a,b = map(int, input().split())
    aList.append(a)
    bList.append(b)

bList.sort()
bList.reverse()

maxA = max(aList)

count = 0
damage = 0
for b in bList:
    if maxA < b:
        damage+=b
        count+=1
    if damage >= H:
        break

if damage < H:
    remainingHP = H - damage
    count = count + math.ceil(remainingHP / maxA)

print(count)
Problem p03473 (python)

Fixed submission:
M = int(input())
twoDays = 48
print(twoDays - M)

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

sliceA = S[0:A]
sliceB = S[A+1:A+B+1]

if sliceA.isdigit() and sliceB.isdigit() and S.find("-") == A and len(sliceA) == A and len(sliceB) == B:
    print("yes")
else:
    print("no")
Problem p03485 (python)

Fixed submission:
import math

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

mean = (a+b)/2
print(math.ceil(mean))

Buggy submission (verdict: Runtime Error):
import math
N,H = map(int,input().split())

aList = []
bList = []
for count in range(0,N):
    a,b = map(int, input().split())
    aList.append(a)
    bList.append(b)

bList.sort()
bList.reverse()

maxA = max(aList)

count = 0
damage = 0
for b in bList:
    if maxA < b:
        damage+=b
        count+=1
    if damage > H:
        break

if damage < H:
    remainingHP = H - damage
    count = count + math.ceil(remainingHP / maxA)

print(count)
Problem p03469 (python)

Fixed submission:
s = str(raw_input())
s = s.replace('2017', '2018', 1)
print(s)

Buggy submission (verdict: Runtime Error):
s = str(raw_input())
s = s.replace('2017', '2018', 1)
print(s)

Buggy submission (verdict: Runtime Error):
s = raw_input()
s = s.replace('2017', '2018', 1)
print(s)

Buggy submission (verdict: Runtime Error):
import re

s = str(raw_input)
s = re.sub('2018', '2017', s, 1)
print(s)
Problem p03470 (python)

Fixed submission:
s = '0'
l = []
ans = 0
temp = -1
n = int(raw_input())
for i in range(0, n):
    s = raw_input()
    if (s != ''):
        l += [int(s)]
l.sort()
for i in range(0, len(l)):
    if(l[i] != temp):
        ans += 1
        temp = l[i]

print(ans)

Buggy submission (verdict: Runtime Error):
s = '0'
l = []
ans = 0
temp = -1
n = raw_input()
for i in range(0, n):
    s = raw_input()
    if (s != ''):
        l += [int(s)]
l.sort()
for i in range(0, len(l)):
    if(l[i] != temp):
        ans += 1
        temp = l[i]

print(ans)

Buggy submission (verdict: Runtime Error):
s = '0'
l = []
ans = 0
temp = -1
while s != '' :
    s = raw_input()
    if (s != ''):
        l += [int(s)]
l.sort()
for i in range(0, len(l)):
    if(l[i] != temp):
        ans += 1
        temp = l[i]

print(ans)

Buggy submission (verdict: Runtime Error):
s = '0'
l = []
ans = 0
temp = -1
while s != '' :
    s = raw_input()
    if (s != ''):
        l += [int(s)]
l.sort()
for i in range(0, len(l)):
    if(l[i] != temp):
        ans += 1
        temp = l[i]

print ans
Problem p03469 (python)

Fixed submission:
s = input()

print("2018"+s[4:])

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

print("2018"+s[4:])

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

s[0] = '2'
s[1] = '0'
s[2] = '1'
s[3] = '7'

print s
Problem p03474 (python)

Fixed submission:
import re,sys
a,b=map(int, input().split())
s=input()


try:
    s1,s2=s.split("-")
except Exception as e:
    print('No')
    sys.exit()

if(not s1.isdigit() or not s2.isdigit()):
    print('No')
    sys.exit()

if(len(s1)!=a or len(s2)!=b or len(s2)>5):
    print('No')
    sys.exit()

print('Yes')

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


try:
    s1,s2=s.split("-")
except Exception as e:
    print('No')
    sys.exit()

if(not s1.isdigit() or not s2.isdigit()):
    print('No')
    sys.exit()

if(len(s1)!=a or len(s2)!=b or len(s2)>5):
    print('No')
    sys.exit()

print('Yes')
Problem p03474 (python)

Fixed submission:
l = map(int, raw_input().split())
k = raw_input()
listed = list(k)
if (len(k) == (l[0] + l[1] + 1)) and (listed[l[0]] == "-"):
    if (str("".join(listed[0:l[0]])).isdigit() == True) and (str("".join(listed[l[0]+1:len(listed)])).isdigit() == True):
        print "Yes"
        exit()
    print "No"
else:
    print "No"

Buggy submission (verdict: Runtime Error):
l = map(int, raw_input().split())
k = raw_input()
listed = list(k)
if (len(k) == (l[0] + l[1] + 1)) and (listed[l[0]] == "-") and ((int(listed[l[0]+1]) in range(10)) and ((int(listed[l[0]-1])) in range(10))):
    print "Yes"
else:
    print "No"
Problem p03477 (python)

Fixed submission:
l = map(int,raw_input().split())
if(l[0]+l[1]) > (l[2]+l[3]):
    print "Left"
elif (l[0] + l[1]) < (l[2] + l[3]):
    print "Right"
elif (l[0] + l[1]) == (l[2] + l[3]):
    print "Balanced"

Buggy submission (verdict: Runtime Error):
l = list(map(int,raw_input).split())
if(l[0]+l[1]) > (l[2]+l[3]):
    print "Left"
elif (l[0] + l[1]) == (l[2] + l[3]):
    print "Balanced"
else:
    print "Right"
Problem p03729 (python)

Fixed submission:
l = map(str, raw_input().split())
for i in range(len(l)-1):
    tempa = list(l[i])
    tempb = list(l[i+1])
    if tempa[len(tempa)-1] != tempb[0]:
        print "NO"
        exit(0)
print "YES"

Buggy submission (verdict: Runtime Error):
k = map(int, raw_input().split())
temp = [k[0]]
for i in xrange((k[0]*k[2])):
    if sum(temp) % k[1] == k[2]:
        print "YES"
        exit()
    temp.append(int(k[0]))

print "NO"

Buggy submission (verdict: Runtime Error):
l = map(str, raw_input().split())

for i in range(len(l)-1):
    if l[i][len(l)-1] == l[i+1][0]:
        print "YES"
        exit()
print "NO"
Problem p03826 (python)

Fixed submission:
l = map(int, raw_input().split())
if (l[0] * l[1]) > (l[2] * l[3]):
    print (l[0] * l[1])
    exit()
else:
    print (l[2] *  l[3])

Buggy submission (verdict: Runtime Error):
import sys
sys.getrecursionlimit()
sys.setrecursionlimit(1000)

l = int(raw_input())

def factorial(l):
    if l == 0:
        return 1
    else:
        return l * factorial(l-1)
integ = factorial(l)
integ = integ
factors = []
i = 1

while(integ >= i):
    if (integ % i) == 0:
        factors.append(i)
    i+=1
print len(factors)
divisor = long(len(factors))
origin =long((10 ** 9) + 7)

Buggy submission (verdict: Runtime Error):
inputted = int(raw_input())
l = list(raw_input())
x = 0
record = []
record.append(x)
for i in range(len(l)):
    if l[i] == "I":
        x+=1

    elif l[i] == "D":
        x-=1
    record.append(x)
print max(record)
Problem p03494 (python)

Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
b  = 0
cnt = 0
while "loop":
    for num in a:
        if num % 2 == 1:
            b= 1
    if  b == 0:
            a = [ i	/2 for i in a]
            cnt += 1
    else:
        break
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
b  = 0
cnt = 0
while "loop":
    for num in a
        if num % 2 == 1:
            b= 1
    if  b == 0:
        for num in a
        num /=2
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
i = 0
cnt = 0
while "A":
    if bin(a[i][0]) == 0:
        a[i] /= 2
        cnt += 1
    else :
        break
print(cnt)
Problem p03471 (python)

Fixed submission:
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - i + 1):
    if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
      print(i, j, n - i - j)
      exit()
print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - j + 1):
    if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
      print(i, j, n - i -j)
      exit()
print("-1, -1, -1")

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - j + 1):
    if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
      print(i, j, n - i -j)
    exit()
    else:
      print(-1, -1, -1)
    exit()
Problem p04029 (python)

Fixed submission:
count = int(input())
answer = 0
for i in range(1, count + 1):
    answer = answer + i
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
nums = input().split()
costs = []
if nums.count(nums[0]) != len(nums):
    for i in range(-100, 101):
        sum = 0
        for num in nums:
            sum += (int(num) - i) ** 2
        costs.append(sum)
    ans = min(costs)
else:
    ans = 0
print(ans)
Problem p03963 (python)

Fixed submission:
N,K= map(int,input().split())
if(N==1):
      print(K)
else:
    answer = K*((K-1)**(N-1))
    print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())

if(N==1):
  	print(K)
else:
	answer = K*(N-1)*(K-1)
	print(answer)
Problem p04029 (python)

Fixed submission:
N = int(input())
tmp =0
for i in range(1,N+1):
  tmp += i
print(tmp)

Buggy submission (verdict: Runtime Error):
N = int(input())
for i in range(1,N):
  tmp += i
print(tmp)
Problem p04043 (python)

Fixed submission:
a, b, c= map(int,input().split())

list = [a,b,c]

if(7 in list):
    if list.count(5)==2:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())

list = [a,b,c]

if(7 in list):
    if list.count(5)==2:
        print("YES")
    else:
        print("NO")
else:
    print("NO")
Problem p03471 (python)

Fixed submission:
N,Y=map(int,input().split())
ichiman=0
gosen=0
sen=0
se_ichi=0
go_ichi=0
sen_go_ichi=0
mismatch=0
max_ichiman=int(2*(10**7)/(10**4))
for i in range(max_ichiman+1):
    if i*10**4==Y:
        ichiman=i
        break
    if i*10**4>Y:
        ichiman=i-1
        break
Y=Y-ichiman*10**4
for j in range(2+1):
    if j*5*10**3>Y:
        gosen=j-1
        break
Y=Y-gosen*5*10**3
for k in range(5):
    if k*10**3==Y:
        sen=k
min_N=ichiman+gosen+sen
if N-min_N<0:
    mismatch=1
#print(ichiman, gosen, sen,N)
for i2 in range(N-min_N+1):
    if N-min_N<0:
        mismatch=1
    if i2*9>N-min_N:
        se_ichi=i2-1
        break
N=N-se_ichi*9
for j2 in range(N-min_N+1):
    if N-min_N<0:
        mismatch=1
    if j2*5>N-min_N:
        sen_go_ichi=j2-1
        break
N=N-sen_go_ichi*5
for k2 in range(N-min_N+1):
    if N-min_N<0:
        mismatch=1
    if k2==N-min_N:
        go_ichi=k2
        break
N=N-go_ichi
if N-min_N<0:
    mismatch=1
#print(ichiman, gosen, sen,N)
ichiman=ichiman-se_ichi-sen_go_ichi-go_ichi
gosen=gosen+2*go_ichi+sen_go_ichi
sen=sen+5*sen_go_ichi+10*se_ichi

if sen|gosen|ichiman<0:
    mismatch=1
if mismatch==1:
    sen=-1
    ichiman=-1
    gosen=-1
#print(se_ichi,go_ichi,sen_go_ichi,mismatch)
print(ichiman, gosen, sen)

Buggy submission (verdict: Runtime Error):
N,Y=map(int,input().split())
ichiman=0
gosen=0
sen=0
se_ichi=0
go_ichi=0
sen_go_ichi=0
mismatch=0
max_ichiman=int(2*(10**7)/(10**4))
for i in range(max_ichiman+1):
    if i*10**4==Y:
        ichiman=i
        break
    if i*10**4>Y:
        ichiman=i-1
        break
Y=Y-ichiman*10**4
for j in range(2):
    if j*5*10**3>=Y:
        gosen=j
        break
Y=Y-gosen*5*10**3
for k in range(5):
    if k*10**3==Y:
        sen=k
min_N=ichiman+gosen+sen
for i2 in range(N-min_N+1):
    if N-min_N<0:
        mismatch=1
    if i2*9>N-min_N:
        se_ichi=i2-1
        break
N=N-se_ichi*9
for j2 in range(N-min_N+1):
    if N-min_N<0:
        mismatch=1
    if j2*5>N-min_N:
        sen_go_ichi=j2-1
        break
N=N-sen_go_ichi*5
for k2 in range(N-min_N+1):
    if N-min_N<0:
        mismatch=1
    if k2==N-min_N:
        go_ichi=k2
        break
N=N-go_ichi
if N-min_N<0:
    mismatch=1
#print(ichiman, gosen, sen,N)
ichiman=ichiman-se_ichi-sen_go_ichi-go_ichi
gosen=gosen+2*go_ichi+sen_go_ichi
sen=sen+5*sen_go_ichi+10*se_ichi

if sen|gosen|ichiman<0:
    mismatch=1
if mismatch==1:
    sen=-1
    ichiman=-1
    gosen=-1
3print(se_ichi,go_ichi,sen_go_ichi,mismatch)
print(ichiman, gosen, sen)