peterverebics/CodeNet_Python_118 huggingface dataset:
n=int(input())

num,a,b=0,0,0

for i in range(n):
  t,x,y=map(int,input().split())
  num,a,b=abs(t-num),abs(x-a),abs(y-b)
  su=a+b
  if num<su:
    ans="No"
    break
  elif su==0 and num%2==0:
    ans="Yes"
    break
  elif su==0 and num%2!=0:
    ans="No"
    break
  else:
    if num%2==0 and su%2==0:
      ans="Yes"
    elif num%2!=0 and su%2!=0:
      ans="Yes"
    else:
      ans="No"
      
print(ans)
n=int(input())
x,y=0,0
t=0
for i in range(n):
    X,Y,T=map(int,input().split())
    if((T-t)>=(abs(X-x)+abs(Y-y)) and abs(t-T)%2==(abs(x-X)+abs(Y-y))%2):
        x=X
        y=Y
        t=T
    else:
        print("No")
        exit()
print("Yes")
N=int(input())
a=[list(map(int,input().split())) for _ in range(N)]
dp=[[0,0] for _ in range(N+1)]
dp[0][0]=1
for i in range(1,N+1):
  t=a[i-1][0]-dp[i-1][1]
  x=a[i-1][1]
  y=a[i-1][2]
  if t>=x+y and t%2==(x+y+dp[i-1][1])%2 and dp[i-1][0]==1:
    dp[i][0]=1
    dp[i][1]=a[i-1][0]
if dp[N][0]==1:print("Yes")
else:print("No")
num_list=int(input())
a=[1,0,0]
for i in range(num_list):
  b=[int(x) for x in input().split()]
  if (abs(b[1]-a[1])+abs(b[2]-a[2]))<=(b[0]-a[0]) and (abs(b[1]-a[1])+abs(b[2]-a[2])) != 0:
    if i == num_list-1:
      print("Yes")
      break
    a=b
  else:
    print("No")
    break
n = int(input())
posdata = [list(map(int,input().split())) for i in range(n)]
nowpos = [0,0,0]

for i in range(n):
    diff = posdata[i][1] - nowpos[1] + posdata[i][2] - nowpos[2]
    l_parity = diff % 2
    t_parity = (posdata[i][0] - nowpos[0]) % 2
    
    if diff > (nowpos[0] - posdata[i][0]) and l_parity == t_parity:
        nowpos = posdata[i]
    else:
        print("No")
        exit()
    print(nowpos)
print("Yes")
n = int(input())
t=0
x=0
y=0
ans ="Yes"
for i in range(n):
  tt,xx,yy = map(int,input().split())
  dif = abs(x-xx)
  dif +=abs(y-yy)
  if dif>(tt-t) or dif ==(tt-t+1)%2:
    ans = "No"
    break;
  t=tt
  x=xx
  y=yy
print(ans)
n = int(input())

x_now, y_now, t_now = 0, 0, 0

for i in range(n):
    t, x, y = map(int, input().split())
    distance = (t -t_now) - abs(x-x_now) - abs(y-y_now)
    if distance > 0 and distance % 2 == 0:
        x_now,y_now,t_now = x,y,t
    else:
        print('No')
        exit()

print('Yes')
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
        T, X, Y = t, x, y
    print("Yes" if count == N else "No")
N = int(input())
time_coor = []
for n in range(N):
    time_coor.append(list(map(int, input().split())))

can = True
for n in range(N-1):
    dist = abs(time_coor[n+1][1]-time_coor[n][1]) + \
           abs(time_coor[n+1][2]-time_coor[n][2])
    if dist>time_coor[n][0]:
        can = False
        break
    elif dist%2==(time_coor[n+1][0]-time_coor[n][0])%2:
        continue
    

if can==True:
    print("Yes")
else:
    print("No")
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
for li in [rl() for _ in range(n)]:
    t, a, b = li
    if t < a+b or (t - a - b) & 1:
        print('No')
        exit()
print('Yes')
n = int(input())
t = [0]
x = []
y = []
for _ in [0]*n:
    _t, _x, _y = map(int, input().split())
    t += [_t]
    x += [_x]
    y += [_y]
nx = ny = 0
for i in range(n):
    nt = t[i+1] - t[i]
    d = x[i]-nx + y[i]-ny
    if not (nt%2 == d%2 and nt>=d):
        print('No')
        break
    nx = x[i]
    ny = y[i]
else:
    print('Yes')
import fileinput

def main():
	pos = [0, 0]
	lines = [line.rstrip() for line in fileinput.input()]
	for line in lines[1:]:
		t, x, y = map(lambda x: int(x), line.split())
		dest = x + y
		src = sum(pos)
		if (dest - src > t):
			return print("No")
		else:
			arrivable = True if not abs(dest - src - t) % 2 else False
			if (arrivable):
				pos[0], pos[1] = x, y
				next
			else:
				return print("No")
              
	print("Yes")
                
main()
n = int(input())

def check(t, x, y):
    for i in range(t + 1):
        for j in range(t + 1 - i):
            for k in range(t + 1 - i - j):
                if (i - j == x) and (k - (t - i - j - k)) == y:
                    return True
    return False

if all(check(l[0], l[1], l[2]) for l in [list(map(int, input().split())) for i in range(n)]):
    print('Yes')
else:
    print('No')
# -*- coding: utf-8 -*-

N = int(input())
t_prev = 0

for n in range(N):
    t, x, y = map(int, input().split())
    if (t - t_prev) >= (x + y) and (t + x + y) % 2 == 0:
        t_prev = t
    else:
        print('No')
        break
else:
    print('Yes')
N = int(input())
a = [list(map(int,input().split())) for i in range(N)]
for i in range(0,N-1):
    b = (a[i+1][0]-a[i][0])
    c = (abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2]))
    if b>=c:
        if b%2==0 and c%2==0:
            print("Yes")
        elif b%2==1 and c%2==1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
n = int(input())
lst = [list(map(int, input().split())) for _ in range(n)]

ans = 'No'

for line in lst:
    t, x, y = line
    if t < x + y:
        break
    if t % 2 == 0 and (x + y) % 2 != 0:
        break
    if t % 2 != 0 and (x + y) % 2 == 0:
        break

print(ans)
N = int(input())
t=[0]*(N+1); x=[0]*(N+1); y=[0]*(N+1)
t_diff=0; x_diff=0; y_diff=0

for i in range(1,N+1):
    t[i], x[i], y[i] = map(int, input().split())

# print(t, x, y)

for i in range(N):
    t_diff = t[i+1]-t[i]
    x_diff = x[i+1]-x[i]
    y_diff = y[i+1]-y[i]
    if t_diff%2 != (x_diff+y_diff)%2 or t[-1] < (x[-1]+y[-1]):
        print("No")
        exit()

print("Yes")
n = int(input())
pret = 0
prex = 0
prey = 0
flag = True
for i in range(n):
    t,x,y = map(int,input().split())
    if flag:
        tmp = t - pret - abs(x - prex) - abs(y - prey)
        #print(t, x, y, tmp)
        if tmp >= 0 and tmp % 4 == 0:
            pret = t
            prex = x
            prey = y
        else:
            flag = False
if flag:
    print('Yes')
else:
    print('No')
n = int(input())
for i in range(n):
  t,x,y = map(int,input().split())
  if (x + y) > t :
    print("No")
    exit()
print("Yes")
N = int(input())
t, x, y = 0, 0, 0
for i in range(N):
    t_i, x_i, y_i = map(int, input().split())
    T = t_i-t
    D = (x_i-x) + (y_i-y)
    if T % 2 != D % 2 or D > T:
        print("No")
        exit()
    else:
        t = t_i
        x = x_i
        y = y_i
print("Yes")
n = int(input())
count=0
temp=0
for i in range(0,n):
    t,x,y = map(int, input().split())
    if (t-temp)>=x+y and (x+y-(t-temp))%2==0:
        count=count+1
    temp=t
if count==n:
    print("Yes")
else:
    print("No")
N = int(input())
time_coor = []
for n in range(N):
    time_coor.append(list(map(int, input().split())))

can = True
for n in range(N-1):
    if (abs(time_coor[n+1][1])-abs(time_coor[n][1]) + abs(time_coor[n+1][2])-abs(time_coor[n][2]))!=1:
        can = False
        break
    else:
        continue

if can==True:
    print("Yes")
else:
    print("No")
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
for i in txy:
    if i[0] % 2 != (i[1] + i[2]) % 2:
        print("No")
        exit()
print("Yes")
N = int(input())
X = list([int(j) for j in input().split()] for i in range(N))
X.insert(0, [0, 0, 0])

c = 0  

while c <= N-1:
  R = (X[c+1][0]-X[c][0])-(X[c+1][1]+X[c+1][2]-X[c][1]-X[c][2])
  if R<0 or R%2 != 0:
    print("No")
    break
  c += 1
else:
  print("Yes")
N = int(input())
t = 0
x = 0
y = 0
for ti, xi, yi in [map(int, input().split(' ')) for n in range(N)]:
    if not (xi-x+yi-y <= ti-t or (ti-t)%2 == (xi-x+yi-y)%2):
        print('No')
        exit()
    else:
        t = ti
        x = xi
        y = yi
print('Yes')
N = int(input())
t=[0]*(N+1); x=[0]*(N+1); y=[0]*(N+1)
t_diff=0; x_diff=0; y_diff=0

for i in range(1,N+1):
    t[i], x[i], y[i] = map(int, input().split())

for i in range(N):
    t_diff = t[i+1]-t[i]
    x_diff = abs(x[i+1]-x[i])
    y_diff = abs(y[i+1]-y[i])
    if t_diff%2 != (x_diff+y_diff)%2 or t[i+1] < (x[i+1]+y[i+1]):
        print("No")
        exit()

print("Yes")
N = int(input())
t0, x0, y0 = 0, 0, 0
flag=True
for i in range(N):
    t1,x1,y1 = [int(j) for j in input().split()]
    dt = t1 - t0
    dist = abs(x0-x1) + abs(y0-y1)

    if dist > dt:
        print('No')
        flag=False

    elif (dist%2==0 and dt%2==0) or  (dist%2==1 and dt%2==1):
        t0, x0, y0 = t1, x1, y1

    else:
        print('No')
        flag=False

if flag:
    print('Yes')
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]

pre_t, pre_x, pre_y = 0, 0, 0
for t, x, y in TXY:
  diff_t = t - pre_t
  diff_pos = abs(x-pre_x) + abs(y-pre_y)
  if diff_t > diff_pos or diff_pos-diff_t % 2 == 1:
    print('No')
    exit()
  else:
    pre_t, pre_x, pre_y = t, x, y
print('Yes')
n = int(input())
target_point = [list( map(int,input().split())) for i in range(n)]
current_point = [0, 0, 0]
for i in range(n):
    dist = abs(target_point[i][1] - current_point[1]) + abs(target_point[i][2]) - current_point[2]
    time = target_point[i][0] - current_point[0]
    if (dist == time) or ((time > dist) and (time - dist) % 2 == 0):
        current_point = target_point[i]
    else:
        print('No')
        exit()
print('Yes')
n,y = map(int,input().split())

a,b,c = (-1,-1,-1)
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            a,b,c = (i,j,n-i-j)
            break

print(a,b,c)
N,Y = map(int,input().split())
flg = 0
x = -1
y = -1
z = -1
for i in range(Y//10000+1):
    for j in range(min(N-i,Y//5000)+1):
        k = N-i-j
        if k>=0 and 10000*i+5000*j+k*1000==Y:
            flg = 1
            x = i
            y = j
            z = k
            break
    if flg==1:break
print(x,y,z)
def resolve():
    N, Y = map(int, input().split())

    resx, resy, resz = (-1, -1, -1)
    for x in range(N+1):
        for y in range(N+1-x):
            z = N - x - y
            total = 10000*x + 5000*y + 1000*z

            if total == Y:
                resx, resy, resz = (x, y, z)
                break
    
    print(resx, resy, resz)
    
resolve()
N, Y = [int(i) for i in input().rstrip().split(' ')]

cnt = [int(-1)for i in range(3)]
for A in range(N+1):
    for B in range(N+1 - A):
        C = N - A - B
        calc = A*10000 + B*5000 + C*1000
        if calc == Y:
            cnt = [A, B, C]
            break
    else:
        continue
    break
print(' '.join(map(str,cnt)))
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i+5000*j==y-1000*(n-i-j):
            print(i,j,n-i-j)
            exit()
print(-1,-1,-1)
import numpy as np
if __name__ == "__main__":
    N, Y = map(int, input().split())
    ans = [-1, -1, -1]
    for i in range(N+1):
        for j in range(N+1-i):
            k = N - i - j
            y = 10000 * i + 5000 * j + 1000 * k
            if y == Y:
                ans = [i, j, k]
    print("{} {} {}".format(ans[0], ans[1], ans[2]))
N,Y=map(int,input().split())

for i in range(N+1):
    for j in range(N+1-i):
        k=N-i-j
        if 10000*i+5000*j+1000*k==Y:
            print(i,j,k)
            exit()

print(-1,-1,-1)
N,Y=map(int,input().split())
answer=-1,-1,-1
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            answer=x,y,z
            break
    else:
        continue
    break
print(*answer)
n,Y = map(int,(input().split()))
x = -1
y = -1
z = -1
for i in range(n+1):
    for j in range(n+1):
        k=Y-i*10000-j*5000
        if k==(n-i-j)*1000 and k>=0:
            x=i
            y=j
            z=int(k/1000)
print(x,y,z)
n,c=map(int,input().split())
x,y,z=-1,-1,-1
for i in range(n+1):
  for j in range(n+1-i):
    if 10000*i+5000*j+(n-i-j)*1000==c:
      x,y,z=i,j,n-i-j
      print(x,y,z)
      exit()
print(x,y,z)
n,y = [int(e) for e in input().split()]
for i in range(0,n+1):
    for j in range(0,n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            print(str(i)+" " +str(j) + " " + str(n-i-j))
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")
N,Y=map(int,input().split())
answer=0
for n in range(0,N+1):
    for n_ in range(0,N+1-n):
        n__=N-n-n_
        if 10000*n+5000*n_+1000*n__==Y:
            answer=1
            kotae=str(n)+' '+str(n_)+' '+str(n__)
            break
if answer==0:
    print(-1,-1,-1)
else:
    print(kotae)
n, y = map(int, input().split())
for i in range(n + 1):
  for ii in range(n - i + 1):
    if 10000 * i + 5000 * ii + 1000 * (n - i - ii) == y:
      print('{} {} {}'.format(i, ii, n - i - ii))
      exit()
print('-1 -1 -1')
N, Y = map(int, input().split())
Y /= 1000
x = 10
y = 5
z = 1
for i in range(N+1):
    for j in range(N+1):
        if x*i+y*j+(N-i-j) == Y and i+j <= N:
            print(i, j, N-i-j)
            exit()
print(-1, -1, -1)
N, Y = map(int, input().split())
ans = 0
a = 0
b = 0
c = 0
for a in range(N+1):
    for b in range(N-a+1):
        c = N - a - b
        if (a*10000 + b*5000 + c*1000) == Y:
            ans = 1
            x = a
            y = b
            z = c
            break
if ans == 1:
    print(x,y,z)
else:
    print( '-1 -1 -1')
n,y=map(int,input().split())
for a in range(n+1):
    for b in range(n+1):
        c=(y-(a*10000+b*5000))//1000
        if a+b+c==n and c>=0:
            print(a,b,c)
            exit()
print(-1,-1,-1)
from itertools import *
N,Y = map(int,input().split())
if 10000*N < Y:
  print(-1,-1,-1)
  exit()
for i in range(N):
  for j in range(N-i):
    k = N-i-j
    for xyz in permutations([i,j,k],3):
      x,y,z = xyz
      if 10000*x + 5000*y + 1000*z == Y:
        print(x,y,z)
        exit()
print(-1,-1,-1)
def main():
    N,Y=map(int,input().split())

    for i in range(Y//10000+1):
        tY=Y-10000*i
        for j in range(tY//5000+1):
            k=(tY-5000*j)//1000
            if i+j+k==N:
                print(i,j,k)
                return

    print("-1 -1 -1")

main()
N,Y = map(int,input().split())
for a in range(N+1):
    for b in range(N+1):
        val = Y-10000*a-5000*b
        n = N-a-b
        if n>=0 and val >=0 and n*1000==val:
            print(a,b,N-a-b);exit()
print('-1 -1 -1')
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")
N, Y = [int(x) for x in input().split()]

for x in range(Y // 10000 + 1): # 1万円札の枚数
    for y in range((Y - 10000 * x) // 5000 + 1): # 5千円札の枚数
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            print(x, y, N - x - y)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)
from sys import exit

n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            exit()

print(-1, -1, -1)
N, Y = map(int, input().split())
ans = [-1,  -1,  -1]
for x in range(N+1):
    for y in range(N+1):
        z = N - (x+y)
        if 10000*x + 5000*y + 1000*z == Y and (0<= z <= N):
            ans = [x, y, z]
            break
print(*ans)
n, money = map(int, input().split())
ans = [-1, -1, -1]
flag = False

money = money // 1000

for i_1 in range(n+1):
  for j_5 in range(n - i_1 + 1):
    if (money - i_1 - j_5 * 5) == 10 * (n - i_1 - j_5):
      flag = True
      ans = [i_1, j_5, n - i_1 - j_5]
      
  if flag:
    break

print(ans[2], ans[1], ans[0])
n,y=map(int,input().split())

for i in range(n+1):
    for j in range(n+1-i):
        k=n-i-j
        if 10000*i+5000*j+1000*k == y:
            print(i,j,k)
            exit()

print(-1,-1,-1)
N, Y= map(int, input().split())
flag = False
for i in range(N+1):
	zandaka = Y - (10000*i)
	for j in range(N+1-i):
		k = (zandaka - 5000*j)//1000
		if(i + j + k == N):
			flag = True
			print(i, j, k)
			break
	if flag is True:
		break
if flag is False:
	print(-1,-1,-1)
N, Y = map(int, input().split())

a = 0

for i in range(N+1):

    for ii in range(N+1):

        iii = N - i - ii

        if iii < 0:
            break
        ans = 10000 * i + 5000 * ii + 1000 * iii
        if ans == Y:
                print(i,ii,iii)
                a += 1
                break

    if a != 0:
        break

if a == 0:
    print(-1,-1,-1)
# -*- coding: utf-8 -*-
from sys import exit
n, y  = map(int, input().split())
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i+5000*j+1000*(n-i-j) == y:
            print(i, j, n-i-j)
            exit()
print(-1, -1, -1)
n,y = map(int, input().split())
for a in range(n+1):
    for b in range(n+1):
        c = n - a - b
        if (10000*a + 5000*b + 1000*c) == y and a + b + c == n and c >= 0:
            print(a,b,c)
            exit(0)
print(-1,-1,-1)
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            print(i, j, n-i-j)
            exit()
print('-1 -1 -1')
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")
import sys
n,y=map(int,input().split())
for i in range(y//10000+1):
  for j in range(y//5000+1):
    k=n-(i+j)
    if k<0:
      continue
    if 10000*i+5000*j+1000*k==y:
      print(' '.join([str(i),str(j),str(k)]))
      sys.exit()
print(' '.join(['-1','-1','-1']))
# abc085_c.py
N,Y = map(int,input().split())
for i in range(N+1):
    for j in range(N+1):
        k = N-i-j
        if i*10000 + j*5000 + k*1000 == Y and k>=0:
            print(i,j,k)
            exit()
print(-1,-1,-1)
N,Y=map(int,input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            print(x,y,z)
            exit()

print(-1,-1,-1)
N,Y = input().split()
N = int(N)
Y_k=int(Y)/1000

answer = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1 - i):
        k = N-i-j
        if 10*i + 5*j + 1*k == Y_k:
            answer = [i,j,k]

print(answer[0],answer[1],answer[2])
n, y = map(int, input().split())

for a in range(n+1):
    for b in range(n+1-a):
        c = n-a-b
        total = 10000*a + 5000*b + 1000*c
        if total==y:
            print("{0} {1} {2}".format(a,b,c))
            exit()

print("-1 -1 -1")
n,y=map(int,input().split())
flag=True
for i in range(n+1):
    if flag:
        for j in range(n-i+1):
            k=n-i-j
            if 10000*i+5000*j+1000*k==y:
                print('{} {} {}'.format(i,j,k))
                flag=False
                break
    else:
        break
if flag:
    print('-1 -1 -1')
n, m = map(int, input().split())
answer = -1, -1, -1

for x in range(n+1):
  for y in range(n-x+1):
    z = n - x - y
    if x * 10000 + y * 5000 + z * 1000 == m:
      answer = (x, y, z)
      break
    else:
      continue
print(*answer)
N,Y = map(int,input().split())

for i in range(N+1):
    for j in range(N+1):
            m = Y - (10000*i+j*5000)
            if m >= 0 and (i+j+m//1000) == N:
                print(i,j,m//1000)
                exit()
print(-1,-1,-1)
n, y = map(int, input().split())

def search():
    for i in range(n+1):
        for j in range(n-i+1):
            k = (n - i - j)
            if i * 10000 + j * 5000 + 1000 * k == y:
                return i, j, k
    return -1, -1, -1
print(*search())
n, y = map(int, input().split())
for i in range(n + 1):
	for j in range(n+1 - i):
		k = n - i - j
		if i *10000 + j * 5000 + k *1000 == y:
			print(i,j,k)
			exit()
			
print('-1 -1 -1')
N, Y = map(int, input().split())
for x in range(min(Y // 10000 + 1, N + 1)):
  for y in range(min(Y // 5000 + 1, N + 1)):
    r = Y - x * 10000 - y * 5000
    if r >= 0 and r // 1000 == N - x - y: 
      print(x, y, r // 1000)
      exit()
      
print(-1, -1, -1)
n,y = map(int,input().split())
ans = [-1,-1,-1]

for i in range(n+1):
    for j in range(n+1):
            if 10000*i+5000*j+1000*(n-i-j)==y and n-i-j>=0:
                ans = [i,j,n-i-j]

print(*ans)
n,Y = map(int,(input().split()))
x = 0
y = 0
z = 0
f = True
for i in range(n+1):
    for j in range(n+1):
        k=Y-i*10000-j*5000
        if k==(n-i-j)*1000 and k>=0:
            x=i
            y=j
            z=int(k/1000)
            f=False
if f :
    x = -1
    y = -1
    z = -1
print(x,y,z)
N,Y = map(int,input().split())

for x in range(N+1):
  for y in range(N-x+1):
    z = N-x-y
    if 10000*x+5000*y+1000*z==Y:
      print(x,y,z)
      exit()

print(-1,-1,-1)
import sys

num = sys.stdin.readline().split(' ')
N = int(num[0])
Y = int(num[1])


for x in range(N+1):
    for y in range(N+1):
        if 10000 * x + 5000 * y + 1000*(N-x-y) == Y and N-x-y >= 0:
            print(str(x)+' '+str(y)+' '+str(N-x-y))
            sys.exit()
        else:
            continue

print('-1 -1 -1')
N,Y = map(int,input().split())

for x in range(N+1):
  for y in range(N+1):
    z = N-x-y
    if 0<=z and 10000*x+5000*y+1000*z==Y:
      print(x,y,z)
      exit()

print(-1,-1,-1)
N, Y = map(int, input().split())

for x in range(N + 1):
    for y in range(N + 1 - x):
        z = N - x - y
        if x * 10000 + y * 5000 + z * 1000 == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)
n,y=map(int,input().split())
#1000円がn-a-b枚、5000円がa枚、10000万円がb枚とする
for i in range(0,n+1):
    for j in range(0,n-i+1):
        if 1000*(n-i-j)+5000*i+10000*j==y:
            print(j,i,n-i-j)
            exit()
print(-1,-1,-1)
N, Y = map(int, input().split())

for a in range(Y // 10000 + 1):
    for b in range((Y - 10000 * a) // 5000 + 1):
        if a + b + (Y - 10000 * a - 5000 * b) // 1000 == N:
            print(a, b, N - a - b)
            exit()
print(-1, -1, -1)
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n,y=map(int, input().split())

for a in range(n+1):
    for b in range(n+1):
        c = max(n - (a+b), 0)
        if (a+b+c == n):
            if (10000*a+5000*b+1000*c == y):
                print(a,b,c)
                exit()
print(-1,-1,-1)
n,Y=map(int,input().split())

ans=0
for x in range(0,n+1):
  if ans>0:
    break
  for y in range(0,n+1-x):
    z=n-x-y
    if 10000*x+5000*y+1000*z==Y:
      ans+=1
      print(str(x)+' '+str(y)+' '+str(z))
      
    if ans>0:
      break
      
if ans==0:
  print(str(-1)+' '+str(-1)+' '+str(-1))
n,y = map(int, input().split())


s = [-1,-1,-1]

for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j +1000*(n-i-j) == y:
            s = [i,j,n-i-j]
            break

print(*[x for x in s])
N,Y=map(int,input().split())
ans=-1,-1,-1
for i in range(N+1):
    for j in range(N+1-i):
            if 1<=N<=2000 and 10000*i+5000*j+1000*(N-i-j)==Y:
                ans=i,j,N-i-j
print(*ans)
n,y=map(int,input().split())
count=0
for i in range(n+1):
  for j in range(n+1):
    k=n-i-j
    if k>=0 and k<=n:
      if i*10000+j*5000+k*1000==y:
        print(i,j,k)
        exit()
print(-1,-1,-1)
n,y=map(int,input().split())

for i in range(n+1):
  for j in range(n+1-i):
    k=n-i-j
    if 10000*i+5000*j+1000*k==y:
      print(i,j,k)
      exit()
print(-1,-1,-1)
#-*-coding:utf-8-*-
import sys

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

if __name__=="__main__":
    main2()
N, Y = map(int, input().split())
for i in range(Y // 10000 + 1):
  for j in range((Y - 10000 * i) // 5000 + 1):
    if 10000 * i + 5000 * j == Y - 1000 * (N - i - j) and N - i - j >= 0:
      print(i, j, N - i - j)
      exit()
print(-1, -1, -1)