I believe this is true for both ending and restarting a new competitive segment.
You're
allowed to use all of the training related expenses once allotted,
regardless of filled slots. So the answer there would be zero has to go
back.
For tuition, again you can use all of what was allotted,
regardless of filled slots, so if you received $30K for three slots, if
appropriate you can use that $30K on two trainees, the key word being
appropriate.
Stipend is managed by their appointment, so you
can't spend more than the SOA's for you're filled slots, anything left
is back to the Feds. Anything left over would go back as part of the
unobligated funds which cannot, as far as I know, carry into a new
segment.