transfer; algorithm works, but not in UVA