Once Upon an Input: Reasoning via Per-Instance Program Synthesis