TITLE: Non-isomorphic groups with isomorphic nth powers (and similarly in other categories)
QUESTION [7 upvotes]: What's the simplest example (if any) of two non-isomorphic groups G and H such that $G \times G \cong H \times H$? A similar question can be asked for $n^{th}$ powers for fixed $n > 1$.
The Krull-Remak-Schmidt theorem guarantees a "unique factorization" into direct products of directly indecomposable groups. It applies to finite groups, and more generally for groups that satisfy both the ascending and descending chain conditions on normal subgroups. 
Wherever such a unique factorization holds, it would follow that isomorphic $n^{th}$ powers implies isomorphic groups (by the usual expedient on counting the multiplicities of each directly indecomposable factor on both sides). So, counterexamples must be infinite at the very least.
However, I'm not able to come up with any counterexample nor can I see an easy proof. [EDIT: Resolved now in one of the answers. The question below still seems open.]
Also related: can we have groups G,H such that $G^2 \cong H^3$ but G is not the cube of any group and H is not the square of any group? Again, this fails in the cases where we have a unique factorization, because we can count multiplicities of indecomposables. $2$ and $3$ can be replaced by any two relatively prime numbers above.
Incidentally, this is somewhat related to an earlier question on Math Overflow: When is A isomorphic to A^3?
A similar question can probably be asked in many other categories.

REPLY [7 votes]: Concerning a "similar question ... in ... other categories": this is not an uncommon phenomenon for modules over many familiar rings. I note that the example A above is an abelian group, i.e. a Z-module, albeit a fairly involved one; replacing Z with a larger ring leads to more mundane (and, in particular, finitely generated) examples. 
The first Weyl algebra $A_1=k[x,y]/(xy-yx-1)$ (k is a field of characteristic zero) is a Noetherian simple noncommutative domain which is not a principal ideal ring: e.g. the right ideal $I=(x^2, 1+xy)$ is not principal, hence not isomorphic to $A_1$ as a module. Weyl algebra $A_1$ has two more interesting properties: (1) it is hererditary, i.e. every right ideal is a projective module; (2) every projective module over $A_1$ of uniform dimension $r\geq 2$ is free. It follows that $I\oplus I$ is isomorphic to $A_1\oplus A_1,$ although $I$ and $A_1$ aren't isomorphic. To get a commutative example with this flavor, take $R$ to be your favorite Dedekind domain whose class group has an even order (e.g. $Z[\sqrt{10}]$) and $I$ an ideal of order 2 in $Cl(R)$. Then $I\oplus I\simeq R\oplus I^2\simeq R\oplus R$, yet $I$ isn't principal. For details of these examples (and much more), see McConnell and Robson, Noncommutative Noetherian Rings, especially Chapter 11 dealing with stable freeness.