Switch to ByteString for better performance and submit to SPOJ