Solution (source code)

= Solution

Let $k_0$ be the unique <discrete logarithm> of the measured value $c_0$, so that $c_0=g^{k_0}$. The <fiber> calculation gives exactly the pairs $(yb+k_0,b)$ with $b\in\mathbb Z_M$, where $M=p-1$. The initial amplitude of each pair is $1/M$, so the <Born rule> assigns probability $M/M^2=1/M$ to this outcome.

After <projective measurement> and normalization, the first two <quantum registers> are in the <coset state>
$$
\boxed{|C_{k_0}\rangle=\frac1{\sqrt M}\sum_{b=0}^{M-1}|yb+k_0\bmod M\rangle|b\rangle.}
$$
The measured third <quantum register> factors as $|c_0\rangle$ and may be omitted. There is no loss of coherence between the $M$ terms in this <post-measurement state>: the <quantum measurement> reveals the common function value, not an individual input pair.