code jam Qualification Round 2014, Problem B. Cookie Clicker Alpha

Judged response for input B-small: Correct!
Judged response for input B-large: Correct!