Initially there is 1 stone on top of every unit square of the m*n-sized board. Outside the board there was an infinite supply of stones. Andy plays using the board and stones as follows: each step, Andy can choose one of 3 moves:
Select a non-empty square that is not in the leftmost column. take one stone from the square and place 2 stones in the square to the left
Select a non-empty square that is not in the bottom row. take one stone from the square and place 2 stones in the square below it
Select 2 adjacent non-empty squares. Take one stone from the 2 unit squares
prove that Andy can take all the stones if and only if m*n is even
I've tried using invariant but stuck.
Let's index the rows from $0$ to $n-1$ from bottom to top, and index the columns from $0$ to $m-1$ from left to right.
Then we say a single stone on the square $(i,j)$ has cost $2^{i+j}$, then the total cost of the board at the start is $\displaystyle\sum_{i=0}^{n-1} \sum_{j=0}^{m-1} 2^{i+j} = (2^n-1)(2^m-1) \equiv nm-2\left\lfloor\frac{nm}{2}\right\rfloor \pmod3$. Then any moves of type $1$ and $2$ has $0$ effect on this total cost. For any move of type $3$, it will decrease this cost by $2^k + 2^{k+1}$ for some $k\in Z, 0\le k< n+m-2$. Also $2^k + 2^{k+1} = 3\cdot2^k \equiv 0 \pmod 3$.
So you can take the invariant of the total cost$\mod 3$, and use it to show that the invariant never gets to zero which is the cost of the final state.