Output #1
48
If he gets head, head, tail, head, head, head, in this order, the following amounts of money are awarded.
* In the $1$\-st coin toss, the coin heads. Change the counter's value from $0$ to $1$ and receive $2$ yen.
* In the $2$\-nd coin toss, the coin heads. Change the counter's value from $1$ to $2$ and receive $7$ yen. Additionally, get $10$ yen as a streak bonus.
* In the $3$\-rd coin toss, the coin tails. Change the counter's value from $2$ to $0$.
* In the $4$\-th coin toss, the coin heads. Change the counter's value from $0$ to $1$ and receive $8$ yen.
* In the $5$\-th coin toss, the coin heads. Change the counter's value from $1$ to $2$ and receive $2$ yen. Additionally, get $10$ yen as a streak bonus.
* In the $6$\-th coin toss, the coin heads. Change the counter's value from $2$ to $3$ and receive $8$ yen. Additionally, get $1$ yen as a streak bonus.
In this case, Takahashi receives $2+(7+10)+0+8+(2+10)+(8+1)=48$ yen in total, which is the maximum possible.
Note that streak bonuses are awarded any number of times each time the counter shows $C_i$.
As a side note, if he gets head in all $6$ coin tosses, he only receives $2+(7+10)+(1+1)+8+(2+5)+8=44$ yen, which is not the maximum.