Solution (source code)

= Solution

Put $K'=K(1+r)^{t_0-T}$. At the choice time,
$$
 \max(c_{t_0},p_{t_0})=c_{t_0}+(K'-S_{t_0}^1)^+.
$$
Buy a <European call option> of strike $K$ and maturity $T$, together with a <European put option> of strike $K'$ and maturity $t_0$. If the call is selected, the short-maturity put expires worthless. If the put is selected, sell the call and combine its value with the short-maturity put's cash payment; <put-call parity> makes this exactly enough to buy the maturity-$T$ put. This self-financing replication proves
$$
\boxed{\pi(C(K,t_0,T))=\pi(EC(K,T))+\pi(EP(K(1+r)^{t_0-T},t_0)).}
$$
It requires tradability of the priced options at the choice time, but not completeness of every other market claim. The identity also covers $t_0=0$ and $t_0=T$.