more aizu/hackerrank. optimized Haskell