Buggy python submission (verdict: Runtime Error):
def find(n, y):
  for i in range(n+1):
    for j in range(n+1-i):
      if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
        return i, j, n-i-j
  return -1, -1, -1
N, Y = map(int, input().split())
i, j, k = find(N, Y)
print("{} {} {}".format(i, j, k)

Fixed submission:
def find(n, y):
  for i in range(n+1):
    for j in range(n+1-i):
      if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
        return i, j, n-i-j
  return -1, -1, -1
N, Y = map(int, input().split())
i, j, k = find(N, Y)
print("{} {} {}".format(i, j, k))

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
goukei = 0
is_exist = False
for i in range(N+1):
  for j in range(N+1):
    k = N - i - j
    goukei = i * 10000 + j * 5000 + k * 1000
    if goukei == Y and i + j + k == N:
      printf("{} {} {}".format(i, j, k))
      is_exist = True
      break
  if is_exist:
    break
if is_exist == False:
  print("-1 -1 -1")

Fixed submission:
def find(n, y):
  for i in range(n+1):
    for j in range(n+1-i):
      if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
        return i, j, n-i-j
  return -1, -1, -1
N, Y = map(int, input().split())
i, j, k = find(N, Y)
print("{} {} {}".format(i, j, k))

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
sum = 0
is_exist = False
for i in range(N+1):
  for j in range(N+1):
    k = N - i - j
    sum = i * 10000 + j * 5000 + k * 1000
    if sum == Y and i + j + k == N:
      printf("{} {} {}".format(i, j, k))
      is_exist = True
      break
  if is_exist:
    break
if is_exist == False:
  print("-1 -1 -1")

Fixed submission:
def find(n, y):
  for i in range(n+1):
    for j in range(n+1-i):
      if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
        return i, j, n-i-j
  return -1, -1, -1
N, Y = map(int, input().split())
i, j, k = find(N, Y)
print("{} {} {}".format(i, j, k))

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
sum = 0
is_exist = False
for i in range(N+1):
  for j in range(N+1):
    k = N - i - j
    sum = i * 10000 + j * 5000 + k * 1000
    if sum == Y and i + j + k == N:
      printf("{} {} {}".format(i, j, k))
      is_exist = True
      break
if is_exist == False:
  print("-1 -1 -1")

Fixed submission:
def find(n, y):
  for i in range(n+1):
    for j in range(n+1-i):
      if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
        return i, j, n-i-j
  return -1, -1, -1
N, Y = map(int, input().split())
i, j, k = find(N, Y)
print("{} {} {}".format(i, j, k))

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
sum = 0
is_exist = False
for i in range(N+1):
  for j in range(N+1):
    k = N - i - j
    sum = i * 10000 + j * 5000 + k * 1000
    if sum == Y and i + j + k == N:
      printf(str(i) + " " + str(j) + " " + str(k))
      is_exist = True
      break
if is_exist == False:
  print("-1 -1 -1")

Fixed submission:
def find(n, y):
  for i in range(n+1):
    for j in range(n+1-i):
      if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
        return i, j, n-i-j
  return -1, -1, -1
N, Y = map(int, input().split())
i, j, k = find(N, Y)
print("{} {} {}".format(i, j, k))

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
sum = 0
is_exist = False
for i in range(N+1):
  for j in range(N+1):
    for k in range(N+1):
      if i + j + k > N:
        break
      sum = i * 10000 + j * 5000 + k * 1000
      if sum == Y:
        printf(str(i) + " " + str(j) + " " + str(k))
        is_exist = True
        break
if is_exist == False:
  print("-1 -1 -1")

Fixed submission:
def find(n, y):
  for i in range(n+1):
    for j in range(n+1-i):
      if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
        return i, j, n-i-j
  return -1, -1, -1
N, Y = map(int, input().split())
i, j, k = find(N, Y)
print("{} {} {}".format(i, j, k))

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
sum = 0
is_exist = False
for i in range(N+1):
  for j in range(N+1):
    for k in range(N+1):
      if i + j + k > N:
        break
      sum = i * 10000 + j * 5000 + k * 1000
      if sum == Y:
        printf(str(i) + " " + str(j) + " " + str(k))
        is_exist = True
        break
if is_exist = False:
  print("-1 -1 -1")


Fixed submission:
def find(n, y):
  for i in range(n+1):
    for j in range(n+1-i):
      if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
        return i, j, n-i-j
  return -1, -1, -1
N, Y = map(int, input().split())
i, j, k = find(N, Y)
print("{} {} {}".format(i, j, k))