C: stubs
C: input handling & cost computation