Let $f: X \to X$ be such that $d(f(x), f(y)) = d(x, y)$ for all $x, y \in X$. To show that $f$ is onto.
Let $(X,d)$ be a compact metric space. Let $f: X \to X$ be such that $d(f(x),f(y)) = d(x,y)$ for all $x,y \in X$. Show that $f $ is onto (surjective).