Solution (source code)

= Solution

The answer is the <monotone rearrangement>
$$
\boxed{T(x)=G^{-1}(F(x)),\qquad \pi=(\operatorname{Id},T)_*\mu.}
$$
It pushes $\mu$ to $\nu$ by the same cumulative-distribution argument as in part (a).

For the squared <transport cost>, the two-point swap difference is
$$
(y_1-x_1)^2+(y_2-x_2)^2-(y_2-x_1)^2-(y_1-x_2)^2
=-2(x_2-x_1)(y_2-y_1).
$$
Thus any optimal support has no crossed pairs: $x_1<x_2$ forces $y_1\le y_2$. This follows from the finite-cost converse proved above; every cost here is bounded. Conversely, an increasing graph is <c-cyclically monotone> for this cost. After removing the marginal terms $\sum x_i^2+\sum y_i^2$, the cycle inequalities say that pairing the sorted $x_i$ and $y_i$ maximizes $\sum x_iy_i$. Exchanging any inverted pairing increases that sum by the nonnegative product of the two differences, so repeated exchanges prove the inequality. Therefore the displayed increasing transport is optimal.

For uniqueness, let $\pi$ be any noncrossing coupling. The sets $A=\{x\le a\}$ and $B=\{y\le b\}$ cannot both have positive mass in $A\setminus B$ and $B\setminus A$: a point from each would give a strictly crossed pair. Consequently one of these differences has zero mass, and
$$
\pi\{x\le a,y\le b\}=\min\{F(a),G(b)\}.
$$
This determines the joint distribution uniquely and is exactly the distribution of the common-quantile coupling $(F^{-1}(U),G^{-1}(U))$ for uniform $U$. Since $F$ is continuous and strictly increasing, that coupling is induced by $T=G^{-1}F$. Hence \b[there is one optimal deterministic plan, with maps differing only on $\mu$-null sets]; in fact it is the unique optimal coupling. This proves the <one-dimensional quadratic transport uniqueness criterion> directly.