Is a function $X \times Y \to Z$ continuous iff precomposition with continuous functions $X\to X\times Y$ and $Y\to X\times Y$ are continuous
Let
$$X=\Bbb R \text{ with the usual topology};$$ $$Y=\Bbb R \text{ with the cocountable topology };$$ $$Z=\Bbb R \text{ with the cofinite topology};$$ $$f:X\times Y\rightarrow Z$$ $$f(x,y)= \begin{cases} \frac{xy}{x^2+y^2}, & \text{if } (x,y)\neq(0,0) \\[2ex] 0, & \text{if } (x,y)=(0,0) \end{cases} $$
Then $f$ is not continuous, otherwise, $f$ restricted to the diagonal $\Delta$ of $X\times Y$ will be continuous. But $f(x,x)=\frac{1}{2}$ for $(x,x)\neq (0,0)$; Thus $(f|_{\Delta})^{-1}(\frac{1}{2})=\Delta \setminus \{(0,0)\}$, which is not closed in $\Delta$, though $\{\frac{1}{2}\}$ is closed in $Z$.
Lemma 1:
Every continuous function $g:\Bbb R \to \Bbb R_{\text{cocountable}}$ must be constant.
proof: $f(\Bbb Q)$ is countable, hence closed in $\Bbb R_{\text{cocountable}}$. $f^{-1}(f(\Bbb Q))$ is a closed set containing $\Bbb Q$, hence equal to $\Bbb R$. $f^{-1}(f(\Bbb Q))=\Bbb R$ implies $f(\Bbb R)=f(f^{-1}(f(\Bbb Q)))\subseteq f(\Bbb Q) $, hence $f(\Bbb R)$ is countable. A countable, connected subset of $\Bbb R_{\text{cocountable}}$ must be a one-point set. Hence $f$ is constant. $\square$
Claim 1:
For every continuous function $g: \Bbb R \to \Bbb R\times \Bbb R_{\text{cocountable}}$, the image must be contained in $\Bbb R\times \{y_0\}$ for some $y_0$.
proof: $\pi_2\circ g$ is a continuous function from $\Bbb R$ to $\Bbb R_{\text{cocountable}}$. ($\pi_2$ is the projection onto the second coordinate). By lemma 1, $\pi_2\circ g$ is constant. Hence the result follows. $\square$
Hence for every continuous function $g: \Bbb R \to \Bbb R\times \Bbb R_{\text{cocountable}}$, the precomposition $f\circ g:\Bbb R\to \Bbb R_{\text{cofinite}}$ is equal to $f(x,y_0)=\frac{x^2y_0^2}{x^2+y_0^2}$ ($y_0$ fixed). Replacing $\Bbb R_{\text{cofinite}}$ by the finer topology $\Bbb R$, the function is easily seen to be continuous by standard calculus argument. Hence $f\circ g:\Bbb R\to \Bbb R_{\text{cofinite}}$ is continuous.
Lemma 2:
Every continuous function $h:\Bbb R_{\text{cocountable}} \to \Bbb R$ must be constant.
proof: (continuity on co-countable topology drhab's answer) Let $h$ be such a function with e.g. $0,1\in h\left(\mathbb{R}\right)$. Suppose $f$ is continuous and let $D_0,D_1$ be disjoint open sets containing $0$ and $1$ respectively. Then $h^{-1}\left(D_0 \right)$ and $h^{-1}\left(D_1\right)$ must be disjoint sets both having a countable complement. Then $h^{-1}\left(D_0\right)$ as a subset of the complement of $h^{-1}\left(D_1\right)$ is countable and consequently $\mathbb{R}=h^{-1}\left(D_0 \right)\cup h^{-1}\left(D_0\right)^{c}$ is countable. Contradiction. $\square$
Claim 2:
For every continuous function $h: \Bbb R_{\text{cocountable}} \to \Bbb R\times \Bbb R_{\text{cocountable}}$, the image must be contained in $\{x_0\}\times\Bbb R_{\text{cocountable}}$ for some $x_0$.
proof: $\pi_1\circ h$ is a continuous function from $\Bbb R_{\text{cocuntable}}$ to $\Bbb R$. ($\pi_1$ is the projection onto the first coordinate). By lemma 2, $\pi_1\circ h$ is constant. Hence the result follows. $\square$
Hence for every continuous function $h: \Bbb R_{\text{cocountable}} \to \Bbb R\times \Bbb R_{\text{cocountable}}$, the precomposition $f\circ h:\Bbb R_{\text{cocountable}}\to \Bbb R_{\text{cofinite}}$ is equal to $f(x_0,y)=\frac{x_0^2y^2}{x_0^2+y^2}$ ($x_0$ fixed). $(f\circ h)^{-1}(A)$ is closed (i.e. countable) for every closed (i.e. finite) set $A$. In fact, the preimage of each element can have cardinality at most $2$ (by looking at the $\text{graph}^1$). Hence $f\circ h:\Bbb R_{\text{cocountable}}\to \Bbb R_{\text{cofinite}}$ is continuous.
$^1$