Update old print statements to use print function.
Write apply_cost and its test.