Haskell で AtCoder Beginners Selection

## PracticeA - Welcome to AtCoder
[問題](https://atcoder.jp/contests/abs/tasks/practice_1 "Welcome to AtCoder")
```hs
main :: IO ()
main = do
    a <- readLn
    bc <- fmap (read :: String -> Int) . words <$> getLine
    s <- getLine
    putStr ((show (a + (bc !! 0) + (bc !! 1))) ++ " " ++ s)
    return ()
```

## ABC086A - Product
[問題](https://atcoder.jp/contests/abs/tasks/abc086_a "Product")
```hs
main :: IO ()
main = do
    [a, b] <- fmap (read :: [Char] -> Int) . words <$> getLine
    let x = a * b
    if odd x
        then putStr "Odd"
        else putStr "Even"
```

## ABC081A - Placing Marbles
[問題](https://atcoder.jp/contests/abs/tasks/abc081_a "Placing Marbles")
```hs
main :: IO ()
main = do
    x <- fmap (\x -> (read :: [Char] -> Int) [x]) <$> getLine
    print $ sum x
```

## ABC081B - Shift only
[問題](https://atcoder.jp/contests/abs/tasks/abc081_b "Shift only")
```hs
fun :: (Integral t, Num p) => t -> p
fun x = if even x
    then 1 + fun (x `div` 2)
    else 0

main :: IO ()
main = do
    ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
    print $ minimum (map fun (ns !! 1))
```

## ABC087B - Coins
[問題](https://atcoder.jp/contests/abs/tasks/abc087_b "Coins")
```hs
main :: IO ()
main = do
    [[a], [b], [c], [x]] <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
    print $ length ([() | o <- [0 .. a], p <- [0 .. b], q <- [0 .. c], 500 * o + 100 * p + 50 * q == x])
```

## ABC083B - Some Sums
[問題](https://atcoder.jp/contests/abs/tasks/abc083_b "Some Sums")
```hs
fun :: Show a => a -> Int
fun x = sum [(read :: [Char] -> Int) [c] | c <- show x]

main :: IO ()
main = do
    [n, a, b] <- fmap (read :: [Char] -> Int) . words <$> getLine
    print $ sum [x | x <- [1 .. n], let s = fun x, a <= s, b >= s]
```

## ABC088B - Card Game for Two
[問題](https://atcoder.jp/contests/abs/tasks/abc088_b "Card Game for Two")
```hs
import Data.List ( sort )

main :: IO ()
main = do
    (n:ns) <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
    let
        list = zip (reverse (sort (head ns))) [1 .. (head n)]
        od = sum [a | (a, b) <- list, odd b]
        ev = sum [a | (a, b) <- list, even b]

    print $ abs (od - ev)
```

## ABC085B - Kagami Mochi 
[問題](https://atcoder.jp/contests/abs/tasks/abc085_b "Kagami Mochi")
```hs
import Data.List ( nub, transpose )

main :: IO ()
main = do
    (n:ns) <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
    let list = head $ transpose ns
    print $ length $ nub list
```

## ABC085C - Otoshidama 
[問題](https://atcoder.jp/contests/abs/tasks/abc085_c "Otoshidama")
```hs
main :: IO ()
main = do
    [n, y] <- fmap (read :: [Char] -> Integer) . words <$> getLine
    let
        (m, y1) = (y `div` 10000, y `mod` 10000)
        (g, y2) = (y1 `div` 5000, y1 `mod` 5000)
        (s, y3) = (y2 `div` 1000, y2 `mod` 1000)
    
    (\(a, b, c) -> putStr (show a ++ " " ++ show b ++ " " ++ show c)) $ fun m g s n

fun :: (Num a, Ord a) => a -> a -> a -> a -> (a, a, a)
fun m g s n
    | p == n = (m, g, s)
    | p > n = (-1, -1, -1)
    | p < n && m >= 1 = fun (m - 1) (g + 2) s n
    | p < n && g >= 7 = fun (m + 3) (g - 7) (s + 5) n
    | p < n && g >= 5 = fun (m + 2) (g - 5) (s + 5) n
    | p < n && g >= 3 = fun (m + 1) (g - 3) (s + 5) n
    | p < n && g >= 1 = fun m (g - 1) (s + 5) n
    | otherwise = (-1, -1, -1)
    where p = m + g + s
```

## ABC049C - 白昼夢
[問題](https://atcoder.jp/contests/abs/tasks/arc065_a "白昼夢")
```hs
import Data.List ( isPrefixOf )

main :: IO ()
main = do
    s <- getLine

    if fun $ reverse s
        then putStr "YES"
        else putStr "NO"

fun :: [Char] -> Bool
fun [] = True
fun l
    | "maerd" `isPrefixOf` l = fun $ drop 5 l
    | "remaerd" `isPrefixOf` l = fun $ drop 7 l
    | "esare" `isPrefixOf` l = fun $ drop 5 l
    | "resare" `isPrefixOf` l = fun $ drop 6 l
    | otherwise = False
```

## ABC086C - Traveling
[問題](https://atcoder.jp/contests/abs/tasks/arc089_a "Traveling")
```hs
fun :: Integral a => a -> a -> a -> a -> a -> Bool
fun x y a b t = man <= t && even (man - t)
    where man = abs (x - a) + abs (y - b)

fun2 :: Integral t => t -> t -> t -> [[t]] -> Bool
fun2 _ _ _ [] = True
fun2 x y t (l:ls) = fun x y x1 y1 (t1 - t) && fun2 x1 y1 t1 ls
    where [t1, x1, y1] = l

main :: IO ()
main = do
    (n:ns) <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
    if fun2 0 0 0 ns
        then putStr "Yes"
        else putStr "No"
```