SPOJ 18 problems solved