This is a question from Pugh's Real Mathematical Analysis that I'm looking for a solution for.
Suppose $f:\mathbb{R}^2\to \mathbb{R}$ is a function such that for constant $y_0,x_0$, we have that $x\mapsto (x,y_0)$, $y\mapsto (x_0,y)$ are continuous functions and for any compact $S$, $f(S)$ is compact. Show that $f$ is continuous.
I know this does not hold without the assumption of preserving compactness, however I don't see how the new assumption would play in the formation of a proof.
Sketch of Proof: Suppose $f$ is not continuous at some point $(x_0, y_0)$, then there exists $\varepsilon>0$ and some sequence $(x_n, y_n)$ converging to $(x_0, y_0)$ such that \begin{align} |f(x_n, y_n)-f(x_0, y_0)|\geq \varepsilon. \end{align}
WLOG, take a sequence $\{(x_n, y_n)\}$ such that $x_n$ and $y_n$ converges to $x_0, y_0$ strictly monotonically. Since $\{(x_n, y_n)\}^\infty_{n=0}$ is compact then $\{f(x_n, y_n)\}^\infty_{n=0}$ is compact. Let $f(x_L, y_L)$ be the limit point of $\{f(x_n, y_n)\}$ for some $(x_L, y_L) \neq (x_0, y_0)$.
We can now pass to a subsequence $(x_{n_k}, y_{n_k})$ such that $f(x_{n_k}, y_{n_k})$ converges strictly monotonically to $f(x_L, y_L)$. Now consider $S=\{(x_{n_k}, y_{n_k})\}^\infty_{k=0}\backslash\{(x_L, y_L)\}$ which is also compact since the only limit is $(x_0, y_0)$. Finally $f(S)$ is also compact. But $f(S)$ cannot be compact since there does not exists $(x_{n_k}, y_{n_k}) \in S$ such that $f(x_{n_k}, y_{n_k}) = f(x_L, y_L)$.