SPOJ tutorial problem - taking inputs