SPOJ submission 10055185