read N Y

for (( x = N; x >= 0; x-- )); do
    (( x * 10000 > Y )) && continue
    for (( y = N - x; y >= 0; y-- )); do
        z=$(( N - x - y ))
        if (( x * 10000 + y * 5000 + z * 1000 == Y )); then
            echo ${x} ${y} ${z}
            exit
        fi
    done
done

echo -1 -1 -1
