SPOJ's solutions in Haskell