Show $f$ is constant if $|f(x)-f(y)|\leq (x-y)^2$.
For any $x\in\mathbb{R}$, $$ \begin{align} |f'(x)| &=\lim_{h\to0}\frac{|f(x+h)-f(x)|}{|h|}\\ &\le\lim_{h\to0}\frac{h^2}{|h|}\\ &=0 \end{align} $$ Therefore, $f$ is constant.
Here's a proof more elementary.
Let $c=f(0)$, we have to prove that $f(x)=c$ whenever $x\neq0$. Supposing that $n$ is an arbitrary positive integer, we have $$\left|f\left(\frac{m+1}nx\right)-f\left(\frac mnx\right)\right|\le\left(\frac{m+1}nx-\frac mnx\right)^2=\frac{x^2}{n^2}$$ Hence \begin{align*} |f(x)-f(0)| \;&=\;\left|\,\sum_{m=0}^{n-1}\left(f\left(\frac{m+1}nx\right)-f\left(\frac mnx\right)\right)\,\right|\\ &\le\;\sum_{m=0}^{n-1}\,\left|f\left(\frac{m+1}nx\right)-f\left(\frac mnx\right)\right|\\ &\le\;\frac{x^2}n \end{align*} Let $n\to\infty$, we have $|f(x)-f(0)|=0$, thus $f(x)=c$.
It suffices to show that $f'(x)=0$ for all $x\in\mathbb{R}$. We see that the given condition implies
$$\left| \frac{f(x)-f(y)}{x-y} \right| \le |x-y|.$$
So in a $\delta$-neighborhood of $x$, the quotient in definition of the derivative is less than $\delta$. So the limit is 0, and we are done.