SPOJ submission 10055039