This question already has an answer here:

- when is A isomorphic to A^3? 4 answers

Let $G,H$ groups. Suppose that $G \times G \cong H \times H$. Then is necessarily $G \cong H$?

I know that if $G,H$ are finite groups then it is true (you show that the map $FinGrp \rightarrow \mathbb{N}$, $A \mapsto \left|Hom(A,G)\right| $ determines $G$, and then $\left|Hom(A,G)\right|=\sqrt{\left|Hom(A,G\times G)\right|}=\sqrt{\left|Hom(A,H\times H)\right|}=\left|Hom(A,H)\right|$), so I am interested in the infinite case.

Note that the proof for the finite case also works for finite topological spaces, finite graphs, and maybe other categories I didn't consider. So I also interested on the analogous questions about infinite topological spaces, infinite graphs, or any other interesting category.