Below is my solution to the Codeforces div2 735 problem D: Diane.
We want to find the simplest way to construct a string $s$ which has no substrings occuring an odd number of times. Let us consider the string $a^{k}$. If $k$ is even then we have the followin substring properties.
If $k$ is odd, then we have the opposite parities. Observe that if we could separate $a^k$ and $a^{k+1}$ then because $k$ and $k+1$ have opposite parity, the substrings each occur an odd number of times.
Thus $s=a^kba^{k+1}$ generates strings of length $2k+2$, i.e. $2, 4, 6, \cdots$. Furthermore, $s=a^kbca^{k+1}$ generates strings of length $2k+3$, i.e. $3, 5, 7, \cdots$. Finally, if $n=1$, we trivially set $s=a$. Note the time required to print out the string is $O(n)$, so this solution passes.
