My solution to Timus Online Judge