Your friend just gave you some big news, and you want to put as many exclamation marks as you can at the end of your sentence in response. You start with one exclamation mark in your clipboard. If it takes you $b$ milliseconds to highlight your previous text and press ctrl-c (copying action) and $a$ milliseconds to press ctrl-v (inserting action), what strategy should you employ to enter exclamation marks as fast as possible?
Or, more succinctly; "how many times should you paste before you copy again?"
There must be a way more interesting / elegant than just working out the HJB recursion!
If I have $n$ exclamation marks in the file and $m$ on the clipboard, I can add $m$ in $a$ msec, leaving $m$ on the clipboard or I can add $n$ in $a+b$ msec, leaving $n$ on the clipboard. The first paste gives $n=m=1$. After each copy/paste we have $n=2m$ so we start with that. We clearly want to do $k$ pastes between copies. Then one cycle consists of $k-1$ pastes, copy, paste. It takes $ak+b$ msec and multiplies the number of exclamation points by $(1+\frac {k-1}2)\cdot 2=1+k$. To get the fastest exponential growth rate, we want the fastest growth rate of the log of the number of exclamation points, so we maximize $\frac {\log(1+k)}{ak+b}$. Taking the derivative and setting to zero we have $$0=\frac d{dk}\frac {\log(1+k)}{ak+b}= \frac{a k - a (k + 1) \log(k + 1) + b}{(k + 1) (a k + b)^2}\\ ak+b=a(k+1)\log(k+1)\\ k+\frac ba=k\log(k+1)$$ which we can't solve analytically. It might yield to the Lambert W function. A plot is below, where the horizontal axis is $\frac ba$ and the vertical axis is $k$.