[step:Pass from pairs with $Y_j<X_i$ to pairs with $X_i<Y_j$]
Let $C_-$ be the set
\begin{align*}
C_- &:= \{(i,j) \in \{1,\dots,m\} \times \{1,\dots,n\} : Y_j < X_i\}.
\end{align*}
Let $C_+$ be the set
\begin{align*}
C_+ &:= \{(i,j) \in \{1,\dots,m\} \times \{1,\dots,n\} : X_i < Y_j\}.
\end{align*}
For each cross-pair $(i,j)$, pairwise distinctness excludes $X_i=Y_j$, so exactly one of $Y_j<X_i$ and $X_i<Y_j$ holds. Therefore $C_-$ and $C_+$ partition the Cartesian product $\{1,\dots,m\}\times\{1,\dots,n\}$, whose cardinality is $mn$. Thus
\begin{align*}
\#C_+ = mn-\#C_-.
\end{align*}
Using the previous step and the definition $U_{m,n}=\#C_+$,
\begin{align*}
U_{m,n}
= mn-\left(S_X-\frac{m(m+1)}{2}\right)
= mn+\frac{m(m+1)}{2}-S_X.
\end{align*}
Since $S_X=\sum_{i=1}^m R_i$, this is precisely
\begin{align*}
U_{m,n}=mn+\frac{m(m+1)}{2}-\sum_{i=1}^m R_i.
\end{align*}
The same affine identity also gives
\begin{align*}
S_X = mn+\frac{m(m+1)}{2}-U_{m,n},
\end{align*}
so $U_{m,n}$ and $S_X$ determine each other uniquely.
[/step]