Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/1000) + 1

if(max1 > n+1):
  for i in reversed(range(n+1)):
    rest1 = y-i*1000
    max2 = int((rest1)/5000) + 1
    for ii in reversed(range(max2)):
      rest2 = y-i*1000-ii*5000
      mod = rest2%10000
      iii = int(rest2/10000)
      tot = i+ii+iii
      if(mod == 0 and tot == n):
        print(iii, ii, i)
        sys.exit()
else:
  for i in reversed(range(max1)):
    rest1 = y-i*1000
    max2 = int((rest1)/5000) + 1
    for ii in reversed(range(max2)):
      rest2 = y-i*1000-ii*5000
      mod = rest2%10000
      iii = int(rest2/10000)
      tot = i+ii+iii
      if(mod == 0 and tot == n):
        print(iii, ii, i)
        sys.exit()

print(-1,-1,-1)

Fixed submission:
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/1000) + 1

for i in range(max1):
  rest = y-i*9000-n*1000
  mod = rest%4000
  ii  = int((rest)/4000)
  iii = n-i-ii
  if(mod == 0 and iii>=0 and ii>=0):
    print(i, ii, iii)
    sys.exit()
    
print(-1,-1,-1)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/1000) + 1

for i in reversed(range(max1)):
  rest1 = y-i*1000
  max2 = int((rest1)/5000) + 1
  for ii in reversed(range(max2)):
    rest2 = y-i*1000-ii*5000
    mod = rest2%10000
    iii = int(rest2/10000)
    tot = i+ii+iii
    if(mod == 0 and tot == n):
      print(iii, ii, i)
      sys.exit()

print(-1,-1,-1)

Fixed submission:
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/1000) + 1

for i in range(max1):
  rest = y-i*9000-n*1000
  mod = rest%4000
  ii  = int((rest)/4000)
  iii = n-i-ii
  if(mod == 0 and iii>=0 and ii>=0):
    print(i, ii, iii)
    sys.exit()
    
print(-1,-1,-1)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/10000) + 1

for i in reversed(range(max1)):
  rest1 = y-i*10000
  max2 = int((rest1)/5000) + 1
  for ii in range(max2):
    rest2 = y-i*10000-ii*5000
    mod = rest2%1000
    iii = int(rest2/1000)
    tot = i+ii+iii
    if(mod == 0 and tot == n):
      print(i, ii, iii)
      sys.exit()

print(-1,-1,-1)

Fixed submission:
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/1000) + 1

for i in range(max1):
  rest = y-i*9000-n*1000
  mod = rest%4000
  ii  = int((rest)/4000)
  iii = n-i-ii
  if(mod == 0 and iii>=0 and ii>=0):
    print(i, ii, iii)
    sys.exit()
    
print(-1,-1,-1)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/10000) + 1

for i in reversed(range(max1)):
  rest1 = y-i*10000
  max2 = int((rest1)/5000) + 1
  for ii in reversed(range(max2)):
    rest2 = y-i*10000-ii*5000
    mod = rest2%1000
    iii = int(rest2/1000)
    tot = i+ii+iii
    if(mod == 0 and tot == n):
      print(i, ii, iii)
      sys.exit()

print(-1,-1,-1)

Fixed submission:
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/1000) + 1

for i in range(max1):
  rest = y-i*9000-n*1000
  mod = rest%4000
  ii  = int((rest)/4000)
  iii = n-i-ii
  if(mod == 0 and iii>=0 and ii>=0):
    print(i, ii, iii)
    sys.exit()
    
print(-1,-1,-1)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/10000) + 1

for i in range(max1):
  rest1 = y-i*10000
  max2 = int((rest1)/5000) + 1
  for ii in range(max2):
    rest2 = y-i*10000-ii*5000
    mod = rest2%1000
    iii = int(rest2/1000)
    tot = i+ii+iii
    if(mod == 0 and tot == n):
      print(i, ii, iii)
      sys.exit()

print(-1,-1,-1)

Fixed submission:
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/1000) + 1

for i in range(max1):
  rest = y-i*9000-n*1000
  mod = rest%4000
  ii  = int((rest)/4000)
  iii = n-i-ii
  if(mod == 0 and iii>=0 and ii>=0):
    print(i, ii, iii)
    sys.exit()
    
print(-1,-1,-1)