My ACM code almost in UVa