import Data.List import Control.Lens import Control.Arrow main :: IO () main = do input <- lines <$> readFile "input" let counts = map ((\[x,y]->x>y) . map length . group . sort) $ transpose input let (gamma,epsilon) = boolToDec *** boolToDec $ (id &&& map not) counts print $ gamma * epsilon boolToDec :: [Bool] -> Int boolToDec = sum . imap (\x y->(2^x)*y) . reverse . map fromEnum