Solution (source code)

= Solution

By the <Heine-Borel theorem>, a noncompact <subset> $X\subseteq\mathbb R$ is either <unbounded> or not <closed>. If $X$ is <unbounded>, the restriction $f(x)=x$ is a <continuous function> with <unbounded> range.

Otherwise $X$ is <bounded> and not <closed>. Choose $a\in\overline X\setminus X$, and define
$$
\boxed{f(x)=\frac1{|x-a|},\qquad x\in X.}
$$
Its denominator is nonzero on $X$, so it is <continuous>. Since $a$ is in the <closure>, for every $n$ there is $x_n\in X$ with $0<|x_n-a|<1/n$. Hence $f(x_n)>n$, proving that this <continuous function> is <unbounded>. These two cases establish <unbounded continuous witnesses to noncompactness of a real subspace>.