code submitted to Sphere Online Judge (http://www.spoj.com)