Can $ f\colon \mathbb{R}^k \to \mathbb{R}^n$ such that $ \forall y \in \operatorname{im}(f)$, $f^{-1}(y) = \{a_y,b_y\} $ be continuous?
This is the problem we want to solve:
Can $f\colon \mathbb{R}^k \to \mathbb{R}^n$ such that $ \forall y \in \operatorname{im}(f)$, $ f^{-1}(y) = \{a_y,b_y\}, a_y \neq b_y $ be continuous?
Originally I've seen this question on an exam but it was stated only for the case $ k = n = 1 $ and $f$ surjective, which made it really easy to show $f$ can't be continuous, by using the Weierstrass extreme value theorem. A very similar argument seem to work for any $k$, as long as $n=1$. However, for general $k$ and $n$ this seems much harder. I don't see how surjectivity affects this problem, so I've dropped this assumption for now. Edit:Slup commented below, showing the relevance of surjectivity for this question.
Induction on $n$ and looking at projections of $f$ onto individual coordinates seemed tempting at first, but the composition of $f$ with a projection seems to lose any traces of the property that the inverse image of a point = exactly two points, so I don't see how this could be useful.
Trying to visualise this for $k=n=2$, it intuitively seems that in order to transform the space in this way, we would have to 'tear' it along some curve. For bigger $k = n$, that becomes 'tearing' along some $n-1$ dimensional manifold, but that's obviously completely informal, sort of useless and I completely have no idea how this idea could be translated into a formal proof.
Bonus question: Does the answer or the proof change in a significant way if we limit the domain to $ f:\overline{\mathbb{B}^k} \to \mathbb{R}^n $? We operate on a compact ball now, so that's fairly different from $\mathbb{R}^k$.
I did not read the paper of Mioduszewski mentioned in one of the posts. I only have some partial answers when $f$ is more regular than continuous.
If $k\leq n$ and $f:\overline{B}\rightarrow\mathbb{R}^{n}$ (the bonus question) is Lipschitz continuous, then using the area formula for Lipschitz functions (it's in the book of Evans and Gariepy "Measure theory and fine properties of functions") $$ \infty>L\mathcal{L}^{k}(\overline{B})\geq\int_{\overline{B}}Jf\,dx=\int _{\mathbb{R}^{n}}\mathcal{H}^{0}(\overline{B}\cap f^{-1}(\{y\})\,dy=\int _{\mathbb{R}^{n}}2\,dy=\infty, $$ which is a contradiction. Here, $Jf$ is the Jacobian of $f$, $L$ is the bound of $Jf$, and $\mathcal{H}^{0}$ is the counting measure. If $f:\mathbb{R}% ^{k}\rightarrow\mathbb{R}^{n}$ is Lipschitz continuous and $Jf$ has finite integral, you get the same contradiction.
If $k>n$ and $f\in C^{k+1-n}(\mathbb{R}^{k})$, then using Sard's theorem https://en.wikipedia.org/wiki/Sard's_theorem the set of points $\{x\in \mathbb{R}^{k}:\,Jf(x)=0\}\cap f^{-1}(\{y\})$ is empty for $\mathcal{L}^{n}$ a.e. $y\in\mathbb{R}^{n}$. Hence, if $f$ is onto or if $f(\mathbb{R}^{k})$ has positive measure, then taking $y\in f(\mathbb{R}^{k})$ such that $\{x\in\mathbb{R}^{k}:\,Jf(x)=0\}\cap f^{-1}(\{y\})=\emptyset$, we get that $Jf(x)$ has rank $n$ and so we can apply the implicit function theorem to conclude that $f^{-1}(\{y\}$ is locally the graph of a function. In particular $f^{-1}(\{y\})$ cannot consists of two points.