SPOJ submission 10059195