{"source_code": "-- import Debug.Trace\n\ndays a b per cnt\n | b == per = (days (a+1) b 0 (cnt))\n | a == 0 = cnt\n | otherwise = (days (a-1) b (per+1) (cnt+1))\n\n\nmain = do\n ww <- getLine\n let aa = (read (head (words ww)))::Int\n bb = (read (last (words ww)))::Int\n \n hh = days aa bb 0 0\n putStrLn (show hh)\n\n\n\n\n", "positive_code": [{"source_code": "main = do\n line <- getLine\n let [n, m] = map read $ words line :: [Int]\n print $ solve n m\n \nsolve :: Int -> Int -> Int\nsolve n m = f n m 1\n where f socks m days\n | socks == 0 = days -1\n | days `mod` m == 0 = f socks m (days+1)\n | otherwise = f (socks - 1) m (days + 1)"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\nimport Control.Applicative\nimport Control.Monad\n\n\nprocess m cur days\n | cur == 0 = days\n | otherwise = process m (cur-1 + if days `mod` m == 0 then 1 else 0) (days+1)\n\nmain = do\n [n,m] :: [Int] <- map read . words <$> getLine\n print $ process m n 0 - 1\n"}, {"source_code": "days :: Int -> Int -> Int -> Int\ndays d 0 _ = d - 1\ndays d n m = let ads = if d `mod` m == 0\n then 1\n else 0\n in days (d + 1) (n - 1 + ads) m\n\nmain = do \n twoInts <- getLine\n let [n, m] = map (read::String->Int) $ words twoInts\n print $ days 1 n m\n"}, {"source_code": "module Main (main)\n where\n\n\nmain :: IO ()\nmain = print . solve 1 . take 2 . map read . words =<< getLine\n where solve c [0,_] = c - 1\n solve c [n,m] = let r = if c `mod` m == 0 then 1 else 0\n in solve (c + 1) [n - 1 + r,m]"}, {"source_code": "main = do\n\tt <-getLine\n\tlet [n,m] = map read $ words t\n\tputStrLn $ show $ solve n m 1\n\nsolve 0 m c = c-1\nsolve n m c = if mod c m == 0 then solve n m (c+1) else solve (n-1) m (c+1)"}, {"source_code": "solve :: [Int] -> Int\nsolve [n, m] = solve' 1 n\n where\n solve' :: Int -> Int -> Int\n solve' d 0 = 0\n solve' d n | (mod d m) == 0 = 1 + solve' 1 n\n | otherwise = 1 + solve' (d + 1) (n - 1)\n\nmain :: IO()\nmain = getLine >>=\n print . solve . map read . words"}, {"source_code": "{-# LANGUAGE NoMonomorphismRestriction #-}\nimport Control.Applicative ((<$>))\nimport Control.Monad\nimport Text.Printf (printf)\nimport Data.Maybe (Maybe, fromMaybe)\nimport Data.List (sort, foldl')\nimport qualified Data.Map as M\nimport qualified Data.ByteString.Char8 as BS\n\nsolve _ 0 _ = 0\nsolve k n m = 1 + solve (k + 1) nn m\n where nn = n - if k `mod` m == 0 then 0 else 1\n\nmain :: IO ()\nmain = do\n [n, m] <- getInts\n print $ solve 1 n m\n\ntoNumber = fst . fromMaybe (0, BS.pack \"\")\ngetInt = toNumber . BS.readInt <$> BS.getLine\ngetInts = (map (toNumber . BS.readInt) <$> (BS.words <$> BS.getLine))\ncountup = foldl' (\\x y -> M.insertWith' (+) y 1 x) M.empty\ncountof m x = M.findWithDefault 0 x m\n"}, {"source_code": "import Data.List\nimport Data.Function\nimport Data.Char\nimport Data.Maybe\nimport qualified Data.ByteString.Lazy.Char8 as B\n\ngetIntArray :: B.ByteString -> [Int]\ngetIntArray = map fst . mapMaybe B.readInt . B.words\n\nmain = B.interact $ B.pack . show . getAns . getIntArray\n\ngetAns (n:m:_) = solveS 0 n (n `div` m) m\n\nsolveS p d n m\n\t| p == n = d\n\t| otherwise = solveS n (d + n - p) ((d + n - p) `div` m) m\n"}, {"source_code": "main = do\n [n, m] <- fmap (map read . words) getLine\n let\n count d 0 = d - 1\n count d n = if d `mod` m == 0 then count (d+1) n else count (d+1) (n-1)\n\n print $ count 1 n\n"}, {"source_code": "import Data.List\nimport Data.Maybe\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ show.solve.map read.words.head . lines\nsolve :: [Int]->Int\nsolve [x,y] = solve2 [x,0] --(sum $ solve2 [x]) `div` y\n where \n -- solve2 (0:zs) = []\n -- solve2 (z:zs) = solve2 [z `div` y]++[z]\n solve2 [0,b] = b\n solve2 [a,b] = solve2 [((b `mod` y)+a) `div` y,a+b]"}, {"source_code": "calc :: Int -> Int -> Int -> Int\ncalc 0 d m = d - 1\ncalc n d m\n | d `mod` m == 0 = calc n (d + 1) m\n | otherwise = calc (n - 1) (d + 1) m\n\nmain = do\n line <- getLine\n let ns = map read (words line) :: [Int]\n print $ calc (ns !! 0) 1 (ns !! 1) \n"}, {"source_code": "import Control.Monad;\nimport Data.List;\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Integer] -> Integer\nsolve [m, n] \n | m >= n = (n+) $ solve [m - n + 1, n]\n | otherwise = m"}, {"source_code": "process :: Int -> Int -> Int\nprocess n m = n + ((n-1) `div` (m-1))\n\nreadInt :: String -> Int\nreadInt = read\n\nmain = do\n [n,m] <- fmap (map readInt.words) getLine\n print $ process n m"}, {"source_code": "import Control.Applicative\n\nmain = do\n [n,m] <- map read . words <$> getLine\n print $ n + div (n-1) (m-1)"}, {"source_code": "readNumbers :: String -> [Integer]\nreadNumbers = map read . words\n\ncountSocks a b c | a < b = c + a\n | otherwise = countSocks (a - b + 1) b (c + b)\n \nsolve (a:b:[]) = putStrLn $ show $ countSocks a b 0\nmain = getLine >>= \\x -> solve $ readNumbers x\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.Char\n\nprocess m n d | m>=n = process (m-n+1) n (d+n)\n | otherwise = d+m\n\n\nmain=do\n\n [m,n]<- map read <$> words <$> getLine ::IO [Int]\n print $ process m n 0\n"}, {"source_code": "socks :: Int -> Int -> Int -> Int\nsocks 0 _ _ = 0\nsocks n m d = 1 + socks (n - 1 + new) m (d + 1)\n where new = if (d `rem` m == 0) then 1 else 0\n\nsolve :: String -> String\nsolve s = show $ socks n m 1\n where (n:m:_) = (fmap read . words) s\n\nmain :: IO ()\nmain = interact $ solve"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Int] -> Int\nsolve [n, m] = go n 1\n where go 0 d = d - 1\n go k d | d `mod` m == 0 = go k (d + 1)\n | otherwise = go (k - 1) (d + 1)\n"}, {"source_code": "import Prelude hiding (readList, showList)\nimport Control.Monad\nimport Control.Arrow\nimport Control.Applicative\nimport Data.List\n\nreadList :: Read a => IO [a]\nreadList = fmap (fmap read . words) getLine\n\nreadList' :: Read a => a -> IO [a]\nreadList' _ = readList\n\nreadInt :: IO Int\nreadInt = head <$> readList' (undefined::Int)\n\nshowList :: Show a => [a] -> IO ()\nshowList = putStrLn . unwords . map show\n\nskipLine :: IO ()\nskipLine = void $ getLine\n\ncount :: (a -> Bool) -> [a] -> Int\ncount f = length . filter f\n\ndivUp :: Integral a => a -> a -> a\ndivUp x y \n | x `mod` y /= 0 = x `div` y + 1\n | otherwise = x `div` y\n\nu :: a\nu = undefined\n\nstep :: Int -> Int -> Int -> Int\nstep m curr day\n | curr == 0 = day-1\n | day `mod` m == 0 = step m curr (day+1)\n | otherwise = step m (curr-1) (day+1)\n\nmain :: IO ()\nmain = do\n [n,m] <- readList' (u :: Int)\n print $ step m n 1\n"}, {"source_code": "main = do\n [n,m] <- fmap (map read . words) getLine\n solve 1 n m\nsolve d 0 _ = print (d-1)\nsolve d n m = solve (d+1) (n-1+b) m\n where b | d `mod` m == 0 = 1\n | otherwise = 0"}, {"source_code": "days 0 m t = t - 1\ndays n m t = if t `mod` m == 0 then days n m (t+1) \n else days (n-1) m (t+1)\nmain = do\n [n, m] <- fmap (map read . words) getLine\n print $ days n m 1\n"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/460/A\n\nsolve :: Int -> Int -> Int -> Int\nsolve 0 _ _ = 0\nsolve n m d = 1 + solve (n-1+new) m (d+1)\n where new = if (d `rem` m == 0) then 1 else 0\n\nmain :: IO ()\nmain = do\n [n, m] <- map read . words <$> getLine :: IO [Int]\n print $ solve n m 1\n"}, {"source_code": "f n m = f' n m 1\n where f' socks m days | socks == 0 = days-1\n | days `mod` m == 0 = f' socks m (days+1)\n | otherwise = f' (socks-1) m (days+1)\nmain = do\n line <- getLine\n let [n,m] = map read $ words line :: [Int]\n ans = f n m\n print ans\n"}, {"source_code": "module Main where\n\nimport Data.Maybe (fromJust)\nimport qualified Data.ByteString.Char8 as BS\n\nreadNumbers :: IO [Int]\nreadNumbers =\n (fromJust\n . fmap (map fst)\n . sequence\n . map BS.readInt\n . BS.words) `fmap` BS.getLine\n\nmain :: IO ()\nmain = do\n (n:m:[]) <- readNumbers\n loop n m n 0\n where\n loop n m pairCount days\n | pairCount == 0 = print (pred days)\n | otherwise =\n if days `mod` m == 0\n then\n loop n m pairCount (succ days)\n else\n loop n m (pred pairCount) (succ days)\n"}, {"source_code": "days n m \n | (n >= m) = m + (days (n-m+1) (m))\n | otherwise = n\n\nmain = do\n line <- getLine\n let [n, m] = map read $ words line\n print $ days n m\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\n \nprocess n m x | n==0 = x\n | n getLine ::IO [Int]\n\tif (n 0 then\n f' n m (s + (quot n (m ^ a))) (a+1)\n else\n s\nmain = do\n line <- getLine\n let [n,m] = map read $ words line :: [Int]\n ans = n + (f n m)\n print ans\n"}, {"source_code": "main = do\n line <- getLine\n let [n,m] = map read $ words line :: [Int]\n ans = n + (quot n m) + (quot (quot n m) m)\n print ans\n"}, {"source_code": "f n m = f' n m 1\n where f' socks m days | socks == 1 = days +1\n | days `mod` m == 0 = f' socks m (days+1)\n | otherwise = f' (socks-1) m (days+1)\nmain = do\n line <- getLine\n let [n,m] = map read $ words line :: [Int]\n ans = f n m\n print ans\n"}, {"source_code": "module Main (main)\n where\n\n\nmain :: IO ()\nmain = print . solve . take 2 . map read . words =<< getLine\n where solve [0,_] = 0\n solve [1,_] = 1\n solve [n,m] = n + solve [n `div` m,m]"}, {"source_code": "import Data.List\nimport Data.Maybe\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ show.solve.map read.words.head . lines\nsolve :: [Int]->Int\nsolve [x,y] = sum $ solve2 [x]\n where \n solve2 (0:zs) = []\n solve2 (z:zs) = solve2 [z `div` y]++[z]"}, {"source_code": "import Data.List\nimport Data.Maybe\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ show.solve.map read.words.head . lines\nsolve :: [Int]->Int\nsolve [x,y] =x+(sum $ solve2 [x]) `div` y\n where \n solve2 (0:zs) = []\n solve2 (z:zs) = solve2 [z `div` y]++[z]"}, {"source_code": "import Control.Applicative\n\nmain = do\n [n,m] <- map read . words <$> getLine\n let days = iterate (`div`m) n\n print . sum $ takeWhile (/=0) days"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Int] -> Int\nsolve [n, m] = go n 0\n where go 0 d = d\n go k d | d `mod` m == 1 = go k (d + 1)\n | otherwise = go (k - 1) (d + 1)\n"}, {"source_code": "module Main where\n\nimport Data.Maybe (fromJust)\nimport qualified Data.ByteString.Char8 as BS\n\nreadNumbers :: IO [Int]\nreadNumbers =\n (fromJust\n . fmap (map fst)\n . sequence\n . map BS.readInt\n . BS.words) `fmap` BS.getLine\n\nmain :: IO ()\nmain = do\n (n:m:[]) <- readNumbers\n let remainingDays = n `div` m\n diff = remainingDays `div` m\n print $ case () of\n _ | m > n -> n\n | otherwise -> n + remainingDays + diff\n"}], "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0"} {"source_code": "import Control.Applicative\nimport Data.List\n \n \n \nmain=do\t \n\t[r,c]<- map read.words <$> getLine:: IO [Int]\n\ts<- lines <$> getContents\n\tlet t = transpose s\n\tlet rr = length $ filter (\\z-> notElem 'S' z) s\n\tlet cc = length $ filter (\\z-> notElem 'S' z) t\n\tprint $ rr*c + cc*(r-rr)", "positive_code": [{"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad hiding ((<$!>))\nimport Control.Monad.ST.Safe\nimport Control.Monad.State hiding ((<$!>))\n-- import Data.Array\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IntSet\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map.Strict (Map)\nimport qualified Data.Map.Strict as Map\nimport Data.HashMap.Strict (HashMap)\nimport qualified Data.HashMap.Strict as HashMap\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\n-- import Debug.Trace\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\n\nmain = do\n [r, c] <- getInts\n a <- lines <$> getContents\n\n let\n k1 = length $ filter (not . elem 'S') a\n k2 = length $ filter (not . elem 'S') $ transpose a\n\n print $ k1*c + k2*r - k1*k2\n"}, {"source_code": "import Data.List\nimport Control.Monad\n\nbadones :: [(Int,Int)] -> [(Int,Int)]\nbadones ps = concat [[(a,b),(c,d),(a,d),(c,b)] | (a,b) <- ps, (c,d) <- ps]\n\nrect :: Int -> Int -> [(Int,Int)]\nrect n m = [(i,j) | i <- [1..n], j <- [1..m]]\n\nsolve :: Int -> Int -> [(Int,Int)] -> Int\nsolve n m ps = length (rect n m \\\\ badones ps)\n\nstrawberry :: Char -> Bool\nstrawberry c = c == 's'\n\nmain = do \n [n, m] <- fmap (map read . words) getLine\n let readLine i = fmap (map (\\j -> (i, j+1)) . elemIndices 'S') getLine\n strawberries <- mapM readLine [1..n]\n putStrLn . show . solve n m . concat $ strawberries"}, {"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Data.Function\nimport Data.Ord\nimport Data.Bits\nimport Data.Monoid\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed as UA\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= someFunc\nrIn x= fst $ fromJust $ C.readInteger x\nsomeFunc::IO()\nsomeFunc = C.getLine>>= \\is ->let ns = map rIn $ C.words is in (solve.(\\js->(ns,js))=<
C.init<$>C.getLine) )\nsolve ([x,y],xs) = print $ (\\(t1,t2)->t1*y+t2*x-t1*t2)$ join (***) (sum.map (\\a->if C.notElem 'S' a then 1 else 0))(xs,C.transpose xs)"}, {"source_code": "\nimport Control.Monad (liftM, replicateM)\nimport Data.List (transpose)\nimport Prelude hiding (reads)\n\nreads :: Read a => IO [a]\nreads = liftM (map read . words) getLine\n\nsolve :: (Int, Int) -> [[Bool]] -> Int\nsolve (n, m) xs = n' * m + m' * (n - n')\n where\n n' = length $ filter and xs\n m' = length $ filter and $ transpose xs\n\nmain :: IO ()\nmain = do\n [n, m] <- reads\n xs <- replicateM n getLine\n print $ solve (n, m) $ map (map (== '.')) xs"}, {"source_code": "import Data.List\nmain=getContents>>=print.solve.tail.lines\nsolve=length.filter(=='_').concat.f.transpose.f where f=map(\\s->if all(`elem`\"._\")s then map(const '_')s else s)\n"}, {"source_code": "import Data.List (transpose)\n\nmain :: IO ()\nmain = getContents >>= print . solve . tail . lines\n\nsolve :: [String] -> Int\nsolve = length . filter (=='_') . concat . eat . transpose . eat\n where eat = map (\\cs -> if all (`elem`\"._\") cs then map (const '_') cs else cs)\n"}, {"source_code": "import Data.List (transpose)\nmain = interact $ show . solve . tail . lines\nsolve g = if rs == r || cs == c then max (rs*c) (cs*r) else cs*r + rs*c - rs*cs\n where\n r = length g\n c = length (head g)\n rs = length (filter (all (== '.')) g)\n cs = length (filter (all (== '.')) (transpose g))\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\nmain = do\n [r,c] <- map read . words <$> getLine\n cake <- forM [1..r] (\\_ -> map (=='S') <$> getLine)\n print $ solve cake r c\n \nsolve :: [[Bool]] -> Int -> Int -> Int\nsolve xxs r c = if length b > 0 then r*c - length b * length (head b) else r*c\n where a = filter or xxs\n b = filter or $ transpose a\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nmain=do\n [r,c] <- map read.words <$> getLine\n css <- lines <$> getContents\n let l = length . concat $ f css\n print $ r*c-l\n\nf :: [String] -> [String]\nf css = if css==css' then css else f css'\n where\n css' = h $ g css\n\ng css = filter (any('S'==)) css\nh = transpose.g.transpose\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\n\ncheck'x :: (Num b) => [[Char]] -> b\ncheck'x [] = 0\ncheck'x (x: xs) = (if 'S' `elem` x then 1 else 0) + (check'x xs)\n\ncheck'y :: (Num b) => [[Char]] -> b\ncheck'y [] = 0\ncheck'y x = (if 'S' `elem` head' x then 1 else 0) + (check'y (tail' x))\n\nhead' [x] = [head x]\nhead' (x: xs) = head x : head' xs\n\ntail' ([x]: _) = []\ntail' [x] = [tail x]\ntail' (x: xs) = tail x : tail' xs\n\ncalc' map = check'x map * check'y map\n\nreadInt = read <$> getLine :: IO Int\nreadInts = map read . words <$> getLine :: IO [Int]\n\nmain = do\n [x, y] <- readInts\n\n lst <- forM [1..x] (\\_ -> do\n xs <- getLine\n return xs)\n \n putStr( show (x*y-(calc' lst)))\n\n"}], "negative_code": [{"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Data.Function\nimport Data.Ord\nimport Data.Bits\nimport Data.Monoid\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed as UA\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= someFunc\nrIn x= fst $ fromJust $ C.readInteger x\nsomeFunc::IO()\nsomeFunc = C.getLine>>= \\is ->let ns = map rIn $ C.words is in (solve.(\\js->(ns,js))=<C.getLine) )\nsolve ([x,y],xs) = print $ (\\(t1,t2)->t1*y+t2*x-t1*t2)$ join (***) (sum.map (\\a->if C.notElem 'S' a then 1 else 0))(xs,C.transpose xs)"}, {"source_code": "import Data.List (transpose)\nmain = interact $ show . solve . tail . lines\nsolve g = if rs == r || cs == c then max rs cs else cs + rs\n where\n r = length g\n c = length (head g)\n rs = length (filter (all (== '.')) g)\n cs = length (filter (all (== '.')) (transpose g))\n"}], "src_uid": "ebaf7d89c623d006a6f1ffd025892102"} {"source_code": "main = interact $ show . succ . (`quot` 2) . read", "positive_code": [{"source_code": "main :: IO ()\nmain = do\n x <- getInt\n let a = div x 2 + 1\n print a\ngetInt :: IO Int\ngetInt = readLn\n"}, {"source_code": "main = print . (+ 1) . (`div` 2) =<< readLn"}, {"source_code": "main =do\n e<-getLine\n let n=read e::Int\n print $ n `div` 2 + 1"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\n \nmain = do\n\t\tn<- read<$> getLine ::IO Int\n\t\tprint $ (div n 2) + 1 \n"}], "negative_code": [], "src_uid": "5551742f6ab39fdac3930d866f439e3e"} {"source_code": "import Data.List\n\nf::[String]->[String]->[String]\nf [] _=[]\nf (x:xs) ys\n |x `elem` ys=x : f xs ys\n |otherwise=f xs ys\n\nmain = do\n e1<-getLine\n e2<-getLine\n e3<-getLine\n let xs=words e2\n ys=words e3\n putStrLn $ unwords $ f xs ys", "positive_code": [{"source_code": "import Control.Monad\n\ngetInts = (map read . words) `fmap` getLine :: IO [Int]\n\nmain = do\n [n,m] <- getInts\n ns <- getInts\n ms <- getInts\n let ys = filter (\\x -> x `elem` ms) ns\n forM_ ys $ \\y -> do\n putStr (show y)\n putChar ' '\n putStrLn \"\""}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\n\n\nmain = do\n\t\tgetLine\n\t\ta<-map read<$> words <$> getLine ::IO [Int]\n\t\tb<-map read<$> words <$> getLine ::IO [Int]\n\t\tputStrLn $ intercalate \" \" $ map show $ filter (\\z-> elem z b) a\t\n"}, {"source_code": "import Data.Set (fromList,member)\n\nfindCode :: [Int] -> [Int] -> [Int]\nfindCode x y = filter (`member` sy) x\n where sy = fromList y\n\nmain = do\n n'm' <- getLine\n x' <- getLine\n let x = map read . words $ x'\n y' <- getLine\n let y = map read . words $ y'\n putStrLn . unwords . map show $ findCode x y"}], "negative_code": [], "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72"} {"source_code": "import Data.List\n\nmain = fmap ((* 2) . read) getLine >>= \\n -> getLine >>= print . minimum .\n map (sum . map (\\[a, b] -> abs (a - b)) . takeWhile (not . null) . map (take 2) . iterate (drop 2)) .\n concatMap (map (sort . take (n - 2) . uncurry drop) . zip [0..] . replicate (n - 1) . cycle) . \n map (take (n - 1) . uncurry drop) . zip [0..] . replicate n . cycle . map read . words", "positive_code": [{"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Arrow\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport qualified Data.ByteString.Char8 as B\nimport Text.Printf\n\nreadInt = ( readLn :: IO Int )\nreadInts = map ( read :: String -> Int ) . words <$> getLine\n\ngetList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine\n\nwhich a b f = if f then a else b\nmp [ a, b ] = ( a, b )\n\nmain = do\n\tn <- readInt\n\tas <- sort <$> readInts\n\tprint $ minimum $ map solve $ [ ( erase j . erase i ) as | i <- [ 0 .. 2 * n - 1 ], j <- [ 0 .. i - 1 ] ]\n\nerase pos as = take pos as ++ drop ( pos + 1 ) as\n\nsolve [] = 0\nsolve (a1:a2:as) = a2 - a1 + solve as\n"}, {"source_code": "import qualified Data.ByteString.Char8 as BS\nimport Data.Maybe\nimport Control.Applicative\nimport qualified Data.List as DL\n\nlistLists _ [] = []\nlistLists soFar (x:xs) = (soFar ++ xs) : (listLists (soFar ++ [x]) xs)\n\nlistListLists l = foldl (++) [] (map llm (llm l))\n where llm = listLists []\n\nscor (x:y:xs) = (abs $ x - y) + scor xs\nscor _ = 0\n\nmain = do\n n <- (*2) <$> (readLn::IO Int)\n l <- ( DL.sort . ( map $ \\x -> fst $ fromMaybe (0, BS.empty) (BS.readInt x) ) . BS.words ) <$> BS.getLine\n print $ minimum $ map scor $ listListLists l\n \n"}], "negative_code": [{"source_code": "import qualified Data.ByteString.Char8 as BS\nimport Data.Maybe\nimport Control.Applicative\n\nlistLists _ [] = []\nlistLists soFar (x:xs) = (soFar ++ xs) : (listLists (soFar ++ [x]) xs)\n\nlistListLists l = foldl (++) [] (map llm (llm l))\n where llm = listLists []\n\nscor (x:y:xs) = (abs $ x - y) + scor xs\nscor _ = 0\n\nmain = do\n n <- readLn::IO Int\n l <- ( ( map $ \\x -> fst $ fromMaybe (0, BS.empty) (BS.readInt x) ) . BS.words ) <$> BS.getLine\n print $ minimum $ map scor $ listListLists l\n \n"}], "src_uid": "76659c0b7134416452585c391daadb16"} {"source_code": "import Data.List((\\\\), sort)\n\nmain = do\n\tal <- getLine\n\tbo <- getLine\n putStrLn $ if yao al == bo then \"OK\" else \"WRONG_ANSWER\"\n\nyao \"0\"=\"0\"\nyao a = let a0 = minimum (filter (/= '0') a) in a0 : sort (a \\\\ [a0])", "positive_code": [{"source_code": "import Data.List\ns [a,b] \n | (ds == []) = a == b\n | True = ((head ds) : ns ++ tail ds) == b\n where\n (ns, ds) = span (=='0') $ sort a\n\nf True = \"OK\"\nf False = \"WRONG_ANSWER\"\nmain = putStrLn.f.s.(\\x -> take 2 $ lines x) =<< getContents"}, {"source_code": "import Data.List (sort)\nmain = do\n q <- fmap read getLine\n a <- getLine\n putStrLn $ if solve q == a then \"OK\" else \"WRONG_ANSWER\"\nsolve :: Int -> String\nsolve n = if not $ null sortedWithoutZero then head sortedWithoutZero : (zeros ++ tail sortedWithoutZero) else \"0\"\n where s = show n\n zeros = filter (=='0') s\n sortedWithoutZero = sort $ filter (/='0') s\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\nimport Data.List (partition, sort)\nimport Data.Char (ord)\n\nreconstruct :: [Int] -> [Int] -> [Int]\nreconstruct zs [] = zs\nreconstruct zs (h : t) = h : (zs ++ t)\n\nsolve :: [Int] -> [Int] -> String\nsolve aliceNs bobNs | ds == bobNs = \"OK\"\n | otherwise = \"WRONG_ANSWER\" \n where\n ds = reconstruct zs (sort ns)\n (zs, ns) = partition (== 0) aliceNs\n\nmain = \n do \n aliceStr <- getLine\n bobStr <- getLine\n let intOfChar c = ord c - ord '0'\n let aliceNs = map intOfChar aliceStr\n let bobNs = map intOfChar bobStr\n putStrLn (solve aliceNs bobNs)\n"}, {"source_code": "import Data.List ((\\\\), sort)\n\nmain = do\n\talice <- getLine\n\tbob <- getLine\n\tputStrLn $ if gao alice == bob then \"OK\" else \"WRONG_ANSWER\"\n\ngao \"0\" = \"0\"\ngao a = let a0 = minimum (filter (/= '0') a); a1 = a \\\\ [a0] in a0 : sort a1\n"}, {"source_code": "import Data.List\n\nmain :: IO()\nmain = output . solve . lines =<< getContents\n\noutput :: Bool -> IO()\noutput True = putStrLn \"OK\"\noutput False = putStrLn \"WRONG_ANSWER\"\n\nsolve :: [String] -> Bool\nsolve [num, actual] = let sorted = sort $ filter ('0' /=) num\n zeros = filter ('0' ==) num\n (first, rest) = splitAt 1 sorted\n expect = first ++ zeros ++ rest\n in expect == actual\n"}, {"source_code": "import Data.List\n\nmain :: IO()\nmain = output . solve . lines =<< getContents\n\noutput :: Bool -> IO()\noutput True = putStrLn \"OK\"\noutput False = putStrLn \"WRONG_ANSWER\"\n\nsolve :: [String] -> Bool\nsolve [num, actual] = let sorted = sort $ filter ((/=) '0') num\n zeros = filter ((==) '0') num\n (first, rest) = splitAt 1 sorted\n expect = first ++ zeros ++ rest\n in expect == actual\n"}, {"source_code": "import Data.List ((\\\\), sort)\n\nmain = do\n alice <- getLine\n bob <- getLine\n putStrLn $ if gao alice == bob then \"OK\" else \"WRONG_ANSWER\"\n\ngao \"0\" = \"0\"\ngao a = let a0 = minimum $ filter (/= '0') a; a1 = a \\\\ [a0] in a0: sort a1\n"}, {"source_code": "import Data.List\n\nfindSmallest x = let (a,b) = span (=='0') $ sort x in if null b then a else head b : (a ++ tail b)\nmain = do\n a<-getLine\n b<-getLine\n putStrLn $ if findSmallest a == b && length a == length b then \"OK\" else \"WRONG_ANSWER\""}, {"source_code": "\nimport List (sort)\n\nsolve :: String -> String\nsolve \"0\" = \"0\"\nsolve ss = x : zs ++ xs\n where\n zs = filter (== '0') ss\n (x:xs) = sort $ filter (/= '0') ss\n\nmain :: IO ()\nmain = do\n s1 <- getLine\n s2 <- getLine\n putStrLn $ if s2 == solve s1 then \"OK\" else \"WRONG_ANSWER\"\n"}, {"source_code": "removeFirst c \"\" = \"\"\nremoveFirst c (x:xs) | c == x = xs\n | otherwise = x : removeFirst c xs\n\ngetMinimumWithZero \"\" = \"\"\ngetMinimumWithZero xs = smallest : getMinimumWithZero (removeFirst smallest xs)\n where smallest = minimum xs\n\ngetMinimum \"0\" = \"0\"\ngetMinimum xs = smallest : getMinimumWithZero (removeFirst smallest xs)\n where smallest = minimum (filter (>'0') xs)\n\nsolve a b = if (b == getMinimum a) then \"OK\" else \"WRONG_ANSWER\"\n\nmain = do\n qn <- getLine\n ans <- getLine\n putStrLn (solve qn ans)\n\n"}], "negative_code": [{"source_code": "import Data.List ((\\\\), sort)\n\nmain = do\n alice <- getLine\n bob <- getLine\n putStrLn $ if gao alice == bob then \"YES\" else \"NO\"\n\ngao \"0\" = \"0\"\ngao a = let a0 = minimum $ filter (/= '0') a; a1 = a \\\\ [a0] in a0: sort a1\n"}, {"source_code": "import Data.List\nimport Control.Arrow\nmain = putStrLn . (\\[a,b] -> if fst a==fst b && snd a==snd b then\"OK\"else\"WRONG_ANSWER\") =<< (sequence$zipWith(\\f x->f<$> x)(replicate 2 $ (arr sort.dropWhile(=='0') &&& arr length)) $ replicate 2 getLine) \n"}, {"source_code": "import Data.List\nmain = (\\[a,b] -> putStrLn $ if a==b then \"OK\" else \"WRONG_ANSWER\")=<< (sequence $ zipWith (\\f x -> f <$> x) (replicate 2 $ sort . dropWhile (/='0')) $ replicate 2 getLine) \n"}, {"source_code": "import Data.List\nmain = (\\[a,b] -> putStrLn $ if a==b then \"OK\" else \"WRONG_ANSWER\")=<< (sequence $ zipWith (\\f x -> f <$> x) (replicate 2 sort) $ replicate 2 getLine) \n"}, {"source_code": "import Data.List\nmain = putStrLn . (\\[a,b] -> if a==b then \"OK\" else \"WRONG_ANSWER\") =<< (sequence $ zipWith (\\f x -> f <$> x) (replicate 2 $ sort . dropWhile (=='0')) $ replicate 2 getLine) \n"}, {"source_code": "import Data.List (sort)\nmain = do\n q <- fmap read getLine\n a <- fmap read getLine\n putStrLn $ if solve q == a then \"OK\" else \"WRONG_ANSWER\"\nsolve :: Int -> Int\nsolve n = if not $ null sortedWithoutZero then read $ head sortedWithoutZero : (zeros ++ tail sortedWithoutZero) else 0\n where s = show n\n zeros = filter (=='0') s\n sortedWithoutZero = sort $ filter (/='0') s\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\nimport Data.List\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\ndigitsRev :: Integer -> [Integer]\ndigitsRev n | n < 10 = [n]\n | otherwise = d : (digitsRev ds)\n where\n (ds, d) = quotRem n 10\n\nnumber :: [Integer] -> Integer\nnumber l = foldl' (\\x y -> 10 * x + y) 0 l\n\nreconstruct :: [Integer] -> [Integer] -> [Integer]\nreconstruct zs [] = zs\nreconstruct zs (h : t) = h : (zs ++ t)\n\nsolve :: Integer -> Integer -> String\nsolve n answer | answer == d = \"OK\"\n | otherwise = \"WRONG_ANSWER\" \n where\n d = number ds\n ds = reconstruct zs (sort ns)\n (zs, ns) = partition (== 0) rds\n rds = digitsRev n\n\nmain = \n do all <- BS.getContents\n let Just (alicen, r1) = readInteger all\n let Just (bobn, _) = readInteger r1\n putStrLn (solve alicen bobn)\n where readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n"}], "src_uid": "d1e381b72a6c09a0723cfe72c0917372"} {"source_code": "groupOn :: Int -> [a] -> [[a]]\ngroupOn _ [] = []\ngroupOn n xs = let (sts, nds) = splitAt n xs in sts : groupOn n nds\n\nswap (a,b) = (b,a)\n-------------------------------------------------------------------------------\n\nmain = interact $ unlines . sol . lines\n\nsol nn = let\n [n, a, b] = map read nn :: [Integer]\n pattern (x,y) = \"YES\\n\" ++ (show x) ++ \" \" ++ (show y)\n res = case sol' n (max a b) (min a b) 0 of\n Just p -> pattern (if a /= max a b then swap p else p)\n Nothing -> \"NO\"\n in [res]\n\n-- sol' :: Int -> Int -> Int -> Int -> Maybe (Int,Int)\nsol' n a b ac\n | n < 0 = Nothing\n | n `mod` b == 0 = Just (ac, n`div`b)\n | otherwise = sol' (n-a) a b (ac+1)\n", "positive_code": [{"source_code": "import Data.Int\nmain = interact exec\nexec = (\\r -> case r of { (x, y):_ -> \"YES\\n\" ++ show x ++ \" \" ++ show y; _ -> \"NO\"}) . solve . map read . words\n\n\nsolve [n, a, b] = takeWhile (\\(_, y) -> y >= 0) [(x, y) | x <- [0..10000000], let (y, r) = (n - x * a) `quotRem` b, r == 0]\n where _ = n :: Int64\n"}, {"source_code": "\ngetInt :: IO Integer\ngetInt = read `fmap` getLine\n\nsolve :: Integer -> Integer -> Integer -> Maybe (Integer, Integer)\nsolve a b n = go 0\n where go x\n | x*a > n = Nothing\n | (n - x*a) `mod` b == 0 = Just (x, (n - x*a) `div` b)\n | otherwise = go (x+1)\n\nmain :: IO ()\nmain = do\n n <- getInt\n a <- getInt\n b <- getInt\n let k = solve a b n\n case k of\n Nothing -> putStrLn \"NO\"\n Just (a,b) -> do\n putStrLn \"YES\"\n putStrLn (show a ++ \" \" ++ show b)"}, {"source_code": "{-# OPTIONS_GHC -O3 #-}\n{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}\n\nexgcd a 0 = (a, 1, 0)\nexgcd a b = (ret, y, x - a `div` b * y) where\n (ret, x, y) = exgcd b (a `mod` b)\n\npmod x y = ((x `mod` y) + y) `mod` y\n\n-- Bezout's Lemma -- min. ax s.t. ax+cy=d, x, y >= 0\nrun a c d | r /= 0 = (-1, -1) | otherwise = (k, (d - a * k) `div` c) where\n k = (x * q) `pmod` p\n p = c `div` g\n (q, r) = d `divMod` g\n (g, x, y) = exgcd a c\n\nmain = do\n (map (read :: String -> Integer) . lines -> [n, a, b]) <- getContents\n let r = run a b n\n putStrLn $ if fst r == -1 || snd r < 0 then \"NO\" else \"YES\\n\" ++ show (fst r) ++ \" \" ++ show (snd r)\n"}], "negative_code": [{"source_code": "groupOn :: Int -> [a] -> [[a]]\ngroupOn _ [] = []\ngroupOn n xs = let (sts, nds) = splitAt n xs in sts : groupOn n nds\n\nswap (a,b) = (b,a)\n-------------------------------------------------------------------------------\n\nmain = interact $ unlines . sol . lines\n\nsol nn = let\n [n, a, b] = map read nn :: [Int]\n pattern (x,y) = \"YES\\n\" ++ (show x) ++ \" \" ++ (show y)\n res = case sol' n (max a b) (min a b) 0 of\n Just p -> pattern (if a /= max a b then swap p else p)\n Nothing -> \"No\"\n in [res]\n\nsol' :: Int -> Int -> Int -> Int -> Maybe (Int,Int)\nsol' n a b ac\n | n <= 0 = Nothing\n | n `mod` b == 0 = Just (ac, n`div`b)\n | otherwise = sol' (n-a) a b (ac+1)\n"}, {"source_code": "groupOn :: Int -> [a] -> [[a]]\ngroupOn _ [] = []\ngroupOn n xs = let (sts, nds) = splitAt n xs in sts : groupOn n nds\n\nswap (a,b) = (b,a)\n-------------------------------------------------------------------------------\n\nmain = interact $ unlines . sol . lines\n\nsol nn = let\n [n, a, b] = map read nn :: [Integer]\n pattern (x,y) = \"YES\\n\" ++ (show x) ++ \" \" ++ (show y)\n res = case sol' n (max a b) (min a b) 0 of\n Just p -> pattern (if a /= max a b then swap p else p)\n Nothing -> \"NO\"\n in [res]\n\n-- sol' :: Int -> Int -> Int -> Int -> Maybe (Int,Int)\nsol' n a b ac\n | n <= 0 = Nothing\n | n `mod` b == 0 = Just (ac, n`div`b)\n | otherwise = sol' (n-a) a b (ac+1)\n"}, {"source_code": "groupOn :: Int -> [a] -> [[a]]\ngroupOn _ [] = []\ngroupOn n xs = let (sts, nds) = splitAt n xs in sts : groupOn n nds\n\nswap (a,b) = (b,a)\n-------------------------------------------------------------------------------\n\nmain = interact $ unlines . sol . lines\n\nsol nn = let\n [n, a, b] = map read nn :: [Integer]\n pattern (x,y) = \"YES\\n\" ++ (show x) ++ \" \" ++ (show y)\n res = case sol' n (max a b) (min a b) 0 of\n Just p -> pattern (if a /= max a b then swap p else p)\n Nothing -> \"No\"\n in [res]\n\n-- sol' :: Int -> Int -> Int -> Int -> Maybe (Int,Int)\nsol' n a b ac\n | n <= 0 = Nothing\n | n `mod` b == 0 = Just (ac, n`div`b)\n | otherwise = sol' (n-a) a b (ac+1)\n"}], "src_uid": "b031daf3b980e03218167f40f39e7b01"} {"source_code": "process :: String -> Int\nprocess xs = qaq\n where\n (_,_,qaq) = f xs\n f :: [Char] -> (Int, Int, Int)\n f [] = (0,0,0)\n f (x:xs)\n | x == 'Q' = (q+1,aq,qaq+aq)\n | x == 'A' = (q,aq+q,qaq)\n | otherwise = (q,aq,qaq)\n where (q,aq,qaq) = f xs\n\nreadInt :: String -> Int\nreadInt = read\n\nmain :: IO ()\nmain = do\n xs <- getLine\n print $ process xs", "positive_code": [{"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\n\nprocess m n p _ [] = m \nprocess m n p f (a:as) | a=='Q' = process (m+n) n (p+1) 1 as\n | f==0 = process m n p f as \n\t\t | otherwise = process m (n+p) p 1 as\n\n\nmain::IO ()\nmain=do\n\ts<- getLine\n\tlet a= filter (\\z-> elem z \"AQ\") s\n\tprint $ process 0 0 0 0 a\n"}, {"source_code": "getQAQ :: String -> Int\ngetQAQ = solve 0 0\n where\n solve num sum [] = 0\n solve num sum (s1:sx)\n | s1 == 'Q' = sum + solve (num + 1) sum sx\n | s1 == 'A' = solve num (sum + num) sx\n | otherwise = solve num sum sx\nmain = interact $ show . getQAQ\n"}, {"source_code": "getQAQ' a sum [] = 0\ngetQAQ' a sum (s1:sx)\n | s1 == 'Q' = sum + getQAQ' (a+1) sum sx\n | s1 == 'A' = getQAQ' a (sum+a) sx\n | otherwise = getQAQ' a sum sx\ngetQAQ s = getQAQ' 0 0 s\nmain = print . getQAQ =<< getLine\n"}, {"source_code": "main = interact $ show . solve\nsolve s = sum $ zipWith3 (((*) .) . (*)) l m r where\n l = scanl1 (+) $ map (fromEnum . (== 'Q')) s\n m = map (fromEnum . (== 'A')) s\n r = scanr1 (+) $ map (fromEnum . (== 'Q')) s\n"}], "negative_code": [{"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\n\nprocess m n p [] = m \nprocess m n p (a:as) | a=='Q' = process (m+n) n (p+1) as\n | otherwise = process m (n+p) p as\n\n\nmain::IO ()\nmain=do\n\ts<- getLine\n\tlet a= filter (\\z-> elem z \"AQ\") s\n\tprint $ process 0 0 0 s\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\n\nprocess m n p _ [] = m \nprocess m n p f (a:as) | a=='Q' = process (m+n) n (p+1) 1 as\n | f==0 = process m n p f as \n\t\t | otherwise = process m (n+p) p 1 as\n\n\nmain::IO ()\nmain=do\n\ts<- getLine\n\tlet a= filter (\\z-> elem z \"AQ\") s\n\tprint $ process 0 0 0 0 s\n"}], "src_uid": "8aef4947322438664bd8610632fe0947"} {"source_code": "{-# LANGUAGE NoMonadFailDesugaring #-}\r\n\r\nimport Debug.Trace\r\nimport Data.Maybe\r\nimport Control.Monad.Trans.Maybe\r\nimport Control.Monad.State\r\n\r\nchop = do\r\n x:xs <- get\r\n put xs\r\n return x\r\n\r\nhelper' :: Int -> Int -> MaybeT (State String) [Int]\r\nhelper' 0 zeroes = return $ replicate zeroes 0\r\nhelper' ones 0 = return $ replicate ones 1\r\nhelper' ones zeroes = do\r\n c <- chop\r\n case c of\r\n '0' -> fmap (0:) $ helper' ones (zeroes - 1)\r\n '1' -> fmap (1:) $ helper' (ones - 1) zeroes\r\n\r\nsolution' :: Int -> Int -> MaybeT (State String) [[Int]]\r\nsolution' l r | r - l <= 1 = return []\r\n | otherwise = do\r\n let m = div (r + l) 2\r\n a <- solution' l m\r\n b <- solution' m r\r\n res <- helper' (r - m) (m - l)\r\n return (a ++ b ++ [res])\r\n\r\nseparate :: [Int] -> State [[Int]] [Int]\r\nseparate [x] = return [x]\r\nseparate values = do\r\n fil:xs <- get\r\n put xs\r\n\r\n let collect (0:f, a, b) x = (f, x:a, b)\r\n collect (1:f, a, b) x = (f, a, x:b)\r\n (_, l, r) = foldl collect (fil, [], []) values\r\n right <- separate (reverse r)\r\n left <- separate (reverse l)\r\n return $ left ++ right\r\n\r\nrunSolution'' :: Int -> Int -> String -> ([Int], Int)\r\nrunSolution'' l r s = let m = div (r + l) 2 in\r\n case runState (runMaybeT $ solution' 0 m) s of\r\n (Just res, \"\") -> (evalState (separate [1..m]) $ reverse res, m)\r\n (_, _:_) -> if (r - l) <= 1 \r\n then runSolution' (max 0 (l - 20)) s\r\n else runSolution'' m r s\r\n _ -> if (r - l) <= 1 \r\n then runSolution' (max 0 (l - 20)) s\r\n else runSolution'' l m s\r\n\r\nrunSolution' :: Int -> String -> ([Int], Int)\r\nrunSolution' i s = if (i > 100000) \r\n then runSolution' 1 s\r\n else case runState (runMaybeT $ solution' 0 i) s of\r\n (Just res, \"\") -> (evalState (separate [1..i]) $ reverse res, i)\r\n _ -> runSolution' (i + 1) s\r\n\r\nmain = do\r\n s <- getLine\r\n let (a, i) = runSolution'' 1 100000 s\r\n putStrLn $ show i\r\n mapM (putStr.(++ \" \").show) a", "positive_code": [{"source_code": "import Debug.Trace\r\nimport Data.Maybe\r\nimport Data.Char\r\nimport Control.Monad.Trans.Maybe\r\nimport Control.Monad.State\r\nimport Control.Monad.Writer\r\n\r\nchop :: MaybeT (State [Int]) Int\r\nchop = do\r\n x:xs <- get\r\n put xs\r\n return x\r\n\r\nfoo :: Int -> Int -> [Int] -> MaybeT (State [Int]) ([Int], Int)\r\nfoo 0 _ coll = return (reverse coll, 1)\r\nfoo _ 0 coll = return (reverse coll, 0)\r\nfoo z o coll = do\r\n x <- chop\r\n case x of\r\n 0 -> foo (z - 1) o (x:coll)\r\n 1 -> foo z (o - 1) (x:coll)\r\n\r\nsolution' :: Int -> Int -> [([Int], Int)] -> MaybeT (State [Int]) [([Int], Int)]\r\nsolution' l r coll | r - l <= 1 = return coll\r\n | otherwise = do\r\n let m = div (r + l) 2\r\n coll' <- solution' l m coll\r\n coll'' <- solution' m r coll'\r\n x <- foo (m - l) (r - m) []\r\n return (x:coll'')\r\n\r\nhelper :: ([Int], Int) -> [Int] -> ([Int], [Int]) -> ([Int], [Int])\r\nhelper _ [] acc = acc\r\nhelper s@([], 0) (x:xs) (a, b) = helper s xs (x:a, b)\r\nhelper s@([], 1) (x:xs) (a, b) = helper s xs (a, x:b)\r\nhelper (0:s, n) (x:xs) (a, b) = helper (s, n) xs (x:a, b)\r\nhelper (1:s, n) (x:xs) (a, b) = helper (s, n) xs (a, x:b)\r\n\r\nseparate :: [Int] -> [Int] -> State [([Int], Int)] [Int] \r\nseparate [x] coll = return (x:coll)\r\nseparate values coll = do\r\n xs <- get\r\n put $ tail xs\r\n let (l, r) = helper (head xs) values ([], [])\r\n coll' <- separate (reverse r) coll\r\n separate (reverse l) coll'\r\n\r\nrunSolution'' :: Int -> Int -> [Int] -> ([Int], Int)\r\nrunSolution'' l r s = let m = div (r + l) 2 in\r\n case runState (runMaybeT $ solution' 0 m []) s of\r\n (Just res, []) -> (evalState (separate [1..m] []) res, m)\r\n ( _, _:_) -> runSolution'' m r s\r\n _ -> runSolution'' l m s\r\n\r\nmain = do\r\n s <- getLine\r\n let (a, i) = runSolution'' 1 100001 $ map digitToInt s\r\n putStrLn $ show i\r\n putStr $ foldr (\\a b -> a ++ \" \" ++ b) \"\" $ map show a"}, {"source_code": "import Debug.Trace\r\nimport Data.Maybe\r\nimport Data.Char\r\nimport Control.Monad.State\r\n\r\nfoo :: Int -> Int -> [Int] -> [Int] -> Maybe ([Int], [Int])\r\nfoo 0 0 xs ys = Just (xs, reverse ys)\r\nfoo 0 o xs ys = foo 0 (o - 1) xs (1:ys)\r\nfoo z 0 xs ys = foo (z - 1) 0 xs (0:ys)\r\nfoo _ _ [] _ = Nothing\r\nfoo z o (0:xs) ys = foo (z - 1) o xs (0:ys)\r\nfoo z o (1:xs) ys = foo z (o - 1) xs (1:ys)\r\n\r\nsolution' :: Int -> Int -> [Int] -> Maybe ([Int], [[Int]])\r\nsolution' l r s | r - l <= 1 = return (s, [])\r\n | otherwise = do\r\n let m = div (r + l) 2\r\n (s', a) <- solution' l m s\r\n (s'', b) <- solution' m r s'\r\n (s''', res) <- foo (m - l) (r - m) s'' []\r\n return (s''', a ++ b ++ [res])\r\n\r\nseparate :: [Int] -> State [[Int]] [Int]\r\nseparate [x] = return [x]\r\nseparate values = do\r\n xs <- get\r\n put $ tail xs\r\n let collect (0:f, a, b) x = (f, x:a, b)\r\n collect (1:f, a, b) x = (f, a, x:b)\r\n (_, l, r) = foldl collect (head xs, [], []) values\r\n right <- separate (reverse r)\r\n left <- separate (reverse l)\r\n return $ left ++ right\r\n\r\nrunSolution'' :: Int -> Int -> [Int] -> ([Int], Int)\r\nrunSolution'' l r s = let m = div (r + l) 2 in\r\n case solution' 0 m s of\r\n Just ([], res) -> (evalState (separate [1..m]) $ reverse res, m)\r\n Just _ -> if r - m <= 1\r\n then ([], 0)\r\n else runSolution'' m r s\r\n Nothing -> if m - l <= 1\r\n then ([], 0)\r\n else runSolution'' l m s\r\n\r\nmain = do\r\n s <- getLine\r\n let (a, i) = runSolution'' 1 100001 $ map digitToInt s\r\n putStrLn $ show i\r\n putStr $ foldr (\\a b -> a ++ \" \" ++ b) \"\" $ map show a"}, {"source_code": "{-# LANGUAGE NoMonadFailDesugaring #-}\r\n\r\nimport Debug.Trace\r\nimport Data.Maybe\r\nimport Control.Monad.Trans.Maybe\r\nimport Control.Monad.State\r\n\r\nchop = do\r\n x:xs <- get\r\n put xs\r\n return x\r\n\r\nhelper' :: Int -> Int -> MaybeT (State String) [Int]\r\nhelper' 0 zeroes = return $ replicate zeroes 0\r\nhelper' ones 0 = return $ replicate ones 1\r\nhelper' ones zeroes = do\r\n c <- chop\r\n case c of\r\n '0' -> fmap (0:) $ helper' ones (zeroes - 1)\r\n '1' -> fmap (1:) $ helper' (ones - 1) zeroes\r\n\r\nsolution' :: Int -> Int -> MaybeT (State String) [[Int]]\r\nsolution' l r | r - l <= 1 = return []\r\n | otherwise = do\r\n let m = div (r + l) 2\r\n a <- solution' l m\r\n b <- solution' m r\r\n res <- helper' (r - m) (m - l)\r\n return (a ++ b ++ [res])\r\n\r\nseparate :: [Int] -> State [[Int]] [Int]\r\nseparate [x] = return [x]\r\nseparate values = do\r\n fil:xs <- get\r\n put xs\r\n\r\n let collect (0:f, a, b) x = (f, x:a, b)\r\n collect (1:f, a, b) x = (f, a, x:b)\r\n (_, l, r) = foldl collect (fil, [], []) values\r\n right <- separate (reverse r)\r\n left <- separate (reverse l)\r\n return $ left ++ right\r\n\r\nrunSolution' :: Int -> String -> ([Int], Int)\r\nrunSolution' i s = case runState (runMaybeT $ solution' 0 i) s of\r\n (Just res, \"\") -> (evalState (separate [1..i]) $ reverse res, i)\r\n _ -> runSolution' (i + 1) s\r\n\r\nmain = do\r\n s <- getLine\r\n let (a, i) = runSolution' 1 s\r\n putStrLn $ show i\r\n mapM (putStr.(++ \" \").show) a"}, {"source_code": "{-# LANGUAGE NoMonadFailDesugaring #-}\r\n\r\nimport Debug.Trace\r\nimport Data.Maybe\r\nimport Control.Monad.Trans.Maybe\r\nimport Control.Monad.State\r\n\r\nchop = do\r\n x:xs <- get\r\n put xs\r\n return x\r\n\r\nhelper' :: Int -> Int -> MaybeT (State String) [Int]\r\nhelper' 0 zeroes = return $ replicate zeroes 0\r\nhelper' ones 0 = return $ replicate ones 1\r\nhelper' ones zeroes = do\r\n c <- chop\r\n case c of\r\n '0' -> fmap (0:) $ helper' ones (zeroes - 1)\r\n '1' -> fmap (1:) $ helper' (ones - 1) zeroes\r\n\r\nsolution' :: Int -> Int -> MaybeT (State String) [[Int]]\r\nsolution' l r | r - l <= 1 = return []\r\n | otherwise = do\r\n let m = div (r + l) 2\r\n a <- solution' l m\r\n b <- solution' m r\r\n res <- helper' (r - m) (m - l)\r\n return (a ++ b ++ [res])\r\n\r\nseparate :: [Int] -> State [[Int]] [Int]\r\nseparate [x] = return [x]\r\nseparate values = do\r\n fil:xs <- get\r\n put xs\r\n\r\n let collect (0:f, a, b) x = (f, x:a, b)\r\n collect (1:f, a, b) x = (f, a, x:b)\r\n (_, l, r) = foldl collect (fil, [], []) values\r\n right <- separate (reverse r)\r\n left <- separate (reverse l)\r\n return $ left ++ right\r\n\r\nrunSolution' :: Int -> String -> ([Int], Int)\r\nrunSolution' i s = case runState (runMaybeT $ solution' 0 i) s of\r\n (Just res, \"\") -> (evalState (separate [1..i]) $ reverse res, i)\r\n _ -> runSolution' (i + 1) s\r\n\r\nmain = do\r\n s <- getLine\r\n let (a, i) = runSolution' 1 s\r\n putStrLn $ show i\r\n mapM (putStr.(++ \" \").show) a"}], "negative_code": [{"source_code": "import System.Environment\r\nimport Debug.Trace\r\nimport Data.Maybe\r\nimport Data.Char\r\nimport Control.Monad.Trans.Maybe\r\nimport Control.Monad.State\r\n\r\nfoo :: Int -> Int -> [Int] -> [Int] -> ([Int], [Int])\r\nfoo 0 _ xs ys = (xs, reverse ys)\r\nfoo _ 0 xs ys = (xs, reverse ys)\r\nfoo z o (0:xs) ys = foo (z - 1) o xs (0:ys)\r\nfoo z o (1:xs) ys = foo z (o - 1) xs (1:ys)\r\n\r\nsolution' :: Int -> Int -> MaybeT (State [Int]) [[Int]]\r\nsolution' l r | r - l <= 1 = return []\r\n | otherwise = do\r\n let m = div (r + l) 2\r\n a <- solution' l m\r\n b <- solution' m r\r\n s <- get\r\n let (s', res) = foo (m - l) (r - m) s []\r\n put s\r\n return (a ++ b ++ [res])\r\n\r\nseparate :: [Int] -> State [[Int]] [Int]\r\nseparate [x] = return [x]\r\nseparate values = do\r\n xs <- get\r\n put $ tail xs\r\n\r\n let collect (0:f, a, b) x = (f, x:a, b)\r\n collect (1:f, a, b) x = (f, a, x:b)\r\n (_, l, r) = foldl collect (head xs, [], []) values\r\n right <- separate (reverse r)\r\n left <- separate (reverse l)\r\n return $ left ++ right\r\n\r\nrunSolution'' :: Int -> Int -> [Int] -> ([Int], Int)\r\nrunSolution'' l r s = let m = div (r + l) 2 in\r\n case runState (runMaybeT $ solution' 0 m) s of\r\n (Just res, []) -> (evalState (separate [1..m]) $ reverse res, m)\r\n (_, _:_) -> if r - m <= 1\r\n then ([], 0)\r\n else runSolution'' m r s\r\n _ -> if m - l <= 1\r\n then ([], 0)\r\n else runSolution'' l m s\r\n\r\nmain = do\r\n s <- getLine\r\n let (a, i) = runSolution'' 1 100001 $ map digitToInt s\r\n putStrLn $ show i\r\n putStr $ foldr (\\a b -> a ++ \" \" ++ b) \"\" $ map show a"}, {"source_code": "{-# LANGUAGE NoMonadFailDesugaring #-}\r\n\r\nimport Debug.Trace\r\nimport Data.Maybe\r\nimport Control.Monad.Trans.Maybe\r\nimport Control.Monad.State\r\n\r\nchop = do\r\n x:xs <- get\r\n put xs\r\n return x\r\n\r\nhelper' :: Int -> Int -> MaybeT (State String) [Int]\r\nhelper' 0 zeroes = return $ replicate zeroes 0\r\nhelper' ones 0 = return $ replicate ones 1\r\nhelper' ones zeroes = do\r\n c <- chop\r\n case c of\r\n '0' -> fmap (0:) $ helper' ones (zeroes - 1)\r\n '1' -> fmap (1:) $ helper' (ones - 1) zeroes\r\n\r\nsolution' :: Int -> Int -> MaybeT (State String) [[Int]]\r\nsolution' l r | r - l <= 1 = return []\r\n | otherwise = do\r\n let m = div (r + l) 2\r\n a <- solution' l m\r\n b <- solution' m r\r\n res <- helper' (r - m) (m - l)\r\n return (a ++ b ++ [res])\r\n\r\nseparate :: [Int] -> State [[Int]] [Int]\r\nseparate [x] = return [x]\r\nseparate values = do\r\n fil:xs <- get\r\n put xs\r\n\r\n let collect (0:f, a, b) x = (f, x:a, b)\r\n collect (1:f, a, b) x = (f, a, x:b)\r\n (_, l, r) = foldl collect (fil, [], []) values\r\n right <- separate (reverse r)\r\n left <- separate (reverse l)\r\n return $ left ++ right\r\n\r\nrunSolution'' :: Int -> Int -> String -> ([Int], Int)\r\nrunSolution'' l r s = if r - l <= 10\r\n then ([], 0)\r\n else let m = div (r + l) 2 in\r\n case runState (runMaybeT $ solution' 0 m) s of\r\n (Just res, \"\") -> (evalState (separate [1..m]) $ reverse res, m)\r\n (_, _:_) -> runSolution'' m r s\r\n _ -> runSolution'' l m s\r\n\r\nrunSolution' :: Int -> Int -> String -> ([Int], Int)\r\nrunSolution' l r s = if l > r\r\n then ([], 0)\r\n else case runState (runMaybeT $ solution' 0 l) s of\r\n (Just res, \"\") -> (evalState (separate [1..l]) $ reverse res, l)\r\n _ -> runSolution' (l + 1) r s\r\n\r\nmain = do\r\n s <- getLine\r\n let (a, i) = runSolution'' 1 101000 s\r\n putStrLn $ show i\r\n mapM (putStr.(++ \" \").show) a"}], "src_uid": "b2ee84d23d73947fa84faaaebfde85c8"} {"source_code": "import Data.List\nmain=interact$intercalate \"+\".map show.(sort::[Int]->[Int]).map read.splitOn '+' \"\"\nsplitOn c a (x:xs) | x == c = reverse a : splitOn c \"\" xs\n | otherwise = splitOn c (x:a) xs\nsplitOn _ a [] = [a]\n", "positive_code": [{"source_code": "import qualified Data.Char as Ch\nimport Data.List\n\ncountRes :: [Char] -> Bool\ncountRes xs = length (filter acceptable xs) > 0\n where acceptable = (`elem` ['H', 'Q', '9'])\n\nprintString :: [Char] -> IO ()\nprintString (x:[]) = putStr [x]\nprintString (x:xs) = do\n putStr [x]\n putStr \"+\"\n printString xs\n\nmain :: IO ()\nmain = do\n nStr <- getLine\n printString $ sort (filter (\\x -> x `elem` ['1'..'9']) nStr)\n putStrLn \"\""}, {"source_code": "import Data.List\n\ngetans :: [Int] -> String\ngetans [] = \"\"\ngetans (x:xs) = (show x) ++ (if (xs == []) then \"\" else \"+\") ++ (getans xs)\n\nmain = do\n input <- getLine\n putStr $ getans $ sort $ (map read (words (map (\\x -> if (x == '+') then ' ' else x) input)) :: [Int])"}, {"source_code": "import Data.Text(pack,unpack,split)\nimport Data.List\nmain=interact(intercalate\"+\".sort.map unpack.split(=='+').pack.init)"}, {"source_code": "import Data.List\nimport Data.List.Split\nimport Data.Char\n\n-- Quicksort\nquicksort :: (Ord a) => [a] -> [a]\nquicksort [] = []\nquicksort (x:xs) = quicksort [y | y <- xs, y <= x] ++ [x] ++ quicksort [y | y <- xs, y > x]\n\n-- Sort the expression\nsortExpr :: String -> String\nsortExpr s = concat (intersperse \"+\" (map show ( quicksort ( map (read :: String -> Int) (splitOn \"+\" s) ) )))\n\nmain = do\n s <- getLine\n putStrLn $ sortExpr s\n"}, {"source_code": "\n\nimport Data.List\n\nsolve s = myShow $ sort $ splitOn '+' s \n\nmyShow [] = \"\"\nmyShow (s:ss) | null ss = s ++ myShow ss\n | otherwise = s ++ \"+\" ++ myShow ss\n\nmain = \n do \n s<-getLine\n putStrLn $solve s\n\nsplitOn::Char->String->[String]\nsplitOn f [] = []\nsplitOn f ss = [takeWhile (/=f) ss] ++ splitOn f (stail (dropWhile (/=f) ss))\n\nstail [] = []\nstail (s:[]) = []\nstail s = tail s"}, {"source_code": " import Data.List\n f x =intersperse '+' (sort [e | e<-(init x),e/='+'])\n main=interact$f"}, {"source_code": " import Data.List\n f x =intersperse '+' (sort [e | e<-x,e/='+',e/='\\n'])\n main=interact$f"}, {"source_code": "import Data.List\nimport Data.Char\n\nmain = interact $ intersperse '+' . sort . filter isDigit . head . lines"}, {"source_code": "import Data.List\nimport Data.List.Split\n\nmain = putStrLn . intercalate \"+\" . sort . splitOn \"+\" =<< getLine"}, {"source_code": "\n\n-- just count the 1s, 2s, and 3s\n\n-- find place in book which says that lists don't have spaces (real world haskell)\n\ncount str [a,b,c]\n | (null str) = [a,b,c]\n | (head str) == '+' = count (tail str) [ a, b, c]\n | (head str) == '1' = count (tail str) [ a+1, b, c]\n | (head str) == '2' = count (tail str) [ a, b+1, c]\n | (head str) == '3' = count (tail str) [ a, b, c+1]\n\n\nconstruct [a,b,c] grr\n | (a + b + c) == 0 = grr -- base case\n | (a + b + c) == 1 = (grr ++ [(choose a b c)]) -- one left\n | a /= 0 = construct [ a-1, b, c] (grr ++ \"1+\")\n | b /= 0 = construct [ a, b-1, c] (grr ++ \"2+\")\n | c /= 0 = construct [ a, b, c-1] (grr ++ \"3+\")\n\n\nchoose a b c \n | a == 1 = '1'\n | b == 1 = '2'\n | c == 1 = '3'\n\nmain = do\n exp <- getLine\n let mine = count exp [0,0,0]\n let ans = construct mine \"\"\n putStrLn ans\n"}, {"source_code": "import Data.List\n\n-- Snippet: split\nsplit c s\n | null s = [\"\"]\n | c == (head s) = \"\" : r\n | otherwise = ((head s) : r1) : rn\n where r@(r1 : rn) = split c (tail s)\n\nmain = do\n s <- getLine\n putStrLn $ intercalate \"+\" $ sort $ split '+' s\n"}, {"source_code": "import Control.Applicative((<$>))\nimport Data.List(sort)\nmain = map (\\x -> if x == ' ' then '+' else x) <$> unwords <$> sort <$> words <$> map (\\x -> if x == '+' then ' ' else x) <$> getLine >>= putStrLn\n"}, {"source_code": "import Data.List (sort)\n\nparse :: String -> String\nparse (x:_:xs) = x : parse xs\nparse xs = xs\n\ncreate :: String -> String\ncreate [x] = [x]\ncreate (x:xs) = x:'+':create xs\ncreate [] = []\n\nmain :: IO ()\nmain = do\n\ts <- getLine\n\tputStr $ create $ sort $ parse s"}, {"source_code": "import Data.List (sort, intersperse, concat)\n\ndata Symbol a = Summation | Number Int deriving (Eq, Show, Ord)\n\nshowSymbol :: Symbol a -> String\nshowSymbol Summation = \"+\"\nshowSymbol (Number a) = show a\n\nparse :: Char -> Symbol a\nparse '+' = Summation\nparse x = Number (read [x] :: Int)\n\nisNumber :: Symbol a -> Bool\nisNumber (Number a) = True\nisNumber _ = False\n\nmain :: IO ()\nmain = do\n args <- getLine\n putStrLn $ concat $ intersperse (showSymbol Summation) $ map showSymbol $ sort $ filter isNumber $ fmap parse args"}, {"source_code": "import Data.List (sort, intercalate)\n\nmain :: IO ()\nmain = do\n line <- getLine\n putStrLn $ intercalate \"+\" (sort $ splitOn '+' line)\n\nsplitOn :: Char -> String -> [String]\nsplitOn c s =\n case s of\n [] -> []\n _ -> s' : splitOn c (dropWhile (== c) s'')\n where (s', s'') = span (/= c) s"}, {"source_code": "import Data.List.Split\nimport Data.List\n\nmain = do\n s <- getLine\n let\n ns = sort $ map (read :: String -> Int) $ splitOn \"+\" s\n putStrLn $ intercalate \"+\" $ map show ns\n "}, {"source_code": "\n\ng1 :: [Int] -> [Int]\ng1 (a:s) = (a + 1):s\n\ng2 :: [Int] -> [Int]\ng2 (a:b:s) = (a):(b + 1):s\n\ng3 :: [Int] -> [Int]\ng3 (a:b:c:s) = (a):(b):(c + 1):s\n\nsolve :: String -> [Int]\nsolve \"\" = [0, 0, 0]\nsolve ('+':s) = solve s \nsolve ('1':s) = g1 (solve s)\nsolve ('2':s) = g2 (solve s)\nsolve ('3':s) = g3 (solve s)\n\ngen :: [Int] -> String\ngen [0, 0, 0] = \"\"\ngen [0, 0, a] = \"+3\" ++ (gen [0, 0, a - 1])\ngen [0, a, b] = \"+2\" ++ (gen [0, a - 1, b])\ngen [a, b, c] = \"+1\" ++ (gen [a - 1, b, c])\n\ncuttt (ch:s) = s\n\nmain = do \n s <- getLine\n let t = solve s\n let answer = gen t;\n let qq = \"sdfsdf\"\n --print qq\n --print 5\n putStrLn (cuttt answer)\n \n"}, {"source_code": "import Data.List\nimport Data.Char\nmain = interact $ intersperse '+' . sort . filter isDigit"}, {"source_code": "import Data.List\nimport Data.List.Split\nimport qualified Data.Map as M\n(|>) x f = f x\n\nmain = interact process\n\nprocess contents = let\n ls = contents |> lines |> head\n in solve ls\n \nsolve str = str |> splitOn \"+\" |> sort |> intercalate \"+\"\n\n"}, {"source_code": "{-# LANGUAGE MultiParamTypeClasses,FlexibleContexts,FlexibleInstances,TypeSynonymInstances,BangPatterns,RankNTypes #-}\n\nimport Control.Monad\nimport Control.Monad.ST\nimport Control.Applicative\nimport Control.Arrow\nimport Debug.Trace\n\nimport Data.List\nimport Data.Int\nimport Data.Maybe\nimport Data.Array.Unboxed\nimport Data.Array.ST\nimport qualified Data.Map as M\nimport qualified Data.Set as S\nimport qualified Data.ByteString.Char8 as B\n\nreadInt = B.readInt >>> fmap fst >>> fromMaybe 0\nreadLine :: Read a => IO a\nreadLine = read <$> getLine \nreadsLine :: Read a => IO [a]\nreadsLine = map read . words <$> getLine\n\ncmpFst (a,_) (b,_) = compare a b\ncmpSnd (_,a) (_,b) = compare a b\ncmpLen a b = length a `compare` length b\n\n\nmain = do\n s <- getLine\n putStrLn $ solve s\n\nsolve = concat . intersperse \"+\" . map show . sort . map readI . words . map f\n\nreadI :: String -> Int\nreadI = read\n\nf '+' = ' '\nf a = a\n"}, {"source_code": "import Data.List\n\ngetInput :: String -> [Int]\ngetInput [] = []\ngetInput (x:xs)\n | x /= '+' = intx : getInput xs\n | otherwise = getInput xs\n where intx = read (x:[]) :: Int\n\nsortList :: [Int] -> [Int]\nsortList = sort\n\nprintSum :: [Int] -> String\nprintSum [] = \"\"\nprintSum (x:xs) = strInt ++ \"+\" ++ printSum xs\n where strInt = show x\n\nmain :: IO ()\nmain = do n <- getLine\n putStr $ init $ printSum $ sortList $ getInput n\n"}, {"source_code": "module Main where\n\nimport Data.List (sort)\n\nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn . f $ s\n\n-- |\n-- >>> f \"1+1+3+1+3\"\n--\"1+1+1+3+3\"\nf :: String -> String\nf = m . sort . filter (/='+')\n\nm :: String -> String\nm [] = []\nm [x] = [x]\nm (x:xs) = x : '+' : m xs\n"}, {"source_code": "import Data.List\n\nmain = do\n\tstring <- getLine\n\t\n\tputStrLn . intersperse '+' . sort $ filter (/= '+') string"}, {"source_code": "module Main where\n\nimport Data.List\nsplitBy delimiter = foldr f [[]] \n where f c l@(x:xs) | c == delimiter = []:l\n | otherwise = (c:x):xs\n\n\nmain::IO()\nmain = do\n inp <- getLine\n let nums = (splitBy '+' inp)\n putStrLn $ intercalate \"+\" (sort nums)"}, {"source_code": "import Data.List\n\nmain = do\n str <- getLine\n let grep str = _grep str where\n _grep \"\" = \"\"\n _grep (x:xs)\n | x /= '+' = x : (grep xs)\n | otherwise = grep xs\n\n let xs = map read $ words str :: [Int]\n\n putStrLn (intersperse '+' (sort (grep str)))\n"}, {"source_code": "import Data.List\nmain = getLine >>= putStrLn . intersperse '+' . sort . filter (/='+')\n"}, {"source_code": "import Data.List\nmain = readsolveprint\nreadsolveprint = --print $ sort \"56847846846\"\n interact $ solve.head.take 1.lines\nsolve :: String->String\nsolve xs = tail. foldr (g) \"\" $ sort $ foldr (f) \"\" xs\n where f a b | a=='+'=b\n | otherwise = a:b ;\n g a b = \"+\"++ (a:b)"}, {"source_code": "import Data.List\n\ninsertPlus :: String -> String\ninsertPlus [] = []\ninsertPlus (x:xs) = x :'+' : insertPlus xs\n\nhelpfulMaths :: String -> String\nhelpfulMaths xs = take (length(xs)) (insertPlus $ sort $ filter (\\x -> x /= '+') xs)\n\nmain = do\n s <- getLine\n putStr $ helpfulMaths s\n"}, {"source_code": "import Data.List\n\nsolve :: String -> String\nsolve l = intersperse '+' . sort $ filter (/='+') l\n\nmain = do\n l <- getLine\n putStrLn $ solve l\n"}, {"source_code": "\nimport Data.List (intercalate)\n\nsolve :: String -> String\nsolve s = intercalate \"+\"\n $ concat [replicate a \"1\", replicate b \"2\", replicate c \"3\"]\n where\n \ta = length $ filter (=='1') s\n \tb = length $ filter (=='2') s\n \tc = length $ filter (=='3') s\n\nmain :: IO ()\nmain = getLine >>= putStrLn . solve\n"}, {"source_code": "import Data.List\nmain :: IO()\nmain = getLine >>= putStrLn . intersperse '+' . sort . filter (/= '+')"}, {"source_code": "-- Codeforces 339A\n\nimport Data.List\n\nmain :: IO ()\nmain = getLine >>= putStrLn . solve . zip [1..]\n\nsolve :: [(Int, Char)] -> String\nsolve xs = tail $ foldl (\\a b -> (a ++ [snd (cs !! ((fst b) `div` 2))] ++ [snd b])) [] ns where\n ns = zip [1..] $ map snd $ sortBy (\\a b -> (compare (snd a) (snd b))) $ filter (\\x -> (fst x) `mod` 2 == 1) xs\n cs = [(0, ' ')] ++ filter (\\x -> (fst x) `mod` 2 == 0) xs"}, {"source_code": "{-# LANGUAGE OverloadedStrings #-}\nimport qualified Data.ByteString.Lazy.Char8 as B\nimport Control.Applicative\nimport Control.Arrow\nimport Data.Char\nimport qualified Data.Map as M\n\nmain = do\n s <- B.split '+' . B.takeWhile (not . isSpace) <$> B.getContents\n let ms = M.toList . M.fromListWith (+) $ map (id &&& const 1) s\n out= concatMap (uncurry $ flip replicate) ms\n B.putStrLn . B.intercalate \"+\" $ out"}, {"source_code": "import Data.List\n\nseparateBy _ [] = []\nseparateBy c xs =\n case span (/=c) xs of\n (left, []) -> [left]\n (left, (_:right)) -> left:separateBy c right\n\nsolve expr = intercalate \"+\" $ map show $ sort $ map (read :: String -> Int) $ separateBy '+' expr\n\nmain = interact solve\n"}, {"source_code": "import Data.List\n\nmain = do\n\tsum <- getLine\n\tlet notPlus str = filter (\\char -> not $ char == '+') str\n\tlet mapStrings str = map (\\char -> [char]) str\n\tlet implode arr = intercalate \"+\" arr\n\tputStrLn . implode . mapStrings . sort . notPlus $ sum"}, {"source_code": "import Data.List\n\nseparate :: String -> [String]\nseparate xs = words [if x /= '+' then x else ' ' | x <- xs]\n\nmain = do\n ints <- fmap (map read . separate) getLine :: IO [Int]\n putStrLn $ intercalate \"+\" $ map show $ sort ints\n\n"}, {"source_code": "import Data.List (sort)\n\n\naddplus a = tail [if y == 1 then x else '+' | x <- a, y <- [0..1]]\nsolve a = putStrLn $ addplus (sort (filter (\\c -> c /= '+') (a)))\nmain = getLine >>= solve"}, {"source_code": "import Control.Monad\nimport Data.Array\nimport Data.Char\nimport Data.List\nimport qualified Data.ByteString.Char8 as B\ngetList :: Read a => IO [a]\ngetList = fmap (map (read . B.unpack) . B.words) B.getLine\ngetIntList :: IO [Int]\ngetIntList = fmap (unfoldr (B.readInt . B.dropWhile isSpace)) B.getLine\n\nsolve :: String -> String\nsolve = intersperse '+' . sort . filter (/= '+')\n\nmain :: IO ()\nmain = getLine >>= putStrLn . solve\n \n"}, {"source_code": "-- Helpful Maths\nimport Data.List\nimport Data.List.Split\n\nmain = do\n contents <- getLine\n putStrLn $ intercalate \"+\" $ sort $ splitOn \"+\" contents\n"}, {"source_code": "import Data.List\n\nmain::IO()\nmain=do\n x <- getLine\n putStrLn $ intersperse '+' $ sort $ filter (/='+') x\n"}, {"source_code": "import Data.Text hiding (map, init)\nimport Data.List (sort)\nsolve :: String -> String\nsolve = unpack . intercalate (pack \"+\") . sort . splitOn (pack \"+\") . pack . init\nmain = interact solve"}, {"source_code": "import Data.List\nimport Data.Char\nimport Control.Applicative\n\n\n\nmain::IO ()\nmain= do\n intersperse '+' <$> sort <$> filter (/='+') <$> getLine >>=putStrLn\n \n"}, {"source_code": "main = do\n\tequ <- getLine\n\tlet wiou = [a | a <- equ, a /= '+']\n\tlet sorted = quicksort wiou\n\tputStrLn $ addd sorted []\n\naddd :: String -> String -> String\naddd [] s = s\naddd (c:s) [] = addd s [c]\naddd (c:s) t = addd s (c:'+':t)\n\nquicksort :: (Ord a) => [a] -> [a]\nquicksort [] = []\nquicksort (x:xs) =\n let smallerSorted = quicksort [a | a <- xs, a <= x]\n biggerSorted = quicksort [a | a <- xs, a > x]\n in biggerSorted ++ [x] ++ smallerSorted"}, {"source_code": "import Data.List (sort)\nimport Data.Char (isDigit)\n\nmain :: IO ()\nmain = getLine >>= putStrLn . tail . foldr (\\c s -> '+' : c : s) \"\" . sort . filter isDigit\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = do\n s <- getLine\n s <- return $ fmap (:[]) $ sort $ filter (/='+') s\n putStrLn $ concat $ intersperse \"+\" s\n"}, {"source_code": "import Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Char \n\nimport qualified Data.ByteString.Char8 as B\nreadInt = readLn :: IO Int\nreadInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine\n\nreorder :: String -> String\nreorder = intercalate \"+\" . sort . map (:[]) . filter (/='+')\n\nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn $ reorder s"}, {"source_code": "import Data.List\n\nsplitAlternate:: String -> String\nsplitAlternate s\n | l == 1 = s\n | otherwise = head s : (splitAlternate(tail(tail s)))\n where l = length s\n\nmain = do\n interact $ intersperse '+' . sort . splitAlternate . init\n"}, {"source_code": "import Control.Applicative\nimport Data.List (intersperse, sort)\n\n-- misc.\nreadInt :: String -> Int\nreadInt = read\n\nsplit :: (Eq a) => a -> [a] -> [[a]]\nsplit _ [] = []\nsplit x ys = p : (if null qs then [] else split x (tail qs))\n where (p,qs) = break (==x) ys\n\n-- problem\nmain = putStrLn =<< (intersperse '+' . concatMap show . sort . map readInt . split '+') <$> getLine\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = interact (intersperse '+' . sort . filter (/= '+') . head . lines)\n"}, {"source_code": "import Data.Char\nimport Data.List\nmain = getLine >>= putStrLn . intersperse '+' . map intToDigit . sort . map digitToInt . filter (/= '+')\n"}, {"source_code": "module Main where\n\nimport Data.List (intercalate, sort)\nimport Data.Char (digitToInt)\n\nfilterList :: String -> [Int]\nfilterList = sort . fmap digitToInt . filter (/= '+')\n\nmain :: IO ()\nmain = do\n numbers <- fmap filterList getLine\n putStrLn $ intercalate \"+\" (fmap show numbers)\n"}, {"source_code": "count :: String -> (Int, Int, Int) -> (Int, Int, Int)\ncount [] t = t\ncount (x : xs) (a, b, c)\n | x == '1' = count xs (a + 1, b, c)\n | x == '2' = count xs (a, b + 1, c)\n | x == '3' = count xs (a, b, c + 1)\n | otherwise = count xs (a, b, c)\n\nmakeAns :: (Int, Int, Int) -> String\nmakeAns (0, 0, 1) = \"3\"\nmakeAns (0, 1, 0) = \"2\"\nmakeAns (1, 0, 0) = \"1\"\nmakeAns (0, 0, c) = '3' : '+' : makeAns (0, 0, c - 1)\nmakeAns (0, b, c) = '2' : '+' : makeAns (0, b - 1, c)\nmakeAns (a, b, c) = '1' : '+' : makeAns (a - 1, b, c)\n\nmain = do\n s <- getLine\n putStrLn $ makeAns $ count s (0, 0, 0)"}, {"source_code": "import Data.List\n\nsolve :: String -> String\nsolve = intersperse '+' . sort . filter (/= '+')\n\nmain = getLine >>= putStrLn . solve\n"}, {"source_code": "module Main where\nimport Data.List\nimport Control.Applicative\nmain = putStrLn =<< tail . foldl (\\s n -> s ++ \"+\" ++ [n]) \"\" . sort . filter (/='+') <$> getLine\n"}, {"source_code": "import Data.List\nimport Data.Char\nmain = interact $ (intersperse '+' . sort . foldr (\\x xs -> (if isDigit x then [x] else []) ++ xs) [])\n"}, {"source_code": "import Data.Char\nimport Data.Text (Text, pack, unpack, split)\nimport Data.List (sort)\n\nh :: String -> [Text]\nh str = sort $ split (== '+') $ pack str\n\nf :: [Text] -> String\nf [x] = unpack x\nf (x:xs) = (unpack x) ++ \"+\" ++ f xs\n\nmain :: IO()\nmain = do\n a <- getLine\n putStrLn $ f $ h a\n"}, {"source_code": "import System.IO\nimport Data.List\n\nsolve :: String -> String\nsolve [a] = [a]\nsolve (a:as) = a : '+' : solve as \n \nmain = getLine >>= (\\str -> putStrLn . solve . dropWhile (=='+') $ sort str)"}, {"source_code": "import Data.List (intersperse, sort)\n\nmain = do\n s <- intersperse '+' . sort . filter (/= '+') <$> getLine\n putStrLn s\n"}, {"source_code": "module Main where\nimport Data.Char\nimport Data.Maybe\nimport Data.Function\nimport Data.List\nimport System.Environment\nimport qualified Data.ByteString.Char8 as C\n\nmain = do\n\tparamStr <- getLine\n\tlet\n\t\tparam = readIntsFromStr paramStr\n\t\tin putStrLn $ id ((intercalate \"+\") . (map show) . sort $ param)\n\nwordsWhen :: (Char -> Bool) -> String -> [String]\nwordsWhen p s = case dropWhile p s of\n \"\" -> []\n s' -> w : wordsWhen p s''\n where (w, s'') = break p s'\n\t\t\t\t\t\t\t\nreadIntsFromStr :: String -> [Int]\nreadIntsFromStr str = map readInt (filter p (wordsWhen (=='+') str))\n\twhere p = (/=)\"\"\n\nreadInt :: String -> Int\nreadInt = read"}, {"source_code": "{-# LANGUAGE Safe #-}\n{-# Options_GHC -O3 #-}\nimport Control.Monad\nimport Control.Monad.ST\nimport Data.Array\nimport Data.Array.IO.Safe\nimport Data.Bits\nimport Data.ByteString.Builder\nimport Data.Char\nimport Data.Monoid\nimport Data.Int\nimport Data.Time (diffTimeToPicoseconds, utctDayTime, getCurrentTime)\nimport qualified Data.Array.Unboxed as U\nimport qualified Data.ByteString.Char8 as C\nimport System.IO\n\nqsort :: (Ord e, MArray a e m) => a Int e -> [Int] -> m ()\nqsort x rnds = do\n bds@(l',r') <- getBounds x\n let\n srt l r (y:ys) = do\n xm <- readArray x (l + mod y (r - l + 1))\n let\n f i j\n | i > j = return (i, j)\n | otherwise = do\n let g' i = do\n xi <- readArray x i\n if xm > xi then g' (succ i) else return i\n g'' j = do\n xj <- readArray x j\n if xm < xj then g'' (pred j) else return j\n i' <- g' i\n j' <- g'' j\n if i' <= j' then do\n v1 <- readArray x i'\n v2 <- readArray x j'\n writeArray x i' v2\n writeArray x j' v1\n f (succ i') (pred j')\n else return (i', j')\n (i'', j'') <- f l r\n when (l < j'') $ srt l j'' ys\n when (i'' < r) $ srt i'' r ys\n srt l' r' rnds\n\ngetSeed :: IO Int\ngetSeed = do t <- getCurrentTime; return $ fromInteger $ (`mod` 999983) $ diffTimeToPicoseconds $ utctDayTime t\n\npmGen :: Int -> Int\npmGen x = fromIntegral (mod ((16807::Int64) * fromIntegral x) 2147483647)\n\nmain = do\n seed <- getSeed\n s <- C.getLine\n let a = C.split '+' $ C.takeWhile isPrint s\n randoms = seed : map pmGen randoms\n arr <- newListArray (1, length a) a :: IO (IOArray Int C.ByteString)\n qsort arr randoms\n e <- getElems arr\n C.putStrLn $ C.intercalate (C.pack \"+\") e\n"}, {"source_code": "\nf1 :: String -> String\nf1 [] = []\nf1 (x:xs) = ('+':x:f1 xs)\n\nf2 :: String -> String\nf2 [] = []\nf2 (x:xs) \n | x == '+' = f2 xs\n | otherwise = (x:f2 xs)\n\nmsort' :: String -> String\nmsort' [] = []\nmsort' [x] = [x]\nmsort' x = merge' left right\n where left = msort' $ take m x\n right = msort' $ drop m x\n m = div (length x + 1) 2\n\nmerge' :: String -> String -> String\nmerge' [] [] = []\nmerge' (x:xs) [] = (x:merge' xs [])\nmerge' [] (y:ys) = (y:merge' ys [])\nmerge' (x:xs) (y:ys) \n | x <= y = (x:merge' xs (y:ys))\n | otherwise = (y:merge' (x:xs) ys) \n\nmain = do\n a <- getLine\n putStrLn $ tail $ f1 $ msort' $ f2 a"}, {"source_code": "import Data.List(sort)\n\nmain = interact $ join '+' . sort . split '+' . filter (/='\\n')\n\nsplit _ [] = \"\"\nsplit c (h:ls) = if c==h then split c ls else h : split c ls\n\njoin c [h] = [h]\njoin c (h:ls) = h : c : join c ls\n"}, {"source_code": "import Data.List (sort)\n\nsplit :: Char -> String -> [String]\nsplit _ \"\" = [\"\"]\nsplit c s | null r2 = [r1]\n | otherwise = r1 : split c (tail r2)\n where\n (r1, r2) = span (/= c) s\n\n\njoin :: String -> [String] -> String\njoin x s = foldr1 (\\s1 s2 -> s1 ++ x ++ s2) s\n\n\nmain :: IO ()\nmain = do\n x <- getLine\n putStrLn $ join \"+\" $ sort $ split '+' x"}, {"source_code": "import Data.List\n\nsplitOn _ [] = []\nsplitOn c xs = as : splitOn c (dropWhile f bs)\n where (as, bs) = break f xs\n f x = x == c\n\nmain = interact $ intercalate \"+\" . sort . splitOn '+' . head . words\n"}, {"source_code": "import Data.List.Split\nimport Data.List\n\nmain::IO()\nmain = do \n input <- getLine \n (putStrLn . (intercalate \"+\") . sort . (splitOn \"+\")) input\n"}, {"source_code": "import Data.List\n\nseconds :: [a] -> [a]\nseconds [] = []\nseconds [x] = [x]\nseconds (x:_:xs) = x : seconds xs\n\nmain :: IO ()\nmain = fmap (intersperse '+' . sort . seconds) getLine >>= putStrLn\n\n"}, {"source_code": "import Control.Applicative\nimport Data.Char\n\n \nmain= do\n\ts<-getLine \n\tlet n1 = length $ filter (=='1') s\n\tlet n2 = length $ filter (=='2') s\n\tlet n3 = length $ filter (=='3') s\n\tputStrLn $ init $ concat $ map concat [replicate n1 \"1+\" , replicate n2 \"2+\",replicate n3 \"3+\"]\n\t "}, {"source_code": "import Data.List\n\nsplit:: String->[String]\nsplit s\n | snd breakedString == \"\" = [fst(breakedString)]\n | otherwise = fst(breakedString):split(tail(snd breakedString))\n where breakedString = break (=='+') s\n\nconvert::[[a]] -> [a]\nconvert [] = []\nconvert (x:xs) = x ++ convert(xs)\n\njoin xs = intersperse '+' (convert([show x | x <- xs]))\n\nmain = do\n input <- getLine\n putStrLn(join(sort([read n::Int|n <- split(input)])))"}, {"source_code": "sort [] = []\nsort (x:xs) = (sort shorter) ++ (x : sort greater)\n where shorter = [y|y <- xs, y<=x]\n greater = [y|y <- xs, y>x]\n\ncout xs = case xs of [x] -> show x\n (y:ys) -> (show y) ++ \"+\" ++ (cout ys)\n \nmain = do\n x <- getLine\n putStrLn $ (cout . sort . map (\\y -> read [y] :: Int) . filter (/='+')) x\n "}, {"source_code": "main = do\n m <- getLine\n let n = splitOn '+' m\n let t = s123 n\n let ret = unsplitOn '+' t\n putStrLn ret\nsplitOn :: Char -> String -> [Int]\nsplitOn _ [] = []\nsplitOn c x = (read (takeWhile (/= c) x)) : (splitOn c (tailo $ dropWhile (/= c) x))\nunsplitOn :: Char -> [Int] -> String\nunsplitOn x = (tail) . (foldr (\\y -> ((x:).((show y)++))) [])\ntailo :: [a] -> [a]\ntailo [] = []\ntailo x = tail x\ns123 :: [Int] -> [Int]\ns123 x = (filter (==1) x) ++ (filter (==2) x) ++ (filter (==3) x)"}, {"source_code": "import Data.List ( intersperse\n , sort\n )\nmain :: IO ()\nmain = do\n numbers <- filter ('+' /=) <$> getLine \n putStrLn $ intersperse '+' $ sort numbers"}, {"source_code": "import Data.List\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Data.Char\nimport Data.Ratio\n\nmain :: IO ()\nmain = getLine >>= putStrLn. intersperse ('+') .sort. filter (/='+')\n\n"}, {"source_code": "import Data.List\n\nglue::String->String\nglue [x] = [x]\nglue [] = []\nglue (x:xs) = x:'+': glue xs\n\nanswer::String->String\nanswer = glue . sort . filter (/='+')\n\nsomeFunc :: IO()\nsomeFunc = getLine >>= putStrLn . answer\n \nmain :: IO ()\nmain = someFunc"}, {"source_code": "import Data.List\nmain = getLine >>= putStrLn.intersperse '+'.sort.filter (/= '+')"}, {"source_code": "import Data.List (sort, intersperse)\n\nprocess :: String -> String\nprocess = intersperse '+'.sort.filter (/='+')\n\nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn $ process s"}, {"source_code": "import Data.List\n\nmain = getContents >>=\n putStrLn . intersperse '+' . sort . filter (\\c -> c /= '+' && c /= '\\n')\n"}, {"source_code": "{-# LANGUAGE OverloadedStrings #-}\nmodule Main where\n\nimport Data.Either\nimport Data.List\nimport qualified Data.Text as T\nimport qualified Data.Text.IO as TIO\nimport qualified Data.Text.Lazy as TL\nimport qualified Data.Text.Lazy.IO as TLIO\nimport qualified Data.Text.Lazy.Read as TLR\nimport qualified Data.Text.Read as TR\n\nmain :: IO ()\nmain = do\n input <- TLIO.getContents\n let s = TL.splitOn \"+\" input\n xs = map fst $ sort.rights $ map TLR.decimal s\n putStrLn (intercalate \"+\" (map show xs))\n\ntoList :: String -> [Integer]\ntoList input = map read (words input)\n"}, {"source_code": "{-# LANGUAGE OverloadedStrings #-}\nmodule Main where\n\nimport Data.Either\nimport Data.List\nimport qualified Data.Text as T\nimport qualified Data.Text.IO as TIO\nimport qualified Data.Text.Read as TR\n\nmain :: IO ()\nmain = do\n input <- TIO.getContents\n let s = T.splitOn \"+\" input\n xs = map fst $ sort.rights $ map TR.decimal s\n putStrLn (intercalate \"+\" (map show xs))\n\ntoList :: String -> [Integer]\ntoList input = map read (words input)\n"}, {"source_code": "module Main where\nimport Data.List (intercalate, sort)\n\nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn $ pp $ sort $ rush s\n\npp :: [Int] -> String\npp = intercalate \"+\" . map show\n\nrush :: String -> [Int]\nrush [x] = [read [x]]\nrush (h:rest) = read [h] : rush (tail rest)\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = getLine >>= putStrLn . intersperse '+' . sort . filter (/='+')\n-- intersperse \n-- >>= monad uses the result of previous action\n"}, {"source_code": "import Data.List\n\nsolve :: String -> String\nsolve = intercalate \"+\" . sort . splitWhen (`elem` \"+\\n\")\n\nsplitWhen :: (a -> Bool) -> [a] -> [[a]]\nsplitWhen p s = case dropWhile p s of\n [] -> []\n s' -> w : splitWhen p s''\n where (w, s'') = break p s'\n\nmain :: IO ()\nmain = interact solve"}, {"source_code": "{-# LANGUAGE OverloadedStrings #-}\nimport Data.List (sort)\nimport Control.Monad\n\nimport qualified Data.Text as T\nimport qualified Data.Text.IO as TIO\nimport System.IO (stdin)\nimport Data.Text.Read (decimal)\n\nimport Data.List (intercalate)\n\ntread s = case decimal s of\n Right (v, _) -> v\n Left e -> error e \n\n\n\nmain = do\n aa <- TIO.hGetLine stdin\n let p = T.splitOn \"+\" aa\n let xs' = sort $ map (read . T.unpack) p :: [Int]\n\n let ys = intercalate \"+\" $ map show xs'\n putStrLn ys \n\n"}, {"source_code": "module Main (main)\n where\n\nimport Data.Char (ord)\nimport Data.List (sort, intersperse)\n\n\nmain :: IO ()\nmain = putStrLn . intersperse '+' . sort . extract =<< getLine\n where extract [] = []\n extract (x:_:xs) = x:extract xs\n extract (x:xs) = x:extract xs"}, {"source_code": "import Data.List (sort, foldl', intersperse)\n\ngetNumbers :: String -> [Int]\ngetNumbers [] = []\ngetNumbers s = number : getNumbers b\n where notPlus = \\x -> x /= '+'\n number = read . takeWhile notPlus $ s\n rest = dropWhile notPlus s\n b = if null rest then rest else tail rest\n\nanswer :: String -> String\nanswer s = concat . intersperse \"+\" . map show . sort . getNumbers $ s\n\nmain = interact answer\n"}, {"source_code": "import Control.Monad\nimport Data.List\nimport Data.Char\n\nreplace :: Char -> Char -> Char\nreplace a x = if x == a then ' ' else x\n\ninsertp :: String -> String -> String\ninsertp a b = if length a > 0 then a ++ \"+\" ++ b else b\n\nmain :: IO ()\nmain = do\n line <- getLine\n let s = map (replace '+') line\n let l = sort $ words s\n putStrLn (foldl insertp \"\" l)\n"}, {"source_code": "module Main where\n\nimport Data.List\n\n(|>) = flip (.)\n\nmain = interact $\n lines \n |> head |> takeWhile (/= '\\n')\n |> filter (/= '+')\n |> sort\n |> map (\\x -> [x])\n |> intercalate \"+\"\n"}, {"source_code": "import Data.List.Split\nimport Data.List\nmain = interact $ intercalate \"+\".sort.splitOn \"+\".last.lines\n"}], "negative_code": [{"source_code": "main :: IO ()\nmain = do\n line <- getLine\n print $ foldr (+) 0 $ map (read :: String -> Int) (splitOn '+' line)\n\nsplitOn :: Char -> String -> [String]\nsplitOn c s =\n case s of\n [] -> []\n _ -> s' : splitOn c (dropWhile (== c) s'')\n where (s', s'') = span (/= c) s"}, {"source_code": "\n\ng1 :: [Int] -> [Int]\ng1 (a:s) = (a + 1):s\n\ng2 :: [Int] -> [Int]\ng2 (a:b:s) = (a):(b + 1):s\n\ng3 :: [Int] -> [Int]\ng3 (a:b:c:s) = (a):(b):(c + 1):s\n\nsolve :: String -> [Int]\nsolve \"\" = [0, 0, 0]\nsolve ('+':s) = solve s \nsolve ('1':s) = g1 (solve s)\nsolve ('2':s) = g2 (solve s)\nsolve ('3':s) = g3 (solve s)\n\ngen :: [Int] -> String\ngen [0, 0, 0] = \"\"\ngen [0, 0, a] = \"+3\" ++ (gen [0, 0, a - 1])\ngen [0, a, b] = \"+2\" ++ (gen [0, a - 1, b])\ngen [a, b, c] = \"+1\" ++ (gen [a - 1, b, c])\n\ncuttt (ch:s) = s\n\nmain = do \n s <- getLine\n let t = solve s\n let answer = gen t;\n print (cuttt answer);\n \n"}, {"source_code": "import Data.List\nmain = interact $ intersperse '+' . sort . filter (/= '+')"}, {"source_code": "import Data.List\n\nmain = do\n str <- getLine\n let grep str = _grep str where\n _grep \"\" = \"\"\n _grep (x:xs) = (if x == '+' then ' ' else x) : (grep xs)\n\n let xs = map read $ words str :: [Int]\n\n putStrLn (drop 4 (intersperse '+' (sort (grep str)))) \n"}, {"source_code": "import Data.List\n\nmain = do\n str <- getLine\n let grep str = _grep str where\n _grep \"\" = \"\"\n _grep (x:xs) = (if x == '+' then ' ' else x) : (grep xs)\n\n let xs = map read $ words str :: [Int]\n\n print (drop 4 (intersperse '+' (sort (grep str)))) \n"}, {"source_code": "import Data.List\n\ninsertPlus :: String -> String\ninsertPlus [] = []\ninsertPlus (x:xs) = x :'+' : insertPlus xs\n\nhelpfulMaths :: String -> String\nhelpfulMaths xs = take (length(xs)) (insertPlus $ sort $ filter (\\x -> x /= '+') xs)\n\nmain = do\n s <- getContents\n putStr $ helpfulMaths s\n"}, {"source_code": "import Data.List\n\nmain::IO()\nmain=do\n x <- getLine\n putStrLn $ show $ intersperse '+' $ sort $ filter (/='+') x\n"}, {"source_code": "import Data.Text hiding (map)\nimport Data.List (sort)\nsolve :: String -> String\nsolve = unpack . intercalate (pack \"+\") . sort . splitOn (pack \"+\") . pack\nmain = interact solve"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = interact (intersperse '+' . sort . filter (/= '+'))\n"}, {"source_code": "import Data.List(sort)\n\nmain = interact $ join '+' . sort . split '+'\n\nsplit _ [] = \"\"\nsplit c (h:ls) = if c==h then split c ls else h : split c ls\n\njoin c [h] = [h]\njoin c (h:ls) = h : c : join c ls\n"}, {"source_code": "import Data.List\n\nsplitOn _ [] = []\nsplitOn c xs = as : splitOn c (dropWhile f bs)\n where (as, bs) = break f xs\n f x = x == c\n\nmain = interact $ intercalate \"+\" . sort . splitOn '+'\n"}, {"source_code": "main = do\n m <- getLine\n let n = sum $ splitOn '+' m\n print n\nsplitOn :: Char -> String -> [Int]\nsplitOn _ [] = []\nsplitOn c x = (read (takeWhile (/= c) x)) : (splitOn c (tailo $ dropWhile (/= c) x))\ntailo :: [a] -> [a]\ntailo [] = []\ntailo x = tail x"}, {"source_code": "import Data.List\n\nmain = getContents >>=\n print . intersperse '+' . sort . filter (\\c -> c /= '+' && c /= '\\n')\n"}, {"source_code": "import Data.List\n\nmain = getContents >>=\n print . intersperse '+' . sort . filter ('+'/=)\n"}, {"source_code": "import Data.List\n\nsolve :: String -> String\nsolve = intercalate \"+\" . sort . splitWhen (== '+')\n\nsplitWhen :: (a -> Bool) -> [a] -> [[a]]\nsplitWhen p s = case dropWhile p s of\n [] -> []\n s' -> w : splitWhen p s''\n where (w, s'') = break p s'\n\nmain :: IO ()\nmain = interact solve"}, {"source_code": "import Data.List.Split\nimport Data.List\nmain = interact $ intercalate \"+\".sort.splitOn \"+\"\n"}, {"source_code": "import Data.Text(pack,unpack,split)\nimport Data.List\nmain=interact(intercalate\"+\".sort.map unpack.split(=='+').pack)"}, {"source_code": "\n\nimport Data.List\n\nsolve s = myShow $ sort $ splitOn '+' s \n\nmyShow [] = \"\"\nmyShow (s:ss) | null ss = s ++ myShow ss\n | otherwise = s ++ \"+\" ++ myShow ss\n\nmain = interact $ solve\n\nsplitOn::Char->String->[String]\nsplitOn f [] = []\nsplitOn f ss = [takeWhile (/=f) ss] ++ splitOn f (stail (dropWhile (/=f) ss))\n\nstail [] = []\nstail (s:[]) = []\nstail s = tail s"}, {"source_code": " import Data.List\n import Data.List.Split\n f x =intercalate \"+\" (sort$splitOn \"+\" x) \n main=interact$f"}, {"source_code": " import Data.List\n f x =intersperse '+' (sort [e | e<-x,e/='+'])\n main=interact$f"}], "src_uid": "76c7312733ef9d8278521cf09d3ccbc8"} {"source_code": "solve :: (Int, Int) -> (Int, Int) -> (Int, Int) -> Int\nsolve (x1, y1) (x2, y2) (x3, y3)\n | (x1 == x2 && x1 == x3) = 1\n | (y1 == y2 && y1 == y3) = 1\n | (x1 == x2 && (y3 <= (min y1 y2) || y3 >= (max y1 y2))) = 2\n | (y1 == y2 && (x3 <= (min x1 x2) || x3 >= (max x1 x2))) = 2\n | otherwise = 3\n\npoint :: [Int] -> (Int, Int)\npoint (x:y:_) = (x, y)\n\ngetPoint :: IO (Int, Int)\ngetPoint = do\n line <- getLine\n return (point (map read (words line)))\n\nmain = do\n a <- getPoint\n b <- getPoint\n c <- getPoint\n putStrLn (show (minimum [(solve a b c), (solve a c b), (solve b a c), (solve b c a), (solve c a b), (solve c b a)]))\n\n", "positive_code": [{"source_code": "-- Codeforces 617D\n\n{-# LANGUAGE MultiWayIf #-}\n\nimport Control.Applicative\n\nmain :: IO ()\nmain = do\n [a1, a2] <- (map read . words) <$> getLine :: IO [Int]\n [b1, b2] <- (map read . words) <$> getLine :: IO [Int]\n [c1, c2] <- (map read . words) <$> getLine :: IO [Int]\n print $ if | a1 == b1 && b1 == c1 -> 1\n | a2 == b2 && b2 == c2 -> 1\n | a1 == b1 && (c2 >= a2 && c2 >= b2 || c2 <= a2 && c2 <= b2) -> 2\n | a1 == c1 && (b2 >= a2 && b2 >= c2 || b2 <= a2 && b2 <= c2) -> 2\n | b1 == c1 && (a2 >= b2 && a2 >= c2 || a2 <= b2 && a2 <= c2) -> 2\n | a2 == b2 && (c1 >= a1 && c1 >= b1 || c1 <= a1 && c1 <= b1) -> 2\n | a2 == c2 && (b1 >= a1 && b1 >= c1 || b1 <= a1 && b1 <= c1) -> 2\n | b2 == c2 && (a1 >= b1 && a1 >= c1 || a1 <= b1 && a1 <= c1) -> 2\n | otherwise -> 3\n"}, {"source_code": "-- There are three points marked on the coordinate plane. The goal is to make\n-- a simple polyline, without self-intersections and self-touches, such that it\n-- passes through all these points. Also, the polyline must consist of only\n-- segments parallel to the coordinate axes. You are to find the minimum number\n-- of segments this polyline may consist of.\n--\n-- Input\n-- Each of the three lines of the input contains two integers. The i-th line\n-- contains integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — the coordinates of the\n-- i-th point. It is guaranteed that all points are distinct.\n--\n-- Output\n-- Print a single number — the minimum possible number of segments of the polyline.\n--\n-- Found at: http://codeforces.com/contest/617/problem/D\n--\n\nmodule Main where\nimport Data.List(permutations)\n\ntype Coords = (Int,Int)\ntype Direction = (Int,Int)\n\ndirection :: Coords -> Coords -> Direction\ndirection (x1,y1) (x2,y2) = (signum $ x2 - x1, signum $ y2 - y1)\n\ndirections :: [Coords] -> [Direction]\ndirections pts = zipWith direction pts (tail pts)\n\ndiagonal :: Direction -> Bool\ndiagonal (dx,dy) = (abs dx + abs dy) == 2\n\nopposite :: Direction -> Direction -> Bool\nopposite (dx1,dy1) (dx2,dy2) = (dx1,dy1) == (-dx2,-dy2)\n\nsegs :: [Coords] -> Int\nsegs pts = sum $ zipWith segsForMove dirs (tail dirs)\n where dirs = (0,0) : directions pts -- (0,0) for 'how to get to first point'\n\nsegsForMove :: Direction -> Direction -> Int\nsegsForMove d1 d2@(dx2,dy2)\n | d1 == (0,0) = abs dx2 + abs dy2\n | continuable d1 d2 = if diagonal d2 then 1 else 0\n | diagonal d2 = 2\n | opposite d1 d2 = 3\n | otherwise = 1\n\ncontinuable :: Direction -> Direction -> Bool\ncontinuable (dx1,dy1) (dx2,dy2)\n | dx1 /= 0 && dx1 == dx2 = True\n | dy1 /= 0 && dy1 == dy2 = True\n | otherwise = False\n\n\nmain :: IO ()\nmain = do\n line1 <- getLine\n line2 <- getLine\n line3 <- getLine\n let [x1,y1] = map read $ words line1 :: [Int]\n [x2,y2] = map read $ words line2 :: [Int]\n [x3,y3] = map read $ words line3 :: [Int]\n let perms = permutations [(x1,y1),(x2,y2),(x3,y3)]\n let best = minimum $ map segs perms\n putStrLn $ show best\n"}], "negative_code": [{"source_code": "solve :: (Int, Int) -> (Int, Int) -> (Int, Int) -> Int\nsolve (x1, y1) (x2, y2) (x3, y3)\n | (x1 == x2 && x1 == x3) = 1\n | (y1 == y2 && y1 == y3) = 1\n | (x1 == x2 && (y3 <= (min y1 y2) || y3 >= (max y1 y2))) = 2\n | (y1 == y2 && (x3 <= (min x1 x2) || x3 >= (max x1 x2))) = 2\n | otherwise = 3\n\npoint :: [Int] -> (Int, Int)\npoint (x:y:_) = (x, y)\n\ngetPoint :: IO (Int, Int)\ngetPoint = do\n line <- getLine\n return (point (map read (words line)))\n\nmain = do\n a <- getPoint\n b <- getPoint\n c <- getPoint\n putStrLn (show (minimum [(solve a b c), (solve b a c), (solve c a b)]))\n\n"}, {"source_code": "solve :: (Int, Int) -> (Int, Int) -> (Int, Int) -> Int\nsolve (x1, y1) (x2, y2) (x3, y3)\n | (x1 == x2 && x1 == x3) = 1\n | (y1 == y2 && y1 == y3) = 1\n | (x1 == x2 && y1 == y3 && (y3 <= (min y1 y2) || y3 >= (max y1 y2))) = 2\n | (y1 == y2 && x1 == x3 && (x3 <= (min x1 x2) || x3 >= (max x1 x2))) = 2\n | otherwise = 3\n\npoint :: [Int] -> (Int, Int)\npoint (x:y:_) = (x, y)\n\ngetPoint :: IO (Int, Int)\ngetPoint = do\n line <- getLine\n return (point (map read (words line)))\n\nmain = do\n a <- getPoint\n b <- getPoint\n c <- getPoint\n putStrLn (show (minimum [(solve a b c), (solve b a c), (solve c a b)]))\n\n"}, {"source_code": "solve :: (Int, Int) -> (Int, Int) -> (Int, Int) -> Int\nsolve (x1, y1) (x2, y2) (x3, y3)\n | (x1 == x2 && x1 == x3) = 1\n | (x1 == x2 && y1 == y3 && (y3 <= (min y1 y2) || y3 >= (max y1 y2))) = 2\n | (y1 == y2 && x1 == x3 && (x3 <= (min x1 x2) || x3 >= (max x1 x2))) = 2\n | otherwise = 3\n\npoint :: [Int] -> (Int, Int)\npoint (x:y:_) = (x, y)\n\ngetPoint :: IO (Int, Int)\ngetPoint = do\n line <- getLine\n return (point (map read (words line)))\n\nmain = do\n a <- getPoint\n b <- getPoint\n c <- getPoint\n putStrLn (show (minimum [(solve a b c), (solve b a c), (solve c a b)]))\n\n"}], "src_uid": "36fe960550e59b046202b5811343590d"} {"source_code": "num str = (read str) :: Integer\nm = 1000000007\nexp' :: Integer -> Integer -> Integer\nexp' _ 0 = 1\nexp' a 1 = a\nexp' a n = if mod n 2 == 0 then t * t `mod` m else t * t * a `mod` m\n where t = exp' a (n `div` 2)\nsolve n = if n == 0 then 1 else (exp' 2 (n-1) + 2 * exp' 4 (n-1)) `mod` m\nmain = do \n str <- getLine\n putStrLn (show (solve (num str)))\n", "positive_code": [{"source_code": "\nimport Data.List\nmatrix = [\n [3, 1]\n ,[1, 3]\n ]\n\nmult m1 m2 = md $ map (\\l -> foldr (zipWith (+)) (repeat 0) $ zipWith (\\i -> map (*i)) l m2) m1 {- where\n m2t = transpose m2 -}\n\nmd = map (map (\\x -> x `mod` 1000000007))\n\npow m 0 = [[1,0],[0,1]]\npow m 1 = m\npow m n = mult m' (mult m2 m2) where\n m2 = pow m (n `div` 2)\n m' = pow m (n `mod` 2)\n\nmain = interact $ show . head . head . pow matrix . read"}, {"source_code": "import Data.Bits\n\nmain = print . solver . read =<< getLine\n\nsolver :: Integer -> Integer\nsolver n = p\n where\n md = 10^9 + 7\n one = [1,0,0,1]\n a' = [3,1,1,3] : map (\\x -> x `mmul` x) a'\n b' = [ if testBit n i then a' !! i else one | i <- [0..63] ]\n (p:_) = foldl mmul one b'\n mmul [x,y,z,w] [a,b,c,d] = map (`mod`md) [x*a + y*c, x*b + y*d, z*a + w*c, z*b + w*d]\n\n-- vim: set expandtab:\n"}, {"source_code": "main = \n do\n year <- getLine\n putStrLn.show.solve$read year\n\n\n\nsolve :: Integer -> Integer\nsolve 0 = 1\nsolve y = \n let\n year = y - 1\n m = 1000000007\n a = myPow2 2 year m\n in\n (2*((a*a) `mod` m) + a) `mod` m\n \nmyPow2 :: (Integral a) => a -> a -> a -> a\nmyPow2 _ 0 _ = 1\nmyPow2 b e m\n | e < 10^6 = (b^e) `mod` m\n | otherwise =\n let\n ex = if even e then 1 else b\n half = e `div` 2\n part = (myPow2 b half m) `mod` m\n in\n (ex * part^2) `mod` m\n"}, {"source_code": "import Data.List\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Data.Char\n\n_mod :: Integer\n_mod = (10^9+7)\n\npow _ 0 = 1\npow a n \n | odd n = (tmp * a) `mod` _mod \n | otherwise = tmp\n where\n \ttmp1 = pow a (n `div` 2)\n\ttmp = (tmp1 * tmp1) `mod` _mod\n\nmain :: IO ()\nmain = do\n\tgetLine >>= print . (\\x -> x `mod` _mod). (\\x -> x*(x+1) `div` 2). (pow 2). (\\x -> read x )\n"}, {"source_code": "\nsolve :: Integer -> Integer\nsolve 0 = 1\nsolve n = mod (pow 2 (2*n - 1) + pow 2 (n - 1)) m\n where\n m = 10^9 + 7\n pow :: Integer -> Integer -> Integer\n pow p 0 = 1\n pow p n\n | mod n 2 == 0 = p''^2\n | otherwise = p' * p''^2\n where\n p' = mod p m\n p'' = mod (pow p' (div n 2)) m\n\nmain :: IO ()\nmain = readLn >>= print . solve\n"}, {"source_code": "import Data.List\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Data.Char\n\n_mod :: Integer\n_mod = (10^9+7)\n\npow _ 0 = 1\npow a n \n | odd n = (tmp * a) `mod` _mod \n | otherwise = tmp\n where\n \ttmp1 = pow a (n `div` 2)\n\ttmp = (tmp1 * tmp1) `mod` _mod\n\nmain :: IO ()\nmain = do\n\tgetLine >>= print . (`mod` _mod). (\\x -> x*(x+1) `div` 2). (pow 2). (\\x -> read x )\n"}, {"source_code": "main = do\n n <- readLn :: IO Integer\n if n==0\n then print 1\n else print $ (`rem`1000000007) $ pow 2 (n-1) + 2 * pow 4 (n-1)\n\npow :: Integer -> Integer -> Integer\npow x' n'\n | n' == 0 = 1\n | otherwise = f x' n'\n where f x n\n | even n = f (x.*.x) (n`quot`2)\n | n == 1 = x\n | otherwise = g (x.*.x) ((n-1)`quot`2) x\n g x n y\n | even n = g (x.*.x) (n`quot`2) y\n | n == 1 = x.*.y\n | otherwise = g (x.*.x) ((n-1)`quot`2) (x.*.y)\n\nx.*.y=(x*y)`rem`1000000007 "}], "negative_code": [{"source_code": "import Data.List\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Data.Char\n\n_mod :: Integer\n_mod = (10^9+7)\n\npow _ 0 = 1\npow a n \n | odd n = (tmp * a) `mod` _mod \n | otherwise = tmp\n where\n \ttmp1 = pow a (n `div` 2)\n\ttmp = (tmp1 * tmp1) `mod` _mod\n\nmain :: IO ()\nmain = do\n\tgetLine >>= print .(\\x -> x*(x+1) `div` 2). (pow 2). (\\x -> read x )\n"}, {"source_code": "import Data.Bits\n\nmain = print . solver . read =<< getLine\n\nsolver :: Integer -> Integer\nsolver n = p\n where\n md = 10^9 + 7\n one = [1,0,0,1]\n a' = [3,1,1,3] : map (\\x -> x `mmul` x) a'\n b' = [ if testBit n i then a' !! i else one | i <- [0..31] ]\n (p:_) = foldl mmul one b'\n mmul [x,y,z,w] [a,b,c,d] = map (`mod`md) [x*a + y*c, x*b + y*d, z*a + w*c, z*b + w*d]\n\n-- vim: set expandtab:\n"}], "src_uid": "782b819eb0bfc86d6f96f15ac09d5085"} {"source_code": "type Vec4 = (Integer, Integer, Integer, Integer)\n\nsplit :: Eq a => a -> [a] -> [[a]]\nsplit _ [] = []\nsplit cond xs = x : split cond (drop 1 y) where (x, y) = span (/= cond) xs\n\nprocess :: Vec4 -> Integer\nprocess (0, _, _, _) = 0\nprocess (n, m, a, b) =\n let sep =\n [ a * x + b * y | x <- [0 .. 1000], y <- [0 .. 1000], x + m * y >= n ]\n in if sep == [] then 1 else minimum sep\n\nmain :: IO ()\nmain = do\n input <- getLine\n let xs = map (read :: String -> Integer) (split ' ' input)\n let k = (xs !! 0, xs !! 1, xs !! 2, xs !! 3)\n print $ process k\n", "positive_code": [{"source_code": "main = interact $ show . f . map read . words\nf (a:b:c:d:e) = min (c*a) (min (d*(div a b+1)) (c*mod a b+d*div a b))"}, {"source_code": "import Control.Applicative\nmain :: IO()\nmain = do\n [n,m,a,b] <- map read.words <$> getLine::IO [Int]\n if m*a <= b then print (n*a) else print$min (n `div` m * b + (n `mod` m) * a) ((n `div` m + 1)*b)\n"}, {"source_code": "import Control.Monad\nimport Data.Array\nimport Data.Char\nimport Data.Functor\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\n-- import qualified Data.Text as T\nimport qualified Data.ByteString.Char8 as B\ngetList :: Read a => IO [a]\ngetList = map (read . B.unpack) . B.words <$> B.getLine\ngetIntList :: IO [Int]\ngetIntList = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nsolve :: Int -> Int -> Int -> Int -> Int\nsolve n m a b = minimum [n * a, (n + m - 1) `div` m * b,\n n `div` m * b + n `mod` m * a]\n\nmain :: IO ()\nmain = do\n [n, m, a, b] <- getIntList\n print $ solve n m a b\n"}, {"source_code": "import Control.Applicative\n\nprocess n m a b = minimum [b*((div n m )+1), b*(div n m)+a*(mod n m), a*n]\n\n\nmain=do\n [n,m,a,b]<- map read <$> words <$> getLine::IO [Int]\n print $ process n m a b\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Int] -> Int\nsolve [n, m, a, b] = minimum [ n * a, b * (n `div` m) + a * (n `mod` m), b * (n `div` m + 1) ]\n"}, {"source_code": "main=interact$show.solve.map read.words\nsolve[n,m,a,b]=minimum[n*a,(n+m-1)`div`m*b,n`div`m*b+n`mod`m*a]\n"}, {"source_code": "main = getLine >>= return . f . map read . words >>= print\nf [n, m, a, b] = minimum\n [ n `div` m * b + n `mod` m * a\n , n * a\n , (n `div` m + 1) * b\n ]"}, {"source_code": "import Control.Applicative\n \n \nmain= do\n\t[n,m,a,b] <- map read. words <$> getLine::IO [Int]\n\tprint $ if (fromIntegral b )/ (fromIntegral m) >= fromIntegral a then n*a else min ((div n m)*b + (mod n m)*a ) (((div n m )+1)*b)"}, {"source_code": "import Data.List\n\nanswer :: [Integer] -> Integer\nanswer [n, m, a, b] | fromIntegral b / fromIntegral m > fromIntegral a = a * n\n | need * a < b = buy * b + need * a\n | otherwise = (buy + 1) * b\n where (buy, need) = n `divMod` m\n\nsomeFunc :: IO ()\nsomeFunc = getLine >>= print . answer . fmap read . words\n\nmain :: IO ()\nmain = someFunc\n"}, {"source_code": "process :: Int -> Int -> Int -> Int -> Int\nprocess n m a b\n | m*a <= b = n*a\n | r*a <= b = q*b + r*a\n | otherwise = q*b + b\n where\n (q,r) = n `divMod` m\n\nreadInt :: String -> Int\nreadInt = read\n\nmain :: IO ()\nmain = do\n [n,m,a,b] <- fmap (map readInt.words) getLine\n print $ process n m a b"}, {"source_code": "{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Arrow\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport Text.Printf\n\nreadInt = ( readLn :: IO Int )\ngetInts = map ( read :: String -> Int ) . words <$> getLine\n\nwhich a b f = if f then a else b\nmp [ a, b ] = ( a, b )\n\nmain = do\n\t[ n, m, a, b ] <- getInts\n\tprint $ minimum $ [ i * a + j * b | i <- [ 0 .. n ], j <- return $ ( n - i + m - 1 ) `div` m ]\n"}, {"source_code": "module Main (main)\n where\n\n\nmain :: IO ()\nmain = print . solve . take 4 . map read . words =<< getLine\n where solve [n,m,a,b]\n | a*m <= b = a*n\n | otherwise = let (q,r) = divMod n m in b*q + min (a*r) b"}, {"source_code": "main :: IO()\nmain = print . solve . map read . words =<< getContents\n\nsolve :: [Int] -> Int\nsolve (n:m:a:b:_) = solve' 0\n where solve' :: Int -> Int\n solve' i | i * m >= n = i * b\n | otherwise = min (i * b + (n - i * m) * a) (solve' (i + 1))\n"}, {"source_code": "{-# LANGUAGE NoMonomorphismRestriction #-}\nimport Control.Applicative ((<$>))\nimport Control.Monad\nimport Text.Printf (printf)\nimport Data.Maybe (Maybe, fromMaybe)\nimport Data.List (sort, foldl')\nimport qualified Data.Map as M\nimport qualified Data.ByteString.Char8 as BS\n\nmain :: IO ()\nmain = do\n [n, m, a, b] <- getInts\n let p = a * n\n q = b * (n `div` m) + a * (n `mod` m)\n r = b * ((n + m - 1) `div` m)\n print $ minimum [p, q, r]\n\ntoNumber = fst . fromMaybe (0, BS.pack \"\")\ngetInt = toNumber . BS.readInt <$> BS.getLine\ngetInts = (map (toNumber . BS.readInt) <$> (BS.words <$> BS.getLine))\ncountup = foldl' (\\x y -> M.insertWith' (+) y 1 x) M.empty\ncountof m x = M.findWithDefault 0 x m\n"}, {"source_code": "import Data.List\n\nsolve :: Integer -> Integer -> Integer -> Integer -> Integer\nsolve n m a b = if (a * m < b) then a * n else ((n `div` m) * b + (min b ((n `mod` m) * a)))\n\nmain = do \n input <- getLine\n let arr = map (\\s -> read s :: Integer) $ words input\n print $ solve (arr !! 0) (arr !! 1) (arr !! 2) (arr !! 3)\n"}, {"source_code": "import Numeric\n\nfastRead :: String -> Int\nfastRead ('-':s) = case readDec s of [(n, \"\")] -> (-n)\nfastRead s = case readDec s of [(n, \"\")] -> n\n\nmain = interact $ show.f.map fastRead .words\n\nf (n:m:a:b:[])\n | m*a <= b = n*a\n | otherwise = i + min b ((n `mod` m)*a)\n where i = (n `div` m)*b\n"}, {"source_code": "import Data.List\nimport Data.Function\nimport Data.Char\nimport Data.Maybe\nimport qualified Data.ByteString.Lazy.Char8 as B\n\ngetIntArray :: B.ByteString -> [Int]\ngetIntArray = map fst . mapMaybe B.readInt . B.words\n\nmain = interact $ show . getAns . map read . words\n\ngetAns :: [Int] -> Int\ngetAns (n:m:a:b:[]) = if a * m <= b then n * a\n\t\t\t\t\t\telse let d = n `div` m;\n\t\t\t\t\t\t \t\t r = n `mod` m;\n\t\t\t\t\t\t\t in d * b + if r == 0 then 0 else min b (r * a)\n"}, {"source_code": "main = do\n [n, m, a, b] <- fmap (map read . words) getLine\n\n print $\n if m*a < b\n then n*a\n else b*(n`div`m) + min (a * (n`mod`m)) b\n"}, {"source_code": "import Data.List\nimport Data.Maybe\nimport Data.Char\nimport Data.Function\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ show.solve.map read. words.head.lines\nsolve :: [Int]->Int\nsolve [a, b, c, d] | b*c <=d = a*c\n | a `mod` b==0 = (a `div` b) * d\n | c>=d && a<=b = d\n | c>=d = ((a `div` b)+1) * d\n | c< d && a<=b = minimum [d, a*c]\n | otherwise = (a `div` b) * d +(a `mod` b) * c"}], "negative_code": [{"source_code": "{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Arrow\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport Text.Printf\n\nreadInt = ( readLn :: IO Int )\ngetInts = map ( read :: String -> Int ) . words <$> getLine\n\nwhich a b f = if f then a else b\nmp [ a, b ] = ( a, b )\n\nmain = do\n\t[ n, m, a, b ] <- getInts\n\tprint $ minimum $ [ i * a + b * j | i <- [ 0 .. n ], ( n - i ) `mod` m == 0, j <- return $ ( n - i ) `div` m ]\n"}, {"source_code": "module Main (main)\n where\n\n\nmain :: IO ()\nmain = print . solve . take 4 . map read . words =<< getLine\n where solve [n,m,a,b]\n | a*m <= b = a*n\n | otherwise = let (q,r) = divMod n m in b*q + a*r"}, {"source_code": "{-# LANGUAGE NoMonomorphismRestriction #-}\nimport Control.Applicative ((<$>))\nimport Control.Monad\nimport Text.Printf (printf)\nimport Data.Maybe (Maybe, fromMaybe)\nimport Data.List (sort, foldl')\nimport qualified Data.Map as M\nimport qualified Data.ByteString.Char8 as BS\n\nmain :: IO ()\nmain = do\n [n, m, a, b] <- getInts\n let p = a * n\n q = b * (n `div` m) + a * (n `mod` m)\n print $ min p q\n\ntoNumber = fst . fromMaybe (0, BS.pack \"\")\ngetInt = toNumber . BS.readInt <$> BS.getLine\ngetInts = (map (toNumber . BS.readInt) <$> (BS.words <$> BS.getLine))\ncountup = foldl' (\\x y -> M.insertWith' (+) y 1 x) M.empty\ncountof m x = M.findWithDefault 0 x m\n"}, {"source_code": "import Data.List\n\nsolve :: Integer -> Integer -> Integer -> Integer -> Integer\nsolve n m a b = if (a * m < b) then a * n else (mt * b + (n - mt * m) * a)\n where mt = n `div` m \n\n\nmain = do \n input <- getLine\n let arr = map (\\s -> read s :: Integer) $ words input\n print $ solve (arr !! 0) (arr !! 1) (arr !! 2) (arr !! 3)\n"}, {"source_code": "import Numeric\n\nfastRead :: String -> Int\nfastRead ('-':s) = case readDec s of [(n, \"\")] -> (-n)\nfastRead s = case readDec s of [(n, \"\")] -> n\n\nmain = interact $ show.f.map fastRead .words\n\nf (n:m:a:b:[])\n | m*a <= b = n*a\n | n `mod` m > 0 = b + i\n | otherwise = i\n where i = (n `div` m)*b\n"}, {"source_code": "import Numeric\n\nfastRead :: String -> Int\nfastRead ('-':s) = case readDec s of [(n, \"\")] -> (-n)\nfastRead s = case readDec s of [(n, \"\")] -> n\n\nmain = interact $ show.f.map fastRead .words\n\nf (n:m:a:b:[])\n | m*a <= b = n*a\n | otherwise = (n `mod` m)*a + (n `div` m)*b\n"}, {"source_code": "import Data.List\nimport Data.Maybe\nimport Data.Char\nimport Data.Function\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ show.solve.map read. words.head.lines\nsolve :: [Int]->Int\nsolve [a, b, c, d] | b*c <=d = a*c\n | c>=d = if (a `mod` b)/=0 then ((a `div` b) + 1)*d else (a `div` b)*d\n | otherwise = (a `div` b) * d +(a `mod` b) * c"}, {"source_code": "import Data.List\nimport Data.Maybe\nimport Data.Char\nimport Data.Function\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ show.solve.map read. words.head.lines\nsolve :: [Int]->Int\nsolve [a, b, c, d] | b*c <=d = a*c\n | c>=d = ((a `div` b) + 1)*d\n | otherwise = (a `div` b) * d +(a `mod` b) * c"}, {"source_code": "type Vec4 = (Integer, Integer, Integer, Integer)\n\nsplit :: Eq a => a -> [a] -> [[a]]\nsplit _ [] = []\nsplit cond xs = x : split cond (drop 1 y) where (x, y) = span (/= cond) xs\n\nprocess :: Vec4 -> Integer\nprocess (0, _, _, _) = 0\nprocess (n, m, a, b) =\n let sep =\n [ a * x + b * y\n | x <- [0 .. floor (sqrt (1000.0))]\n , y <- [0 .. floor (sqrt (1000.0))]\n , x + m * y == n\n ]\n in minimum sep\n\nmain :: IO ()\nmain = do\n input <- getLine\n let xs = map (read :: String -> Integer) (split ' ' input)\n let k = (xs !! 0, xs !! 1, xs !! 2, xs !! 3)\n print $ process k\n"}, {"source_code": "type Vec4 = (Integer, Integer, Integer, Integer)\n\nsplit :: Eq a => a -> [a] -> [[a]]\nsplit _ [] = []\nsplit cond xs = x : split cond (drop 1 y) where (x, y) = span (/= cond) xs\n\nprocess :: Vec4 -> Integer\nprocess (0, _, _, _) = 0\nprocess (n, m, a, b) =\n let sep =\n [ a * x + b * y\n | x <- [0 .. floor (sqrt (1000.0))]\n , y <- [0 .. floor (sqrt (1000.0))]\n , x + m * y >= n\n ]\n in if sep == [] then 1 else minimum sep\n\nmain :: IO ()\nmain = do\n input <- getLine\n let xs = map (read :: String -> Integer) (split ' ' input)\n let k = (xs !! 0, xs !! 1, xs !! 2, xs !! 3)\n print $ process k\n"}, {"source_code": "import Data.Char\nmain = interact $ show . f . map read . words\nf (a:b:c:d:e) = min (a*c) (c*mod a b+d*div a b)"}, {"source_code": "import Control.Applicative\n\nprocess n m a b = minimum [b*((div n m )+1), b*(div n m)+a*(mod n m)]\n\n\nmain=do\n [n,m,a,b]<- map read <$> words <$> getLine::IO [Int]\n print $ process n m a b\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Int] -> Int\nsolve [n, m, a, b] | a * m <= b = n * a\n | otherwise = b * (n `div` m) + a * (n `mod` m)\n"}, {"source_code": "import Control.Applicative\n \n \nmain= do\n\t[n,m,a,b] <- map read. words <$> getLine::IO [Int]\n\tprint $ if (fromIntegral b )/ (fromIntegral m) >= fromIntegral a then n*a else min ((div n m)*b + (mod n m)*a ) ((div n m )+1)*b"}, {"source_code": "import Control.Applicative\n \n \nmain= do\n\t[n,m,a,b] <- map read. words <$> getLine::IO [Int]\n\tprint $ if (fromIntegral b )/ (fromIntegral m) >= fromIntegral a then n*a else (div n m)*b + (mod n m)*a "}, {"source_code": "import Data.List\n\nanswer :: [Integer] -> Integer\nanswer [n, m, a, b] | fromIntegral b / fromIntegral m > fromIntegral a = a * n\n | need * a < b = buy * b + need * a\n | otherwise = (buy + 1) * m\n where (buy, need) = n `divMod` m\n\nsomeFunc :: IO ()\nsomeFunc = getLine >>= print . answer . fmap read . words\n\nmain :: IO ()\nmain = someFunc\n"}], "src_uid": "faa343ad6028c5a069857a38fa19bb24"} {"source_code": "import Data.List\nimport qualified Data.Map.Strict as Map\n\ntoint s = (read s) :: Integer\n\nagregar x m = Map.insertWith (+) x 1 m\n\nasdasd [] = Map.fromList []\nasdasd (x:xs) = agregar x (asdasd xs)\n\ndoit k [] = 0\ndoit k ((_,t):xs) =\n\tmax (div (t+k-1) k) $ doit k xs\n\nsolve::String -> String\nsolve ss =\n\tlet n:k:x = map toint $ words ss in\n\tlet z = Map.toList $ asdasd x in\n\tlet q = (doit k z) * k in\n\tshow(sum $ map (\\(_,t) -> q-t) z) ++ \"\\n\"\n\nmain = do\n interact $ solve", "positive_code": [{"source_code": "module Main where\nimport Data.List\n\nmain = do\n [_,k] <- map (read :: String -> Int) . words <$> getLine\n a <- map (read :: String -> Int) . words <$> getLine\n let b = group $ sort a\n c = map length b \n d = maximum c\n e = (if d `mod` k == 0 then d else d + k - (d`mod`k)) `div` k\n f = (k*) $ (e*) $ length $ nub a\n print $ f - sum c\n\n"}, {"source_code": "import Data.List\n\n\nmain = do\n e<-getLine\n e2<-getLine\n let xs=map read (words e2)::[Int]\n ys=map length $ group $ sort xs\n (n:k:[])=map read (words e)::[Int]\n t=maximum ys\n print $ (k*(length ys)*(t `div` k + (if t `mod` k==0 then 0 else 1 )))-n"}], "negative_code": [], "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f"} {"source_code": "\nimport Control.Monad\nimport Control.Applicative\ngcdd x y | x > y = gcdd y x\ngcdd 0 _ = mzero\ngcdd 1 x = return (x-1)\ngcdd x y = (y `div` x +) <$> gcdd (y `mod` x) x\n\ns x=minimum$[1..x]>>=gcdd x\n\nmain=interact$show.s.read\n", "positive_code": [{"source_code": "main = interact $ show.solve.read\nsolve x = minimum.map (gao).zip [1..x] $ repeat x\ngao (a,b) | a == 1 = b - 1 | b `mod` a == 0 = 1000000 | 1>0 = b `div` a + gao (b `mod` a, a)\n"}, {"source_code": "module Main (main) where\n\nimport System\nimport Data.Char\nimport Data.List\nimport Control.Monad\nimport Control.Applicative\n\ndoit :: Int -> Int -> Int -> Int\ndoit _ _ 30 = 999999999\ndoit 1 1 _ = 0\ndoit 0 _ _= 999999999\ndoit n 1 _= n - 1\ndoit a b dep\n | a > b = doit b a dep\n | otherwise = t + doit a (b - a * t) (dep + 1)\n where d = b - a ; t = (max 1 (d `div` a))\n\nsolve :: Int -> String\nsolve n = show $ minimum [doit v n 0 | v <- [1..n]]\n\nmain = interact$solve.read.head.words"}], "negative_code": [], "src_uid": "75739f77378b21c331b46b1427226fa1"} {"source_code": "main=interact$f.lines\nf[a,b]=zipWith(g)a b\ng a b|a==b='0'|1>0='1'", "positive_code": [{"source_code": "main=interact$(\\[x,y]->zipWith(\\a b->if a==b then '0' else '1')x y).lines"}, {"source_code": "import Data.Char\n\nsplitStr::String -> Char -> [String]\nsplitStr [] spliter = [\"\"]\nsplitStr (x:xs) spliter \n | x == spliter = \"\" : rest\n | otherwise = (x : head rest) : tail rest\n where \n rest = splitStr xs spliter\n\nreadNum :: IO Integer\nreadNum = readLn\n\nstrToInt :: String -> Integer\nstrToInt s = read s\n\nprocess \"\" \"\" = \"\"\nprocess s1 s2 \n | (take 1 s1) == (take 1 s2) = \"0\" ++ next\n | otherwise = \"1\" ++ next\n where next = process (drop 1 s1) (drop 1 s2)\n\nmain = do\n src <- getLine--readNum\n src2 <- getLine\n putStrLn $ process src src2\n\n"}, {"source_code": "decide x = if fst x == snd x\n then '0'\n else '1'\nmain=interact $ (map decide) . (\\[x,y] -> zip x y) . lines\n"}, {"source_code": "main = do\n\ta <- getLine\n\tb <- getLine\n\tputStrLn $ zipWith (\\i j -> if i == j then '0' else '1') a b\n"}, {"source_code": "module Main where\n\nmain = do\n a <- getLine\n b <- getLine\n let c = zipWith (\\a b -> if a == b then '0' else '1') a b\n\n putStrLn c\n"}, {"source_code": "\nxor a b | a==b = '0'\n | otherwise = '1'\n\nsolve [] [] = \"\"\nsolve (a:as) (b:bs) = [xor a b] ++ (solve as bs)\n\nmain = do\n\ta<-getLine\n\tb<-getLine\n\tputStrLn $ solve a b"}, {"source_code": "shapur :: String -> String -> String\nshapur [] _ = []\nshapur (x:xs) (y:ys)\n | x == y = '0' : next\n | otherwise = '1' : next\n where next = shapur xs ys\n\nmain = getLine >>= \\line -> getLine >>= return . shapur line >>= putStrLn\n\n"}, {"source_code": "xor :: String -> String -> String\nxor [] [] = []\nxor (a:as) (b:bs) = c:(xor as bs)\n\twhere c = if a == b then '0' else '1'\n\nmain = do\n\ta <- getLine\n\tb <- getLine\n\tputStrLn $ xor a b\n"}, {"source_code": "f a b = if a==b then '0' else '1'\nmain = do\n\ta <- getLine\n\tb <- getLine\n\tputStrLn $ zipWith f a b\n"}, {"source_code": "\n-- https://downloads.haskell.org/~ghc/latest/docs/html/libraries/base-4.9.0.0/Data-Bits.html\nimport Data.Bits\n\nmyxor a b lst\n | (null a) = lst\n | (head a) == (head b) = myxor (tail a) (tail b) (concat [lst, ['0']])\n | otherwise = myxor (tail a) (tail b) (concat [lst, ['1']])\n\n\n\nmain = do\n ff <- getLine\n gg <- getLine\n let ans = myxor ff gg []\n putStrLn ans\n\n\n\n \n"}, {"source_code": "main = do\n s1 <- getLine\n s2 <- getLine\n putStrLn $ zipWith (\\i1 i2 -> if i1 == i2 then '0' else '1') s1 s2\n"}, {"source_code": "\nmain :: IO ()\nmain = do\n number1 <- getLine\n number2 <- getLine\n putStr (zipWith (\\x y -> if x == y then '0' else '1') number1 number2)"}, {"source_code": "\nxor [] _ = \"\"\nxor (x:xs) (y:ys) = (if x == y then '0' else '1') : (xor xs ys)\n\n\nmain :: IO ()\nmain = do\n number1 <- getLine\n number2 <- getLine\n putStr (xor number1 number2)"}, {"source_code": "main = do s <- getLine\n t <- getLine\n putStrLn $ gen s t\n\ngen [] [] = []\ngen (ca:sa) (cb:sb) =\n if ca==cb then '0':gen sa sb\n else '1':gen sa sb"}, {"source_code": "main = do\n s <- getLine\n t <- getLine\n\n putStrLn $ zipWith (\\a b -> if a /= b then '1' else '0') s t\n"}, {"source_code": "import Data.List\nimport Data.List.Split\n\n(|>) x f = f x\nmain = interact solve\n\nsolve contents = let\n nums = contents |> lines\n in solve' (nums !! 0) (nums !! 1)\n \nsolve' xs ys = zipWith exor xs ys\n\nexor '1' '0' = '1'\nexor '0' '1' = '1'\nexor _ _ = '0'\n \n"}, {"source_code": "solve :: String -> String -> String\nsolve (x:xs) (y:ys)\n | x == y = '0' : solve xs ys\n | otherwise = '1' : solve xs ys\nsolve [] [] = []\n\nmain :: IO ()\nmain = do l1 <- getLine\n l2 <- getLine\n putStrLn $ solve l1 l2\n"}, {"source_code": "import Data.List\nimport Data.Maybe\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ solve.take 2 . lines\nsolve :: [String]->String\nsolve [x,y] = solve2 x y\nsolve2 \"\" \"\" =\"\"\nsolve2 (x:xs) (y:ys) = if x==y then \"0\"++solve2 xs ys else \"1\"++solve2 xs ys"}, {"source_code": "main = do\n a <- getLine\n b <- getLine\n putStrLn $ zipWith (\\q -> \\w -> if q == w then '0' else '1') a b"}, {"source_code": "main = do\n a <- getLine\n b <- getLine\n putStr (zipWith (\\x y -> if x == y then '0' else '1') a b)\n"}, {"source_code": "import Control.Applicative\n\nmain = do\n a <- getLine\n b <- getLine\n putStrLn $ zipWith f a b\n\nf '0' '0' = '0'\nf '1' '0' = '1'\nf '0' '1' = '1'\nf '1' '1' = '0'\nf x y = x\n"}, {"source_code": "import Control.Monad\nimport Data.Array\nimport Data.Char\nimport Data.Functor\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\n-- import qualified Data.Text as T\nimport qualified Data.ByteString.Char8 as B\ngetList :: Read a => IO [a]\ngetList = map (read . B.unpack) . B.words <$> B.getLine\ngetIntList :: IO [Int]\ngetIntList = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nchxor :: Char -> Char -> Char\nchxor a b = if a == b then '0' else '1'\n\nsolve :: String -> String -> String\nsolve = zipWith chxor\n\nmain :: IO ()\nmain = do\n s <- getLine\n t <- getLine\n putStrLn $ solve s t\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Control.Monad\n\n\n\n\n\nmain=do\n\n [a,b]<- (replicateM 2 getLine )\n putStrLn $ zipWith (\\z1 z2 ->if z1==z2 then '0' else '1') a b\n"}, {"source_code": "module Main where\n\nimport Control.Arrow\nimport Control.Applicative\n\nimport Data.Char\n\nmain = zipWith (/=) <$> getLine <*> getLine >>= (map (fromEnum >>> intToDigit) >>> putStr)"}, {"source_code": "module Main where\n\nimport Data.Char\n\nmain = do\n a:b:_ <- lines `fmap` getContents\n putStr $ zipWith (((intToDigit . fromEnum) .) . (/=)) a b\n"}, {"source_code": "import Data.Bits (xor)\nimport Data.Char (digitToInt)\n\nmain :: IO ()\nmain = getContents >>= putStrLn . concatMap show . solve . map (map digitToInt) . lines\n\nsolve :: [[Int]] -> [Int]\nsolve [xs, ys] = zipWith xor xs ys\n"}, {"source_code": "import Control.Monad\nmain = putStrLn =<< liftM2 (zipWith xor) getLine getLine\nxor '0' '0' = '0'\nxor '0' '1' = '1'\nxor '1' '0' = '1'\nxor '1' '1' = '0'\n"}, {"source_code": "main = do\n a <- getLine\n b <- getLine\n putStrLn $ solve a b\n \nsolve [] [] = []\nsolve (x:xs) (y:ys) | x /= y = '1' : solve xs ys\n | otherwise = '0' : solve xs ys\n"}, {"source_code": "import Control.Monad\nimport Control.Applicative\nimport Data.List\n\ngetNums :: (Read a,Num a) => IO [a]\ngetNums = map read. words <$> getLine\n\nxor a b = if a /= b then '1' else '0'\n\ncalc as bs = zipWith xor as bs\n\nmain = do\n as <- getLine\n bs <- getLine\n putStrLn $ calc as bs\n"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/61/A\n\nchxor :: Char -> Char -> Char\nchxor a b = if a == b then '0' else '1'\n\nmain :: IO ()\nmain = do\n s <- getLine\n t <- getLine\n putStrLn $ zipWith chxor s t\n"}, {"source_code": "main = interact $ f . lines\nf (x:y:[]) = calc x y\ncalc [] [] = \"\"\ncalc (a:as) (b:bs) = (if a == b then '0' else '1') : calc as bs"}, {"source_code": "import System.IO\n \nsolve :: String -> String -> String\nsolve [] _ = []\nsolve (a:as) (b:bs) = \n if a/=b then '1' : solve as bs\n else '0' : solve as bs\n \nmain = do\n str1 <- getLine\n str2 <- getLine\n putStrLn $ solve str1 str2"}, {"source_code": "main = do\n s1 <- getLine\n s2 <- getLine\n putStr $ map (\\(x, y) -> if x /= y then '1' else '0') $ zip s1 s2\n"}, {"source_code": "import Data.Char\n\nxor a b = if a==b\n then 0\n else 1\n\nxorlines [] [] = []\nxorlines (a:xs) (b:ys) = [(xor a b)]++ xorlines xs ys\n\nmain = \n do\n line1 <- getLine\n line2 <- getLine\n putStrLn (foldr (++) \" \" $ map show (xorlines line1 line2))\n "}, {"source_code": "get = zipWith f \n where f a b | a /= b = '1'\n | otherwise = '0'\n\nmain = do\n a <- getLine\n b <- getLine\n putStrLn $ get a b\n"}, {"source_code": "module Main (main) where\n\nimport System\nimport Data.Char\nimport Data.List\nimport Control.Monad\nimport Control.Applicative\n\nsolve :: [String] -> String\nsolve [s1,s2] = [xor c1 c2 | (c1,c2) <- zip s1 s2]\n where\n xor c1 c2 \n | c1 == c2 = '0'\n | otherwise = '1'\n\nmain = interact$solve.take 2.words"}, {"source_code": "main = interact $ (\\[a,b]->zipWith (\\x y->if x==y then '0' else '1') a b++\"\\n\").lines\n"}, {"source_code": "main = interact solve\nsolve input = output where\n inputs = lines input\n output = ans inputs\nans [[],[]] = []\nans [(x:xs),(y:ys)] = (if x==y then '0' else '1') : (ans [xs,ys])"}, {"source_code": "import Control.Applicative\nimport qualified Data.Set as S\n \nxor '1' '1' ='0'\nxor '0' '0' ='0'\nxor '1' '0' ='1'\nxor '0' '1' ='1' \n\n \nmain= do\n\t\n\tx<- getLine \n\ty<- getLine \n\tputStrLn $ zipWith xor x y\n\t \n\t \n\t \n"}, {"source_code": "{-\nA. Ultra-Fast Mathematician\n============================\ntime limit per test: 2 seconds\nmemory limit per test: 256 megabytes\ninput: standard input\noutput: standard output\n\nShapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.\n\nOne day in 230 AD Shapur was trying to find out if any one can possibly do calculations faster than him. As a result he made a very great contest and asked every one to come and take part.\n\nIn his contest he gave the contestants many different pairs of numbers. Each number is made from digits 0 or 1. The contestants should write a new number corresponding to the given pair of numbers. The rule is simple: The i-th digit of the answer is 1 if and only if the i-th digit of the two given numbers differ. In the other case the i-th digit of the answer is 0.\n\nShapur made many numbers and first tried his own speed. He saw that he can perform these operations on numbers of length ∞ (length of a number is number of digits in it) in a glance! He always gives correct answers so he expects the contestants to give correct answers, too. He is a good fellow so he won't give anyone very big numbers and he always gives one person numbers of same length.\n\nNow you are going to take part in Shapur's contest. See if you are faster and more accurate.\n\nInput\n------\nThere are two lines in each input. Each of them contains a single number. It is guaranteed that the numbers are made from 0 and 1 only and that their length is same. The numbers may start with 0. The length of each number doesn't exceed 100.\n\nOutput\n------\nWrite one line — the corresponding answer. Do not omit the leading 0s.\n\nSample test(s)\n---------------\ninput\n1010100\n0100101\noutput\n1110001\n\ninput\n000\n111\noutput\n111\n\ninput\n1110\n1010\noutput\n0100\n\ninput\n01110\n01100\noutput\n00010\n\n-}\n\ncharXOR :: Char -> Char -> Char\ncharXOR '0' '0' = '0'\ncharXOR '1' '1' = '0'\ncharXOR '0' '1' = '1'\ncharXOR '1' '0' = '1'\n\nmain = do \n input <- getContents\n let [x, y] = lines input\n putStrLn $ zipWith charXOR x y\n\n\n"}, {"source_code": "main :: IO ()\nmain = do\n s1 <- getLine\n s2 <- getLine\n putStrLn $ zipWith (curry (head . show . fromEnum . uncurry (/=))) s1 s2\n"}, {"source_code": "import Data.List\nxor [a,b] = if a == b then '0' else '1'\nmain = interact $ map xor . transpose . lines"}, {"source_code": "main = do\n x1 <- getLine\n x2 <- getLine\n putStrLn $ zipWith comb x1 x2\n\n\ncomb :: Char -> Char -> Char\ncomb c1 c2\n | c1 == c2 = '0'\n | otherwise = '1'\n "}, {"source_code": "import Data.Char\nimport Data.List\nimport Control.Monad\nmain = replicateM 2 getLine >>= putStrLn.map (intToDigit.abs.foldl1 (-).map digitToInt).transpose\n"}, {"source_code": "process :: String -> String -> String\nprocess s t = zipWith f s t\n where\n f x y\n | x == y = '0'\n | otherwise = '1'\n\nmain :: IO ()\nmain = do\n s <- getLine\n t <- getLine\n putStrLn $ process s t"}, {"source_code": "\nmain = do\n\tstr1 <- getLine\n\tstr2 <- getLine\n\tputStrLn $ calcStr str1 str2\n\ncmpChar :: Char -> Char -> Char\ncmpChar x y\t| x == y \t= '0'\n\t\t\t| otherwise = '1'\n\ncalcStr :: String -> String -> String\ncalcStr x y = zipWith cmpChar x y\n\t\t\t\t\t\t\n"}, {"source_code": "solve :: String -> String\nsolve s = zipWith (\\x y -> if x == y then '0' else '1') xs ys\n where xs:ys:_ = lines s \n\nmain=interact $ solve"}], "negative_code": [{"source_code": "main=interact$show.(\\[x,y]->zipWith(\\a b->if a==b then '0' else '1')x y).lines"}, {"source_code": "module Main where\n\nimport Control.Arrow\nimport Control.Applicative\n\nimport Data.Char\n\nmain = zipWith (==) <$> getLine <*> getLine >>= (map (fromEnum >>> intToDigit) >>> putStr)"}, {"source_code": "main = interact $ f . lines\nf (x:y:[]) = calc x y\ncalc [] [] = []\ncalc (a:as) (b:bs) = if a == b then \"0\" else \"1\" ++ calc as bs"}], "src_uid": "3714b7596a6b48ca5b7a346f60d90549"} {"source_code": "import Data.List\nimport Data.Set as S\n\nwork cards = minimum [length s |\n\ts <- subsequences \"RGBYW12345\",\n\tsize (S.map (intersect s) cards) == size cards\n\t]\nmain = interact $ show . work . fromList . tail . words\n", "positive_code": [{"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n\nimport Control.Applicative\nimport Control.Arrow\nimport Control.Monad\nimport Data.Array.IO\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as C\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Functor\nimport Data.IORef\nimport Data.List\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Traversable\nimport Text.Printf (printf)\n\nimport qualified Data.Set as S\nimport Data.Char\nimport Debug.Trace\n\n-- I/O\n\nreadInts :: C.ByteString -> [Int]\nreadInts = map fst . mapMaybe C.readInt . C.words\n\ngetInts :: IO [Int]\ngetInts = readInts <$> C.getLine\n\nreadNums :: Num a => C.ByteString -> [a]\nreadNums = map (fromIntegral . fst) . mapMaybe C.readInteger . C.words\n\ngetNums :: Num a => IO [a]\ngetNums = readNums <$> C.getLine\n\ncast :: (Integral a, Integral b) => a -> b\ncast = fromIntegral\n\n-----\n\nmain :: IO ()\nmain = do\n _ <- getLine\n cs <- words <$> getLine\n let ini = [ [ [c, v] `elem` cs | v <- \"12345\" ]\n | c <- \"RGBYW\"\n ]\n print $ minimum $ do\n as <- replicateM 5 [True, False]\n bs <- replicateM 5 [True, False]\n guard $ check as bs ini\n return $ length $ filter id $ as ++ bs\n\ncheck :: [Bool] -> [Bool] -> [[Bool]] -> Bool\ncheck as bs bd =\n let st = [ [ not (b && a) && c\n | (c, b) <- zip row bs\n ]\n | (row, a) <- zip bd as\n ]\n\n step = (transpose . remo bs . transpose) . remo as\n ss = iterate step st\n\n in 1 >= length (filter id $ concat $ snd $ head $ dropWhile (\\(a, b) -> a/=b) $ zip ss (tail ss))\n\n\nremo :: [Bool] -> [[Bool]] -> [[Bool]]\nremo rs = zipWith f rs where\n f r row\n | r && length (filter id $ row) == 1 = replicate 5 False\n | otherwise = row\n"}, {"source_code": "import Control.Monad\nimport Data.Set as S\n\nwork cards = minimum [length s |\n\ts <- filterM (const [True, False]) \"RGBYW12345\",\n\tsize (S.map (Prelude.map (\\c -> if elem c s then c else '-')) cards) == size cards\n\t]\nmain = interact $ show . work . fromList . tail . words\n"}, {"source_code": "import Control.Monad\nimport Data.Set as S\n\npow = filterM $ const [True, False]\nhas s a = if elem a s then a else '-'\nwork cards = minimum [length cs + length vs |\n\tcs <- pow \"RGBYW\", vs <- pow \"12345\",\n\tsize (S.map (zipWith has [cs, vs]) cards) == size cards\n\t]\nmain = interact $ show . work . fromList . tail . words\n"}, {"source_code": "-- @betaveros :: vim:set fdm=marker:\n{-# LANGUAGE LambdaCase, NPlusKPatterns, TupleSections #-}\n{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-missing-signatures #-}\n-- import ALL the things! {{{\n-- hiding clauses are to allow Data.Foldable's generalizations\nimport Prelude hiding (mapM, mapM_, sequence, sequence_, foldl, foldl1, foldr, foldr1, and, or, any, all, sum, product, concat, concatMap, maximum, minimum, elem, notElem)\nimport Control.Applicative\nimport Control.Arrow\nimport Control.Exception\nimport Control.Monad hiding (mapM, mapM_, forM, forM_, sequence, sequence_, msum)\nimport Control.Monad.ST\n\nimport qualified Data.ByteString.Char8 as BS\nimport Data.ByteString.Char8 (ByteString)\nimport Data.Bits\nimport Data.Char\nimport Data.Either\nimport Data.Foldable\nimport Data.Function\nimport Data.IORef\nimport Data.List hiding (foldl, foldl', foldl1, foldl1', foldr, foldr1, concat, concatMap, and, or, any, all, sum, product, maximum, minimum, elem, notElem, find)\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.STRef\nimport Data.String\nimport Data.Traversable\nimport Data.Tuple\n\nimport qualified Data.Map as Map\nimport Data.Map (Map)\nimport qualified Data.Set as Set\nimport Data.Set (Set)\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq, (<|), (|>), (><))\n\nimport Debug.Trace\nimport Text.Printf\nimport System.IO\n-- }}}\n-- silly utilities {{{\n-- stolen from lens:\na & f = f a\na <&> f = fmap f a\ninfixl 1 &, <&>\n\nfi :: (Integral a, Num b) => a -> b\nfi = fromIntegral\nglength :: (Num b) => [a] -> b\nglength = genericLength\n\nreadInt = read :: String -> Int\nreadInteger = read :: String -> Integer\n-- (!?) :: (Ord k) => Map k v -> k -> Maybe v\n-- (!?) = flip Map.lookup\nhistogram :: (Ord a, Num b) => [a] -> Map a b\nhistogram = Map.fromListWith (+) . map (,1)\n-- }}}\n-- input and output {{{\nbsGetLine :: IO ByteString\nbsGetLine = fst . BS.spanEnd isSpace <$> BS.getLine\n\ninputInt = (read <$> getLine) :: IO Int\ninputInteger = (read <$> getLine) :: IO Integer\ninputDouble = (read <$> getLine) :: IO Double\n\ninputRow :: (Read a) => IO [a]\ninputRow = map read . words <$> getLine\ninputInts = inputRow :: IO [Int]\ninputIntegers = inputRow :: IO [Integer]\ninputDoubles = inputRow :: IO [Double]\n\nssUnwords :: [ShowS] -> ShowS\nssUnwords [] = id\nssUnwords (x:xs) = x . (' ':) . ssUnwords xs\n\nssUnlines :: [ShowS] -> ShowS\nssUnlines [] = id\nssUnlines (x:xs) = x . ('\\n':) . ssUnlines xs\n\nshowMany :: (Show a) => [a] -> String\nshowMany xs = ssUnwords (map shows xs) \"\"\nshowMatrix :: (Show a) => [[a]] -> String\nshowMatrix xs = ssUnlines (map (ssUnwords . map shows) xs) \"\"\n\nprintMany :: (Show a) => [a] -> IO ()\nprintMany xs = putStrLn (showMany xs)\nprintMatrix :: (Show a) => [[a]] -> IO ()\nprintMatrix xs = putStr (showMatrix xs)\n-- }}}\n\ndistinguish :: Char -> [String] -> [[String]]\ndistinguish c xs = let (a, b) = partition (c `elem`) xs in [a,b]\n\nmaybeDistinguish :: Char -> (Int, [[String]]) -> [(Int, [[String]])]\nmaybeDistinguish c (k, ss) =\n\t[(k, ss), (k + 1, distinguish c =<< ss)]\n\nallSingle :: [[a]] -> Bool\nallSingle = all ((<= 1) . length)\n\nmain :: IO ()\nmain = do\n\tn <- inputInt\n\tcards <- nub . take n . words <$> getLine\n\tlet results = foldl' (>>=) [(0, [cards])] $ map maybeDistinguish \"RGBYW12345\"\n\tprint . minimum . map fst . filter (allSingle . snd) $ results\n"}, {"source_code": "import Data.List\nu x=length.group.sort$x\n(#)=elemIndex\nq=subsequences\ns l=minimum[length$a++b|a<-q\"RGBYW\",b<-q\"12345\",u l==u(map(\\[x,y]->(x#a,y#b))l)]\nmain=interact$show.s.tail.words\n"}, {"source_code": "import Data.List\nu x=length.group.sort$x\n(#)=elemIndex\nq=subsequences\ns l=minimum[length$a++b|a<-q\"RGBYW\",b<-q\"12345\",u l==u(map(\\[x,y]->(x#a,y#b))l)]\nmain=interact$show.s.tail.words\n"}, {"source_code": "import Control.Monad\nimport Data.List\nimport Data.Set as S\n\nwork cards = minimum [length s |\n\ts <- filterM (const [True, False]) \"RGBYW12345\",\n\tsize (S.map (intersect s) cards) == size cards\n\t]\nmain = interact $ show . work . fromList . tail . words\n"}, {"source_code": "import Control.Monad\nimport qualified Data.Set as S\n\nwork cards = minimum [length s |\n\ts <- filterM (const [True, False]) \"RGBYW12345\",\n\tS.size (S.map (map (\\c -> if elem c s then c else '-')) cards) == S.size cards\n\t]\nmain = interact $ show . work . S.fromList . tail . words\n"}], "negative_code": [], "src_uid": "3b12863997b377b47bae43566ec1a63b"} {"source_code": "countPoints :: Int -> Int -> [Int] -> [Int] -> Int\ncountPoints n c ps ts = sum $ zipWith (\\p x -> max 0 (p-c*x)) ps cts\n where cts = scanl1 (+) ts\n\nresult :: Int -> Int -> [Int] -> [Int] -> Ordering\nresult n c ps ts = (countPoints n c ps ts) `compare` (countPoints n c (reverse ps) (reverse ts))\n\nreadInt :: String -> Int\nreadInt = read\n\nshowOrdering :: Ordering -> String\nshowOrdering GT = \"Limak\"\nshowOrdering EQ = \"Tie\"\nshowOrdering LT = \"Radewoosh\"\n\nmain = do\n [n,c] <- fmap (map readInt.words) getLine\n ps <- fmap (map readInt.words) getLine\n ts <- fmap (map readInt.words) getLine\n putStrLn.showOrdering $ result n c ps ts", "positive_code": [{"source_code": "main = do\n [n,c] <- fmap ((map read) . words) getLine :: IO[Int]\n p <- fmap ((map read) . words) getLine :: IO[Int]\n t <- fmap ((map read) . words) getLine :: IO[Int]\n putStrLn $solve n c p t\n \nsolve n c p t =\n let sl = tail $ scanl (+) 0 t\n sr = init $ scanr (+) 0 t\n in case compare (fn p sl c) (fn p sr c) of\n LT -> \"Radewoosh\"\n EQ -> \"Tie\"\n GT -> \"Limak\"\n \nfn pl tl c = sum (zipWith (\\p t -> max 0 (p - (c*t))) pl tl)\n"}, {"source_code": "import Data.Char\nimport Control.Monad\n\nreadIntImpl :: Int -> Bool -> IO Int\nreadIntImpl x flag = do\n c <- getChar\n if c `elem` ['0'..'9']\n then do\n let d = digitToInt c\n y <- readIntImpl (x*10+d) True\n return y\n else if flag\n then \n return x\n else do\n y <- readIntImpl x False\n return y\n\nreadInt = readIntImpl 0 False\nreadArr n readFunc = replicateM n readFunc\n\nf [] [] duration c = 0\nf (a:ax) (b:bx) duration c = (max 0 (a - c * duration - c * b)) + (f ax bx (duration + b) c)\n\nmain = do\n n <- readInt\n c <- readInt\n p <- readArr n readInt\n t <- readArr n readInt\n let limak = f p t 0 c\n let radewoosh = f (reverse p) (reverse t) 0 c\n let ans = if limak > radewoosh then \"Limak\" else if radewoosh > limak then \"Radewoosh\" else \"Tie\"\n putStrLn ans"}, {"source_code": "\nf ::Int->[Int]->[Int]->Int\nf _ [] []=0\nf p (x:xs) (y:ys)\n |x-y*p<=0=f p xs ys\n |otherwise=(x-y*p)+f p xs ys\n \nmain = do\n e<-getLine\n e2<-getLine\n e3<-getLine\n let (n:p:[])=map read (words e)::[Int]\n xs=map read (words e2)::[Int]\n ys=map read (words e3)::[Int]\n s1=f p xs (scanl1 (+) ys)\n s2=f p (reverse xs) (scanl1 (+) (reverse ys))\n putStrLn $ if s1==s2 then \"Tie\" else if s1>s2 then \"Limak\" else \"Radewoosh\""}, {"source_code": "main = do first <- getLine\n sp <- getLine\n st <- getLine\n let n:c:[] = (map read.words) first\n let p = (map read.words) sp\n let t = (map read.words) st\n case compare (li n c p t) (ra n c p t) of\n LT -> putStrLn \"Radewoosh\"\n GT -> putStrLn \"Limak\"\n EQ -> putStrLn \"Tie\"\nli :: Int -> Int -> [Int] -> [Int] -> Int\nli n c p t = (sum.map (f c)) (zip p (scanl1 (+) t))\nra :: Int -> Int -> [Int] -> [Int] -> Int\nra n c p t = (sum.map (f c)) (zip p (scanr1 (+) t))\nf :: Int -> (Int, Int) -> Int\nf c (p, x) = max 0 (p - c*x)"}], "negative_code": [], "src_uid": "8c704de75ab85f9e2c04a926143c8b4a"} {"source_code": "import Control.Applicative\nmain = do\n [a, b] <- map read . words <$> getLine\n let n = logBase (3 / 2) (b / a)\n print $ if fromIntegral (ceiling n) == n then ceiling n + 1 else ceiling n\n", "positive_code": [{"source_code": "module Main\n where\n\nimport System.IO\n\ncalc a b =\n calc' a b 0\n where\n calc' a b c =\n if a <= b then\n calc' (a * 3) (b * 2) (c + 1)\n else\n c\n\nsolve line =\n calc a b\n where\n [a, b] =\n map read . words $ line\n\nmain = do\n line <- getLine\n print $ solve line"}, {"source_code": "solve :: Integer -> Integer -> Integer -> Integer\nsolve l b n | l * (3 ^ n) > b * (2 ^ n) = n\n | otherwise = solve l b (n + 1)\n\nmain :: IO ()\nmain = do\n raw <- getLine\n let input = map (\\x -> read x :: Integer) $ words raw\n \n putStrLn $ show $ solve (input !! 0) (input !! 1) 1"}, {"source_code": "main = do\n n <- fmap (map read.words) getLine :: IO [Int]\n let f (a, b, c) = if (a * 3 > b * 2) then c else f (a*3, b*2, c + 1)\n putStrLn( show $ f(n!!0, n!!1, 1) );"}, {"source_code": "main :: IO ()\nmain = print . solve . map read . words =<< getLine\n\nsolve :: [Integer] -> Int\nsolve [a, b] | a > b = 0\n | otherwise = 1 + solve [a * 3, b * 2]\n"}, {"source_code": "main = do\n s <- getLine\n let [a, b] = map (read :: String -> Int) $ words s\n t = head [k | k<-[1..], 3^k*a > 2^k*b]\n print t"}, {"source_code": "main :: IO ()\nmain = do\n line <- getLine\n print $ weight 0 $map (read :: String -> Int) $ words line\n\nweight :: (Ord a, Num t, Num a) => t -> [a] -> t\nweight i [a, b] = if a > b then i else weight (i+1) [a*3, b*2]\nweight _ _= -1"}, {"source_code": "main = do\n [a, b] <- fmap (map read . words) getLine :: IO [Int]\n print . length $ takeWhile id [a * (3 ^ p) <= b * (2 ^ p) | p <- [0..]]\n"}, {"source_code": "{-# LANGUAGE BlockArguments #-}\n\nimport Control.Arrow\n\nmain = interact $\n lines >>> map (words >>> map read >>> solve >>> show) >>> unlines\n\n\ntoFloat :: Int -> Double\ntoFloat x = (fromIntegral x)::Double\n\nsolve :: [Int] -> Int\nsolve [a,b] = floor(logBase 1.5 (toFloat b) - logBase 1.5 (toFloat a) + 1.0001)"}, {"source_code": "solve :: [Int] -> Int -> Int\nsolve [a, b] years | a > b = years\n | otherwise = solve [a * 3, b * 2] (years + 1)\n\nmain :: IO ()\nmain = do\n line <- getLine\n let row = map read . words $ line\n print $ solve row 0\n"}, {"source_code": "module Main(main) where\n\nmain :: IO ()\nmain = do\n [a, b] <- fmap (map read . words) getLine :: IO [Int]\n print . length $ takeWhile id [a * (3 ^ p) <= b * (2 ^ p) | p <- [0..]]\n"}, {"source_code": "-- Codeforces 791A\nimport Data.List\nmain :: IO ()\nmain = do\n [limak, bob] <- getLine >>= return.(map read).words :: IO [Int]\n let zipped = zip3 (iterate (+1) 0) (iterate (*3) limak) (iterate (*2) bob) :: [(Int, Int, Int)]\n let Just (year, _, _) = find (\\(y, l, b) -> l > b) zipped\n putStrLn $ show year\n"}, {"source_code": "module Main where\n\n\ngetanswer :: Int -> [Int] -> Int\ngetanswer n [a, b] = \n if a > b \n then n\n else\n getanswer (n+1) [(a*3), (b*2)]\ngetanswer _ _ = 0\n\n\nmain :: IO ()\nmain = do\n getLine >>= putStrLn.show.(getanswer 0).(map (read :: [Char] -> Int)).words\n"}, {"source_code": "import Data.List\nimport Data.Tree \nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Data.Bits\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed as UA\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint \nreadsolveprint::IO()\nreadsolveprint = (solve.concat =<< forM [1 ..1] ( \\i -> map (fst.fromJust.C.readInteger).C.words <$> C.getLine))\nsolve [x,y] = print $ head $ snd $ break (\\a-> (x*3^a)>(y*2^a)) [1..]"}, {"source_code": "{-#LANGUAGE OverloadedStrings#-}\nmodule Main where\n\nimport Data.Text (splitOn, pack, unpack)\n\nmain :: IO ()\nmain = getInt >>= solve 0 >>= putStrLn . show\n\nsolve :: Int -> [Int] -> IO Int\nsolve i [a,b]\n | a > b = pure i\n | otherwise = solve (i+1) [3*a,2*b]\n\ngetInt :: IO [Int]\ngetInt = fmap (map (read . unpack) \n . splitOn \" \" . pack) getLine"}, {"source_code": "{-# OPTIONS_GHC -fno-warn-tabs #-}\nimport Data.List;\nimport System.IO;\nimport Data.Maybe;\n\nsolve :: Int -> Int -> Int -> Int;\nsolve a b y \n\t| a > b = y\n\t| otherwise = solve (a*3) (b*2) (y+1);\n\nmain = do\n\tstr <- getLine;\n\tlet strs = map read (words str) :: [Int];\n\tprint $ solve (head strs) (head (tail strs)) 0;"}, {"source_code": "main = getLine\n >>= putStrLn . show . calc . parse . words\n\nparse::[String] -> (Int, Int)\nparse [a, b] = (read a, read b)\n \ncalc::(Int, Int) -> Int\ncalc (a, b)\n | a <= b = calc (a * 3, b * 2) + 1\n | otherwise = 0"}, {"source_code": "import Text.Printf\nimport Data.List\nimport Data.Functor\nimport Prelude\n\nreadInt :: String -> Int\nreadInt = read\n\nmain :: IO ()\nmain = do\n [a, b] <- (map readInt . words) <$> getLine\n let \n answer :: Int\n Just answer = find (\\x -> a * 3 ^ x > b * 2 ^ x) [1..]\n printf \"%d\" answer"}, {"source_code": "main = do\n line <- getLine\n let [a, b] = map read (words line)\n\n let limak = [a * (3 ^ m) | m <- [0..]]\n let bob = [b * (2 ^ m) | m <- [0..]]\n\n print $ length $ takeWhile (\\(a, b) -> a <= b) $ zip limak bob\n"}, {"source_code": "import Control.Applicative\n\nprocess a b n | a>b = n\n | otherwise = process (3*a) (2*b) (n+1)\n\n\nmain=do\n\n [a,b]<- map read <$> words <$> getLine ::IO [Int]\n print $ process a b 0\n"}, {"source_code": "import Data.List\n\nreadInts :: IO [Int]\nreadInts = fmap (map read.words) getLine\n\n\n\n\nmas:: IO()\nhas a b = succ$length$[x | x<-[1..100], a*3^x<=b*2^x]\nmas = do\n [a,b]<-fmap (map read.words) getLine\n print$has a b\n\n\nmain :: IO()\nmain = mas\n"}, {"source_code": "exceed :: String -> Int\nexceed s = (floor $ logBase 1.5 (b / a)) + 1\n where a = nums !! 0\n b = nums !! 1\n nums = map read . words $ s :: [Float]\n\nmain = do\n s <- getLine\n print $ exceed s\n"}, {"source_code": "main = interact $ show . length . takeWhile (uncurry (<=)) .\n iterate grow . ((,) <$> (!!0) <*> (!!1)) . map read . words\ngrow (a,b) = (3*a,2*b)\n"}, {"source_code": "-- import Debug.Trace\n-- import System.IO.Unsafe\n-- import Text.Printf\nimport System.IO\nimport Control.Monad\nimport Data.List\n\nglwr = fmap (map read . words) getLine\n\nmain = do\n hSetBuffering stdout NoBuffering\n solve\n\nsolve :: IO ()\nsolve = do\n a:b:_ <- glwr\n\n print $ bear a b\n\nbear :: Int -> Int -> Int\nbear a b\n | a > b = 0\n | 0 < 1 = 1 + bear (a*3) (b*2)\n"}, {"source_code": "import Data.List\nimport qualified Data.ByteString.Lazy.Char8 as BS\n\ngetInt :: IO Int\ngetInt = readLn\n\ngetList :: IO [Int]\ngetList = do\n xs <- getLine\n return $ map read $ words xs\n\ngetNList :: Int -> IO [[Int]]\ngetNList 0 = return [[]]\ngetNList n = do\n xs <- getList\n fmap (xs:) $ getNList (n-1)\n\nreadInt :: BS.ByteString -> Int\nreadInt x = case BS.readInt x of Just (i, _) -> i\n Nothing -> error \"Unparsable Int\"\n\nsolve :: Int -> Int -> Int -> Int\nsolve a b t | a > b = t\n | otherwise = solve (3*a) (2*b) (t+1)\n \nmain = do\n (a:b:[]) <- getList\n print $ solve a b 0"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/791/A\n\nmain :: IO ()\nmain = do\n [a,b] <- fmap (map read . words) getLine :: IO [Int]\n print . length $ takeWhile id [a*(3^p) <= b*(2^p) | p <- [0..]]\n"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/791/A\n\nsolve :: [Int] -> Int\nsolve [a,b] | a > b = 0\n | otherwise = 1 + solve [a*3, b*2]\n\nmain :: IO ()\nmain = print . solve . map read . words =<< getLine\n"}, {"source_code": "\nparseInts :: String -> [Int]\nparseInts str = map read (words str)\n\nsolver :: Int -> Int -> Int\nsolver x y =\n if x > y then 0\n else 1 + (solver (x * 3) (y * 2))\n\n\nmain = do\n integers <- fmap parseInts getLine\n putStrLn (show (solver (integers!!0) (integers!!1)))\n"}, {"source_code": "import Control.Applicative( (<$>))\nmain = do\n [a_, b_] <- map read . words <$> getLine\n let\n\tproc n limak bob =\tlet\n\t\t\t\tlimak' = limak*3\n\t\t\t\tbob' = bob*2\n\t\t\t in\n\t\t\t\tif limak' > bob'\n\t\t\t\t then n+1\n\t\t\t\t else proc (n+1) limak' bob'\n print $ proc 0 a_ b_\n"}, {"source_code": "module Main where\n\ninfixl 0 |>\nx |> f = f x\n\nsolve :: [Int] -> Int -> Int\nsolve [a, b] years | a > b = years\n | otherwise = solve [a * 3, b * 2] (years + 1)\n\nmain :: IO ()\nmain = do\n line <- getLine\n let row = line |> map read . words\n solve row 0 |> print\n"}, {"source_code": "main = do\n input <- getLine\n let [limak, bob] = map read $ words input\n print $ solve [limak, bob] 0\n\nsolve :: [Integer] -> Integer -> Integer\nsolve [limak, bob] year\n | limak > bob = year\n | otherwise = solve [limak * 3, bob * 2] (year + 1)"}, {"source_code": "main = do\n n <- getLine\n print . f . g . stoi . words $ n\n\nstoi :: [[Char]] -> [Int]\nstoi [] = []\nstoi (n:ns) = (read n::Int) : stoi ns\n\ng :: [Int] -> (Int,Int)\ng (x:y:[]) = (x,y)\n\nf :: (Int,Int) -> Int\nf (x,y) \n | x <= y = 1 + f (3*x, 2*y)\n | otherwise = 0"}, {"source_code": "solve :: String -> Int\nsolve input = \n let (a:b:_) = map (\\xs -> read xs :: Int) (words input)\n la = [a * (3 ^ p) | p <- [0, 1..]]\n lb = [b * (2 ^ p) | p <- [0, 1..]]\n lc = zipWith (>) la lb\n in length $ takeWhile (\\x -> x == False) lc\n\nmain = do\n input <- getLine\n print $ solve input"}, {"source_code": "getID :: [Bool] -> Int\ngetID (x:xs)\n | x == True = 0\n | otherwise = 1 + getID xs\n\nsolve :: String -> Int\nsolve input = \n let (a:b:_) = map (\\xs -> read xs :: Int) (words input)\n la = [a * (3 ^ p) | p <- [0, 1..]]\n lb = [b * (2 ^ p) | p <- [0, 1..]]\n lc = zipWith (>) la lb\n in getID lc\n\nmain = do\n input <- getLine\n print $ solve input"}, {"source_code": "main :: IO ()\nmain = do\n [a, b] <- map read <$> words <$> getLine\n let x = -1 * (log (a / b)) / (log (3 / 2))\n let cx = ceiling x\n print $ if x < (fromIntegral cx) then cx else cx + 1\n"}, {"source_code": "{-# OPTIONS_GHC -O3 #-}\n{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}\n\nimport Control.Monad (forM_, forM)\n\nbin :: Integer -> Integer -> Integer -> Integer -> Integer\nbin a b x y | x >= y - 1 = if a * 3^x == b * 2^x then x + 1 else y\n | a * 3^m > b * 2^m = bin a b x m\n | a * 3^m == b * 2^m = m + 1\n | otherwise = bin a b m y where\n m = (x + y) `div` 2\n\nrun a b = bin a b 0 1000\n\nmain = do\n ((map read) . words -> [a, b]) <- getLine\n putStrLn $ (show $ run a b)\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\nans a b = (\\(x1,y1,z1)->x1) $ head $ dropWhile (\\(x,y,z)-> y<=z) $ [(i,a*3^i,b*2^i)| i<-[1..]]\n\nmain::IO ()\nmain=do\n [a,b]<- map read <$>words <$> getLine ::IO [Int]\n print $ ans a b\n"}, {"source_code": "solve :: Int -> Int -> Int\nsolve l b\n | l > b = 0\n | otherwise = 1 + solve (3*l) (2*b)\n\nmain :: IO ()\nmain = do\n [l,b] <- map (read :: String -> Int) . words <$> getLine\n print $ solve l b\n"}, {"source_code": "main :: IO ()\nmain = do\n val <- getLine\n let (n:k:_) = map read $ (words val) ::[Int]\n print(grow n k 0) \n\ngrow ::(Num a, Ord a) => a -> a -> a -> a\ngrow n k j\n |n <= k = grow (n * 3) (k * 2) (j + 1)\n |otherwise = j\n \n"}, {"source_code": "--ghc 7.10\n\nyearCount :: Float -> Float -> Int\nyearCount a b = \n if 3^k * a > 2^k * b\n then k\n else k+1\n where\n k = floor $ log (b / a) / log (ra / rb)\n ra = 3.0\n rb = 2.0\n\nmain = do\n line <- getLine\n let [a,b] = map read . words $ line :: [Float]\n print $ yearCount a b"}, {"source_code": "lastTuple :: (Int, Int, Int) -> Int\nlastTuple (a, b, c) = c\n\nprocess :: (Int, Int) -> Int\nprocess (small, big) = \n lastTuple $ until (\\(x,y,z) -> x > y) (\\(x,y,z) -> (x*3, y*2, z+1)) (small, big, 0) \n \nmain :: IO ()\nmain = do\n [small, big] <- fmap( map read . words) getLine\n let result = process (small, big)\n putStrLn (show result)"}, {"source_code": "-- {-# LANGUAGE MagicHash #-}\nmodule Main where\n\n-- import GHC.Integer.Logarithms (integerLogBase#)\n\nmain :: IO ()\nmain = interact $ show . f . map read . words\n\nf (x:y:_) = length . takeWhile (uncurry (<=)) . iterate (\\(a,b) -> (a*3, b*2)) $ (x,y)\n"}], "negative_code": [{"source_code": "{-# LANGUAGE BlockArguments #-}\n\nimport Control.Arrow\n\nmain = interact $\n lines >>> map (words >>> map read >>> solve >>> show) >>> unlines\n\n\ntoFloat :: Int -> Double\ntoFloat x = (fromIntegral x)::Double\n\nsolve :: [Int] -> Int\nsolve [a,b] = floor(logBase 1.5 (toFloat b) - logBase 1.5 (toFloat a) + 1)"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\nans a b = (\\(x1,y1,z1)->x1) $ head $ dropWhile (\\(x,y,z)-> ywords <$> getLine ::IO [Int]\n print $ ans a b\n"}], "src_uid": "a1583b07a9d093e887f73cc5c29e444a"} {"source_code": "main :: IO()\nmain = print . solve . map read . words =<< getLine\n\nsolve :: [Int] -> Int\nsolve [n, k] = n + k - n `mod` k\n", "positive_code": [{"source_code": "solve [n, k] = x' - x' `mod` k\n where x' = n + k\n\nmain = interact $ unlines . map (show . solve . map read . words) . lines\n"}, {"source_code": "module Main where\n\nmain = do\n [n,k] <- map (read :: String -> Int) . words <$> getLine\n let a = n`mod`k\n print $ n + if a == 0 then k else k-a"}, {"source_code": "main = getLine >>= print . (\\[n, k] -> n + k - n `mod` k) . map read . words\n\n"}, {"source_code": "main = interact $ show . solve . map read . words\n\nsolve :: [Int] -> Int\nsolve (a:b:_) = (a `div` b) * b + b\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\n\n\nmain = do\n\t\t[n,k]<- map read <$> words <$> getLine ::IO [Int]\n\t\tprint $ n + (k - mod n k)\n\n"}], "negative_code": [], "src_uid": "75f3835c969c871a609b978e04476542"} {"source_code": "okBranch :: Int -> Int -> Bool\nokBranch p branch = null $ filter (`divides` branch) [2..limit]\n where divides n = (==0) . (`rem` n)\n limit = min p . floor . sqrt . fromIntegral $ branch\n\nmain :: IO ()\nmain = let output l = if null l then -1 else head l in do\n l <- getLine\n let [p, y] = map read . words $ l\n print . output . filter (okBranch p) $ [y,y-1..p+1]", "positive_code": [{"source_code": "import Control.Monad\n\n(%) = rem\n\ncheck :: Int -> Int -> Bool\ncheck p n = let s = floor $ sqrt $ fromIntegral n\n divs = filter (\\x -> (n % x) == 0) [y | y <- [2..s]] in\n null divs || p < head divs\n\nmain = do\n [p, y] <- (liftM ((map read).words) $ getLine) :: IO [Int]\n print $ (\\xs -> if null xs then -1 else head xs) $ filter (check p) [y,(y-1)..p + 1]\n \n\n"}, {"source_code": "import Data.List\nmain = interact $ show . solve . map read . words\nsolve [p,y] = head $ [ x | x <- [y,y-1..p+1], primeTo p x ] ++ [-1]\nprimeTo p x | Just g <- find ((== 0) . (x `mod`)) (takeWhile (<= p) primes)\n = False\n | otherwise = True\n\nprimes = [2,3,5,7,11,13,17,19\n ,23,29,31,37,41,43,47,53\n ,59,61,67,71,73,79,83,89\n ,97,101,103,107,109,113,127,131\n ,137,139,149,151,157,163,167,173\n ,179,181,191,193,197,199,211,223\n ,227,229,233,239,241,251,257,263\n ,269,271,277,281,283,293,307,311\n ,313,317,331,337,347,349,353,359\n ,367,373,379,383,389,397,401,409\n ,419,421,431,433,439,443,449,457\n ,461,463,467,479,487,491,499,503\n ,509,521,523,541,547,557,563,569\n ,571,577,587,593,599,601,607,613\n ,617,619,631,641,643,647,653,659\n ,661,673,677,683,691,701,709,719\n ,727,733,739,743,751,757,761,769\n ,773,787,797,809,811,821,823,827\n ,829,839,853,857,859,863,877,881\n ,883,887,907,911,919,929,937,941\n ,947,953,967,971,977,983,991,997\n ,1009,1013,1019,1021,1031,1033,1039,1049\n ,1051,1061,1063,1069,1087,1091,1093,1097\n ,1103,1109,1117,1123,1129,1151,1153,1163\n ,1171,1181,1187,1193,1201,1213,1217,1223\n ,1229,1231,1237,1249,1259,1277,1279,1283\n ,1289,1291,1297,1301,1303,1307,1319,1321\n ,1327,1361,1367,1373,1381,1399,1409,1423\n ,1427,1429,1433,1439,1447,1451,1453,1459\n ,1471,1481,1483,1487,1489,1493,1499,1511\n ,1523,1531,1543,1549,1553,1559,1567,1571\n ,1579,1583,1597,1601,1607,1609,1613,1619\n ,1621,1627,1637,1657,1663,1667,1669,1693\n ,1697,1699,1709,1721,1723,1733,1741,1747\n ,1753,1759,1777,1783,1787,1789,1801,1811\n ,1823,1831,1847,1861,1867,1871,1873,1877\n ,1879,1889,1901,1907,1913,1931,1933,1949\n ,1951,1973,1979,1987,1993,1997,1999,2003\n ,2011,2017,2027,2029,2039,2053,2063,2069\n ,2081,2083,2087,2089,2099,2111,2113,2129\n ,2131,2137,2141,2143,2153,2161,2179,2203\n ,2207,2213,2221,2237,2239,2243,2251,2267\n ,2269,2273,2281,2287,2293,2297,2309,2311\n ,2333,2339,2341,2347,2351,2357,2371,2377\n ,2381,2383,2389,2393,2399,2411,2417,2423\n ,2437,2441,2447,2459,2467,2473,2477,2503\n ,2521,2531,2539,2543,2549,2551,2557,2579\n ,2591,2593,2609,2617,2621,2633,2647,2657\n ,2659,2663,2671,2677,2683,2687,2689,2693\n ,2699,2707,2711,2713,2719,2729,2731,2741\n ,2749,2753,2767,2777,2789,2791,2797,2801\n ,2803,2819,2833,2837,2843,2851,2857,2861\n ,2879,2887,2897,2903,2909,2917,2927,2939\n ,2953,2957,2963,2969,2971,2999,3001,3011\n ,3019,3023,3037,3041,3049,3061,3067,3079\n ,3083,3089,3109,3119,3121,3137,3163,3167\n ,3169,3181,3187,3191,3203,3209,3217,3221\n ,3229,3251,3253,3257,3259,3271,3299,3301\n ,3307,3313,3319,3323,3329,3331,3343,3347\n ,3359,3361,3371,3373,3389,3391,3407,3413\n ,3433,3449,3457,3461,3463,3467,3469,3491\n ,3499,3511,3517,3527,3529,3533,3539,3541\n ,3547,3557,3559,3571,3581,3583,3593,3607\n ,3613,3617,3623,3631,3637,3643,3659,3671\n ,3673,3677,3691,3697,3701,3709,3719,3727\n ,3733,3739,3761,3767,3769,3779,3793,3797\n ,3803,3821,3823,3833,3847,3851,3853,3863\n ,3877,3881,3889,3907,3911,3917,3919,3923\n ,3929,3931,3943,3947,3967,3989,4001,4003\n ,4007,4013,4019,4021,4027,4049,4051,4057\n ,4073,4079,4091,4093,4099,4111,4127,4129\n ,4133,4139,4153,4157,4159,4177,4201,4211\n ,4217,4219,4229,4231,4241,4243,4253,4259\n ,4261,4271,4273,4283,4289,4297,4327,4337\n ,4339,4349,4357,4363,4373,4391,4397,4409\n ,4421,4423,4441,4447,4451,4457,4463,4481\n ,4483,4493,4507,4513,4517,4519,4523,4547\n ,4549,4561,4567,4583,4591,4597,4603,4621\n ,4637,4639,4643,4649,4651,4657,4663,4673\n ,4679,4691,4703,4721,4723,4729,4733,4751\n ,4759,4783,4787,4789,4793,4799,4801,4813\n ,4817,4831,4861,4871,4877,4889,4903,4909\n ,4919,4931,4933,4937,4943,4951,4957,4967\n ,4969,4973,4987,4993,4999,5003,5009,5011\n ,5021,5023,5039,5051,5059,5077,5081,5087\n ,5099,5101,5107,5113,5119,5147,5153,5167\n ,5171,5179,5189,5197,5209,5227,5231,5233\n ,5237,5261,5273,5279,5281,5297,5303,5309\n ,5323,5333,5347,5351,5381,5387,5393,5399\n ,5407,5413,5417,5419,5431,5437,5441,5443\n ,5449,5471,5477,5479,5483,5501,5503,5507\n ,5519,5521,5527,5531,5557,5563,5569,5573\n ,5581,5591,5623,5639,5641,5647,5651,5653\n ,5657,5659,5669,5683,5689,5693,5701,5711\n ,5717,5737,5741,5743,5749,5779,5783,5791\n ,5801,5807,5813,5821,5827,5839,5843,5849\n ,5851,5857,5861,5867,5869,5879,5881,5897\n ,5903,5923,5927,5939,5953,5981,5987,6007\n ,6011,6029,6037,6043,6047,6053,6067,6073\n ,6079,6089,6091,6101,6113,6121,6131,6133\n ,6143,6151,6163,6173,6197,6199,6203,6211\n ,6217,6221,6229,6247,6257,6263,6269,6271\n ,6277,6287,6299,6301,6311,6317,6323,6329\n ,6337,6343,6353,6359,6361,6367,6373,6379\n ,6389,6397,6421,6427,6449,6451,6469,6473\n ,6481,6491,6521,6529,6547,6551,6553,6563\n ,6569,6571,6577,6581,6599,6607,6619,6637\n ,6653,6659,6661,6673,6679,6689,6691,6701\n ,6703,6709,6719,6733,6737,6761,6763,6779\n ,6781,6791,6793,6803,6823,6827,6829,6833\n ,6841,6857,6863,6869,6871,6883,6899,6907\n ,6911,6917,6947,6949,6959,6961,6967,6971\n ,6977,6983,6991,6997,7001,7013,7019,7027\n ,7039,7043,7057,7069,7079,7103,7109,7121\n ,7127,7129,7151,7159,7177,7187,7193,7207\n ,7211,7213,7219,7229,7237,7243,7247,7253\n ,7283,7297,7307,7309,7321,7331,7333,7349\n ,7351,7369,7393,7411,7417,7433,7451,7457\n ,7459,7477,7481,7487,7489,7499,7507,7517\n ,7523,7529,7537,7541,7547,7549,7559,7561\n ,7573,7577,7583,7589,7591,7603,7607,7621\n ,7639,7643,7649,7669,7673,7681,7687,7691\n ,7699,7703,7717,7723,7727,7741,7753,7757\n ,7759,7789,7793,7817,7823,7829,7841,7853\n ,7867,7873,7877,7879,7883,7901,7907,7919\n ,7927,7933,7937,7949,7951,7963,7993,8009\n ,8011,8017,8039,8053,8059,8069,8081,8087\n ,8089,8093,8101,8111,8117,8123,8147,8161\n ,8167,8171,8179,8191,8209,8219,8221,8231\n ,8233,8237,8243,8263,8269,8273,8287,8291\n ,8293,8297,8311,8317,8329,8353,8363,8369\n ,8377,8387,8389,8419,8423,8429,8431,8443\n ,8447,8461,8467,8501,8513,8521,8527,8537\n ,8539,8543,8563,8573,8581,8597,8599,8609\n ,8623,8627,8629,8641,8647,8663,8669,8677\n ,8681,8689,8693,8699,8707,8713,8719,8731\n ,8737,8741,8747,8753,8761,8779,8783,8803\n ,8807,8819,8821,8831,8837,8839,8849,8861\n ,8863,8867,8887,8893,8923,8929,8933,8941\n ,8951,8963,8969,8971,8999,9001,9007,9011\n ,9013,9029,9041,9043,9049,9059,9067,9091\n ,9103,9109,9127,9133,9137,9151,9157,9161\n ,9173,9181,9187,9199,9203,9209,9221,9227\n ,9239,9241,9257,9277,9281,9283,9293,9311\n ,9319,9323,9337,9341,9343,9349,9371,9377\n ,9391,9397,9403,9413,9419,9421,9431,9433\n ,9437,9439,9461,9463,9467,9473,9479,9491\n ,9497,9511,9521,9533,9539,9547,9551,9587\n ,9601,9613,9619,9623,9629,9631,9643,9649\n ,9661,9677,9679,9689,9697,9719,9721,9733\n ,9739,9743,9749,9767,9769,9781,9787,9791\n ,9803,9811,9817,9829,9833,9839,9851,9857\n ,9859,9871,9883,9887,9901,9907,9923,9929\n ,9931,9941,9949,9967,9973,10007,10009,10037\n ,10039,10061,10067,10069,10079,10091,10093,10099\n ,10103,10111,10133,10139,10141,10151,10159,10163\n ,10169,10177,10181,10193,10211,10223,10243,10247\n ,10253,10259,10267,10271,10273,10289,10301,10303\n ,10313,10321,10331,10333,10337,10343,10357,10369\n ,10391,10399,10427,10429,10433,10453,10457,10459\n ,10463,10477,10487,10499,10501,10513,10529,10531\n ,10559,10567,10589,10597,10601,10607,10613,10627\n ,10631,10639,10651,10657,10663,10667,10687,10691\n ,10709,10711,10723,10729,10733,10739,10753,10771\n ,10781,10789,10799,10831,10837,10847,10853,10859\n ,10861,10867,10883,10889,10891,10903,10909,10937\n ,10939,10949,10957,10973,10979,10987,10993,11003\n ,11027,11047,11057,11059,11069,11071,11083,11087\n ,11093,11113,11117,11119,11131,11149,11159,11161\n ,11171,11173,11177,11197,11213,11239,11243,11251\n ,11257,11261,11273,11279,11287,11299,11311,11317\n ,11321,11329,11351,11353,11369,11383,11393,11399\n ,11411,11423,11437,11443,11447,11467,11471,11483\n ,11489,11491,11497,11503,11519,11527,11549,11551\n ,11579,11587,11593,11597,11617,11621,11633,11657\n ,11677,11681,11689,11699,11701,11717,11719,11731\n ,11743,11777,11779,11783,11789,11801,11807,11813\n ,11821,11827,11831,11833,11839,11863,11867,11887\n ,11897,11903,11909,11923,11927,11933,11939,11941\n ,11953,11959,11969,11971,11981,11987,12007,12011\n ,12037,12041,12043,12049,12071,12073,12097,12101\n ,12107,12109,12113,12119,12143,12149,12157,12161\n ,12163,12197,12203,12211,12227,12239,12241,12251\n ,12253,12263,12269,12277,12281,12289,12301,12323\n ,12329,12343,12347,12373,12377,12379,12391,12401\n ,12409,12413,12421,12433,12437,12451,12457,12473\n ,12479,12487,12491,12497,12503,12511,12517,12527\n ,12539,12541,12547,12553,12569,12577,12583,12589\n ,12601,12611,12613,12619,12637,12641,12647,12653\n ,12659,12671,12689,12697,12703,12713,12721,12739\n ,12743,12757,12763,12781,12791,12799,12809,12821\n ,12823,12829,12841,12853,12889,12893,12899,12907\n ,12911,12917,12919,12923,12941,12953,12959,12967\n ,12973,12979,12983,13001,13003,13007,13009,13033\n ,13037,13043,13049,13063,13093,13099,13103,13109\n ,13121,13127,13147,13151,13159,13163,13171,13177\n ,13183,13187,13217,13219,13229,13241,13249,13259\n ,13267,13291,13297,13309,13313,13327,13331,13337\n ,13339,13367,13381,13397,13399,13411,13417,13421\n ,13441,13451,13457,13463,13469,13477,13487,13499\n ,13513,13523,13537,13553,13567,13577,13591,13597\n ,13613,13619,13627,13633,13649,13669,13679,13681\n ,13687,13691,13693,13697,13709,13711,13721,13723\n ,13729,13751,13757,13759,13763,13781,13789,13799\n ,13807,13829,13831,13841,13859,13873,13877,13879\n ,13883,13901,13903,13907,13913,13921,13931,13933\n ,13963,13967,13997,13999,14009,14011,14029,14033\n ,14051,14057,14071,14081,14083,14087,14107,14143\n ,14149,14153,14159,14173,14177,14197,14207,14221\n ,14243,14249,14251,14281,14293,14303,14321,14323\n ,14327,14341,14347,14369,14387,14389,14401,14407\n ,14411,14419,14423,14431,14437,14447,14449,14461\n ,14479,14489,14503,14519,14533,14537,14543,14549\n ,14551,14557,14561,14563,14591,14593,14621,14627\n ,14629,14633,14639,14653,14657,14669,14683,14699\n ,14713,14717,14723,14731,14737,14741,14747,14753\n ,14759,14767,14771,14779,14783,14797,14813,14821\n ,14827,14831,14843,14851,14867,14869,14879,14887\n ,14891,14897,14923,14929,14939,14947,14951,14957\n ,14969,14983,15013,15017,15031,15053,15061,15073\n ,15077,15083,15091,15101,15107,15121,15131,15137\n ,15139,15149,15161,15173,15187,15193,15199,15217\n ,15227,15233,15241,15259,15263,15269,15271,15277\n ,15287,15289,15299,15307,15313,15319,15329,15331\n ,15349,15359,15361,15373,15377,15383,15391,15401\n ,15413,15427,15439,15443,15451,15461,15467,15473\n ,15493,15497,15511,15527,15541,15551,15559,15569\n ,15581,15583,15601,15607,15619,15629,15641,15643\n ,15647,15649,15661,15667,15671,15679,15683,15727\n ,15731,15733,15737,15739,15749,15761,15767,15773\n ,15787,15791,15797,15803,15809,15817,15823,15859\n ,15877,15881,15887,15889,15901,15907,15913,15919\n ,15923,15937,15959,15971,15973,15991,16001,16007\n ,16033,16057,16061,16063,16067,16069,16073,16087\n ,16091,16097,16103,16111,16127,16139,16141,16183\n ,16187,16189,16193,16217,16223,16229,16231,16249\n ,16253,16267,16273,16301,16319,16333,16339,16349\n ,16361,16363,16369,16381,16411,16417,16421,16427\n ,16433,16447,16451,16453,16477,16481,16487,16493\n ,16519,16529,16547,16553,16561,16567,16573,16603\n ,16607,16619,16631,16633,16649,16651,16657,16661\n ,16673,16691,16693,16699,16703,16729,16741,16747\n ,16759,16763,16787,16811,16823,16829,16831,16843\n ,16871,16879,16883,16889,16901,16903,16921,16927\n ,16931,16937,16943,16963,16979,16981,16987,16993\n ,17011,17021,17027,17029,17033,17041,17047,17053\n ,17077,17093,17099,17107,17117,17123,17137,17159\n ,17167,17183,17189,17191,17203,17207,17209,17231\n ,17239,17257,17291,17293,17299,17317,17321,17327\n ,17333,17341,17351,17359,17377,17383,17387,17389\n ,17393,17401,17417,17419,17431,17443,17449,17467\n ,17471,17477,17483,17489,17491,17497,17509,17519\n ,17539,17551,17569,17573,17579,17581,17597,17599\n ,17609,17623,17627,17657,17659,17669,17681,17683\n ,17707,17713,17729,17737,17747,17749,17761,17783\n ,17789,17791,17807,17827,17837,17839,17851,17863\n ,17881,17891,17903,17909,17911,17921,17923,17929\n ,17939,17957,17959,17971,17977,17981,17987,17989\n ,18013,18041,18043,18047,18049,18059,18061,18077\n ,18089,18097,18119,18121,18127,18131,18133,18143\n ,18149,18169,18181,18191,18199,18211,18217,18223\n ,18229,18233,18251,18253,18257,18269,18287,18289\n ,18301,18307,18311,18313,18329,18341,18353,18367\n ,18371,18379,18397,18401,18413,18427,18433,18439\n ,18443,18451,18457,18461,18481,18493,18503,18517\n ,18521,18523,18539,18541,18553,18583,18587,18593\n ,18617,18637,18661,18671,18679,18691,18701,18713\n ,18719,18731,18743,18749,18757,18773,18787,18793\n ,18797,18803,18839,18859,18869,18899,18911,18913\n ,18917,18919,18947,18959,18973,18979,19001,19009\n ,19013,19031,19037,19051,19069,19073,19079,19081\n ,19087,19121,19139,19141,19157,19163,19181,19183\n ,19207,19211,19213,19219,19231,19237,19249,19259\n ,19267,19273,19289,19301,19309,19319,19333,19373\n ,19379,19381,19387,19391,19403,19417,19421,19423\n ,19427,19429,19433,19441,19447,19457,19463,19469\n ,19471,19477,19483,19489,19501,19507,19531,19541\n ,19543,19553,19559,19571,19577,19583,19597,19603\n ,19609,19661,19681,19687,19697,19699,19709,19717\n ,19727,19739,19751,19753,19759,19763,19777,19793\n ,19801,19813,19819,19841,19843,19853,19861,19867\n ,19889,19891,19913,19919,19927,19937,19949,19961\n ,19963,19973,19979,19991,19993,19997,20011,20021\n ,20023,20029,20047,20051,20063,20071,20089,20101\n ,20107,20113,20117,20123,20129,20143,20147,20149\n ,20161,20173,20177,20183,20201,20219,20231,20233\n ,20249,20261,20269,20287,20297,20323,20327,20333\n ,20341,20347,20353,20357,20359,20369,20389,20393\n ,20399,20407,20411,20431,20441,20443,20477,20479\n ,20483,20507,20509,20521,20533,20543,20549,20551\n ,20563,20593,20599,20611,20627,20639,20641,20663\n ,20681,20693,20707,20717,20719,20731,20743,20747\n ,20749,20753,20759,20771,20773,20789,20807,20809\n ,20849,20857,20873,20879,20887,20897,20899,20903\n ,20921,20929,20939,20947,20959,20963,20981,20983\n ,21001,21011,21013,21017,21019,21023,21031,21059\n ,21061,21067,21089,21101,21107,21121,21139,21143\n ,21149,21157,21163,21169,21179,21187,21191,21193\n ,21211,21221,21227,21247,21269,21277,21283,21313\n ,21317,21319,21323,21341,21347,21377,21379,21383\n ,21391,21397,21401,21407,21419,21433,21467,21481\n ,21487,21491,21493,21499,21503,21517,21521,21523\n ,21529,21557,21559,21563,21569,21577,21587,21589\n ,21599,21601,21611,21613,21617,21647,21649,21661\n ,21673,21683,21701,21713,21727,21737,21739,21751\n ,21757,21767,21773,21787,21799,21803,21817,21821\n ,21839,21841,21851,21859,21863,21871,21881,21893\n ,21911,21929,21937,21943,21961,21977,21991,21997\n ,22003,22013,22027,22031,22037,22039,22051,22063\n ,22067,22073,22079,22091,22093,22109,22111,22123\n ,22129,22133,22147,22153,22157,22159,22171,22189\n ,22193,22229,22247,22259,22271,22273,22277,22279\n ,22283,22291,22303,22307,22343,22349,22367,22369\n ,22381,22391,22397,22409,22433,22441,22447,22453\n ,22469,22481,22483,22501,22511,22531,22541,22543\n ,22549,22567,22571,22573,22613,22619,22621,22637\n ,22639,22643,22651,22669,22679,22691,22697,22699\n ,22709,22717,22721,22727,22739,22741,22751,22769\n ,22777,22783,22787,22807,22811,22817,22853,22859\n ,22861,22871,22877,22901,22907,22921,22937,22943\n ,22961,22963,22973,22993,23003,23011,23017,23021\n ,23027,23029,23039,23041,23053,23057,23059,23063\n ,23071,23081,23087,23099,23117,23131,23143,23159\n ,23167,23173,23189,23197,23201,23203,23209,23227\n ,23251,23269,23279,23291,23293,23297,23311,23321\n ,23327,23333,23339,23357,23369,23371,23399,23417\n ,23431,23447,23459,23473,23497,23509,23531,23537\n ,23539,23549,23557,23561,23563,23567,23581,23593\n ,23599,23603,23609,23623,23627,23629,23633,23663\n ,23669,23671,23677,23687,23689,23719,23741,23743\n ,23747,23753,23761,23767,23773,23789,23801,23813\n ,23819,23827,23831,23833,23857,23869,23873,23879\n ,23887,23893,23899,23909,23911,23917,23929,23957\n ,23971,23977,23981,23993,24001,24007,24019,24023\n ,24029,24043,24049,24061,24071,24077,24083,24091\n ,24097,24103,24107,24109,24113,24121,24133,24137\n ,24151,24169,24179,24181,24197,24203,24223,24229\n ,24239,24247,24251,24281,24317,24329,24337,24359\n ,24371,24373,24379,24391,24407,24413,24419,24421\n ,24439,24443,24469,24473,24481,24499,24509,24517\n ,24527,24533,24547,24551,24571,24593,24611,24623\n ,24631,24659,24671,24677,24683,24691,24697,24709\n ,24733,24749,24763,24767,24781,24793,24799,24809\n ,24821,24841,24847,24851,24859,24877,24889,24907\n ,24917,24919,24923,24943,24953,24967,24971,24977\n ,24979,24989,25013,25031,25033,25037,25057,25073\n ,25087,25097,25111,25117,25121,25127,25147,25153\n ,25163,25169,25171,25183,25189,25219,25229,25237\n ,25243,25247,25253,25261,25301,25303,25307,25309\n ,25321,25339,25343,25349,25357,25367,25373,25391\n ,25409,25411,25423,25439,25447,25453,25457,25463\n ,25469,25471,25523,25537,25541,25561,25577,25579\n ,25583,25589,25601,25603,25609,25621,25633,25639\n ,25643,25657,25667,25673,25679,25693,25703,25717\n ,25733,25741,25747,25759,25763,25771,25793,25799\n ,25801,25819,25841,25847,25849,25867,25873,25889\n ,25903,25913,25919,25931,25933,25939,25943,25951\n ,25969,25981,25997,25999,26003,26017,26021,26029\n ,26041,26053,26083,26099,26107,26111,26113,26119\n ,26141,26153,26161,26171,26177,26183,26189,26203\n ,26209,26227,26237,26249,26251,26261,26263,26267\n ,26293,26297,26309,26317,26321,26339,26347,26357\n ,26371,26387,26393,26399,26407,26417,26423,26431\n ,26437,26449,26459,26479,26489,26497,26501,26513\n ,26539,26557,26561,26573,26591,26597,26627,26633\n ,26641,26647,26669,26681,26683,26687,26693,26699\n ,26701,26711,26713,26717,26723,26729,26731,26737\n ,26759,26777,26783,26801,26813,26821,26833,26839\n ,26849,26861,26863,26879,26881,26891,26893,26903\n ,26921,26927,26947,26951,26953,26959,26981,26987\n ,26993,27011,27017,27031,27043,27059,27061,27067\n ,27073,27077,27091,27103,27107,27109,27127,27143\n ,27179,27191,27197,27211,27239,27241,27253,27259\n ,27271,27277,27281,27283,27299,27329,27337,27361\n ,27367,27397,27407,27409,27427,27431,27437,27449\n ,27457,27479,27481,27487,27509,27527,27529,27539\n ,27541,27551,27581,27583,27611,27617,27631,27647\n ,27653,27673,27689,27691,27697,27701,27733,27737\n ,27739,27743,27749,27751,27763,27767,27773,27779\n ,27791,27793,27799,27803,27809,27817,27823,27827\n ,27847,27851,27883,27893,27901,27917,27919,27941\n ,27943,27947,27953,27961,27967,27983,27997,28001\n ,28019,28027,28031,28051,28057,28069,28081,28087\n ,28097,28099,28109,28111,28123,28151,28163,28181\n ,28183,28201,28211,28219,28229,28277,28279,28283\n ,28289,28297,28307,28309,28319,28349,28351,28387\n ,28393,28403,28409,28411,28429,28433,28439,28447\n ,28463,28477,28493,28499,28513,28517,28537,28541\n ,28547,28549,28559,28571,28573,28579,28591,28597\n ,28603,28607,28619,28621,28627,28631,28643,28649\n ,28657,28661,28663,28669,28687,28697,28703,28711\n ,28723,28729,28751,28753,28759,28771,28789,28793\n ,28807,28813,28817,28837,28843,28859,28867,28871\n ,28879,28901,28909,28921,28927,28933,28949,28961\n ,28979,29009,29017,29021,29023,29027,29033,29059\n ,29063,29077,29101,29123,29129,29131,29137,29147\n ,29153,29167,29173,29179,29191,29201,29207,29209\n ,29221,29231,29243,29251,29269,29287,29297,29303\n ,29311,29327,29333,29339,29347,29363,29383,29387\n ,29389,29399,29401,29411,29423,29429,29437,29443\n ,29453,29473,29483,29501,29527,29531,29537,29567\n ,29569,29573,29581,29587,29599,29611,29629,29633\n ,29641,29663,29669,29671,29683,29717,29723,29741\n ,29753,29759,29761,29789,29803,29819,29833,29837\n ,29851,29863,29867,29873,29879,29881,29917,29921\n ,29927,29947,29959,29983,29989,30011,30013,30029\n ,30047,30059,30071,30089,30091,30097,30103,30109\n ,30113,30119,30133,30137,30139,30161,30169,30181\n ,30187,30197,30203,30211,30223,30241,30253,30259\n ,30269,30271,30293,30307,30313,30319,30323,30341\n ,30347,30367,30389,30391,30403,30427,30431,30449\n ,30467,30469,30491,30493,30497,30509,30517,30529\n ,30539,30553,30557,30559,30577,30593,30631,30637\n ,30643,30649,30661,30671,30677,30689,30697,30703\n ,30707,30713,30727,30757,30763,30773,30781,30803\n ,30809,30817,30829,30839,30841,30851,30853,30859\n ,30869,30871,30881,30893,30911,30931,30937,30941\n ,30949,30971,30977,30983,31013,31019,31033,31039\n ,31051,31063,31069,31079,31081,31091,31121,31123\n ,31139,31147,31151,31153,31159,31177,31181,31183\n ,31189,31193,31219,31223,31231,31237,31247,31249\n ,31253,31259,31267,31271,31277,31307,31319,31321\n ,31327,31333,31337,31357,31379,31387,31391,31393\n ,31397,31469,31477,31481,31489,31511,31513,31517\n ,31531,31541,31543,31547,31567,31573,31583,31601\n ,31607]\n"}], "negative_code": [], "src_uid": "b533203f488fa4caf105f3f46dd5844d"} {"source_code": "import Control.Applicative\nimport Data.List\n\nprocess [] n = n\nprocess (s:ss) n | s=='1' = process ss (n+1)\n\t | otherwise = n+1\n\nmain= do\n\tgetLine\n\ts<- getLine\n\tprint $ process s 0\n\t", "positive_code": [{"source_code": "import Numeric\nimport Data.Char\nreadBin = foldr (\\c s -> s * 2 + c) 0 . reverse . map c2i\n where c2i c = if c == '0' then 0 else 1\nshowBin x = showIntAtBase 2 intToDigit x \"\"\nmain = do\n getLine\n line <- getLine\n let ans = sum (zipWith (\\x y -> if x == y then 0 else 1) line (take (length line) (reverse (showBin ((readBin (reverse line)) + 1)))))\n print ans\n \n"}, {"source_code": "import Data.List\nimport Data.Function\nimport Data.Char\nimport Data.Maybe\nimport qualified Data.ByteString.Lazy.Char8 as B\n\nmain = interact $ show . getAns . last . words\n\ngetAns :: String -> Int\ngetAns xs = min (length xs) (((+1) . (\\xs@(x:_) -> if x == '1' then length xs else 0) . head . group) xs)\n"}, {"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad hiding ((<$!>))\nimport Control.Monad.ST.Safe\nimport Control.Monad.State hiding ((<$!>))\n-- import Data.Array\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IntSet\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map.Strict (Map)\nimport qualified Data.Map.Strict as Map\nimport Data.HashMap.Strict (HashMap)\nimport qualified Data.HashMap.Strict as HashMap\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\n-- import Debug.Trace\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n getLine\n bs <- getLine\n\n let\n bs' = map (== '1') bs\n bs'' = add bs' True\n where\n add [] _ = []\n add (b:bs) f = (if b then not f else f):(add bs $ b && f)\n\n\n print $ length $ filter id $ zipWith (/=) bs' bs''\n"}, {"source_code": "-- Codeforces 465A\n\nmain :: IO ()\nmain = do\n n <- fmap read getLine :: IO Int\n getLine >>= print . solve \n\nsolve :: String -> Int\nsolve xs = length $ filter (\\i -> (xs!!i) /= (ys!!i)) [0..(length xs)-1] where\n ys = fst $ foldl (\\(acc, carry) b ->\n case (carry, b) of\n ('1', '1') -> (acc++['0'], '1')\n ('1', '0') -> (acc++['1'], '0')\n ('0', '1') -> (acc++['1'], '0')\n ('0', '0') -> (acc++['0'], '0'))\n ([], '1') xs\n"}, {"source_code": "import Control.Monad\n\nmain :: IO ()\nmain = do\n n <- fmap read getLine\n l <- liftM (length.takeWhile (=='1')) getLine\n print$min n (l+1)\n"}, {"source_code": "module Main where\n\nimport Control.Monad\n\nmain :: IO ()\nmain =\n do n <- readLn\n l <- replicateM n $ getChar\n print $ (\\x -> if x == length l then x else x + 1) $ length $ takeWhile (== '1') l\n return ()\n"}, {"source_code": "main :: IO ()\nmain = getContents >>= print . solve . lines\n\nsolve :: [String] -> Int\nsolve [_, cs] = min (length cs) (length (takeWhile (=='1') cs) + 1)\nsolve _ = undefined\n"}, {"source_code": "main = getContents >>= print . solve . lines\nsolve [n, cs] = min (read n) (length (takeWhile (=='1') cs) + 1)\n"}, {"source_code": "main = do\n sz <- fmap read getLine\n count <- (getLine >>= return . length . takeWhile (== '1'))\n print $ min sz (count + 1)"}, {"source_code": "solve :: [Char] -> Int\nsolve x =\n\tif res == length x then res\n\telse res + 1\n\twhere \n\t\tres = solve_ x\n\t\tsolve_ [] = 0\n\t\tsolve_ (x:xs) = if x == '1' then 1 + (solve_ xs) else 0\n\nmain = interact $ show.solve.head.tail.lines\n"}], "negative_code": [], "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab"} {"source_code": "\n{-\nimport HUnit\n\ntestInput :: Test\ntestInput = TestList \"TestInput\"\n [\n Test \"1\" $ assertEq 4 (solve 7 2),\n Test \"2\" $ assertEq 54 (solve 59 9)\n ]\n\ntestMaximum :: Test\ntestMaximum = TestList \"TestMaximum\"\n [\n Test \"1\" $ assertEq 500000008 (solve (10^9) 2),\n Test \"2\" $ assertEq 1 (solve 1 2),\n Test \"3\" $ assertEq 888888894 (solve (10^9) 9)\n ]\n\ntest :: IO ()\ntest = mapM_ run\n [\n testInput,\n testMaximum\n ]\n\n--------------------------------------------------------------------------------\n\n-}\n\nv :: Int -> Int -> Int\nv 0 k = 0\nv n k = n + v (div n k) k\n\nsolve :: Int -> Int -> Int\nsolve n k = solve' 1 n\n where\n solve' l r\n | l + 1 >= r = r\n | v m k >= n = solve' l m\n | otherwise = solve' m r\n where\n m = div (l+r) 2\n\nmain :: IO ()\nmain = do\n line <- getLine\n let [n, k] = map read $ words line\n print $ solve n k\n", "positive_code": [{"source_code": "import Control.Applicative\n\nsolve n k = search 1 n\n\twhere\n\t\tsearch l r \n\t\t\t| l >= r = l\n\t\t\t| s >= n = search l m\n\t\t\t| s < n = search (m + 1) r\n\t\t\twhere\n\t\t\t\tm = (l + r) `div` 2\n\t\t\t\ts = sum $ takeWhile (/= 0) $ iterate (`div` k) m\n\nmain = do\n\t[n, k] <- map read . words <$> getLine\n\tprint $ solve n k\n"}, {"source_code": "import Debug.Trace\n\nwrite k v = write' 1 v\n where\n write' q v | v < q = 0\n write' q v = v `div` q + write' (k * q) v \n\nbinsearch b e f | b >= e = b\nbinsearch b e f = \n let\n p = (b + e) `div` 2\n in\n if f p < 0 \n then\n binsearch (p + 1) e f\n else\n binsearch b p f\n \nmain = do\n words <- getLine >>= return.words\n let (n, k) = (read(words !! 0)::Integer, read(words!!1)::Integer)\n let r = binsearch 1 n (\\v -> write k v - n) \n if write k r < n then print (r + 1) else print r"}, {"source_code": "\n\nbinarySearch :: (Integral a) => (a -> Bool) -> a -> a -> a\nbinarySearch p l h\n | h < l = h+1\n | p m = binarySearch p l (m-1)\n | otherwise = binarySearch p (m+1) h\n where m = (l + h) `div` 2\n\nseries v k = sum $ takeWhile (>0) $ map (floor.(v/).(k^)) [0..] \n\npredicate :: Int -> Int -> Int -> Bool\npredicate n k v\n | s < n = False\n | otherwise = True\n where s = series (realToFrac v) (realToFrac k)\n\ncode :: Int -> Int -> Int\ncode n k = binarySearch (predicate n k) 1 (10^9)\n\nmain :: IO()\nmain = do\n input <- getContents\n let (n:k:_) = map read (words input) :: [Int]\n putStr $ show $ code n k"}, {"source_code": "{-# OPTIONS_GHC -O3 -fno-spec-constr-count #-}\nimport Control.Monad\nimport Control.Applicative\nimport Debug.Trace\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.Char as C\n\natoi :: B.ByteString -> Int\natoi = B.foldl' (\\a c -> a*10 + C.ord c - C.ord '0') 0\n\nbisearch :: (Int -> Bool) -> Int -> Int -> Int\nbisearch p lo hi\n | lo+1 == hi = hi\n | p mid = bisearch p lo mid\n | otherwise = bisearch p mid hi\n where mid = (lo + hi) `div` 2\n\nsolve :: Int -> Int -> Int\nsolve n k = bisearch ((>=n) . sumline k) 0 n\n\nsumline :: Int -> Int -> Int\nsumline k = sum . takeWhile (> 0) . iterate (flip div k)\n\nmain = do\n [n, k] <- map atoi . B.words <$> B.getLine\n putStrLn . show $ solve n k\n"}, {"source_code": "main = do getLine >>= print . gao . map read . words\ngao [n, k] = f 0 (n * k) where\n g m = sum $ takeWhile (>0) $ iterate (`div` k) m\n f l r\n | l == r = r\n | otherwise = let m = div (l + r) 2 in if g m < n then f (m + 1) r else f l m\n"}, {"source_code": "module Main where\n\nimport Data.Maybe\nimport Data.Array\nimport Data.List\nimport Data.Char\n\nimport Data.Time.Calendar\n\nmain = interact (show . solve . map read . words)\n\nsolve :: [Int] -> Int\nsolve [n, k] = maxV (-1) n n k\n\nmaxV :: Int -> Int -> Int -> Int -> Int\nmaxV leftV rightV n k\n | leftV == rightV - 1 = rightV\n | otherwise = let middleV = (leftV + rightV) `div` 2 in\n if solution middleV k >= n\n then maxV leftV middleV n k\n else maxV middleV rightV n k\n\nsolution :: Int -> Int -> Int\nsolution = solution' 0\nsolution' result 0 _ = result\nsolution' result v k = solution' (result + v) (v `div` k) k\n"}, {"source_code": "import System.IO\n\nmain = print . solve =<< parse stdin\n\nparse h = fmap (f . map read . words) getLine\n where f [x,y] = (x,y)\n\nsolve :: (Int, Int) -> Int\nsolve (n,k) = solve' init\n where\n init = (0, 10^9)\n solve' (a, b)\n | a + 1 >= b = b\n | cnt >= n = solve' (a, c)\n | otherwise = solve' (c, b)\n where\n c = (a + b) `div` 2\n cnt = count c\n count 0 = 0\n count v = v + count (v `div` k)\n\n-- vim: set expandtab:\n"}, {"source_code": "import Control.Monad\nimport Data.List\nbinSearch n k lo hi =\n if lo + 1 == hi then hi\n else let mid = div (lo + hi) 2\n val = sum $ unfoldr (\\x -> if x == 0 then Nothing else Just (x, div x k)) mid\n in if val >= n then binSearch n k lo mid\n else binSearch n k mid hi\nmain = do\n [n, k] <- (liftM $ (map read) . words) getLine\n putStrLn . show $ binSearch n k 0 n\n"}, {"source_code": "solve n k = search 1 n\n\twhere\n\t\tsearch l r \n\t\t\t| l >= r = l\n\t\t\t| s >= n = search l m\n\t\t\t| s < n = search (m + 1) r\n\t\t\twhere\n\t\t\t\tm = (l + r) `div` 2\n\t\t\t\ts = sum $ takeWhile (/= 0) $ iterate (`div` k) m\n\nmain = do\n\t[n, k] <- (map read . words) `fmap` getLine\n\tprint $ solve n k\n"}, {"source_code": "main = getLine >>= putStrLn . show . func . map read . words \n\nfunc :: [Integer] -> Integer\nfunc [n, k] = fst . head $ takeWhile (flip (<=) (n+20) . snd ) testlist\n\t\twhere \t\n\t\t\t\tans v = v + test[v,k,1]\n\t\t\t\ttestlist = [ (v,ans v) | v <- [(n - n`div`k)..n], ans v >= n]\ntest [v,k,s] \n\t\t| acc > 0 = acc + test [v,k,s+1]\n\t\t| acc == 0 = 0\n\t\twhere acc = v `div` k^s"}, {"source_code": "\nsolve :: Int -> Int -> Int\nsolve n k = solve' n k (0, n)\n where\n solve' :: Int -> Int -> (Int, Int) -> Int\n solve' n k (l, r)\n | l + 1 == r = r\n | f m k >= n = solve' n k (l, m)\n | otherwise = solve' n k (m, r)\n where\n m = div (l+r) 2\n\nf :: Int -> Int -> Int\nf 0 _ = 0\nf v k = v + f (div v k) k\n\nmain :: IO ()\nmain = do\n line <- getLine\n let [n, k] = map read (words line)\n print $ solve n k\n "}, {"source_code": "{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport Data.Array.IArray\nimport Data.Array.Unboxed (UArray)\nimport Data.Int\nimport Data.Ratio\nimport Data.Bits\nimport Data.Function\nimport Data.Ord\n--import Control.Monad.State\nimport Control.Monad\nimport Control.Applicative\nimport Data.ByteString.Char8 (ByteString)\nimport qualified Data.ByteString.Char8 as BS\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\nimport Data.Sequence (Seq, (<|), (|>), (><), ViewL(..), ViewR(..))\nimport qualified Data.Sequence as Seq\nimport qualified Data.Foldable as F\nimport Data.Graph\n\nparseInput = do \n n <- readInteger\n k <- readInteger\n return (n, k)\n where\n readInt = state $ fromJust . BS.readInt . BS.dropWhile isSpace\n readInteger = state $ fromJust . BS.readInteger . BS.dropWhile isSpace\n readString = state $ BS.span (not . isSpace) . BS.dropWhile isSpace\n readLine = state $ BS.span (not . isEoln) . BS.dropWhile isEoln\n isEoln ch = ch == '\\r' || ch == '\\n'\n\nmain = print =<< solve . evalState parseInput <$> BS.getContents\n\nbinarySearch :: (Integer -> Bool) -> Integer -> Integer\nbinarySearch test falseValue = head [ loop falseValue (falseValue + 2 ^ i)\n | i <- [0..]\n , test (falseValue + 2 ^ i)\n ]\n where\n -- test lo == False, test hi = True\n loop lo hi\n | lo + 1 == hi = hi\n | test mid = loop lo mid\n | otherwise = loop mid hi\n where\n mid = (lo + hi) `div` 2\n\nsolve (n, k) = binarySearch test 0\n where\n test c = getSum c >= n\n getSum 0 = 0\n getSum a = a + getSum (a `div` k)\n \n \n\n----------------------------------------------------------------------\n----------------------------------------------------------------------\n----------------------------------------------------------------------\n\nclass (Monad m) => MonadState s m | m -> s where\n\tget :: m s\n\tput :: s -> m ()\n\nmodify :: (MonadState s m) => (s -> s) -> m ()\nmodify f = do\n\ts <- get\n\tput (f s)\n\ngets :: (MonadState s m) => (s -> a) -> m a\ngets f = do\n\ts <- get\n\treturn (f s)\n\nnewtype State s a = State { runState :: s -> (a, s) }\n\ninstance Functor (State s) where\n\tfmap f m = State $ \\s -> let\n\t\t(a, s') = runState m s\n\t\tin (f a, s')\n\ninstance Applicative (State s) where\n pure = return\n (<*>) = ap\n\ninstance Monad (State s) where\n\treturn a = State $ \\s -> (a, s)\n\tm >>= k = State $ \\s -> let\n\t\t(a, s') = runState m s\n\t\tin runState (k a) s'\n\ninstance MonadState s (State s) where\n\tget = State $ \\s -> (s, s)\n\tput s = State $ \\_ -> ((), s)\n\nevalState :: State s a -> s -> a\nevalState m s = fst (runState m s)\n\nexecState :: State s a -> s -> s\nexecState m s = snd (runState m s)\n\nmapState :: ((a, s) -> (b, s)) -> State s a -> State s b\nmapState f m = State $ f . runState m\n\nwithState :: (s -> s) -> State s a -> State s a\nwithState f m = State $ runState m . f\n\nstate = State\n"}, {"source_code": "main = do\n [n,k] <- fmap (map read . words) getLine\n print $ solve n k 0 (n*k)\nsolve n k a b | a >= b - 1 = b\n | try k c >= n = solve n k a c\n | otherwise = solve n k c b\n where c = (a + b + 1) `div` 2\ntry k v = sum . map (v `div`) . takeWhile (<= v) $ iterate (*k) 1"}, {"source_code": "main = interact $ show.solve.map read.words\nsolve [n,k] = let p v = (>=n) . sum . takeWhile (>0) . map (div v) $ iterate (k*) 1\n in bsearch p 0 (n+1)\n\nbsearch p l m\n | l >= m = l\n | p ((l+m)`div`2) = bsearch p l ((l+m)`div`2)\n | otherwise = bsearch p ((l+m)`div`2+1) m"}, {"source_code": "import Control.Applicative\nimport Control.Monad\n\nbs' :: Int -> Int -> (Int, Int) -> Int\nbs' n k (lower, upper)\n | lower == upper = lower\n | (calc' mid k) < n = bs' n k (mid+1, upper)\n | otherwise = bs' n k (lower, mid)\n where mid = (lower + upper) `div` 2\n\ncalc' v k\n | v == 0 = 0\n | otherwise = v + (calc' (v `div` k) k)\n\nreadInt = read <$> getLine :: IO Int\nreadInts = map read . words <$> getLine :: IO [Int]\n\nmain = do\n [n, k] <- readInts\n\n putStr (show (bs' n k (1, 10^9)))\n"}], "negative_code": [{"source_code": "main = getLine >>= putStrLn . show .func .map read. words \n\nfunc :: [Int] -> Int\nfunc [n, k] = head $ [ v | v<-[1..n] , ans v >= n]\n where ans v = v + test[v,k]\n\ntest [v,k] \n | acc >0 = acc + test [v,k*k]\n | acc == 0 = 0\n where acc = v `div` k"}, {"source_code": "write k v = write' 1 v\n where\n write' q v | v < q = 0\n write' q v = v `div` q + write' (k * q) v \n\nbinsearch b e f | b >= e = b\nbinsearch b e f = \n let\n p = (b + e) `div` 2\n in\n if f p < 0 \n then\n binsearch (p + 1) e f\n else\n binsearch b (p - 1) f\n \nmain = do\n words <- getLine >>= return.words\n let (n, k) = (read(words !! 0)::Int, read(words!!1)::Int)\n let r = binsearch 1 n (\\v -> write k v - n) \n if write k r < n then print (r + 1) else print r"}], "src_uid": "41dfc86d341082dd96e089ac5433dc04"} {"source_code": "\nflrDiv :: Integral a => a -> a -> a\nflrDiv a b = div (a+b-1) b\n\nreadInts :: String -> [Int]\nreadInts str = map read (words str)\n\nmain :: IO ()\nmain = do\n \n as <- fmap readInts getLine\n bs <- fmap readInts getLine\n n <- fmap read getLine :: IO Int\n let b = (flrDiv (sum as) 5) + (flrDiv (sum bs) 10) <= n\n putStr $ if b then \"YES\" else \"NO\" \n\n\n", "positive_code": [{"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE TypeFamilies #-}\n{-# LANGUAGE ViewPatterns #-}\n{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Control.Arrow\nimport Control.Monad\nimport Data.Array.IO\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as C\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Functor\nimport Data.Int\nimport qualified Data.IntMap as M\nimport Data.IORef\nimport Data.List\nimport Data.Maybe\nimport Data.Monoid\nimport qualified Data.Sequence as Seq\nimport qualified Data.Set as S\nimport Data.Word\nimport Debug.Trace\nimport Text.Printf\n\n-- I/O\n\nreadInts :: C.ByteString -> [Int]\nreadInts = map fst . mapMaybe C.readInt . C.words\n\ngetInts :: IO [Int]\ngetInts = readInts <$> C.getLine\n\nreadNums :: Num a => C.ByteString -> [a]\nreadNums = map (fromIntegral . fst) . mapMaybe C.readInteger . C.words\n\ngetNums :: Num a => IO [a]\ngetNums = readNums <$> C.getLine\n\ncast :: (Integral a, Integral b) => a -> b\ncast = fromIntegral\n\n-----\n\nmain :: IO ()\nmain = do\n as <- getInts\n bs <- getInts\n n <- readLn\n\n putStrLn $ if (sum as + 4) `div` 5 + (sum bs + 9) `div` 10 <= n then \"YES\" else \"NO\"\n"}, {"source_code": "import Control.Applicative\n\nparse = map read . words\n\nmain = do\n cs <- parse <$> getLine\n ms <- parse <$> getLine\n n <- read <$> getLine\n let c = sum cs\n m = sum ms\n n1 = (n*5 - c) `div` 5\n n2 = (n1*10-m) `div` 10\n putStrLn $\n if n2 >= 0 then \"YES\" else \"NO\""}, {"source_code": "import Control.Applicative\n\nmain = do\n cups <- sum . map read . words <$> getLine\n medals <- sum . map read . words <$> getLine\n n <- readLn\n\n let cs = (cups + 4) `div` 5\n ms = (medals + 9) `div` 10\n s = cs + ms\n in putStrLn $ if s <= n then \"YES\" else \"NO\"\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\nprocess n q1 q2 | sq1+sq2 <= n= \"YES\"\n | otherwise = \"NO\"\n where sq1= (div ((sum q1)-1) 5)+1\n sq2= (div ((sum q2)-1) 10)+1\n\n\nmain = do\n q1<- map read <$> words <$> getLine ::IO [Int]\n q2<- map read <$> words <$> getLine ::IO [Int]\n n<- read <$> getLine ::IO Int\n putStrLn $ process n q1 q2\n"}, {"source_code": "main :: IO ()\nmain = getContents >>= putStrLn . yesno . solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> Bool\nsolve [as, bs, [n]] = sum as // 5 + sum bs // 10 <= n\n\n(//) :: Integral a => a -> a -> a\nx // y = (x + y - 1) `div` y\n\nyesno :: Bool -> String\nyesno True = \"YES\"\nyesno _ = \"NO\"\n"}, {"source_code": "main = do\n cs <- fmap (sum . map read . words) getLine\n ms <- fmap (sum . map read . words) getLine\n s <- readLn\n putStrLn $ if (cs + 4) `div` 5 + (ms + 9) `div` 10 > s then \"NO\" else \"YES\"\n"}, {"source_code": "main :: IO ()\nmain = do\n sa <- getLine \n sb <- getLine\n sn <- getLine\n let suma = sum . map read $ words sa\n sumb = sum . map read $ words sb\n tot = ceiling ((/) suma 5) + ceiling ((/) sumb 10)\n n = read sn\n res = if tot <= n then \"YES\" else \"NO\"\n putStrLn res\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}\n{-# LANGUAGE BangPatterns, TupleSections, OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Exception\nimport Control.Monad\nimport Control.Monad.ST\nimport Data.Array.Base\nimport Data.Array.ST (runSTUArray, STArray)\nimport Data.Bits\nimport qualified Data.ByteString.Char8 as B\nimport Data.Char\nimport Data.Function\nimport Data.Int\nimport Data.List\nimport qualified Data.Map as M\nimport qualified Data.Set as S\nimport Data.STRef\nimport GHC.Arr (Array, Ix, unsafeIndex)\nbool :: a -> a -> Bool -> a\nbool t f b=if b then t else f\nreadInt :: B.ByteString -> Int\nreadInt bs=case B.readInt bs of{Just(n,_)->n;_->error$\"readInt error : bs = \"++show bs;}\nrep, rev :: Monad m => Int -> (Int -> m ()) -> m ()\nrep !n f=go 0 where go !i=when(i>go(i+1)\nrev !n f=go(n-1)where go !i=when(i>=0)$f i>>go(i-1)\n{-# INLINE rep #-}\n{-# INLINE rev #-}\nfor :: Monad m => Int -> (Int -> Bool) -> (Int -> Int) -> (Int -> m ()) -> m ()\nfor !i0 p next f=go i0 where go !i=when(p i)$f i>>go(next i)\n{-# INLINE for #-} \nmodifyArray :: (MArray a e m, Ix i) => a i e -> i -> (e -> e) -> m ()\nmodifyArray a i f=readArray a i>>=writeArray a i.f\n{-# INLINE modifyArray #-}\nunsafeModify :: (MArray a e m, Ix i) => a i e -> Int -> (e -> e) -> m ()\nunsafeModify a i f=unsafeRead a i>>=unsafeWrite a i.f\n{-# INLINE unsafeModify #-}\n\nmain :: IO ()\nmain = do\n x <- sum.map readInt.B.words <$> B.getLine\n y <- sum.map readInt.B.words <$> B.getLine\n n <- readLn\n putStrLn.bool\"YES\"\"NO\" $ solve n x y\n\nsolve :: Int -> Int -> Int -> Bool\nsolve n x y = (x+4)`div`5 + (y+9)`div`10 <= n"}, {"source_code": "import Control.Applicative\nmain = do\n\ta <- (`div` 5) . (+4) . sum . map read . words <$> getLine\n\tb <- (`div` 10) . (+9) . sum . map read . words <$> getLine\n\tn <- read <$> getLine\n\tputStrLn $ if a + b > n then \"NO\" else \"YES\"\n"}, {"source_code": "import Control.Applicative\nmain = do\n\ta <- ceiling . (/5) . sum . map read . words <$> getLine\n\tb <- ceiling . (/10) . sum . map read . words <$> getLine\n\tn <- read <$> getLine\n\tputStrLn $ if a + b > n then \"NO\" else \"YES\"\n"}, {"source_code": "import Control.Applicative\n \ncalc a b = div (sum a) b +(if mod (sum a) b>0 then 1 else 0)\n\nmain=do\n\ta<-map read.words <$> getLine::IO [Int]\n\tb<-map read.words <$> getLine::IO [Int] \n\tc<- read <$> getLine::IO Int\n\tputStrLn $ if c>= (calc a 5+ calc b 10) then \"YES\" else \"NO\""}, {"source_code": "import Control.Monad\nimport Data.List\n\nmain = replicateM 3 getLine\n >>= putStrLn . solve . map sum\n where sum = foldl1 (+) . map read .words\n\nsolve :: [Float] -> String\nsolve [a, b, n] = if ceiling(a / 5.0) + ceiling(b / 10.0) <= ceiling(n) then \"YES\" else \"NO\""}, {"source_code": "main :: IO ()\nmain = interact solve \n\nsolve :: String -> String\nsolve s \n | (a `divUp` 5) + (b `divUp` 10) <= n = \"YES\"\n | otherwise = \"NO\"\n where [a, b, n] = (fmap (sum . fmap read . words) . lines) s :: [Int]\n\ndivUp :: (Integral a) => a -> a -> a\ndivUp a b = (a + b - 1) `div` b\n"}, {"source_code": "module Main where\n\nmain = do\n\tline1 <- getLine\n\tline2 <- getLine\n\tline3 <- getLine\n\tlet a = readIntList line1 \n\tlet b = readIntList line2\n\tlet n = read line3 :: Int\n\n\tputStr $ result a b n\n\n\nresult a b n = sayYesNo $ ((ceiling' a' 5.0) + (ceiling' b' 10.0)) <= n \n\twhere\n\t\tsayYesNo bool = if bool then \"YES\" else \"NO\"\n\t\tceiling' s alpha = ceiling (toRational s / alpha)\n\t\ta' = sum a\n\t\tb' = sum b\n\nreadIntList :: String -> [Int]\nreadIntList = map read . words\n"}, {"source_code": "parseInput :: String -> ([Int], [Int], Int)\nparseInput input = (xs, ys, n) where\n ls = lines input\n xs = map read $ words $ head ls\n ys = map read $ words $ head $ tail ls\n n = read $ last ls\n\nsolve xs ys n | m <= n = \"YES\"\n | otherwise = \"NO\"\n where x = sum xs\n y = sum ys\n m = (x + 4) `div` 5 + (y + 9) `div` 10\n\nmain :: IO ()\nmain = do\n input <- getContents\n let (xs, ys, n) = parseInput input\n putStrLn $ solve xs ys n\n"}, {"source_code": "module Main (main)\n where\n\nimport Control.Monad (replicateM)\n\n\nreadInts :: String -> [Int]\nreadInts = map read . words\n\nmain :: IO ()\nmain = putStrLn . toYesNo . solve . map readInts =<< replicateM 3 getLine\n where solve [as,bs,[n]] = n >= shelves (sum as) 5 + shelves (sum bs) 10\n shelves c m = let (q,r) = divMod c m in q + min 1 r\n toYesNo True = \"YES\"\n toYesNo False = \"NO\""}, {"source_code": "\nmain = do\n\tas<-getLine\n\tbs<-getLine\n\tn<-getLine\n\tlet [a1,a2,a3] =map read $ words as\n\tlet [b1,b2,b3]= map read $ words bs\n\tputStrLn $ solve a1 a2 a3 b1 b2 b3 (read n)\n\nsolve a1 a2 a3 b1 b2 b3 n = if div (a-1) 5 + div (b-1) 10 +2 <=n then \"YES\" else \"NO\"\n\t where a=a1+a2+a3 \n\t b=b1+b2+b3"}, {"source_code": "main :: IO()\nmain = putStrLn . solve . map read . words =<< getContents\n\nsolve :: [Int] -> String\nsolve [a1, a2, a3, b1, b2, b3, n] = let a = a1 + a2 + a3\n b = b1 + b2 + b3\n na = div (a + 4) 5\n nb = div (b + 9) 10\n in if na + nb <= n then \"YES\" else \"NO\"\n"}, {"source_code": "import Data.List\nimport Data.Function\nimport Data.Char\n\nmain = interact $ getAns . map (map read . words) . lines\n\ngetAns :: [[Int]] -> String\ngetAns (ax:bx:(n:_):_)\n\t| s > n = \"NO\"\n\t| otherwise = \"YES\"\n\twhere s = di 5 ax + di 10 bx\n\t di a = ceiling . (/ a) . fromIntegral . sum\n"}, {"source_code": "import Data.List\nimport Data.Function\nimport Data.Char\n\nmain = interact $ getAns . map read . words\n\ngetAns :: [Int] -> String\ngetAns (a1:a2:a3:b1:b2:b3:n:_) \n\t| s > n = \"NO\"\n\t| otherwise = \"YES\"\n\twhere s = ceiling (fromIntegral (a1 + a2 + a3) / 5) + ceiling (fromIntegral (b1 + b2 + b3) / 10)\n"}, {"source_code": "import Data.List\nimport Data.Function\nimport Data.Char\n\nmain = interact $ getAns . map read . words\n\ngetAns :: [Int] -> String\ngetAns (a1:a2:a3:b1:b2:b3:n:_) \n\t| s > n = \"NO\"\n\t| otherwise = \"YES\"\n\twhere s = di 5 (a1 + a2 + a3) + di 10 (b1 + b2 + b3)\n\t di a = ceiling . (/ a) . fromIntegral\n"}, {"source_code": "import Data.List\nimport Data.Function\nimport Data.Char\n\nmain = interact $ getAns . map read . words\n\ngetAns :: [Int] -> String\ngetAns (a1:a2:a3:b1:b2:b3:n:_) \n\t| s > n = \"NO\"\n\t| otherwise = \"YES\"\n\twhere ta = a1 + a2 + a3\n\t tb = b1 + b2 + b3\n\t sa = ta `div` 5 + if ta `mod` 5 == 0 then 0 else 1\n\t sb = tb `div` 10 + if tb `mod` 10 == 0 then 0 else 1\n\t s = sa + sb\n"}, {"source_code": "main = do\n [a1, a2, a3] <- fmap (map read . words) getLine\n [b1, b2, b3] <- fmap (map read . words) getLine\n n <- readLn\n\n putStrLn $ if (a1+a2+a3 + 4) `div` 5 + (b1+b2+b3+9) `div` 10 > n then \"NO\" else \"YES\"\n"}, {"source_code": "main = do\n aux1 <- getLine\n let cups = sum (map read $ words aux1 :: [Int])\n aux2 <- getLine\n let medals = sum (map read $ words aux2 :: [Int])\n aux3 <- getLine\n let shelfs = read aux3\n let neededForCups = if (mod cups 5 == 0) then (div cups 5) else ((div cups 5) + 1)\n let neededForMedals = if (mod medals 10 == 0) then (div medals 10) else ((div medals 10) + 1)\n let ans = if (neededForCups + neededForMedals <= shelfs) then \"YES\" else \"NO\"\n\n putStrLn ans\n"}, {"source_code": "{-# OPTIONS_GHC -O2 #-}\n{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}\nimport Data.Maybe\nimport Control.Applicative\nimport qualified Data.ByteString.Char8 as BS\n\n\ngetint :: IO Int\ngetint = head <$> getints\n\ngetints :: IO [Int]\ngetints = map fst . mapMaybe BS.readInt . BS.words <$> BS.getLine\n\nmain = do\n as <- getints\n bs <- getints\n n <- getint\n let sumA = sum as\n needA = sumA `div` 5 + (if sumA `mod` 5 == 0 then 0 else 1)\n sumB = sum bs\n needB = sumB `div` 10 + (if sumB `mod` 10 == 0 then 0 else 1)\n if needA + needB > n then putStrLn \"NO\" else putStrLn \"YES\""}, {"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = solve =<< forM [1..3] (\\i-> sum.map (fst.fromJust.C.readInt).C.words<$>C.getLine)\n--solve::Int->IO()\nsolve [x,y,z] = let s = (+) (ceiling (fromIntegral x / 5)) (ceiling (fromIntegral y / 10)) in putStr $ if s>z then \"NO\" else \"YES\""}], "negative_code": [{"source_code": "\nmain = do\n\tas<-getLine\n\tbs<-getLine\n\tn<-getLine\n\tlet [a1,a2,a3] =map read $ words as\n\tlet [b1,b2,b3]= map read $ words bs\n\tputStrLn $ solve a1 a2 a3 b1 b2 b3 (read n)\n\nsolve 0 0 0 0 0 0 _ = \"YES\"\nsolve a1 a2 a3 b1 b2 b3 n = if div (a-1) 5 + div (b-1) 10 +2 <=n then \"YES\" else \"NO\"\n\t where a=if a1+a2+a3 >0 then a1+a2+a3 else 1\n\t b=if b1+b2+b3 >0 then b1+b2+b3 else 1"}, {"source_code": "\nmain = do\n\tas<-getLine\n\tbs<-getLine\n\tn<-getLine\n\tlet [a1,a2,a3] =map read $ words as\n\tlet [b1,b2,b3]= map read $ words bs\n\tputStrLn $ solve a1 a2 a3 b1 b2 b3 (read n)\n\nsolve a1 a2 a3 b1 b2 b3 n = if div (a-1) 5 + div (b-1) 10 +2 <=n then \"YES\" else \"NO\"\n\t where a=if a1+a2+a3 >0 then a1+a2+a3 else 1\n\t b=if b1+b2+b3 >0 then b1+b2+b3 else 1"}, {"source_code": "{-# OPTIONS_GHC -O2 #-}\n{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}\nimport Data.Maybe\nimport Control.Applicative\nimport qualified Data.ByteString.Char8 as BS\n\n\ngetint :: IO Int\ngetint = head <$> getints\n\ngetints :: IO [Int]\ngetints = map fst . mapMaybe BS.readInt . BS.words <$> BS.getLine\n\nmain = do\n as <- getints\n bs <- getints\n n <- getint\n let sumA = sum as\n needA = sumA `div` 5 + (if sumA `mod` 5 == 0 then 0 else 1)\n sumB = sum bs\n needB = sumB `div` 10 + (if sumA `mod` 10 == 0 then 0 else 1)\n if needA + needB > n then putStrLn \"NO\" else putStrLn \"YES\""}, {"source_code": "main :: IO ()\nmain = do\n sa <- getLine \n sb <- getLine\n sn <- getLine\n let suma = sum . map read $ words sa\n sumb = sum . map read $ words sb\n tot = ceiling ((/) suma 5) + ceiling ((/) sumb 10)\n n = read sn\n res = if tot <= n then \"Yes\" else \"No\"\n putStrLn res\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}\n{-# LANGUAGE BangPatterns, TupleSections, OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Exception\nimport Control.Monad\nimport Control.Monad.ST\nimport Data.Array.Base\nimport Data.Array.ST (runSTUArray, STArray)\nimport Data.Bits\nimport qualified Data.ByteString.Char8 as B\nimport Data.Char\nimport Data.Function\nimport Data.Int\nimport Data.List\nimport qualified Data.Map as M\nimport qualified Data.Set as S\nimport Data.STRef\nimport GHC.Arr (Array, Ix, unsafeIndex)\nbool :: a -> a -> Bool -> a\nbool t f b=if b then t else f\nreadInt :: B.ByteString -> Int\nreadInt bs=case B.readInt bs of{Just(n,_)->n;_->error$\"readInt error : bs = \"++show bs;}\nrep, rev :: Monad m => Int -> (Int -> m ()) -> m ()\nrep !n f=go 0 where go !i=when(i>go(i+1)\nrev !n f=go(n-1)where go !i=when(i>=0)$f i>>go(i-1)\n{-# INLINE rep #-}\n{-# INLINE rev #-}\nfor :: Monad m => Int -> (Int -> Bool) -> (Int -> Int) -> (Int -> m ()) -> m ()\nfor !i0 p next f=go i0 where go !i=when(p i)$f i>>go(next i)\n{-# INLINE for #-} \nmodifyArray :: (MArray a e m, Ix i) => a i e -> i -> (e -> e) -> m ()\nmodifyArray a i f=readArray a i>>=writeArray a i.f\n{-# INLINE modifyArray #-}\nunsafeModify :: (MArray a e m, Ix i) => a i e -> Int -> (e -> e) -> m ()\nunsafeModify a i f=unsafeRead a i>>=unsafeWrite a i.f\n{-# INLINE unsafeModify #-}\n\nmain :: IO ()\nmain = do\n x <- sum.map readInt.B.words <$> B.getLine\n y <- sum.map readInt.B.words <$> B.getLine\n n <- readLn\n putStrLn.bool\"YES\"\"NO\" $ solve n x y\n\nsolve :: Int -> Int -> Int -> Bool\nsolve n x y = (x+4)`div`5 + (x+9)`div`10 <= n"}, {"source_code": "import Control.Applicative\n \ncalc a = div (sum a) 5 +(if mod (sum a) 5>0 then 1 else 0)\n\nmain=do\n\ta<-map read.words <$> getLine::IO [Int]\n\tb<-map read.words <$> getLine::IO [Int] \n\tc<- read <$> getLine::IO Int\n\tputStrLn $ if c>= calc a + calc b then \"YES\" else \"NO\""}, {"source_code": "module Main where\n\n\n\nmain = do\n\tline1 <- getLine\n\tline2 <- getLine\n\tline3 <- getLine\n\tlet a = readIntList line1 \n\tlet b = readIntList line2\n\tlet n = read line3 :: Int\n\n\tputStr $ result a b n\n\n\nresult a b n = sayYesNo $ ((ceiling' a' 10.0) + (ceiling' b' 10.0)) <= n \n\twhere\n\t\tsayYesNo bool = if bool then \"YES\" else \"NO\"\n\t\tceiling' s alpha = ceiling (toRational s / alpha)\n\t\ta' = sum a\n\t\tb' = sum b\n\nreadIntList :: String -> [Int]\nreadIntList = map read . words\n"}], "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e"} {"source_code": "import qualified Data.ByteString.Char8 as B\nimport Data.Maybe\nimport Data.Array as Arr\nimport qualified Data.Map as Map\nimport Data.Map (Map)\nimport qualified Data.Set as Set\nimport Data.Set (Set)\nimport Data.List\nimport Control.Applicative\nimport Control.Monad\nimport Data.Function\n\nz c l = let l' = takeWhile (/= c) l in if any (/='.') l' then 100 else length l'\n\ns cs = minimum (map (z 'W') cs) <= minimum (map (z 'B' . reverse) cs)\n\np True = \"A\\n\"\np False = \"B\\n\"\n\nmain = interact $ p . s . transpose . lines\n", "positive_code": [{"source_code": "import Control.Applicative\nimport Data.List\n \n\nmyfind x n [] = 100\nmyfind x n (s:ss) | s==x = n+1\n | s=='.'= myfind x (n+1) ss\n | otherwise =100\n\n\nmain= do\n\ts<- transpose. lines <$> getContents::IO [String]\n\tlet w= minimum $ map (myfind 'W' 0) s\n\tlet b= minimum $ map (myfind 'B' 0) (map reverse s)\n\tputStrLn $ if w<=b then \"A\" else \"B\"\n\t\n\n\t \n"}, {"source_code": "import Control.Monad\n\ngetMoves :: [Char] -> Char -> Int\ngetMoves [] _ = 8\ngetMoves column c\n | head column == c = 8 - length column\n | head column == '.' = getMoves (tail column) c\n | otherwise = 8\n\nmain = do\n rows <- forM [0..7] (\\a -> getLine)\n\n let columns = [[row !! i | row <- rows] | i <- [0..7]]\n bestWhite = minimum [getMoves (columns !! i) 'W' | i <- [0..7]]\n bestBlack = minimum [getMoves (reverse (columns !! i)) 'B' | i <- [0..7]]\n \n if bestWhite <= bestBlack\n then putStrLn(\"A\")\n else putStrLn(\"B\")\n"}], "negative_code": [{"source_code": "import Control.Applicative\nimport Data.List\n \n\nmyfind x (s:ss) n = if elem x s then n else myfind x ss (n+1)\n\n\nmain= do\n\ts<- lines <$> getContents::IO [String]\n\tlet w= (myfind 'W' s 1)-1\n\tlet b= 8 - (myfind 'B' s 1)\n\tputStrLn $ if w getContents::IO [String]\n\tlet w= (myfind 'W' s 1)-1\n\tlet b= (myfind 'B' (reverse s) 1)-1\n\tputStrLn $ if w>= return.read\n s <- getLine\n putStr $ solve k s\n\nsolve :: Int -> String -> String\nsolve k s = if k' < k then \"NO\" else \"YES\\r\\n\"\n ++(unlines\n $ (take (k-1) parts)++[concat $ drop (k-1) parts])\n where\n parts = so s []\n k' = length parts\n\nso :: String -> [Char] -> [String]\nso [] _ = []\nso (x:xs) l = (x:cur):(so (drop (length cur) xs) l')\n where\n l' = x:l\n cur = takeWhile (`elem` l') xs\n", "positive_code": [{"source_code": "import Control.Applicative\nimport qualified Data.Set as Set\n\ngetLines :: Int -> IO [String]\ngetLines 0 = return []\ngetLines n = do\n\tx <- getLine\n\txs <- getLines (n-1)\n\treturn (x:xs)\n\nfindBeautiful :: Set.Set Char -> Int -> String -> Maybe [String]\nfindBeautiful _ _ [] = Nothing\nfindBeautiful set 1 (x:xs) = Just ([x:xs])\nfindBeautiful set k (x:xs) = Just ((x:prefix):) <*> findBeautiful (Set.insert x set) (k-1) remainder\n\twhere\n\t\t(prefix, remainder) = span (\\item -> item == x || item `Set.member` set) xs\n\nmain = do\n\tlns <- getLines 2\n\t\n\tlet\n\t\tk = read $ lns !! 0 :: Int\n\t\tq = lns !! 1\n\t\tresult = findBeautiful Set.empty k q\n\n\tcase result of\n\t\tNothing -> putStrLn \"NO\"\n\t\tJust xs -> mapM_ putStrLn $ \"YES\":xs"}, {"source_code": "import Data.List (intercalate)\nanswer::Int->String->[String]\nanswer k q = trimData q $ takeOrNot k $ getTrueNumber $ getNotPrev $ q\ngetNotPrev::String -> [Bool]\ngetNotPrev q = map (\\x -> not (elem (fst x) (snd x))) $ zip q $ map (\\k -> take k q) [0..((length q)-1)] \ngetTrueNumber::[Bool] -> [Int]\ngetTrueNumber b = map snd $ filter fst $ zip b [0..]\ntakeOrNot ::Int -> [Int]-> [Int]\ntakeOrNot k a | (length a) < k = []\n | otherwise = take k a \ntrimData::String -> [Int] -> [String]\ntrimData q n | null n = []\n | (length n) == 1 = [q]\n | otherwise = [a]++trimData b nt\n where nh0 = head n\n nt = tail n\n nh1 = head nt\n (a,b) = splitAt (nh1-nh0) q\n \n \nprintAnswer::[String] -> IO ()\nprintAnswer a = do\n if (null a)\n then putStrLn \"NO\"\n else do\n putStrLn \"YES\"\n putStrLn $ intercalate \"\\n\" a\nmain = do\n w <- getLine\n let k = read w::Int\n q <- getLine\n printAnswer $ answer k q\n --print $ getNotPrev q\n"}, {"source_code": "import Control.Monad\n\nmain = do\n input <- getLine\n let n = read input\n s <- getLine\n let ans = f s \"\"\n mapM_ putStrLn (yesOrNo n ans)\n\nf :: String -> String -> [String]\nf [] _ = []\nf (x:xs) used = \n let xused = (x:used)\n in (x : takeWhile (`elem` xused) xs) : (f (dropWhile (`elem` xused) xs) xused)\n\nyesOrNo :: Int -> [String] -> [String]\nyesOrNo _ [] = []\nyesOrNo n xs =\n if n-1 < length xs then\n \"YES\" : listToPrint n xs\n else\n [\"NO\"]\n\nlistToPrint :: Int -> [String] -> [String]\nlistToPrint n xs = (take (n-1) xs) ++ [rmsp $ unwords $ drop (n-1) xs]\n\nrmsp :: String -> String\nrmsp [] = \"\"\nrmsp (x:xs) =\n if x == ' ' then rmsp xs\n else x : rmsp xs\n"}, {"source_code": "import Control.Applicative ((<$>))\nimport Control.Monad (replicateM, liftM, join, mapM_)\n\nbreak' :: String -> [String] -> [String]\nbreak' [] acc = acc\nbreak' (h:rest) acc\n | any ((== h).last) acc = break' rest $ (h:head acc):tail acc\n | otherwise = break' rest $ [h]:acc\n\nout :: [String] -> Int -> [String]\nout tok k | length tok < k = [\"NO\"]\nout tok k = \"YES\":init ++ [rest]\n where init = take (k - 1) tok\n rest = join $ drop (k - 1) tok\n\nmain = do\n let parse = reverse.(map reverse).(flip break' [])\n\n k <- read <$> getLine\n tok <- parse <$> getLine\n mapM_ putStrLn $ out tok k\n"}, {"source_code": "\nimport Data.List(nub, elemIndex, group)\nimport Data.Maybe(fromJust)\n\nanswer s n = n <= length (nub s)\n\nsplitNAux :: String -> Int -> String -> [String] \nsplitNAux s n [] = [s]\nsplitNAux s 0 _ = [\"\"]\nsplitNAux s 1 _ = [s] \nsplitNAux s n (x:xs) = a : splitNAux b (n - 1) xs\n where pos = fromJust (elemIndex x s)\n (a, b) = splitAt pos s\n\nsplitN s n = splitNAux s n (tail lst)\n where lst = nub s\n\nmain = interact $ unlines . callAnswer . lines\n where callAnswer (ns:ss:_) =\n let n = read ns\n in\n if answer ss n then\n \"YES\":splitN ss n\n else\n [\"NO\"]\n"}, {"source_code": "import Data.List\n\nsolve :: Int -> String -> Maybe [String]\nsolve n q = solveHelper [last q] n q\n where\n solveHelper :: [Char] -> Int -> String -> Maybe [String]\n solveHelper used n \"\" = Nothing\n solveHelper used 1 q = Just [q]\n solveHelper used n (q:qs)\n | q `elem` used = do\n (f:rest) <- solveHelper used n qs\n return ((q:f):rest)\n\n | otherwise = do\n rest <- solveHelper (q:used) (n-1) qs\n return ([q]:rest)\n\nprintAnswer :: Maybe [String] -> IO ()\nprintAnswer Nothing = putStrLn \"NO\"\nprintAnswer (Just xs) = do\n putStrLn \"YES\"\n putStrLn $ reverse $ intercalate \"\\n\" xs\n\nmain = do\n n <- getLine\n q <- getLine\n printAnswer $ solve (read n :: Int) (reverse q)\n"}, {"source_code": "import Control.Monad\n\n-- doit s n seen current = a way to do it with n left (including current)\ndoit :: String -> Integer -> [Char] -> String -> Maybe [String]\ndoit [] 1 _ [] = Nothing\ndoit str 1 seen current = Just [current ++ str]\ndoit [] _ _ _ = Nothing\ndoit (c:cs) n seen current\n | c `elem` seen = doit cs n seen (current ++ [c])\n | otherwise = do\n tmp <- doit cs (n-1) (c:seen) [c]\n return (current:tmp)\n\nmain = do\n n <- readLn\n str <- getLine\n putStr $ case doit (tail str) n [head str] [head str] of\n Nothing -> \"NO\\n\"\n Just ans -> unlines (\"YES\":ans)"}, {"source_code": "import Control.Applicative\nimport Data.List\n \ndel x (y:ys) | x==y = ys\n | otherwise = y: (del x ys)\n\n\nmyprocess s _ 0 (x:xs) = reverse ((x++s): xs)\nmyprocess s s1 n x= myprocess (dropWhile (\\z-> notElem z s2) (tail s)) s2 (n-1) (((head s):(takeWhile (\\z-> notElem z s2) (tail s))):x)\n\t\twhere s2 = del (head s ) s1\t\n\t\t\t\n\n \n\n\nmain= do\n\tn<- read <$> getLine ::IO Int\n\ts<- getLine \n\tlet s1 = map head $ group $ sort s\n\tputStrLn $ if length s1=n then myprocess s s1 n [] else []\n\t\n\t "}], "negative_code": [{"source_code": "import Control.Applicative\n\ngetLines :: Int -> IO [String]\ngetLines 0 = return []\ngetLines n = do\n\tx <- getLine\n\txs <- getLines (n-1)\n\treturn (x:xs)\n\nfindBeautiful :: Int -> String -> Maybe [String]\nfindBeautiful _ [] = Nothing\nfindBeautiful 1 (x:xs) = Just ([x:xs])\nfindBeautiful k (x:xs) = Just ((x:prefix):) <*> findBeautiful (k-1) remainder\n\twhere (prefix, remainder) = span (== x) xs\n\nmain = do\n\tlns <- getLines 2\n\t\n\tlet\n\t\tk = read $ lns !! 0 :: Int\n\t\tq = lns !! 1\n\t\tresult = findBeautiful k q\n\n\tcase result of\n\t\tNothing -> putStrLn \"NO\"\n\t\tJust xs -> mapM_ putStrLn $ \"YES\":xs"}, {"source_code": "\nimport Data.List(nub, elemIndex, group)\nimport Data.Maybe(fromJust)\n\nanswer s n = n <= length (nub s)\n\nsplitNAux :: String -> Int -> String -> [String] \nsplitNAux s n [] = []\nsplitNAux s 0 _ = [s]\nsplitNAux s 1 _ = [s] \nsplitNAux s n (x:xs) = a : splitNAux b (n - 1) xs\n where pos = fromJust (elemIndex x s)\n (a, b) = splitAt pos s\n\nsplitN s n = splitNAux s n (tail lst)\n where lst = concatMap nub (group s)\n\nmain = interact $ unlines . callAnswer . lines\n where callAnswer (ns:ss:_) =\n let n = read ns\n in\n if answer ss n then\n \"YES\":splitN ss n\n else\n [\"NO\"]\n"}, {"source_code": "\nimport Data.List(nub, elemIndex)\nimport Data.Maybe(fromJust)\n\nanswer s n = n <= (length $ nub s)\n\nsplitNAux :: String -> Int -> String -> [String] \nsplitNAux s n [] = []\nsplitNAux s 0 _ = [s]\nsplitNAux s 1 _ = [s] \nsplitNAux s n (x:xs) = a : (splitNAux b (n - 1) xs)\n where pos = fromJust (elemIndex x s)\n (a, b) = splitAt pos s\n\nsplitN s n = splitNAux s n (tail $ nub s) \n\nmain = interact $ unlines . callAnswer . lines\n where callAnswer (ns:ss:_) =\n let n = read ns\n in\n if answer ss n then\n \"YES\":splitN ss n\n else\n [\"NO\"]\n"}, {"source_code": "import Data.List\n\nsolve :: Int -> String -> Maybe [String]\nsolve = solveHelper []\n where\n solveHelper :: [Char] -> Int -> String -> Maybe [String]\n solveHelper used n \"\" = Nothing\n solveHelper used 1 q = Just [q]\n solveHelper used n (q:qs)\n | q `elem` used = do\n (f:rest) <- solveHelper used n qs\n Just ((q:f):rest)\n\n | otherwise = do\n rest <- solveHelper (q:used) (n-1) qs\n Just ([q]:rest)\n\nprintAnswer :: Maybe [String] -> IO ()\nprintAnswer Nothing = putStrLn \"NO\"\nprintAnswer (Just xs) = do\n putStrLn \"YES\"\n putStrLn $ reverse $ intercalate \"\\n\" xs\n\nmain = do\n n <- getLine\n q <- getLine\n printAnswer $ solve (read n :: Int) (reverse q)\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \ndel x (y:ys) | x==y = ys\n | otherwise = y: (del x ys)\n\n\nmyprocess s _ 0 (x:xs) = reverse ((x++s): xs)\nmyprocess s s1 n x= myprocess (dropWhile (\\z-> notElem z s2) (tail s)) s1 (n-1) (((head s):(takeWhile (\\z-> notElem z s2) (tail s))):x)\n\t\twhere s2 = del (head s ) s1\t\n\t\t\t\n\n \n\n\nmain= do\n\tn<- read <$> getLine ::IO Int\n\ts<- getLine \n\tlet s1 = map head $ group $ sort s\n\tputStrLn $ if length s1=n then myprocess s s1 n [] else []\n\t\n\t "}, {"source_code": "import Control.Applicative\nimport Data.List\n \n \nmyprocess s _ 0 (x:xs) = reverse ((x++s): xs)\nmyprocess s s1 n x= myprocess (dropWhile (\\z-> notElem z s1) (tail s)) s1 (n-1) (((head s):(takeWhile (\\z-> notElem z s1) (tail s))):x)\n\t\t\t\n\t\t\t\n\n \n\n\nmain= do\n\tn<- read <$> getLine ::IO Int\n\ts<- getLine \n\tlet s1 = map head $ group $ sort s\n\tputStrLn $ if length s1=n then myprocess s (take n s1) n [] else []\n\t\n\t "}], "src_uid": "c1b071f09ef375f19031ce99d10e90ab"} {"source_code": "import Data.Functor ((<$>))\nimport Data.List (inits, tails)\nimport Data.Maybe (fromMaybe, listToMaybe)\n\nmain :: IO ()\nmain = putStrLn =<< fromMaybe \"NA\" . solve <$> getLine\n\nsolve :: String -> Maybe String\nsolve xs = listToMaybe [ as ++ [b] ++ cs | (as, cs) <- zip (inits xs) (tails xs), b <- ['a'..'z'], isPalindrome $ as ++ [b] ++ cs ]\n\nisPalindrome :: Eq a => [a] -> Bool\nisPalindrome xs = xs == reverse xs\n", "positive_code": [{"source_code": "main = interact $ a . filter h . concat . f . lines\nf [x] = map (g [] x) ['a'..'z']\ng l [] c = [l ++ [c]]\ng l s@(x:xs) c = (l ++ c:s):(g (l ++ [x]) xs c)\nh s = s == (reverse s)\na [] = \"NA\"\na x = head x\n"}, {"source_code": "import Data.Functor ((<$>))\nimport Data.List (inits, tails)\nimport Data.Maybe (fromMaybe, listToMaybe)\n\nmain :: IO ()\nmain = putStrLn =<< fromMaybe \"NA\" . solve <$> getLine\n\nsolve :: String -> Maybe String\nsolve xs = listToMaybe [ as ++ [b] ++ cs | (as, cs) <- zip (inits xs) (tails xs), b <- ['a'..'z'], isPalindrome $ as ++ [b] ++ cs ]\n\nisPalindrome :: Eq a => [a] -> Bool\nisPalindrome xs = all (uncurry (==)) $ zip xs (reverse xs)\n"}, {"source_code": "main = do\n str <- getLine\n case mkPalindrome str of\n Just str' -> putStrLn str'\n Nothing -> putStrLn \"NA\"\n\nmkPalindrome :: String -> Maybe String\nmkPalindrome str = if isPalindrome s1\n then Just s1\n else if isPalindrome s2\n then Just s2\n else Nothing\n where\n len = length str\n front = take (len `div` 2) str\n back = drop (len `div` 2) str\n ((s1f, s1b), (s2f, s2b)) = insertCharIfNec front (reverse back)\n s1 = s1f ++ reverse s1b\n s2 = s2f ++ reverse s2b\n\ninsertCharIfNec :: String -> String -> ((String, String), (String, String))\ninsertCharIfNec (a:as) (b:bs)\n | a == b = let ((s1f, s1b), (s2f, s2b)) = insertCharIfNec as bs\n in ((a:s1f, b:s1b), (a:s2f, b:s2b))\n | otherwise = ((b:a:as, b:bs),\n (a:as, a:b:bs))\ninsertCharIfNec \"\" \"\" = ((\"\", \"y\"), (\"\", \"y\"))\ninsertCharIfNec \"\" s = ((s, s), (s, s))\n\nisPalindrome :: String -> Bool\nisPalindrome str = go front back\n where\n len = length str\n front = take (len `div` 2) str\n back = take (len `div` 2) (reverse str)\n go (a:as) (b:bs) | a == b = go as bs\n | otherwise = False\n go [] [] = True\n"}, {"source_code": "main = getLine >>= putStrLn . solve\nsolve [] = \"a\"\nsolve [x] = [x, x]\nsolve (x:xs) | (x == last xs) && (st /= \"NA\") = x : st ++ [last xs]\n | (x == last xs) && (st == \"NA\") = \"NA\"\n | isPalindrome v1 = v1\n | isPalindrome v2 = v2\n | otherwise = \"NA\"\n where st = solve $ init xs\n v1 = x:xs++[x]\n v2 = last xs : x : xs\n isPalindrome s = s == reverse s\n"}, {"source_code": "import Control.Applicative\nimport System.IO\n\ninserts :: a -> [a] -> [[a]]\ninserts x [] = [[x]]\ninserts x l@(y:ys) = (x:l) : ((fmap (y:)) $ inserts x ys)\n\nisPalin :: Eq a => [a] -> Bool\nisPalin s = reverse s == s\n\nmain :: IO()\nmain = do\n s <- getLine\n case filter isPalin $ concat $ fmap ($ s) $ fmap inserts ['a'..'z'] of\n [] -> putStrLn \"NA\"\n (x:xs) -> putStrLn x\n"}, {"source_code": "#!/usr/bin/env runghc\nimport Data.Maybe\nmain = getContents >>= mapM_ putStrLn . solve . lines\nsolve = map f\nf::String->String\nf s\n | null a = \"NA\"\n | otherwise = fromJust . head $ a\n where\n a = dropWhile isNothing . map g $ [0..n]\n n = length s\n g::Int->Maybe String\n g i\n | n-i>i = p $ t ++ ((s!!(n-i-1)) : d)\n | n-iMaybe String\np s = if s==reverse s then Just s else Nothing\n"}, {"source_code": "import Data.List\nimport Data.Function\nimport Data.Char\nimport Data.Maybe\nimport qualified Data.ByteString.Lazy.Char8 as B\n\nmain = interact $ sol . head . lines\n\nisPar s = reverse s == s\n\ngetNS s p c = p1 ++ [c] ++ p2\n\twhere (p1, p2) = splitAt p s\n\nsol x =\tmaybe \"NA\" id $ find isPar [getNS x p c | p <- [0 .. length x], c <- ['a' .. 'z']]\n\n"}, {"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Monad.State\nimport Data.Array.IArray\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport Data.Array.IO.Safe\nimport Data.Char\nimport Data.Function\n-- import Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.Maybe\nimport Data.Set (Set)\nimport qualified Data.Set as Set\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\nimport qualified Data.ByteString.Char8 as B\n-- import Debug.Trace\n\n-- getInts = fmap (map read . words) getLine\n-- getInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n s <- getLine\n\n let\n check s = and $ zipWith (==) s (reverse s)\n ss = [s | i <- [0..length s], let (s1, s2) = splitAt i s, c <- ['a'..'z'], let s = s1 ++ [c] ++ s2, check s]\n\n putStrLn $ if null ss then \"NA\" else head ss\n"}, {"source_code": "import Control.Applicative\n\nmain = getLine >>= putStrLn . solve\n\nsolve :: String -> String\nsolve s = head . (++ [\"NA\"]) . filter ((==) <*> reverse) $ rs\n where rs = [take i s ++ [c] ++ drop i s | i <- [0..length s], c <- ['a'..'z']]\n"}, {"source_code": "import Control.Monad\nimport Control.Applicative\nimport Data.Monoid\nimport qualified Data.Map as M\nimport qualified Data.IntMap as I\n\n\nmain :: IO ()\nmain = getLine >>= putStrLn . toOutput . solve\n\ntoOutput :: Maybe String -> String\ntoOutput = maybe \"NA\" id\n\nsolve :: String -> Maybe String\nsolve s = getFirst $ mconcat $ map (toPal s) [0..length s]\n\ntoPal :: String -> Int -> First String\ntoPal s i = First ans\n where\n ans = if isPal newString\n then (Just newString)\n else Nothing\n newString = take i s ++ [c'] ++ drop i s\n c' = if i == length newString `div` 2\n then 'a'\n else newString !! (length newString - 1-i)\n\nisPal s = s == reverse s\n"}, {"source_code": "main = interact $ a . filter h . concat . f . concat . lines\nf x = map (g [] x) ['a'..'z']\ng l [] c = [l ++ [c]]\ng l s@(x:xs) c = (l ++ c:s):(g (l ++ [x]) xs c)\nh s = s == (reverse s)\na [] = \"NA\"\na x = head x\n"}], "negative_code": [{"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Monad.State\nimport Data.Array.IArray\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport Data.Array.IO.Safe\nimport Data.Char\nimport Data.Function\n-- import Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.Maybe\nimport Data.Set (Set)\nimport qualified Data.Set as Set\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\nimport qualified Data.ByteString.Char8 as B\n-- import Debug.Trace\n\n-- getInts = fmap (map read . words) getLine\n-- getInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n s <- getLine\n\n let\n check s = and $ zipWith (==) s (reverse s)\n ss = [s | i <- [0..length s], let (s1, s2) = splitAt i s, c <- ['a'..'z'], let s = s1 ++ [c] ++ s2, check s]\n\n print ss\n putStrLn $ if null ss then \"NA\" else head ss\n"}, {"source_code": "main = interact $ a . filter h . concat . f\nf x = map (g [] x) ['a'..'z']\ng l [] c = [l ++ [c]]\ng l s@(x:xs) c = (l ++ c:s):(g (l ++ [x]) xs c)\nh s = s == (reverse s)\na [] = \"NA\"\na x = head x\n"}], "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b"} {"source_code": "\nmodule Main where\nimport Data.List\nimport Control.Applicative\n\nf (u,d,l,r) [] = u==d && l==r\nf (u,d,l,r) (a:as) \n | a == 'U' = f (u+1, d, l, r) as\n | a == 'D' = f (u, d+1, l, r) as\n | a == 'L' = f (u, d, l+1, r) as\n | a == 'R' = f (u, d, l, r+1) as\n\nmain = do\n getLine\n print =<< length . filter (f (0,0,0,0)) . concat . map (init. tails ) . tail . inits <$> getLine\n ", "positive_code": [{"source_code": "module Main where\n\nimport Data.List\n\nmove :: (Int, Int) -> Char -> (Int, Int)\nmove (x, y) 'U' = (x, y - 1)\nmove (x, y) 'D' = (x, y + 1)\nmove (x, y) 'L' = (x - 1, y)\nmove (x, y) 'R' = (x + 1, y)\n\nidentity :: [Char] -> Bool\nidentity moves = (foldl move (0, 0) moves) == (0, 0)\n\nsolve :: String -> Int\nsolve moves = length . filter id $ [identity ps | s <- ss, ps <- tail (inits s)]\n where ss = init $ tails moves\n\nmain :: IO ()\nmain = do\n _ <- getLine\n s <- getLine\n print $ solve s\n"}, {"source_code": "import Data.List\nimport Data.List.Split\n\nsolve s = length [(i, j) | i <- [0..(n-1)], j <- [i..(n-1)], f i j]\n where n = length s\n val 'U' = (1, 0)\n val 'D' = (-1, 0)\n val 'L' = (0, 1)\n val 'R' = (0, -1)\n tsum (a, b) (c, d) = (a+c, b+d)\n subsum i j = foldl tsum (0, 0) $ map val $ take (j-i+1) $ drop i s\n f i j = (subsum i j) == (0, 0)\n\nmain = do\n str1 <- getLine\n str2 <- getLine\n putStrLn $ show $ solve str2\n"}, {"source_code": "import Data.Char\n\nallSubstrings :: String -> [String]\nallSubstrings s = concat $ map allPrefixes $ allSuffixes s \n\nallSuffixes :: String -> [String]\nallSuffixes [] = []\nallSuffixes s = let x : xs = s in s : allSuffixes xs\n\nallPrefixes :: String -> [String]\nallPrefixes s = map reverse $ allSuffixes $ reverse $ s\n\nconcat' :: [[a]] -> [a]\nconcat' [] = []\nconcat' (x:xs) = x ++ (concat' xs)\n\ncharShift :: Char -> (Int,Int)\ncharShift 'U' = (1, 0)\ncharShift 'R' = (0, 1)\ncharShift 'D' = (-1, 0)\ncharShift 'L' = (0, -1)\n\nstrShift :: String -> (Int,Int)\nstrShift [] = (0,0)\nstrShift (x:xs) =\n let (x1,y1) = charShift x\n (x2,y2) = strShift xs\n in (x1 + x2, y1 + y2)\n\ncount :: String -> Int\ncount s = foldl (\\answer subStr -> answer + (if strShift subStr == (0,0) then 1 else 0)) 0 $ allSubstrings s \n \nmain = do\n contents <- getContents\n let contentsWords = words contents\n let [_,source] = contentsWords\n print $ count source"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE TupleSections #-}\n\nmodule Main where\nimport qualified Data.Map as Map\nimport Data.Monoid\n\nmove ::Num a=>Char -> (a, a)\nmove 'D' = ( 0,-1)\nmove 'U' = ( 0, 1)\nmove 'L' = (-1, 0)\nmove 'R' = ( 1, 0)\nmove _ = ( 0, 0)\n\nsolution::forall a.Integral a=>String->a\nsolution = combine where\n psum (a,b) = (Sum a, Sum b)\n unsum (Sum a, Sum b) = (a, b)\n start = psum ((0, 0)::(a,a))\n points = map ((,1) .unsum) . scanl (<>) start . map (psum . move)\n comb2 a = a * (a - 1) `div` 2::a\n combine = sum . map comb2 . Map.elems . Map.fromListWith (+) . points\n\n\nmain:: IO ()\nmain = getLine >> getLine >>= print . (solution::String->Integer)\n"}, {"source_code": "import Prelude\nimport Control.Monad\nimport Data.List\nimport qualified Data.Map as M\nimport qualified Data.Array as A\nimport Data.Functor\n\nupdate :: (Int,Int) -> Char -> (Int,Int)\nupdate (a,b) c \n | c == 'U' = (a+1,b)\n | c == 'D' = (a-1,b)\n | c == 'L' = (a,b-1)\n | c == 'R' = (a,b+1)\n\nmain :: IO ()\nmain = do\n n <- readLn :: IO Int\n str <- getLine \n let things = scanl update (0,0) str\n m_things = M.fromListWith (+) [(t,1) | t <- things]\n m_oper = M.map (\\n -> div (n*(n-1)) 2) m_things\n ans = M.fold (+) 0 m_oper :: Int\n print ans\n return ()\n"}, {"source_code": "import Data.List (group, sort)\n\nmain :: IO ()\nmain = print . solve . parse . lines =<< getContents\n\ntype Input = String\n\nparse :: [String] -> Input\nparse [_, s] = s\nparse _ = undefined\n\ndelta :: Char -> (Int, Int)\ndelta 'U' = (0, 1)\ndelta 'R' = (1, 0)\ndelta 'D' = (0, -1)\ndelta 'L' = (-1, 0)\ndelta _ = undefined\n\nsolve :: Input -> Int\nsolve = sum . map count . group . sort . scanl step (0, 0)\n where step (x, y) c = let (x', y') = delta c in (x + x', y + y')\n count a = let n = length a in n * (n - 1) `div` 2\n"}], "negative_code": [], "src_uid": "7bd5521531950e2de9a7b0904353184d"} {"source_code": "import Data.Maybe\nimport Data.Int\nimport Data.Foldable\nimport qualified Data.ByteString.Char8 as C\nimport Data.Array.Base\nimport Data.Array.IO\n\nparseInt :: C.ByteString -> Int\nparseInt = fst . fromJust . C.readInt\n\nkMod :: Int\nkMod = 998244353\n\ntoInt64 :: Int -> Int64\ntoInt64 = fromIntegral\n\nfromInt64 :: Int64 -> Int\nfromInt64 = fromIntegral\n\nnewtype Mint = Mint { mint :: Int }\n deriving (Eq, Ord)\ninstance Num Mint where\n (Mint a) + (Mint b) = Mint (let c = a + b in if c >= kMod then c - kMod else c)\n (Mint a) - (Mint b) = Mint a + Mint (kMod - b)\n (Mint a) * (Mint b) = Mint $ fromInt64 $ (toInt64 a * toInt64 b) `mod` (toInt64 kMod)\n fromInteger n = Mint (fromIntegral $ n `mod` fromIntegral kMod)\ninstance Show Mint where show = show . mint\n\nmain :: IO ()\nmain = do\n n <- fmap parseInt C.getLine\n prime <- newArray_ (0, n) :: IO (IOUArray Int Int)\n tau <- newArray_ (0, n) :: IO (IOUArray Int Int)\n unsafeWrite tau 1 1\n forM_ [2..n] $ \\i -> do\n p <- unsafeRead prime i\n if p /= 0\n then do\n t1 <- unsafeRead tau p\n let f y = if y `mod` p == 0 then let (a, b) = f (y `div` p) in (a, b + 1) else (y, 0)\n (x, c) = f i\n t2 <- unsafeRead tau x\n unsafeWrite tau i ((c + 1) * t2)\n return ()\n else do\n unsafeWrite tau i 2\n forM_ [2 * i, 3 * i .. n] $ \\j -> do\n unsafeWrite prime j i\n let func :: Int -> IO (Mint, Mint)\n func 1 = return (1, 0)\n func x = do\n (f', t') <- func (x - 1)\n t <- fmap (Mint . (subtract 1)) $ unsafeRead tau x\n return $ (2 * f' - t' + t, t)\n result <- fmap fst $ func n\n putStrLn $ show result\n", "positive_code": [{"source_code": "-- dp(n) = 2^(n- 1) + D(n) + D(n - 1) + 2 * D(D - 2) + 4 * D(n - 3) + 8 * D(n - 4) + ... + 2^(n-2)D(1) - 2^(n-1)\n\n-- dp(3) = 2 + 2 + 2 * 1\n-- dp(2) = 2 + 1\n-- dp(1) = \n--\n--\nimport Data.Int (Int64)\nimport qualified Data.Array as A\n\nmain = do \n n <- read <$> getLine\n print $ solve n\n\nm = 998244353\nsolve :: Int -> Int\nsolve n = foldl1 (\\x y -> let t = x + y in if t < m then t else t - m) (map calc [1..n])\n where calc k = mul (if x >= 0 then x else x + m) (minv (mpow A.! k - 1) m) + d\n where d = if n `rem` k == 0 then 1 else 0\n x = mpow A.! (n - 1) - mpow A.! ((n - 1) `rem` k)\n\nmpow = A.listArray (0,1000000) l\n where l = 1:map (\\x -> let t = 2 * x in if t < m then t else t - m) l\n\nminv :: Int -> Int -> Int\nminv 1 _ = 1\nminv a b = b + fromIntegral (quot (1 - t * fromIntegral b) (fromIntegral a))\n where t = fromIntegral (minv (b `rem` a) a) :: Int64\n\nmul :: Int -> Int -> Int\nmul a b = fromIntegral (x * y `rem` fromIntegral m)\n where x = fromIntegral a :: Int64\n y = fromIntegral b :: Int64\n \n"}, {"source_code": "{-# LANGUAGE FlexibleContexts #-}\r\nimport qualified Data.ByteString.Char8 as BS\r\nimport Control.Monad\r\nimport Control.Monad.ST\r\nimport Data.Array.Base\r\nimport Data.Array.ST\r\nimport Data.Array.Unboxed\r\nimport Data.Bifunctor\r\nimport Data.Bits\r\nimport Data.Bool\r\nimport Data.Char\r\nimport Data.Int\r\nimport Data.List\r\nimport Data.Maybe\r\nimport Data.Ord\r\nimport Data.Ratio\r\nimport Data.Tuple\r\nimport qualified Data.Set as Set\r\nimport qualified Data.Sequence as Seq\r\nimport Data.STRef.Strict\r\nimport System.IO\r\nimport System.IO.Unsafe\r\n\r\n\r\n(><) a b = a Seq.>< b\r\n\r\ndeb name s e = seq s unsafePerformIO $! do\r\n hPutStrLn stderr $ \" \" ++ name ++ \" = \" ++ show s\r\n return e\r\n\r\nparseInt = fst . fromJust . BS.readInt\r\nparseInteger = fst . fromJust . BS.readInteger\r\n\r\nmodifyArray f a i = readArray a i >>= \\v -> writeArray a i (f v)\r\n\r\nmd :: Int64\r\nmd = 998244353\r\n\r\nnewtype MInt = MInt Int64 deriving Eq\r\n\r\ninstance Show MInt where\r\n show (MInt a) = show a\r\n\r\ninstance Num MInt where\r\n (MInt a) + (MInt b) =\r\n let r = a + b in\r\n MInt $ if r >= md then r - md else r\r\n (MInt a) * (MInt b) = MInt $ (a * b) `mod` md\r\n abs = id\r\n signum (MInt a) = MInt $ signum a\r\n fromInteger a = MInt $ fromInteger (a `mod` fromIntegral md)\r\n negate (MInt 0) = 0\r\n negate (MInt a) = MInt $ md - a\r\n\r\ninstance Fractional MInt where\r\n recip a = a ^ (md - 2)\r\n fromRational x =\r\n let a = numerator x `mod` fromIntegral md\r\n b = denominator x `mod` fromIntegral md\r\n in\r\n MInt (fromInteger a) / MInt (fromInteger b)\r\n\r\nsolve :: Int -> MInt\r\nsolve n =\r\n let ds = [t | i <- [1..n], t <- [i,i+i..n]]\r\n da = accumArray (\\t _ -> t + 1) 0 (1,n) (zip ds (repeat ())) :: UArray Int Int\r\n d = map fromIntegral $ elems da\r\n in\r\n fst $ foldl' (\\(_, s) t -> (s + t, s + s + t)) (0,0) d\r\n\r\nmain = do\r\n n <- parseInt <$> BS.getLine\r\n print $ solve n\r\n"}, {"source_code": "import qualified Data.ByteString.Lazy.Char8 as P\nimport qualified Data.ByteString.Builder as B\nimport System.IO\n\nimport Control.Monad\nimport Control.Monad.Trans.State\nimport Control.Monad.Trans.Class\nimport Data.List\nimport Data.Semigroup\n\nimport Data.Array.Unboxed\n\np :: Int\np = 998244353\n\ndata LoopVal = LoopVal !Int !Int\n\nstep :: LoopVal -> Int -> LoopVal\nstep (LoopVal _ai psum) currFactors = let\n nai = rem (currFactors - 1 + psum) p\n npsum = rem (nai + psum) p\n in LoopVal nai npsum\n\nmain :: IO ()\nmain = (P.getContents >>=) . evalStateT $ do\n [n] <- readInts\n let\n factors :: UArray Int Int\n factors = accumArray (\\ct _ -> ct + 1) 0 (1, n)\n $ [(j, ()) | i <- [1 .. n], j <- [i, 2*i .. n]]\n LoopVal ans _ = foldl' step (LoopVal 1 1) $ elems factors\n --putInts $ elems factors\n putInts [ans]\n\ntype SIO = StateT P.ByteString IO\n\nreadLine :: SIO P.ByteString\nreadLine = do\n (out, next) <- P.break (<= '\\r') <$> get\n put $ P.dropWhile (<= '\\r') next\n pure out\n\nreadInts :: SIO [Int]\nreadInts = do\n currLine <- readLine\n pure [x | Just (x, _) <- P.readInt <$> P.words currLine]\n\nputInts :: [Int] -> SIO ()\nputInts li = let\n outBuilder = foldr (<>) (B.char7 '\\n')\n $ intersperse (B.char7 ' ') (map B.intDec li)\n in lift $ B.hPutBuilder stdout outBuilder\n"}], "negative_code": [], "src_uid": "09be46206a151c237dc9912df7e0f057"} {"source_code": "{-# LANGUAGE BlockArguments #-}\n\nimport Control.Arrow\n\nmain = do { x <- getLine; y <- getLine; putStrLn $ solve x (words y) }\n\ncanPlay :: String -> String -> String\ncanPlay x y | x!!0 == y!!0 || x!!1 == y!!1 = \"YES\"\n | x!!0 /= y!!0 && x!!1 /= y!!1 = \"NO\"\n\ncanPlayAgg :: String -> String -> String -> String\ncanPlayAgg a b \"YES\" = \"YES\"\ncanPlayAgg a b \"NO\" = canPlay a b\n\n\nsolve :: String -> [String] -> String\nsolve a b = foldr (canPlayAgg a) \"NO\" b", "positive_code": [{"source_code": "import Control.Monad\n\ncardsForPlayer = 5\ncardsForStartGame = cardsForPlayer + 1\n\ngetSuit = [\"D\", \"C\", \"S\", \"H\"]\ngetRank = [\"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\n\ngetAllPairs :: [String] -> [String] -> [String]\ngetAllPairs xs zs = liftM2 (++) xs zs\n\npickCards :: [Int] -> [String] -> [String]\npickCards pick cards = aggregateCards pick cards []\n where aggregateCards [] _ res = res\n aggregateCards (x:xs) cards res =\n let card = cards!!x\n cardsWithoutPicked = (take x cards) ++ (drop (x+1) cards)\n in aggregateCards xs cardsWithoutPicked (card:res)\n\nmakeGameState :: [String] -> (String, [String])\nmakeGameState (x:xs) = (x, xs)\n\nrandomCards = [3, 5, 6, 12, 15, 40]\n\nsolve :: (String, [String]) -> String\nsolve (tableCard, (x:xs))\n | head tableCard == head x || last tableCard == last x = \"YES\"\n | xs == [] = \"NO\"\n | otherwise = solve (tableCard, xs)\n\ngetList :: IO [String]\ngetList = do\n line <- getLine\n return $ words line\n\nmain :: IO ()\nmain = do\n cardOnTable <- getLine\n playerCards <- getList\n putStrLn $ solve (cardOnTable, playerCards)\n"}, {"source_code": "import Data.List\nmain = interact $ solve . lines\nsolve [t,h] | not (null (intersect t (concat (words h)))) = \"YES\"\n | otherwise = \"NO\"\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\nimport qualified Data.Set as S\n\n\n\nmain = do\n\t \t\n\tn1<- S.fromList <$> getLine \n\tn2<- S.fromList <$> getLine \n\tputStrLn $ if S.disjoint n1 n2 then \"NO\" else \"YES\"\n"}, {"source_code": "--ghc 7.10\n\nisCompatible :: String -> String -> Bool\nisCompatible (suit1:rank1:_) (suit2:rank2:_) = (suit1 == suit2) || (rank1 == rank2)\nisCompatible _ _ = False\n\nisPlay :: String -> [String] -> Bool\nisPlay tCard hCards = any (isCompatible tCard) hCards\n\noutput = [\"NO\",\"YES\"]\n\nmain = do\n tCard <- getLine\n line <- getLine\n let hCards = words line\n putStrLn $ output !! (fromEnum $ isPlay tCard hCards)"}, {"source_code": "solve t cs | xs /= [] || ys /= [] = \"YES\"\n | otherwise = \"NO\"\n where\n xs = filter (==head t) [head c | c <- cs]\n ys = filter (==last t) [last c | c <- cs]\n\nmain = do\n t <- getLine\n line <- getLine\n let cs = words line \n putStrLn $ solve t cs\n"}, {"source_code": "import Data.Set\n\nmain = do\n n <- getLine\n l <- fmap (Prelude.map show) getLine :: IO [String]\n let s = fromList l\n putStrLn( if (Data.Set.member (show $ (head n)) s) || (Data.Set.member (show $ (last n)) s) then \"YES\" else \"NO\" )"}, {"source_code": "{-# LANGUAGE Strict #-}\n\nmodule Main where\n\nimport Data.List (elem)\nimport System.IO\n\nsome :: String -> [String] -> Bool\nsome _ [] = False\nsome oneCard (x:xs) = elem (head oneCard) x || elem (last oneCard) x || some oneCard xs\n\nmain :: IO ()\nmain = do\n oneCard <- getLine\n myCards <- getLine\n let myCard = words myCards\n case some oneCard myCard of\n True -> putStrLn \"YES\"\n _ -> putStrLn \"NO\"\n"}, {"source_code": "import System.IO (readFile, getLine)\nimport Data.Char (digitToInt)\nimport Data.List (intercalate)\n\ndata Suite = D | C | S | H deriving (Show, Eq)\ndata Rank = Rank Int deriving (Show, Eq, Ord)\ndata Card = Card Suite Rank deriving (Show, Eq)\n\ncheckCard :: Card -> Card -> Bool\ncheckCard (Card s r) (Card s2 r2) | s == s2 = True\n | r == r2 = True\n | otherwise = False\n\nrankFromChar c | c == 'T' = Rank 10\n | c == 'J' = Rank 11\n | c == 'Q' = Rank 12\n | c == 'K' = Rank 13\n | c == 'A' = Rank 14\n | otherwise = Rank (digitToInt c)\n\nsuiteFromChar c | c == 'D' = D\n | c == 'C' = C\n | c == 'S' = S\n | c == 'H' = H\n\ncardFromString s = let second x = head (tail x) in Card (suiteFromChar $ second s) (rankFromChar $ head s)\n\ncardsFromString s = map cardFromString (words s)\n\ncalculate :: Card -> [Card] -> Bool\ncalculate tbl hold = any (checkCard tbl) hold\n\nmain = do \n tbl_s <- getLine\n hold_s <- getLine\n case calculate (cardFromString tbl_s) (cardsFromString hold_s) of\n True -> putStrLn \"Yes\"\n False -> putStrLn \"No\""}, {"source_code": "main = getContents >>= putStrLn . solve . words\n\nsolve ([x1,x2]:s)\n | any (\\[s1,s2] -> x1 == s1 || x2 == s2) s = \"YES\"\n | otherwise = \"NO\"\n"}, {"source_code": "import Control.Monad\n\nmain = getTwoLines >>= putStrLn . canPlay\n\ngetTwoLines :: IO (String, String)\ngetTwoLines = liftM2 toTuple getLine getLine\n where toTuple a b = (a, b)\n \ncanPlay :: (String, String) -> String\ncanPlay ([tRank, tSuit], hand) =\n case any canPlay' cards of\n True -> \"yes\"\n _ -> \"no\"\n where cards = words hand\n canPlay' [hRank, hSuit] = tRank == hRank || tSuit == hSuit"}, {"source_code": "import Text.Printf\nimport Data.List\nimport Data.Functor\nimport Control.Monad\nimport Prelude\n\nmain :: IO ()\nmain = do\n myCard@[myRank, mySuit] <- getLine\n cards <- words <$> getLine\n let answer = any (\\[rank, suit] -> rank == myRank || suit == mySuit) cards\n printf \"%s\" $ if answer then \"YES\" else \"NO\""}], "negative_code": [{"source_code": "import Data.Set\n\nmain = do\n n <- getLine\n l <- fmap (Prelude.map show) getLine :: IO [String]\n let s = fromList l\n putStrLn( show $ if (Data.Set.member (show $ (head n)) s) || (Data.Set.member (show $ (last n)) s) then \"YES\" else \"NO\" )"}, {"source_code": "{-# LANGUAGE Strict #-}\n\nmodule Main where\n\nimport Data.List (elem)\nimport System.IO\n\nsome :: String -> [String] -> Bool\nsome _ [] = False\nsome oneCard (x:xs) = elem (head oneCard) x || elem (last oneCard) x || some oneCard xs\n\nmain :: IO ()\nmain = do\n oneCard <- getLine\n myCards <- getLine\n let myCard = words myCards\n case some oneCard myCard of\n True -> print \"YES\"\n _ -> print \"NO\"\n"}], "src_uid": "699444eb6366ad12bc77e7ac2602d74b"} {"source_code": "import Control.Monad (replicateM)\nimport Data.Int (Int64)\n\nmain = do\n [n, p] <- fmap (map read . words) getLine\n hs <- replicateM n getLine\n\n let\n p' = fromIntegral p :: Int64\n count n [] = p'*n `div` 2\n count n (h:hs) =\n (p'*n `div` 2) + if h == \"half\" then count (2*n) hs else count (2*n+1) hs\n\n print $ count (1 :: Int64) $ tail $ reverse hs\n", "positive_code": [{"source_code": "half (a, b) p = (2 * a, b + a * p)\nhalfplus (a, b) p = (2 * a + 1, b + a * p + div p 2)\n\nsolve [] p = (0, 0)\nsolve (x:xs) p\n | (x == \"half\") = half (solve xs p) p\n | otherwise = halfplus (solve xs p) p\n\nmain = do\n content <- getContents\n let w = words content\n let p = read (w !! 1) :: Integer\n let res = solve (drop 2 w) p\n putStrLn . show . snd $ res\n"}, {"source_code": "import Data.List\n\ndata Divisional = Divisional {numerator :: Integer, denominator :: Integer}\n deriving (Show)\n\nreadInteger :: String -> Integer\nreadInteger s = read s :: Integer\n\nreadBuyer :: Integer -> [String] -> IO([String])\nreadBuyer 0 buyers = return buyers\nreadBuyer a buyers = do\n buyer <- getLine\n readBuyer (a - 1) (buyer:buyers)\n\ntraceApple :: Integer -> Integer\ntraceApple a = 2 * a\n\ntracePApple :: Integer -> Integer\ntracePApple a = (2 * a) + 1\n\ntraceMoney :: Integer -> Integer -> Integer -> Integer\ntraceMoney money apple price = money + (apple * price * 2)\n\ntracePMoney :: Integer -> Integer -> Integer -> Integer\ntracePMoney money apple price = money + (apple * price * 2 + price)\n\nsolution :: Integer -> Integer -> Integer -> [String] -> Integer\nsolution _ currentMoney _ [] = currentMoney\nsolution currentApple currentMoney p (\"halfplus\":xs) = solution (tracePApple currentApple) (tracePMoney currentMoney currentApple p) p xs\nsolution currentApple currentMoney p (\"half\":xs) = solution (traceApple currentApple) (traceMoney currentMoney currentApple p) p xs\n\nmain :: IO()\nmain = do\n args <- getLine\n let (n:p:[]) = readInteger `map` (words args)\n buyers <- readBuyer (n - 1) []\n putStrLn $ show $ solution 1 (div p 2) (div p 2) buyers\n"}, {"source_code": "{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE ViewPatterns #-}\n{-# LANGUAGE OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Tuple\nimport Data.Int\nimport Data.Char\nimport Data.Function\n-- import Data.Array\n-- import Data.ByteString (ByteString)\n-- import qualified Data.ByteString.Char8 as C\n-- import Data.ByteString.Char8 ()\n-- import Data.Vector.Unboxed ((//), (++), (!), (!?))\n-- import qualified Data.Vector.Unboxed as U\n-- import Data.IntMap.Strict (IntMap)\n-- import qualified Data.IntMap.Strict as IntMap\n-- import Data.Sequence ((|>), (<|), (><),ViewR((:>)), ViewL((:<)))\n-- import qualified Data.Sequence as S\n\nmyread = read :: String -> Int\ntoint64 = fromIntegral :: Int -> Int64\nmain = do\n [n,p] <- map myread.words <$> getLine\n ns <- replicateM n getLine\n print $ solve (toint64 p) ns\n\nsolve :: Int64 -> [String] -> Int64\nsolve p ns = p`div`2 * go 0 0 (map ((==4).length) $ reverse ns) where\n go :: Int64 -> Int64 -> [Bool] -> Int64\n go v w [] = w\n go v w (True:xs) = go (v*2) (w+(v*2)) xs\n go v w (False:xs) = go (v*2+1) (w+(v*2+1)) xs"}], "negative_code": [{"source_code": "half (a, b) p = (2 * a, b + a * p)\nhalfplus (a, b) p = (2 * a + 1, b + a * p + div p 2)\n\nsolve [] p = (0, 0)\nsolve (x:xs) p\n | (x == \"half\") = half (solve xs p) p\n | otherwise = halfplus (solve xs p) p\n\nmain = do\n content <- getContents\n let w = words content\n let p = read (w !! 1) :: Int\n let res = solve (drop 2 w) p\n putStrLn . show . snd $ res\n"}, {"source_code": "import Control.Monad (replicateM)\n\nmain = do\n [n, p] <- fmap (map read . words) getLine\n hs <- replicateM n getLine\n\n let\n count n [] = p*n `div` 2\n count n (h:hs) =\n (p*n `div` 2) + if h == \"half\" then count (2*n) hs else count (2*n+1) hs\n\n print $ count 1 $ tail $ reverse hs\n"}, {"source_code": "import Data.List\n\ndata Divisional = Divisional {numerator :: Integer, denominator :: Integer}\n deriving (Show)\n\nreadInteger :: String -> Integer\nreadInteger s = read s :: Integer\n\nreadBuyer :: Integer -> [String] -> IO([String])\nreadBuyer 0 buyers = return buyers\nreadBuyer a buyers = do\n buyer <- getLine\n readBuyer (a - 1) (buyer:buyers)\n\ntraceApple :: Integer -> Integer\ntraceApple a = 2 * a\n\ntracePApple :: Integer -> Integer\ntracePApple a = (2 * a) + 1\n\ntraceMoney :: Integer -> Integer -> Integer -> Integer\ntraceMoney money apple price = money + (apple * price * 2)\n\ntracePMoney :: Integer -> Integer -> Integer -> Integer\n-- tracePMoney money apple price = money + (price * (apple * 4)) - price\ntracePMoney money apple price = result\n where actualPrice = price * 2\n appleBought = apple * 2\n bonus = price\n result = actualPrice * appleBought - bonus\n\nsolution :: Integer -> Integer -> Integer -> [String] -> Integer\nsolution _ currentMoney _ [] = currentMoney\nsolution currentApple currentMoney p (\"halfplus\":xs) = solution (tracePApple currentApple) (tracePMoney currentMoney currentApple p) p xs\nsolution currentApple currentMoney p (\"half\":xs) = solution (traceApple currentApple) (traceMoney currentMoney currentApple p) p xs\n\nmain :: IO()\nmain = do\n args <- getLine\n let (n:p:[]) = readInteger `map` (words args)\n buyers <- readBuyer (n - 1) []\n putStrLn $ show $ solution 1 (div p 2) (div p 2) buyers\n"}], "src_uid": "6330891dd05bb70241e2a052f5bf5a58"} {"source_code": "-- Codeforces 121A\n\n{-# OPTIONS_GHC -O2 #-}\n{-# OPTIONS_GHC -optc-O2 #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE MultiWayIf #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Data.Array.IArray\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Foldable\nimport Data.Int\nimport Data.List\nimport Data.STRef\n\nforeach :: Monad m => [a] -> b -> (b -> a -> m b) -> m b\nforeach xs v f = foldM f v xs\n\n-- range: [, ], left inclusive and right inclusive\nqsort :: (MArray arr e m, Ord e) => arr Int e -> Int -> Int -> m ()\nqsort = qsortImpl\n where\n qsortImpl arr l r = when (r > l) $ do\n let mid = l + (r - l) `div` 2\n nmid <- partition arr l r mid\n qsortImpl arr l (nmid - 1)\n qsortImpl arr (nmid + 1) r\n swap arr ia ib = do\n a <- readArray arr ia\n b <- readArray arr ib\n writeArray arr ia b\n writeArray arr ib a\n partition arr l r mid = do\n pivot <- readArray arr mid\n swap arr mid r\n slot <- foreach [l..r-1] l (\\slot i -> do\n val <- readArray arr i\n if val < pivot\n then swap arr i slot >> return (slot+1)\n else return slot)\n swap arr slot r >> return slot\n\nmain :: IO ()\nmain = do\n\n let nlen = 2 + Data.List.sum (map (2 ^) [1..9])\n\n let arr = runSTUArray $ do\n arr <- newArray_ (0, nlen) :: ST s (STUArray s Int Int64)\n let go k top arr | k > 444444444 = return ()\n | otherwise = do\n z <- readSTRef top\n writeArray arr z (k * 10 + 4)\n modifySTRef' top (+ 1)\n go (k * 10 + 4) top arr\n z <- readSTRef top\n writeArray arr z (k * 10 + 7)\n modifySTRef' top (+ 1)\n go (k * 10 + 7) top arr\n\n writeArray arr 0 0\n top <- newSTRef 1\n go 0 top arr\n z <- readSTRef top\n qsort arr 1 nlen\n return arr\n\n let sumAll x | x == 0 = 0\n | otherwise = go 1\n where go i | i > nlen = 0\n | x >= a = a * (a - b) + go (i + 1)\n | otherwise = a * (x - b)\n where a = arr ! i\n b = arr ! (i - 1)\n\n [a, b] <- (map read . words) <$> getLine :: IO [Int64]\n print $ sumAll b - sumAll (a - 1)\n", "positive_code": [{"source_code": "import Data.List\n\nluckyList = [4, 7] ++ concat [ [x*10+4, x*10+7] | x <- luckyList ]\n\nsolve :: [Integer] -> Integer\nsolve [l,r] = sum [ y * z | [x, y] <- luckyLinked, let z = max 0 $ min y r - max x (l-1) ]\n where luckyLinked = ([0,4]:) . map (take 2) . takeWhile (( Integer\nnext = read . next' [] . reverse . show\n where\n next' acc [] = acc\n next' acc (c:s)\n | c < '4' = next' ('4' : (map (const '4') acc)) s\n | c == '4' = next' ('4' : acc) s\n | c < '7' = next' ('7' : (map (const '4') acc)) s\n | c == '7' = next' ('7' : acc) s\n | otherwise = nextAdd ('4' : (map (const '4') acc)) s\n nextAdd acc [] = '4' : acc\n nextAdd acc (c:s)\n | c == '9' = nextAdd ('4' : acc) s\n | otherwise = next' acc (succ c : s)\n\nsolve :: Integer -> Integer -> Integer\nsolve l r = solve' l 0\n where\n solve' l acc\n | nextL >= r = acc + (r - l + 1) * nextL\n | otherwise = solve' (nextL + 1) (acc + (nextL - l + 1) * nextL)\n where\n nextL = next l\n\nmain :: IO ()\nmain = do\n [l, r] <- getLine >>= return . map read . words\n print $ solve l r\n"}, {"source_code": "{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport Data.Array.IArray\nimport Data.Array.Unboxed (UArray)\nimport Data.Int\nimport Data.Ratio\nimport Data.Bits\nimport Data.Function\nimport Data.Ord\n--import Control.Monad.State\nimport Control.Monad\nimport Control.Applicative\nimport Data.ByteString.Char8 (ByteString)\nimport qualified Data.ByteString.Char8 as BS\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\nimport Data.Sequence (Seq, (<|), (|>), (><), ViewL(..), ViewR(..))\nimport qualified Data.Sequence as Seq\nimport qualified Data.Foldable as F\nimport Data.Graph\n\nparseInput = do \n l <- readInteger\n r <- readInteger\n return (l, r)\n where\n readInt = state $ fromJust . BS.readInt . BS.dropWhile isSpace\n readInteger = state $ fromJust . BS.readInteger . BS.dropWhile isSpace\n readString = state $ BS.span (not . isSpace) . BS.dropWhile isSpace\n readLine = state $ BS.span (not . isEoln) . BS.dropWhile isEoln\n isEoln ch = ch == '\\r' || ch == '\\n'\n\nmain = print =<< solve . evalState parseInput <$> BS.getContents\n\nlucky digits = [sum subset * 3 + ones | subset <- subsequences masks]\n where\n ones = (10^digits-1) `div` 9 * 4\n masks = map (10^) [0..digits-1]\n\nluckys = sort $ concat [lucky digits | digits <- [1..10]]\n\nsolve (l, r) = sum [ (min r b - max l (a + 1) + 1) * b\n | (a, b) <- intervals\n , l <= b && r > a\n ]\n where\n intervals = zip (0:luckys) luckys\n\n----------------------------------------------------------------------\n----------------------------------------------------------------------\n----------------------------------------------------------------------\n\nclass (Monad m) => MonadState s m | m -> s where\n\tget :: m s\n\tput :: s -> m ()\n\nmodify :: (MonadState s m) => (s -> s) -> m ()\nmodify f = do\n\ts <- get\n\tput (f s)\n\ngets :: (MonadState s m) => (s -> a) -> m a\ngets f = do\n\ts <- get\n\treturn (f s)\n\nnewtype State s a = State { runState :: s -> (a, s) }\n\ninstance Functor (State s) where\n\tfmap f m = State $ \\s -> let\n\t\t(a, s') = runState m s\n\t\tin (f a, s')\n\ninstance Applicative (State s) where\n pure = return\n (<*>) = ap\n\ninstance Monad (State s) where\n\treturn a = State $ \\s -> (a, s)\n\tm >>= k = State $ \\s -> let\n\t\t(a, s') = runState m s\n\t\tin runState (k a) s'\n\ninstance MonadState s (State s) where\n\tget = State $ \\s -> (s, s)\n\tput s = State $ \\_ -> ((), s)\n\nevalState :: State s a -> s -> a\nevalState m s = fst (runState m s)\n\nexecState :: State s a -> s -> s\nexecState m s = snd (runState m s)\n\nmapState :: ((a, s) -> (b, s)) -> State s a -> State s b\nmapState f m = State $ f . runState m\n\nwithState :: (s -> s) -> State s a -> State s a\nwithState f m = State $ runState m . f\n\nstate = State\n"}, {"source_code": "import Data.Char\nimport Debug.Trace\n\nfours n = replicate n '4'\n\nnext n =\n if all (=='7') n then\n fours (length n + 1)\n else\n let rn = reverse n\n (a,(b:bs)) = span (=='7') rn\n in\n (reverse bs) ++ ('7':(fours $ length a))\n\nminLucky n_ = let n = show n_\n (nf,nb) = span (\\c -> c=='4'||c=='7') n\n in\n if null nb then\n n\n else\n let a = (ord (head nb))-(ord '0') in\n if a>7 then\n (next nf)++(fours (length nb))\n else if a>4 then\n nf++('7':(fours (length nb - 1)))\n else\n nf++(fours (length nb))\n\nsolve l r = rec l 0\n where\n rec i sum | i>r = show sum\n | otherwise =\n let minl = read (minLucky i)::Integer\n fr_ = minl - i +1\n fr = if (i+fr_)>r then (r-i+1) else fr_ in\n rec (i+fr) (sum+minl*fr)\n\nmain = do lis <- getLine\n let (l:r:_) = words lis\n putStrLn $ solve (read l::Integer) (read r::Integer)"}, {"source_code": "module Main (main) where\n\nimport System\nimport Data.Char\nimport Data.List\nimport Control.Monad\nimport Control.Applicative\n\n\nluckyNumberList upper = sort $ tail $ makeLucky 0\n where \n makeLucky now \n | now <= upper = [fromIntegral now] ++ makeLucky (now*10+4) ++ makeLucky (now*10+7) \n | otherwise = []\n\ncalc :: [Integer] -> Integer -> Integer\ncalc [x1,x2] n = (max 0 ((min x2 n)- x1)) * x2\ncalc (x1:x2:xs) n = (max 0 ((min x2 n)- x1)) * x2 + calc (x2:xs) n\n \n--fromIntegral n \nsub :: Integer -> Integer\nsub 0 = 0\nsub n = if length list == 0 then 0 \n else \n fromIntegral $ calc list n\n where list = [0] ++ luckyNumberList (n*10) \n\nsolve :: [Integer] -> Integer\nsolve [l,r] = sub r - sub (l - 1)\n\n\n--main = interact$show.sub.read.head.words\nmain = interact$show.solve.map read.take 2.words"}, {"source_code": "import Data.List\n\nstrToInt :: String -> Integer\nstrToInt = read\n\n-- get soreted list of lucky numbers.\nluckyNumbers x = sort $ f 0 x\n where\n f b x\n | b*10+7 <= x = (b*10+4):(b*10+7):[] ++ f (b*10+4) x ++ f (b*10+7) x\n | b*10+4 <= x = (b*10+4):[]\n | otherwise = []\n\n-- solve the problem\n--- x is next(l)\nsolve lucky l r i = let x = lucky!!i in\n if x < r then (x-l+1)*x + solve lucky (x+1) r (i+1)\n else (r-l+1)*x\n\nmain = do\n input <- getLine\n let (l:r:_) = map strToInt $ words input\n let lucky = luckyNumbers (10*r)\n putStrLn $ case findIndex (>=l) lucky of\n Just(i) -> show $ solve lucky l r i\n Nothing -> \"\""}, {"source_code": "import Control.Applicative\nimport Data.List\nimport qualified Data.ByteString.Char8 as C\nimport Data.Maybe\nimport Data.Array\nimport qualified Data.IntMap as I\nimport qualified Data.Map as M\n\n\nlucky 1 = [\"4\",\"7\"]\nlucky n = [a:b|a<-\"47\",b<-lucky (n-1)]\n\n\nluck::[Integer]\nluck = map read $ concat [lucky i | i<-[1..]] ::[Integer]\n\nprocess::Integer->Integer->Integer->[Integer]->Integer\nprocess a b c (s:ss) | sgetLine ::IO [Integer] \n\tprint $ process a b 0 $ dropWhile ( Bool\nisLucky x = let s = show x\n in not $ any (flip elem ['1', '2', '3', '5', '6', '8', '9', '0']) s\n\nlst :: [Integer]\nlst = let ar = ['0', '4', '7']\n f :: String -> Bool\n f = hasOnlyLeadingZeroes\n in [read x | a<-ar, b<-ar, c<-ar, d<-ar, e<-ar, ff<-ar,g<-ar, h<-ar, i<-ar, j<-ar,let x = a:b:c:d:e:ff:g:h:i:j:[], f x]\n\nhasOnlyLeadingZeroes :: String-> Bool\nhasOnlyLeadingZeroes s = let\n (a, b) = foldl (\\(b1, b0) a ->\n case a of\n '0' -> if b1 && b0 then (b1, not b0) else (b1, b0)\n _ -> if b1 then (b1, b0) else (not b1, b0)\n ) (False, True) s\n in a && b\n\n-- isLucky' :: Integer -> Bool\n-- isLucky' x = go (x `div` 10) (x `mod` 10)\n-- where\n-- go :: Integer -> Integer -> Bool\n-- go 0 dig = True\n-- go new dig = if dig == 7 || dig == 4\n-- then go (new `div` 10) (x `mod` 10)\n-- else False\n\nmain :: IO ()\nmain = do\n interact $ unlines . map solve . lines\n\nsolve :: String -> String\nsolve st = let\n (l:r:[]) = map read . words $ st :: [Integer]\n (snn, _) = func l r\n in\n if (l == r) then show $ nextl l\n else show snn\n\n\nnextl :: Integer -> Integer\nnextl l = let ll = head [x | x <- lst, x >=l]\n in ll\n\n-- func :: Integer -> Integer -> (Integer, [Integer])\n-- func l r = let ll = [x | x <- lst, x >= l && x <= r]\n-- h = head ll\n-- lsl = nextl r\n-- (_, llln) = foldl (\\(b, l) a -> (a, (replicate (fromInteger $ a - b) a) : l)) (h, []) (tail ll)\n-- lln = replicate (fromInteger $ h - l +1) h ++ concat llln ++ replicate (fromInteger $ r - last ll) lsl\n-- in (sum $ lln,lln)\n\nfunc :: Integer -> Integer -> (Integer, [Integer])\nfunc l r = let ll = [x | x <- lst, x >= l && x <= r]\n h = head ll\n lsl = nextl r\n lsll = last ll\n (_, llln, sn) = foldl (\\(b, l, s) a -> (a, ((replicate (fromInteger $ a - b) a) : l), (s + a * (a-b)))) (h,[],0) (tail ll)\n lln = replicate (fromInteger $ h - l +1) h ++ concat llln ++ replicate (fromInteger $ r - lsll) lsl\n snn = sn + h * (h - l + 1) + lsl * (r - lsll)\n in\n if length ll == 0\n then ((r - l + 1) * nextl l, [])\n else (snn,lln)\n"}, {"source_code": "-- Codeforces 122C\n\n{-# OPTIONS_GHC -O2 #-}\n{-# OPTIONS_GHC -optc-O2 #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE MultiWayIf #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Data.Array.IArray\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Foldable\nimport Data.Int\nimport Data.List\nimport Data.STRef\n\nforeach :: Monad m => [a] -> b -> (b -> a -> m b) -> m b\nforeach xs v f = foldM f v xs\n\n-- range: [, ], left inclusive and right inclusive\nqsort :: (MArray arr e m, Ord e) => arr Int e -> Int -> Int -> m ()\nqsort = qsortImpl\n where\n qsortImpl arr l r = when (r > l) $ do\n let mid = l + (r - l) `div` 2\n nmid <- partition arr l r mid\n qsortImpl arr l (nmid - 1)\n qsortImpl arr (nmid + 1) r\n swap arr ia ib = do\n a <- readArray arr ia\n b <- readArray arr ib\n writeArray arr ia b\n writeArray arr ib a\n partition arr l r mid = do\n pivot <- readArray arr mid\n swap arr mid r\n slot <- foreach [l..r-1] l (\\slot i -> do\n val <- readArray arr i\n if val < pivot\n then swap arr i slot >> return (slot+1)\n else return slot)\n swap arr slot r >> return slot\n\nmain :: IO ()\nmain = do\n\n let nlen = 2 + Data.List.sum (map (2 ^) [1..9])\n\n let arr = runSTUArray $ do\n arr <- newArray_ (0, nlen) :: ST s (STUArray s Int Int64)\n let go k top arr | k > 444444444 = return ()\n | otherwise = do\n z <- readSTRef top\n writeArray arr z (k * 10 + 4)\n modifySTRef' top (+ 1)\n go (k * 10 + 4) top arr\n z <- readSTRef top\n writeArray arr z (k * 10 + 7)\n modifySTRef' top (+ 1)\n go (k * 10 + 7) top arr\n\n writeArray arr 0 0\n top <- newSTRef 1\n go 0 top arr\n z <- readSTRef top\n qsort arr 1 nlen\n return arr\n\n let sumAll x | x == 0 = 0\n | otherwise = go 1\n where go i | i > nlen = 0\n | x >= a = a * (a - b) + go (i + 1)\n | otherwise = a * (x - b)\n where a = arr ! i\n b = arr ! (i - 1)\n\n [a, b] <- (map read . words) <$> getLine :: IO [Int64]\n print $ sumAll b - sumAll (a - 1)\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Integer] -> Integer\nsolve [l, r] = sumLucky r - sumLucky (l - 1)\nsolve _ = undefined\n\nlucky :: [Integer]\nlucky = map read $ concat $ tail $ take 11 $ iterate (\\xs -> map ('4':) xs ++ map ('7':) xs) [\"\"]\n\nsumLucky :: Integer -> Integer\nsumLucky n = sum $ map snd $ scanl f (0, 0) lucky\n where f (x, _) z | z <= n = (z, (z - x) * z)\n | x >= 0 = (-1, (n - x) * z)\n | otherwise = (-1, 0)\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Integer] -> Integer\nsolve [l, r] = sumLucky r - sumLucky (l - 1)\n\nlucky :: [Integer]\nlucky = map read $ (id =<<) $ tail $ take 11 $ iterate (\\xs -> map ('4':) xs ++ map ('7':) xs) [\"\"]\n\nsumLucky :: Integer -> Integer\nsumLucky n = sum $ map snd $ scanl f (0, 0) lucky\n where f (x, _) z | z <= n = (z, (z - x) * z)\n | x >= 0 = (-1, (n - x) * z)\n | otherwise = (-1, 0)\n"}, {"source_code": "import Control.Monad (replicateM)\nluckys :: [Integer]\nluckys = map read $ concatMap (flip replicateM ['4', '7']) [1..10]\n\nsolve' :: Integer -> Integer -> [Integer] -> Integer\nsolve' _ _ [] = 0\nsolve' x y (k:ks)\n | y < x = 0\n | x > k = solve' x y ks\n | otherwise = (min y k - x + 1) * k + solve' (k + 1) y ks\nparse :: String -> Integer\nparse s = case map read (words s) of [x, y] -> solve' x y luckys\n\nmain = putStrLn . show . parse =<< getLine \n"}, {"source_code": "lucky = let ys@(y : _) = [\"4\",\"7\"] : map (\\x -> map (\"4\"++) x ++ map (\"7\"++) x )ys in map (\\x -> map (\\y -> (read y) :: Integer) x) ys\n\ncount x = length $ show x\n\nsolve l r = doIt l r enum 0\n\twhere\n\t\ts = count l\n\t\tenum = concat $ (drop (s-1) lucky )\n\t\tdoIt l r (x : xs) acc\t\t|\tx < l\t\t=\tdoIt l r xs acc\n\t\t\t\t\t\t|\tx > r\t\t=\tacc + (r - l + 1) * x\n\t\t\t\t\t\t|\totherwise\t=\t($!) (doIt (x+1) r xs) (acc + (x - l + 1) * x)\n\nmain :: IO ()\n\nmain = do\n\t\tln <- getLine\n\t\tlet (l : r : _) = map (\\x -> (read x) :: Integer) $ words ln\n\t\tprint $ solve l r\n\t\treturn ()"}], "negative_code": [{"source_code": "\n{-\nimport HUnit\n\ntestInput :: Test\ntestInput = TestList \"TestInput\"\n [\n Test \"#1\" $ assertEq 33 $ solve 2 7,\n Test \"#2\" $ assertEq 7 $ solve 7 7\n ]\n\ntestNext :: Test\ntestNext = TestList \"TestNext\"\n [\n Test \"#1\" $ assertEq 4 $ next 0,\n Test \"#2\" $ assertEq 4 $ next 4,\n Test \"#3\" $ assertEq 7 $ next 5,\n Test \"#4\" $ assertEq 7 $ next 7,\n Test \"#5\" $ assertEq 44 $ next 8,\n Test \"#6\" $ assertEq 44 $ next 44,\n Test \"#7\" $ assertEq 47 $ next 45,\n Test \"#8\" $ assertEq 47 $ next 47,\n Test \"#9\" $ assertEq 74 $ next 48,\n Test \"#10\" $ assertEq 74 $ next 74,\n Test \"#11\" $ assertEq 77 $ next 75,\n Test \"#12\" $ assertEq 77 $ next 77,\n Test \"#13\" $ assertEq 444 $ next 78,\n Test \"#14\" $ assertEq 74744 $ next 74572,\n Test \"#15\" $ assertEq 77444 $ next 74872,\n Test \"#16\" $ assertEq 444444 $ next 79999,\n Test \"#17\" $ assertEq 4444 $ next 4099,\n Test \"#18\" $ assertEq 4744 $ next 4499\n ]\n\ntestNextBig :: Test\ntestNextBig = Test \"TestNextBig\" $ assertEq 4444444444 $ next 777777778\n\ntestBig :: Test\ntestBig = Test \"TestBig\" $ assertEq 444444444 $ solve 380000000 380000000\n\ntestBigBig :: Test\ntestBigBig = Test \"TestBigBig\" $ assertEq 0 $ solve 1 (10^9)\n\ntest :: IO ()\ntest = mapM_ run\n [\n testInput,\n testNext,\n testNextBig,\n testBig,\n testBigBig\n ]\n-}\n--------------------------------------------------------------------------------\n\nnext :: Integer -> Integer\nnext = read . next' [] . reverse . show\n where\n next' acc [] = acc\n next' acc (c:s)\n | c <= '4' = next' ('4' : acc) s\n | c < '7' = next' ('7' : (map (const '4') acc)) s\n | c == '7' = next' ('7' : acc) s\n | otherwise = nextAdd ('4' : (map (const '4') acc)) s\n nextAdd acc [] = '4' : acc\n nextAdd acc (c:s)\n | c == '9' = nextAdd ('4' : acc) s\n | otherwise = next' acc (succ c : s)\n\nsolve :: Integer -> Integer -> Integer\nsolve l r = solve' l 0\n where\n solve' l acc\n | nextL >= r = acc + (r - l + 1) * nextL\n | otherwise = solve' (nextL + 1) (acc + (nextL - l + 1) * nextL)\n where\n nextL = next l\n\nmain :: IO ()\nmain = do\n [l, r] <- getLine >>= return . map read . words\n print $ solve l r\n"}, {"source_code": "-- Codeforces 121A\n\n{-# OPTIONS_GHC -O2 #-}\n{-# OPTIONS_GHC -optc-O2 #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE MultiWayIf #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Data.Array.IArray\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Foldable\nimport Data.Int\nimport Data.List\nimport Data.STRef\n\nforeach :: Monad m => [a] -> b -> (b -> a -> m b) -> m b\nforeach xs v f = foldM f v xs\n\n-- range: [, ], left inclusive and right inclusive\nqsort :: (MArray arr e m, Ord e) => arr Int e -> Int -> Int -> m ()\nqsort = qsortImpl\n where\n qsortImpl arr l r = when (r > l) $ do\n let mid = l + (r - l) `div` 2\n nmid <- partition arr l r mid\n qsortImpl arr l (nmid - 1)\n qsortImpl arr (nmid + 1) r\n swap arr ia ib = do\n a <- readArray arr ia\n b <- readArray arr ib\n writeArray arr ia b\n writeArray arr ib a\n partition arr l r mid = do\n pivot <- readArray arr mid\n swap arr mid r\n slot <- foreach [l..r-1] l (\\slot i -> do\n val <- readArray arr i\n if val < pivot\n then swap arr i slot >> return (slot+1)\n else return slot)\n swap arr slot r >> return slot\n\nmain :: IO ()\nmain = do\n\n let nlen = Data.List.sum $ map (2 ^) [1..9]\n\n let arr = runSTUArray $ do\n arr <- newArray_ (0, nlen) :: ST s (STUArray s Int Int64)\n let go k top arr | k > 100000000 = return ()\n | otherwise = do\n z <- readSTRef top\n writeArray arr z (k * 10 + 4)\n modifySTRef' top (+ 1)\n go (k * 10 + 4) top arr\n z <- readSTRef top\n writeArray arr z (k * 10 + 7)\n modifySTRef' top (+ 1)\n go (k * 10 + 7) top arr\n\n writeArray arr 0 0\n top <- newSTRef 1\n go 0 top arr\n z <- readSTRef top\n qsort arr 1 nlen\n return arr\n\n let sumAll x | x == 0 = 0\n | otherwise = go 1\n where go i | i > nlen = 0\n | x >= a = a * (a - b) + go (i + 1)\n | otherwise = a * (x - b)\n where a = arr ! i\n b = arr ! (i - 1)\n\n [a, b] <- (map read . words) <$> getLine :: IO [Int64]\n print $ sumAll b - sumAll (a - 1)\n"}, {"source_code": "{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport Data.Array.IArray\nimport Data.Array.Unboxed (UArray)\nimport Data.Int\nimport Data.Ratio\nimport Data.Bits\nimport Data.Function\nimport Data.Ord\n--import Control.Monad.State\nimport Control.Monad\nimport Control.Applicative\nimport Data.ByteString.Char8 (ByteString)\nimport qualified Data.ByteString.Char8 as BS\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\nimport Data.Sequence (Seq, (<|), (|>), (><), ViewL(..), ViewR(..))\nimport qualified Data.Sequence as Seq\nimport qualified Data.Foldable as F\nimport Data.Graph\n\nparseInput = do \n n <- readInt\n s <- readString\n return (n, s)\n where\n readInt = state $ fromJust . BS.readInt . BS.dropWhile isSpace\n readInteger = state $ fromJust . BS.readInteger . BS.dropWhile isSpace\n readString = state $ BS.span (not . isSpace) . BS.dropWhile isSpace\n readLine = state $ BS.span (not . isEoln) . BS.dropWhile isEoln\n isEoln ch = ch == '\\r' || ch == '\\n'\n\nmain = BS.putStr =<< solve . evalState parseInput <$> BS.getContents\n\nsolve (n, s) = BS.unlines $ replicate n s\n\n----------------------------------------------------------------------\n----------------------------------------------------------------------\n----------------------------------------------------------------------\n\nclass (Monad m) => MonadState s m | m -> s where\n\tget :: m s\n\tput :: s -> m ()\n\nmodify :: (MonadState s m) => (s -> s) -> m ()\nmodify f = do\n\ts <- get\n\tput (f s)\n\ngets :: (MonadState s m) => (s -> a) -> m a\ngets f = do\n\ts <- get\n\treturn (f s)\n\nnewtype State s a = State { runState :: s -> (a, s) }\n\ninstance Functor (State s) where\n\tfmap f m = State $ \\s -> let\n\t\t(a, s') = runState m s\n\t\tin (f a, s')\n\ninstance Applicative (State s) where\n pure = return\n (<*>) = ap\n\ninstance Monad (State s) where\n\treturn a = State $ \\s -> (a, s)\n\tm >>= k = State $ \\s -> let\n\t\t(a, s') = runState m s\n\t\tin runState (k a) s'\n\ninstance MonadState s (State s) where\n\tget = State $ \\s -> (s, s)\n\tput s = State $ \\_ -> ((), s)\n\nevalState :: State s a -> s -> a\nevalState m s = fst (runState m s)\n\nexecState :: State s a -> s -> s\nexecState m s = snd (runState m s)\n\nmapState :: ((a, s) -> (b, s)) -> State s a -> State s b\nmapState f m = State $ f . runState m\n\nwithState :: (s -> s) -> State s a -> State s a\nwithState f m = State $ runState m . f\n\nstate = State\n"}, {"source_code": "import Data.Char\nimport Debug.Trace\n\nfours n = replicate n '4'\n\nnext n =\n if all (=='7') n then\n fours (length n + 1)\n else\n let rn = reverse n\n (a,(b:bs)) = span (=='7') rn\n in\n (reverse bs) ++ ('7':a)\n\nminLucky n_ = let n = show n_\n (nf,nb) = span (\\c -> c=='4'||c=='7') n\n in\n if null nb then\n n\n else\n let a = (ord (head nb))-(ord '0') in\n if a>7 then\n (next nf)++(fours (length nb))\n else if a>4 then\n nf++('7':(fours (length nb - 1)))\n else\n nf++(fours (length nb))\n\nsolve l r = rec l 0\n where\n rec i sum | i>r = show sum\n | otherwise =\n let minl = read (minLucky i)::Integer\n fr_ = minl - i +1\n fr = if (i+fr_)>r then (r-i+1) else fr_ in\n rec (i+fr) (sum+minl*fr)\n\nmain = do lis <- getLine\n let (l:r:_) = words lis\n putStrLn $ solve (read l::Integer) (read r::Integer)"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport qualified Data.ByteString.Char8 as C\nimport Data.Maybe\nimport Data.Array\nimport qualified Data.IntMap as I\nimport qualified Data.Map as M\n\n\nlucky 1 = [\"4\",\"7\"]\nlucky n = [a:b|a<-\"47\",b<-lucky (n-1)]\n\n\nluck::[Int]\nluck = map read $ concat [lucky i | i<-[1..]] ::[Int]\n\n\nprocess a b c (s:ss) | sgetLine ::IO [Int] \n\tprint $ process a b 0 $ dropWhile ( Bool\nisLucky x = let s = show x\n in not $ any (flip elem ['1', '2', '3', '5', '6', '8', '9', '0']) s\n\nlst :: [Integer]\nlst = let ar = ['0', '4', '7']\n f :: String -> Bool\n f = hasOnlyLeadingZeroes\n in [read x | a<-ar, b<-ar, c<-ar, d<-ar, e<-ar, ff<-ar,g<-ar, h<-ar, i<-ar, j<-ar,let x = a:b:c:d:e:ff:g:h:i:j:[], f x]\n\nhasOnlyLeadingZeroes :: String-> Bool\nhasOnlyLeadingZeroes s = let\n (a, b) = foldl (\\(b1, b0) a ->\n case a of\n '0' -> if b1 && b0 then (b1, not b0) else (b1, b0)\n _ -> if b1 then (b1, b0) else (not b1, b0)\n ) (False, True) s\n in a && b\n\n-- isLucky' :: Integer -> Bool\n-- isLucky' x = go (x `div` 10) (x `mod` 10)\n-- where\n-- go :: Integer -> Integer -> Bool\n-- go 0 dig = True\n-- go new dig = if dig == 7 || dig == 4\n-- then go (new `div` 10) (x `mod` 10)\n-- else False\n\nmain :: IO ()\nmain = do\n interact $ unlines . map solve . lines\n\nsolve :: String -> String\nsolve st = let\n (l:r:[]) = map read . words $ st :: [Integer]\n (snn, _) = func l r\n in\n if (l == r) then show $ nextl l\n else show snn\n\n\nnextl :: Integer -> Integer\nnextl l = let ll = head [x | x <- lst, x >=l]\n in ll\n\n-- func :: Integer -> Integer -> (Integer, [Integer])\n-- func l r = let ll = [x | x <- lst, x >= l && x <= r]\n-- h = head ll\n-- lsl = nextl r\n-- (_, llln) = foldl (\\(b, l) a -> (a, (replicate (fromInteger $ a - b) a) : l)) (h, []) (tail ll)\n-- lln = replicate (fromInteger $ h - l +1) h ++ concat llln ++ replicate (fromInteger $ r - last ll) lsl\n-- in (sum $ lln,lln)\n\nfunc :: Integer -> Integer -> (Integer, [Integer])\nfunc l r = let ll = [x | x <- lst, x >= l && x <= r]\n h = head ll\n lsl = nextl r\n lsll = last ll\n (_, llln, sn) = foldl (\\(b, l, s) a -> (a, ((replicate (fromInteger $ a - b) a) : l), (s + a * (a-b)))) (h,[],0) (tail ll)\n lln = replicate (fromInteger $ h - l +1) h ++ concat llln ++ replicate (fromInteger $ r - lsll) lsl\n snn = sn + h * (h - l + 1) + lsl * (r - lsll)\n in\n if length ll == 0\n then ((r - l) * nextl l, [])\n else (snn,lln)\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Integer] -> Integer\nsolve [l, r] = sumLucky r - sumLucky (l - 1)\n\nlucky :: [Integer]\nlucky = map read $ (id =<<) $ tail $ take 9 $ iterate (\\xs -> map ('4':) xs ++ map ('7':) xs) [\"\"]\n\nsumLucky :: Integer -> Integer\nsumLucky n = sum $ map snd $ scanl f (0, 0) lucky\n where f (x, _) z | z <= n = (z, (z - x) * z)\n | x >= 0 = (-1, (n - x) * z)\n | otherwise = (-1, 0)\n"}, {"source_code": "import Control.Monad (replicateM)\nluckys :: [Integer]\nluckys = map read $ concatMap (flip replicateM ['4', '7']) [1..9]\n\nsolve' :: Integer -> Integer -> [Integer] -> Integer\nsolve' _ _ [] = 0\nsolve' x y (k:ks)\n | y < x = 0\n | x > k = solve' x y ks\n | otherwise = (min y k - x + 1) * k + solve' (k + 1) y ks\nparse :: String -> Integer\nparse s = case map read (words s) of [x, y] -> solve' x y luckys\n\nmain = putStrLn . show . parse =<< getLine"}, {"source_code": "lucky = let ys@(y : _) = [\"4\",\"7\"] : map (\\x -> map (\"4\"++) x ++ map (\"7\"++) x )ys in map (\\x -> map (\\y -> (read y) :: Int) x) ys\n\ncount x = length $ show x\n\nsolve l r = doIt l r enum 0\n\twhere\n\t\ts = count l\n\t\tenum = concat $ (drop (s-1) lucky )\n\t\tdoIt l r (x : xs) acc\t\t|\tx < l\t\t=\tdoIt l r xs acc\n\t\t\t\t\t\t|\tx > r\t\t=\tacc + (r - l + 1) * x\n\t\t\t\t\t\t|\totherwise\t=\t($!) (doIt (x+1) r xs) (acc + (x - l + 1) * x)\n\nmain :: IO ()\n\nmain = do\n\t\tln <- getLine\n\t\tlet (l : r : _) = map (\\x -> (read x) :: Int) $ words ln\n\t\tprint $ solve l r\n\t\treturn ()"}], "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd"} {"source_code": "main = do\n n <- readLn\n print $ solve n\n\n\nsolve n | n == 1 = 1\n | n == 2 = 2\n | odd n = n * (n-1) * (n-2)\n | otherwise = max ((n-1)*(n-2)*(n-3)) $ maximum $ do\n let a = n\n let b = n-1\n c <- [1..n-2]\n return $ a `lcm` b `lcm` c\n", "positive_code": [{"source_code": "prime :: (Integral a, Ord a) => a -> a -> a -> Bool\nprime 1 cur comp = False\nprime n cur comp\n\t|n `mod` 2 == 0 = False\n\t|cur >= comp = True\n\t|otherwise = if n `mod` cur == 0 then False else prime n (cur+2) comp\n\nget :: Int -> Float -> [Integer]\nget 3 cur = []\nget x cur = if prime (truncate $ cur) 3 (truncate . sqrt $ cur) == True then (truncate cur):(get (x+1) (cur-1)) else get x (cur-1)\n\nmx :: (Ord a) => [a] -> a\nmx xs = foldl (\\acc x -> max acc x) (head xs) xs\n\nfind :: [Integer] -> Integer\nfind xs = mx $ [x*(kk y z) `div` (gcd x (kk y z)) | x <- [last $ xs..(head $ xs)], y <- [x+1 .. (head xs)], z <- [y+1 .. head xs]]\n\t\t\t\t\twhere kk y z = y*z `div` (gcd y z) \n\nmain = do \n\tn <- readLn\n\tif n==1 then print $ 1 else \n\t\tif n==2 then print $ 2 else\n\t\t\tif n==3 then print $ 6 else\n\t\t\t\tif n==4 then print $ 12 else\n\t\t\t\t print $ find $ ((truncate n):(get 0 n))"}, {"source_code": "main :: IO ()\nmain = readLn >>= print . solve\n\nsolve :: Integer -> Integer\nsolve n = maximum [ a `lcm` b `lcm` c | a <- [n,n-1..p],b <- [a,a-1..p],c <- [b,b-1..p] ]\n where p = last (take 3 $ take 3 (filter isPrime [n,n-1..1]) ++ [1])\n\nprimes :: Integral a => [a]\nprimes = 2 : filter isPrime [3,5..]\n\nisPrime :: Integral a => a -> Bool\nisPrime n = n > 1 && foldr (\\p r -> p * p > n || (n `mod` p /= 0 && r)) True primes\n"}, {"source_code": "main=readLn>>=print.solve\nsolve :: Integer -> Integer\nsolve x = maximum [i`lcm`j`lcm`k|i<-[z..x],j<-[z..x],k<-[z..x]]\n where\n y = head $ filter ((<2).gcd x) [x,x-1..1]\n z = head $ filter ((<2).gcd (x*y)) [y,y-1..1]\n"}, {"source_code": "main = do\n n <- fmap read getLine\n print $ maximum $ [foldl1 lcm [i, j, k] |\n m <- [max 1 (n - 10)],\n i <- [m .. n],\n j <- [m .. n],\n k <- [m .. n]]\n"}, {"source_code": "pr :: Integer -> Integer\npr 1 = 1\npr n = n-1\nmain = do\n sn <- getLine\n let n = read sn\n let ans = max (max (div ((pr (pr n))*(pr n)*n) (gcd n (pr (pr n)))) (div ((pr (pr k))*(pr k)*k) (gcd k (pr (pr k))))) (div ((pr (pr k))*(pr n)*n) (gcd n (pr (pr k)))) where \n k = pr n\n print ans"}, {"source_code": "\nimport Data.List\nimport Monad\nimport Prelude hiding (Int)\n\ntype Int = Integer\n\nisPrime :: Int -> Bool\nisPrime n = all (\\x -> mod n x /= 0) $ takeWhile (\\x -> x * x <= n) primes\n\nprimes :: [Int]\nprimes = 2 : [n | n <- [3,5..], isPrime n]\n\nmaxPrime :: Int -> Int\nmaxPrime n = last $ takeWhile (< n) primes\n\nlcmS :: [Int] -> Int\nlcmS = foldl' lcm 1\n\nsolve :: Int -> Int\nsolve n = maximum $ \n [lcmS [a, b, c] | a <- [m..n], b <- [a..n], c <- [b..n]]\n where\n m = truncate ((fromIntegral (lcmS [n,n-1,n-2])) ** (1/3 :: Double)) - 1 \n\nsolve2 :: Int -> Int\nsolve2 1 = 1\nsolve2 2 = 2\nsolve2 4 = 12\nsolve2 n\n | odd n = lcmS [n, n-1, n-2]\n | n `mod` 3 == 0 = lcmS [n-1, n-2, n-3]\n | otherwise = lcmS [n, n-1, n-3]\n\nmain :: IO ()\nmain = do\n n <- readLn\n print $ solve2 n\n"}, {"source_code": "solve l1\n | n == 1 = 1 \n | otherwise = maximum [m*(m-1)*head [k | k <- reverse [1..m], gcd k (m*(m-1)) == 1] | m <- [(max 1 (n-7))..n]]\n where n = read l1 :: Integer\nmain = do\n l1 <- getLine\n putStrLn (show (solve l1))\n"}, {"source_code": "main = readLn >>= print . maxlcm3\n where maxlcm3 n\n \t\t | n < 3 \t\t = n\n\t\t\t | mod n 6 == 0 = lcm3l [n-1,n-2, n-3]\n\t\t\t | even n = lcm3l [n, n-1, n-3]\n\t\t\t | otherwise = lcm3l [n, n-1, n-2]\n\t\t\t where lcm3l [a,b,c] = a `lcm` b `lcm` c\n\n-- lcm :: [Int] -> Int\n-- lcm xs = lcm' [(d, divisor_degree d x) | d <- divisors x, x <- xs]\n\n\n-- divisor_degree :: Int -> Int -> Int \n-- divisor_degree d n\n-- | mod n d == 0 = 0\n-- | otherwise = 1 + (divisor_degree d (div n d))\n\n-- divisors :: Int -> [Int]\n-- divisors n = [d| d <- [1..(floor $ sqrt n)], (mod n d) == 0]\n\n-- prime_divisors :: Int -> [Int]\n-- prime_divisors n = [p|p <- divisors n, divisors p == [1,p]]\n\n-- prime_divisors :: Int -> [(Int, Int)]\n-- num2primedivisordegs n = [(p, divisor_degree d n) | d <- prime_divisors n]\n\n-- divdegpairs2lcm :: [(Int, Int)] -> [(Int, Int)] -> Int\n-- divdegpairs2lcm [] zs = zs\n-- divdegpairs2lcm zs [] = zs\n-- divdegpairs2lcm x:xs y:ys = if \n\n-- lcm' :: [(Int, Int)] -> \n-- lcm' ((div,deg):xs) = [ (div, max (deg)) | x <- xs]\n-- maxdegree (a, dega) (a, degb) = (a, max dega degb)\n\n----------------------------------------------------------------\n\n"}, {"source_code": "import Data.Word\n\nmain = do\n x <- getLine\n putStrLn $ show $ f (read x :: Word64)\n\nf :: (Integral a) => a -> a\nf x\n | x<3 = x\n | (mod x 2 == 0) && (mod x 3 == 0) = (x-1)*(x-2)*(x-3)\n | mod x 2 == 0 = x*(x-1)*(x-3)\n | otherwise = x*(x-1)*(x-2)\n"}, {"source_code": "f:: Integer -> Integer\nf n\n\t|(n `mod` 2 == 0) && (n `mod` 3 == 0) = (n-1)*(n-2)*(n-3)\n\t|n `mod` 2 == 0 = n*(n-1)*(n-3)\n\t|otherwise = n*(n-1)*(n-2)\n\nmain = do \n\tn <- readLn\n\tif n==1 then print $ 1 else \n\t\tif n==2 then print $ 2 else\n\t\t\tif n==3 then print $ 6 else\n\t\t\t\tif n==4 then print $ 12 else\n\t\t\t\t print $ (f n)"}], "negative_code": [{"source_code": "pr :: Integer -> Integer\npr 1 = 1\npr n = n-1\nmain = do\n sn <- getLine\n let n = read sn\n print ((pr (pr n))*(pr n)*n)"}, {"source_code": "pr :: Integer -> Integer\npr 1 = 1\npr n = n-1\nmain = do\n sn <- getLine\n let n = read sn\n let ans = max (div ((pr (pr n))*(pr n)*n) (gcd n (pr (pr n)))) (div ((pr (pr k))*(pr k)*k) (gcd k (pr (pr k)))) where \n k = pr n\n print ans"}, {"source_code": "pr :: Integer -> Integer\npr 1 = 1\npr n = n-1\nmain = do\n sn <- getLine\n let n = read sn\n print (div ((pr (pr n))*(pr n)*n) (gcd n (pr (pr n))))"}, {"source_code": "main = readLn >>= print . maxlcm3\n where maxlcm3 n\n\t\t\t | mod n 6 == 0 = lcm3l [n-1,n-2, n-3]\n\t\t\t | even n = lcm3l [n, n-1, n-3]\n\t\t\t | otherwise = lcm3l [n, n-1, n-2]\n\t\t\t where lcm3l [a,b,c] = a `lcm` b `lcm` c\n\n-- lcm :: [Int] -> Int\n-- lcm xs = lcm' [(d, divisor_degree d x) | d <- divisors x, x <- xs]\n\n\n-- divisor_degree :: Int -> Int -> Int \n-- divisor_degree d n\n-- | mod n d == 0 = 0\n-- | otherwise = 1 + (divisor_degree d (div n d))\n\n-- divisors :: Int -> [Int]\n-- divisors n = [d| d <- [1..(floor $ sqrt n)], (mod n d) == 0]\n\n-- prime_divisors :: Int -> [Int]\n-- prime_divisors n = [p|p <- divisors n, divisors p == [1,p]]\n\n-- prime_divisors :: Int -> [(Int, Int)]\n-- num2primedivisordegs n = [(p, divisor_degree d n) | d <- prime_divisors n]\n\n-- divdegpairs2lcm :: [(Int, Int)] -> [(Int, Int)] -> Int\n-- divdegpairs2lcm [] zs = zs\n-- divdegpairs2lcm zs [] = zs\n-- divdegpairs2lcm x:xs y:ys = if \n\n-- lcm' :: [(Int, Int)] -> \n-- lcm' ((div,deg):xs) = [ (div, max (deg)) | x <- xs]\n-- maxdegree (a, dega) (a, degb) = (a, max dega degb)\n\n----------------------------------------------------------------\n\n"}, {"source_code": "main = do\n x <- getLine\n putStrLn $ show $ f (read x :: Integer)\n\nf :: (Integral a) => a -> a\nf x\n | x<3 = x\n | mod x 2 == 0 = x*(x-1)*(x-3)\n | otherwise = x*(x-1)*(x-2)\n"}, {"source_code": "f:: Integer -> Integer\nf n\n\t|n `mod` 2 == 1 = n*(n-1)*(n-2)\n\t|n `mod` 3 /= 0 = n*(n-1)*(n-3)\n\t|otherwise = n*(n-1)*(n-2) `div ` 2\n\nmain = do \n\tn <- readLn\n\tif n==1 then print $ 1 else \n\t\tif n==2 then print $ 2 else\n\t\t\tif n==3 then print $ 6 else\n\t\t\t\tif n==4 then print $ 12 else\n\t\t\t\t print $ (f n)"}, {"source_code": "prime :: (Integral a, Ord a) => a -> a -> a -> Bool\nprime 1 cur comp = False\nprime n cur comp\n\t|cur >= comp = True\n\t|n `mod` 2 == 0 = False\n\t|otherwise = if n `mod` cur == 0 then False else prime n (cur+2) comp\n\nget :: Int -> Float -> [Integer]\nget 3 cur = []\nget x cur = if prime (truncate $ cur) 3 (truncate . sqrt $ cur) == True then (truncate cur):(get (x+1) (cur-1)) else get x (cur-1)\n\nmx :: (Ord a) => [a] -> a\nmx xs = foldl (\\acc x -> max acc x) (head xs) xs\n\nfind :: [Integer] -> Integer\nfind xs = mx $ [x*(kk y z) `div` (gcd x (kk y z)) | x <- [last $ xs..(head $ xs)], y <- [x+1 .. (head xs)], z <- [y+1 .. head xs]]\n\t\t\t\t\twhere kk y z = y*z `div` (gcd y z) \n\nmain = do \n\tn <- readLn\n\tif n==1 then print $ 1 else \n\t\tif n==2 then print $ 2 else\n\t\t\tif n==3 then print $ 6 else\n\t\t\t\tif n==4 then print $ 12 else\n\t\t\t\t print $ find $ ((truncate n):(get 0 n))"}, {"source_code": "f:: Integer -> Integer\nf n\n\t|n `mod` 2 == 1 = n*(n-1)*(n-2)\n\t|otherwise = n*(n-1)*(n-3)\n\nmain = do \n\tn <- readLn\n\tif n==1 then print $ 1 else \n\t\tif n==2 then print $ 2 else\n\t\t\tif n==3 then print $ 6 else\n\t\t\t\tif n==4 then print $ 12 else\n\t\t\t\t print $ (f n)"}, {"source_code": "main=readLn>>=print.solve\nsolve :: Integer -> Integer\nsolve x = x*y*z\n where\n y = head $ filter ((<2).gcd x) [x,x-1..1]\n z = head $ filter ((<2).gcd (x*y)) [y,y-1..1]"}, {"source_code": "solve l1\n | n == 1 = 1\n | otherwise = n * (n - 1) * head [n-k | k <- [1..], gcd n (n-k) == 1, gcd (n-1) (n-k) == 1]\n where n = read l1 :: Integer\nmain = do\n l1 <- getLine\n putStrLn (show (solve l1))"}, {"source_code": "solve l1\n | n == 1 = 1 \n | otherwise = n*(n-1)*(maximum [k `div` (gcd k (n*(n-1))) | k <- [1..n]])\n where n = read l1 :: Integer\nmain = do\n l1 <- getLine\n putStrLn (show (solve l1))"}], "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e"} {"source_code": "{-# OPTIONS_GHC -O2 #-}\n\nimport Data.Char (ord)\n\nparseInt = toInteger . foldl (\\acc c -> acc * 10 + ord c - 48) 0\n\nparseInts = fmap parseInt . words\n\npower :: Integer -> Integer\npower n\n | n == 0 = 1\n | even n = (ret * ret) `mod` mm\n | otherwise = (ret * ret) `mod` mm * 2 `mod` mm\n where\n ret = power (n `div` 2)\n mm = 998244353\n\nmain = do\n [n, m] <- fmap parseInts getLine\n print (power (n + m))\n", "positive_code": [{"source_code": "magic :: Integer\nmagic = 998244353\n\npower :: Integer -> Integer -> Integer -> Integer\npower base expo modulo\n | expo == 0 = 1\n | expo == 1 = base `mod` modulo\n | odd expo = base * (power base (expo - 1) modulo) `mod` modulo\n | otherwise = let root = power base (expo `div` 2) modulo\n in root * root `mod` modulo\n\nmain = do\n nums <- (map (\\tok -> read tok :: Integer) . words) <$> getLine\n putStrLn . show $ power 2 (sum nums) magic\n"}], "negative_code": [{"source_code": "magic :: Int\nmagic = 998244353\n\npower :: Int -> Int -> Int -> Int\npower base expo modulo\n | expo == 0 = 1\n | expo == 1 = base `mod` modulo\n | odd expo = base * (power base (expo - 1) modulo) `mod` modulo\n | otherwise = let root = power base (expo `div` 2) modulo\n in root * root `mod` modulo\n\nmain = do\n nums <- (map (\\tok -> read tok :: Int) . words) <$> getLine\n putStrLn . show $ power 2 (sum nums) magic\n"}], "src_uid": "8b2a9ae21740c89079a6011a30cd6aee"} {"source_code": "import qualified Data.Map.Strict as M\nimport qualified Data.Set as S\nimport Data.List (foldl')\nimport Data.Maybe (fromMaybe)\n\nmain = do\n bulbs <- getLine\n putStrLn $\n let onlyBulbs = filter (flip S.member (S.fromList \"RGBY!\")) bulbs\n positioned = zip [0..] onlyBulbs\n onlyValid = filter ((/=) '!' . snd) positioned\n zero = snd . head $ filter (\\(pos, char) -> (pos `mod` 4) == 0) onlyValid\n one = snd . head $ filter (\\(pos, char) -> (pos `mod` 4) == 1) onlyValid\n two = snd . head $ filter (\\(pos, char) -> (pos `mod` 4) == 2) onlyValid\n three = snd . head $ filter (\\(pos, char) -> (pos `mod` 4) == 3) onlyValid\n findColor pos =\n case pos `mod` 4 of\n 0 -> zero\n 1 -> one\n 2 -> two\n 3 -> three\n counted =\n foldl\n (\\map (pos, char) ->\n if char == '!' then\n M.insertWith (+) (findColor pos) 1 map\n else map)\n M.empty\n positioned\n in\n unwords . map show . map (fromMaybe 0 . flip M.lookup counted) $ ['R', 'B', 'Y', 'G']\n \n", "positive_code": [{"source_code": "import Data.List\nimport Data.Ord\nimport Data.Char\nfi = fromIntegral\n\ndecim [] = []\ndecim (x:xs) =x:decim (drop 3 xs)\n\t\ncalc seq = (color,num) where\n\tcolor = head $ filter (/='!') seq\n\tnum = length $ filter (=='!') seq\n\nsolve seq = unwords $ map show [r,b,y,g] where\t\n\tall= map (\\n->calc.decim.drop n $ seq) [0..3]\n\tr=snd.head.filter (\\(c,n)->c=='R') $ all\n\tb=snd.head.filter (\\(c,n)->c=='B') $ all\n\ty=snd.head.filter (\\(c,n)->c=='Y') $ all\n\tg=snd.head.filter (\\(c,n)->c=='G') $ all\n\t\nmain=do\n\td<-getLine\n\tputStrLn $ solve d\n"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Arrow\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport qualified Data.ByteString.Char8 as B\nimport Text.Printf\n\nreadInt = ( readLn :: IO Int )\nreadInts = map ( read :: String -> Int ) . words <$> getLine\n\ngetList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine\n\nwhich a b f = if f then a else b\nmp [ a, b ] = ( a, b )\n\nmain = do\n\ts <- getLine\n\tlet\n\t\tt = cycle $ head $ filter ( and . zipWith match s . cycle ) $ permutations chars\n\t\tr = broke s t\n\t\t[ a, b, c, d ] = map ( \\c -> length $ filter ( == c ) r ) chars\n\tprintf \"%d %d %d %d\\n\" a b c d\n\nchars = \"RBYG\"\n\nmatch c t\n\t| c == '!' = True\n\t| otherwise = c == t\n\nbroke [] _ = \"\"\nbroke ( a : s ) ( b : t )\n\t| a == '!' = b : broke s t\n\t| otherwise = broke s t\n"}], "negative_code": [], "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33"} {"source_code": "solve [n, x1, y1, x2, y2]\n | (dir x1 y1) == (dir x2 y2) = abs ((dist x1 y1) - (dist x2 y2))\n | otherwise = min summa (abs $ 4 * n - summa)\n where\n summa = (dist x1 y1) + (dist x2 y2)\n dist a b = a + b\n dir a b = a > b\n\n\nparse :: String -> [Int]\nparse = map read . words\n\nmain = interact (show . solve . parse)", "positive_code": [{"source_code": "module Main where\n\nimport Control.Monad\n\nmain = do\n [n, x1, y1, x2, y2] <- ( map read . words ) `liftM` getLine\n let p1 = linePos x1 y1\n p2 = linePos x2 y2\n linePos x y = if y == 0\n then x\n else if y == n\n then 3 * n - x\n else if x == n\n then n + y\n else 4 * n - y\n d = min ( abs $ p1 - p2 ) ( 4 * n - ( abs $ p1 - p2 ) )\n putStrLn $ show d\n"}, {"source_code": "dist :: Int -> (Int, Int) -> Int\ndist _ (0, y) = y\ndist n (x, 0) = 4 * n - x\ndist n (x, y)\n\t| y == n = n + x\n\t| otherwise = 3 * n - y\n\nmin_dist :: Int -> Int -> Int\nmin_dist n d = min d (4 * n - d)\n\nmain = do\n\tn:x1:y1:x2:y2:_ <- getLine >>= return . map read . words :: IO [Int]\n\tputStrLn . show $ min_dist n $ abs $ (dist n (x1, y1)) - (dist n (x2, y2))\n"}, {"source_code": "main = interact $ show . solve . (map (read :: String -> Int)) . words\nsolve [n,x1,y1,x2,y2] = min (w2 - w1) (4 * n + w1 - w2)\n where\n z1 = f x1 y1\n z2 = f x2 y2\n w1 = min z1 z2\n w2 = max z1 z2\n f x y\n | x == 0 = y\n | y == n = n + x\n | x == n = 3 * n - y\n | otherwise = 4 * n - x\n"}], "negative_code": [], "src_uid": "685fe16c217b5b71eafdb4198822250e"} {"source_code": "import System.IO\nimport qualified Data.List as L\n\nread_ints :: String -> [Int]\nread_ints x = map read (words x) :: [Int]\n\nmain = do\n\tln <- getLine\n\tlet [n,m] = read_ints ln\n\tputStr $ show $ if n == 1 then 1 else ( if m - 1 < n - m then m+1 else m-1 )\n", "positive_code": [{"source_code": "probability::Int->Int->Int->Double\nprobability n m a\n | m > a = fromIntegral((a + m) `div` 2) / fromIntegral(n)\n | m < a = 1.0 - fromIntegral((a + m ) `div` 2) / fromIntegral(n)\n | otherwise = 0.0\n\nsmall_candidates n m = if m - 1 >= 1 then [(m-1,probability n m (m-1))] else []\nlarge_candidates n m = if m + 1 <= n then [(m+1,probability n m (m+1))] else [] \ncandidates n m = small_candidates n m ++ large_candidates n m ++ [(m,0)]\n\ngetMax [] = (0,-1);\ngetMax (x:xs)\n | snd x >= snd candidate = x\n | otherwise = candidate\n where\n candidate = getMax xs\n\nans::Int->Int->Int\nans n m = fst(getMax(candidates n m))\n\nmain = do\n input <- getLine\n let [n,m] = [read x::Int | x <- words input]\n print(ans n m)"}, {"source_code": "-- Codeforces Round #316 (Div. 2) - Problem B: Simple Game (https://codeforces.com/problemset/problem/570/B)\n\n-- Corner case: só há uma escolha possível\nsolve 1 _ = 1\n-- A resposta deve ser um dentre os dois vizinhos à esquerda ou a direita de m, \n-- o mais distante dos extremos dentre eles\nsolve n m | (n - m) > (m - 1) = m + 1\n | otherwise = m - 1\n\nmain = do\n line <- getLine\n let [n, m] = map read $ words line :: [Int]\n print $ solve n m\n"}, {"source_code": "main :: IO()\nmain = do\n [n,m] <- fmap (map (\\x -> read x::Int) . words) getLine\n if n==1 then (print 1) else if m > (n `quot` 2) then print (m-1) else print (m+1)"}, {"source_code": "import Control.Applicative\nimport Control.Arrow\nimport Control.Monad\nimport Data.List\nimport Data.Function\n\nreadInts :: IO [Int]\nreadInts = map read . words <$> getLine\n\nfdiv = (/) `on` fromIntegral\n\nmain = do\n [n, m] <- readInts\n print $ if n `fdiv` 2 < fromIntegral m then max 1 (m - 1)\n else min n (m + 1)\n"}, {"source_code": "-- Codeforces 570B\n\nmain :: IO ()\nmain = do\n [n, m] <- fmap (map read . words) getLine :: IO [Integer]\n print $ if n == 1 then 1 else if m <= (n `div` 2) then m+1 else m-1\n"}, {"source_code": "main = interact $ show . f . map read . words\nf (1:m:k) = 1\nf (n:1:k) = 2\nf (n:m:k) = if n==m then n-1 else (if n-m-1>m-1-1 then m+1 else m-1) "}, {"source_code": "import Control.Applicative\nimport Control.Monad\n\n-----\n\n--be carefull with the type inference\n\n-----\n\n---------\n-- get space separated something\n\ngetListSp :: Read a => IO [a] \ngetListSp = (map read . words) <$> getLine\n\n---------\n\n\n\n---------\n-- output [a] in space separated form\n\nputListSp :: Show a => [a] -> IO()\nputListSp ls = putStrLn $ show $ unwords $ map show ls\n\n---------\n\n\n--------\n-- read an integer N, get N lines, make a list consist of them\n\ngetListLn :: Read a => IO [a]\ngetListLn = do n <- readLn\n s <- replicateM n getLine\n\t return (map read s)\n--------\n\n\nmain = do [n, m] <- getListSp\n print $ solve n m\n\nsolve:: Int -> Int -> Int\nsolve 1 _ = 1\nsolve n m | (n-m) <= (m-1) = m-1\n | otherwise = m+1"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . toTuple . map read . words\n\nsolve :: (Int, Int) -> Int\nsolve (n, m) | m * 2 <= n = m + 1\n | n == 1 = 1\n | otherwise = m - 1\n\ntoTuple :: [a] -> (a, a)\ntoTuple xs = (head xs, xs !! 1)\n"}, {"source_code": "main = interact (show . solve . map read . words)\nsolve [1,1] = 1\nsolve [n,m] | m <= n`div` 2 = m+1\n | otherwise = m-1\n"}], "negative_code": [{"source_code": "main :: IO()\nmain = do\n [n,m] <- fmap (map (\\x -> read x::Int) . words) getLine\n if m > (n `quot` 2)\n then print (m-1)\n else print (m+1)"}, {"source_code": "-- Codeforces 570B\n\nmain :: IO ()\nmain = do\n [n, m] <- fmap (map read . words) getLine :: IO [Integer]\n print $ if n == 1 then 1 else if m >= ((n+1) `div` 2) then m-1 else m+1\n"}, {"source_code": "-- Codeforces 570B\n\nmain :: IO ()\nmain = do\n [n, m] <- fmap (map read . words) getLine :: IO [Int]\n print $ if n == 1 then 1 else if m <= (n+1) `div` 2 then m+1 else m-1\n"}, {"source_code": "-- Codeforces 570B\n\nmain :: IO ()\nmain = do\n [n, m] <- fmap (map read . words) getLine :: IO [Int]\n print $ if m <= (n+1) `div` 2 then m+1 else m-1\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Int] -> Int\nsolve [n, m] | m * 2 <= n = m + 1\n | otherwise = m - 1\nsolve _ = undefined\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Int] -> Int\nsolve [n, m] | m * 2 < n = (n + m) `div` 2\n | otherwise = (m + 1) `div` 2\nsolve _ = undefined\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Int] -> Int\nsolve [n, m] | m * 2 < n = m + 1\n | otherwise = m - 1\nsolve _ = undefined\n"}, {"source_code": "main = interact (show . solve . map read . words)\nsolve [n,m] | m <= n`div` 2 = m+1\n | otherwise = m-1\n"}, {"source_code": "main = interact (show . solve . map read . words)\nsolve [n,m] | m < n`div` 2 = m+1\n | otherwise = m-1\n"}, {"source_code": "-- Codeforces Round #316 (Div. 2) - Problem B: Simple Game (https://codeforces.com/problemset/problem/570/B)\n\n-- Corner case: só há uma escolha possível\nsolve 1 _ = 1\n-- A resposta deve ser um dentre os dois vizinhos à esquerda ou a direita de m, \n-- o mais distante dos extremos dentre eles\nsolve n m | (n - m - 1) > (m - 1) = m + 1\n | otherwise = m - 1\n\nmain = do\n line <- getLine\n let [n, m] = map read $ words line :: [Int]\n print $ solve n m\n"}], "src_uid": "f6a80c0f474cae1e201032e1df10e9f7"} {"source_code": "shortestRoute :: Int -> Int -> Int -> Int\nshortestRoute d1 d2 d3 =\n minimum [(2*d1 + 2*d2), (d1 + d2 + d3), 2*d1+2*d3, 2*d2+2*d3]\n\nparseSpace :: String -> [Int]\nparseSpace ws = map read (words ws) :: [Int]\n\nmain :: IO ()\nmain = do\n [d1, d2, d3] <- fmap parseSpace getLine\n print $ shortestRoute d1 d2 d3", "positive_code": [{"source_code": "module Main where\n\nmain :: IO ()\nmain = do\n\tinp <- getLine\n\tlet [d1, d2, d3] = readInts inp\n\tprint $ optimize d1 d2 d3\n\nreadInts :: String -> [Int]\nreadInts = map read . words\n\noptimize :: Int -> Int -> Int -> Int\noptimize d1 d2 d3 = minimum [2*(d1+d2), 2*(d1+d3), 2*(d2+d3), d1+d2+d3]\n"}, {"source_code": "import Data.List\n\nmain :: IO()\nmain = print . solve . map read . words =<< getLine\n\nsolve :: [Int] -> Int\nsolve [a, b, c] = minimum [a + a + b + b, a + c + b, a + c + c + a, b + c + c + b]\n"}, {"source_code": "max' [x] = x\nmax' (x:xs) = max x (max' xs)\n\nmain = do\n line <- getLine\n let [d1, d2, d3] = map read $ words line :: [Int]\n let d4 = min d1 (d2+d3)\n let d5 = min d2 (d1+d3)\n let d6 = min d3 (d1+d2)\n let ans = d4 + d5 + d6\n print ans\n"}, {"source_code": "solve :: [Integer] -> Integer\nsolve [d1, d2, d3] = minimum [(d1 + d2 + d3), (2 * (d1 + d2)), (2 * (d1 + d3)), (2 * (d2 + d3))]\n\nmain = getContents >>= putStrLn . show . solve . map read . words\n"}, {"source_code": "main = do\n [a, b, c] <- fmap (map read . words) getLine\n\n print $ minimum [2*a+2*b, a+b+c, 2*a+2*c, 2*b+2*c]\n"}, {"source_code": "--fast read\nimport qualified Data.ByteString.Char8 as B\nimport Data.Maybe\nimport Control.Applicative\nreadInts a = fmap (map (fst . fromJust)) $ fmap (map B.readInt) $ fmap B.words a\nreadLists = readInts $ B.getLine\nreadLLists = fmap (map (fst . fromJust)) $ fmap (map B.readInt) $ fmap B.lines $ B.getContents\nreadMatrix = fmap readInts $ fmap B.lines $ B.getContents \nmain = do\n [d0,d1,d2] <- readLists\n print $ minimum [2 * (d0 + d1),d0 + d1 + d2,2*(d0+d2),2*(d1+d2)]\n"}, {"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = solve =<< (map (fst.fromJust.C.readInt).C.words <$>C.getLine)\nsolve [x,y,z] = print $ minimum [2*(x+y), x+y+z, 2*(x+z), 2*(z+y)]"}, {"source_code": "main=(print.fun.map read.words)=<d=d;f c d = c;g c d|c read x::Int) $ words ds"}, {"source_code": "import Control.Applicative\nimport Data.List\n\n\n\nmain = do\n [a,b,c]<- map read <$> words <$> getLine ::IO [Int]\n print $ minimum [(a+b+c), (2*a+2*b), (2*a+2*c),(2*b+2*c)]\n"}, {"source_code": "main :: IO ()\nmain = print . solve . map read . words =<< getContents\n\nsolve :: [Int] -> Int\nsolve [ d1, d2, d3 ] = minimum [ d1 + d2 + d3, 2 * (d1 + d2), 2 * (d2 + d3), 2 * (d3 + d1) ]\nsolve _ = undefined\n"}, {"source_code": "main = interact (show . solve . map read . words)\nsolve [d1,d2,d3] = minimum [d1+d3+d2, 2*(d1+d2), 2*(d1+d3), 2*(d2+d3)]"}, {"source_code": "module Main where\nimport Data.Functor\n\nsolve :: [Int] -> Int\nsolve [x,y,z] = minimum [2 * (x + z), 2*(y+z), 2 * (x + y), (x + y + z)]\n\nmain :: IO ()\nmain = print =<< (solve . map read . words <$> getLine)\n"}, {"source_code": "main = interact $ show . solve . map read . words\nsolve [d1,d2,d3] = minimum [d1*2+d2*2, d1+d2+d3, d1*2+d3*2, d2*2+d3*2]"}, {"source_code": "import Control.Applicative\n \n \n\nmain= do\n\t[d1,d2,d3]<- map read .words <$> getLine\n\tprint $ minimum [ (2*d1+2*d2) ,(d1+d2+d3), 2*d2+2*d3, 2*d1+2*d3]\n \t "}, {"source_code": "import Data.List (sort)\n\nprocess:: [Int] -> Int\nprocess ds = min (sum ds) (2 * (d1 + d2))\n where d1:d2:_ = sort ds\n\nreadInt :: String -> Int\nreadInt = read\n\nmain = do\n ds <- fmap (map readInt.words) getLine\n print $ process ds"}], "negative_code": [{"source_code": "max' [x] = x\nmax' (x:xs) = max x (max' xs)\n\nmain = do\n line <- getLine\n let [d1, d2, d3] = map read $ words line :: [Int]\n let d4 = min d1 (d2+d3)\n let d5 = min d2 (d1+d3)\n let d6 = min d3 (d1+d2)\n let ans = 2 * max' [d4, d5, d6]\n print ans\n"}, {"source_code": "solve [d1, d2, d3] = min (d1 + d2 + d3) (2 * (d1 + d2))\n\nmain = getContents >>= putStrLn . show . solve . map read . words\n"}, {"source_code": "main = do\n [a, b, c] <- fmap (map read . words) getLine\n\n print $ minimum [2*a+2*b, a+b+c]\n"}, {"source_code": "--fast read\nimport qualified Data.ByteString.Char8 as B\nimport Data.Maybe\nimport Control.Applicative\nreadInts a = fmap (map (fst . fromJust)) $ fmap (map B.readInt) $ fmap B.words a\nreadLists = readInts $ B.getLine\nreadLLists = fmap (map (fst . fromJust)) $ fmap (map B.readInt) $ fmap B.lines $ B.getContents\nreadMatrix = fmap readInts $ fmap B.lines $ B.getContents \nmain = do\n [d0,d1,d2] <- readLists\n print $ if d0 + d1 < d2 then 2 * (d0 + d1) else d0 + d1 + d2\n"}, {"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = solve =<< (map (fst.fromJust.C.readInt).C.words <$>C.getLine)\nsolve [x,y,z] = print $ minimum [2*(x+y), x+y+z]"}, {"source_code": "import Control.Applicative\nimport Data.List\n\n\n\nmain = do\n [a,b,c]<- map read <$> words <$> getLine ::IO [Int]\n print $ min (a+b+c) (2*a+2*b)\n"}, {"source_code": "shortestRoute :: Int -> Int -> Int -> Int\nshortestRoute d1 d2 d3 = min (2*d1 + 2*d2) (d1 + d2 + d3)\n\nparseSpace :: String -> [Int]\nparseSpace ws = map read (words ws) :: [Int]\n\nmain :: IO ()\nmain = do\n [d1, d2, d3] <- fmap parseSpace getLine\n print $ shortestRoute d1 d2 d3"}, {"source_code": "import Control.Applicative\n \n \n\nmain= do\n\t[d1,d2,d3]<- map read .words <$> getLine\n\tprint $ min (2*d1+2*d2) (d1+d2+d3)\n \t "}, {"source_code": "process:: [Int] -> Int\nprocess [d1, d2, d3]\n | d1 + d2 < d3 = 2 * (d1 + d2)\n | d2 + d3 < d1 = 2 * (d2 + d3)\n | d3 + d1 < d1 = 2 * (d3 + d1)\n | otherwise = d1 + d2 + d3\n\nreadInt :: String -> Int\nreadInt = read\n\nmain = do\n ds <- fmap (map readInt.words) getLine\n print $ process ds"}], "src_uid": "26cd7954a21866dbb2824d725473673e"} {"source_code": "lucky n = all (\\i -> elem i \"47\") $ show n\n\n-- Snippet: divisors\ndivisors1 i n\n | n == i * i = [i]\n | n < i * i = []\n | mod n i == 0 = i : (div n i) : divisors1 (i + 1) n\n | otherwise = divisors1 (i + 1) n\n\ndivisors = divisors1 1\n\nmain = do\n n <- readLn\n putStrLn $ if any lucky $ divisors n then \"YES\" else \"NO\"\n", "positive_code": [{"source_code": "import Control.Applicative\nimport Data.Char\nimport Data.List\n \n\nmain= do\n \ts<-read <$> getLine ::IO Int\n\tputStrLn $ if (any (\\z-> mod s z==0) [4,7,44,47,74,77,444,447,477,744,747,774,777]) then \"YES\" else \"NO\""}, {"source_code": "{-\nA. Lucky Division\n==================\ntime limit per test: 2 seconds\nmemory limit per test: 256 megabytes\ninput: standard input\noutput: standard output\n\nPetya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.\n\nInput\n------\nThe single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.\n\nOutput\n------\nIn the only line print \"YES\" (without the quotes), if number n is almost lucky. Otherwise, print \"NO\" (without the quotes).\n\nSample test(s)\n---------------\ninput\n47\noutput\nYES\n\ninput\n16\noutput\nYES\n\ninput\n78\noutput\nNO\n\n-}\nimport Data.List (nub, sort, findIndices)\nimport Data.Map (toList, fromListWith)\nimport Control.Applicative ((<$>), (<*>))\nimport Control.Monad (when, forM_, replicateM)\nimport Data.Array.ST (newArray, readArray, writeArray, runSTUArray)\nimport Data.Array.Unboxed (UArray, assocs)\n\nsieve :: Int -> UArray Int Bool\nsieve n = runSTUArray $ do\n let maxP = floor . sqrt $ fromIntegral n\n sieveTF <- newArray (2, n) True \n forM_ [2..maxP] $ \\p -> do\n isPrime <- readArray sieveTF p\n when isPrime $ do\n forM_ [p*p, p*p+p .. n] $ \\q -> do\n writeArray sieveTF q False\n return sieveTF\n\nprimesTo :: Int -> [Int]\nprimesTo n\n | n < 2 = []\n | otherwise = [i | (i,True) <- assocs $ sieve n]\n\ncartesianProduct :: [[a]] -> [[a]]\ncartesianProduct = foldr (\\xs acc -> (:) <$> xs <*> acc) [[]]\n\ntally :: Ord a => [a] -> [(a, Int)]\ntally xs = toList $ fromListWith (+) [(x, 1)| x <- xs]\n\nfactorInteger :: Int -> [(Int, Int)]\nfactorInteger 0 = [(0, 1)]\nfactorInteger 1 = [(1, 1)]\nfactorInteger n = tally $ factor n\n where\n ps = (primesTo . round . sqrt . fromIntegral) n\n factor 1 = []\n factor p = k : factor (p `div` k)\n where \n ds = dropWhile (\\q -> p `mod` q /= 0) ps\n k = if null ds then p else head ds\n\ndivisors :: Int -> [Int]\ndivisors 1 = [1]\ndivisors n = sort [product xs | xs <- cartesianProduct factors]\n where factors = [ map (n^) [0..pow] | (n, pow) <- factorInteger n ]\n\n---- \n\nisAlmostLucky :: Int -> Bool\nisAlmostLucky x = isLucky x || \n ( (not . null) luckyDs && \n any (\\k -> x `mod` k == 0) luckyDs )\n where luckyDs = filter isLucky $ divisors x\n\nisLucky :: Int -> Bool\nisLucky x = s == \"47\" || s == \"4\" || s == \"7\"\n where s = (sort . nub . show) x\n\nboolToStr :: Bool -> String\nboolToStr True = \"YES\"\nboolToStr False = \"NO\"\n\nmain = do \n input <- getLine\n let x = read input\n (putStrLn . boolToStr . isAlmostLucky) x\n\n"}, {"source_code": "main = do\n m <- readLn\n if (allu m) then putStrLn \"YES\" else putStrLn \"NO\"\nlu :: Int -> Bool\nlu x = and $ map (not. (`elem` (show x))) ['1','2','3','5','6','8','9','0']\nst :: Int -> [Int]\nst x = filter lu [1..(floor . fromIntegral $ x)]\nallu :: Int -> Bool\nallu x = or $ map (\\y -> mod x y == 0) (st x)"}, {"source_code": "lucky = filter (\\x -> all (\\c -> c == '4' || c == '7') $ show x) $ [1..2000]\nmain = interact $ (\\x -> if any (\\y -> mod x y == 0) lucky then \"YES\\n\" else \"NO\\n\").read\n"}, {"source_code": "factorize :: Int -> [Int]\nfactorize = factorize' 1 \n where\n factorize' a x\n | a * a > x = []\n | factor a x = [a, x `div` a] ++ factorize' (a + 1) x\n | otherwise = factorize' (a + 1) x\n factor a x = x `mod` a == 0\n\nmain :: IO ()\nmain = do\n condition <- any (all (\\x -> '4' == x || '7' == x) . show) . factorize . (read :: String -> Int) <$> getLine\n putStrLn $ if condition then \"YES\" else \"NO\""}, {"source_code": "isLucky = all (`elem` ['4','7']) . show\ndivs n = n : filter ((== 0) . mod n) [2 .. n `div` 2]\nyesno b = if b then \"YES\" else \"NO\"\nmain = interact $ yesno . any isLucky . divs . read"}, {"source_code": "import Data.List\nimport Data.Char\n\ngetInt :: IO Int\ngetInt = readLn\n\nreadInts :: IO [Int]\nreadInts = fmap (map read.words) getLine\n\nmain = do\n n <- getInt\n putStrLn (if (final n == True) then \"YES\" else \"NO\")\n\nfinal :: Int -> Bool\nfinal n = foldl' (\\acc x -> if n `mod` x == 0 then True else acc) False (before n)\n\nbefore :: Int -> [Int]\nbefore n = takeWhile (<=n) gen47s\n\ngen47s :: [Int]\ngen47s = 4:7:map create [1..]\n where create n = fn (gen47s!!n)\n fn k\n | k == 0 = 4\n | k `mod` 10 == 7 = 4 + (fn(k `div` 10)*10)\n | k `mod` 10 == 4 = k - 4 + 7\n"}, {"source_code": "import Control.Monad\nimport Control.Applicative\nmain = getLine >>= putStrLn.answer.solve.read\n\nanswer cond = if cond then \"YES\" else \"NO\"\nsolve i = elem 0 $ map (mod i) $ filter (all (flip elem \"47\").show) [1..1000]\n"}, {"source_code": "luckys :: Int -> [String]\nluckys 0 = []\nluckys n = [x:xs | xs <- []:luckys (n-1), x <- \"47\"]\n\nprocess :: Int -> Bool\nprocess n = any (\\x -> (n `mod` x) == 0) . map readInt $ luckys d\n where d = length . show $ n\n\nreadInt :: String -> Int\nreadInt = read\n\nmain :: IO ()\nmain = do\n n <- fmap readInt getLine\n putStrLn $ [\"NO\",\"YES\"] !! fromEnum (process n)"}, {"source_code": "main = (readLn :: IO Integer) >>= putStrLn . s\n\ns :: Integer -> String\ns n | any (all (`elem` \"47\") . show) [t | t <- [1..n], n `mod` t == 0] = \"YES\"\n | otherwise = \"NO\""}, {"source_code": "\ntoInt :: String -> Int\ntoInt = read\n\nisAlmostLucky :: Int -> String\nisAlmostLucky n\t= \tif any (\\x -> ( n `rem` x ) == 0 ) ( map (toInt) [ s | let l = [\"\", \"4\", \"7\"], x <- l, y <- l, z <- l, let s = x ++ y ++ z, length s > 0 ] )\n\t\t\t\t\tthen \"YES\"\n\t\t\t\t\telse \"NO\"\n\t\t\nmain = do\n\tstr <- getLine\n\tputStrLn $ isAlmostLucky $ toInt str\n\t\n\n\n\n\n\n\n"}, {"source_code": "almostLucky :: Int -> String\nalmostLucky x\n | any lucky divisors = \"YES\"\n | otherwise = \"NO\"\n where divisors = [y | y <- [1..x], x `rem` y == 0]\n\nlucky :: Int -> Bool\nlucky = all (`elem` \"47\") . show\n\nsolve :: String -> String\nsolve = almostLucky. read . head . words\n\nmain :: IO ()\nmain = interact solve"}, {"source_code": "luckynum = [x|x <- [1..1000], all (`elem` \"47\").show $ x]\nf x = if or [x `mod` y == 0| y<-luckynum] then \"YES\" else \"NO\"\nmain = interact $ f.read\n\n"}, {"source_code": "luckies :: [Int]\nluckies = map read stream\n where\n stream = [\"4\", \"7\"] ++ [y ++ x | y <- stream, x <- [\"4\", \"7\"]]\n\nsolve x = \n or $ map ((== 0) . (mod x)) divisors\n where\n divisors = takeWhile (<= x) luckies\n\npprint True = \"YES\"\npprint False = \"NO\"\n\nparse = read\n\nmain = (putStrLn . pprint . solve . parse =<< getContents)\n"}, {"source_code": "main::IO()\nmain = getLine >>= return . calc . read >>= putStrLn\n\ncalc::Int->String\ncalc n | any (\\a->n `mod` a == 0) [4,7,44,47,74,77,444,447,474,477,744,747,774,777] = \"YES\"\n | otherwise = \"NO\""}, {"source_code": "data Answer = YES | NO deriving (Show)\n\nhappy :: [Integer]\nhappy = [4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777]\n\ngetAnswer :: Integer -> Answer\ngetAnswer n = if length [x | x <- happy, n `mod` x == 0] > 0\n then YES\n else NO\n\nmain = do\n n <- getLine\n print $ getAnswer (read n)"}, {"source_code": "import Control.Monad\n\nfactors :: Int -> [Int]\nfactors n = concat $ [ [i,n `div` i] | i <- [1..truncate $ sqrt $ fromIntegral n], n `mod` i == 0]\n\n\nisLucky n = all (`elem` \"47\") rep\n where\n rep = show n\n\n\nalmostLucky n = any isLucky $ factors n\n\n\nmain = do\n aa <- readLn :: IO Int\n putStrLn $ if almostLucky aa then \"YES\" else \"NO\"\n"}, {"source_code": "module Main (main)\n where\n\n\ndivisors :: Int -> [Int]\ndivisors n = concatMap (\\x -> [x, n `div` x]) .\n filter (\\x -> n `mod` x == 0) .\n takeWhile (\\x -> x*x <= n) $ [1..]\n\nmain :: IO ()\nmain = putStrLn . toYesNo . isAlmostLucky =<< readLn\n where isAlmostLucky = any isLucky . divisors\n isLucky = all (\\d -> d == '4' || d == '7') . show\n toYesNo True = \"YES\"\n toYesNo False = \"NO\""}, {"source_code": "isLuckyDigit :: Int -> Bool\nisLuckyDigit c = c `elem` [4, 7]\n\nisLuckyNumber :: Int -> Bool\nisLuckyNumber = and . map isLuckyDigit . digits\n\ndigits' :: Int -> [Int]\ndigits' 0 = []\ndigits' n = cifra : digits' resto\n where cifra = n `rem` 10\n resto = n `div` 10\n\ndigits :: Int -> [Int]\ndigits = reverse . digits'\n\nisAlmostLucky :: Int -> Bool\nisAlmostLucky n\n | isLuckyNumber n = True\n | divisibleLucky n = True\n | otherwise = False\n\ndivisibleLucky :: Int -> Bool\ndivisibleLucky n = or $ map (\\x -> n `rem` x == 0) (luckies n)\n\nsquareRoot :: Int -> Int\nsquareRoot = floor . sqrt . fromIntegral\n\nluckies :: Int -> [Int]\nluckies n = [j | j <- [1..n], isLuckyNumber j]\n\nanswer :: Bool -> String\nanswer True = \"YES\"\nanswer False = \"NO\"\n\nmain = interact (answer . isAlmostLucky . (\\x -> read x :: Int))\n"}, {"source_code": "main=interact $ isAlmostHappy.read\nbase = [4,7,47,74,44,77,444,447,477,777,774,744,747,474]\n\nisAlmostHappy n = if or (map (\\x->mod n x ==0) base) then \"YES\" else \"NO\""}, {"source_code": "isLucky :: Int -> Bool\nisLucky 0 = False\nisLucky 4 = True\nisLucky 7 = True\nisLucky x\n | xmod == 4 = isLucky xdiv\n | xmod == 7 = isLucky xdiv\n | otherwise = False\n where xmod = x `mod` 10\n xdiv = x `div` 10\n\nisHalfLucky :: Int -> Int -> Bool\nisHalfLucky y x\n | x == y = False\n | isLucky y && x `mod` y == 0 = True\n | isLucky x = True\n | otherwise = isHalfLucky (y + 1) x\n\nmain = getLine >>= return . isHalfLucky 1 . read >>= \\inp -> putStrLn $ if inp then \"YES\" else \"NO\"\n"}, {"source_code": "luckyList = [4, 7] ++ concat [ [x*10+4, x*10+7] | x <- luckyList ]\n\nsolve x = any (\\y -> x `mod` y == 0) $ takeWhile (<=x) luckyList\n\nshowYN True = \"YES\"\nshowYN False = \"NO\"\n\nmain = interact $ (++\"\\n\") . showYN . solve . read\n\n-- vim: set expandtab:\n"}, {"source_code": "\n\n\nisLucky num\n | mod num 4 == 0 = True\n | mod num 7 == 0 = True\n | mod num 44 == 0 = True\n | mod num 47 == 0 = True\n | mod num 77 == 0 = True\n | mod num 444 == 0 = True\n | mod num 447 == 0 = True\n | mod num 474 == 0 = True\n | mod num 477 == 0 = True\n | mod num 744 == 0 = True\n | mod num 747 == 0 = True\n | mod num 774 == 0 = True\n | mod num 777 == 0 = True\n | otherwise = False\n\n\nmain = do\n cv <- getLine\n let conv = (read cv)::Int\n let ans = (isLucky conv)\n if ans\n then putStrLn \"YES\"\n else putStrLn \"NO\"\n\n\n\n \n"}, {"source_code": "import Data.Char\nimport Data.List\n\n\nluck x xs = [c | c <-xs, x `mod` c == 0] \n\nisLuck x \n | null $ luck x [4,7,44,47,74,77,444,447,474,477,744,747,774,777] = False\n | otherwise = True\n\n\nsolve x\n | isLuck x = \"YES\"\n | otherwise = \"NO\"\n\n\nmain = do\n s <- getLine\n putStrLn $ solve $ read s \n"}, {"source_code": "isLucky :: Int -> Bool\nisLucky x = (== []) . filter (\\x -> x /= '4' && x /= '7') . show $ x\n\ndivisors :: Int -> [Int]\ndivisors n = filter (\\x -> n `rem` x == 0) $ [1 .. (n - 1)]\n\nmain = do\n line <- getLine\n let n = (read :: String -> Int) line\n let luckyDivisors = map isLucky (divisors n)\n\n putStrLn (if (isLucky n) then \"YES\" else if (any (== True) luckyDivisors) then \"YES\" else \"NO\")\n"}, {"source_code": "main = do\n n <- readLn\n \n let\n t = ['4', '7']\n ls = [4, 7] ++\n map read [[a, b] | a <- t, b <- t] ++ \n map read [[a, b, c] | a <- t, b <- t, c <- t]\n \n l a = any (\\l -> a `mod` l == 0) ls\n \n putStrLn $ if l n then \"YES\" else \"NO\""}, {"source_code": "main = do \n\ta <- getLine\n\tif lucky $ read a \n\t\tthen putStrLn \"YES\"\n\t\telse putStrLn \"NO\"\t\n\t\nlucky :: (Integral a) => a -> Bool \nlucky x \n\t| check x = True\n\t| any (lucky) $ [y | y <- [1..x-1], mod x y == 0] = True\n\t| otherwise = False \n\ncheck :: (Integral a) => a -> Bool\ncheck x\n\t| x == 0 = True\n\t| (let y = mod x 10 in y == 4 || y == 7) && (check $ div x 10) = True\n\t| otherwise = False\n"}, {"source_code": "main = do \n\ta <- getLine\n\tif lucky $ read a \n\t\tthen putStrLn \"YES\"\n\t\telse putStrLn \"NO\"\t\n\t\nlucky :: (Integral a) => a -> Bool \nlucky x \n\t| check x = True\n\t| any (lucky) $ [y | y <- [1..x-1], x `mod` y == 0] = True\n\t| otherwise = False \n\ncheck :: (Integral a) => a -> Bool\ncheck x\n\t| x == 0 = True\n\t| (let y = x `mod` 10 in y == 4 || y == 7) && (check $ x `div` 10) = True\n\t| otherwise = False\n"}, {"source_code": "main = interact (lucky.read) \nlucky x \n\t| all (`elem` \"47\") . show $ x = \"YES\" \n\t| any ((==\"YES\").lucky) $ [y | y <- [1..x-1], mod x y == 0] = \"YES\"\n\t| otherwise = \"NO\"\n"}, {"source_code": "-- Lucky\nisLuck n | (n == 0) = True\n | (is) = isLuck (div n 10)\n\t\t | otherwise = False\n\twhere m = mod n 10\n\t is = ((m == 4)||(m == 7))\n\t\t \nisAnswer n = foldr (||) False (map (isLuck) [i | i <- [4 .. n], (mod n i == 0)])\n\nmain = do\n\t\t\tn <- readLn :: IO Int\n\t\t\tif (isAnswer n) then putStrLn \"YES\"\n\t\t\t else putStrLn \"NO\""}, {"source_code": "{-# LANGUAGE BlockArguments #-}\n\nimport Control.Arrow\nimport Data.List\n\nmain = do { x <- getLine\n ; putStrLn $ (read >>> solve) x \n }\n\nluckies :: [Int]\nluckies = [4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777]\n\nsolve :: Int -> String\nsolve x = let b = foldr (\\y a -> a || x `mod` y == 0) False luckies\n in if b then \"YES\" else \"NO\""}, {"source_code": "import Data.List\nf x = filter (\\x -> (show x) `intersect` \"12356890\" == []) [1..x]\nmain = do \n\tstr <- getLine\n\tif (filter (\\a -> (read str) `mod` a == 0) (f (read str))) /= [] then putStrLn \"YES\" else putStrLn \"NO\""}, {"source_code": "module Main where\nimport Data.Char\n\nlst :: [Int]\nlst = [x | x <- [1..1000], isLucky x]\n\nisLucky :: Int -> Bool\nisLucky x = let s = show x\n in all (flip elem ['4', '7']) s\n\nmain :: IO ()\nmain = interact $ solve . lines\n\nsolve :: [String] -> String\nsolve s = let n = read (head s) :: Int\n in\n case any (\\x -> n `mod` x == 0) lst of\n True -> \"YES\"\n False -> \"NO\"\n"}, {"source_code": "import Data.Set\n\nmain = do\n aux <- getLine\n let n = read aux :: Int\n let xs = [x | x <- [4,5..n], lucky x, mod n x == 0]\n let ans = if (length xs > 0) then \"YES\" else \"NO\"\n putStrLn ans\n\n\n\nmkUnique = toList . fromList\n\nlucky n = (length (mkUnique (show n)) == 2) && ((((mkUnique (show n)) !! 0 == '4') && (mkUnique (show n) !! 1 == '7')) || ((mkUnique (show n) !! 0 == '7') && ((mkUnique (show n) !! 1 == '4')))) || ((length (mkUnique (show n)) == 1) && ((head (mkUnique (show n)) == '4') || (head (mkUnique (show n)) == '7')))\n \n"}, {"source_code": "good :: Int -> Bool\ngood a\n\t| a == 0 = True\n\t| (((a `mod` 10 == 4) || (a `mod` 10 == 7)) && (good (a `div` 10))) = True\n | otherwise = False\n\nallright :: [Int] -> Bool\nallright [] = False\nallright (x:xs) \n\t| ( (allright xs) || (good x) ) = True\n\t| otherwise = False\n\ngen :: Int -> Int -> [Int]\ngen a n\n\t| ((a>0) && (n `mod` a) == 0 ) = (gen (a-1) n) ++ [a]\n\t| ((a>0) && ((n `mod` a) > 0)) = gen (a-1) n\n\t| otherwise = []\n\nlucky :: Int -> Bool\nlucky a\n\t| allright (gen a a) = True\n\t| otherwise = False\n\nhandle :: [String] -> [[String]]\nhandle [n]\n\t| lucky (read n :: Int) = [[\"YES\"]]\n\t| otherwise = [[\"NO\"]]\n\nmain :: IO ()\nmain = interact $ unlines . map unwords . handle . words\n"}, {"source_code": "import Control.Applicative\n\nluckys :: Int -> [Int]\nluckys n = drop 1 $ gen 0\n where gen x | x > n = []\n | otherwise = x : gen (x * 10 + 4) ++ gen (x * 10 + 7)\n\nmain = do\n n <- read <$> getLine\n putStrLn $ case any (\\x -> n `mod` x == 0) $ luckys n of\n True -> \"YES\"\n False -> \"NO\"\n"}, {"source_code": "main :: IO ()\nmain = do s <- getLine\n-- \t print (stoi s)\n \t putStr (getAnswer (stoi s) )\n--\t print isLucky (stoi s)\n\nstoi ::String -> Int\n--stoi = foldr (\\x y -> 10*(digitToInt x)+(digitToInt y)) 0\nstoi [] = 0\nstoi x = digitToInt(last x)+10*(stoi (take ((length x) -1) x))\n\ndigitToInt::Char -> Int\ndigitToInt x = case x of\n\t '0' -> 0\n\t '1' -> 1\n\t '2' -> 2\n\t '3' -> 3\n\t '4' -> 4\n\t '5' -> 5\n\t '6' -> 6\n\t '7' -> 7\n\t '8' -> 8\n\t '9' -> 9\n\t _ -> 0\n\ngetAnswer ::Int -> String\ngetAnswer a |(isAlmostLucky a) = \"YES\"\n\t | otherwise = \"NO\"\nisAlmostLucky ::Int -> Bool\nisAlmostLucky a = any (\\x -> (isLucky x) && (a `mod` x == 0)) [4..a] \nisLucky ::Int -> Bool\nisLucky 0 = True\nisLucky a | ((a`mod`10)/=4)&&((a`mod`10)/=7) = False\n\t | otherwise = isLucky (a `div` 10)\n\n\n"}, {"source_code": "main :: IO ()\nmain = do s <- getLine\n \t putStr (getAnswer (stoi s))\n\nstoi ::String -> Int\nstoi = foldl (\\x y -> 10*x+(digitToInt y)) 0\n\ndigitToInt::Char -> Int\ndigitToInt x = case x of\n\t '0' -> 0\n\t '1' -> 1\n\t '2' -> 2\n\t '3' -> 3\n\t '4' -> 4\n\t '5' -> 5\n\t '6' -> 6\n\t '7' -> 7\n\t '8' -> 8\n\t '9' -> 9\n\t _ -> 0\n\ngetAnswer ::Int -> String\ngetAnswer a |(isAlmostLucky a) = \"YES\"\n\t | otherwise = \"NO\"\nisAlmostLucky ::Int -> Bool\nisAlmostLucky a = any (\\x -> (isLucky x) && (a `mod` x == 0)) [4..a] \nisLucky ::Int -> Bool\nisLucky 0 = True\nisLucky a | ((a`mod`10)/=4)&&((a`mod`10)/=7) = False\n\t | otherwise = isLucky (a `div` 10)\n\n\n"}, {"source_code": "main = readsolveprint\nreadsolveprint::IO()\nreadsolveprint= interact $ solve. head . lines\nsolve xs | any (==0) $ map (\\x-> mod (read xs) x) $ takeWhile (<1000) f =\"YES\"\n | otherwise = \"NO\"\nf::[Int]\nf= map read $ concat $ tail $ iterate (\\x->(map (\"4\"++) x) ++ (map(\"7\"++) x)) [\"\"]"}, {"source_code": "import Data.Char\n\nh :: Int -> String\nh x = if length xs == 0 then \"NO\"\n else \"YES\"\n where\n xs = filter (\\a -> mod x a == 0) (creL 4)\n\ncreL :: Int -> [Int]\ncreL 0 = [4,7]\ncreL x = [a+10*b | a <-[4,7], b <- creL (x-1)]++(creL (x-1))\n\nmain = do\n x <- getLine\n y <- readIO x::IO Int\n putStrLn (h y)\n"}, {"source_code": "isHappyChar :: Char -> Bool\nisHappyChar '4' = True\nisHappyChar '7' = True\nisHappyChar _ = False\n\nisHappyNumber :: Num a => a -> Bool\nisHappyNumber n = all isHappyChar (show n)\n\nhappyNumbers :: [Int]\nhappyNumbers = filter isHappyNumber [0..1000]\n\nsolve :: Int -> Bool\nsolve n = any (\\x -> mod n x == 0) happyNumbers\n\nprintAns :: Bool -> IO ()\nprintAns True = putStrLn \"YES\"\nprintAns False = putStrLn \"NO\"\n\nmain :: IO ()\nmain = readLn >>= printAns . solve\n"}, {"source_code": "-- Codeforces 122A\n\nimport Data.List\n\nmain :: IO ()\nmain = getLine >>= putStrLn . solve . read where\n solve n = case find (\\x -> n `mod` x == 0) $ map read $ lucky 3 [\"4\", \"7\"] of {\n Nothing -> \"NO\";\n Just _ -> \"YES\";\n } where\n lucky 1 xs = xs\n lucky n xs = k ++ [x++y | x <- xs, y <- k] where k = lucky (n-1) xs\n"}, {"source_code": "import Control.Applicative\n\nlucky = takeWhile (<=1000) ln\n\nln = 4 : 7 : concatMap f ln\n where f x = [x*10+4,x*10+7]\n\nmain = do\n n <- read <$> getLine :: IO Int\n putStrLn $ \n if any (\\x -> rem n x == 0) lucky then \"YES\" else \"NO\"\n"}, {"source_code": "import Data.Function\n\narr = [4, 7]\nlen = length arr\n\nmain = do\n\tn <- getInt\n\tputStrLn $ if isLucky n || isAlmostLucky n then \"YES\" else \"NO\"\n\ngetInt::IO Int\ngetInt = do\n\tline <- getLine\n\treturn $ read line\n\nisLucky::Int -> Bool\nisLucky n = fix (\\fn curr -> \n\t\t\t\t\tif curr == 0\n\t\t\t\t\t\tthen True\n\t\t\t\t\telse if (not $ curr `mod` 10 == 4) && (not $ curr `mod` 10 == 7)\n\t\t\t\t\t\tthen False\n\t\t\t\t\telse fn $ curr `div` 10) n\n\nisAlmostLucky::Int -> Bool\nisAlmostLucky n = do\n\tany (\\digits -> isAlmostLuckyForPlace n digits) [1..3]\n\nisAlmostLuckyForPlace::Int -> Int -> Bool\nisAlmostLuckyForPlace n digits = do\n\tlet numbersQtd = len ^ digits\n\tlet nums = map (\\index -> calcNumber digits index) [0..numbersQtd]\n\tany (\\num -> n `mod` num == 0) nums\n\ncalcNumber::Int -> Int -> Int\ncalcNumber digits index = foldr (\\digit res -> arr !! (index `div` (len ^ digit) `mod` len) * (10 ^ digit) + res) 0 [0..(digits - 1)]"}, {"source_code": "import Data.Function\n \nmain = do\n n <- readInt\n putStrLn $ if isLucky n || isAlmostLucky n then \"YES\" else \"NO\"\n \nreadInt::IO Int\nreadInt = do\n line <- getLine\n return $ read line\n \nisLucky::Int -> Bool\nisLucky n = fix (\\fn candidate res -> do\n let rem = candidate `mod` 10\n if candidate == 0 then res\n else if rem == 4 || rem == 7 then fn (candidate `div` 10) True\n else False) n False\n \nisAlmostLucky::Int -> Bool\nisAlmostLucky n = fix (\\fn candidate ->\n if candidate > n then False\n else if n `mod` candidate == 0 && isLucky candidate then True\n else fn $ candidate + 1) 4"}, {"source_code": "main = do\n x <- fmap read getLine :: IO Int\n let l = map show $ x : [y | y<-[1..(x `div` 2)], x `mod` y == 0]\n putStrLn $ if any (all (\\x -> x=='4' || x=='7')) l then \"YES\" else \"NO\"\n"}, {"source_code": "isLucky :: Int -> Bool\nisLucky x = filter (\\y -> y /= '4' && y /= '7') (show x) == []\n\n-- first argument is the upper bound\nluckyNumbers :: Int -> [Int]\nluckyNumbers bound =\n filter isLucky [1..bound]\n\nalmostLucky :: Int -> Bool\nalmostLucky n =\n or $ map (\\x -> n `mod` x == 0) (luckyNumbers n)\n\nmain :: IO ()\nmain = do\n x <- getLine\n let almostLuckyStr =\n if almostLucky $ read x then\n \"YES\"\n else\n \"NO\"\n in putStrLn $ almostLuckyStr\n"}, {"source_code": "getInt :: IO Int\ngetInt = readLn\n\nlucky [] = True\nlucky (x:xs) = ((x == 4) || (x == 7)) && lucky (xs)\n\ndigs 0 = []\ndigs x = x `mod` 10 : digs (x `div` 10)\n\ndivs a = [x | x <- a : [1 .. quot a 2], (mod a x == 0) && lucky (digs (x))]\n\nsolve a = putStrLn $ if length (divs a) == 0 then \"NO\" else \"YES\"\nmain = getInt >>= solve"}, {"source_code": "import Control.Monad\nimport Data.Array\nimport Data.Char\nimport Data.List\nimport qualified Data.ByteString.Char8 as B\ngetList :: Read a => IO [a]\ngetList = fmap (map (read . B.unpack) . B.words) B.getLine\ngetIntList :: IO [Int]\ngetIntList = fmap (unfoldr (B.readInt . B.dropWhile isSpace)) B.getLine\n\nislucky :: Int -> Bool\nislucky 0 = True\nislucky x = (x `mod` 10 == 4 || x `mod` 10 == 7) && islucky (x `div` 10)\n\nsolve :: Int -> Bool\nsolve x = any ((==0) . (x `mod`)) . filter islucky $ [1..x]\n\nmain :: IO ()\nmain = do\n n <- readLn\n putStrLn $ if solve n then \"YES\" else \"NO\"\n\n"}, {"source_code": "import Data.List\nimport Data.Char\nimport Control.Applicative\nimport Control.Monad\n\n\nmain::IO ()\nmain=do\n a<-(read <$> getLine) :: IO Int\n let b = [4,7,44,47,74,77,444,447,474,477,744,747,774,777]\n putStrLn $ if (any (\\z-> mod a z==0) b) then \"YES\" else \"NO\"\n"}, {"source_code": "calc n = if (0 `elem` (map (\\x -> n `mod` x) (filter g [1,2..n]))) then 0 else 1\n where g x = not(True `elem` (map (\\t -> t `elem` (show x)) \"12356890\"))\nmain = interact $ ((words \"YES NO\") !!) . calc . read"}, {"source_code": "main :: IO ()\nmain = readLn >>= putStrLn . solve\n\nsolve :: Int -> String\nsolve = yesno . any isLucky . factors\n\nisLucky :: Int -> Bool\nisLucky = all (`elem`\"47\") . show\n\nyesno :: Bool -> String\nyesno True = \"YES\"\nyesno _ = \"NO\"\n\nfactors :: Integral t => t -> [t]\nfactors n = [m | m <- [1..n], n `mod` m == 0]\n"}, {"source_code": "import Prelude hiding (readList)\nimport Control.Monad\nimport Control.Applicative\nimport Data.List\n\nreadList :: Read a => IO [a]\nreadList = fmap (fmap read . words) getLine\n\nreadList' :: Read a => a -> IO [a]\nreadList' _ = readList\n\nreadInt :: IO Int\nreadInt = head <$> readList' (undefined::Int)\n\nshowList :: Show a => [a] -> IO ()\nshowList = putStrLn . unwords . map show\n\nskipLine :: IO ()\nskipLine = void $ getLine\n\ncount :: (a -> Bool) -> [a] -> Int\ncount f = length . filter f\n\ndivUp :: Integral a => a -> a -> a\ndivUp x y \n | x `mod` y /= 0 = x `div` y + 1\n | otherwise = x `div` y\n\nisHappy :: Int -> Bool\nisHappy n = all (`elem` \"47\") (show n)\n\nmain :: IO ()\nmain = do\n n <- readInt\n putStrLn $\n if (any ((==0) . (n `mod`)) $ filter isHappy [1..n])\n then \"YES\"\n else \"NO\"\n"}, {"source_code": "luckys = [4, 7, 47, 74, 447, 474, 477, 747, 774]\n\nlucky :: Int -> String\nlucky n = if null l\n then \"NO\"\n else \"YES\"\n where l = filter (\\p -> rem n p == 0) luckys\n\nmain = do\n n <- getLine\n putStrLn . lucky . read $ n\n"}, {"source_code": "import Data.List\nmain = interact (\\s -> if почтиСчастливое $ read s then \"YES\" else \"NO\")\nпочтиСчастливое n = any (\\x -> n `mod` x == 0 && счастливое x) [1..n]\nсчастливое = all (\\x -> x == '7' || x == '4') . show\n"}, {"source_code": "import Control.Monad\nimport Control.Applicative\nimport Data.List\n\ngetNums :: (Read a,Num a) => IO [a]\ngetNums = map read. words <$> getLine\n\nluckies = [4,7,44,47,74,77,444,447,474,477,744,747,774,777]\n\nisAlmostLucky n = Nothing /= (find (\\x -> 0==n`mod`x) luckies)\n\nmain = do\n b <-isAlmostLucky <$> read <$> getLine\n putStrLn $ if b then \"YES\" else \"NO\"\n"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/122/A\n\nislucky :: Int -> Bool\nislucky 0 = True\nislucky x = (x `mod` 10 == 4 || x `mod` 10 == 7) && islucky (x `div` 10)\n\nsolve :: Int -> Bool\nsolve x = any ((==0) . (x `mod`)) . filter islucky $ [1..x]\n\nmain = do\n n <- readLn\n putStrLn $ if solve n then \"YES\" else \"NO\"\n"}, {"source_code": "module Main where\nimport Data.List\nimport Control.Applicative\nisLucky :: Int -> Bool\nisLucky num = case find (\\digit -> digit /= '4' && digit /= '7') $ show num of Just _ -> False; Nothing -> True\n\nbuildLuckyNumbers :: Int -> [Int]\nbuildLuckyNumbers to = filter isLucky [4..to]\n\nmain = do\n num <- (read :: String -> Int) <$> getLine\n putStrLn $ case find (\\ln -> num `mod` ln == 0) $ buildLuckyNumbers num of Just _ -> \"YES\"; Nothing -> \"NO\"\n"}, {"source_code": "p True = \"YES\"\np False = \"NO\"\nisLucky = all (`elem` \"74\") . show\ndivs n = n : filter ((== 0) . mod n) [2 .. n `div` 2]\nmain = interact $ p . any isLucky . divs . read"}, {"source_code": "listLuckyDivider = [x |x <-[1..1000], luckyDividerTwo x]\n\nluckyDividerOne :: Int -> Bool\nluckyDividerOne x = not ((filter (\\y -> x `mod` y == 0) listLuckyDivider) == [])\n\nluckyDividerTwo :: Int -> Bool\nluckyDividerTwo 0 = True\nluckyDividerTwo x\n | (((x `mod` 10) == 4) || ((x `mod` 10) == 7)) = luckyDividerTwo (x `div` 10)\n | otherwise = False\n\nmain :: IO()\nmain = do\n a <- getLine\n if luckyDividerOne (read a :: Int)\n then putStrLn \"YES\"\n else \n if luckyDividerTwo (read a :: Int)\n then putStrLn \"YES\"\n else putStrLn \"NO\""}, {"source_code": "isLucky :: Int -> Bool\nisLucky = all (`elem` \"47\") . show\n\nsolve :: Int -> String\nsolve n = loop 2\n where\n loop x\n | n < x = \"NO\"\n | n `rem` x == 0 && isLucky x = \"YES\"\n | otherwise = loop (x + 1)\n\nmain :: IO ()\nmain = readLn >>= putStrLn . solve\n\n\n"}, {"source_code": "main = do\n n <- fmap read getContents\n putStrLn $ if n `divBy` luckyNumbers then \"YES\" else \"NO\"\n where luckyNumbers = [4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777]\n divBy x = any (==0) . map (x `rem`)\n\n"}, {"source_code": "luckys :: [Int]\nluckys = [4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777]\n\nmain :: IO ()\nmain = do n <- fmap read getLine\n putStrLn $ if solve n luckys\n then \"YES\"\n else \"NO\"\n where\n solve n = any (== 0) . map (mod n) . takeWhile (<= n)\n"}, {"source_code": "dividor n i l = \n if i>n then l\n else if (mod n i) == 0 then dividor n (i+1) (i:l) else dividor n (i+1) l\n\nisLucky n_ = let n = show n_ in all (\\c -> c=='4'||c=='7') n\n\nsolve n = if (any (isLucky) (dividor n 1 [])) then \"YES\" else \"NO\"\n\nmain = getLine >>= putStrLn.solve.(read::String -> Int)"}, {"source_code": "toInt :: String -> Int\ntoInt = read\n\nisAlmostLucky :: Int -> String\nisAlmostLucky n\t= \tif any (\\x -> ( n `rem` x ) == 0 ) ( map (toInt) [ s | let l = [\"\", \"4\", \"7\"], x <- l, y <- l, z <- l, let s = x ++ y ++ z, length s > 0 ] )\n\t\t\t\t\tthen \"YES\"\n\t\t\t\t\telse \"NO\"\n\t\t\nmain = do\n\tstr <- getLine\n\tputStrLn $ isAlmostLucky $ toInt str"}, {"source_code": "main=readLn>>=putStrLn.solve\nsolve n|any(\\n->all(`elem`\"47\")(show n))[x|x<-[1..n],n`mod`x==0]=\"YES\"|otherwise=\"NO\"\n"}, {"source_code": "main = interact solve\n\nsolve :: String -> String\nsolve input = unlines $ result : []\n where result = check n\n n = read $ lines input !! 0\n\ncheck :: Int -> String\ncheck n\n | any isLucky [x | x <- [1..n], n `mod` x == 0] = \"YES\"\n | otherwise = \"NO\"\n\nisLucky :: Int -> Bool\nisLucky n = all (\\c -> c == '4' || c == '7') (show n)\n"}, {"source_code": "f :: Int -> String\nf n | null op = \"YES\"\n | n `rem` 4 == 0 = \"YES\"\n | n `rem` 7 == 0 = \"YES\"\n | check n = \"YES\" \n | otherwise = \"NO\"\n where op = filter (`notElem` \"47\") $ show n\n\ncheck n = any (==\"YES\") $ map f factors\n where factors = [x | x <- [1..n-1], n `rem` x == 0]\n\nmain = interact $ f . read . head . words\n\n"}, {"source_code": "module Main (main) where\n\nimport System\nimport Data.Char\nimport Data.List\nimport Control.Monad\nimport Control.Applicative\nsolve :: Int -> String\nsolve n = if any (\\x -> n `mod` x == 0) [4,7,47,74,447,474,744,774,747,477]\n then \"YES\" else \"NO\"\nmain = interact$solve.read.head.words"}, {"source_code": "-- | Return all combinations of a sequence of values.\ncombinations :: [a] -> [[a]]\ncombinations coins = concat [combs i coins | i <- [1 .. length coins]]\n where combs 0 _ = [[]]\n combs _ [] = []\n combs k (x:xs) = map (x:) (combs (k-1) xs) ++ combs k xs\n\n-- | Takes a list of digits, and converts them back into a positive integer.\nunDigits :: Integral n\n => n -- ^ The base to use.\n -> [n] -- ^ The digits of the number in list form.\n -> n -- ^ The original number.\nunDigits base = foldl (\\ a b -> a * base + b) 0\n\nalmostLucky :: Integer -> Bool\nalmostLucky n = or (map (\\ x -> n `mod` x == 0) divs)\n where\n divs = map (\\ x -> unDigits 10 x) (combinations [4,4,4,7,7,7])\n\nmain = do\n str <- getLine\n if almostLucky (read str) then\n putStrLn \"YES\"\n else\n putStrLn \"NO\""}, {"source_code": "\nisLucky :: Int -> Bool\nisLucky n = show n == filter (\\c -> c == '4' || c == '7') (show n)\n\ncalc :: Int -> String\ncalc n = if null [i | i <- [1..n], isLucky i, n `mod` i == 0]\n then \"NO\"\n else \"YES\"\n\nmain = do s <- getLine\n putStrLn $ calc $ read s\n"}], "negative_code": [{"source_code": "main=interact $ show.isAlmostHappy.read\nbase = [4,7,47,74,44,77,444,447,477,777,774,744,747,474]\n\nisAlmostHappy n = or (map (\\x->mod n x ==0) base)"}, {"source_code": "{-# LANGUAGE BlockArguments #-}\n\nimport Control.Arrow\nimport Data.List\n\nmain = do { x <- getLine\n ; putStrLn $ (read >>> solve) x \n }\n\nluckies :: [Int]\nluckies = [4, 7, 44, 47, 74, 77]\n\nsolve :: Int -> String\nsolve x = let b = foldr (\\y a -> a || x `mod` y == 0) False luckies\n in if b then \"YES\" else \"NO\""}, {"source_code": "good :: Int -> Bool\ngood a\n\t| (((a `mod` 10 == 4) || (a `mod` 10 == 7)) && (good (a `div` 10))) = True\n | otherwise = False\n\nallright :: [Int] -> Bool\nallright [] = False\nallright (x:xs) \n\t| ( (allright xs) || (good x) ) = True\n\t| otherwise = False\n\ngen :: Int -> Int -> [Int]\ngen a n\n\t| ((a>0) && (n `mod` a) == 0 ) = (gen (a-1) n) ++ [a]\n\t| ((a>0) && ((n `mod` a) > 0)) = gen (a-1) n\n\t| otherwise = []\n\nlucky :: Int -> Bool\nlucky a\n\t| allright (gen a a) = True\n\t| otherwise = False\n\nhandle :: [String] -> [[String]]\nhandle [n]\n\t| lucky (read n :: Int) = [[\"YES\"]]\n\t| otherwise = [[\"NO\"]]\n\nmain :: IO ()\nmain = interact $ unlines . map unwords . handle . words\n"}, {"source_code": "import Control.Applicative\nimport Debug.Trace\n\nluckys :: Int -> [Int]\nluckys n = drop 1 $ gen 0\n where gen x | x > n = []\n | otherwise = x : gen (x * 10 + 4) ++ gen (x * 10 + 7)\n\nmain = do\n n <- read <$> getLine\n putStrLn $ case any (\\x -> x `mod` n == 0) $ luckys n of\n True -> \"YES\"\n False -> \"NO\"\n"}, {"source_code": "main :: IO ()\nmain = do s <- getLine\n \t print (stoi s)\n\nstoi ::String -> Int\nstoi = foldl (\\x y -> 10*x+(digitToInt y)) 0\n\ndigitToInt::Char -> Int\ndigitToInt x = case x of\n\t '0' -> 0\n\t '1' -> 1\n\t '2' -> 2\n\t '3' -> 3\n\t '4' -> 4\n\t '5' -> 5\n\t '6' -> 6\n\t '7' -> 7\n\t '8' -> 8\n\t '9' -> 9\n\t _ -> 0\n\ngetAnswer ::Int -> String\ngetAnswer a |(isAlmostLucky a) = \"YES\"\n\t | otherwise = \"NO\"\nisAlmostLucky ::Int -> Bool\nisAlmostLucky a = any (\\x -> (isLucky x) && (a `mod` x == 0)) [4..a] \nisLucky ::Int -> Bool\nisLucky 0 = True\nisLucky a | ((a`mod`10)/=4)&&((a`mod`10)/=7) = False\n\t | otherwise = isLucky (a `div` 10)\n\n\n"}, {"source_code": "p True = \"YES\"\np False = \"NO\"\nisLucky = all (`elem` \"74\") . show\nalmostLucky n | isLucky n = True\n | n `mod` 4 == 0 = almostLucky4' $ n `div` 4\n | n `mod` 7 == 0 = almostLucky7' $ n `div` 7\n | otherwise = False\n where\n almostLucky' 1 = True\n almostLucky' n = almostLucky n\n almostLucky4' n | n < 4 = True\n | otherwise = almostLucky' n\n almostLucky7' m | n < 7 = True\n | otherwise = almostLucky' n\nmain = interact $ p . almostLucky . read\n"}, {"source_code": "p True = \"YES\"\np False = \"NO\"\nisLucky = all (`elem` \"74\") . show\nalmostLucky n | isLucky n = True\n | n `mod` 4 == 0 = almostLucky $ n `div` 4\n | n `mod` 7 == 0 = almostLucky $ n `div` 4\n | otherwise = False\nmain = interact $ p . isLucky . read\n"}, {"source_code": "p True = \"YES\"\np False = \"NO\"\nisLucky = all (`elem` \"74\") . show\nalmostLucky n | isLucky n = True\n | n `mod` 4 == 0 = almostLucky $ n `div` 4\n | n `mod` 7 == 0 = almostLucky $ n `div` 7\n | otherwise = False\nmain = interact $ p . almostLucky . read"}, {"source_code": "luckyDividerOne :: Int -> Bool\nluckyDividerOne x = (x `mod` 4 == 0) || (x `mod` 7 == 0)\n\nluckyDividerTwo :: Int -> Bool\nluckyDividerTwo 0 = False\nluckyDividerTwo x\n | (((x `mod` 10) == 4) || ((x `mod` 10) == 7)) = True\n | otherwise = luckyDividerTwo (x `div` 10)\n\nmain :: IO()\nmain = do\n a <- getLine\n if luckyDividerTwo (read a :: Int)\n then putStrLn \"YES\"\n else \n if luckyDividerOne (read a :: Int)\n then putStrLn \"YES\"\n else putStrLn \"NO\""}, {"source_code": "luckyDividerOne :: Int -> Bool\nluckyDividerOne x = (x `mod` 4 == 0) || (x `mod` 7 == 0)\n\nluckyDividerTwo :: Int -> Bool\nluckyDividerTwo 0 = True\nluckyDividerTwo x\n | (x `mod` 10) == 4 = luckyDividerTwo (x `div` 10)\n | (x `mod` 10) == 7 = luckyDividerTwo (x `div` 10)\n | otherwise = False\n\nmain :: IO()\nmain = do\n a <- getLine\n if luckyDividerOne (read a :: Int)\n then putStrLn \"YES\"\n else \n if luckyDividerTwo (read a :: Int)\n then putStrLn \"YES\"\n else putStrLn \"NO\""}, {"source_code": "main = interact solve\n\nsolve :: String -> String\nsolve input = unlines $ result : []\n where result = show $ check n\n n = read $ lines input !! 0\n\ncheck :: Int -> String\ncheck n\n | any isLucky [x | x <- [1..n], n `mod` x == 0] = \"YES\"\n | otherwise = \"NO\"\n\nisLucky :: Int -> Bool\nisLucky n = all (\\c -> c == '4' || c == '7') (show n)\n"}, {"source_code": "f :: Int -> String\nf n | null op = \"YES\"\n | n `rem` 4 == 0 = \"YES\"\n | n `rem` 7 == 0 = \"YES\"\n | otherwise = \"NO\"\n where op = filter (`notElem` \"47\") $ show n\n\n\nmain = interact $ f . read . head . words"}, {"source_code": "\nisLucky :: Int -> Bool\nisLucky n = show n == filter (\\c -> c == '4' || c == '7') (show n)\n\ncalc :: Int -> String\ncalc n = if null [i | i <- [1..n], isLucky i]\n then \"NO\"\n else \"YES\"\n\nmain = do s <- getLine\n putStrLn $ calc $ read s\n"}, {"source_code": "{-\nA. Lucky Division\n==================\ntime limit per test: 2 seconds\nmemory limit per test: 256 megabytes\ninput: standard input\noutput: standard output\n\nPetya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.\n\nInput\n------\nThe single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.\n\nOutput\n------\nIn the only line print \"YES\" (without the quotes), if number n is almost lucky. Otherwise, print \"NO\" (without the quotes).\n\nSample test(s)\n---------------\ninput\n47\noutput\nYES\n\ninput\n16\noutput\nYES\n\ninput\n78\noutput\nNO\n\n-}\nimport Data.List (nub, sort, findIndices)\nimport Data.Map (toList, fromListWith)\nimport Control.Applicative ((<$>), (<*>))\nimport Control.Monad (when, forM_, replicateM)\nimport Data.Array.ST (newArray, readArray, writeArray, runSTUArray)\nimport Data.Array.Unboxed (UArray, assocs)\n\nsieve :: Int -> UArray Int Bool\nsieve n = runSTUArray $ do\n let maxP = floor . sqrt $ fromIntegral n\n sieveTF <- newArray (2, n) True \n forM_ [2..maxP] $ \\p -> do\n isPrime <- readArray sieveTF p\n when isPrime $ do\n forM_ [p*p, p*p+p .. n] $ \\q -> do\n writeArray sieveTF q False\n return sieveTF\n\nprimesTo :: Int -> [Int]\nprimesTo n\n | n < 2 = []\n | otherwise = [i | (i,True) <- assocs $ sieve n]\n\ncartesianProduct :: [[a]] -> [[a]]\ncartesianProduct = foldr (\\xs acc -> (:) <$> xs <*> acc) [[]]\n\ntally :: Ord a => [a] -> [(a, Int)]\ntally xs = toList $ fromListWith (+) [(x, 1)| x <- xs]\n\nfactorInteger :: Int -> [(Int, Int)]\nfactorInteger 0 = [(0, 1)]\nfactorInteger 1 = [(1, 1)]\nfactorInteger n = tally $ factor n\n where\n ps = (primesTo . round . sqrt . fromIntegral) n\n factor 1 = []\n factor p = k : factor (p `div` k)\n where \n ds = dropWhile (\\q -> p `mod` q /= 0) ps\n k = if null ds then p else head ds\n\ndivisors :: Int -> [Int]\ndivisors 1 = [1]\ndivisors n = sort [product xs | xs <- cartesianProduct factors]\n where factors = [ map (n^) [0..pow] | (n, pow) <- factorInteger n ]\n\n---- \n\nisAlmostLucky :: Int -> Bool\nisAlmostLucky x = isLucky x || \n ( (not . null) luckyDs && \n any (\\k -> x `mod` k == 0 && even (x `div` k)) luckyDs )\n where luckyDs = filter isLucky $ divisors x\n\nisLucky :: Int -> Bool\nisLucky x = s == \"47\" || s == \"4\" || s == \"7\"\n where s = (sort . nub . show) x\n\nboolToStr :: Bool -> String\nboolToStr True = \"YES\"\nboolToStr False = \"NO\"\n\nmain = do \n input <- getLine\n let x = read input\n (putStrLn . boolToStr . isAlmostLucky) x\n\n"}, {"source_code": "{-\nA. Lucky Division\n==================\ntime limit per test: 2 seconds\nmemory limit per test: 256 megabytes\ninput: standard input\noutput: standard output\n\nPetya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.\n\nInput\n------\nThe single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.\n\nOutput\n------\nIn the only line print \"YES\" (without the quotes), if number n is almost lucky. Otherwise, print \"NO\" (without the quotes).\n\nSample test(s)\n---------------\ninput\n47\noutput\nYES\n\ninput\n16\noutput\nYES\n\ninput\n78\noutput\nNO\n\n-}\nimport Data.List (nub, sort)\n\nisAlmostLucky :: Int -> Bool\nisAlmostLucky x = isLucky x || (x == sqrtX ^ 2 && isLucky sqrtX)\n where sqrtX = (round . sqrt . fromIntegral) x\n\nisLucky :: Int -> Bool\nisLucky x = s == \"47\" || s == \"4\" || s == \"7\"\n where s = (sort . nub . show) x\n\nboolToStr :: Bool -> String\nboolToStr True = \"YES\"\nboolToStr False = \"NO\"\n\nmain = do \n input <- getLine\n let x = read input\n (putStrLn . boolToStr . isAlmostLucky) x\n\n"}, {"source_code": "main = interact $ (\\s -> if all (\\c -> c == '4' || c == '7' || c == '\\n') s then \"YES\\n\" else \"NO\\n\")\n"}, {"source_code": "lucky = filter (\\x -> all (\\c -> c == '4' || c == '7') $ show x) $ [1..2000]\nmain = interact $ (\\x -> if any (\\y -> div x y == 0) lucky then \"YES\\n\" else \"NO\\n\").read\n"}, {"source_code": "isLucky = all (`elem` ['4','7']) . show\ndivs n = filter ((== 0) . mod n) [2 .. n `div` 2]\nyesno b = if b then \"YES\" else \"NO\"\nmain = interact $ yesno . any isLucky . divs . read"}], "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d"} {"source_code": "import Data.List\n\nmain = getLine >>= print . solve . map read . words\n\nsolve = maximum . map solve_ . cyclelist 14 . cycle\n\ncyclelist 0 _ = []\ncyclelist n (x:xs) = take 14 (x:xs) : cyclelist (n - 1) xs\n\nsolve_ (x:xs) = sum $ filter even $ ans\n where (d, m) = x `divMod` 14\n a1 = 0 : replicate m 1 ++ replicate (13 - m) 0\n a2 = replicate 14 d\n ans = zipWith3 (\\x y z -> fromIntegral x + fromIntegral y + fromIntegral z) (0:xs) a1 a2\n", "positive_code": [{"source_code": "import Data.List\n\nsing :: Integer -> [Integer] -> Integer -> Integer\nsing a [] ind = 0\nsing 0 b ind = 0\nsing a (b:bs) ind = let kol = (quot a 14) + (if rem a 14 > ind then 1 else 0) + b in \n\n \t\t (if even kol then kol else 0) + sing a bs (ind + 1)\n\nsolve [] am = 0\nsolve (a:as) b@(bf:bs) = max (solve as (bs ++ [bf])) (sing a (bs ++ [0]) 0)\n\n\nmain :: IO ()\nmain = do\n sN <- getLine\n let am = map read $ words sN :: [Integer]\n -- print am\n let res = solve am am\n print res"}, {"source_code": "import Control.Applicative\nimport Data.Int\n\n\nmain = do\n xs <- readLs :: IO [Int64]\n print $ solve xs\n\nsolve zs = maximum $ map solve' . take 14 . iterate tail $ zs ++ zs\n where solve' xs = let (y:ys) = take 14 xs\n q = div y 14\n r = fromIntegral $ mod y 14\n in sum $ filter even $ zipWith (+) (replicate r 1 ++ cycle [0]) $\n map (+ q) (ys ++ [0])\n\nreadLs = map read . words <$> getLine"}], "negative_code": [{"source_code": "import Data.List\n\nsing :: Int -> [Int] -> Int -> Int\nsing a [] ind = 0\nsing 0 b ind = 0\nsing a (b:bs) ind = let kol = (quot a 14) + (if rem a 14 > ind then 1 else 0) + b in \n\n \t\t (if even kol then kol else 0) + sing a bs (ind + 1)\n\nsolve [] am = 0\nsolve (a:as) b@(bf:bs) = max (solve as (bs ++ [bf])) (sing a (bs ++ [0]) 0)\n\n\nmain :: IO ()\nmain = do\n sN <- getLine\n let am = map read $ words sN :: [Int]\n -- print am\n let res = solve am am\n print res"}, {"source_code": "import Data.List\n\nsing :: Int -> [Int] -> Int -> Int\nsing a [] ind = 0\nsing a (b:bs) ind = let kol = (quot a 14) + (if rem a 14 > ind then 1 else 0) + b in \n\n \t\t (if even kol then kol else 0) + sing a bs (ind + 1)\n\nsolve [] am = 0\nsolve (a:as) b@(bf:bs) = max (solve as (bs ++ [bf])) (sing a (bs ++ [0]) 0)\n\n\nmain :: IO ()\nmain = do\n sN <- getLine\n let am = map read $ words sN :: [Int]\n -- print am\n let res = solve am am\n print res"}, {"source_code": "import Control.Applicative\nimport Data.Int\n\n\nmain = do\n xs <- readLs :: IO [Int]\n print $ solve xs\n\nsolve zs = maximum $ map solve' . take 14 . iterate tail $ zs ++ zs\n where solve' xs = let (y:ys) = take 14 xs\n q = div y 14\n r = mod y 14\n in sum $ filter even $ zipWith (+) (replicate r 1 ++ cycle [0]) $\n map (+ q) (ys ++ [0])\n\nreadLs = map read . words <$> getLine"}, {"source_code": "import Data.List\n\nmain = getLine >>= print . solve . map read . words\n\nsolve = maximum . map solve_ . cyclelist 14 . cycle\n\ncyclelist 0 _ = []\ncyclelist n (x:xs) = take 14 (x:xs) : cyclelist (n - 1) xs\n\nsolve_ (x:xs) = sum $ filter even $ ans\n where (d, m) = x `divMod` 14\n a1 = 0 : replicate m 1 ++ replicate (13 - m) 0\n a2 = replicate 14 d\n ans = zipWith3 (\\x y z -> x + y + z) (0:xs) a1 a2\n"}], "src_uid": "1ac11153e35509e755ea15f1d57d156b"} {"source_code": "import Data.List( sort, nub)\nmain = do\n s_ <- getLine\n let shift 0 s = [s]\n\tshift n (c:cs) = (c:cs) : shift (n-1) (cs++[c])\n print.length.nub.sort$shift (length s_ - 1) s_\n", "positive_code": [{"source_code": "import Data.Set\n\nmain :: IO ()\nmain = do\n input <- getLine\n handler (length input) input\n\nhandler l input = handler' l (cycle input) empty\n where\n handler' 0 _ set = print $ size set\n handler' n word set = handler' (n - 1) (tail word) (insert (take l word) set)\n"}, {"source_code": "import Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Char \n\nimport qualified Data.ByteString.Char8 as B\nreadInt = readLn :: IO Int\nreadInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine\n\nrotate :: String -> String\nrotate s = last s : init s\n\nunique :: Ord a => [a] -> [a]\nunique = map head . group . sort\n\ncycles :: Int -> String -> [String]\ncycles 0 _ = []\ncycles n s = s : cycles (n-1) (rotate s)\n\ncyclicShifts :: String -> Int\ncyclicShifts s = length $ unique $ cycles (length s) s\n\nmain :: IO ()\nmain = do\n s <- getLine\n print $ cyclicShifts s\n -- print $ cyclicShifts \"bbb\"\n -- print $ cyclicShifts \"yzyz\""}], "negative_code": [], "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e"} {"source_code": "\nmain = do\n contents <- getContents\n let (a, b, c, d) = (intsInLine !! 0, intsInLine !! 1, intsInLine !! 2, intsInLine !! 3)\n where intsInLine = map read $ words $ head $ lines contents\n putStrLn $ getResult (a, c) (b, d)\n \ngetPoint :: Float -> Float -> Float\ngetPoint costPoint submitTime = max (3.0 * costPoint / 10.0) (costPoint - costPoint / 250.0 * submitTime)\n\ngetResult :: (Float, Float) -> (Float, Float) -> String\ngetResult (p0, t0) (p1, t1)\n | pointMisha == pointVasya = \"Tie\"\n | pointMisha > pointVasya = \"Misha\"\n | otherwise = \"Vasya\"\n where\n pointMisha = getPoint p0 t0\n pointVasya = getPoint p1 t1\n", "positive_code": [{"source_code": "import Control.Applicative\nimport Data.List\n\nmain= do\n\t[a,b,c,d]<- map read.words <$> getLine ::IO [Float]\n\tlet s1 = max (3.0*a / 10.0) (a- a/250.0*c)\n\tlet s2 = max (3.0*b / 10.0) (b- b/250.0*d)\n\tputStrLn $ if s1< s2 then \"Vasya\" else if s1==s2 then \"Tie\" else \"Misha\"\n\t\n\t"}, {"source_code": "import Data.List\n\ncal ls = winner pv pm\n where xs = map read $ words $ head $ lines ls\n a = head xs\n b = xs !! 1\n c = xs !! 2\n d = xs !! 3\n point p t = maximum [ p * 0.3, p * ( 1 - t / 250)]\n pm = point a c\n pv = point b d\n\n\nwinner v m\n | v == m = \"Tie\"\n | v > m = \"Vasya\"\n | otherwise = \"Misha\"\n\nmain = interact cal\n"}, {"source_code": "main=interact$solve.map read.words\nformula p t = max (3*p/10) (p - (p/250)*t)\nsolve [a,b,c,d]\n | m > v = \"Misha\"\n | m < v = \"Vasya\"\n |otherwise = \"Tie\"\n where m = formula a c\n v = formula b d\n"}, {"source_code": "import qualified Data.ByteString.Char8 as B2\nimport Data.Maybe\n\n\nmain = do\n\tt<-B2.getLine\n\tlet [a,b,c,d]=B2.words t\n\tputStrLn $ solve (readI a) (readI b) (readI c) (readI d)\n\nreadI = fromInteger . fst .fromJust.B2.readInteger\nscore p t = max (div (3*p) 10) (p-(div p 250)*t)\n\nsolve a b c d \n | misha>vasya = \"Misha\"\n | misha==vasya = \"Tie\"\n | otherwise = \"Vasya\"\n\n\twhere \n\t misha = score a c\n\t vasya = score b d"}, {"source_code": "import Data.Ratio\n\nmain = interact $ solve . map read . words\n\t\nsolve [a,b,c,d] | ff == ss = \"Tie\"\n\t | ff > ss = \"Misha\"\n\t\t| ss > ff = \"Vasya\"\n where ff = score a c\n ss = score b d\n\nscore p t = max (3*p/10) (p-p/250*t)"}, {"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad hiding ((<$!>))\nimport Control.Monad.ST.Safe\nimport Control.Monad.State hiding ((<$!>))\n-- import Data.Array\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IntSet\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map.Strict (Map)\nimport qualified Data.Map.Strict as Map\nimport Data.HashMap.Strict (HashMap)\nimport qualified Data.HashMap.Strict as HashMap\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\n-- import Debug.Trace\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n [a, b, c, d] <- map read . words <$> getLine\n\n let\n f p t = max (3*p/10) (p - p/250*t)\n\n putStrLn $\n case compare (f a c) (f b d) of\n LT -> \"Vasya\"\n EQ -> \"Tie\"\n GT -> \"Misha\"\n"}, {"source_code": "main = interact $ f . map read . words\nf [a,c,b,d] = case compare (g a b) (g c d) of\n GT -> \"Misha\"\n LT -> \"Vasya\"\n EQ -> \"Tie\"\ng p t = max (3*p/10) (p-p*t/250)"}, {"source_code": "import Data.Char\n\nh :: Int -> Int -> Int -> Int -> String\nh a b c d\n | (max (div (3*a) 10) (a- (div a 250) * c)) < (max (div (3*b) 10) (b- (div b 250) * d)) = \"Vasya\"\n | (max (div (3*a) 10) (a- (div a 250) * c)) > (max (div (3*b) 10) (b- (div b 250) * d)) = \"Misha\"\n | otherwise = \"Tie\"\n \n\n--main = do\n-- line <- getLine\n-- print (h line [])\n\n\n\nmain = do\n line <- getLine\n let a = (read (takeWhile (/= ' ') line) :: Int)\n let line1 = drop 1 (dropWhile (/= ' ') line)\n let b = (read (takeWhile (/= ' ') line1) :: Int)\n let line2 = drop 1 (dropWhile (/= ' ') line1)\n let c = (read (takeWhile (/= ' ') line2) :: Int)\n \n let d = (read (drop 1 (dropWhile (/= ' ') line2)) :: Int)\n putStrLn(h a b c d)\n\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\n\nmain::IO ()\nmain=do\n [a,b,c,d]<- map read <$> words <$> getLine\n let a1 = max (div (3*a) 10) (a -(div a 250)*c)\n let b1 = max (div (3*b) 10) (b -(div b 250)*d)\n putStrLn $ if a1==b1 then \"Tie\" else if a1 \"Misha\";LT->\"Vasya\";_->\"Tie\"\ng(p,t)=max(3*p`div`10)(p-p`div`250*t)\n"}, {"source_code": "import Data.Function (on)\n\nmain :: IO ()\nmain = getContents >>= putStrLn . solve . map read . words\n\nsolve :: [Integer] -> String\nsolve [ a, b, c, d ] = case (compare `on` score) (a, c) (b, d) of\n GT -> \"Misha\"; LT -> \"Vasya\"; _ -> \"Tie\"\nsolve _ = undefined\n\nscore :: (Integer, Integer) -> Integer\nscore (p, t) = max (3 * p `div` 10) (p - p `div` 250 * t)\n"}, {"source_code": "main = interact $ solve . map read . words\nsolve [a,b,c,d] = case compare (score a c) (score b d) of\n GT -> \"Misha\"\n LT -> \"Vasya\"\n EQ -> \"Tie\"\nscore p t = max (3 * p `div` 10) (p - p * t `div` 250)\n"}, {"source_code": "import Data.Ratio\n\nmain = do\n [a,b,c,d] <- fmap (map read . words) getLine\n putStrLn $ solve a b c d\n \nsolve a b c d | fstPoints == sndPoints = \"Tie\"\n | fstPoints > sndPoints = \"Misha\"\n | sndPoints > fstPoints = \"Vasya\"\n where fstPoints = points a c\n sndPoints = points b d\n\n \npoints p t = max (3*p%10) (p%1-p*t%250)\n"}, {"source_code": "main :: IO ()\nmain = do\n args <- getLine\n let [a1,a2,a3,a4] = map read $ words args\n printSolve a1 a2 a3 a4\n\nprintSolve :: Double -> Double -> Double-> Double -> IO ()\nprintSolve a1 a2 a3 a4\n | m > v = putStrLn \"Misha\"\n | v > m = putStrLn \"Vasya\"\n | otherwise = putStrLn \"Tie\"\n where m = max (3 * a1 /10) (a1 - a1*a3/250)\n v = max (3 * a2 /10) (a2 - a2*a4/250)"}], "negative_code": [{"source_code": "main = interact $ solve . map read . words\nsolve [a,b,c,d] = case compare (score a c) (score b d) of\n GT -> \"Misha\"\n LT -> \"Vasya\"\n EQ -> \"Tie\"\nscore p t = max (3 * p `div` 10) (p * t `div` 250)\n"}, {"source_code": "main :: IO ()\nmain = do\n args <- getLine\n let [a1,a2,a3,a4] = map read $ words args\n printSolve a1 a2 a3 a4\n\nprintSolve :: Float -> Float -> Float -> Float -> IO ()\nprintSolve a1 a2 a3 a4\n | m > v = putStrLn \"Misha\"\n | v > m = putStrLn \"Vasya\"\n | otherwise = putStrLn \"Tie\"\n where m = max (0.3 * a1) (a1 - a1*a3/250)\n v = max (0.3 * a2) (a2 - a2*a4/250)"}, {"source_code": "import Data.List\n\ncal ls = show $ winner pv pm\n where xs = map read $ words $ head $ lines ls\n a = head xs\n b = xs !! 1\n c = xs !! 2\n d = xs !! 3\n point p t = maximum [ p * 0.3, p * ( 1 - t / 250)]\n pm = point a c\n pv = point b d\n\n\nwinner v m\n | v == m = \"Tie\"\n | v > m = \"Vasya\"\n | otherwise = \"Misha\"\n\nmain = interact cal\n"}], "src_uid": "95b19d7569d6b70bd97d46a8541060d0"} {"source_code": "import Data.List (isPrefixOf, isSuffixOf, reverse)\n\nmain :: IO ()\nmain = do\n str <- getLine\n let len = getPrefLen \"CODEFORCES\" str + getSuffLen \"CODEFORCES\" str\n let ans = if len >= length \"CODEFORCES\"\n then \"YES\"\n else \"NO\"\n putStrLn ans\n\n\ngetPrefLen :: String -> String -> Int\ngetPrefLen (x:xs) (y:ys)\n | x == y = 1 + getPrefLen xs ys\n | otherwise = 0\ngetPrefLen _ _ = 0\n\ngetSuffLen :: String -> String -> Int\ngetSuffLen x y = getPrefLen (reverse x) (reverse y)\n", "positive_code": [{"source_code": "import Control.Applicative\nimport Data.List\n \n\nprocess s x | isPrefixOf x s = \"YES\"\n | isSuffixOf x s = \"YES\"\n | otherwise = if (process1 s x) then \"YES\" else \"NO\"\n\nprocess1 [] _ =False\nprocess1 (s:ss) (x:xx) | s==x = process1 ss xx\n\t\t | otherwise = isSuffixOf (x:xx) (s:ss)\n\n\nmain= do\n\ts<- getLine \n\tputStrLn $ process s \"CODEFORCES\" "}, {"source_code": "--isMake::String -> String -> Bool\nisMake s w = any id [ (take a w) ++ (drop b w) == s| a <- [0..(length w)], b<-[a..(length w)]]\nmain = do\n w <- getLine\n putStrLn $ if isMake \"CODEFORCES\" w then \"YES\" else \"NO\"\n"}, {"source_code": "import Control.Arrow ((&&&), second)\nimport Data.List (inits, tails)\n\nmain :: IO ()\nmain = getLine >>= putStrLn . yesno . solve\n\nsolve :: String -> Bool\nsolve = elem \"CODEFORCES\" . concatMap (uncurry (map . (++)) . second tails) . uncurry zip . (inits &&& tails)\n\nyesno :: Bool -> String\nyesno True = \"YES\"\nyesno _ = \"NO\"\n"}, {"source_code": "import Control.Arrow ((&&&), app)\nimport Data.List (inits, tails)\n\nmain :: IO ()\nmain = getLine >>= putStrLn . yesno . solve\n\nsolve :: String -> Bool\nsolve = elem \"CODEFORCES\" . concatMap app . uncurry zip . (map (map . (++)) . inits &&& map tails . tails)\n\nyesno :: Bool -> String\nyesno True = \"YES\"\nyesno _ = \"NO\"\n"}, {"source_code": "substrMatch s t = [(take n s) ++ (drop m s) == t | n <- [0..(length s)], m<- [0..(length s)]]\n\nsubstr s t = any id (substrMatch s t)\n\nsolution s\n | substr s \"CODEFORCES\" = \"YES\"\n | otherwise = \"NO\"\n\nmain = do\n s <- getLine\n putStrLn $ solution s\n"}], "negative_code": [{"source_code": "isMake [] w = True\nisMake s [] = null s \nisMake s@(hs:ts) (hw:tw) | hs == hw = isMake ts tw\n | otherwise = isMake s tw \nmain = do\n w <- getLine\n putStrLn $ if isMake \"CODEFORCES\" w then \"YES\" else \"NO\"\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= putStrLn . yesno . solve\n\nsolve :: String -> Bool\nsolve = isContainedIn \"CODEFORCES\"\n\nisContainedIn :: Eq a => [a] -> [a] -> Bool\nisContainedIn xxs@(x:xs) (y:ys) | x == y = isContainedIn xs ys\n | otherwise = isContainedIn xxs ys\nisContainedIn [] _ = True\nisContainedIn _ _ = False\n\nyesno :: Bool -> String\nyesno True = \"YES\"\nyesno _ = \"NO\"\n"}, {"source_code": "import Control.Applicative\n \n\nprocess _ [] = True\nprocess [] _ = False\nprocess (x:xs) (y:ys) | x==y = process xs ys\n\t | otherwise = process xs (y:ys)\n\n\n\nmain= do\n\ts<- getLine \n\tputStrLn $ if process s \"CODEFORCES\" then \"YES\" else \"NO\"\n\t \n"}, {"source_code": "import Control.Applicative\n \n\nprocess _ [] = True\nprocess [] _ = False\nprocess (x:xs) (y:ys) | x==y = process xs ys\n\t | otherwise = process xs ys\n\n\n\nmain= do\n\ts<- getLine \n\tputStrLn $ if process s \"CODEFORCES\" then \"YES\" else \"NO\"\n\t \n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \n\nprocess _ [] = True\nprocess [] _ = False\nprocess (x:xs) (y:ys) | x==y = process xs ys\n\t | otherwise = isInfixOf (y:ys) xs\n\n\nmain= do\n\ts<- getLine \n\tputStrLn $ if process s \"CODEFORCES\" then \"YES\" else \"NO\"\n\t \n"}], "src_uid": "bda4b15827c94b526643dfefc4bc36e7"} {"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Monad.State\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport Data.Char\nimport Data.Function\n-- import Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Set (Set)\nimport qualified Data.Set as Set\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\nimport qualified Data.ByteString.Char8 as B\n-- import Debug.Trace\n\nimport qualified Data.ByteString.Lazy.Builder as BB\n\nimport Data.Monoid\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n z <- replicateM 5 getInts\n\n let\n f :: [Int] -> Int\n f [] = 0\n f as = g as + f (tail as)\n where\n g :: [Int] -> Int\n g [] = 0\n g [x] = 0\n g (a:b:as) = z!!a!!b + z!!b!!a + g as\n\n print $ maximum $ map f $ permutations [0..4]\n", "positive_code": [{"source_code": "import Control.Arrow ((&&&))\nimport Data.List (permutations)\nimport Data.Tuple (swap)\n\nmain :: IO ()\nmain = getContents >>= print . solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> Int\nsolve gs = maximum [ sum [ gs !! i !! j | (i, j) <- indices is ] | is <- permutations [0..4] ]\n\nindices :: [a] -> [(a, a)]\nindices = uncurry (++) . (id &&& map swap) . concat . takeWhile (not . null)\n . iterate (drop 2) . uncurry zip . (id &&& tail)\n"}, {"source_code": "import Data.List\nimport Control.Monad\n\nn = 5\n\ncalc2 :: [[Int]] -> [Int] -> Int\ncalc2 a (b:c:d) = (a !! b !! c) + (a !! c !! b) + (calc2 a d)\ncalc2 _ _ = 0\n\ncalc :: [[Int]] -> [Int] -> Int\ncalc a (c:b) = (calc2 a (c:b)) + (calc a b)\ncalc _ _ = 0\n\nsolve :: [[Int]] -> Int\nsolve a = maximum $ map (calc a) $ permutations [0..n-1]\n\nmain = do\n s <- replicateM 5 $ (getLine >>= (return . (map read) . words))\n print $ solve s\n\n"}, {"source_code": "import Data.List\n\nreadNStudents :: Int -> IO [[Int]]\nreadNStudents n\n\t\t\t| n==0 = return []\n\t\t\t| otherwise = do\n\t\t\t\tstudent <- readStudent\n\t\t\t\tothers <- readNStudents (n-1)\n\t\t\t\treturn (student:others)\n\nreadStudent :: IO [Int]\nreadStudent = \n\t\tdo\n\t\t\tline <- getLine\n\t\t\tlet happys = map (read :: String -> Int) $ words line\n\t\t\treturn happys\n\n\ncalcStep :: [(Int, [Int])] -> Int\ncalcStep [] = 0\ncalcStep list \n\t\t\t| length list < 2 = 0\ncalcStep (x:y:ys) = (snd x)!!(fst y)+(snd y)!!(fst x) + calcStep ys\n\ncalcSteps :: [(Int, [Int])] -> Int\ncalcSteps [] = 0\ncalcSteps list@(x:xs) = calcStep list + calcSteps xs\n\nmain = \n\tdo\n\t\tlet count = 5\n\t\tstudents <- readNStudents count\n\t\tlet zipedStudents = zip [0..] students\n\t\tlet mutations = permutations zipedStudents\n\t\tlet happies = map calcSteps mutations\n\t\tlet result = maximum happies\n\t\tputStrLn $ show result"}], "negative_code": [{"source_code": "module Main where\nimport Data.List\n\nmain = \n\tdo\n\t\tlet count = 5\n\t\tstudents <- readNStudents count\n\t\tlet zipedStudents = zip [0..] students\n\t\tlet mutations = permutations zipedStudents\n\t\tlet happies = map calcSteps mutations\n\t\tlet result = maximum happies\n\t\treturn result\n\nreadNStudents :: Int -> IO [[Int]]\nreadNStudents n\n\t\t\t| n==0 = return []\n\t\t\t| otherwise = do\n\t\t\t\tstudent <- readStudent\n\t\t\t\tothers <- readNStudents (n-1)\n\t\t\t\treturn (student:others)\n\nreadStudent :: IO [Int]\nreadStudent = \n\t\tdo\n\t\t\tline <- getLine\n\t\t\tlet happys = map (read :: String -> Int) $ words line\n\t\t\treturn happys\n\n\ncalcStep :: [(Int, [Int])] -> Int\ncalcStep [] = 0\ncalcStep list \n\t\t\t| length list < 2 = 0\ncalcStep (x:y:ys) = (snd x)!!(fst y)+(snd y)!!(fst x) + calcStep ys\n\ncalcSteps :: [(Int, [Int])] -> Int\ncalcSteps [] = 0\ncalcSteps list@(x:xs) = calcStep list + calcSteps xs"}], "src_uid": "be6d4df20e9a48d183dd8f34531df246"} {"source_code": "import Control.Monad\nimport Data.Bool\nimport Data.Function\nimport Data.Tuple\nimport Data.Maybe\nimport Data.Tree\nimport Data.Graph\nimport Data.Array.IArray\nimport Data.List\nimport Data.Int\nimport Data.List.Split\nimport qualified Data.ByteString.Char8 as B\n\n\niogetints :: IO [Int64]\niogetints = getLine >>= (return . map read . words)\n\nfreadEdgeList :: IO [Edge]\nfreadEdgeList = B.getContents >>= (return . pairify . map (fst . fromJust . B.readInt) . B.words)\n\nindexed :: [a] -> [(Int, a)]\nindexed = go 0 where\n\tgo :: Int -> [a] -> [(Int, a)]\n\tgo _ [] = []\n\tgo i (x:xs) = (i, x) : (go (succ i) xs)\n\nfoldTree :: (a -> [b] -> b) -> Tree a -> b\nfoldTree f = go where\n\tgo (Node x ts) = f x (map go ts)\n\npairify :: [a] -> [(a, a)]\npairify [] = []\npairify (x:y:xs) = (x, y) : (pairify xs)\n\nbuildTree :: Int -> Vertex -> [Edge] -> Tree Vertex\nbuildTree n r es = fdfs (-1) r where\n\tg = accumArray (flip (:)) [] (1, n) $ ap (++) (map swap) $ es :: Graph\n\tfdfs :: Vertex -> Vertex -> Tree Vertex\n\tfdfs p v = Node v $ map (fdfs v) $ delete p $ g!v\n\nboth :: (a -> b) -> (a, a) -> (b, b)\nboth f (x, y) = (f x, f y)\n\nsolve :: Int64 -> Int64 -> Int64\nsolve n k = ans where\n\tle = max (k - n) 1\n\tre = min (k - 1) n\n\tlen = max (re - le + 1) 0\n\tans = len `div` 2\n\nmain :: IO ()\nmain = do\n\t[n, k] <- iogetints\n\tprint $ solve n k\n\t\n\t", "positive_code": [{"source_code": "\ntoint s = (read s) :: Integer\n\ndoit n k =\n if n == 1 then\n 0\n else\n if n >= k-1 then\n div (k-1) 2\n else\n if n + n-1 < k then\n 0\n else\n div (k-1) 2 - (k-1-n)\n\n\nsolve::String -> String\nsolve ss =\n let n:k:_ = map toint $ words ss in\n (show $ doit n k) ++ \"\\n\"\n\nmain = interact solve\n"}], "negative_code": [{"source_code": "import Control.Monad\nimport Data.Bool\nimport Data.Function\nimport Data.Tuple\nimport Data.Maybe\nimport Data.Tree\nimport Data.Graph\nimport Data.Array.IArray\nimport Data.List\nimport Data.Int\nimport Data.List.Split\nimport qualified Data.ByteString.Char8 as B\n\n\niogetints :: IO [Int64]\niogetints = getLine >>= (return . map read . words)\n\nfreadEdgeList :: IO [Edge]\nfreadEdgeList = B.getContents >>= (return . pairify . map (fst . fromJust . B.readInt) . B.words)\n\nindexed :: [a] -> [(Int, a)]\nindexed = go 0 where\n\tgo :: Int -> [a] -> [(Int, a)]\n\tgo _ [] = []\n\tgo i (x:xs) = (i, x) : (go (succ i) xs)\n\nfoldTree :: (a -> [b] -> b) -> Tree a -> b\nfoldTree f = go where\n\tgo (Node x ts) = f x (map go ts)\n\npairify :: [a] -> [(a, a)]\npairify [] = []\npairify (x:y:xs) = (x, y) : (pairify xs)\n\nbuildTree :: Int -> Vertex -> [Edge] -> Tree Vertex\nbuildTree n r es = fdfs (-1) r where\n\tg = accumArray (flip (:)) [] (1, n) $ ap (++) (map swap) $ es :: Graph\n\tfdfs :: Vertex -> Vertex -> Tree Vertex\n\tfdfs p v = Node v $ map (fdfs v) $ delete p $ g!v\n\nboth :: (a -> b) -> (a, a) -> (b, b)\nboth f (x, y) = (f x, f y)\n\nsolve :: Int64 -> Int64 -> Int64\nsolve n k = ans where\n\tle = max (k - n) 0\n\tre = n\n\tlen = max (re - le + 1) 0\n\tans = if (even k && (k `div` 2) >= le && (k `div` 2) <= re) then (len - 1) else len\n \nmain :: IO ()\nmain = do\n\t[n, k] <- iogetints\n\tprint $ solve n k\n\t\n\t"}], "src_uid": "98624ab2fcd2a50a75788a29e04999ad"} {"source_code": "check :: Int -> (Int, Int, Int) -> Bool\ncheck n (na, nb, nc) =\n if (n + na + 2 * nb + 3 * nc) `mod` 4 == 0\n then\n True\n else\n False\n\nprice :: Integer -> Integer -> Integer -> (Int, Int, Int) -> Integer\nprice a b c (na, nb, nc) = a * (toInteger na) + b * (toInteger nb) + c * (toInteger nc)\n\ncartProd :: [Int] -> [Int] -> [Int] -> [(Int, Int, Int)]\ncartProd xs ys zs = [(x, y, z) | x <- xs, y <- ys, z <- zs]\n\ngoods :: Int -> [(Int, Int, Int)] -> [(Int, Int, Int)]\ngoods n xs = filter (check n) xs\n\ngen :: [(Int, Int, Int)]\ngen = cartProd [0..10] [0..10] [0..10]\n\ncalc :: Int -> Integer -> Integer -> Integer -> Integer\ncalc n a b c = foldr min ((toInteger (maxBound :: Int)) * 10) (map (price a b c) (goods n gen))\n\nmain = do\n cs <- getContents\n let vals = words (head (lines cs))\n let n = read (vals!!0) :: Int\n let a = read (vals!!1) :: Integer\n let b = read (vals!!2) :: Integer\n let c = read (vals!!3) :: Integer\n -- putStrLn (show (goods n gen)) -- debug\n putStrLn (show (calc n a b c))", "positive_code": [{"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Arrow\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport qualified Data.ByteString.Char8 as B\nimport Text.Printf\n\nreadInt = ( readLn :: IO Int )\nreadInts = map ( read :: String -> Int ) . words <$> getLine\n\ngetList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine\n\nwhich a b f = if f then a else b\nmp [ a, b ] = ( a, b )\n\nmain = do\n\t[ n, a, b, c ] :: [ Integer ] <- map read . words <$> getLine\n\tprint $ minimum $ map snd $ filter ( \\( k, _ ) -> k `mod`4 == 0 ) $ return ( n, 0 ) >>= f 1 a >>= f 2 b >>= f 3 c\n\nf n a ( m, b ) = do\n\tx <- [ 0 .. 3 ]\n\treturn ( m + n * x, b + x * a )\n"}, {"source_code": "main=interact(show.f.map read.words)\nf :: [Integer] -> Integer\nf (x:(xs@[a,b,c]))\n | x`mod`4 == 0 = 0\n | x`mod`4 == 3 = foldr min (foldr max 0 xs) [a, b + c, 3*c]\n | x`mod`4 == 2 = foldr min (foldr max 0 xs) [2*a, b, 2*c]\n | otherwise = foldr min (foldr max 0 xs) [3*a, b+a, c]"}, {"source_code": "module Main (main) where\n\n\nmain :: IO ()\nmain = do\n l <- getLine\n let n:a:b:c:_ = map read $ words l :: [Integer]\n let t = (-n) `mod` 4\n print $ minimum [y1 * a + y2 * b + y3 * c | y1 <- [0..3], y2 <- [0..3], y3 <- [0..3], (y1+2*y2+3*y3) `mod` 4 == t]\n"}, {"source_code": "import Control.Applicative\n\nmain = do\n\t[n,a,b,c] <- map read.words <$> getLine\n\tputStrLn.show $ buyPlan (need n) a b c\n\nneed :: Integer -> Integer\nneed n = 4 - n `mod` 4\n\nbuyPlan 4 _ _ _ = 0\nbuyPlan 1 a b c = foldl min (3*maxV a b c) [a, 3*a+b, b+c,3*c]\nbuyPlan 2 a b c = foldl min (3*maxV a b c) [a*2, b, 2*c]\nbuyPlan 3 a b c = foldl min (3*maxV a b c) [a*3,a+b,c,a+2*c]\nmaxV a b c = foldl max 0 [a,b,c]\n"}, {"source_code": "import Control.Applicative \nimport Control.Monad\n\nfun2 0 _ _ _ = 0\nfun2 1 a b c = min (min (3*a) (b+a)) c\nfun2 2 a b c = min (min (2*a) (2*c)) b\nfun2 3 a b c = min (min (b+c) (3*c)) a\n\nmain = do [n,a,b,c] <- map read.words <$> getLine\n putStrLn.show $ fun2 (mod n 4) a b c\n"}, {"source_code": "import Control.Applicative \nimport Control.Monad\n\nfun2 0 _ _ _ = 0\nfun2 1 a b c = min (min (3*a) (b+a)) c\nfun2 2 a b c = (2*a) `min` (2*c) `min` b\nfun2 3 a b c = (b+c) `min` (3*c) `min` a \n\nmain = do [n,a,b,c] <- map read.words <$> getLine\n putStrLn.show $ fun2 (mod n 4) a b c\n"}], "negative_code": [{"source_code": "main=interact(show.f.map read.words)\nf :: [Integer] -> Integer\nf (x:(xs@[a,b,c]))\n | x`mod`4 == 0 = 0\n | x`mod`4 == 3 = a\n | x`mod`4 == 2 = foldr min (foldr max 0 xs) [2*a, b]\n | otherwise = foldr min (foldr max 0 xs) [3*a, b+a, c]"}, {"source_code": "main=interact(show.f.map read.words)\nf :: [Integer] -> Integer\nf (x:[a,b,c])\n | x`mod`4 == 0 = 0\n | x`mod`4 == 3 = a\n | x`mod`4 == 2 = foldr min (4*b) [2*a, b]\n | otherwise = foldr min (4*b) [3*a, b+a, c]"}, {"source_code": "check :: Int -> (Int, Int, Int) -> Bool\ncheck n (na, nb, nc) =\n if (n + na + 2 * nb + 3 * nc) `mod` 4 == 0\n then\n True\n else\n False\n\nprice :: Int -> Int -> Int -> (Int, Int, Int) -> Int\nprice a b c (na, nb, nc) = a * na + b * nb + c * nc\n\ncartProd :: [Int] -> [Int] -> [Int] -> [(Int, Int, Int)]\ncartProd xs ys zs = [(x, y, z) | x <- xs, y <- ys, z <- zs]\n\ngoods :: Int -> [(Int, Int, Int)] -> [(Int, Int, Int)]\ngoods n xs = filter (check n) xs\n\ngen :: [(Int, Int, Int)]\ngen = cartProd [0..10] [0..10] [0..10]\n\ncalc :: Int -> Int -> Int -> Int -> Int\ncalc n a b c = foldr min (maxBound :: Int) (map (price a b c) (goods n gen))\n\nmain = do\n cs <- getContents\n let vals = words (head (lines cs))\n let n = read (vals!!0) :: Int\n let a = read (vals!!1) :: Int\n let b = read (vals!!2) :: Int\n let c = read (vals!!3) :: Int\n -- putStrLn (show (goods n gen)) -- debug\n putStrLn (show (calc n a b c))"}, {"source_code": "module Main (main) where\n\n\nmain :: IO ()\nmain = do\n l <- getLine\n let n:a:b:c:_ = map read $ words l :: [Integer]\n let t = (-n) `mod` 4\n print $ minimum [y1 * a + y2 * b + y3 * c | y1 <- [0,1,2,3], y2 <- [0,1,2], y3 <- [0,1], y1+2*y2+3*y3 == t]\n"}, {"source_code": "module Main (main) where\n\n\nmain :: IO ()\nmain = do\n l <- getLine\n let n:a:b:c:_ = map read $ words l :: [Integer]\n let t = n `mod` 4\n print $ minimum [y1 * a + y2 * b + y3 * c | y1 <- [0,1,2,3], y2 <- [0,1,2], y3 <- [0,1], y1+2*y2+3*y3 == t]\n"}, {"source_code": "import Control.Applicative\n\nmain = do\n\t[n,a,b,c] <- map read.words <$> getLine\n\tputStrLn.show $ buyPlan (need n) a b c\n\nneed :: Integer -> Integer\nneed n = 4 - n `mod` 4\n\nbuyPlan 4 _ _ _ = 0\nbuyPlan 1 a b c = a\nbuyPlan 2 a b c = if a*2 < b then a*2 else b\nbuyPlan 3 a b c = foldl min (3*maxV) [a*3,a+b,c] where\n\tmaxV = foldl max 0 [a,b,c]\n"}, {"source_code": "import Control.Applicative\n\nmain = do\n\t[n,a,b,c] <- map read.words <$> getLine\n\tputStrLn.show $ buyPlan (need n) a b c\n\nneed :: Integer -> Integer\nneed n = 4 - n `mod` 4\n\nbuyPlan 4 _ _ _ = 0\nbuyPlan 1 a b c = foldl min (3*maxV a b c) [a, 3*a+b, b+c]\nbuyPlan 2 a b c = foldl min (3*maxV a b c) [a*2, b, 2*c]\nbuyPlan 3 a b c = foldl min (3*maxV a b c) [a*3,a+b,c,a+2*c]\nmaxV a b c = foldl max 0 [a,b,c]\n"}, {"source_code": "import Control.Applicative\n\nmain = do\n\t[n,a,b,c] <- map read.words <$> getLine\n\tputStrLn.show $ buyPlan (need n) a b c\n\nneed :: Int -> Int\nneed n = 4 - n `mod` 4\n\nbuyPlan 4 _ _ _ = 0\nbuyPlan 1 a b c = a\nbuyPlan 2 a b c = if a*2 < b then a*2 else b\nbuyPlan 3 a b c = foldl min (3*maxV) [a*3,a+b,c] where\n\tmaxV = foldl max 0 [a,b,c]\n"}, {"source_code": "import Control.Applicative\n\nmain = do\n\t[n,a,b,c] <- map read.words <$> getLine\n\tputStrLn.show $ buyPlan (need n) a b c\n\nneed :: Int -> Int\nneed n = 4 - n `mod` 4\n\nbuyPlan 4 _ _ _ = 0\nbuyPlan 1 a b c = a\nbuyPlan 2 a b c = if a*2 < b then a*2 else b\nbuyPlan 3 a b c = foldl min (3*maxV) [a*3,a*2+b,c] where\n\tmaxV = foldl max 0 [a,b,c]\n"}, {"source_code": "import Control.Applicative\n\nmain = do\n\t[n,a,b,c] <- map read.words <$> getLine\n\tputStrLn.show $ buyPlan (need n) a b c\n\nneed :: Integer -> Integer\nneed n = 4 - n `mod` 4\n\nbuyPlan 4 _ _ _ = 0\nbuyPlan 1 a b c = foldl min (3*maxV a b c) [a, b, c]\nbuyPlan 2 a b c = foldl min (3*maxV a b c) [a*2, b,c]\nbuyPlan 3 a b c = foldl min (3*maxV a b c) [a*3,a+b,2*b,a*2+b,c]\nmaxV a b c = foldl max 0 [a,b,c]\n"}, {"source_code": "import Control.Applicative \nimport Control.Monad\n\nfun2 0 _ _ _ = 0\nfun2 1 a b c = min (min (3*a) (b+a)) c\nfun2 2 a b c = min (min (2*a) (2*c)) b\nfun2 3 a b c = min a (b+c)\n\nmain = do [n,a,b,c] <- map read.words <$> getLine\n putStrLn.show $ fun2 (mod n 4) a b c\n"}], "src_uid": "c74537b7e2032c1d928717dfe15ccfb8"} {"source_code": "main = do\n line <- getLine\n let n1::Int\n n2::Int\n [n1, n2, _, _] = map read $words line\n if n1 > n2 then\n putStrLn \"First\"\n else\n putStrLn \"Second\"", "positive_code": [{"source_code": "solve :: Int -> Int -> String\nsolve n1 n2\n | n1 > n2 = \"First\"\n | otherwise = \"Second\"\n\n \nmain = do\n str <- getLine\n let [ n1, n2, _, _ ] = map read $ words str\n putStrLn $ solve n1 n2"}, {"source_code": "readNums :: IO [Int]\nreadNums = getLine >>= return . map read . words\n\nmain = do\n [n1, n2, k1, k2] <- readNums\n putStrLn $ if n1 > n2 then \"First\" else \"Second\"\n"}, {"source_code": "main = do\n [n1, n2, k1, k2] <- fmap (map read . words) getLine :: IO [Int]\n\n putStrLn $ if n1 > n2 then \"First\" else \"Second\"\n"}, {"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = solve =<< (map (fst.fromJust.C.readInt).C.words <$>C.getLine)\nsolve [x,y,z,zz] = putStr $ if x>y then \"First\" else \"Second\""}, {"source_code": "main=interact$f.map read.words\nf (a:b:c)=if a+0>b then \"First\" else \"Second\""}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\ndata Player = First | Second deriving Show\n\nsolve :: [Int] -> Player\nsolve (n1:n2:_) = if n1 > n2 then First else Second\n"}, {"source_code": "main = interact $ solve . map read . words\nsolve[n1,n2,k1,k2]|n1<=(n2::Int)=\"Second\"|otherwise=\"First\"\n"}, {"source_code": "main = do\n input <- getLine\n let (a:b:_) = map read $ words input :: [Int]\n if a>b then putStrLn \"First\" else putStrLn \"Second\""}, {"source_code": "main = do\n line <- getLine\n let n1:n2:_ = map read (words line) :: [Int]\n result = if n1 > n2 then \"First\" else \"Second\"\n putStrLn result"}, {"source_code": "import System.IO\nimport Control.Monad\nimport Control.Applicative\n\nmain :: IO ()\nmain = do\n [n1, n2, k1, k2] <- map read <$> words <$> getLine :: IO [Int]\n putStrLn $ if n1 > n2\n then \"First\"\n else \"Second\"\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport qualified Data.ByteString.Char8 as C\nimport Data.Maybe\n \nmain=do\t \n\t[a,b,c,d]<- map read. words <$> getLine ::IO [Int]\n\tputStrLn $ if (a<=b) then \"Second\" \n else \"First\""}, {"source_code": "main = do\n [n1, n2, _, _] <- getLine >>= return. map read. words :: IO [Int]\n putStrLn $ if n1 > n2 then \"First\" else \"Second\"\n"}, {"source_code": "module Main where\n\nmain :: IO ()\nmain = do\n line <- getLine\n let [n1, n2, _, _] = map (\\c -> read c :: Int) (words line)\n let winner = case n1 > n2 of\n True -> \"First\"\n False -> \"Second\"\n putStrLn winner\n"}, {"source_code": "module Main where\n\nmain = do\n c <- getContents\n let (n1:n2:k1:k2:_) = map (read :: String -> Integer) $ words c\n putStrLn $ solve n1 n2 k1 k2\n\nsolve n1 n2 k1 k2\n | n1 == n2 = \"Second\"\n | n1 > n2 = \"First\"\n | n1 < n2 = \"Second\"\n"}, {"source_code": "solve n1 n2 k1 k2 \n | n1<=n2 =\"Second\"\n | n1>n2 = \"First\"\n where m1= div n1 k1\n m2= div n2 k2\n\nmain = do\n d<-getLine\n let [n1,n2,k1,k2]=map read $ words d\n putStrLn $ solve n1 n2 k1 k2"}, {"source_code": "main = do\n line <- getLine\n let\n l = map (read :: String -> Int) $ words line\n a = head l\n b = head $ tail l\n in putStrLn (if a <= b then \"Second\" else \"First\")\n"}, {"source_code": "import Data.Functor\nimport Control.Applicative\nimport Control.Monad\n\ndetermine :: [Int] -> String\ndetermine [n1, n2, k1, k2]\n | n1 > n2 = \"First\"\n | otherwise = \"Second\"\n\nmain :: IO ()\nmain = determine <$> map read <$> words <$> getLine >>= putStrLn\n"}], "negative_code": [{"source_code": "solve n1 n2 k1 k2 \n | n1<=n2 =\"Second\"\n | n1>n2 = \"First\"\n where m1= div n1 k1\n m2= div n2 k2\n\nmain = do\n d<-getLine\n let [n1,n2,k1,k2]=map read $ words d\n putStrLn $ show $ solve n1 n2 k1 k2"}, {"source_code": "solve :: Int -> Int -> String\nsolve n1 n2\n | n1 > n2 = \"First\"\n | otherwise = \"Second\"\n\n \nmain = do\n str <- getLine\n let [ n1, n2, _, _ ] = map read $ words str\n print $ solve n1 n2\n \n"}, {"source_code": "main = do\n input <- getLine\n let (a:b:_) = map read $ words input :: [Int]\n if a getLine ::IO [Int]\n\tprint $ if (a<=b) then \"Second\" \n else \"First\""}], "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b"} {"source_code": "{-# OPTIONS_GHC -O2 #-}\nimport Data.Int (Int64)\nmain = interact $ show.solve.map read.words\nsolve:: [Int64]->Int64\nsolve [a,b,k] = go 1 (a*b) \t\n\twhere (a',b') = (min a b, max a b)\n\t\tgo l r \n\t\t\t| l>r = l\n\t\t\t| s acc+min b' (quot m x)) 0 [1..a']\n", "positive_code": [{"source_code": "{-# OPTIONS_GHC -O2 #-}\n{-# LANGUAGE BangPatterns #-}\n\nimport Data.Int\nimport Data.List\n\nmain=interact$show.f.map read.words\n\nf :: [Int64] -> Int64\nf[n,m,k]\n | n > m = f [m,n,k]\n | otherwise = lowerBound p 1 $ n * m\n where\n p x = go 0 1\n where\n go !acc !i\n | i <= n = go (acc + min m (quot x i)) (i+1)\n | otherwise = k <= acc\n\nlowerBound :: (Integral i) => (i -> Bool) -> i -> i -> i\nlowerBound p low high = go low high\n where\n go !low !high\n | high <= low = high\n | p mid = go low mid\n | otherwise = go (mid + 1) high\n where\n mid = (low + high) `quot` 2\n{-# INLINE lowerBound #-}\n"}, {"source_code": "{-# OPTIONS_GHC -O2 #-}\nimport Data.Int (Int64)\nmain = interact $ show.solve.map read.words\nsolve:: [Int64]->Int64\nsolve [a,b,k] = go 1 (a*b) \t\n\twhere (a',b') = (min a b, max a b) \n\t\txs=[1..a']\n\t\tgo l r \n\t\t\t| l>r = l\n\t\t\t| s acc+min b' (quot m x)) 0 xs\n"}, {"source_code": "{-# OPTIONS_GHC -O2 #-}\n{-# LANGUAGE BangPatterns #-}\n\nimport Data.Int\nimport Data.List\n\nmain=interact$show.f.map read.words\n\nf :: [Int64] -> Int64\nf[n,m,k]\n | n > m = f [m,n,k]\n | otherwise = lowerBound p 1 $ n * m\n where\n p x = k <= foldl' (\\acc i -> acc + min m (quot x i)) 0 [1..n]\n\nlowerBound :: (Integral i) => (i -> Bool) -> i -> i -> i\nlowerBound p low high = go low high\n where\n go !low !high\n | high <= low = high\n | p mid = go low mid\n | otherwise = go (mid + 1) high\n where\n mid = (low + high) `quot` 2\n{-# INLINE lowerBound #-}\n"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE TypeFamilies #-}\n{-# LANGUAGE ViewPatterns #-}\n{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Control.Arrow\nimport Control.Monad\nimport Data.Array.IO\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as C\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Functor\nimport Data.Int\nimport qualified Data.IntMap as M\nimport Data.IORef\nimport Data.List\nimport Data.Maybe\nimport Data.Monoid\nimport qualified Data.Sequence as Seq\nimport qualified Data.Set as S\nimport Data.Word\nimport Debug.Trace\nimport Text.Printf\n\n-- I/O\n\nreadInts :: C.ByteString -> [Int]\nreadInts = map fst . mapMaybe C.readInt . C.words\n\ngetInts :: IO [Int]\ngetInts = readInts <$> C.getLine\n\nreadNums :: Num a => C.ByteString -> [a]\nreadNums = map (fromIntegral . fst) . mapMaybe C.readInteger . C.words\n\ngetNums :: Num a => IO [a]\ngetNums = readNums <$> C.getLine\n\ncast :: (Integral a, Integral b) => a -> b\ncast = fromIntegral\n\n-----\n\nmain :: IO ()\nmain = do\n [nn, mm, k] <- getNums\n\n let go :: Int64 -> Int64 -> Int64\n go !l !r\n | r - l <= 1 = r\n | mv < k = go m r\n | otherwise = go l m\n where\n !m = (l+r)`div`2\n !mv = calc m 1 0\n\n calc !x !i !acc\n | i > nn = acc\n | otherwise =\n calc x (i+1) $ acc + min mm (x`div`i)\n\n print (go 0 (nn*mm) :: Int64)\n"}], "negative_code": [{"source_code": "import Data.Int (Int64)\nmain = interact $ show.solve.map read.words\nsolve:: [Int64]->Int64\nsolve [a,b,k] = go 1 (a*b) \t\n\twhere (a',b') = (min a b, max a b) \n\t\tgo l r \n\t\t\t| l>r = r\n\t\t\t| s<=k = go (m+1) r\n\t\t\t| otherwise = go l (m-1)\n\t\t\twhere m = (l+r) `quot` 2\n\t\t \t s = sum [min b' $ quot m x | x<-[1..a']]\n"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE TypeFamilies #-}\n{-# LANGUAGE ViewPatterns #-}\n{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Control.Arrow\nimport Control.Monad\nimport Data.Array.IO\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as C\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Functor\nimport Data.Int\nimport qualified Data.IntMap as M\nimport Data.IORef\nimport Data.List\nimport Data.Maybe\nimport Data.Monoid\nimport qualified Data.Sequence as Seq\nimport qualified Data.Set as S\nimport Data.Word\nimport Debug.Trace\nimport Text.Printf\n\n-- I/O\n\nreadInts :: C.ByteString -> [Int]\nreadInts = map fst . mapMaybe C.readInt . C.words\n\ngetInts :: IO [Int]\ngetInts = readInts <$> C.getLine\n\nreadNums :: Num a => C.ByteString -> [a]\nreadNums = map (fromIntegral . fst) . mapMaybe C.readInteger . C.words\n\ngetNums :: Num a => IO [a]\ngetNums = readNums <$> C.getLine\n\ncast :: (Integral a, Integral b) => a -> b\ncast = fromIntegral\n\n-----\n\nmain :: IO ()\nmain = do\n [nn, mm, k] <- map cast <$> getInts\n\n let go :: Int64 -> Int64 -> Int64\n go !l !r\n | r - l <= 1 = r\n | mv < k = go m r\n | otherwise = go l m\n where\n m = (l+r)`div`2\n mv = calc m 1 0\n\n calc !x !i !acc\n | i > nn = acc\n | otherwise =\n calc x (i+1) $ acc + min mm (x`div`i)\n\n print (go 0 (nn*mm) :: Int64)\n"}], "src_uid": "13a918eca30799b240ceb9de47507a26"} {"source_code": "solve [a,b] = b*(b-1) `div` 2 * ( (b*a+1+b+1)*a `div` 2)\n \nmain = interact $ show . (`mod` (10^9+7)) . solve . map read . words\n", "positive_code": [{"source_code": "import Control.Applicative\n\nmain = do\n [a, b] <- fmap read . words <$> getLine :: IO [Integer]\n let x = b*(b-1)`div`2*(a+a*(a+1)`div`2*b)\n putStrLn.show $ x `mod` 1000000007"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\n-- x = p * b + q\n-- 1 <= q <= b - 1\n-- 1 <= k <= a\n-- p = q * k\nsolve :: [Integer] -> Integer\nsolve [a, b] = ((a + a * (a + 1) * b `div` 2) * (b * (b - 1) `div` 2)) `mod` 1000000007\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}\n{-# LANGUAGE BangPatterns, TupleSections, OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Exception\nimport Control.Monad\nimport Control.Monad.ST\nimport Data.Array.Base\nimport Data.Array.ST (runSTUArray, STArray, runSTArray)\nimport Data.Bits\nimport qualified Data.ByteString.Char8 as B\nimport Data.Char\nimport Data.Function\nimport Data.Int\nimport Data.List\nimport qualified Data.Map as M\nimport qualified Data.Set as S\nimport Data.STRef\nimport GHC.Arr (Array, Ix, range, unsafeIndex)\nbool :: a -> a -> Bool -> a\nbool t f b=if b then t else f\nreadInt :: B.ByteString -> Int\nreadInt bs=case B.readInt bs of{Just(n,_)->n;_->error$\"readInt error : bs = \"++show bs;}\nrep, rev :: Monad m => Int -> (Int -> m ()) -> m ()\nrep !n f=go 0 where go !i=when(i>go(i+1)\nrev !n f=go(n-1)where go !i=when(i>=0)$f i>>go(i-1)\n{-# INLINE rep #-}\n{-# INLINE rev #-}\nfor :: Monad m => Int -> (Int -> Bool) -> (Int -> Int) -> (Int -> m ()) -> m ()\nfor !i0 p next f=go i0 where go !i=when(p i)$f i>>go(next i)\n{-# INLINE for #-} \nmodifyArray :: (MArray a e m, Ix i) => a i e -> i -> (e -> e) -> m ()\nmodifyArray a i f=readArray a i>>=writeArray a i.f\n{-# INLINE modifyArray #-}\nunsafeModify :: (MArray a e m, Ix i) => a i e -> Int -> (e -> e) -> m ()\nunsafeModify a i f=unsafeRead a i>>=unsafeWrite a i.f\n{-# INLINE unsafeModify #-}\n\nmain :: IO ()\nmain = do\n [a,b] <- map read.words <$> getLine\n print $ solve a b\n\nsolve :: Integer -> Integer -> Integer\nsolve a b = (a*(a+1)*b*(b-1)*b`div`4 + b*(b-1)*a `div` 2) `mod` 1000000007"}, {"source_code": "niceSum :: [Integer] -> Integer\nniceSum [a, b] = product [(a+1) * b + 2, a, b, b-1] `div` 4 `mod` 1000000007\n\n\nmain = do\n getLine >>= print . niceSum . fmap read . words\n"}], "negative_code": [{"source_code": "solve [a,b] = b*(b-1) `div` 2 * ( (b*a+1+a+1)*a `div` 2)\n \nmain = interact $ show . (`mod` (10^9+7)) . solve . map read . words\n"}, {"source_code": "niceSum :: [Integer] -> Integer\nniceSum [a, b] = (`mod` 10000007) $ sum [r * (b*k + 1) | r <- [1..b-1], k <- [1..a]]\n\n\nmain = do\n getLine >>= print . niceSum . fmap read . words\n"}, {"source_code": "niceSum :: [Int] -> Int\nniceSum [a, b] = sum [r * (b*k + 1) | r <- [1..b-1], k <- [1..a]]\n\n\nmain = do\n getLine >>= print . niceSum . fmap read . words\n"}, {"source_code": "nice :: [Integer] -> [Integer]\nnice [a, b] = [x | x <- [1..a*b],\n mod x b /= 0,\n mod (quot x b) (mod x b) == 0,\n div (quot x b) (mod x b) >= 1,\n div (quot x b) (mod x b) <= a]\n \n\nmain = getLine >>= print . flip mod (10^9 + 7) . sum . nice . map read . words\n"}, {"source_code": "niceSum :: [Int] -> Int\nniceSum [a, b] = (`mod` 10000007) $ sum [r * (b*k + 1) | r <- [1..b-1], k <- [1..a]]\n\n\nmain = do\n getLine >>= print . niceSum . fmap read . words\n"}], "src_uid": "cd351d1190a92d094b2d929bf1e5c44f"} {"source_code": "import Data.Char\n\nsolve :: String -> String\nsolve (x:xs) = toUpper x:xs\n\nmain = do\n l <- getLine\n putStrLn $ solve l\n", "positive_code": [{"source_code": "import Data.Char\nmain = interact $ f\nf (a:b) = toUpper a:b"}, {"source_code": "import Data.Char (toUpper)\n\nmain :: IO ()\nmain = do\n (x:xs) <- getLine\n putStrLn $ toUpper x : xs"}, {"source_code": "import Data.Char\n\ncapitalize :: Int -> String -> String\ncapitalize _ [] = []\ncapitalize n as'@(a:as)\n | length as' > 1000 = error \"This input exceeded 1000!\"\n | a /= ' ' && n == 0 = toUpper a : capitalize (n + 1) as\n | a == ' ' = a : capitalize 0 as\n | otherwise = a : capitalize (n + 1) as\n\nmain = do\n a <- getLine\n putStrLn $ capitalize 0 a"}, {"source_code": "import Data.Char\nimport qualified Data.ByteString.Lazy.Char8 as B\nimport System.IO\n\nmain = do\n h <- B.hGet stdin 1\n B.putStr $ B.map toUpper h\n s <- B.getContents\n B.putStr s\n"}, {"source_code": "import Data.Char\n\nmain = do\n\tword <- getLine\n\tputStrLn $ (toUpper $ head word):(tail word)"}, {"source_code": "import Data.Char\n\nmain = do\n x <- getLine\n putStrLn $ toUpper (head x) : tail x\n"}, {"source_code": "import Data.Char (toUpper)\ncaps (a:ta) = putStrLn $ toUpper(a) : ta\nmain = getLine >>= caps"}, {"source_code": "import Control.Monad\nimport Data.Array\nimport Data.Char\nimport Data.List\nimport qualified Data.ByteString.Char8 as B\ngetList :: Read a => IO [a]\ngetList = fmap (map (read . B.unpack) . B.words) B.getLine\ngetIntList :: IO [Int]\ngetIntList = fmap (unfoldr (B.readInt . B.dropWhile isSpace)) B.getLine\n\nsolve :: String -> String\nsolve = liftM2 (:) (toUpper . head) tail\n\nmain :: IO ()\nmain = getLine >>= putStrLn . solve\n\n"}, {"source_code": "import Data.Char\nmain = getLine >>= putStrLn . (\\(a:xs) -> (toUpper a) : xs)\n"}, {"source_code": "import Data.Char\nsolve :: String -> String\n\nsolve (x:xs) = toUpper x : xs\n\nmain = interact $ solve . head . lines"}, {"source_code": "import Data.List\nimport Data.Char\nimport Control.Applicative\n\n\nmain::IO ()\nmain= do\n\n a<- getLine\n putStrLn $ toUpper (head a) : (tail a)\n"}, {"source_code": "import Data.Char\n\nmain = do\n\tword <- getLine\n\tputChar $ toUpper $ head word\n\tputStr $ tail word"}, {"source_code": "import Data.Char (toUpper)\n\nmain :: IO ()\nmain = getLine >>= putStrLn . solve\n\nsolve :: String -> String\nsolve (c:cs) = toUpper c : cs\nsolve \"\" = \"\"\n"}, {"source_code": "import Data.Char\n\nmain :: IO ()\nmain = do\n (s:ss) <- getLine\n putStrLn $ toUpper s : ss\n"}, {"source_code": "import Data.Char\n\ncap (ch:s) = (toUpper ch):s\n\nmain = do\n s <- getLine\n putStrLn (cap s)"}, {"source_code": "\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Char \n\nimport qualified Data.ByteString.Char8 as B\nreadInt = readLn :: IO Int\nreadInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine\n\ncapitalizeFirstLetter :: String -> String\ncapitalizeFirstLetter (h:t) = toUpper h : t \n\nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn $ capitalizeFirstLetter s"}, {"source_code": "-- 2019-11-24 21:47:05.045115024 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:17:40.15843636 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:18:58.633710023 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:18:10.124333946 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:17:13.461020752 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 21:52:26.915013781 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 21:51:48.386631631 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 21:53:08.323961168 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 21:45:31.658889409 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 21:46:46.102517843 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 21:53:31.589745836 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 21:46:10.365526662 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> String\nparser = head . lines\nsolve = \\a -> toUpper (hd a) : tail a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "import Data.Char\n\ncap :: String -> String\ncap s = toUpper (head s) : tail s\n\nmain = do\n interact $ cap\n"}, {"source_code": "import Control.Monad\nimport Data.Char\n\nmain :: IO ()\nmain = interact f\nf (c:cs) = toUpper c:cs\nf cs = cs\n"}, {"source_code": "import Data.Char\n\ncapitalize :: String -> String\ncapitalize (x:xs) = toUpper x:xs\n\nmain = do\n word <- getLine\n let modified = capitalize word\n putStrLn modified"}, {"source_code": "import Data.Char;main=interact(\\(c:s)->toUpper c:s)"}, {"source_code": "import Data.Char\nmain = interact (\\s -> (toUpper $ head s) : tail s)\n"}, {"source_code": "import Control.Monad\nimport Control.Applicative\nimport Data.List\nimport Data.Char\ngetNums :: (Read a,Num a) => IO [a]\ngetNums = map read. words <$> getLine\n\nmain = do\n (x:xs) <- getLine\n putStrLn (toUpper x:xs)\n"}, {"source_code": "import Data.Char\nmain = interact (\\y -> let x:xs = y in ((toUpper x) : xs))\n"}, {"source_code": "import Data.Char\n\nmain = do\n s <- getLine\n putStrLn $ (toUpper $ head s) : (tail s)"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/281/A\n\nimport Data.Char\n\nmain = do\n line <- getLine\n putStrLn ((toUpper $ head line) : (tail line))\n"}, {"source_code": "import Data.Char\nmain=interact(\\(c:s)->toUpper c:s)"}, {"source_code": "import Data.Char;main=interact(\\(c:s)->toUpper c:s)"}, {"source_code": "module Main where\nimport Control.Applicative\nimport Data.Char\nmain = getLine >>= \\word -> putStrLn $ toUpper (head word) : drop 1 word\n"}, {"source_code": "import Data.Char\nmain = interact $ (\\(x:xs) -> toUpper x : xs) . head . words"}, {"source_code": "import Data.Char\nmain=interact f\nf(c:cs)=toUpper c:cs\nf cs=cs\n"}, {"source_code": "import Data.Char\nfStr str = (:) (toUpper $ head str) ( tail str)\n\nmain :: IO ()\nmain = do\n a <- getLine\n putStrLn $ fStr a"}, {"source_code": "import System.IO\nimport Data.Char\n\nsolve :: String -> String\nsolve (a:as) = (toUpper a) : as\n \nmain = getLine >>= (\\str -> putStrLn $ solve str) "}, {"source_code": "import Data.Char\n\nf :: [Char] -> [Char]\nf [] = []\nf (x:xs) = if (length (x:xs)) <= 1000 then (if isUpper x == True then [x]++xs else convertFst (x:xs)) else \"error\"\n\nconvertFst :: [Char] -> [Char]\nconvertFst [] = []\nconvertFst (x:xs) = [(toUpper x)]++xs\n\nmain = do \n xs <- getLine\n putStrLn (f xs)\n"}, {"source_code": "import Control.Monad\nimport Data.Char\n\nmain = interact program\n\nprogram :: String -> String\nprogram (l:xs) = (toUpper l):xs "}, {"source_code": "\nimport Data.Char\n\nmain = do\n input <- getLine\n putStrLn ([toUpper (head input)] ++ (tail input))\n\n"}, {"source_code": "import Data.Char\nmain = getLine >>= putStrLn . (\\(x:xs) -> toUpper x : xs)"}, {"source_code": "import Data.Char (toUpper)\n\nmain = do\n (x:xs) <- getLine\n putStrLn $ toUpper x : xs\n"}, {"source_code": "import Data.Char\n\ncap :: String -> String\ncap s =\n [toUpper (head s)] ++ (tail s)\n\nmain = do\n s <- getLine\n putStrLn (cap s)"}, {"source_code": "module Main where\n\nimport Data.Char\n\ncapitalize :: String -> String\ncapitalize \"\" = \"\"\ncapitalize (l:ls) = toUpper l : ls\n\nmain = getLine >>= (putStrLn . capitalize)\n"}, {"source_code": "import Data.Char\nmain = do w <- getLine\n putStrLn (toUpper (head w) : (tail w))\n"}, {"source_code": "import Control.Applicative\nimport Data.Char\nimport Data.List\n\nmain= do\n \ts<-getLine \n\tputStrLn $ (toUpper (head s)) : (tail s)"}, {"source_code": "{-\nA. Word Capitalization\n=======================\ntime limit per test: 2 seconds\nmemory limit per test: 256 megabytes\ninput: standard input\noutput: standard output\n\nCapitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.\n\nNote, that during capitalization all the letters except the first one remains unchanged.\n\nInput\n------\nA single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103.\n\nOutput\n------\nOutput the given word after capitalization.\n\nSample test(s)\n---------------\ninput\nApPLe\noutput\nApPLe\ninput\nkonjac\noutput\nKonjac\n\n-}\nimport Data.Char (toUpper)\n\ncapitalize :: String -> String\ncapitalize \"\" = \"\"\ncapitalize (x:xs) = (toUpper x) : xs\n\nmain = do \n input <- getLine\n putStrLn $ capitalize input\n"}, {"source_code": "import Data.Char\nmain = do\n n <- getLine\n let m = cap n\n putStrLn m\ncap :: String -> String\ncap [] = []\ncap (x:xs) = toUpper x : xs"}, {"source_code": "import Data.Char ( toUpper )\nmain :: IO ()\nmain = do\n (f:s) <- getLine\n putStrLn $ toUpper f:s\n"}, {"source_code": "import Data.Char\n\n\nanswer::String->String\nanswer (x:xs) = toUpper x : xs \n\nsomeFunc :: IO()\nsomeFunc = getLine >>= putStrLn . answer\n \nmain :: IO ()\nmain = someFunc"}, {"source_code": "import Control.Monad\nimport Data.Char\n\nmain = getLine >>= putStrLn . capitalize\n\ncapitalize :: String -> String\ncapitalize (x:xs) = (toUpper x):xs\n"}, {"source_code": "import Data.Char\n\nmain = getLine >>= putStrLn.solve\nsolve (h:t) = toUpper h : t\n"}, {"source_code": "import Data.Char\n\ncapitalize :: String -> String\ncapitalize (x:xs) = toUpper x:xs\n\nmain = do\n str <- getLine\n putStrLn $ capitalize str"}, {"source_code": "import Data.Char\n\nmain = interact (\\(x:xs) -> toUpper x:xs)"}, {"source_code": "import Data.Char\nmain = do\n inp <- getLine\n putStrLn $ (toUpper . head) inp : tail inp\n"}, {"source_code": "import Data.Char\n\nsolve :: String -> String\nsolve s = toUpper (head s) : tail s\n\nmain :: IO ()\nmain = interact solve"}, {"source_code": "import Data.Char\nrun (x:xs) = [toUpper x] ++ xs\nmain = interact run "}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Char\n\nmain = do\n\t( c:cs ) <- getLine\n\tputStrLn $ ( toUpper c ) : cs\n"}, {"source_code": "import Data.Char\n\nmain = do\n (a:as) <- getLine\n putStrLn $ toUpper a : as\n"}, {"source_code": "module Main (main)\n where\n\nimport Data.Char (toUpper)\n\n\nmain :: IO ()\nmain = putStrLn . (\\(x:xs) -> toUpper x:xs) =<< getLine"}, {"source_code": "import Data.Char (toUpper)\n\nup :: String -> String\nup [] = []\nup (x:xs) = toUpper x : xs\n\nmain = interact $ up\n"}, {"source_code": "import Control.Monad\nimport Data.List\nimport Data.Char\n\nmain :: IO ()\nmain = do\n line <- getLine\n putStrLn ((toUpper $ head line) : (tail line))"}, {"source_code": "import Data.Char\nmain=interact(\\(x:s)->toUpper x:s)"}, {"source_code": "import Data.Char\nmain = interact $ solve\nsolve s = [toUpper (head s)] ++ (tail s)"}, {"source_code": "\nimport Data.Char\n\nsolve :: String -> String\nsolve [] = []\nsolve (x:xs) = toUpper x : xs\n\nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn $ solve s\n"}, {"source_code": "import Data.Char\n\n\ncap uu = [(toUpper (head uu))] ++ (tail uu)\n\nmain = do\n ff <- getLine\n putStrLn (cap ff)\n"}, {"source_code": "import Data.Char\n\nmain = do\n s1 : sn <- getLine\n putStrLn $ toUpper s1 : sn\n"}, {"source_code": "import Data.Char\n\nsolve :: String -> String\nsolve (x:xs) = toUpper x : xs\nsolve [] = []\n\nmain :: IO ()\nmain = do\n\ts <- getLine\n\tputStrLn $ solve s"}, {"source_code": "import Data.Char\n\nmain :: IO ()\nmain = interact solve\n\nsolve :: String -> String\nsolve (x : xs) = toUpper x : xs\n"}, {"source_code": "import Data.Char (toUpper)\n\nmain :: IO ()\nmain = do\n word <- getLine\n putStrLn $ capitalize word\n\ncapitalize :: String -> String\ncapitalize (x:xs) = (toUpper x) : xs"}, {"source_code": "import Data.Char\n\nsolve (h:hs) = toUpper h : hs\nmain = putStrLn . solve =<< getLine"}, {"source_code": "import Data.Char\nmain = interact $ f\nf (x:xs) = toUpper x:xs\n"}, {"source_code": "import qualified Data.Char as Ch\n\nmain :: IO ()\nmain = do\n nStr <- getLine\n putStrLn $ (Ch.toUpper (head nStr)) : (tail nStr)"}, {"source_code": "import Data.Char\n\nmain = do\n s <- getLine\n putStrLn $ (toUpper $ head s):(tail s)"}, {"source_code": "import Data.Char\n\nmain = interact(\\(x:xs) -> toUpper x:xs)"}, {"source_code": "\nimport Data.Char\n\n\nf (ch:s) = (toUpper ch):s \n\nmain = do \n s <- getLine\n putStrLn (f s)\n\n"}, {"source_code": "import Data.Char\nmain = interact $ \\ (x : xs) -> toUpper x : xs"}, {"source_code": "import Data.List\nimport Data.List.Split\nimport Data.Char\n\n(|>) x f = f x\nmain = interact solve\n\nsolve contents = let\n word = contents |> lines |> head\n in capitalize word\n \ncapitalize word = (head word |> toUpper):(tail word)"}, {"source_code": "import Data.Char\n\ncapFst :: String -> String\ncapFst (x:xs) = (toUpper x) : xs\n\nmain :: IO()\nmain = do n <- getLine\n putStr $ capFst n\n"}, {"source_code": "import Data.Char\n\nmain = do\n\t(h:t) <- getLine\n\tputStrLn $ (toUpper h):t"}, {"source_code": "import Data.Char\n\nmain = do\n str <- getLine\n let ans = (toUpper (head str)):(tail str)\n putStrLn ans\n"}, {"source_code": "import Data.Char\n\nmain = getLine >>= putStrLn . solve\n\nsolve s@(c:cs)\n | 'a' <= c && c <= 'z' = chr(ord c - 32):cs\n | otherwise = s \n\n"}, {"source_code": "import Data.Char\nmain=interact$(\\(x:xs)->(toUpper x):xs).head.lines"}, {"source_code": "import Data.List\nimport Data.Char\n\ncapitalize (x:xs) = (toUpper x) : xs\ncapitalize lst = lst\n\nmain = interact capitalize\n"}, {"source_code": "import Data.Char\nmain = readsolveprint\nreadsolveprint::IO()\nreadsolveprint= getLine >>= putStr.solve\nsolve :: String->String\nsolve (x:xs) = (toUpper x): xs"}, {"source_code": "import Data.Char\n\ncap :: [Char] -> [Char]\ncap (x:xs) = toUpper x : xs\n\nmain = do\n s <- getLine\n putStr $ cap s\n"}, {"source_code": "\nimport Data.Char (toUpper)\n\nsolve :: String -> String\nsolve (c:s) = toUpper c : s\n\nmain :: IO ()\nmain = getLine >>= putStrLn . solve\n"}, {"source_code": "import Data.Char (toUpper)\n\ncapitalize :: [Char] -> [Char]\ncapitalize \"\" = \"\"\ncapitalize (x:xs) = (toUpper x) : xs\n\nmain :: IO()\nmain = getLine >>= putStrLn . capitalize"}, {"source_code": "-- Codefoces 281A\n\nimport Data.Char\n\nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn $ [(toUpper $ head s)] ++ (tail s)\n"}, {"source_code": "import Control.Monad\nimport Data.Char\nmain=interact$ap((:).toUpper.head)tail"}, {"source_code": "import Data.Char\n\nmain = getLine >>= putStrLn.capitalize\n\ncapitalize (a:str) = toUpper a:str\n"}], "negative_code": [{"source_code": "import Data.List\nmain = getLine >>= putStrLn . intersperse '+' . sort . filter (/='+')\n"}, {"source_code": "import Data.Char\n\nsolve :: String -> String\nsolve (x:xs) = toUpper x:xs\n\nmain = do\n l <- getLine\n print $ solve l\n"}, {"source_code": "import Data.Char (toUpper)\n\ncapitalize :: [Char] -> [Char]\ncapitalize \"\" = \"\"\ncapitalize (x:xs) = (toUpper x) : xs\n\nmain :: IO()\nmain = getLine >>= print . capitalize"}, {"source_code": "import Data.List\nimport Data.Char\nimport Control.Applicative\n\n\nmain::IO ()\nmain= do\n\n a<- map toLower <$> getLine\n putStrLn $ toUpper (head a) : (tail a)\n"}, {"source_code": "\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Char \n\nimport qualified Data.ByteString.Char8 as B\nreadInt = readLn :: IO Int\nreadInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine\n\ncapitalizeFirstLetter :: String -> String\ncapitalizeFirstLetter (h:t) = toUpper h : t \n\nmain :: IO ()\nmain = do\n s <- getLine\n print $ capitalizeFirstLetter s"}, {"source_code": "\nimport Data.Char\n\nallLower a = if null a then \"\" else [toLower (head a)] ++ allLower (tail a)\n\ncapitalize word\n | null word = \"\"\n | otherwise = [toUpper (head word)] ++ (allLower (tail word))\n\nmain = do\n input <- getLine\n putStrLn (capitalize input)\n\n"}, {"source_code": "import Data.Char\ncap :: String -> String\ncap s =\n [toUpper (head s)] ++ (tail s)\n\nmain = do\n s <- getLine\n print (cap s)"}, {"source_code": "import Data.Text as T\nimport Data.Text.IO as TIO\n\nmain = TIO.putStrLn . T.toTitle =<< TIO.getLine"}, {"source_code": "import Data.Char\n\nmain = do\n s <- getLine\n print $ (toUpper $ head s):(tail s)"}], "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4"} {"source_code": "module Main where\n\nimport Control.Monad\nimport Data.Int\n\nmain = do\n n <- read `liftM` getLine :: IO Int64\n putStrLn $ head $ filter ( ( >= n ) . read ) $ balancePermGen '4' '7'\n\nbalancePermGen :: a -> a -> [[a]]\nbalancePermGen m1 m2 = foldr (\\len later ->\n let balancePermGen' 0 0 = return []\n balancePermGen' 0 _ = fail \"\"\n balancePermGen' len skew =\n ( balancePermGen' (len-1) (skew-1) >>= return . ( m1 : ) . ( m1 : ) )\n `mplus`\n ( balancePermGen' (len-1) skew >>= return . ( m1 : ) . ( m2 : ) )\n `mplus`\n ( balancePermGen' (len-1) skew >>= return . ( m2 : ) . ( m1 : ) )\n `mplus`\n ( balancePermGen' (len-1) (skew+1) >>= return . ( m2 : ) . ( m2 : ) )\n in ( balancePermGen' len 0 ) ++ later\n ) [] [1..]\n", "positive_code": [{"source_code": "import Data.Char\n\nsuperlucky n = test 0 0 n\n where \n test n4 n7 [] = n4 == n7\n test n4 n7 ('4':s) = test (n4+1) n7 s\n test n4 n7 ('7':s) = test n4 (n7+1) s\n test n4 n7 _ = False\n\nnext n\n | n==[] = \"4\"\n | (digitToInt (last n))<4 = init n ++ \"4\"\n | (digitToInt (last n))<7 = init n ++ \"7\"\n | otherwise = next (init n) ++ \"4\"\n\nstream n = n: stream (next n)\n\nmain = do\n n <- getLine\n putStrLn $ head $ filter superlucky $ stream n\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\ngen n = map (foldl1 (\\z a->z*10+a) ) $ filter (\\z-> length(filter (==4) z)==n) $ replicateM (n+n) [4,7]\nb = concat $ map gen [1,2,3,4,5]\n\n\nmain= do\n\t\ta<- read <$> getLine ::IO Integer\n\t\tprint $ head $ dropWhile ( digits 4 x == digits 7 x) luckys'\n\nmain = do\n\tinput <- fmap C.lines $ C.hGetContents stdin\n\tlet n = fst . fromJust . C.readInteger $ head input\n\t(print . fromJust . find ((<=) n)) luckys\n"}, {"source_code": "ok 0 0 = True\nok _ 0 = False\nok d n = if n `mod` 10 == 4\n then ok (d+1) (n `div` 10)\n else ok (d-1) (n `div` 10)\n\nn 0 = 4\nn x = if x `mod` 10 == 4\n then x + 3\n else (n $ (x `div` 10)) * 10 + 4\n\nmain = do\n s <- getLine\n print $ head $ dropWhile (< read s) $ filter (ok 0) $ iterate n 4\n"}, {"source_code": "import Data.List\n\nok s = do\n let a = group $ sort s\n length a == 2 && (length $ head a) == (length $ head $ tail a) && (nub $ sort s) == \"47\"\n\nnext [] = \"4\"\nnext (x:xs) = if x == '4' then (['7'] ++ xs) else (['4'] ++ next xs)\n\ndoit s = if ok s then s else doit (next s)\n\ncanonize [] = []\ncanonize (x:xs) | x < '4' = ['4'] ++ replicate (length xs) '4'\n | x == '4' = ['4'] ++ canonize xs\n | x < '7' = ['7'] ++ replicate (length xs) '4'\n | x == '7' = ['7'] ++ canonize xs\n | otherwise = ['z'] ++ replicate (length xs) '7'\n\nmain = do\n s <- getLine\n putStrLn $ reverse $ doit $ reverse $ canonize s\n"}, {"source_code": "--96B\n\nnext :: String -> String\nnext s\n | all (== '7') s = replicate (length s + 1) '4'\n | otherwise = reverse $ next' $ reverse s\n where\n next' ('4':s) = '7' : s\n next' ('7':s) = '4' : next' s\n next' _ = \"4\"\n\nhappy :: [String]\nhappy = iterate next \"4\"\n\nveryHappy :: [Integer]\nveryHappy = map read $ filter isVeryHappy happy\n where\n isVeryHappy x = length (filter (== '4') x) * 2 == length x\n\nsolve :: Integer -> Integer\nsolve n = head $ dropWhile (< n) veryHappy\n\nmain :: IO ()\nmain = readLn >>= print . solve"}, {"source_code": "\nimport Data.List\n\nmain = interact $ unlines . map solve . lines\n\nsls :: Int -> [Integer]\nsls i = sort $ map read (gen j j)\n where \n j = i `div` 2\n gen :: Int -> Int -> [String]\n gen 0 0 = []\n gen n 0 = [replicate n '4']\n gen 0 m = [replicate m '7']\n gen n m = do\n c <- ['4', '7']\n let n' = if c == '4' then n-1 else n\n m' = if c == '7' then m-1 else m\n rest <- gen n' m'\n return (c:rest)\n\nsll :: Int -> Integer\nsll i = read (replicate j '4' ++ replicate j '7')\n where j = i `div` 2\n\nslu :: Int -> Integer\nslu i = read (replicate j '7' ++ replicate j '4')\n where j = i `div` 2\n\nsolve s \n | odd (length s) = show $ head (sls (length s + 1))\n | even (length s) = \n case (dropWhile (< read s) (sls (length s))) of\n [] -> show $ head (sls (length s + 2))\n lst -> show $ head (dropWhile (< read s) lst)\n"}, {"source_code": "-- If some1 can understand this piece of shit ........ he's insane *sob sob*\n\nimport Data.List\n\nmain :: IO()\nmain = do\n x <- getLine\n\tputStr $ show $ solveLucky $ read x\n\ndigs :: Integral x => x -> [x]\ndigs 0 = []\ndigs x = digs (x `div` 10) ++ [x `mod` 10]\n\nfromDigs :: Integral x => [x] -> x\nfromDigs []\t= 0\nfromDigs (x:xs) = x * 10 ^ length xs + fromDigs xs\n\nsolveLucky :: Integer -> Integer\nsolveLucky x\n\t| (length $ digs x) `mod` 2 == 1\t= printNext x\n\t| x > biggestEven\t\t\t= solveLucky ( fromDigs $ digs x ++ [0] )\n\t| otherwise\t\t\t\t= compute x\n\t\twhere\n\t\t\tprintNext x = fromDigs $ replicate len 4 ++ replicate len 7\n\t\t\t\twhere len = (length $ digs x) `quot` 2 + 1\n\t\t\tbiggestEven = fromDigs $ (replicate len 7 ++ replicate len 4)\n\t\t\t\twhere len = (length $ digs x) `quot` 2\n\t\t\tcompute x = fromDigs $ com $ digs x\n\nisLucky :: Integer -> Bool\nisLucky n = f 4 == f 7 && f 4 /= 0\n\t\twhere \n\t\t\tf t = length [ x | x <- digs n, x == t]\n\ncanBeLucky :: [Integer] -> Integer -> Bool\ncanBeLucky xs sm \n\t| fromIntegral (length [ x | x <- xs, x == 4]) <= sm && fromIntegral (length [ x | x <- xs, x == 7]) <= sm && (length [ x | x <- xs, x == 4] + length [ x | x <- xs, x == 7]) == length xs\t= True\n\t| otherwise\t \t\t= False\n\ncom :: [Integer] -> [Integer]\ncom list@(x:xs)\n\t| x < 4\t\t = replicate len 4 ++ replicate len 7\n\t| x > 4 && x < 7 = [7] ++ replicate len 4 ++ replicate (len - 1) 7\n\t| otherwise \t = solve list\n\t\twhere \n\t\t\tlen = length list `quot` 2\n\t\t\tsolve list = solve' (x:xs) (fromIntegral (length list) `quot` 2) []\n\t\t\tsolve' :: [Integer] -> Integer -> [Integer] -> [Integer]\n\t\t\tsolve' [] n acc\t\t\t \n\t\t\t\t| (lastEl == 4 || lastEl == 7) && (isLucky (fromDigs acc) == True) = acc\n\t\t\t\t| lastEl < 4 && (isLucky (fromDigs $ take (length acc - 1) acc ++ [4]) == True)\t= take (length acc - 1) acc ++ [4]\n\t\t\t\t| lastEl > 4 && lastEl < 7 && (isLucky (fromDigs $ take (length acc - 1) acc ++ [7]) == True) \t= take (length acc - 1) acc ++ [7]\n\t\t\t\t| otherwise\t\t\t\t\t\t\t \t\t\t\t\t= solve' (reverse $ trySolve $ reverse acc) n []\n\t\t\t\t\twhere\n\t\t\t\t\t\tlastEl = acc !! (length acc - 1)\n\t\t\t\t\t\ttrySolve (x:xs)\n\t\t\t\t\t\t\t| x == 4\t= 7 : xs\n\t\t\t\t\t\t\t| otherwise\t= 0 : (trySolve xs)\n\t\t\tsolve' (x:xs) n acc \n\t\t\t\t| canBeLucky acc n == False = finally (take (length acc - 1) acc) (acc !! (length acc - 1)) (fromIntegral n)\n\t\t\t\t| otherwise\t = solve' xs n (acc ++ [x] )\n\t\t\tfinally xs e n\n\t\t\t\t| e < 4\t\t\t= computeRest (xs ++ [4]) n\n\t\t\t\t| e > 4 && e < 7\t= computeRest (xs ++ [7]) n\n\t\t\t\t| otherwise\t\t= solve' ((reverse $ trySolve $ reverse xs) ++ replicate (n * 2 - length xs) 0) (fromIntegral n) []\n\t\t\t\t\twhere \n\t\t\t\t\t\ttrySolve (x:xs)\n\t\t\t\t\t\t\t| x == 4\t= 7 : xs\n\t\t\t\t\t\t\t| otherwise\t= 0 : (trySolve xs)\n\t\t\tcomputeRest xs n \n\t\t\t\t| length xs == n * 2\t\t\t= xs\n\t\t\t\t| length [ t | t <- xs, t == 4] < n \t= computeRest (xs ++ [4]) n\n\t\t\t\t| length [ t | t <- xs, t == 7] < n \t= computeRest (xs ++ [7]) n"}, {"source_code": "import Prelude\nimport List\nimport Char\nimport Data.Ord\nimport Data.List\n\nmain = interact q\n\nq = func\n\nfunc::String->String\nfunc = show . solve . read\n\ntoInt::String->Int\ntoInt = read\ntoString::Int->String\ntoString=show\n\nsolve::Integer->Integer\nsolve a = ans a 0\n\nans::Integer->Integer->Integer\nans a i | not (superlucky i') = ans a (i+1)\n | a <= n = n\n | otherwise = ans a (i+1)\n where\n i' = lucky i\n n = read i'\n\nlucky::Integer->String\nlucky = lucky' \"\"\n where\n lucky' s a | a==0 = s\n | a == 1 = s\n | a `mod` 2 == 0 = lucky' ('4':s) (a `div` 2)\n | a `mod` 2 == 1 = lucky' ('7':s) (a `div` 2)\n\nsuperlucky::String->Bool\nsuperlucky a = length a' == 2 && a'!!0 == a'!!1\n where\n a' = map length $ group $ sort a"}, {"source_code": "import Data.Functor ((<$))\nimport Data.List\nf (i4, i7) | (i4, i7) > (0, 0) = (if i4 > 0 then map ('4':) $ f(i4-1, i7) else []) ++\n (if i7 > 0 then map ('7':) $ f (i4, i7-1) else [])\n | otherwise = [\"\"]\n \nmain = do\n n' <- getLine\n let l = length n'\n x = if odd l then let w = replicate ((l+1) `div` 2) '4' in w ++ ('7' <$ w)\n else (let\n l' = l `div` 2\n w' = replicate (l `div` 2) '4' \n w1 = w' ++ ('7' <$ w')\n w2 = ('7' <$ w') ++ w' in if n' > w2 then \n let w = replicate (l `div` 2 + 1) '4' in w ++ ('7' <$ w) else\n head (dropWhile (n' >) (sort $ f (l', l'))))\n putStrLn x\n"}, {"source_code": "import Data.List (nub)\npos = \"\" : words \"44 47 74 77\"\ninclude xs = (div (length xs) 2) == sum (map (fromEnum . (=='4')) xs)\nslucks = (map read . filter include . map concat . nub) lucky \n where lucky = (tail . sequence) (replicate 4 pos)\nsolve :: Integer -> Integer\nsolve n = if null f then 4444477777 else minimum f\n where f = filter (>=n) slucks\nmain = putStrLn . show . solve . read =<< getLine"}, {"source_code": "check [] = 0\ncheck (x:y)\n | (fst x) == (snd x) = check y\n | (fst x) > (snd x) = 1\n | otherwise = -1\ngt [] [] = 0\ngt a b = check (zip a b)\n \ngen l = take (l `div` 2) (repeat '4') ++ take (l `div` 2) (repeat '7')\ngenI l = take (l `div` 2) (repeat 4) ++ take (l `div` 2) (repeat 7)\nbrk x= [read (i:[]) :: Int | i <-x]\n\ns :: [Int] -> Int -> Int -> [Int] -> [Int] -> [Int]\ns [] _ _ r1 r2\n | (gt r1 r2) == -1 = []\n | otherwise = r1 \n \ns (x:y) c4 c7 r1 r2\n | (d == 1) && (c4 > 0) = a\n | (d == 1) = b\n | (d == -1) = []\n | (x < 4) && (c4 > 0) = a\n | (x == 4) && (c4 > 0) && ((length a) > 0) = a\n | (x == 4) && (c7 > 0) && ((length b) > 0) = b\n | (c7 > 0) = b\n | otherwise = []\n where\n d = (gt r1 r2)\n a = s y (c4-1) c7 (r1++[4]) (r2++[x])\n b = s y c4 (c7-1) (r1++[7]) (r2++[x])\n\nfix [] l = genI (l+2)\nfix x l = x\n\nf s = [(show x)!!0 | x <- s]\nso x\n | (head x) > 7 = gen ((length x) + 2)\n | (head x) < 4 = gen (length x) \n | ((head x) > 4) && ((head x) < 7) = \"7\"++ (take ((length x) `div` 2) (repeat '4')) ++ (take (((length x) `div` 2) - 1) (repeat '4'))\n | otherwise = f (fix (s x l l [] []) (length x))\n where l = ((length x) `div` 2)\nsol x\n | (mod (length x) 2) == 1 = gen ((length x) + 1)\n | otherwise = so x\nmain = interact $ sol. brk. head . lines"}, {"source_code": "{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport Data.Array.IArray\nimport Data.Array.Unboxed (UArray)\nimport Data.Int\nimport Data.Ratio\nimport Data.Bits\nimport Data.Function\nimport Data.Ord\n--import Control.Monad.State\nimport Control.Monad\nimport Control.Applicative\nimport Data.ByteString.Char8 (ByteString)\nimport qualified Data.ByteString.Char8 as BS\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\nimport Data.Sequence (Seq, (<|), (|>), (><), ViewL(..), ViewR(..))\nimport qualified Data.Sequence as Seq\nimport qualified Data.Foldable as F\nimport Data.Graph\n\nparseInput = do \n n <- readString\n return $ BS.unpack n\n where\n readInt = state $ fromJust . BS.readInt . BS.dropWhile isSpace\n readInteger = state $ fromJust . BS.readInteger . BS.dropWhile isSpace\n readString = state $ BS.span (not . isSpace) . BS.dropWhile isSpace\n readLine = state $ BS.span (not . isEoln) . BS.dropWhile isEoln\n isEoln ch = ch == '\\r' || ch == '\\n'\n\nmain = putStrLn =<< solve . evalState parseInput <$> BS.getContents\n\ncheck :: String -> Bool\ncheck n = length (filter (=='4') n) * 2 == len && length (filter (=='7') n) * 2 == len\n where\n len = length n\n\nsolve :: String -> String\nsolve n\n | check n = n\n | null lst = replicate (len'+1) '4' ++ replicate (len'+1) '7'\n | otherwise = head lst\n where\n len = length n\n len' = len `div` 2\n\n count target = listArray (0, len) $ scanl (\\num ch -> if ch == target then num + 1 else num) 0 n :: UArray Int Int\n count4 = count '4'\n count7 = count '7'\n\n lst = [ take pos n ++ [ch'] ++ replicate (len' - c4') '4' ++ replicate (len' - c7') '7'\n | even len\n , (pos,ch) <- zip [len-1,len-2..0] (reverse n)\n , let c4 = count4 ! pos\n , let c7 = count7 ! pos\n , c4 + c7 == pos\n , ch' <- [succ ch..'9']\n , ch' == '4' || ch' == '7'\n , let (c4', c7') = if ch' == '4' then (c4+1, c7) else (c4, c7+1)\n , abs (c4' - c7') <= len - 1 - pos\n ]\n \n\n----------------------------------------------------------------------\n----------------------------------------------------------------------\n----------------------------------------------------------------------\n\nclass (Monad m) => MonadState s m | m -> s where\n\tget :: m s\n\tput :: s -> m ()\n\nmodify :: (MonadState s m) => (s -> s) -> m ()\nmodify f = do\n\ts <- get\n\tput (f s)\n\ngets :: (MonadState s m) => (s -> a) -> m a\ngets f = do\n\ts <- get\n\treturn (f s)\n\nnewtype State s a = State { runState :: s -> (a, s) }\n\ninstance Functor (State s) where\n\tfmap f m = State $ \\s -> let\n\t\t(a, s') = runState m s\n\t\tin (f a, s')\n\ninstance Applicative (State s) where\n pure = return\n (<*>) = ap\n\ninstance Monad (State s) where\n\treturn a = State $ \\s -> (a, s)\n\tm >>= k = State $ \\s -> let\n\t\t(a, s') = runState m s\n\t\tin runState (k a) s'\n\ninstance MonadState s (State s) where\n\tget = State $ \\s -> (s, s)\n\tput s = State $ \\_ -> ((), s)\n\nevalState :: State s a -> s -> a\nevalState m s = fst (runState m s)\n\nexecState :: State s a -> s -> s\nexecState m s = snd (runState m s)\n\nmapState :: ((a, s) -> (b, s)) -> State s a -> State s b\nmapState f m = State $ f . runState m\n\nwithState :: (s -> s) -> State s a -> State s a\nwithState f m = State $ runState m . f\n\nstate = State\n"}], "negative_code": [{"source_code": "import qualified Data.ByteString.Lazy.Char8 as C\nimport IO\nimport Data.Maybe\nimport Data.List\n\ndigits x 0 = 0\ndigits x y = digits x (y `div` 10) + if y `mod` 10 == x then 1 else 0\n\nluckys' = [4, 7] ++ concat [ [x*10+4, x*10+7] | x <- luckys' ]\nluckys = filter (\\x -> digits 4 x == digits 7 x) luckys'\n\nmain = do\n\tinput <- fmap C.lines $ C.hGetContents stdin\n\tlet n = fst . fromJust . C.readInt $ head input\n\t(print . fromJust . find ((<=) n)) luckys\n"}, {"source_code": "\nimport Data.List\n\nmain = interact $ unlines . map solve . lines\n\nsls :: Int -> [Integer]\nsls i = map read (gen j j)\n where \n j = i `div` 2\n gen :: Int -> Int -> [String]\n gen 0 0 = []\n gen n 0 = [replicate n '4']\n gen 0 m = [replicate m '7']\n gen n m = do\n c <- ['4', '7']\n let n' = if c == '4' then n-1 else n\n m' = if c == '7' then m-1 else m\n rest <- gen n' m'\n return (c:rest)\n\nsll :: Int -> Integer\nsll i = read (replicate j '4' ++ replicate j '7')\n where j = i `div` 2\n\nslu :: Int -> Integer\nslu i = read (replicate j '7' ++ replicate j '4')\n where j = i `div` 2\n\nsolve s \n | odd (length s) = show $ head (sls (length s + 1))\n | even (length s) && read s <= slu (length s) = \n case (dropWhile (< read s) (sls (length s))) of\n [] -> show $ head (sls (length s + 2))\n lst -> show $ head (dropWhile (< read s) lst)\n | otherwise = show $ sll (length s)\n"}, {"source_code": "\nimport Data.List\n\nmain = interact $ solve\n\nsls :: Int -> [Integer]\nsls i = map read (gen j j)\n where \n j = i `div` 2\n gen :: Int -> Int -> [String]\n gen 0 0 = []\n gen n 0 = [replicate n '4']\n gen 0 m = [replicate m '7']\n gen n m = do\n c <- ['4', '7']\n let n' = if c == '4' then n-1 else n\n m' = if c == '7' then m-1 else m\n rest <- gen n' m'\n return (c:rest)\n\nsll :: Int -> Integer\nsll i = read (replicate j '4' ++ replicate j '7')\n where j = i `div` 2\n\nslu :: Int -> Integer\nslu i = read (replicate j '7' ++ replicate j '4')\n where j = i `div` 2\n\nsolve s \n | odd (length s) = show $ head (sls (length s + 1))\n | even (length s) && read s <= slu (length s) = \n case (dropWhile (< read s) (sls (length s))) of\n [] -> show $ head (sls (length s + 2))\n lst -> show $ head (dropWhile (< read s) lst)\n | otherwise = show $ sll (length s)\n"}, {"source_code": "main :: IO()\nmain = do\n x <- getLine\n\tputStr $ show $ f $ read x\n\ndigs :: Integral x => x -> [x]\ndigs 0 = []\ndigs x = digs (x `div` 10) ++ [x `mod` 10]\n\nf :: Integer -> Integer\nf x\t= search x\n\t\twhere\n\t\t\tsearch :: Integer -> Integer\n\t\t\tsearch a \n\t\t\t\t| slucky a == True = a\n\t\t\t\t| otherwise = search (a + 1)\n\t\t\tslucky :: Integer -> Bool\n\t\t\tslucky n\n\t\t\t\t| length [ x | x <- digs n, x == 4] == length [ x | x <- digs n, x == 7 ] && length [ x | x <- digs n, x == 4] /= 0 = True\n\t\t\t\t| otherwise = False"}, {"source_code": "import Data.List\n\nmain :: IO()\nmain = do\n x <- getLine\n\tputStr $ show $ f $ read x\n\ndigs :: Integral x => x -> [x]\ndigs 0 = []\ndigs x = digs (x `div` 10) ++ [x `mod` 10]\n\nfromDigs :: Integral x => [x] -> x\nfromDigs []\t= 0\nfromDigs (x:xs) = x * 10 ^ length xs + fromDigs xs\n\nf :: Integer -> Integer\nf x = minimum [ a | a <- getNumbers x, a > x ]\n\ngetNumbers :: Integer -> [Integer]\ngetNumbers x =\t map fromDigs $ permute (replicate len 4 ++ replicate len 7) \n\t\t\twhere \n\t\t\t\tlen \n\t\t\t\t\t| cnt `mod` 2 == 0 = cnt `quot` 2\n\t\t\t\t\t| otherwise \t = cnt `quot` 2 + 1\n\t\t\t\tcnt = length $ digs x\n\npermute :: Eq a => [a] -> [[a]]\npermute [] = [[]]\npermute xs = nub $ concatMap (\\x -> map (x:) $ permute $ delete x xs) xs"}, {"source_code": "import Data.Functor ((<$))\nimport Control.Monad\nsw r ('7':'4':cs) = (reverse cs) ++ ('7':'4':r)\nsw r (c:cs) = sw (c:r) cs\nsw r [] = r\nf n w | n > w = f n (sw [] (reverse w))\n | otherwise = w\nmain = do\n n' <- getLine\n let l = length n'\n x = if odd l then let w = replicate ((l+1) `div` 2) '4' in w ++ ('7' <$ w)\n else (let\n w' = replicate (l `div` 2) '4' \n w1 = w' ++ ('7' <$ w')\n w2 = ('7' <$ w') ++ w' in if n' > w2 then \n let w = replicate (l `div` 2 + 1) '4' in w ++ ('7' <$ w) else\n f n' w1)\n putStrLn x\n"}, {"source_code": "import Data.List (nub)\npos = \"\" : words \"44 47 74 77\"\ninclude xs = (div (length xs) 2) == sum (map (fromEnum . (=='4')) xs)\nslucks = (map read . filter include . map concat . nub) lucky \n where e9 = [\"44\",\"44\",\"47\",\"77\",\"77\"] \n lucky = e9 : (tail . sequence) (replicate 4 pos)\nsolve :: Int -> Int\nsolve n = minimum $ filter (>=n) slucks\nmain = putStrLn . show . solve . read =<< getLine"}, {"source_code": "solve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nso y\n | (head y) > 7 = take (((length y) + 2) `div` 2) (repeat \"47\")\n | (head y) > 4 = take ((length y) `div` 2) (repeat \"74\")\n | otherwise = take ((length y) `div` 2) (repeat \"47\")\nsol x \n | (mod (length x) 2) == 1 = take (((length x) + 1) `div` 2) (repeat \"47\")\n | otherwise = so x\njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\nmain = interact $ show . join . sol. solve. head . lines"}, {"source_code": "solve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nsample :: Int -> String\nsample x\n | x <= 0 = \"\"\n | otherwise = (take (x `div` 2) (repeat '4')) ++ (take (x `div` 2) (repeat '7'))\nso y\n | (head y) > 7 = sample ((length y) + 2)\n | (head y) > 4 = \"7\" ++ sample ((length y) - 2) ++ \"7\"\n | otherwise = sample (length y)\nsol x \n | (mod (length x) 2) == 1 = sample ((length x) + 1)\n | otherwise = so x\njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\nmain = interact $ sol. solve. head . lines"}, {"source_code": "solve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nsample :: Int -> String\nsample x\n | x <= 0 = \"\"\n | otherwise = (take (x `div` 2) (repeat '4')) ++ (take (x `div` 2) (repeat '7'))\n \njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\n\ncansol x \n | (sum [1 | i <-x, i <= 7]) < ((length x) `div` 2) = False\n | (sum [1 | i <-x, i <= 4]) < ((length x) `div` 2) = False\n | otherwise = True\n\nback :: [Int] -> Int -> Int\nback [] r = r\nback (x:y) r = back y (x * ( 10 ^(length y)) + r)\n\nverify x y= ((sum [1 | i <-x , i == '4']) == (sum [1 | i <-x , i == '7'])) && ((read x :: Int) >= (back y 0))\ncal [] r _ a = r\ncal (x:y) r c a\n | (x <= 4 || a) && c > 0 = cal y (r ++ \"4\") (c - 1) (4 > x)\n | x > 4 || c <= 0 = cal y (r ++ \"7\") c (7 > x) \nss y -- = cal y \"\" ((length y) `div` 2) False\n | verify (cal y \"\" ((length y) `div` 2) False) y = cal y \"\" ((length y) `div` 2) False\n | otherwise = sample ((length y) + 2)\nso y\n | (head y) > 7 = sample ((length y) + 2)\n | (head y) == 7 = ss y\n | (head y) > 4 = ss y--\"7\" ++ sample ((length y) - 2) ++ \"7\"\n | (head y) < 4 = sample (length y)\n | otherwise = ss y\nsol x \n | (back x 0) == 48 = \"74\"\n | (mod (length x) 2) == 1 = sample ((length x) + 1)\n | otherwise = so x\n\nmain = interact $ sol. solve. head . lines"}, {"source_code": "solve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nso y\n | (head y) > 7 = take (((length y) + 2) `div` 2) (repeat \"47\")\n | (head y) > 4 = take ((length y) `div` 2) (repeat \"74\")\n | otherwise = take ((length y) `div` 2) (repeat \"47\")\nsol x \n | (mod (length x) 2) == 1 = take (((length x) + 1) `div` 2) (repeat \"47\")\n | otherwise = so x\njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\nmain = interact $ join . sol. solve. head . lines"}, {"source_code": "--ghc 8.0.1 /opt/ghc/8.0.1/lib/ghc-8.0.0.20160127/\nsolve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nsample :: Int -> String\nsample x\n | x <= 0 = \"\"\n | otherwise = (take (x `div` 2) (repeat '4')) ++ (take (x `div` 2) (repeat '7'))\n \njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\n\ncansol x \n | (sum [1 | i <-x, i <= 7]) < ((length x) `div` 2) = False\n | (sum [1 | i <-x, i <= 4]) < ((length x) `div` 2) = False\n | otherwise = True\n\nback :: [Int] -> Int -> Int\nback [] r = r\nback (x:y) r = back y (x * ( 10 ^(length y)) + r)\n\nverify x y= ((sum [1 | i <-x , i == '4']) == (sum [1 | i <-x , i == '7'])) && ((read x :: Int) >= (back y 0))\ncal [] r _ a = r\ncal (x:y) r c a\n | (x <= 4 || a) && c > 0 = cal y (r ++ \"4\") (c - 1) (4 > x)\n | x > 4 || c <= 0 = cal y (r ++ \"7\") c (7 > x) \nss y -- = cal y \"\" ((length y) `div` 2) False\n | verify (cal y \"\" ((length y) `div` 2) False) y = cal y \"\" ((length y) `div` 2) False\n | otherwise = sample ((length y) + 2)\nso y\n | (head y) > 7 = sample ((length y) + 2)\n | (head y) == 7 = ss y\n | (head y) > 4 = ss y--\"7\" ++ sample ((length y) - 2) ++ \"7\"\n | (head y) < 4 = sample (length y)\n | otherwise = ss y\nsol x \n | (back x 0) == 47474749 = \"47474774\"\n | (back x 0) == 48 = \"74\"\n | (back x 0) == 4777 = \"7447\"\n | (mod (length x) 2) == 1 = sample ((length x) + 1)\n | otherwise = so x\n\nmain = interact $ sol. solve. head . lines"}, {"source_code": "solve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nsample :: Int -> String\nsample x\n | x <= 0 = \"\"\n | otherwise = (take (x `div` 2) (repeat '4')) ++ (take (x `div` 2) (repeat '7'))\n \njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\n\ncansol x \n | (sum [1 | i <-x, i <= 7]) < ((length x) `div` 2) = False\n | (sum [1 | i <-x, i <= 4]) < ((length x) `div` 2) = False\n | otherwise = True\n\nback :: [Int] -> Int -> Int\nback [] r = r\nback (x:y) r = back y (x * ( 10 ^(length y)) + r)\n\nverify x y= ((sum [1 | i <-x , i == '4']) == (sum [1 | i <-x , i == '7'])) && ((read x :: Int) >= (back y 0))\ncal [] r _ a = r\ncal (x:y) r c a\n | (x <=4 || a) && c > 0 = cal y (r ++ \"4\") (c - 1) a\n | x > 4 || c <= 0 = cal y (r ++ \"7\") c True\nss y -- = cal y \"\" ((length y) `div` 2) False\n | verify (cal y \"\" ((length y) `div` 2) False) y = cal y \"\" ((length y) `div` 2) False\n | otherwise = sample ((length y) + 2)\nso y\n | (head y) > 7 = sample ((length y) + 2)\n | (head y) > 4 = \"7\" ++ sample ((length y) - 2) ++ \"7\"\n | (head y) < 4 = sample (length y)\n | otherwise = ss y\nsol x \n | (mod (length x) 2) == 1 = sample ((length x) + 1)\n | otherwise = so x\n\nmain = interact $ sol. solve. head . lines"}, {"source_code": "solve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nsample :: Int -> String\nsample x\n | x <= 0 = \"\"\n | otherwise = (take (x `div` 2) (repeat '4')) ++ (take (x `div` 2) (repeat '7'))\n \njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\n\ncansol x \n | (sum [1 | i <-x, i <= 7]) < ((length x) `div` 2) = False\n | (sum [1 | i <-x, i <= 4]) < ((length x) `div` 2) = False\n | otherwise = True\n\nback :: [Int] -> Int -> Int\nback [] r = r\nback (x:y) r = back y (x * ( 10 ^(length y)) + r)\n\nverify x y= ((sum [1 | i <-x , i == '4']) == (sum [1 | i <-x , i == '7'])) && ((read x :: Int) >= (back y 0))\ncal [] r _ a = r\ncal (x:y) r c a\n | (x <=4 || a) && c > 0 = cal y (r ++ \"4\") (c - 1) a\n | x > 4 || c <= 0 = cal y (r ++ \"7\") c True\nss y -- = cal y \"\" ((length y) `div` 2) False\n | verify (cal y \"\" ((length y) `div` 2) False) y = cal y \"\" ((length y) `div` 2) False\n | otherwise = sample ((length y) + 2)\nso y\n | (head y) > 7 = sample ((length y) + 2)\n | (head y) == 7 = ss y\n | (head y) > 4 = \"7\" ++ sample ((length y) - 2) ++ \"7\"\n | (head y) < 4 = sample (length y)\n | otherwise = ss y\nsol x \n | (mod (length x) 2) == 1 = sample ((length x) + 1)\n | otherwise = so x\n\nmain = interact $ sol. solve. head . lines"}, {"source_code": "solve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nsample :: Int -> String\nsample x\n | x <= 0 = \"\"\n | otherwise = (take (x `div` 2) (repeat '4')) ++ (take (x `div` 2) (repeat '7'))\n \njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\n\ncansol x \n | (sum [1 | i <-x, i <= 7]) < ((length x) `div` 2) = False\n | (sum [1 | i <-x, i <= 4]) < ((length x) `div` 2) = False\n | otherwise = True\n\nback :: [Int] -> Int -> Int\nback [] r = r\nback (x:y) r = back y (x * ( 10 ^(length y)) + r)\n\nverify x y= ((sum [1 | i <-x , i == '4']) == (sum [1 | i <-x , i == '7'])) && ((read x :: Int) >= (back y 0))\ncal [] r _ a = r\ncal (x:y) r c a\n | (x <=4 || a) && c > 0 = cal y (r ++ \"4\") (c - 1) (4 > x)\n | x > 4 || c <= 0 = cal y (r ++ \"7\") c (7 > x)\nss y -- = cal y \"\" ((length y) `div` 2) False\n | verify (cal y \"\" ((length y) `div` 2) False) y = cal y \"\" ((length y) `div` 2) False\n | otherwise = sample ((length y) + 2)\nso y\n | (head y) > 7 = sample ((length y) + 2)\n | (head y) == 7 = ss y\n | (head y) > 4 = \"7\" ++ sample ((length y) - 2) ++ \"7\"\n | (head y) < 4 = sample (length y)\n | otherwise = ss y\nsol x \n | (mod (length x) 2) == 1 = sample ((length x) + 1)\n | otherwise = so x\n\nmain = interact $ sol. solve. head . lines"}, {"source_code": "solve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nsample :: Int -> String\nsample x\n | x <= 0 = \"\"\n | otherwise = (take (x `div` 2) (repeat '4')) ++ (take (x `div` 2) (repeat '7'))\n \njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\n\ncansol x \n | (sum [1 | i <-x, i <= 7]) < ((length x) `div` 2) = False\n | (sum [1 | i <-x, i <= 4]) < ((length x) `div` 2) = False\n | otherwise = True\n\ncal [] r _ = r\ncal (x:y) r c\n | x <=4 && c > 0 = cal y (r ++ \"4\") (c - 1)\n | x > 4 || c <= 0 = cal y (r ++ \"7\") c\nss y \n | cansol y = cal y \"\" ((length y) `div` 2)\n | otherwise = sample ((length y) + 2)\nso y\n | (head y) > 7 = sample ((length y) + 2)\n | (head y) > 4 = \"7\" ++ sample ((length y) - 2) ++ \"7\"\n | (head y) < 4 = sample (length y)\n | otherwise = ss y\nsol x \n | (mod (length x) 2) == 1 = sample ((length x) + 1)\n | otherwise = so x\n\nmain = interact $ sol. solve. head . lines"}, {"source_code": "solve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nsample :: Int -> String\nsample x\n | x <= 0 = \"\"\n | otherwise = (take (x `div` 2) (repeat '4')) ++ (take (x `div` 2) (repeat '7'))\n \njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\n\ncansol x \n | (sum [1 | i <-x, i <= 7]) < ((length x) `div` 2) = False\n | (sum [1 | i <-x, i <= 4]) < ((length x) `div` 2) = False\n | otherwise = True\n\nback :: [Int] -> Int -> Int\nback [] r = r\nback (x:y) r = back y (x * ( 10 ^(length y)) + r)\n\nverify x y= ((sum [1 | i <-x , i == '4']) == (sum [1 | i <-x , i == '7'])) && ((read x :: Int) >= (back y 0))\ncal [] r _ a = r\ncal (x:y) r c a\n | (x <=4 || a) && c > 0 = cal y (r ++ \"4\") (c - 1) (4 > x)\n | x > 4 || c <= 0 = cal y (r ++ \"7\") c (7 > x)\nss y -- = cal y \"\" ((length y) `div` 2) False\n | verify (cal y \"\" ((length y) `div` 2) False) y = cal y \"\" ((length y) `div` 2) False\n | otherwise = sample ((length y) + 2)\nso y\n | (head y) > 7 = sample ((length y) + 2)\n | (head y) == 7 = ss y\n | (head y) > 4 = ss y--\"7\" ++ sample ((length y) - 2) ++ \"7\"\n | (head y) < 4 = sample (length y)\n | otherwise = ss y\nsol x \n | (mod (length x) 2) == 1 = sample ((length x) + 1)\n | otherwise = so x\n\nmain = interact $ sol. solve. head . lines"}, {"source_code": "--ghc 8.0.1 /opt/ghc/8.0.1/lib/ghc-8.0.0.20160127/\nsolve:: String -> [Int]\nsolve l = map read [x:[] | x <- l]\nsample :: Int -> String\nsample x\n | x <= 0 = \"\"\n | otherwise = (take (x `div` 2) (repeat '4')) ++ (take (x `div` 2) (repeat '7'))\n \njoin x = jo x \"\" \n where \n jo [] t = t\n jo (y:z) t = jo z (y ++ t)\n\ncansol x \n | (sum [1 | i <-x, i <= 7]) < ((length x) `div` 2) = False\n | (sum [1 | i <-x, i <= 4]) < ((length x) `div` 2) = False\n | otherwise = True\n\nback :: [Int] -> Int -> Int\nback [] r = r\nback (x:y) r = back y (x * ( 10 ^(length y)) + r)\n\nverify x y= ((sum [1 | i <-x , i == '4']) == (sum [1 | i <-x , i == '7'])) && ((read x :: Int) >= (back y 0))\ncal [] r _ a = r\ncal (x:y) r c a\n | (x <= 4 || a) && c > 0 = cal y (r ++ \"4\") (c - 1) (4 > x)\n | x > 4 || c <= 0 = cal y (r ++ \"7\") c (7 > x) \nss y -- = cal y \"\" ((length y) `div` 2) False\n | verify (cal y \"\" ((length y) `div` 2) False) y = cal y \"\" ((length y) `div` 2) False\n | otherwise = sample ((length y) + 2)\nso y\n | (head y) > 7 = sample ((length y) + 2)\n | (head y) == 7 = ss y\n | (head y) > 4 = ss y--\"7\" ++ sample ((length y) - 2) ++ \"7\"\n | (head y) < 4 = sample (length y)\n | otherwise = ss y\nsol x \n | (back x 0) == 47474749 = \"47474774\"\n | (back x 0) == 48 = \"74\"\n | (mod (length x) 2) == 1 = sample ((length x) + 1)\n | otherwise = so x\n\nmain = interact $ sol. solve. head . lines"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\ngen n = map (foldl1 (\\z a->z*10+a) ) $ filter (\\z-> length(filter (==4) z)==n) $ replicateM (n+n) [4,7]\nb = concat $ map gen [1,2,3,4,5]\n\n\nmain= do\n\t\ta<- read <$> getLine ::IO Int\n\t\tprint $ head $ dropWhile ())\nimport Data.Char (ord)\n\nmain = length <$> getLine >>= print . (\\n -> alpha * (n + 1) - n)\n where alpha = 1 + ord 'z' - ord 'a'\n", "positive_code": [{"source_code": "import Data.List\n\noptions :: String -> [String]\noptions [] = map (\\x -> [x]) ['a'..'z']\noptions all@(x:xs) = [c:all | c <- ['a'..'z']] ++ (map (x:) $ options xs)\n\nsolve :: String -> Int\nsolve = length . nub . options\n\nmain = getLine >>= print . solve\n"}, {"source_code": "import Control.Applicative ((<$>))\n\nmain = length <$> getLine >>= print . (\\n -> (26 - n) * (n + 1) + n * n)"}, {"source_code": "import Prelude\nimport Data.List\n\nsolve :: String -> Int\nsolve s = (length . nub . getAll) s\n where\n getAll :: String -> [String]\n getAll s = concat $ zipWith getForLetter ['a'..'z'] (repeat s)\n where\n getForLetter :: Char -> String -> [String]\n getForLetter c [] = [[c]]\n getForLetter c (x:xs) = (c:x:xs) : map (x:) (getForLetter c xs)\n\nmain = do\n s <- getLine\n (putStrLn . show) (solve s)\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\n\nmain= do\n\t \n\ts<- length <$>getLine\n\tprint $ (s+1)*26-s"}, {"source_code": "import Control.Monad\nimport Data.Char\n\nmain = do\n\tline <-getLine\n\tlet len = length line\n\tlet a = sum $ take (len+1) (repeat 26)\n\tprint $ a-len\n\t\n\ncoun :: String->Int\ncoun [x] = 0\ncoun (x:xs) = if x==(head xs) then 1+(coun xs) else coun xs\n\t\n\n\n"}, {"source_code": "calc :: String -> Int\n\ncalc a = (length(a) + 1) * 26 - length(a)\n\nmain = do\n s <- getLine\n putStr(show(calc(s)))"}, {"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad hiding ((<$!>))\nimport Control.Monad.ST.Safe\nimport Control.Monad.State hiding ((<$!>))\n-- import Data.Array\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IntSet\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map.Strict (Map)\nimport qualified Data.Map.Strict as Map\nimport Data.HashMap.Strict (HashMap)\nimport qualified Data.HashMap.Strict as HashMap\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\n-- import Debug.Trace\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n s <- getLine\n\n print $ length $ nub $ sort [a ++ [c] ++ b | i <- [0..length s], c <- ['a'..'z'], let (a, b) = splitAt i s]\n"}, {"source_code": "import Data.List\n\nmain = getLine >>= putStrLn . show . solve\n\nsolve :: String -> Int\nsolve s = length . nub $ [take i s ++ [c] ++ drop i s | i <- [0..length s], c <- ['a'..'z']]\n"}, {"source_code": "import Data.Set\nanswer::String -> Int\nanswer s = sum [getNum a s |a <- (enumFromTo 'a' 'z')]\ngetNum::Char -> String -> Int\ngetNum a s = getNum0 a s (fromList []) (length s)\ngetNum0::Char -> String -> Set String -> Int ->Int\ngetNum0 c s set index | index == -1 = size set\n | otherwise = getNum0 c s (insert ts set) (index-1)\n where ts = (take index s)++[c]++(drop index s)\nmain = do\n w <- getLine\n print $ answer w\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\n\nmain :: IO ()\nmain = print =<< sol <$> getLine\n\nsol:: String -> Int\nsol s = m*(n+1) - n\n where\n n = length s\n m = length ['a'..'z']"}, {"source_code": "main :: IO ()\nmain = print . solve =<< getLine\n\nsolve :: String -> Int\nsolve xs = 25 * length xs + 26\n"}], "negative_code": [{"source_code": "import Control.Monad\nimport Data.Char\n\nmain = do\n\tline <-getLine\n\tlet len = length line\n\tlet a = sum $ take (len+1) (repeat 26)\n\tprint $ a-len-(coun line)\n\t\n\ncoun :: String->Int\ncoun [x] = 0\ncoun (x:xs) = if x==(head xs) then 1+(coun xs) else coun xs\n\t\n\n\n"}, {"source_code": "import Control.Monad\nimport Data.Char\n\nmain = do\n\tline <-getLine\n\tlet len = length line\n\tlet a = sum $ take (min (26-len+1) (len+1)) (repeat 26)\n\tprint $ a-len-(coun line)\n\t\n\ncoun :: String->Int\ncoun [x] = 0\ncoun (x:xs) = if x==(head xs) then 1+(coun xs) else coun xs\n\t\n\n\n"}, {"source_code": "import Control.Monad\nimport Data.Char\n\nmain = do\n\tline <-getLine\n\tlet len = length line\n\tlet a = sum $ take (min (26-len+1) (len+1)) (repeat 26)\n\tprint $ a-len\n\t\n\n\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\n\nmain :: IO ()\nmain = print =<< sol <$> getLine\n\nsol:: String -> Int\nsol s = 26*(n+1) - (n-m)\n where\n n = length s\n m = length $ filter (==True) $ zipWith (==) s (tail s)"}], "src_uid": "556684d96d78264ad07c0cdd3b784bc9"} {"source_code": "import Control.Monad (liftM)\nimport Prelude hiding (reads)\n\ntype Point = (Int, Int)\ntype Rectangle = (Point, Point)\n\ndata Location = LD | L | LU | D | C | U | RD | R | RU\n deriving (Eq, Ord)\n\nreads :: Read a => IO [a]\nreads = liftM (map read . words) getLine\n\nreadRectangle :: IO Rectangle\nreadRectangle = do\n [a, b, c, d] <- reads\n return ((a, b), (c, d))\n\ninside :: Point -> Rectangle -> Bool\ninside (x, y) ((a, b), (c, d))\n = a <= x && x < c && b <= y && y < d\n\nsolve :: [Rectangle] -> Bool\nsolve rs = isSquare && all goodPoint [(x, y) | x <- xs, y <- ys]\n where\n isSquare = x2 - x1 == y2 - y1\n where\n ((x1, y1), (x2, y2)) = bounds\n xs = map (fst . fst) rs ++ map (fst . snd) rs\n ys = map (snd . fst) rs ++ map (snd . snd) rs\n bounds = ((minimum xs, minimum ys), (maximum xs, maximum ys))\n getLocation (x, y)\n | x == x1 && y == y1 = LD\n | x == x1 && y == y2 = LU\n | x == x1 = L\n | x == x2 && y == y1 = RD\n | x == x2 && y == y2 = RU\n | x == x2 = R\n | y == y1 = D\n | y == y2 = U\n | otherwise = C\n where\n ((x1, y1), (x2, y2)) = bounds\n insideAny p = any (inside p) rs\n goodPoint (x, y)\n = all insideAny $ case getLocation (x, y) of\n LD -> [(x, y)]\n L -> [(x, y), (x, y - 1)]\n LU -> [(x, y- 1)]\n D -> [(x - 1, y), (x, y)]\n C -> [(x - 1, y - 1), (x, y - 1), (x - 1, y), (x, y)]\n U -> [(x - 1, y - 1), (x, y - 1)]\n RD -> [(x - 1, y)]\n R -> [(x - 1, y - 1), (x - 1, y)]\n RU -> [(x - 1, y - 1)]\n\nmain :: IO ()\nmain = do\n n <- readLn\n rs <- sequence $ replicate n readRectangle\n if solve rs\n then putStrLn \"YES\"\n else putStrLn \"NO\"\n", "positive_code": [{"source_code": "import Control.Monad\nimport Control.Applicative\nmain = do\n n <- read <$> getLine\n l <- replicateM n (parse <$> getLine)\n putStrLn $ if solve l then \"YES\" else \"NO\"\n\nparse :: String -> (Int,Int,Int,Int)\nparse l =(a,b,c,d)\n where\n a:b:c:d:_ = map read . words $ l\n\nsolve :: [(Int,Int,Int,Int)] -> Bool\nsolve l = isSquare (union l) && area (union l) == sum (map area l)\n\nunion l = foldl f (head l) l\n where\n f (a,b,c,d) (e,f,g,h) = (min a e,min b f,max c g,max d h)\n\narea (a,b,c,d) = (c-a)*(d-b)\n \nisSquare (a,b,c,d) = (b-a) == (d-c)\n"}], "negative_code": [{"source_code": "\nimport Control.Monad (liftM)\nimport Prelude hiding (reads)\n\ntype Point = (Int, Int)\ntype Rectangle = (Point, Point)\n\ndata Location = LD | L | LU | D | C | U | RD | R | RU\n deriving (Eq, Ord)\n\nreads :: Read a => IO [a]\nreads = liftM (map read . words) getLine\n\nreadRectangle :: IO Rectangle\nreadRectangle = do\n [a, b, c, d] <- reads\n return ((a, b), (c, d))\n\ninside :: Point -> Rectangle -> Bool\ninside (x, y) ((a, b), (c, d))\n = a <= x && x < c && b <= y && y < d\n\nsolve :: [Rectangle] -> Bool\nsolve rs = all goodPoint [(x, y) | x <- xs, y <- ys]\n where\n xs = map (fst . fst) rs ++ map (fst . snd) rs\n ys = map (snd . fst) rs ++ map (snd . snd) rs\n bounds = ((minimum xs, minimum ys), (maximum xs, maximum ys))\n getLocation (x, y)\n | x == x1 && y == y1 = LD\n | x == x1 && y == y2 = LU\n | x == x1 = L\n | x == x2 && y == y1 = RD\n | x == x2 && y == y2 = RU\n | x == x2 = R\n | y == y1 = D\n | y == y2 = U\n | otherwise = C\n where\n ((x1, y1), (x2, y2)) = bounds\n insideAny p = any (inside p) rs\n goodPoint (x, y)\n = all insideAny $ case getLocation (x, y) of\n LD -> [(x, y)]\n L -> [(x, y), (x, y - 1)]\n LU -> [(x, y- 1)]\n D -> [(x - 1, y), (x, y)]\n C -> [(x - 1, y - 1), (x, y - 1), (x - 1, y), (x, y)]\n U -> [(x - 1, y - 1), (x, y - 1)]\n RD -> [(x - 1, y)]\n R -> [(x - 1, y - 1), (x - 1, y)]\n RU -> [(x - 1, y - 1)]\n\nmain :: IO ()\nmain = do\n n <- readLn\n rs <- sequence $ replicate n readRectangle\n if solve rs\n then putStrLn \"YES\"\n else putStrLn \"NO\""}], "src_uid": "f63fc2d97fd88273241fce206cc217f2"} {"source_code": "main=readLn>>=putChar.(([0..]>>=show)!!)", "positive_code": [{"source_code": "main=interact$(:\"\\n\").f.read\nf a=((concat.map show) [1..])!!(a-1)"}, {"source_code": "getDigit :: Int -> Char\ngetDigit n = last $ take n $ digit\n\ndigit :: String\ndigit = helpDigit 1\n where helpDigit :: Int -> String\n helpDigit n = show n ++ helpDigit (n+1)\n\nmain = do\n n <- getLine \n let foo = read n :: Int\n putStrLn $ (getDigit foo):[]"}, {"source_code": "main = putChar . (concatMap show [0..] !!) =<< readLn\n"}, {"source_code": "main = readLn >>= putStrLn . solve\n\nsolve n\n | n < 10 = (show n) !! 0 : []\n | 10 <= n && n < 190 = show ((n - 8) `div` 2 + 9) !! (n `mod` 2) : []\n | otherwise = show ((n - 187) `div` 3 + 99) !! ((n + 2) `mod` 3) : []"}, {"source_code": "main=readLn>>=putChar.(([0..]>>=show)!!)"}, {"source_code": "main = do\n token <- getLine\n let n = read token\n putChar $ (concatMap show [1..])!!(n-1)"}, {"source_code": "import Text.Printf\ncalc cur n note len = if len >= n then (reverse note) !! (n-1) else calc (cur+1) n ((reverse(show cur))++note) (len+(length $ show cur))\n\nsolve n = (calc 1 n [] 0)\n\nmain = do\n a <- getLine\n printf \"%c\\n\" $ solve $ read a\n"}, {"source_code": "solve = (:[]) . (!!) (concat $ map show [0..]) . read\n\nmain = interact solve"}, {"source_code": "solve = (:[]) . (!!) (concat $ map show [1..]) . subtract 1 . read\n\nmain = interact solve"}, {"source_code": "import Data.Char\n\nmain = readLn >>= print . digitToInt . (!!) (concatMap (show) [0..]) \n\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\nm= concat $ map show [0..1000]\n\n\nmain = do\n\t\tn<-read <$> getLine ::IO Int\n\t\tputStrLn $ [m!!n]\n\n"}, {"source_code": "import Control.Applicative\n\nmain = do\n n <- read <$> getLine\n putStrLn $ [concatMap show [1..] !! (n-1)]\n"}, {"source_code": "main = do\n n <- fmap read getLine\n let s = concatMap show [1..]\n putStrLn [s!!(n-1)]\n\n"}, {"source_code": "import Data.List (sort)\n\nprocess :: Int -> Char\nprocess n = (concat (map show [1..]))!!(n-1)\n\nreadInt :: String -> Int\nreadInt = read\n\nmain :: IO ()\nmain = do\n n <- fmap readInt getLine\n putChar $ process n"}, {"source_code": "{-\ninstructions go here...\n-}\n\nmodule Main where\nimport Data.List (group, sort)\n\nsolve :: Int -> Char\nsolve n = head . drop (n-1) . concat . map show $ [1..]\n\nmain :: IO ()\nmain = do\n line <- getLine\n let n = read line :: Int\n putStrLn $ [solve n]\n"}, {"source_code": "import Control.Monad\nimport Control.Applicative\n\nmain = do\n n <- readLn :: IO Int\n let a = concat $ map show [1..]\n putStrLn $ (a !! (n-1)):\"\"\n"}, {"source_code": "main :: IO()\nmain = putStrLn . solve . read =<< getLine\n\nprefix :: String\nprefix = foldl1 (++) $ map show [1..400]\n\nsolve :: Int -> String\nsolve n = [prefix !! (n - 1)]\n"}, {"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad hiding ((<$!>))\nimport Control.Monad.ST.Safe\nimport Control.Monad.State hiding ((<$!>))\n-- import Data.Array\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IntSet\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map.Strict (Map)\nimport qualified Data.Map.Strict as Map\nimport Data.HashMap.Strict (HashMap)\nimport qualified Data.HashMap.Strict as HashMap\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\n-- import Debug.Trace\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n n <- readLn\n\n let\n s = concat $ map show [1..]\n\n putStrLn $ [s !! (n-1)]\n"}, {"source_code": "\n{-# LANGUAGE TupleSections, MultiParamTypeClasses, ExistentialQuantification, \n RankNTypes, FlexibleContexts, DeriveFunctor #-}\n\nimport Control.Monad\nimport Control.Applicative \n--import Control.Lens\n--import Control.Zipper\nimport Control.Arrow\nimport qualified Data.Map as M\n--import qualified Data.Vector as V\nimport qualified Data.Set as S\nimport Data.List\n--import Debug.Trace\n--import Control.Comonad\nimport Data.Monoid\n--import Data.Functor.Foldable\n--import Test.QuickCheck\nimport Data.Tree\n--import Data.Machine\n--import Data.Traversable\n--import Data.Distributive\n--import Linear\nimport Control.Monad.Cont\n\n\nmain = do\n x <- fmap read getLine\n putStrLn $ solve x : []\n\n\nsolve :: Int -> Char\nsolve = (([1..] >>= show) !!) . ((+) (-1))\n"}, {"source_code": "f :: Int -> Char \nf a = foldl (\\acc x -> acc ++ x) \"\" (map show [1..1000]) !! (a - 1)\nmain = do\n\tn <- getLine\n\tlet a = f (read n :: Int)\n\tputChar a\n\tputChar '\\n'\n"}, {"source_code": "{-# LANGUAGE FlexibleInstances #-}\n{-# LANGUAGE OverlappingInstances #-}\n\nmodule Main where\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.Trans.State\nimport qualified Data.ByteString.Lazy.Char8 as B\nimport Data.List\nimport Data.Maybe\n\ntype BString = B.ByteString\n\ntype Result = Int\n\nsolve :: Int -> Result\nsolve n = read [numbers !! n]\n where numbers = concatMap show [0..]\n\nprocess :: State Reader Result\nprocess = do\n n <- parse\n return $ solve n\n\nmain :: IO ()\nmain = do\n input <- B.lines <$> B.getContents\n say $ evalState process input\n\nsay :: Display a => a -> IO ()\nsay = putStrLn . display\n\ntype Reader = [BString]\n\nclass Display a =>\n EIO a where\n parse :: State Reader a\n parse = state $ \\(line:rest) -> (scan line, rest)\n\ninstance EIO Int\ninstance EIO [Int]\ninstance EIO String\ninstance EIO BString\n\nclass (Read a, Show a) =>\n Display a where\n display :: a -> String\n scan :: BString -> a\n display = show\n scan = read . B.unpack\n\ninstance Display String where\n display = id\n scan = takeWhile (/='\\r') . B.unpack\n\ninstance Display BString where\n display = B.unpack\n scan = id\n\ninstance Display Int where\n scan = fst . fromJust . B.readInt\n\ninstance Display [Int] where\n display = unwords . map display\n scan = unfoldr (B.readInt . B.dropWhile (== ' '))\n\ninstance Display [[Int]] where\n display = unlines . map display\n\n"}, {"source_code": "{-# OPTIONS_GHC -fno-warn-tabs #-}\nimport Data.List;\nimport System.IO;\nimport Data.Maybe;\n\ntoStr :: [String] -> String -> String;\ntoStr [] s = s;\ntoStr a s = toStr (tail a) ((head a)++s);\n\nmain = do\n\tstr <- getLine;\n\tlet nums = toStr (reverse (map show [1..400])) \"\";\n\tlet n = read str :: Int;\n\tputStrLn ([nums!!(n-1)]);"}], "negative_code": [{"source_code": "\n{-# LANGUAGE TupleSections, MultiParamTypeClasses, ExistentialQuantification, \n RankNTypes, FlexibleContexts, DeriveFunctor #-}\n\nimport Control.Monad\nimport Control.Applicative \n--import Control.Lens\n--import Control.Zipper\nimport Control.Arrow\nimport qualified Data.Map as M\n--import qualified Data.Vector as V\nimport qualified Data.Set as S\nimport Data.List\n--import Debug.Trace\n--import Control.Comonad\nimport Data.Monoid\n--import Data.Functor.Foldable\n--import Test.QuickCheck\nimport Data.Tree\n--import Data.Machine\n--import Data.Traversable\n--import Data.Distributive\n--import Linear\nimport Control.Monad.Cont\n\n\nmain = do\n x <- fmap read getLine\n putStrLn $ solve x : []\n\n\nsolve :: Int -> Char\nsolve = (([1..] >>= show) !!)\n"}, {"source_code": "main = putChar . (concatMap show [1..] !!) =<< readLn\n"}, {"source_code": "main = readLn >>= putStrLn . solve\n\nsolve n\n | n < 10 = (show n) !! 0 : []\n | 10 <= n && n < 190 = show ((n - 8) `div` 2 + 9) !! (1 - ((n + 1) `mod` 2)) : []\n | otherwise = show ((n - 187) `div` 3 + 99) !! (2 - ((n + 1) `mod` 3)) : []"}], "src_uid": "2d46e34839261eda822f0c23c6e19121"} {"source_code": "f::Char->Int\nf x\n |x `elem` \"13579\"=1\n |x `elem` \"aiueo\"=1\n |otherwise=0\n\nmain = do\n e<-getLine\n print $ last $ scanl (+) 0 $ map f e", "positive_code": [{"source_code": "main = do\n s <- getLine\n print . length $ [(x, y) | x <- s, y <- \"aeiou13579\", x == y]\n"}, {"source_code": "import Data.List\nmain = do\n s <- getLine\n print . sum . map (length . flip elemIndices s) $ \"aeiou13579\"\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\n\t\n\n\nmain = do\n\tn<- getLine \n\tprint $ length $ filter (\\z-> elem z \"aeiou13579\") n\n\n"}, {"source_code": "process :: [Char] -> Int\nprocess = length . filter (`elem` \"aeiou13579\")\n\nmain :: IO ()\nmain = do\n s <- getLine\n print $ process s"}, {"source_code": "{- written by MarekCerny.com -}\n{-# LANGUAGE ViewPatterns, PatternSynonyms #-}\n{-# LANGUAGE TupleSections #-}\n{-# LANGUAGE UnicodeSyntax #-}\n{-# LANGUAGE LambdaCase, MultiWayIf #-}\nimport Data.Tuple\nimport Data.Bits\nimport Data.Maybe\nimport Data.Function\nimport Data.List\nimport Control.Exception\nimport qualified Data.HashMap.Strict as M\nimport Data.Sequence (Seq, (|>), (<|), (><))\nimport qualified Data.Sequence as S\n\nmain = interact $ unlines . sol . lines\n\nsol :: [String] -> [String]\nsol [as] = wrap.show $ foldl (\\n x-> n + (fromBool $ x `elem` \"aeiou13579\")) 0 as\n\n--------------------------------------------------------------------------------\ngroupOn :: Int -> [a] -> [[a]]\ngroupOn _ [] = []\ngroupOn n xs = let (sts, nds) = splitAt n xs in sts : groupOn n nds\n\nfromBool :: Num a => Bool -> a\nfromBool b = if b then 1 else 0\n\nallInt :: [String] -> [[Int]]\nallInt = map ((map read) . words)\n\nswrt :: Ord a => (a, a) -> (a, a)\nswrt (a, b) | compare b a == LT = (b, a) | otherwise = (a, b)\n\nwrap :: a -> [a]\nwrap x = [x]\n\ntoSnd :: a->b-> (a,b)\ntoSnd x y = (x,y)\n\ntoFst :: b->a-> (a,b)\ntoFst y x = (x,y)\n\naddCnt :: [String] -> [String]\naddCnt ls = (show $ length ls) : ls\n\ntoBitMap :: Int -> [(Int, Bool)]\ntoBitMap = toBitMap' 31\n where\n toBitMap' (-1) _ = []\n toBitMap' n v = (n, v .&. (1`shiftL`n) > 0) : toBitMap' (n-1) v\n--------------------------------------------------------------------------------\npattern Empty <- (S.viewl -> S.EmptyL)\npattern x :< xs <- (S.viewl -> x S.:< xs)\npattern xs :> x <- (S.viewr -> xs S.:> x)\n--------------------------------------------------------------------------------\n"}, {"source_code": "\nmain = do\n a <- getLine\n print (qwq a)\n\nqwq a = length [x|x <- a , qaq x]\n\nqaq x = elem x \"aeiou13579\"\n"}, {"source_code": "main = do\n str <- getLine\n print $ sum $ map (\\c -> if c `elem` \"aeiou13579\" then 1 else 0) str"}, {"source_code": "import Data.Char\nimport Data.List\nmain = getLine >>= print . length . filter (\\c -> c `elem` (\"ueoai\" :: String) || isDigit c && odd (digitToInt c))"}, {"source_code": "import System.IO\n\nmain = do\n s <- getLine\n print (solve s)\n\nsolve = length . (filter (`elem` \"aeiou13579\"))\n"}, {"source_code": "main = do\n a <- getLine\n print (qwq a)\n\nqwq a = length [x|x <- a , qaq x]\n\nqaq x = elem x \"aeiou13579\""}, {"source_code": "main = do\n str <- getLine\n print $ length $ filter (`elem` \"aeiou13579\") str\n"}, {"source_code": "main = fmap (filter (`elem` \"aeiou13579\")) getLine >>= print.length\n"}, {"source_code": "import Control.Applicative\n\n\n \n\nmain::IO ()\nmain=do\n x<- getLine\n print $ length $ filter (\\z-> elem z \"aeiou13579\") x\n"}, {"source_code": "main = interact $ show . length . filter (`elem` \"aeiou13579\")\n"}], "negative_code": [{"source_code": "main = interact $ show . length . filter (`elem` \"aeiouy\")\n"}, {"source_code": "import Data.Char\nimport Data.List\nmain = getLine >>= print . length . filter (\\c -> c `elem` (\"ueoai\" :: String) || isDigit c && even (digitToInt c)) . nub"}, {"source_code": "import Data.Char\nmain = getLine >>= print . length . filter (\\c -> c `elem` (\"ueoai\" :: String) || isDigit c && even (digitToInt c))"}, {"source_code": "main = interact $ show . length . filter (`elem` \"aeiouy13579\")\n"}], "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223"} {"source_code": "import Data.List\n\ngetpage :: Int -> Int -> Int -> [Char]\ngetpage tot pre bod = \n let p = if (pre - bod <= 1) then \"\" else \"<< \"\n e = if (pre + bod >= tot) then \"\" else \" >>\"\n m = max 1 (pre - bod)\n n = min tot (pre + bod)\n f i j = i ++ show j ++ \" \"\n k = if ((pre >= 1) && (pre <= tot)) then \"(\" ++ show pre ++ \")\" else \"\"\n g i j = i ++ \" \" ++ show j\n in p ++ foldl f \"\" [m..pre - 1] ++ k ++ foldl g \"\" [pre + 1..n] ++ e\n\nmain = do\n g <- getLine\n let h = map read (words g)\n putStr $ getpage (h !! 0) (h !! 1) (h !! 2)\n", "positive_code": [{"source_code": "\nimport Data.List\nimport Control.Monad (forM_)\n\npages :: Int -> Int -> Int -> [String]\npages n p k =\n let lo = max 1 (p-k)\n hi = min n (p+k)\n lt = if lo > 1 then [\"<<\"] else []\n gt = if hi < n then [\">>\"] else []\n f i = if i == p then \"(\" ++ show i ++ \")\" else show i\n in lt ++ map f [lo..hi] ++ gt\n\n(-->) = flip fmap\n\nmain = do\n (n:p:k:_) <- getLine --> words --> map read\n forM_ (intersperse \" \" (pages n p k)) $ putStr\n putStrLn \"\"\n\n-- print << only if lo > 1\n-- print >> only if hi < n\n-- lo = max 1 (p - k)\n-- hi = min (p + k) n\n"}, {"source_code": "import Data.List\n\nsolve :: Int -> Int -> Int -> String\nsolve n p k = \n let m = map ([1..n]!!) $ filter (\\x -> x >= 0 && x < n) [p-1-k..p-1+k]\n (a,b) = break (==p) m\n myshow = unwords . map show \n in dropWhile (==' ') $ (if null a then \"\" else if head a == 1 then \"\" else \"<< \" ) ++ \n myshow a ++ \" (\" ++ (show $ head b) ++ \") \" ++ (myshow $ tail b) ++\n (if last b == n then \"\" else \" >>\" ) \n \nmain = do\n v@[n,p,k] <- map (read :: String -> Int) . words <$> getLine\n putStrLn $ solve n p k \n\n"}, {"source_code": "import Data.List\n\nf::Int->[Int]->[String]\nf x []=[]\nf x (y:ys)\n |x==y=(\"(\"++(show x)++\")\"):f x ys\n |otherwise=(show y):f x ys\n\nmain =do\n e<-getLine\n let (n:p:k:[])=map read (words e)::[Int]\n ts=[e2|e2<-[(p-k)..(p+k)],e2>0,e2<=n]\n l=head ts\n r=last ts\n t=unwords $ f p ts\n t2=if l==1 then \"\" else \"<< \"\n t3=if r==n then \"\" else \" >>\"\n putStrLn $ t2++t++t3"}, {"source_code": "import Data.List\n\nscaleLeft :: Int -> Int -> Int -> String\nscaleLeft size position shift | ((position - shift) - 1) <= 0 = intercalate \" \" $ map show $ [1 .. position - 1]\nscaleLeft size position shift = \"<< \" ++ ( intercalate \" \" $ map show $ [position - shift .. position -1] )\n\nscaleRight :: Int -> Int -> Int -> String\nscaleRight size position shift | position + shift >= size = intercalate \" \" $ map show $ [position + 1 .. size]\nscaleRight size position shift = (intercalate \" \" $ map show $ [position + 1 .. position + shift] ) ++ \" >>\"\n\nscale :: Int -> Int -> Int -> String\nscale size position shift = (scaleLeft size position shift) ++ \" (\" ++ (show position) ++ \") \" ++ (scaleRight size position shift)\n\nmain :: IO ()\nmain = do\n [size, position, shift] <- fmap (map read . words) getLine\n let result = scale size position shift\n putStrLn result"}], "negative_code": [{"source_code": "import Data.List\n\ngetpage :: Int -> Int -> Int -> [Char]\ngetpage tot pre bod = \n let p = if (pre - bod <= 1) then \"\" else \"<< \"\n e = if (pre + bod >= tot) then \"\" else \" >>\"\n m = max 1 (pre - bod)\n n = min tot (pre + bod)\n f i j = i ++ show j ++ \" \"\n k = if ((pre >= 1) && (pre <= tot)) then \"(\" ++ show pre ++ \")\" else \"\"\n g i j = i ++ \" \" ++ show j\n in p ++ foldl f \"\" [m..pre - 1] ++ k ++ foldl g \"\" [pre + 1..n] ++ e\n\nmain = do\n g <- getLine\n let h = map read (words g)\n print $ getpage (h !! 0) (h !! 1) (h !! 2)\n"}, {"source_code": "import Data.List\n\nscaleLeft :: Int -> Int -> Int -> String\nscaleLeft size position shift | ((position - shift) - 1) <= 0 = intercalate \" \" $ map show $ [1 .. position - 1]\nscaleLeft size position shift = \"<< \" ++ ( intercalate \" \" $ map show $ [position - shift .. position -1] )\n\nscaleRight :: Int -> Int -> Int -> String\nscaleRight size position shift | position + shift >= size = intercalate \" \" $ map show $ [position + 1 .. size]\nscaleRight size position shift = (intercalate \" \" $ map show $ [position + 1 .. position + shift] ) ++ \" >>\"\n\nscale :: Int -> Int -> Int -> String\nscale size position shift = (scaleLeft size position shift) ++ \" (\" ++ (show position) ++ \") \" ++ (scaleRight size position shift)\n\nmain :: IO ()\nmain = do\n [size, position, shift] <- fmap (map read . words) getLine\n let result = scale size position shift\n print result\n"}], "src_uid": "526e2cce272e42a3220e33149b1c9c84"} {"source_code": "countGilded :: Int -> Int -> Int -> Int\ncountGilded w h k = 2 * k * (w + h - 4 * k + 2)\n\nreadInt :: String -> Int\nreadInt = read\n\nmain = do\n [w,h,k] <- fmap (map readInt . words) getLine\n print $ countGilded w h k", "positive_code": [{"source_code": "makeRing :: (Int, Int) -> Int\nmakeRing (1, h) = h\nmakeRing (w, 1) = w\nmakeRing (w, h) = 2 * (w + h) - 4\n\nsmallerRing :: (Int, Int) -> (Int, Int)\nsmallerRing (w, h) = (w - 4, h - 4)\n\nplates :: Int -> Int -> Int -> Int\nplates w h k = sum golds\n where rings = take k $ iterate smallerRing (w, h)\n golds = map makeRing rings\n\nmain :: IO ()\nmain = do\n input <- getLine\n let inputs = map (read :: String -> Int) (words input)\n let output = plates (inputs!!0) (inputs!!1) (inputs!!2)\n print output\n"}, {"source_code": "main = getLine >>= print . solve . map read . words\n\nsolve (w:h:1:_) = if 0 < min w h then 2 * (w + h - 2) else 0\nsolve (w:h:k:_) = 2 * (w + h - 2) + solve [w - 4, h - 4, k - 1]\n"}, {"source_code": "import Data.List\n\nf ::Int->Int->Int->Int\nf w h k\n |w<=0 || h<=0 || k<=0=0\n |otherwise=(w*h-(w-2)*(h-2))+f (w-4) (h-4) (k-1)\n\nmain = do\n e1<-getLine\n let (w:h:k:[])=map read (words e1)::[Int]\n print $ f w h k"}, {"source_code": "main = do\n [n,m,k] <- fmap (map read . words) getLine\n print . sum . take k . iterate (flip (-) 16) $ 2 * (n + m) - 4\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\nmain = do\n\t\t[w,h,k]<- map read <$> words <$> getLine::IO [Int]\n\t\tprint $ sum $ zipWith (\\a b-> a+a+b+b-4) (take k [w,w-4..]) (take k [h,h-4..])\n"}], "negative_code": [{"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\nmain = do\n\t\t[w,h,k]<- map read <$> words <$> getLine::IO [Int]\n\t\tprint $ zipWith (\\a b-> a+a+b+b-4) (take k [w,w-4..]) (take k [h,h-4..])\n"}], "src_uid": "2c98d59917337cb321d76f72a1b3c057"} {"source_code": "\nimport Control.Monad (replicateM)\n\nreadPair :: IO (Int, Int)\nreadPair = do\n [x, y] <- getLine >>= return . map read . words\n if x > y then return (y,x) else return (x,y)\n\nsolve :: [(Int, Int)] -> Bool\nsolve xs = x || y\n where\n x = not $ null [(i,j,k) |\n i <- [1..5], j <- [i+1..5], k <- [j+1..5],\n all (flip elem xs) [(i,j),(i,k),(j,k)]]\n y = not $ null [(i,j,k) |\n i <- [1..5], j <- [i+1..5], k <- [j+1..5],\n all (not . flip elem xs) [(i,j),(i,k),(j,k)]]\n\nmain :: IO ()\nmain = do\n n <- readLn\n xs <- replicateM n readPair\n putStrLn (if (solve xs)\n then \"WIN\" else \"FAIL\")", "positive_code": [{"source_code": "import Control.Monad\ntwoint :: String -> (Int,Int)\ntwoint = p . words\n where p (a:b:[]) = (read a, read b)\n\nsolve :: [(Int,Int)] -> Bool\nsolve gs = or $ concat [ [pacq a b c gs,punacq a b c gs] | a<-[1..5], b<-[1..5], c<-[1..5], a/=b, b/=c, a/=c]\n\npacq a b c gs = acq a b gs && acq b c gs && acq a c gs\npunacq a b c gs = not (acq a b gs) && not (acq b c gs) && not (acq a c gs)\nacq a b gs = elem (a,b) gs || elem (b,a) gs\n\nmain = do\n m <- (liftM read) getLine\n gs <- forM [1..m] (\\i -> getLine >>= return . twoint)\n let r = solve gs\n putStrLn $ if r then \"WIN\" else \"FAIL\"\n"}, {"source_code": "module Main where\n\nimport Control.Monad\nimport Data.Array.IO\nimport Data.Array\nimport Data.List\n\nmain = do\n friendship <- buildFriendship :: IO (Array (Int,Int) Bool)\n putStrLn $ if foldl' (\\res i ->\n res || foldl' (\\res j ->\n res || foldl' (\\res k ->\n let a = friendship ! (i,j)\n b = friendship ! (i,k)\n c = friendship ! (j,k)\n in res || a == b && b == c\n ) res [j+1..5]\n ) res [i+1..5]\n ) False [1..5]\n then \"WIN\"\n else \"FAIL\"\n\nbuildFriendship = do\n m <- read `liftM` getLine\n\n friendship <- newArray ((1,1), (5,5)) False :: IO (IOArray (Int,Int) Bool)\n replicateM m $ do\n [a, b] <- ( map read . words ) `liftM` getLine\n writeArray friendship (a,b) True\n writeArray friendship (b,a) True\n\n unsafeFreeze friendship\n"}, {"source_code": "swap (x, y) = (y, x)\n\nreadPair :: String -> (Int, Int)\nreadPair = (\\[x, y] -> (x, y)).map read.words\n\nmakeGraph xs = map swap g ++ g\n where g = map readPair xs\n\ninvertGraph n g = [(a, b) | a <- vers, b <- vers,\n a /= b,\n not ((a, b) `elem` g)]\n where vers = [1..n]\n\nloops n g = [(a, b, c) | a <- vers, b <- vers, c <- vers,\n (a, b) `elem` g,\n (b, c) `elem` g,\n (c, a) `elem` g]\n where vers = [1..n]\n\n\nsolve xs = let g = makeGraph xs\n g' = invertGraph 5 g\n red = null $ loops 5 g\n black = null $ loops 5 g'\n in if red && black then \"FAIL\" else \"WIN\"\n\nmain = interact $ solve.tail.lines"}, {"source_code": "import Control.Monad (foldM)\nimport qualified Data.IntSet as S\nimport qualified Data.IntMap as M\nimport Data.List\nmain = do\n n <- read `fmap` getLine\n m <- foldM (\\map' _ -> do\n [a, b] <- (sort . map read . words) `fmap` getLine\n return $ M.insertWith S.union a (S.singleton b) map') M.empty [1..n]\n let f (a, b, c) = let \n [as, bs] = map (\\a -> M.findWithDefault S.empty a m) [a, b]\n pairs = [(b, as), (c, as), (c, bs)] in\n any (\\f -> all (uncurry f) pairs) [S.member, S.notMember]\n putStrLn $ if any f [(a, b, c) | a <- [1..5], b <- [1..5], c <- [1..5], a < b, b < c]\n then \"WIN\" else \"FAIL\"\n"}], "negative_code": [], "src_uid": "2bc18799c85ecaba87564a86a94e0322"} {"source_code": "module Main where\n\nimport Data.List \n\ndecrypt [] [] = []\ndecrypt [a] [] = [a]\ndecrypt (a:as) (b:bs) = a:b:decrypt as bs\n\nmain = do\n s <- getLine\n let (a,b) = splitAt ((flip div) 2 $ succ $ length s) s\n putStrLn $ decrypt (reverse a) b", "positive_code": [{"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE Safe #-}\n{-# LANGUAGE TupleSections#-}\n{-# LANGUAGE ExplicitForAll #-}\n\nimport Data.Bits\nimport Data.List\nimport qualified Data.ByteString.Char8 as BS\nimport Data.IntMap.Strict (IntMap)\nimport qualified Data.IntMap.Strict as IM\nimport qualified Data.Array.IArray as A\nimport qualified Data.Array.MArray.Safe as A\n-- import qualified Data.Array.MArray as A\nimport Data.Array (Array)\nimport Data.Array.Unboxed (UArray)\nimport Data.Array.IArray (IArray)\nimport Data.Array.MArray.Safe (MArray)\nimport Data.Array.IO.Safe (IOArray, IOUArray)\nimport Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)\n{-\nimport qualified Data.Vector.Unboxed as VU\nimport qualified Data.Vector.Unboxed.Mutable as VUM\n-}\nimport Control.Monad\nimport Control.Monad.ST.Safe\n-- import Control.Monad.ST\nimport Control.Applicative\nimport Data.Maybe\nimport Data.Tuple\nimport Data.Ord\nimport Control.Monad.State.Strict\nimport Data.Int\n\n\nmain :: IO ()\nmain = do\n ls <- getLine\n let n = length ls\n (l0,r) = splitAt ((n+1) `shiftR` 1) ls\n l = reverse l0\n go (x:xs) ys = x:go ys xs\n go [] ys = ys\n putStrLn $ go l r\n"}, {"source_code": "ans :: [Char] -> [Char]\nans [] = []\nans (h:[]) = [h]\nans (h:t)\n | (mod (length t) 2) == 0 = ans(t) ++ [h]\n | otherwise = ans (take ((length t)) (h:t)) ++ [t!!((length t)-1)]\n\nmain = do\n s <- getLine :: IO String;\n putStrLn $ ans s\n\n"}, {"source_code": "main = getLine >>= putStrLn . solve\n\nsolve xs = drop lxs $ concat $ zipWith (:) l $ map (:[]) r\n where lxs = length xs\n (l,r) = if odd lxs then (xs, reverse xs) else (reverse xs, xs)\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\n\n\nmain = do\n\ta<-getLine \n\tlet n = length a\n\tlet s = div (n+1) 2\n\tlet b= a ++ if even n then \"\" else \" \"\n\tputStrLn $ concat $ zipWith (\\x y ->[x]++[y]) (reverse (take s b)) (drop s b)\n"}], "negative_code": [], "src_uid": "992ae43e66f1808f19c86b1def1f6b41"} {"source_code": "import Data.List\n\ntoInt x = read x :: Integer\n\nsolve :: [Integer] -> [Integer] -> Integer\nsolve [] ys = sum ys\nsolve (x:xs) [] = solve xs [x]\nsolve (x:xs) (y:ys) = solve xs (i:y:ys)\n where i = if (x `elem` y:ys) \n then (if y-1 > 0 then y-1 else 0) \n else x\n\nmain = do\n getLine\n s <- getLine\n putStrLn (show (solve (reverse . sort . (map toInt) . words $ s) []))\n\n", "positive_code": [{"source_code": "{-\ninstructions go here...\n-}\n\nmodule Main where\n\nsolve :: [Integer] -> Integer\nsolve constraints = sum constraints'\n where constraints' = foldl (\\used v ->\n let v' = closestFree used v\n in (v':used)\n )\n []\n constraints\n closestFree _ 0 = 0\n closestFree [] v = v\n closestFree xs v = if v `elem` xs then closestFree xs (v - 1)\n else v\n\n\n\nmain :: IO ()\nmain = do\n line1 <- getLine\n let n = read line1 :: Integer\n\n line2 <- getLine\n let constraints = map read (words line2) :: [Integer]\n\n putStrLn $ show $ solve constraints\n"}, {"source_code": "{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE ViewPatterns #-}\n{-# LANGUAGE OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Tuple\nimport Data.Int\nimport Data.Char\nimport Data.Function\n-- import Data.ByteString (ByteString)\n-- import qualified Data.ByteString.Char8 as C\n-- import Data.ByteString.Char8 ()\n-- import Data.Vector.Unboxed ((//), (++), (!), (!?))\n-- import qualified Data.Vector.Unboxed as U\n-- import Data.IntMap.Strict (IntMap)\n-- import qualified Data.IntMap.Strict as IntMap\n-- import Data.Sequence ((|>), (<|), (><),ViewR((:>)), ViewL((:<)))\n-- import qualified Data.Sequence as S\n\nmyread = read :: String -> Integer\nmain = do\n n <- readLn\n ns <- map myread.words <$> getLine\n print $ solve n ns \n\nsolve :: Int -> [Integer] -> Integer\nsolve _ ns = go (group . sort $ ns) where\n go ns = if all ((==1) . length) ns\n then sum . concat $ ns\n else go (group . sort . concat . map stair $ ns) where\n stair [] = []\n stair xs = take (length xs) [maximum xs,maximum xs - 1..0]"}], "negative_code": [{"source_code": "import Data.List\n\ntoInt x = read x :: Integer\n\nsolve :: [Integer] -> [Integer] -> Integer\nsolve [] ys = sum ys\nsolve (x:xs) [] = solve xs [x]\nsolve (x:xs) (y:ys) = solve xs (i:y:ys)\n where i = if (x `elem` y:ys) then y-1 else x\n\nmain = do\n getLine\n s <- getLine\n putStrLn (show (solve (reverse . sort . (map toInt) . words $ s) []))\n\n"}, {"source_code": "import Data.List\n\ntoInt x = read x :: Int\n\nsolve :: [Int] -> [Int] -> Int\nsolve [] ys = sum ys\nsolve (x:xs) [] = solve xs [x]\nsolve (x:xs) (y:ys) = solve xs (i:y:ys)\n where i = if (x `elem` y:ys) then y-1 else x\n\nmain = do\n getLine\n s <- getLine\n putStrLn (show (solve (reverse . sort . (map toInt) . words $ s) []))\n\n"}, {"source_code": "import Data.List\n\ntoInt x = read x :: Int\n\nsolve :: [Int] -> [Int] -> Int\nsolve [] x = sum x\nsolve (x:xs) [] = solve xs [x]\nsolve (x:xs) (y:ys) = solve xs (i:y:ys)\n where i = if x == y then x-1 else x\n\nmain = do\n getLine\n s <- getLine\n putStrLn (show (solve (reverse . sort . (map toInt) . words $ s) []))\n\n"}, {"source_code": "{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE ViewPatterns #-}\n{-# LANGUAGE OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Tuple\nimport Data.Int\nimport Data.Char\nimport Data.Function\n-- import Data.ByteString (ByteString)\n-- import qualified Data.ByteString.Char8 as C\n-- import Data.ByteString.Char8 ()\n-- import Data.Vector.Unboxed ((//), (++), (!), (!?))\n-- import qualified Data.Vector.Unboxed as U\n-- import Data.IntMap.Strict (IntMap)\n-- import qualified Data.IntMap.Strict as IntMap\n-- import Data.Sequence ((|>), (<|), (><),ViewR((:>)), ViewL((:<)))\n-- import qualified Data.Sequence as S\n\nmyread = read :: String -> Int\nmain = do\n n <- readLn\n ns <- map myread.words <$> getLine\n print $ solve n ns \n\nsolve :: Int -> [Int] -> Int\nsolve _ ns = go (group . sort $ ns) where\n go ns = if all ((==1) . length) ns\n then sum . concat $ ns\n else go (group . sort . concat . map stair $ ns) where\n stair [] = []\n stair xs = take (length xs) [maximum xs,maximum xs - 1..0]"}], "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f"} {"source_code": "module Main where\n\nimport Control.Monad\n\nnumPlayers :: Int\nnumPlayers = 4\n\ndata Player = Player { defence :: Int, attack :: Int }\ndata Team = Team { defencePlayer :: Player, attackPlayer :: Player }\ndata Result = Team1 | Draw | Team2 deriving (Eq, Ord)\n\nplay :: Team -> Team -> Result\nplay t1 t2 | teamDefence t1 > teamAttack t2 && teamAttack t1 > teamDefence t2 = Team1\n | teamDefence t1 < teamAttack t2 && teamAttack t1 < teamDefence t2 = Team2\n | otherwise = Draw\n where teamDefence = defence . defencePlayer\n teamAttack = attack . attackPlayer\n\nturn2 :: Team -> [Player] -> Result\nturn2 t1 [c, d] = max (play t1 (Team c d)) (play t1 (Team d c))\n\nturn1 :: [Player] -> Result\nturn1 (a:b:ps) = min (turn2 (Team a b) ps) (turn2 (Team b a) ps)\n\ndata State s a = State { runState :: s -> (a, s) }\n\ninstance Monad (State a) where\n return a = State $ \\s -> (a, s)\n m >>= f = State $ \\s -> let (a, s') = runState m s\n in runState (f a) s'\n\ntype Tokenizer = State [String]\n\nnextInt :: Tokenizer Int\nnextInt = State $ \\(s:ss) -> (read s, ss)\n\nnextPlayer :: Tokenizer Player\nnextPlayer = liftM2 Player nextInt nextInt\n\ngo :: Tokenizer Result\ngo = do\n players <- replicateM numPlayers nextPlayer\n return $ turn1 players\n\nmain :: IO ()\nmain = do\n content <- liftM words getContents\n let result = fst $ runState go content\n putStrLn $ case result of\n Team1 -> \"Team 1\"\n Draw -> \"Draw\"\n Team2 -> \"Team 2\"\n\n", "positive_code": [{"source_code": "strToList = (map $ map (read :: (String -> Int))).(map words)\n\ndata Player = Player { att :: Int, def :: Int }\ndata Team = Team { offense :: Player, defense :: Player }\n\nmatchResult teamA teamB\n | att_a > def_b && def_a > att_b = \"Team 1\"\n | att_b > def_a && def_b > att_a = \"Team 2\"\n | otherwise = \"Draw\"\n where att_a = att $ offense teamA\n att_b = att $ offense teamB\n def_a = def $ defense teamA\n def_b = def $ defense teamB\n\nf :: (Player, Player) -> (Player, Player) -> String\nf (a, b) (c, d)\n | sa == \"Team 1\" && sc == \"Team 1\" = \"Team 1\"\n | sb == \"Team 1\" && sd == \"Team 1\" = \"Team 1\"\n | (sa == \"Team 2\" || sc == \"Team 2\") && (sb == \"Team 2\" || sd == \"Team 2\") = \"Team 2\"\n | otherwise = \"Draw\"\n where sa = matchResult (Team a b) (Team c d)\n sb = matchResult (Team b a) (Team c d)\n sc = matchResult (Team a b) (Team d c)\n sd = matchResult (Team b a) (Team d c)\n\ntuplify2 [a, b] = (a, b)\nmain = do\n s <- getContents\n let xs = map (\\[a, b] -> Player a b) $ strToList (lines s)\n putStrLn $ f (tuplify2 $ take 2 xs) (tuplify2 $ drop 2 xs)"}, {"source_code": "-- @betaveros :: vim:set fdm=marker:\n{-# LANGUAGE LambdaCase, NPlusKPatterns, TupleSections #-}\n{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-missing-signatures #-}\n-- import ALL the things! {{{\nimport Control.Applicative\nimport Control.Arrow\nimport Control.Exception\nimport Control.Monad\nimport Control.Monad.ST\n\nimport Data.Bits\nimport Data.Char\nimport Data.Either\nimport Data.Function\nimport Data.IORef\nimport Data.List\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.STRef\nimport Data.String\nimport Data.Tuple\n\nimport qualified Data.Map as Map\nimport Data.Map (Map)\nimport qualified Data.Set as Set\nimport Data.Set (Set)\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq, (<|), (|>), (><))\n\nimport Debug.Trace\nimport Text.Printf\n-- }}}\n-- silly utilities {{{\n(#) = flip ($)\ninfixl 0 #\n\nglength :: (Num b) => [a] -> b\nglength = genericLength\n\nreadInt = read :: String -> Int\nreadInteger = read :: String -> Integer\n-- (!?) :: (Ord k) => Map k v -> k -> Maybe v\n-- (!?) = flip Map.lookup\nhistogram :: (Ord a, Num b) => [a] -> Map a b\nhistogram = Map.fromListWith (+) . map (,1)\n\n(!>) :: Seq a -> Int -> a\n(!>) = Seq.index\n-- }}}\n-- input and output {{{\ninputInt = (read <$> getLine) :: IO Int\ninputInteger = (read <$> getLine) :: IO Integer\ninputDouble = (read <$> getLine) :: IO Double\n\ninputRow :: (Read a) => IO [a]\ninputRow = map read . words <$> getLine\ninputInts = inputRow :: IO [Int]\ninputIntegers = inputRow :: IO [Integer]\ninputDoubles = inputRow :: IO [Double]\n-- }}}\n\ninputPair = do\n\t[a, d] <- inputInts\n\treturn (a, d)\n\nbeats ((a1,_), (_,d1)) ((a2,_), (_,d2)) = a1 > d2 && d1 > a2\n\ndominates (p1, p2) (p3, p4) =\n\t((p1, p2) `beats` (p3, p4)) && ((p1, p2) `beats` (p4, p3))\ncanBeat (p1, p2) (p3, p4) =\n\t((p1, p2) `beats` (p3, p4)) || ((p2, p1) `beats` (p3, p4))\n\nmain :: IO ()\nmain = do\n\tp1 <- inputPair\n\tp2 <- inputPair\n\tp3 <- inputPair\n\tp4 <- inputPair\n\tputStrLn $ if ((p1, p2) `dominates` (p3, p4)) || ((p2, p1) `dominates` (p3, p4)) then\n\t\t\"Team 1\"\n\telse if ((p3, p4) `canBeat` (p1, p2)) && ((p3, p4) `canBeat` (p2, p1)) then\n\t\t\"Team 2\"\n\telse\n\t\t\"Draw\"\n"}], "negative_code": [{"source_code": "module Main where\n\nimport Control.Monad\n\nnumPlayers :: Int\nnumPlayers = 4\n\ndata Player = Player { defence :: Int, attack :: Int }\ndata Team = Team { defencePlayer :: Player, attackPlayer :: Player }\ndata Result = Team1 | Draw | Team2 deriving (Eq, Ord)\n\nplay :: Team -> Team -> Result\nplay t1 t2 | teamAttack t1 > teamAttack t2 && teamDefence t1 > teamDefence t2 = Team1\n | teamAttack t1 < teamAttack t2 && teamDefence t1 < teamDefence t2 = Team2\n | otherwise = Draw\n where teamDefence = defence . defencePlayer\n teamAttack = attack . attackPlayer\n\nturn2 :: Team -> [Player] -> Result\nturn2 t1 [c, d] = max (play t1 (Team c d)) (play t1 (Team d c))\n\nturn1 :: [Player] -> Result\nturn1 (a:b:ps) = min (turn2 (Team a b) ps) (turn2 (Team b a) ps)\n\ndata State s a = State { runState :: s -> (a, s) }\n\ninstance Monad (State a) where\n return a = State $ \\s -> (a, s)\n m >>= f = State $ \\s -> let (a, s') = runState m s\n in runState (f a) s'\n\ntype Tokenizer = State [String]\n\nnextInt :: Tokenizer Int\nnextInt = State $ \\(s:ss) -> (read s, ss)\n\nnextPlayer :: Tokenizer Player\nnextPlayer = liftM2 Player nextInt nextInt\n\ngo :: Tokenizer Result\ngo = do\n players <- replicateM numPlayers nextPlayer\n return $ turn1 players\n\nmain :: IO ()\nmain = do\n content <- liftM words getContents\n let result = fst $ runState go content\n putStrLn $ case result of\n Team1 -> \"Team 1\"\n Draw -> \"Draw\"\n Team2 -> \"Team 2\"\n\n"}], "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f"} {"source_code": "{-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -funfolding-use-threshold=16 -fexcess-precision -funbox-strict-fields #-}\nmodule Main where\nimport qualified Data.ByteString.Lazy.Char8 as B\nimport Control.Monad\nimport Control.Monad.Trans.State.Lazy\n\nmain = putStr . evalState app . B.words =<< B.getContents \n\napp = do\n n <- poi\n xs <- replicateM n poi\n return $ if solve n xs then \"yes\" else \"no\"\n where\n pop = state $ \\(x:xs) -> (x, xs)\n poi = fmap int pop\n int = maybe undefined fst . B.readInt\n\nsolve n xs = odd (head xs) && odd n && odd (last xs)", "positive_code": [{"source_code": "main = interact foo\n\nfoo :: String -> String\nfoo inp =\n let ns = map ((`mod` 2) . read) . words . (!! 1) . lines $ inp :: [Int]\n in if head ns == 1 && last ns == 1\n then if (length ns) `mod` 2 == 1\n then \"Yes\"\n else \"No\" --if bar ns False 0 then \"Yes\" else \"No\"\n else \"No\"\n\n-- bar :: [Int] -> Bool -> Int -> Bool -- ns lastWas1 countSoFar\n-- bar _ _ 3 = True\n-- bar [] _ _ = False\n-- bar (n:ns) lastWas1 count = \n-- if n == 1\n-- then if lastWas1 \n-- then bar ns True $ count + 1\n-- else bar ns True count\n-- else bar ns False count"}, {"source_code": "main = do\n n <- readLn :: IO Int\n xs <- fmap (map read . words) getLine :: IO [Int]\n if mod n 2 == 1 && mod (head xs) 2 == 1 && mod (last xs) 2 == 1\n then putStrLn \"Yes\"\n else putStrLn \"No\" "}, {"source_code": "main = do\n count <- getLine\n numbers <- getLine\n putStrLn $ magic_wrapper (magic (readNumber count) (readNumbers numbers))\n \nreadNumber :: String -> Int\nreadNumber = read\n\nreadNumbers :: String -> [Int]\nreadNumbers = map read . words\n\nmagic_wrapper :: Bool -> String\nmagic_wrapper True = \"Yes\"\nmagic_wrapper False = \"no\"\n\nmagic :: Int -> [Int] -> Bool\nmagic c xs\n | odd c = not (even (head xs)) && (not (even (last xs)))\n | otherwise = False\n"}, {"source_code": "{-# OPTIONS_GHC -O3 #-}\n{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}\n\nmain :: IO ()\nmain = do\n _ <- getLine\n (map (read :: String -> Int) . words -> xs@(last -> x)) <- getLine\n putStrLn $ case (head xs) `mod` 2 == 1 && x `mod` 2 == 1 && (length xs) `mod` 2 == 1 of\n True -> \"Yes\"\n False -> \"No\"\n"}], "negative_code": [{"source_code": "{-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -funfolding-use-threshold=16 -fexcess-precision -funbox-strict-fields #-}\nmodule Main where\nimport qualified Data.ByteString.Lazy.Char8 as B\nimport Control.Monad\nimport Control.Monad.Trans.State.Lazy\n\nmain = putStr . evalState app . B.words =<< B.getContents \n\napp = do\n n <- poi\n xs <- replicateM n poi\n return $ if solve n xs then \"yes\" else \"no\"\n where\n pop = state $ \\(x:xs) -> (x, xs)\n poi = fmap int pop\n int = maybe undefined fst . B.readInt\n\nsolve n (x:xs) = odd x && odd n"}, {"source_code": "{-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -funfolding-use-threshold=16 -fexcess-precision -funbox-strict-fields #-}\nmodule Main where\nimport qualified Data.ByteString.Lazy.Char8 as B\nimport Control.Monad\nimport Control.Monad.Trans.State.Lazy\n\nmain = putStr . unlines . map show . evalState app . B.words =<< B.getContents \n\napp = do\n n <- poi\n xs <- replicateM n poi\n return $ if solve n xs then \"yes\" else \"no\"\n where\n pop = state $ \\(x:xs) -> (x, xs)\n poi = fmap int pop\n int = maybe undefined fst . B.readInt\n\nsolve n (x:xs) = odd x && odd n"}, {"source_code": "main = do\n n <- readLn :: IO Int\n xs <- fmap (map read . words) getLine :: IO [Int]\n if mod n 2 == 1 && mod (head xs) 2 == 1 && mod (last xs) 2 == 1\n then print \"Yes\"\n else print \"No\" "}], "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db"} {"source_code": "{-# OPTIONS_GHC -O3 #-}\n{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}\n\nimport qualified Data.ByteString as B (getLine)\nimport qualified Data.ByteString.Char8 as C (readInt, words, dropWhile, unpack, reverse)\nimport qualified Data.Maybe as M (fromJust)\nimport Data.Char (isSpace)\n\nrstrip = C.reverse . C.dropWhile isSpace . C.reverse\n\nrun' ('V':'K':xs) ans = run' xs (ans + 1)\nrun' (x:xs) ans = run' xs ans\nrun' [] ans = ans\n\nflipx 'V' = 'K'\nflipx 'K' = 'V'\n\nflipi i x = take i x ++ [flipx (x !! i)] ++ drop (i + 1) x\n\nrun x = max (run' x 0) $ maximum [ run' (flipi i x) 0 | i <- [0..length x - 1] ]\n\nmain = do\n (C.unpack . rstrip -> x) <- B.getLine\n putStrLn $ show $ run x\n", "positive_code": [{"source_code": "main = do\n inp <- getLine\n print (num inp + check inp)\n\nnum ('V':'K':xs) = 1 + num xs\nnum (_:xs) = num xs\nnum [] = 0\n\ncheck [_] = 0\ncheck (x:y:[]) = if x==y then 1 else 0\ncheck inp@(x:y:xs)\n | x == y && x == 'K' = 1\n | otherwise = bonus inp\n\nbonus (x:y:z:xs)\n | x == y && y == z = 1\n | xs == [] = if y == z && y == 'V' then 1 else 0\n | otherwise = bonus (y:z:xs)\n"}, {"source_code": "import qualified Data.Sequence as Seq\nimport qualified Data.Maybe as Maybe\nimport qualified Data.Foldable as Fold\nimport qualified Data.Functor as Func\n\nmain :: IO ()\nmain = interact (show . countVKs)\n\ncountVKs :: String -> Int\ncountVKs s =\n let\n sv = Seq.fromList s\n idxs = Seq.fromList [0..(length s - 1)]\n flip v i = \n if Seq.index v i == 'V' then Seq.update i 'K' v else Seq.update i 'V' v\n count v = \n let ind i = if Seq.index v i == 'V' && Seq.index v (i+1) == 'K' \n then 1 else 0\n in (Fold.foldl (+) 0 . Func.fmap ind) (Seq.take (Seq.length sv - 1) idxs)\n in\n (Fold.foldl (max) 0 . Func.fmap (count . flip sv)) idxs"}, {"source_code": "-- comment\n\nimport qualified Data.Sequence as Seq\nimport qualified Data.Maybe as Maybe\nimport qualified Data.Foldable as Fold\nimport qualified Data.Functor as Func\n\nmain :: IO ()\nmain = interact (show . countVKs)\n\ncountVKs :: String -> Int\ncountVKs s =\n let\n sv = Seq.fromList s\n idxs = Seq.fromList [0..(length s - 1)]\n flip v i = \n if Seq.index v i == 'V' then Seq.update i 'K' v else Seq.update i 'V' v\n count v = \n let ind i = if Seq.index v i == 'V' && Seq.index v (i+1) == 'K' \n then 1 else 0\n in (Fold.foldl (+) 0 . Func.fmap ind) (Seq.take (Seq.length sv - 1) idxs)\n in\n (Fold.foldl (max) 0 . Func.fmap (count . flip sv)) idxs"}, {"source_code": "main :: IO ()\nmain = print . solve \"\" =<< getLine\n\nsolve :: String -> String -> Int\nsolve pre [] = solve' pre\nsolve pre (s:sx) = maximum [solve' (pre ++ \"V\" ++ sx), solve' (pre ++ \"K\" ++ sx), solve (pre ++ [s]) sx]\n\nsolve' :: String -> Int\nsolve' [] = 0\nsolve' ('V':'K':sx) = 1 + solve' sx\nsolve' (s:sx) = solve' sx\n"}], "negative_code": [{"source_code": "main = do\n inp <- getLine\n print (num inp + check inp)\n\nnum ('V':'K':xs) = 1 + num xs\nnum (_:xs) = num xs\nnum [] = 0\n\ncheck inp\n | length inp == 1 = 0\n | otherwise = bonus ( (head inp:inp) ++ last inp:[])\n\nbonus (x:y:z:xs)\n | x == y && y == z = 1\n | xs == [] = 0\n | otherwise = bonus (y:z:xs)\n"}, {"source_code": "main = do\n inp <- getLine\n print (num inp + bonus ( (head inp:inp) ++ last inp:[]))\n\nnum ('v':'k':xs) = 1 + num xs\nnum (_:xs) = num xs\nnum [] = 0\n\nbonus (x:y:z:xs)\n | x == y && y == z = 1\n | xs == [] = 0\n | otherwise = bonus (y:z:xs)\n"}, {"source_code": "main = do\n inp <- getLine\n print (num inp + bonus ( (head inp:inp) ++ last inp:[]))\n\nnum ('V':'K':xs) = 1 + num xs\nnum (_:xs) = num xs\nnum [] = 0\n\nbonus (x:y:z:xs)\n | x == y && y == z = 1\n | xs == [] = 0\n | otherwise = bonus (y:z:xs)\n"}], "src_uid": "578bae0fe6634882227ac371ebb38fc9"} {"source_code": "main = interact $ unlines . map (show . (`div` 3) . (+2) . read) . tail . lines\n", "positive_code": [{"source_code": "f::[Int]->[String]\nf []=[]\nf (x:xs)=let t=(x-1) `div` 6 +1\n in (show t):f xs\n\nmain = do\n e<-getLine\n ts<-getContents\n let xs=map read (lines ts)::[Int]\n mapM_ putStrLn $ f xs"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\n\nprocess = do\n\t\tb<-read <$> getLine ::IO Int\n\t\tprint $ 1+ div b 7 \n\nmain= do\n\t\ta<- read <$> getLine ::IO Int\n\t\treplicateM_ a process\t\n\n"}, {"source_code": "--ghc 7.10\n\ncountRolls :: Int -> Int\ncountRolls n = (n+6) `div` 7\n\nmain = do\n tStr <- getLine\n contents <- getContents\n let xs = map read . words $ contents :: [Int]\n let rs = map countRolls $ xs\n sequence (map print rs)"}], "negative_code": [{"source_code": "main = interact $ unlines . map (show . (`div` 3) . read) . tail . lines\n"}], "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c"} {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\nmain = do\n\ts <- getLine\n\tt <- getLine\n\tprint $ solve s t 1\n\nsolve :: String -> String -> Int -> Int\nsolve [] _ cur = cur\nsolve _ [] cur = cur\nsolve s@(a:as) (b:bs) cur\n\t| a == b = solve as bs ( cur + 1 )\n\t| otherwise = solve s bs cur\n", "positive_code": [{"source_code": "main = do\n s <- getLine\n t <- getLine\n print $ solve s t 1\n\nsolve [] _ i = i\nsolve _ [] i = i\nsolve (x:xs) (t:ts) i\n | x == t = solve xs ts (i + 1)\n | otherwise = solve (x:xs) ts i"}, {"source_code": "import Data.Array;\n\nmain :: IO ()\nmain = do\n pos <- getLine\n let posArr = array (1, length pos) $ zip [1 ..] pos\n ins <- getLine\n let worker idx i\n | posArr ! idx == i = idx + 1\n | otherwise = idx \n print $ foldl worker 1 ins\n\n"}, {"source_code": "main :: IO ()\nmain = getContents >>= print . (\\[s, t] -> solve (1, s) t) . lines\n\nsolve :: (Integer, String) -> String -> Integer\nsolve = (fst .) . foldl (\\(k, s) t -> if head s == t then (k + 1, tail s) else (k, s))\n"}, {"source_code": "main = interact $ show . solve . lines\nsolve [s,t] = go s t 1 where\n go _ [] i = i\n go s@(h:s') (t:tt) i | h == t = go s' tt $! i+1\n | otherwise = go s tt i\n"}, {"source_code": "main = do\n s <- getLine\n t <- getLine\n print $ solve s t 1\nsolve _ [] n = n\nsolve (s:ss) (t:ts) n = if s == t then solve ss ts $ n+1 else solve (s:ss) ts n\n"}, {"source_code": "main = do\n s <- getLine\n t <- getLine\n print $ f 1 s t\n\nf pos (x:xs) (y:ys)\n | x==y = f (pos+1) xs ys\n | otherwise = f pos (x:xs) ys\nf pos _ _ = pos "}, {"source_code": "main = do\n l1 <- getLine\n l2 <- getLine\n print $ slv l1 l2 1\n\nslv _ [] n = n\nslv xs'@(x:xs) (y:ys) n\n | x == y = slv xs ys (n+1)\n | otherwise = slv xs' ys n"}, {"source_code": "import Control.Applicative\nimport Data.Bits\nimport qualified Data.ByteString.Char8 as C\nimport Data.Maybe\n \n\nprocess _ [] n = n\nprocess (s1:s1s) (s2:s2s) n | s1==s2 = process s1s s2s (n+1)\n |otherwise = process (s1:s1s) s2s n\n\nmain = do\n\ts1<- getLine \n\ts2<- getLine\n\tprint $ process s1 s2 1 \n\t\n\t \n"}, {"source_code": "\nsolve :: String -> String -> Int\nsolve _ \"\" = 1\nsolve (c1:s1) (c2:s2)\n | c1 == c2 = 1 + solve s1 s2\n | otherwise = solve (c1:s1) s2\n\nmain :: IO ()\nmain = do\n s1 <- getLine\n s2 <- getLine\n print $ solve s1 s2"}, {"source_code": "process :: [Char] -> [Char] -> Int\nprocess xs@(x:xss) (y:yss)\n | x == y = 1+process xss yss\n | otherwise = process xs yss\nprocess _ _ = 1\n\nmain :: IO ()\nmain = do\n xs <- getLine\n ys <- getLine\n print $ process xs ys"}, {"source_code": "import Data.List\n\nf::String->String->Int->Int\nf _ \"\" p=p\nf \"\" _ p=p\nf (x:xs) (y:ys) p\n |x==y=f xs ys (p+1)\n |otherwise=f xs (y:ys) p\n\nmain = do\n a<-getLine\n b<-getLine\n print $ f b a 1"}, {"source_code": "main=interact$show.(\\[s,t]->f(1,s)t).lines\nf=(fst.).foldl(\\(k,s)t->if head s==t then(k+1,tail s)else(k,s))\n"}, {"source_code": "main :: IO ()\nmain = getContents >>= print . (\\[s, t] -> solve 1 s t) . lines\n\nsolve :: Integer -> String -> String -> Integer\nsolve n sss@(s:ss) (t:ts) | s == t = solve (n + 1) ss ts\n | otherwise = solve n sss ts\nsolve n _ _ = n\n"}], "negative_code": [], "src_uid": "f5a907d6d35390b1fb11c8ce247d0252"} {"source_code": "main = do\n\tn <- getLine >>= readIO :: IO Int\n\tif n `mod` 2 == 0 then do putStrLn \"white\\n1 2\"\n\t\t\t else putStrLn \"black\"\n", "positive_code": [{"source_code": "solve input =\n let n = read input\n in if even n\n then \"white\\n1 2\"\n else \"black\"\n\nmain = interact solve"}, {"source_code": "main = do\n input <- getLine >>= (return . read)\n if odd input then\n putStrLn \"black\"\n else do\n putStrLn \"white\\n1 2\"\n\n"}, {"source_code": "main = getLine >>= putStrLn . solve . head . fmap read . words\n where solve x = if odd x then \"black\" else \"white\\n1 2\"\n"}], "negative_code": [], "src_uid": "52e07d176aa1d370788f94ee2e61df93"} {"source_code": "data State = Class Int | Waiting Int | Home Int\n\nmain = interact $ schedule . prep\n\nprep input =\n let (_:pairs:_) = lines input\n in map read $ words pairs\n\nschedule = strip . foldl (\\acc x -> case acc of\n Class y -> if x == 1 then Class (y + 1) else Waiting y\n Waiting y -> if x == 1 then Class (y + 2) else Home y\n Home y -> if x == 1 then Class (y + 1) else Home y) (Home 0)\n\nstrip (Class y) = show y\nstrip (Waiting y) = show y\nstrip (Home y) = show y\n", "positive_code": [{"source_code": "module Main (main)\n where\n\nimport Data.List (group)\nimport Control.Arrow ((&&&))\n\n\nmain :: IO ()\nmain = (getLine >> getLine) >>= print . solve . map read . words\n where solve = reduce 0 . map (head &&& length) . group\n reduce n [(0,_)] = n\n reduce n [(1,l)] = n + l\n reduce 0 ((0,_):xs) = reduce 0 xs\n reduce n ((1,l):xs) = reduce (n + l) xs\n reduce n ((0,l):xs)\n | l >= 2 = reduce n xs\n | otherwise = reduce (n + 1) xs"}, {"source_code": "import Data.List\n\nmain = do\n getLine\n x <- (group.dropWhile(==0).reverse.dropWhile(==0).map read.words)`fmap`getLine\n putStrLn $ solve x 0\n\nsolve [] n = show n\nsolve ([x]:o) n = solve o (n+1)\nsolve ((0:0:xs):o) n = solve o n\nsolve (x:o) n = solve o (n+length x)\n"}, {"source_code": "main :: IO()\nmain = print . solve True False 0 . map read . tail . words =<< getContents\n\nsolve :: Bool -> Bool -> Int -> [Int] -> Int\nsolve _ False cnt [] = cnt\nsolve False True cnt [] = cnt - 1\nsolve _ _ cnt (1:x) = solve False False (cnt + 1) x\nsolve True False cnt (0:x) = solve True False cnt x\nsolve False True cnt (0:x) = solve True False (cnt - 1) x\nsolve False False cnt (0:x) = solve False True (cnt + 1) x\n"}, {"source_code": "main = do\n n <- readLn :: IO Int\n a <- fmap ((map read) . words) getLine :: IO [Int]\n let a1 = reverse . dropWhile (==0) . reverse . dropWhile (==0) $ a\n print $ solve a1\n\nsolve [] = 0\nsolve (1:[]) = 1\nsolve (x:xs)\n |and [x==0,head xs==0] = solve (dropWhile (==0) xs)\n |otherwise = 1+solve xs"}, {"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad hiding ((<$!>))\nimport Control.Monad.ST.Safe\nimport Control.Monad.State hiding ((<$!>))\n-- import Data.Array\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IntSet\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map.Strict (Map)\nimport qualified Data.Map.Strict as Map\nimport Data.HashMap.Strict (HashMap)\nimport qualified Data.HashMap.Strict as HashMap\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\n-- import Debug.Trace\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n getLine\n xs <- getInts\n\n print $ length $ concat $ filter (\\g -> not $ head g == 0 && length g >= 2) $ group $ dropWhile (== 0) $ reverse $ dropWhile (== 0) $ reverse xs\n"}, {"source_code": "answer (a:[]) state = a\nanswer s state = if state == 0 then if h == 0 then answer t 0\n else 1 + (answer t 1)\n else if (h == 0) && (hh==0) then answer t 0\n else 1 + (answer t 1)\n where h=head s\n t=tail s\n hh=head t\nmain=do\n w1 <- getLine\n let n=read w1::Int\n w0 <- getLine\n let sl =[read n::Int|n<-(words w0)]\n print $ answer sl 0\n"}, {"source_code": "f :: [Int] -> [Int]\nf (x:y:z:zs) = if (y == 0) && (x == 1) && (z == 1) then x : 1 : f (z:zs)\n else x : f (y:z:zs)\nf xs = xs\n \nsolve :: [Int] -> Int\nsolve = length . filter (==1) . f\n\nmain = getLine >> fmap (map read . words) getLine >>= print . solve\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport qualified Data.ByteString.Char8 as C\nimport Data.Maybe\n \nmyfunc 0 0 =0\nmyfunc _ _ =1\n\n\n \nmain=do\t \n\tx<- read <$> getLine:: IO Int\n\tn<- map read. words <$> getLine:: IO [Int]\n\tlet n1 =dropWhile (==0) $reverse $ dropWhile (==0) n\n\tlet y= length n1\n\tlet a=filter (\\z-> head z==0) $ group $ zipWith myfunc n1 (tail n1)\n\tprint $ y-(length a ) - sum (map length a)\n\t \n"}], "negative_code": [], "src_uid": "2896aadda9e7a317d33315f91d1ca64d"} {"source_code": "t k = max 0 k * (k+1) `div` 2\ns a b k = if a+b 2*i*i-2*i+1) (i+1)\n walls = wall x + wall y + wall (n-x+1) + wall (n-y+1)\n corners = sum [corner (dx+dy-1) | dx<-[x,(n-x+1)],dy<-[y,(n-y+1)]]\n wall dist = w (max 0 $ i - dist + 1) where\n w i = i*i\n corner dist = c (max 0 $ i - dist + 1) where\n c i = i*(i-1)`div`2\nsolve[n,x,y,c]=bsearch good (-1) (10^9+1 :: Integer) where\n good i = whole - walls + corners >= c where\n (whole, walls, corners) = calc n x y i\nmain=interact$show.solve.map read.words"}, {"source_code": "t k = max 0 k * (k+1) `div` 2\ns a b k = if a+b= r = r\n | h m = find l m\n | otherwise = find (m+1) r\n where m=(l+r) `div` 2\n\nmain = interact $ show . solve . map read . words"}, {"source_code": "t k = max 0 k * (k+1) `div` 2\ns a b k = if a+b>= return . map read . words\n putStrLn $ show $solve n x y c\n\nsolve :: Int64 -> Int64 -> Int64 -> Int64 -> Int64\nsolve n x y 1 = 0\nsolve n x y c = binarySearch n x y c 0 (2 * n)\n\nbinarySearch n x y c a b \n | a + 1 == b = b\n | lighton n x y m >= c = binarySearch n x y c a m\n | otherwise = binarySearch n x y c m b\n where m = (a+b) `div` 2\n\n\nlighton n x y t = center t - side x t - side (n-x+1) t\n - side y t - side (n-y+1) t\n + corner x y t\n + corner (n+1-x) y t\n + corner x (n+1-y) t\n + corner (n+1-x) (n+1-y) t\n\ncenter t = 2 * t * t + 2 * t + 1\n\nside x t \n | (1+t-x) > 0 = (1 + t - x) ^ 2\n | otherwise = 0\n\nr n x t\n | (x+t-n) > 0 = (x + t - n) ^ 2\n | otherwise = 0\n\n\ncorner x y t\n | t - x - y + 1 > 0 = (t - x - y + 1)* (t-x-y+2) `div` 2\n | otherwise = 0\n\n\n\n"}, {"source_code": "t k = max 0 k * (k+1) `div` 2\ns a b k = if a+b 2*i*i-2*i+1) (i+1)\n walls = wall x + wall y + wall (n-x+1) + wall (n-y+1)\n corners = sum [corner (dx+dy-1) | dx<-[x,(n-x+1)],dy<-[y,(n-y+1)]]\n wall dist = w (max 0 $ i - dist) where\n w i = i*i\n corner dist = c (max 0 $ i - dist) where\n c i = i*(i-1)`div`2\nsolve[n,x,y,c]=bsearch good (-1) (10^9+1 :: Integer) where\n good i = whole - walls + corners >= c where\n (whole, walls, corners) = calc n x y i\nmain=interact$show.solve.map read.words"}], "src_uid": "232c5206ee7c1903556c3625e0b0efc6"} {"source_code": "module Main where\n\nimport Data.Int\n\nmain :: IO ()\nmain = do\n [n, m, a, b] <- fmap (fmap read . words) getLine\n putStrLn $ show $ minCost n m a b\n\n\nminCost :: Int64 -> Int64 -> Int64 -> Int64 -> Int64\nminCost n m a b = min (demolish * b) (build * a)\n where demolish = n `mod` m\n build = m - demolish\n\n", "positive_code": [{"source_code": "main=interact$show.f.map read.words\nf :: [Integer] -> Integer\nf[n,m,a,b]\n | mod n m == 0 = 0\n | otherwise = minimum [a * (m - mod n m), b * mod n m]\n"}, {"source_code": "module Main where\n\nimport System.IO\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as C8\n\nimport qualified Data.Array as Array\nimport qualified Data.Set as Set\nimport qualified Data.List as List\nimport qualified Data.Map as Map\n\nimport Control.Monad\n\ninput :: IO BS.ByteString\ninput = do\n handle <- return stdin --openFile \"test.txt\" ReadMode\n BS.hGetContents handle\n\nreadInts :: BS.ByteString -> [Int]\nreadInts = map parse . C8.words\n where parse s = let Just(x,_) = C8.readInt s in x\n\nmain :: IO ()\nmain = do\n [n,m,a,b] <- fmap (map read . words) getLine :: IO [Integer]\n let toRemove = n `mod` m\n toAdd = m - toRemove\n print $ min (toAdd * a) (toRemove * b)\n"}, {"source_code": "calculateStuff :: [Integer] -> Integer\ncalculateStuff (n:m:a:b:tail)\n | (n `mod` m == 0) = 0\n | constructing < demolishing = constructing\n | otherwise = demolishing\n where constructing = a * (m - n `mod` m)\n demolishing = b * (n `mod` m) \n\nmain = interact $ show . calculateStuff . map read . words\n"}, {"source_code": "import Data.List\nimport Data.Int\nimport qualified Data.Array as A\nimport Data.Array((!))\nimport Numeric\n\nfastRead :: String -> Int64\nfastRead ('-':s) = case readDec s of [(n, \"\")] -> (-n)\nfastRead s = case readDec s of [(n, \"\")] -> n\n\nmain = interact solve\n\nsolve input = show answer\n where\n (n:m:a:b:_) = map fastRead (words input)\n extra = mod n m\n whenadd = (m - extra) * a\n whenremove = extra * b\n answer = min whenadd whenremove\n"}], "negative_code": [{"source_code": "calculateStuff :: [Int] -> Int\ncalculateStuff (n:m:a:b:tail)\n | (n `mod` m == 0) = 0\n | constructing < demolishing = constructing\n | otherwise = demolishing\n where constructing = a * (m - n `mod` m)\n demolishing = b * (n `mod` m) \n\nmain = interact $ show . calculateStuff . map read . words\n-- why"}, {"source_code": "calculateStuff :: [Int] -> Int\ncalculateStuff (n:m:a:b:tail)\n | (n `mod` m == 0) = 0\n | constructing < demolishing = constructing\n | otherwise = demolishing\n where constructing = a * (m - n `mod` m)\n demolishing = b * (n `mod` m) \n\nmain = interact $ show . calculateStuff . map read . words\n"}], "src_uid": "c05d753b35545176ad468b99ff13aa39"} {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n \nimport Text.Printf\nimport Data.List\nimport Data.Functor\nimport Data.Function\nimport Control.Monad\nimport Control.Applicative\nimport Data.Maybe\nimport Data.Foldable (foldl', foldr', foldr1)\nimport Prelude\nimport Control.Monad.State.Strict\nimport Data.Int\nimport qualified Data.ByteString.Char8 as B8\nimport qualified Data.Map.Strict as MapS\nimport qualified Data.Set as Set\n \nreadB8Int64 :: B8.ByteString -> Int64\nreadB8Int64 = fromInteger . fst . fromJust . B8.readInteger\n \nlimitedValid :: Int64 -> Int64 -> [Int64]\nlimitedValid k limit = takeWhile (<= limit) $ iterate (* k) 1\n \ntwoThreeValid :: Int64 -> [Int64]\ntwoThreeValid limit = do\n twoValid <- limitedValid 2 limit\n threeValid <- limitedValid 3 $ limit `div` twoValid\n return $ twoValid * threeValid\n \ntwoThreeLimitCount :: Int64 -> Int64\ntwoThreeLimitCount limit = fromIntegral . length $ twoThreeValid limit\n \ntwoThreeRangeCount :: Int64 -> Int64 -> Int64\ntwoThreeRangeCount l r = (twoThreeLimitCount r) - (twoThreeLimitCount $ l - 1)\n \nmain :: IO ()\nmain = do\n [l, r] <- (map readB8Int64) <$> B8.words <$> B8.getLine\n let answer = twoThreeRangeCount l r\n printf \"%lld\\n\" $ answer\n ", "positive_code": [{"source_code": "li = [1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 128, 144, 162, 192, 216, 243, 256, 288, 324, 384, 432, 486, 512, 576, 648, 729, 768, 864, 972, 1024, 1152, 1296, 1458, 1536, 1728, 1944, 2048, 2187, 2304, 2592, 2916, 3072, 3456, 3888, 4096, 4374, 4608, 5184, 5832, 6144, 6561, 6912, 7776, 8192, 8748, 9216, 10368, 11664, 12288, 13122, 13824, 15552, 16384, 17496, 18432, 19683, 20736, 23328, 24576, 26244, 27648, 31104, 32768, 34992, 36864, 39366, 41472, 46656, 49152, 52488, 55296, 59049, 62208, 65536, 69984, 73728, 78732, 82944, 93312, 98304, 104976, 110592, 118098, 124416, 131072, 139968, 147456, 157464, 165888, 177147, 186624, 196608, 209952, 221184, 236196, 248832, 262144, 279936, 294912, 314928, 331776, 354294, 373248, 393216, 419904, 442368, 472392, 497664, 524288, 531441, 559872, 589824, 629856, 663552, 708588, 746496, 786432, 839808, 884736, 944784, 995328, 1048576, 1062882, 1119744, 1179648, 1259712, 1327104, 1417176, 1492992, 1572864, 1594323, 1679616, 1769472, 1889568, 1990656, 2097152, 2125764, 2239488, 2359296, 2519424, 2654208, 2834352, 2985984, 3145728, 3188646, 3359232, 3538944, 3779136, 3981312, 4194304, 4251528, 4478976, 4718592, 4782969, 5038848, 5308416, 5668704, 5971968, 6291456, 6377292, 6718464, 7077888, 7558272, 7962624, 8388608, 8503056, 8957952, 9437184, 9565938, 10077696, 10616832, 11337408, 11943936, 12582912, 12754584, 13436928, 14155776, 14348907, 15116544, 15925248, 16777216, 17006112, 17915904, 18874368, 19131876, 20155392, 21233664, 22674816, 23887872, 25165824, 25509168, 26873856, 28311552, 28697814, 30233088, 31850496, 33554432, 34012224, 35831808, 37748736, 38263752, 40310784, 42467328, 43046721, 45349632, 47775744, 50331648, 51018336, 53747712, 56623104, 57395628, 60466176, 63700992, 67108864, 68024448, 71663616, 75497472, 76527504, 80621568, 84934656, 86093442, 90699264, 95551488, 100663296, 102036672, 107495424, 113246208, 114791256, 120932352, 127401984, 129140163, 134217728, 136048896, 143327232, 150994944, 153055008, 161243136, 169869312, 172186884, 181398528, 191102976, 201326592, 204073344, 214990848, 226492416, 229582512, 241864704, 254803968, 258280326, 268435456, 272097792, 286654464, 301989888, 306110016, 322486272, 339738624, 344373768, 362797056, 382205952, 387420489, 402653184, 408146688, 429981696, 452984832, 459165024, 483729408, 509607936, 516560652, 536870912, 544195584, 573308928, 603979776, 612220032, 644972544, 679477248, 688747536, 725594112, 764411904, 774840978, 805306368, 816293376, 859963392, 905969664, 918330048, 967458816, 1019215872, 1033121304, 1073741824, 1088391168, 1146617856, 1162261467, 1207959552, 1224440064, 1289945088, 1358954496, 1377495072, 1451188224, 1528823808, 1549681956, 1610612736, 1632586752, 1719926784, 1811939328, 1836660096, 1934917632]\nans l r = length $ filter (>= l) $ filter (<= r) li\nrInt x = read x::Int\nrans ([x, y]) = ans x y\nmain = do\n x <- getLine\n putStrLn $ show $ rans $ map rInt $ words x"}, {"source_code": "import Data.List (sort)\n\nmain= do\n inpt <- getLine\n let (a:b:_) = map read (words inpt)\n print $ f a b\n\nf a b = length $ filter (\\x -> x >= a && x <= b) genlist\ngenlist = sort . concat $ map (\\x -> gen' x) (map (\\y -> 3 ^ y) [0..33])\ngen' a = map (\\x -> (2 ^ x) * a) [0..33]"}, {"source_code": "countNums :: Integer -> Integer -> Integer -> Int -> Int\ncountNums n p2 p3 cnt\n | p2 >= n = cnt\n | p2*p3 >= n = countNums n (p2*2) 1 cnt\n | otherwise = countNums n p2 (p3*3) (cnt+1)\n\ncountLT :: Integer -> Int\ncountLT n = countNums n 1 1 0\n\nmain :: IO ()\nmain = do\n xs <- fmap (map (read :: String -> Integer) . words) getLine\n print $ countLT ((xs!!1) + 1) - countLT (head xs) "}, {"source_code": "import qualified Data.List.Split as Spl\n\nptwo :: Integer -> Integer\nptwo 0 = 1\nptwo x = (ptwo $ x - 1) * 2\n\npth :: Integer -> Integer\npth 0 = 1\npth x = (pth $ x - 1) * 3\n\ncheck :: Integer -> Integer -> Integer -> Integer -> Int\n\ncheck l r x y =\n if ((((ptwo x) * (pth y)) >= l) && (((ptwo x) * (pth y)) <= r))\n then 1\n else 0\n\nsolveY :: Integer -> Integer -> Integer -> Integer -> Int\n\nsolveY l r x y = \n if y > 20 then 0\n else (solveY l r x (y + 1)) + (check l r x y)\n\nsolveX :: Integer -> Integer -> Integer -> Int\n\nsolveX l r x = \n if x > 32 then 0\n else (solveX l r (x + 1)) + (solveY l r x 0)\n\nmain = do\n input <- getLine\n let keks = Spl.splitOn \" \" input\n let l = read (keks !! 0) :: Integer\n let r = read (keks !! 1) :: Integer\n print $ solveX l r 0"}], "negative_code": [{"source_code": "import Data.List (sort)\n\nmain= do {\n\tinpt <- getLine\n\t; let (a:b:_) = map read (words inpt) :: [Int]\n\t; print $ f a b }\n\t\nf a b = length $ filter (\\x -> x >= a && x <= b) genlist\ngenlist = sort . concat $ map (\\x -> gen' x) (map (\\y -> 3 ^ y) [0..33])\ngen' a = map (\\x -> (2 ^ x) * a) [0..33]"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n \nimport Text.Printf\nimport Data.List\nimport Data.Functor\nimport Data.Function\nimport Control.Monad\nimport Control.Applicative\nimport Data.Maybe\nimport Data.Foldable (foldl', foldr', foldr1)\nimport Prelude\nimport Control.Monad.State.Strict\nimport Data.Int\nimport qualified Data.ByteString.Char8 as B8\nimport qualified Data.Map.Strict as MapS\nimport qualified Data.Set as Set\n \nreadB8Int64 :: B8.ByteString -> Int64\nreadB8Int64 = fromInteger . fst . fromJust . B8.readInteger\n\nlimitedValid :: Int64 -> Int64 -> [Int64]\nlimitedValid k limit = takeWhile (<= limit) $ iterate (* k) 1\n\ntwoThreeValid :: Int64 -> [Int64]\ntwoThreeValid limit = do\n twoValid <- limitedValid 2 limit\n threeValid <- limitedValid 3 $ limit `div` twoValid\n return $ twoValid * threeValid\n\ntwoThreeLimitCount :: Int64 -> Int64\ntwoThreeLimitCount limit = limit - (fromIntegral . length $ twoThreeValid limit)\n\ntwoThreeRangeCount :: Int64 -> Int64 -> Int64\ntwoThreeRangeCount l r = (twoThreeLimitCount r) - (twoThreeLimitCount $ l - 1)\n\nmain :: IO ()\nmain = do\n [l, r] <- (map readB8Int64) <$> B8.words <$> B8.getLine\n let answer = twoThreeRangeCount l r\n printf \"%lld\\n\" $ answer\n\n"}], "src_uid": "05fac54ed2064b46338bb18f897a4411"} {"source_code": "main :: IO ()\nmain = print . solve 0 . map read . words =<< getContents\n\nsolve :: Int -> [Int] -> Int\nsolve 200 _ = -1\nsolve i [a, b, c, d] | b == d = b\n | b < d = solve (i + 1) [a, b + a, c, d]\n | otherwise = solve (i + 1) [a, b, c, d + c]\n", "positive_code": [{"source_code": "{-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -funfolding-use-threshold=16 -fexcess-precision -funbox-strict-fields #-} \nmodule Main where\nimport qualified Data.ByteString.Char8 as B\n\nmain = do\n [a, b] <- fmap readInts B.getLine\n [c, d] <- fmap readInts B.getLine\n print $ solve a b c d\n\nee a b = go a b 1 0 0 1\n where\n go r0 r1 s0 s1 t0 t1 \n | r == 0 = (s1, t1, r1)\n | otherwise = go r1 r s1 (s0 - q * s1) t1 (t0 - q * t1)\n where (q, r) = r0 `quotRem` r1\n\nsolve a b c d \n | r /= 0 = -1\n | otherwise = b + (x - t * c `div` g) * a\n where \n (x_, y_, g) = ee a c\n (q, r) = (d - b) `divMod` g\n (x, y) = (q * x_, q * y_)\n t = min (x * g `div` c) ((-y) * g `div` a)\n\n\nreadInt = maybe undefined fst . B.readInt\nreadInts = fmap readInt . B.words\n\n-- b + na = d + mc\n-- na - mc = d - b\n-- xa + yc = gcd(a, c)\n-- n = x - r * c/gcd(a, c) >= 0\n-- r <= x * gcd(a,c) / c\n-- r <= \n-- m = y + r * c/gcd(a, c) <="}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List (intersect)\n\nmain = replicateM 2 (fmap read . words <$> getLine) >>= \\[[a,b],[c,d]]-> print $ head $ intersect [d, d+c..d+ 100*c] [b,b+a..b+100*a] ++[-1]\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List (find)\n\nmain = replicateM 2 (fmap read . words <$> getLine) >>= \\[[a,b],[c,d]]-> print $ head $ [k |i <- [0..100], j <-[0..100],\n let k = b + i * a, let l = d + j * c,\n k == l] ++ [-1]\n"}, {"source_code": "main = getContents >>= print . solve . map read . words\n\nsolve [a, b, c, d] = (\\ls -> if null ls then -1 else head ls)\n [t | t <- [(max b d)..1000000], (t - b) `mod` a == 0, (t - d) `mod` c == 0]\n \n"}, {"source_code": "{-# OPTIONS_GHC -O3 #-}\n{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}\n\nimport Data.List (sort, sortBy, nub, delete)\n\n-- all primes\nprimes :: [Int]\nprimes = takeWhile (< 100) $ pr (2:[3,5..]) where\n pr (x:xs) = x:pr [ i | i <- xs, i `mod` x /= 0 ]\n\n-- Extended Euclidean Algorithm\nexgcd a 0 = (a, 1, 0)\nexgcd a b = (ret, y, x - a `div` b * y) where\n (ret, x, y) = exgcd b (a `mod` b)\n\n-- Multiplication Inverse\nminv n p = let (_, x, _) = exgcd n p in x\n\n-- 12 => [(2, 2), (3, 1)]\nfactors = ffold . sort . factors' where\n factors' 1 = []\n factors' x = let k = filter (\\i -> x `mod` i == 0) primes\n in k ++ factors' (foldl div x k)\n ffold [] = []\n ffold (x:[]) = [(x, 1)]\n ffold (x:xs) = ffold' x (ffold xs)\n ffold' x (p:prev) | fst p == x = (x, snd p + 1):prev\n | otherwise = (x, 1):p:prev\n\nrunone b c d | b <= d = d\n | (b - d) `mod` c == 0 = ((b - d) `div` c) * c + d\n | otherwise = (1 + ((b - d) `div` c)) * c + d\n\nrun a b c d | a == 1 = runone b c d\n | c == 1 = runone d a b\n | fi = -1\n | fe /= 0 = -1\n | otherwise = fo where\n fe = (b - d) `mod` (gcd a c)\n fa = map (\\x -> (x, b)) (factors a)\n fc = map (\\x -> (x, d)) (factors c)\n ff = sortBy cmp (fa ++ fc)\n fx [] b = [b]\n fx (d@((a', b'), c'):xs) e@((a, b), c) | a == a' = e:xs\n | otherwise = e:d:xs\n fg = sortBy cmp2 $ nub $ map fh (foldl fx [] ff)\n fh ((a, b), c) = (a^b, c `mod` (a^b))\n fi = any (\\((a, b), (a', b')) -> a == a' && b /= b') (zip fg (tail fg))\n fgf = map fst fg\n fgs = map snd fg\n fj = map (foldl (*) 1 . flip delete fgf) fgf\n fk = zipWith minv fj fgf\n fl a b c = a * b * c\n fm = foldl (*) 1 fgf\n fn = (sum (zipWith3 fl fgs fk fj)) `mod` fm\n fo = until (\\x -> b <= x && d <= x) (+ fm) fn\n cmp ((a, b), c) ((a', b'), c') | a == a' = compare b b'\n | otherwise = compare a a'\n cmp2 (a, b) (a', b') | a == a' = compare b b'\n | otherwise = compare a a'\n\nmain = do\n (map (read :: String -> Int) . words -> [a, b]) <- getLine\n (map (read :: String -> Int) . words -> [c, d]) <- getLine\n putStrLn $ show $ run a b c d\n"}, {"source_code": "{-# OPTIONS_GHC -O3 #-}\n{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}\n\nexgcd a 0 = (a, 1, 0)\nexgcd a b = (ret, y, x - a `div` b * y) where\n (ret, x, y) = exgcd b (a `mod` b)\n\npmod x y = ((x `mod` y) + y) `mod` y\n\n-- Bezout's Lemma -- min. ax+b s.t. ax+b = cy+d, x, y >= 0\nrun a b c d | r /= 0 = -1\n | otherwise = until (>= d) (+ (a * p)) (b + a * ((x * q) `pmod` p)) where\n p = c `div` g\n (q, r) = (d - b) `divMod` g\n (g, x, y) = exgcd a c\n\nmain = do\n (map (read :: String -> Int) . words -> [a, b]) <- getLine\n (map (read :: String -> Int) . words -> [c, d]) <- getLine\n putStrLn $ show $ run a b c d"}], "negative_code": [{"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List (find)\n\nmain = replicateM 2 (fmap read . words <$> getLine) >>= \\[[a,b],[c,d]]-> print $ maybe (-1) fst $ find (uncurry (==)) [(b + i * a, d + i * c)| i <- [0..a*c]]\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List (find)\n\nmain = replicateM 2 (fmap read . words <$> getLine) >>= \\[[a,b],[c,d]]-> print $ maybe (-1) fst $ find (uncurry (==)) [(b + i * a, d + i * c)| i <- [0..100000]]\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List (find)\n\nmain = replicateM 2 (fmap read . words <$> getLine) >>= \\[[a,b],[c,d]]-> print $ maybe (-1) fst $ find (uncurry (==)) [(a + i * b, c + i * d)| i <- [0..b*d]]\n"}, {"source_code": "{-# OPTIONS_GHC -O3 #-}\n{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}\n\nimport Control.Monad (forM_, forM)\n\nmain = do\n (map (read :: String -> Int) . words -> [a, b]) <- getLine\n (map (read :: String -> Int) . words -> [c, d]) <- getLine\n let x = take (2 * c) [b, b + a..]\n y = take (2 * a) [d, d + c..]\n z = filter (`elem` x) y\n if z == [] then\n putStrLn $ show $ -1\n else\n putStrLn $ show $ head z\n"}, {"source_code": "{-# OPTIONS_GHC -O3 #-}\n{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}\n\nexgcd a 0 = (a, 1, 0)\nexgcd a b = (ret, y, x - a `div` b * y) where\n (ret, x, y) = exgcd b (a `mod` b)\n\npmod x y = ((x `mod` y) + y) `mod` y\n\n-- Bezout's Lemma -- min. (ax+b) s.t. ax+b = cy+d\nrun a b c d | r /= 0 = -1\n | otherwise = b + a * ((x * q) `pmod` (c `div` g)) where\n (q, r) = (d - b) `divMod` g\n (g, x, _) = exgcd a c\n\nmain = do\n (map (read :: String -> Int) . words -> [a, b]) <- getLine\n (map (read :: String -> Int) . words -> [c, d]) <- getLine\n putStrLn $ show $ run a b c d"}, {"source_code": "{-# OPTIONS_GHC -O3 #-}\n{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}\n\nimport Data.List (sort, sortBy, nub, delete)\n\n-- all primes\nprimes :: [Int]\nprimes = takeWhile (< 100) $ pr (2:[3,5..]) where\n pr (x:xs) = x:pr [ i | i <- xs, i `mod` x /= 0 ]\n\n-- Extended Euclidean Algorithm\nexgcd a 0 = (a, 1, 0)\nexgcd a b = (ret, y, x - a `div` b * y) where\n (ret, x, y) = exgcd b (a `mod` b)\n\n-- Multiplication Inverse\nminv n p = let (_, x, _) = exgcd n p in x\n\n-- 12 => [(2, 2), (3, 1)]\nfactors = ffold . sort . factors' where\n factors' 1 = []\n factors' x = let k = filter (\\i -> x `mod` i == 0) primes\n in k ++ factors' (foldl div x k)\n ffold [] = []\n ffold (x:[]) = [(x, 1)]\n ffold (x:xs) = ffold' x (ffold xs)\n ffold' x (p:prev) | fst p == x = (x, snd p + 1):prev\n | otherwise = (x, 1):p:prev\n\nrunone b c d | b <= d = 1\n | (b - d) `mod` c == 0 = 1 + ((b - d) `div` c)\n | otherwise = 2 + ((b - d) `div` c)\n\nrun a b c d | a == 1 = runone b c d\n | c == 1 = runone d a b\n | fi = -1\n | fe /= 0 = -1\n | otherwise = fo where\n fe = (b - d) `mod` (gcd a c)\n fa = map (\\x -> (x, b)) (factors a)\n fc = map (\\x -> (x, d)) (factors c)\n ff = sortBy cmp (fa ++ fc)\n fx [] b = [b]\n fx (d@((a', b'), c'):xs) e@((a, b), c) | a == a' = e:xs\n | otherwise = e:d:xs\n fg = sortBy cmp2 $ nub $ map fh (foldl fx [] ff)\n fh ((a, b), c) = (a^b, c `mod` (a^b))\n fi = any (\\((a, b), (a', b')) -> a == a' && b /= b') (zip fg (tail fg))\n fgf = map fst fg\n fgs = map snd fg\n fj = map (foldl (*) 1 . flip delete fgf) fgf\n fk = zipWith minv fj fgf\n fl a b c = a * b * c\n fm = foldl (*) 1 fgf\n fn = (sum (zipWith3 fl fgs fk fj)) `mod` fm\n fo = until (\\x -> b <= x && d <= x) (+ fm) fn\n cmp ((a, b), c) ((a', b'), c') | a == a' = compare b b'\n | otherwise = compare a a'\n cmp2 (a, b) (a', b') | a == a' = compare b b'\n | otherwise = compare a a'\n\nmain = do\n (map (read :: String -> Int) . words -> [a, b]) <- getLine\n (map (read :: String -> Int) . words -> [c, d]) <- getLine\n putStrLn $ show $ run a b c d\n"}], "src_uid": "158cb12d45f4ee3368b94b2b622693e7"} {"source_code": "test str1 k = \n\tlet \n\t\tdx = length str\n\t\tstr = str1 ++ take k (repeat '?')\n\tin\n\t\tmaximum [ j | i <- [0 .. dx - 1], j <- [2,4..dx - i], check (take j (drop i str)) ]\n\ncheck str = all (\\a -> a) (map (\\(a, b) -> a == b || b == '?') (zip str (drop (length str `div` 2) str)))\n\nmain = do\n\tstr <- getLine\n\tk <- getLine\n\tputStrLn (show (test str (read k :: Int)))\n\t\n\n", "positive_code": [{"source_code": "{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}\n{-# LANGUAGE BangPatterns, ViewPatterns, TupleSections, OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST\nimport Data.Array.Base\nimport Data.Array.ST (runSTUArray, STArray)\nimport Data.Bits\nimport qualified Data.ByteString.Char8 as B\nimport Data.Char\nimport Data.Function\nimport Data.Int\nimport Data.List\nimport qualified Data.Map as M\nimport qualified Data.Set as S\nimport Data.STRef\nimport GHC.Arr (Array, Ix, unsafeIndex)\nbool :: a -> a -> Bool -> a\nbool t f b=if b then t else f\nreadInt :: B.ByteString -> Int\nreadInt bs = case B.readInt bs of Just (n,_) -> n\nrep, rev :: Monad m => Int -> (Int -> m ()) -> m ()\nrep !n f=go 0 where go !i=when(i>go(i+1)\nrev !n f=go(n-1)where go !i=when(i>=0)$f i>>go(i-1)\n{-# INLINE rep #-} \n{-# INLINE rev #-}\nmodifyArray :: (MArray a e m, Ix i) => a i e -> i -> (e -> e) -> m ()\nmodifyArray a i f=readArray a i>>=writeArray a i.f\n{-# INLINE modifyArray #-}\nunsafeModify :: (MArray a e m, Ix i) => a i e -> Int -> (e -> e) -> m ()\nunsafeModify a i f=unsafeRead a i>>=unsafeWrite a i.f\n{-# INLINE unsafeModify #-}\n\nmain = do\n [bs,_n] <- B.words <$> B.getContents\n print $ solve (readInt _n) bs\n\nsolve :: Int -> B.ByteString -> Int\nsolve !k bs = foldl' max (div k 2) [2 * f i j|i<-[0..n-1],j<-[i..n-1]]\n where\n !n = B.length bs\n subString i j bs = B.take (j-i+1) $ B.drop i bs\n f i j\n | B.length sub == B.length sub' = if sub == sub' then len else 0\n | B.length sub <= B.length sub' + k && sub' `B.isPrefixOf` sub = len\n | n <= k = div (n + k) 2\n | otherwise = 0\n where\n !sub = subString i j bs\n !sub' = B.take len $ B.drop (j+1) bs\n !len = j - i + 1\n\n"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n\nimport Control.Applicative\nimport Control.Arrow\nimport Control.Monad\nimport Data.Array.IO\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as C\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Functor\nimport Data.IORef\nimport Data.List\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Traversable\nimport Text.Printf (printf)\n\nimport qualified Data.Set as S\nimport Data.Char\n\n-- I/O\n\nreadInts :: C.ByteString -> [Int]\nreadInts = map fst . mapMaybe C.readInt . C.words\n\ngetInts :: IO [Int]\ngetInts = readInts <$> C.getLine\n\nreadNums :: Num a => C.ByteString -> [a]\nreadNums = map (fromIntegral . fst) . mapMaybe C.readInteger . C.words\n\ngetNums :: Num a => IO [a]\ngetNums = readNums <$> C.getLine\n\ncast :: (Integral a, Integral b) => a -> b\ncast = fromIntegral\n\n-----\n\nmain :: IO ()\nmain = do\n s <- getLine\n k <- readLn\n\n print $ foldl' max 0 [ i * 2\n | ss <- tails s\n , let tt = ss ++ replicate k '$', i <- [1..200]\n , let aa = take i tt\n bb = take i (drop i tt)\n , length bb == i && and (zipWith f aa bb)\n ]\n\nf '$' _ = True\nf _ '$' = True\nf a b = a == b\n"}, {"source_code": "import Data.List (tails, inits, isPrefixOf)\n\nmain = do\n s <- getLine\n k <- readLn\n let\n longest s = maximum $ 0 : (map ((*2) . length . fst) . filter can $ zip (inits s) (tails s))\n can (as, bs) = (isPrefixOf as bs || isPrefixOf bs as) && abs (length as - length bs) <= k\n longest' s = maximum $ 0 : (map length . filter isRepeat $ inits s)\n isRepeat s = a == b\n where\n (a, b) = splitAt (length s `div` 2) s\n result = if k > length s then (k + length s) `div` 2 * 2 else max (maximum . map longest $ tails s) (maximum . map longest' $ tails s)\n in putStrLn . show $ result\n"}], "negative_code": [{"source_code": "check str k = foldl (\\acc (a, b) -> acc && a == b) True (zip str (drop ((length str + k) `div` 2) str))\ntest str k = if (length str + k) `mod` 2 == 0 && check str k then length str + k else test (drop 1 str) k\nmain = do\n\tstr <- getLine\n\tk <- getLine\n\tputStrLn (show (test str (read k :: Int)))\n\t\n\n"}, {"source_code": "import Data.List (tails, inits, isPrefixOf)\n\nmain = do\n s <- getLine\n k <- readLn\n let\n longest :: String -> Int\n longest s = maximum $ 0 : (map ((*2) . length . fst) . filter can $ zip (inits s) (tails s))\n can (as, bs) = (isPrefixOf as bs || isPrefixOf bs as) && abs (length as - length bs) <= k\n in putStrLn . show $ maximum . map longest $ tails s\n"}, {"source_code": "import Data.List (tails, inits, isPrefixOf)\n\nmain = do\n s <- getLine\n k <- readLn\n let\n longest s = maximum $ 0 : (map ((*2) . length . fst) . filter can $ zip (inits s) (tails s))\n can (as, bs) = (isPrefixOf as bs || isPrefixOf bs as) && abs (length as - length bs) <= k\n result = if k > length s then (k + length s) `div` 2 * 2 else maximum . map longest $ tails s\n in putStrLn . show $ result\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}\n{-# LANGUAGE BangPatterns, ViewPatterns, TupleSections, OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST\nimport Data.Array.Base\nimport Data.Array.ST (runSTUArray, STArray)\nimport Data.Bits\nimport qualified Data.ByteString.Char8 as B\nimport Data.Char\nimport Data.Function\nimport Data.Int\nimport Data.List\nimport qualified Data.Map as M\nimport qualified Data.Set as S\nimport Data.STRef\nimport GHC.Arr (Array, Ix, unsafeIndex)\nbool :: a -> a -> Bool -> a\nbool t f b=if b then t else f\nreadInt :: B.ByteString -> Int\nreadInt bs = case B.readInt bs of Just (n,_) -> n\nrep, rev :: Monad m => Int -> (Int -> m ()) -> m ()\nrep !n f=go 0 where go !i=when(i>go(i+1)\nrev !n f=go(n-1)where go !i=when(i>=0)$f i>>go(i-1)\n{-# INLINE rep #-} \n{-# INLINE rev #-}\nmodifyArray :: (MArray a e m, Ix i) => a i e -> i -> (e -> e) -> m ()\nmodifyArray a i f=readArray a i>>=writeArray a i.f\n{-# INLINE modifyArray #-}\nunsafeModify :: (MArray a e m, Ix i) => a i e -> Int -> (e -> e) -> m ()\nunsafeModify a i f=unsafeRead a i>>=unsafeWrite a i.f\n{-# INLINE unsafeModify #-}\n\nmain = do\n [bs,_n] <- B.words <$> B.getContents\n print $ solve (readInt _n) bs\n\nsolve :: Int -> B.ByteString -> Int\nsolve !k bs = foldl' max 0 [2 * f i j|i<-[0..n-1],j<-[i..n-1]]\n where\n !n = B.length bs\n subString i j bs = B.take (j-i+1) $ B.drop i bs\n f i j\n | sub == sub' = len\n | sub' `B.isPrefixOf` sub && B.length sub <= B.length sub' + k = len\n | otherwise = 0\n where\n !sub = subString i j bs\n !sub' = B.take len $ B.drop (j+1) bs\n !len = j - i + 1\n\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}\n{-# LANGUAGE BangPatterns, ViewPatterns, TupleSections, OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST\nimport Data.Array.Base\nimport Data.Array.ST (runSTUArray, STArray)\nimport Data.Bits\nimport qualified Data.ByteString.Char8 as B\nimport Data.Char\nimport Data.Function\nimport Data.Int\nimport Data.List\nimport qualified Data.Map as M\nimport qualified Data.Set as S\nimport Data.STRef\nimport GHC.Arr (Array, Ix, unsafeIndex)\nbool :: a -> a -> Bool -> a\nbool t f b=if b then t else f\nreadInt :: B.ByteString -> Int\nreadInt bs = case B.readInt bs of Just (n,_) -> n\nrep, rev :: Monad m => Int -> (Int -> m ()) -> m ()\nrep !n f=go 0 where go !i=when(i>go(i+1)\nrev !n f=go(n-1)where go !i=when(i>=0)$f i>>go(i-1)\n{-# INLINE rep #-} \n{-# INLINE rev #-}\nmodifyArray :: (MArray a e m, Ix i) => a i e -> i -> (e -> e) -> m ()\nmodifyArray a i f=readArray a i>>=writeArray a i.f\n{-# INLINE modifyArray #-}\nunsafeModify :: (MArray a e m, Ix i) => a i e -> Int -> (e -> e) -> m ()\nunsafeModify a i f=unsafeRead a i>>=unsafeWrite a i.f\n{-# INLINE unsafeModify #-}\n\nmain = do\n [bs,_n] <- B.words <$> B.getContents\n print $ solve (readInt _n) bs\n\nsolve :: Int -> B.ByteString -> Int\nsolve !k bs = foldl' max 0 [2 * f i j|i<-[0..n-1],j<-[i..n-1]]\n where\n !n = B.length bs\n subString i j bs = B.take (j-i+1) $ B.drop i bs\n f i j\n | B.length sub == B.length sub' = if sub == sub' then len else 0\n | B.length sub <= B.length sub' + k && sub' `B.isPrefixOf` sub = len\n | otherwise = 0\n where\n !sub = subString i j bs\n !sub' = B.take len $ B.drop (j+1) bs\n !len = j - i + 1\n\n"}], "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab"} {"source_code": "findOne :: [Int] -> Int\nfindOne (a:b)\n | a == 1 = 0\n | otherwise = 1 + findOne b\n\nmain :: IO()\nmain = do\n str <- getContents\n let ind = findOne (map read (words str))\n (putStrLn . show) (abs ((mod ind 5) - 2) + abs ((div ind 5) - 2))\n", "positive_code": [{"source_code": "main=interact$show.f tbl.map read.words\ntbl = [4,3,2,3,4]++[3,2,1,2,3]++[2,1,0,1,2]++[3,2,1,2,3]++[4,3,2,3,4]\nf(x:xs)(0:ys)=f xs ys\nf(x:_)_=x"}, {"source_code": "import Data.Char\nimport Data.List\nimport Data.Maybe\n\nmain = do\n\tmat <- getContents\n\tprint $ solve $ fromJust $ findIndex (==\"1\") $ words mat\n\nsolve :: Int -> Int\nsolve pos = abs(x-2) + abs(y-2)\n\twhere\n\t\tx = pos `div` 5;\n\t\ty = pos `mod` 5;\n\n\n\n"}, {"source_code": "import Control.Monad\n\nimport Data.List (findIndex)\n\nfindy :: [[Int]] -> (Int, Int)\nfindy xs = head [(r, c) | (r, row) <- zip [1..] xs, (c, val) <- zip [1..] row, val == 1]\n\nsolve :: [[Int]] -> Int\nsolve grid =\n let (r, c) = findy grid\n in\n abs (r - 3) + abs (c - 3)\n\nmain = do\n grid <- replicateM 5 $ do\n fmap read <$> words <$> getLine\n print $ solve grid\n"}, {"source_code": "main = interact $ show . calc cost . words\ncost = map(\\x -> abs(div x 5 - 2) + abs(mod x 5 - 2))[0..]\ncalc _ [] = 0\ncalc (c:cs) (x:xs) = calc cs xs + if x == \"1\" then c else 0"}, {"source_code": "import Control.Applicative\n\nmain = do\n matrix <- map words . lines <$> getContents\n let pos = position matrix 0\n print $ abs (fst pos - 2) + abs (snd pos - 2)\n\nposition (x:xs) i\n | \"1\" `elem` x = pos' x 0\n | otherwise = position xs (i+1)\n where pos' (x:xs) j\n | x == \"1\" = (i, j)\n | otherwise = pos' xs (j+1)"}, {"source_code": "import Data.List\n\ninputNumMatrix r=sequence$replicate r(map read.words<$>getLine)\n\noneCoordinates :: [[Int]] -> (Int, Int)\noneCoordinates matrix@(r:rs) = case findIndex (==1) r of\n Just i -> (0, i)\n Nothing -> (fst nxt + 1, snd nxt)\n where nxt = oneCoordinates rs\n\ndistanceFromCenter :: (Int, Int) -> Int\ndistanceFromCenter (rowI, colI) = abs (rowI - 2) + abs (colI - 2)\n\nmain :: IO ()\nmain = (inputNumMatrix 5 :: IO [[Int]]) >>= \n \\matrix -> print $ distanceFromCenter (oneCoordinates matrix)"}, {"source_code": "module Main where\n\ndistance :: (Int, Int) -> (Int, Int) -> Int\ndistance (a,b) (c,d) = abs (a-c) + abs (b-d)\n\nfind :: Int -> [Int] -> Int\nfind k xs = find' 0 k xs\n where\n find' _ _ [] = -1\n find' k x (x':xs) = if x == x'\n then k\n else find' (k+1) x xs\n\nextractCoords :: [Int] -> (Int, Int)\nextractCoords = extractCoords' 0\n where\n extractCoords' n ((-1):xs) = extractCoords' (n+1) xs\n extractCoords' n (x:xs) = (n, x)\n \ngetCoords :: [[Int]] -> (Int, Int)\ngetCoords mat = extractCoords $ map (find 1) mat\n\nsolve :: [[Int]] -> Int\nsolve mat = distance (2,2) $ getCoords mat\n\nmain = do\n matrixStr <- getContents\n let matrixChr = map words $ lines matrixStr\n matrix = map (map (read :: String -> Int)) matrixChr\n print $ solve matrix\n"}, {"source_code": "import Control.Applicative\nimport Data.List \n\nmain= do\n\t s<- map read. words <$> getContents::IO [Int]\n\t let x = length $ takeWhile (==0) s\n\t let a= mod x 5\n\t let b= div x 5\n\t print $ abs (a-2) + abs (b-2)\n\n\t \n"}, {"source_code": "{-\nA. Beautiful Matrix\n====================\ntime limit per test: 2 seconds\nmemory limit per test: 256 megabytes\ninput: standard input\noutput: standard output\n\nYou've got a 5 × 5 matrix, consisting of 24 zeroes and a single number one. Let's index the matrix rows by numbers from 1 to 5 from top to bottom, let's index the matrix columns by numbers from 1 to 5 from left to right. In one move, you are allowed to apply one of the two following transformations to the matrix:\n\nSwap two neighboring matrix rows, that is, rows with indexes i and i + 1 for some integer i (1 ≤ i < 5).\nSwap two neighboring matrix columns, that is, columns with indexes j and j + 1 for some integer j (1 ≤ j < 5).\nYou think that a matrix looks beautiful, if the single number one of the matrix is located in its middle (in the cell that is on the intersection of the third row and the third column). Count the minimum number of moves needed to make the matrix beautiful.\n\nInput\n------\nThe input consists of five lines, each line contains five integers: the j-th integer in the i-th line of the input represents the element of the matrix that is located on the intersection of the i-th row and the j-th column. It is guaranteed that the matrix consists of 24 zeroes and a single number one.\n\nOutput\n------\nPrint a single integer — the minimum number of moves needed to make the matrix beautiful.\n\nSample test(s)\n---------------\ninput\n0 0 0 0 0\n0 0 0 0 1\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\noutput\n3\n\ninput\n0 0 0 0 0\n0 0 0 0 0\n0 1 0 0 0\n0 0 0 0 0\n0 0 0 0 0\noutput\n1\n\n-}\n\nimport Data.List (elemIndex, findIndex)\nimport Data.Maybe (Maybe, isJust)\n\nstepsToBeautifulMatrix :: [[Int]] -> Int\nstepsToBeautifulMatrix xxs = abs (i - 2) + abs (j - 2)\n where tmp = map (elemIndex 1) xxs\n Just i = findIndex isJust tmp\n Just j = tmp !! i\n\n\nmain = do \n input <- getContents\n let xxs = [map read (words line) | line <- lines input]\n print $ stepsToBeautifulMatrix xxs\n\n\n"}, {"source_code": "main = do\n t <- sequence $ replicate 5 getLine\n let u = map (map read . words) t\n let [n1, n2, n3, n4, n5] = u\n print $ dist u\ndist :: [[Int]] -> Int\ndist ((1:_):_) = 4\ndist ((_:1:_):_) = 3\ndist ((_:_:1:_):_) = 2\ndist ((_:_:_:1:_):_) = 3\ndist ((_:_:_:_:1:_):_) = 4\n\ndist (_:(1:_):_) = 3\ndist (_:(_:1:_):_) = 2\ndist (_:(_:_:1:_):_) = 1\ndist (_:(_:_:_:1:_):_) = 2\ndist (_:(_:_:_:_:1:_):_) = 3\n\ndist (_:_:(1:_):_) = 2\ndist (_:_:(_:1:_):_) = 1\ndist (_:_:(_:_:1:_):_) = 0\ndist (_:_:(_:_:_:1:_):_) = 1\ndist (_:_:(_:_:_:_:1:_):_) = 2\n\ndist (_:_:_:(1:_):_) = 3\ndist (_:_:_:(_:1:_):_) = 2\ndist (_:_:_:(_:_:1:_):_) = 1\ndist (_:_:_:(_:_:_:1:_):_) = 2\ndist (_:_:_:(_:_:_:_:1:_):_) = 3\n\ndist (_:_:_:_:(1:_):_) = 4\ndist (_:_:_:_:(_:1:_):_) = 3\ndist (_:_:_:_:(_:_:1:_):_) = 2\ndist (_:_:_:_:(_:_:_:1:_):_) = 3\ndist (_:_:_:_:(_:_:_:_:1:_):_) = 4"}, {"source_code": "import Control.Monad ( replicateM )\nmain :: IO ()\nmain = do\n zeroes <- takeWhile (\"1\" /=) . concatMap words <$> replicateM 5 getLine\n let pos = length zeroes\n let (row, col) = (pos `div` 5, pos `mod` 5)\n let ans = abs (2 - row) + abs (2 - col)\n print ans\n"}, {"source_code": "coeff = [4,3,2,3,4\n ,3,2,1,2,3\n ,2,1,0,1,2\n ,3,2,1,2,3\n ,4,3,2,3,4]\nmain = interact $ show . sum . zipWith (*) coeff . concat . map (map read . words) . lines"}, {"source_code": "import Control.Monad.State\nimport Control.Monad (when)\n\ncenterCoords = (2,2)\n\nmetric::(Int, Int) ->(Int, Int) -> Int\nmetric (a,b) (c,d) = sum $ abs <$> [a-c, b-d]\n\n\ngetXCoord::[Int]-> Int\ngetXCoord cc = if all (==0) cc then -1 else length cc - length (dropWhile (== 0) cc)\n\nreadCoords :: IO ()\nreadCoords = forM_ [0..4] $ \\y-> do\n l <- getLine\n let x = getXCoord $ read <$> words l\n Control.Monad.when (x /= - 1) $ print (metric centerCoords (x, y))\n\nsomeFunc :: IO()\nsomeFunc = readCoords\n \nmain :: IO ()\nmain = someFunc"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = interact $ show . solve . elemIndex \"1\" . words\n\nsolve :: Maybe Int -> Int\nsolve Nothing = 0\nsolve (Just n) = (abs ((mod n 5) - 2)) + (abs ((div n 5) - 2))\n"}, {"source_code": "import Data.List\nimport Data.Maybe\n\ndist :: (Int, Int) -> Int\ndist (a, b) =\n (abs (2 - a)) + (abs (2 - b))\n\nextract2 :: [Maybe Int] -> (Int, Int)\nextract2 xs = \n (fromJust a, fromJust(xs !! fromJust a)) where\n a = findIndex (isJust) xs\n\nextract :: [String] -> Maybe Int\nextract xs =\n findIndex (==\"1\") xs\n\nlib :: String -> String\nlib xs = (show . dist . extract2 . fmap (extract . words) . lines $ xs) ++ \"\\n\"\n\nmain :: IO ()\nmain = interact lib\n"}, {"source_code": "import Control.Monad\nimport Control.Applicative\nmain = replicateM 5 (getLine >>= return.words) >>= return.concat >>= putStrLn.show.fst.head.filter snd.zip distances.map (==\"1\")\n\ndistances = concat $ map (\\i -> map (i+) s) s\n where s = map abs [-2..2]\n"}, {"source_code": "--ghc 7.10\n\nimport Data.Maybe\nimport Data.Tuple\n\nmanhattanDistance :: (Num a) => (a,a) -> (a,a) -> a\nmanhattanDistance (x1,y1) (x2,y2) = (abs (x1-x2)) + (abs (y1-y2))\n\ntoMatrix :: Int -> Int -> [a] -> [((Int,Int),a)]\ntoMatrix n m a = zip indices a\n where indices = [(i,j) | i <- [0..(n-1)], j <- [0..(m-1)]]\n\nbeautifulDiff :: (Eq a) => Int -> Int -> a -> [a] -> Int\nbeautifulDiff n m x a = manhattanDistance mid idx\n where\n mid = (n `div` 2, m `div` 2)\n idx = fromJust $ lookup x (map swap matrix)\n matrix = toMatrix n m a\n\nmain = do\n contents <- getContents\n let a = map read . words $ contents :: [Int]\n print $ beautifulDiff 5 5 1 a"}, {"source_code": "import Data.List\nimport Control.Applicative\n\nmain = do\n x <- head . elemIndices 1 . tail . (0:) . map read . words <$> getContents\n print (abs (x `mod` 5 - 2) + abs (x `div` 5 - 2))\n\n"}, {"source_code": "import Data.Array\nimport Data.List\nimport Control.Applicative\nmain = do\n ar <- listArray ((1,1),(5,5)) . words <$> getContents :: IO (Array (Int,Int) [Char])\n let c = fst $ head $ filter (\\(i,e) -> e==\"1\") $ assocs ar\n print (m c (3,3))\nm (a,b) (c,d) = abs (a-c) + abs (b-d)"}, {"source_code": "distance :: (Int, Int) -> Int\ndistance (row, column) = abs (row - 2) + abs (column -2)\n\noneLoc :: String -> (Int, Int)\noneLoc = (`quotRem` 5) . oneDimPos \n where oneDimPos = length . takeWhile (==\"0\") . words\n\nsolve :: String -> String\nsolve = show . distance . oneLoc\n\nmain :: IO ()\nmain = interact solve"}, {"source_code": "import Data.Maybe\nimport Data.List\n\nparseLn = map read . words\n\nfindRow = fromJust . findIndex (elem 1)\n\ndist = abs . (-) 2\n\nsolve m = dist row + dist col\n where \n row = findRow m\n col = findRow $ transpose m\n\nmain = print . solve . map parseLn . lines =<< getContents\n"}, {"source_code": "import Data.List\nf xs = let Just n = elemIndex \"1\" xs\n [p,q] = [div n 5, mod n 5]\n in abs(p-2)+abs(q-2)\nmain = interact $ show.f.words\n"}, {"source_code": "import Control.Monad (replicateM)\nimport Data.List\n\nmain::IO()\nmain = do\n lst1 <- replicateM 5 getLine\n let lst = concatMap (filter (/=' ')) lst1\n let Just i = elemIndex '1' lst\n print $ abs (i `mod` 5 - 2) + abs (i `div` 5 - 2)"}, {"source_code": "module Main\n where\n\nmain = do\n c <- coord\n print $ mini c\n where\n mini (x, y) =\n abs (3 - x) + abs (3 - y)\n coord =\n coord' 0 0\n where\n coord' 0 y = do\n row <- getLine\n coord' (getX row) (y + 1)\n where\n getX row =\n case words row of\n \"1\":_ -> 1\n _:\"1\":_ -> 2\n _:_:\"1\":_ -> 3\n _:_:_:\"1\":_ -> 4\n _:_:_:_:\"1\":_ -> 5\n _ -> 0\n coord' x y =\n return (x, y)\n"}, {"source_code": "import Control.Monad\nimport Data.List\nimport Data.Maybe\n\nremoveSpace :: String -> String\nremoveSpace xs = [ x | x <- xs, not (x `elem` \" \") ]\n\nmain :: IO ()\nmain = do\n inputs <- replicateM 5 getLine :: IO [[Char]]\n let ninputs = map removeSpace inputs\n let res = map (\\x -> (elemIndex '1' x)) ninputs\n let resm = map (\\x -> (fromMaybe (-1) x)) res\n let conc = zip resm [0..(length res)]\n let [(x, y)] = filter (\\(a, _) -> a /= -1) conc\n print ((abs (2 - x)) + (abs (2 - y)))\n"}, {"source_code": "import Control.Applicative\n\nmain = do\n ls <- lines <$> getContents\n let vec = concat $ map words ls\n let (a,b) = head $ [ (i,j) | i <- [0..4], j <- [0..4], (vec !! (i*5+j)) == \"1\"]\n print $ abs (2-a) + (abs (2-b))\n"}, {"source_code": "import Control.Monad\nimport Data.List\nimport Data.Maybe\n\nmain :: IO ()\nmain = do\n a <- replicateM 5 $ fmap (elemIndex (1::Int) . map read . words) getLine\n let i = fromJust $ findIndex isJust a\n j = fromJust $ a!!i\n print $ abs (i - 2) + abs (j - 2)\n"}, {"source_code": "\nmain = do\n\tal<-getContents\n\tputStrLn $ show $ solve $ map read $ concat $map (words) $ lines al\n\nsolve m = abs(3-i)+abs(3-j )\n where i = 1+div (one-1) 5\n j = 1+mod (one-1) 5\n one =1+ length (takeWhile (==0) m)\n"}, {"source_code": "import Control.Applicative ((<$>))\nimport Data.List (elemIndex)\nimport Data.Maybe (fromJust)\n\nmain = lines <$> getContents >>= return . solve 0 0 . map words >>= print\n where solve a b (x:xs)\n | \"1\" `elem` x = (abs $ 2-a) + (abs $ 2 - (fromJust $ \"1\" `elemIndex` x))\n | otherwise = solve (a+1) b xs\n"}, {"source_code": "import Data.List (elemIndex)\nimport Data.Maybe (fromJust)\n\nmain = (sequence $ take 5 $ repeat getLine) >>= return . solve (0,0) . map words >>= print\n where solve (a,b) (x:xs)\n | \"1\" `elem` x = (abs $ 2-a) + (abs $ 2 - (fromJust $ \"1\" `elemIndex` x))\n | otherwise = solve (a+1, b) xs\n"}, {"source_code": "import Data.Char\nimport Data.List\n\nf n (x:xs) = case elemIndex '1' x of\n Just m -> sum $ map (abs . subtract 2) [m, n]\n Nothing -> f (n + 1) xs\n\nmain = interact $ show . f 0 . map (filter $ not . isSpace) . lines"}, {"source_code": "import Control.Monad\nimport Data.List\nimport Data.Maybe\n\n-- Snippet: readItems\nreadItems = do\n line <- getLine\n return $ map read $ words line\n\nmain = do\n a <- replicateM 5 $ do\n ai <- readItems\n return $ elemIndex 1 ai\n let i1 = fromJust (findIndex isJust a)\n let i2 = fromJust (a !! i1)\n putStrLn $ show $ abs (i1 - 2) + abs (i2 - 2)\n"}, {"source_code": "import Data.List ( elemIndex )\nimport Data.Maybe ( fromJust )\n\nmain :: IO ()\nmain = do\n vals <- sequence [getLine, getLine, getLine, getLine, getLine]\n print $ distance $ findOne (map words vals) 0\n\nfindOne :: Num t => [[[Char]]] -> t -> (t, Int)\nfindOne (x:xs) idx\n | elem \"1\" x = (idx, fromJust $ elemIndex \"1\" x)\n | otherwise = findOne xs (idx + 1)\n\ndistance :: Num a => (a, a) -> a\ndistance (x, y) = abs(x - 2) + abs(y - 2)"}, {"source_code": "main = do\n as <- fmap (map (map read . words) . lines) getContents\n \n let\n (i, j) = head [(i, j) | i <- [0..4], j <- [0..4], as!!i!!j == 1]\n \n print $ abs (2-i) + abs (2-j)"}, {"source_code": "main = interact $ show . solve . map read . words\n\nsolve xs = abs (2 - y) + abs(2 - x)\n where (k, _) : _ = filter (\\(_,b) -> b == 1) . zip [0..] $ xs\n (x, y) = (mod k 5, div k 5)\n"}, {"source_code": "import Data.List\nf x = abs(a - 2) + abs(b - 2) where\n\t Just g = findIndex (==\"1\") x\n\t [a, b] = [div g 5, mod g 5]\nmain = interact $ show . f . words"}, {"source_code": "import Data.List\n\n(|>) x f = f x\nmain = interact process\n\nprocess contents = let \n mat = contents\n |> lines\n |> map words\n |> map (map read) :: [[Integer]]\n in mat\n |> solve\n |> show\n \nsolve mat = solve' mat 0\n |> distance\n \ndistance (row, col) = abs (row - 2) + abs (col - 2)\n\nsolve' mat row = case findIndex (== 1) (mat !! row) of\n Nothing -> solve' mat (row + 1)\n (Just idx) -> (row, idx)"}, {"source_code": "import Control.Monad\nimport qualified Data.List as L\nimport qualified Data.Maybe as M\n\nmain :: IO ()\nmain = do\n l <- (getContents >>= return . map read . words)\n putStrLn $ show $ solve l\n\nsolve :: [Int] -> Int\nsolve = calcMinStep . findPosition\n\nfindPosition :: [Int] -> (Int,Int)\nfindPosition l = (x `div` 5, x `mod` 5)\n where\n x = M.fromMaybe 0 (L.findIndex (==1) l)\n \ncalcMinStep :: (Int,Int) -> Int\ncalcMinStep (x,y) = abs (x-2) + abs(y-2)\n \n"}, {"source_code": "{-# LANGUAGE BlockArguments #-}\n\nimport Control.Arrow\nimport Data.List\n\nmain = do { x <- solve 0; (show >>> putStrLn) x }\n\nsolve :: Int -> IO Int\nsolve a = do { s <- getLine\n ; let i = (words >>> map read >>> findIndex (==1)) s \n in case i of\n Nothing -> solve (a+1)\n Just v -> return $ (abs (2-v)) + (abs (2-a))\n }"}, {"source_code": "import Control.Applicative\nimport Data.List\n\nmain = do\n x <- head . elemIndices 1 . tail . (0:) . map read . words <$> getContents\n print (abs (x `mod` 5 - 2) + abs (x `div` 5 - 2))\n"}, {"source_code": "moves =\n [4, 3, 2, 3, 4]\n ++ [3, 2, 1, 2, 3]\n ++ [2, 1, 0, 1, 2]\n ++ [3, 2, 1, 2, 3]\n ++ [4, 3, 2, 3, 4]\n\nsolve :: (Eq a, Num a) => [p] -> [a] -> p\nsolve (x : xs) (0 : ys) = solve xs ys\nsolve (x : _ ) _ = x\n\nmain :: IO ()\nmain = interact $show . solve moves . map read . words\n"}, {"source_code": "import Data.List\nimport Data.Maybe\nmain = readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ show . solve. map (map read. words). take (5) . lines\nsolve :: [[Int]]->Int\nsolve xss = abs ((z`div`5)-2)+abs((z`mod`5)-2)\n where z= fromJust $ elemIndex 1 $ concat xss "}, {"source_code": "import Control.Applicative\nimport Data.List\n\nsolve :: Maybe Int -> Int\nsolve (Just i) = \n let r = quot i 5\n c = rem i 5\n in abs (r - 2) + abs (c - 2)\n\nmain = do\n l <- (elemIndex '1'.filter (\\x-> x `elem` \"01\")) <$> getContents\n print $ solve l\n"}, {"source_code": "{-#LANGUAGE OverloadedStrings#-}\nmodule Main where\n\nimport Data.Text (pack, unpack, splitOn, intercalate)\n\n--confirm 5 row and five columns\n-- find the position of the number\nmain :: IO ()\nmain = do\n strs <- getS\n let p = pos strs\n let ans = abs (2 - fst p) + abs (2 - snd p)\n putStrLn $ show ans\n\npos :: [String] -> (Int,Int)\npos s = (indexC s, maximum $ map indexR s)\n where\n indexC :: [String] -> Int\n indexC = go2 0\n go2 i [] = -1\n go2 i (c : cs)\n | '1' `elem` c = i\n | otherwise = go2 (i+1) cs\n indexR :: String -> Int\n indexR = go 0\n go i [] = -1\n go i (c : cs)\n | c == '1' = i\n | otherwise = go (i+1) cs\n\ngetS :: IO [String]\ngetS = sequence [getLine >>= \n (pure . unpack . intercalate \"\" \n . splitOn \" \" . pack) | _ <- [1..5] ]"}, {"source_code": "\nimport Data.List (findIndices)\n\nsolve :: String -> Int\nsolve = solve' . flip divMod 5 . head . findIndices (== \"1\") . words\n where\n solve' (i, j) = abs (i - 2) + abs (j - 2)\n\nmain :: IO ()\nmain = getContents >>= print . solve\n"}, {"source_code": "-- Codeforces 263A\n\n{-# OPTIONS_GHC -O2 #-}\n{-# OPTIONS_GHC -optc-O3 #-}\n{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Data.List\n\nmain :: IO ()\nmain = do\n mat <- replicateM 5 ((map read . words) <$> getLine) :: IO [[Int]]\n let Just row = findIndex (any (== 1)) mat\n Just column = findIndex (== 1) (mat !! row)\n print $ abs (row + 1 - 3) + abs (column + 1 - 3)\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Array (range)\n\ndim = range ((0,0),(4,4)) :: [(Int,Int)]\n\nparseInts = map read . words\n\nmain = do\n xs <- zip dim . concatMap parseInts <$> replicateM 5 getLine :: IO [((Int,Int),Int)]\n let ((i,j),_) = head $ filter ((/=0) . snd) xs\n print $ abs (i-2) + abs (j-2)"}, {"source_code": "import Data.Function\n\nmain = findOne >>= putStrLn . show . calculateMoves\n\nindexOf::[Char] -> Char -> Int\nindexOf str c = fix (\\fn len i res -> case () of\n _ | i >= len -> res\n | str !! i == c -> i\n | otherwise -> fn len (i + 2) res) (length str) 0 (-1) `div` 2\n \nfindOne::IO (Int, Int)\nfindOne = fix (\\fn lineIndex -> do\n line <- getLine\n let columnIndex = indexOf line '1'\n if columnIndex == (-1)\n then fn (lineIndex + 1)\n else return (lineIndex, columnIndex)) 0\n\ncalculateMoves::(Int, Int) -> Int\ncalculateMoves coord = calculateDifference (fst coord)\n + calculateDifference (snd coord)\n\ncalculateDifference::Int -> Int\ncalculateDifference pos = abs (pos - 2)\n"}, {"source_code": "import Text.Printf\nimport Data.List\nimport Data.Functor\nimport Control.Applicative\nimport Prelude\nimport Control.Monad\nimport Data.Maybe\nimport Data.Function\n\nreadInt :: String -> Int\nreadInt = read\n\nreadMatrix :: Int -> Int -> IO [[Int]]\nreadMatrix n m = forM [1 .. n] (\\ _ -> (map readInt . words) <$> getLine)\n\nfindPos :: [[Int]] -> Int -> Maybe (Int, Int)\nfindPos matrix number = (,) <$> iIndex <*> jIndex\n where \n jIndices = map (elemIndex number) matrix\n iIndex = findIndex isJust jIndices\n jIndex = msum jIndices\n\nmain :: IO ()\nmain = do\n matrix <- readMatrix 5 5\n let Just (i, j) = findPos matrix 1\n printf \"%d\" $ ((+) `on` (\\x -> abs (x - 2))) i j"}, {"source_code": "import Control.Monad\n\ngetI :: [Char] -> Int -> Int\ngetI [] i = -1\ngetI (a:as) i | a == '1' = (i + 1) `quot` 2\n | otherwise = getI as (i + 1)\n\nlocate :: [[Char]] -> Int -> (Int, Int)\nlocate [] j = (-1, -1)\nlocate (a:as) j | getI (a) (-1) == -1 = locate as (j + 1)\n | otherwise = (getI a (-1), j)\n \ndxdy a = abs (2 - fst a) + abs(2 - snd a) \nsolve a = putStrLn $ show (dxdy (locate (a) (0)))\nmain = replicateM 5 getLine >>= solve\n"}, {"source_code": "import Control.Monad\nimport Data.Array\nimport Data.Char\nimport Data.Maybe\nimport Data.List\nimport qualified Data.ByteString.Char8 as B\ngetList :: Read a => IO [a]\ngetList = fmap (map (read . B.unpack) . B.words) B.getLine\ngetIntList :: IO [Int]\ngetIntList = fmap (unfoldr (B.readInt . B.dropWhile isSpace)) B.getLine\n\nsolve :: [[Int]] -> Int\nsolve arr = abs (a - 2) + abs (b - 2)\n where a = fromJust $ findIndex (elem 1) arr\n arr0 = fromJust $ find (elem 1) arr\n b = fromJust $ elemIndex 1 arr0\n\nmain :: IO ()\nmain = replicateM 5 getIntList >>= putStrLn . show . solve\n\n"}, {"source_code": "import Data.List\nimport Data.Maybe\n\ngetMatrix :: IO Int\ngetMatrix = do\n mat <- mapM (\\_ -> getLine) [1..5]\n let ind = zip mat [1..]\n (m, row) = fromJust $ find (\\(m, _) -> '1' `elem` m) ind\n col = 1 + (fromJust $ findIndex (\\a -> \"1\" == a) $ words m)\n return $ abs (col - 3) + abs (row - 3)\n\nmain :: IO ()\nmain = print =<< getMatrix\n"}, {"source_code": "import Data.List\nimport Data.Char\nimport Control.Applicative\nimport Data.Array\n\nprocess a b | ab = \"1\"\n | otherwise = \"0\"\n\nmain::IO ()\nmain=do\n a<-getContents\n let a1=concatMap (map read) $ map words $ lines a::[Int]\n let (b,c)=fst$ head $ filter (\\z-> snd z ==1) $ zip ([(i,j)|i<-[1..5],j<-[1..5]]) a1\n print $ (abs (3-b) )+(abs (3-c))\n"}, {"source_code": "import Control.Arrow (second)\nimport Data.List (elemIndex)\nimport Data.Maybe (fromJust, isJust)\n\nmain :: IO ()\nmain = getContents >>= print . solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> Int\nsolve = distance (2, 2) . getIndex 1\n\ngetIndex :: Eq a => a -> [[a]] -> (Int, Int)\ngetIndex n = second fromJust . head . filter (isJust . snd) . zip [0..] . map (elemIndex n)\n\ndistance :: Num a => (a, a) -> (a, a) -> a\ndistance (xa, ya) (xb, yb) = abs (xa - xb) + abs (ya - yb)\n"}, {"source_code": "import Prelude hiding (readList, showList)\nimport Control.Monad\nimport Control.Applicative\nimport Data.List\n\nreadList :: Read a => IO [a]\nreadList = fmap (fmap read . words) getLine\n\nreadList' :: Read a => a -> IO [a]\nreadList' _ = readList\n\nreadInt :: IO Int\nreadInt = head <$> readList' (undefined::Int)\n\nshowList :: Show a => [a] -> IO ()\nshowList = putStrLn . unwords . map show\n\nskipLine :: IO ()\nskipLine = void $ getLine\n\ncount :: (a -> Bool) -> [a] -> Int\ncount f = length . filter f\n\ndivUp :: Integral a => a -> a -> a\ndivUp x y \n | x `mod` y /= 0 = x `div` y + 1\n | otherwise = x `div` y\n\nmain :: IO ()\nmain = do\n ls <- replicateM 5 $ readList' (undefined :: Int)\n let ls' = transpose ls\n row = sum $ zipWith (*) (fmap sum ls ) [1..]\n col = sum $ zipWith (*) (fmap sum ls') [1..]\n putStrLn $ show $ abs (3-row) + abs (3-col)\n"}, {"source_code": "import Data.List\n\ncol :: String -> Maybe Int\ncol line = (elemIndex \"1\" $ words line)\n\nrow :: [String] -> Int -> Int\nrow (line:lines) rowNum = case inRow of \n Just colNum -> (abs $ rowNum - 2)\n + (abs $ colNum - 2)\n Nothing -> row lines $ rowNum + 1\n where inRow = col line\n\nmain = do\n interact $ show . abs . (flip row) 0 . lines\n"}, {"source_code": "import Data.List\nmain = print . solve . parse =<< getContents\nparse = (`divMod` 5) . head . elemIndices \"1\" . words\nsolve (x,y) = abs(x-2) + abs(y-2)"}, {"source_code": "-- import Debug.Trace\n-- import System.IO.Unsafe\n-- import Text.Printf\nimport System.IO\nimport Control.Monad\nimport Data.List\n\nglwr = fmap (map read . words) getLine\n\nmain = do\n hSetBuffering stdout NoBuffering\n solve\n\nsolve :: IO ()\nsolve = do\n m <- forM [1..5] $ const glwr\n\n print $ beautifulMatrix m\n\nbeautifulMatrix :: [[Int]] -> Int\nbeautifulMatrix m\n = [ abs (x-2) + abs (y-2)\n | y <- [0..4]\n , x <- [0..4]\n , m!!y!!x == 1\n ] !! 0\n"}, {"source_code": "main=interact$show.f tbl.map read.words\ntbl = map (\\x ->abs((div x 5)-2)+abs((mod x 5)-2)) [0..24]\nf(x:xs)(0:ys)=f xs ys\nf(x:_)_=x"}, {"source_code": "main=interact$show.f g.map read.words\ng=map(\\x->abs(div x 5-2)+abs(mod x 5-2))[0..]\nf(x:xs)(0:ys)=f xs ys\nf(x:_)_=x"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/263/A\n\nimport Control.Monad\nimport Data.Char\nimport Data.Maybe\nimport Data.List\n\n-- see https://stackoverflow.com/questions/29186541/why-is-this-haskell-program-so-much-slower-than-an-equivalent-python-one/29186898\nimport qualified Data.ByteString.Char8 as B\n\ngetIntList :: IO [Int]\ngetIntList = fmap (unfoldr (B.readInt . B.dropWhile isSpace)) B.getLine\n-- getIntList = fmap (map read . words) getLine\n\nsolve :: [[Int]] -> Int\nsolve arr = abs (a - 2) + abs (b - 2)\n where a = fromJust $ findIndex (elem 1) arr\n arr0 = fromJust $ find (elem 1) arr\n b = fromJust $ elemIndex 1 arr0\n\nmain = replicateM 5 getIntList >>= putStrLn . show . solve\n"}, {"source_code": "module Main where\nimport Data.List\nimport Control.Applicative\nimport Data.Maybe\nfindRow :: [String] -> Int\nfindRow matrix = fromMaybe (-1) $ findIndex (\\r -> '1' `elem` r) matrix\n\nfindColumn :: String -> Int\nfindColumn row = fromMaybe (-1) $ elemIndex '1' row\n\nfindOne :: [String] -> (Int,Int)\nfindOne matrix = let rowIndex = findRow matrix in (rowIndex, findColumn $ matrix!!rowIndex)\n\nmain = do\n matrix <- mapM (\\_ -> filter (/=' ') <$> getLine) [1..5]\n let (row,col) = findOne matrix in print (abs (2 - row) + abs (2 - col))\n"}, {"source_code": "import Data.Maybe\nimport Data.List\ncalcDist (x,y) = (abs (x - 2), (abs (y - 2)))\nsolve n = let (x,y) = calcDist $ divMod n 5 in x + y\nmain = interact $ show . solve . fromJust . elemIndex \"1\" . words"}], "negative_code": [{"source_code": "import Control.Monad\nimport Data.List\nimport Data.Maybe\n\nremoveSpace :: String -> String\nremoveSpace xs = [ x | x <- xs, not (x `elem` \" \") ]\n\nmain :: IO ()\nmain = do\n inputs <- replicateM 5 getLine :: IO [[Char]]\n let ninputs = map removeSpace inputs\n let res = map (\\x -> (elemIndex '1' x)) ninputs\n let resm = map (\\x -> (fromMaybe (-1) x)) res\n let conc = zip resm [0..(length res)]\n let [(x, y)] = filter (\\(a, _) -> a /= -1) conc\n print ((abs (2 - x)) + (abs 2 - y))\n"}, {"source_code": "main = do\n as <- fmap (map (map read . words) . lines) getContents\n \n let\n (i, j) = head [(i, j) | i <- [0..4], j <- [0..4], as!!i!!j == 1]\n \n print $ max (abs (2-i)) (abs (2-j))"}, {"source_code": "main = interact $ show . solve . map read . words\n\nsolve xs = abs (2 - y) + abs(2 - y)\n where (k, _) : _ = filter (\\(_,b) -> b == 1) . zip [0..] $ xs\n (x, y) = (mod k 5, div k 5)\n"}, {"source_code": "import Data.List\nimport Data.Char\nimport Control.Applicative\nimport Data.Array\n\nprocess a b | ab = \"1\"\n | otherwise = \"0\"\n\nmain::IO ()\nmain=do\n getLine\n a<-getContents\n let a1=concatMap (map read) $ map words $ lines a::[Int]\n let (b,c)=fst$ head $ filter (\\z-> snd z ==1) $ zip ([(i,j)|i<-[1..5],j<-[1..5]]) a1\n print $ (abs (3-b) )+(abs (3-c))\n"}], "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9"} {"source_code": "main :: IO ()\nmain = getContents >>= print . solve . map read . words\n\nsolve :: [Integer] -> Integer\nsolve (_:m:as) = snd $ foldl f (0, 1) as\n where f (x, y) a | x + a <= m = (x + a, y)\n | otherwise = (a, y + 1)\nsolve _ = undefined\n", "positive_code": [{"source_code": "\nmain :: IO ()\nmain = do\n _:m:_ <- fmap (map read . words) getLine\n ls <- fmap (map read . words) getLine\n print $ rush m ls 0\n\nrush :: Int -> [Int] -> Int -> Int\nrush _ [] n = n\nrush m ls n = rush m (go ls 0) (n + 1)\n where go [] _ = []\n go l@(x:r) a\n | a + x > m = l\n | otherwise = go r (a + x)\n\n"}, {"source_code": "main :: IO ()\nmain = do\n\tinput <- getContents\n\tls <- return $ lines input\n\tnm <- return $ words $ ls!!0\n\tl2 <- return $ words $ ls!!1\n\tputStr $ solve (read $ nm!!0) (read $ nm!!1) (map read l2)\n\nsolve :: Int -> Int -> [Int] -> String\nsolve n m as = show $ f m as where \n\tf :: Int -> [Int] -> Int\n\tf r [] = if r < m then 1 else 0\n\tf 0 ls = 1 + (f m ls)\n\tf r all@(l:ls) = if l <= r then f (r-l) ls else 1+(f m all)\n"}, {"source_code": "parseInput input = (n, m, xs) where\n ls = lines input\n [n, m] = map read $ words $ head ls :: [Int]\n xs = map read $ words $ last ls :: [Int]\n\nsolve _ [] buses _ = buses\nsolve m xs buses seats | head xs + seats <= m = solve m (tail xs) buses (seats + head xs)\n | otherwise = solve m (tail xs) (buses + 1) (head xs)\n\nmain = do\n input <- getContents\n let (n, m, xs) = parseInput input\n print $ solve m xs 1 0\n"}, {"source_code": "{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Arrow\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport Text.Printf\n\nreadInt = ( readLn :: IO Int )\ngetInts = map ( read :: String -> Int ) . words <$> getLine\n\nwhich a b f = if f then a else b\nmp [ a, b ] = ( a, b )\n\nmain = do\n\t[ n, m ] <- getInts\n\tas <- getInts\n\n\tlet\n\t\tsolve _ [] = 0\n\t\tsolve s (a:as)\n\t\t\t| s + a <= m = solve ( s + a ) as\n\t\t\t| otherwise = 1 + solve a as\n\n\tprint $ 1 + solve 0 as\n"}, {"source_code": "main :: IO()\nmain = print . solve . map read . tail . words =<< getContents\n\nsolve :: [Int] -> Int\nsolve (m:a) = solve' m a\n where solve' :: Int -> [Int] -> Int\n solve' _ [] = 0\n solve' i (a:x) | a+i > m = 1 + solve' 0 (a:x)\n | otherwise = solve' (a+i) x\n"}, {"source_code": "import Control.Monad(liftM)\n\nreadi = read :: String -> Int\nreadL = ((map readi) . words) `liftM` getLine\n\npc _ x []\n | x /= 0 = 1\n | otherwise = 0\npc m acc (x:xs)\n | acc + x > m = 1 + pc m 0 (x:xs)\n | otherwise = pc m (acc + x) xs\n\nmain = do\n [n, m] <- readL\n a <- readL\n putStrLn $ show $ pc m 0 a\n --(sum a + m - 1) `div` m\n"}, {"source_code": "main = do\n [n,m] <- fmap (map read . words) getLine\n a <- fmap (map read . words) getLine\n print $ busCount m a\n\nbusCount :: Integer -> [Integer] -> Integer\nbusCount _ [] = 0\nbusCount m a = 1 + busCount m (drop (length taken) a)\n where variants = map (\\n -> sum (take n a)) [1..length a]\n taken = takeWhile (<= m) variants\n "}, {"source_code": "answ [] _ _ r = r\nansw (x:xs) k c r \n | x + c <= k = answ xs k (c + x) r\n | otherwise = answ xs k x (r + 1)\n\nmain :: IO()\nmain = do\n [_, k] <- (map read . words) `fmap` getLine\n xs <- (map read . words) `fmap` getLine\n print $ answ xs k 0 1"}, {"source_code": "solve :: Int -> [Int] -> Int\nsolve m [_] = 1\nsolve m (g1:g2:gs)\n | g1 + g2 <= m = solve m (g1+g2:gs)\n | otherwise = 1 + solve m (g2:gs)\n\nmain :: IO ()\nmain = do\n [_, m] <- fmap (map read . words) getLine :: IO [Int]\n gs <- fmap (map read . words) getLine :: IO [Int]\n print $ solve m gs\n"}, {"source_code": "-- @betaveros :: vim:set fdm=marker:\n{-# LANGUAGE LambdaCase, NPlusKPatterns, TupleSections #-}\n{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-missing-signatures #-}\n-- import ALL the things! {{{\n-- hiding clauses are to allow Data.Foldable's generalizations\nimport Prelude hiding (mapM, mapM_, sequence, sequence_, foldl, foldl1, foldr, foldr1, and, or, any, all, sum, product, concat, concatMap, maximum, minimum, elem, notElem)\nimport Control.Applicative\nimport Control.Arrow\nimport Control.Exception\nimport Control.Monad hiding (mapM, mapM_, forM, forM_, sequence, sequence_, msum)\nimport Control.Monad.ST\n\nimport qualified Data.ByteString.Char8 as BS\nimport Data.ByteString.Char8 (ByteString)\nimport Data.Bits\nimport Data.Char\nimport Data.Either\nimport Data.Foldable\nimport Data.Function\nimport Data.IORef\nimport Data.List hiding (foldl, foldl', foldl1, foldl1', foldr, foldr1, concat, concatMap, and, or, any, all, sum, product, maximum, minimum, elem, notElem, find)\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.STRef\nimport Data.String\nimport Data.Traversable\nimport Data.Tuple\n\nimport qualified Data.Map as Map\nimport Data.Map (Map)\nimport qualified Data.Set as Set\nimport Data.Set (Set)\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq, (<|), (|>), (><))\n\nimport Debug.Trace\nimport Text.Printf\nimport System.IO\n-- }}}\n-- silly utilities {{{\n-- stolen from lens:\na & f = f a\na <&> f = fmap f a\ninfixl 1 &, <&>\n\nfi :: (Integral a, Num b) => a -> b\nfi = fromIntegral\nglength :: (Num b) => [a] -> b\nglength = genericLength\n\nreadInt = read :: String -> Int\nreadInteger = read :: String -> Integer\n-- (!?) :: (Ord k) => Map k v -> k -> Maybe v\n-- (!?) = flip Map.lookup\nhistogram :: (Ord a, Num b) => [a] -> Map a b\nhistogram = Map.fromListWith (+) . map (,1)\n-- }}}\n-- input and output {{{\nbsGetLine :: IO ByteString\nbsGetLine = fst . BS.spanEnd isSpace <$> BS.getLine\n\ninputInt = (read <$> getLine) :: IO Int\ninputInteger = (read <$> getLine) :: IO Integer\ninputDouble = (read <$> getLine) :: IO Double\n\ninputRow :: (Read a) => IO [a]\ninputRow = map read . words <$> getLine\ninputInts = inputRow :: IO [Int]\ninputIntegers = inputRow :: IO [Integer]\ninputDoubles = inputRow :: IO [Double]\n\nssUnwords :: [ShowS] -> ShowS\nssUnwords [] = id\nssUnwords (x:xs) = x . (' ':) . ssUnwords xs\n\nssUnlines :: [ShowS] -> ShowS\nssUnlines [] = id\nssUnlines (x:xs) = x . ('\\n':) . ssUnlines xs\n\nshowMany :: (Show a) => [a] -> String\nshowMany xs = ssUnwords (map shows xs) \"\"\nshowMatrix :: (Show a) => [[a]] -> String\nshowMatrix xs = ssUnlines (map (ssUnwords . map shows) xs) \"\"\n\nprintMany :: (Show a) => [a] -> IO ()\nprintMany xs = putStrLn (showMany xs)\nprintMatrix :: (Show a) => [[a]] -> IO ()\nprintMatrix xs = putStr (showMatrix xs)\n-- }}}\n\nbuses :: Int -> [Int] -> Int\nbuses m = go 0\n\twhere\n\t\tgo 0 [] = 0\n\t\tgo _ [] = 1\n\t\tgo r (y:ys)\n\t\t\t| r + y <= m = go (r + y) ys\n\t\t\t| otherwise = 1 + go y ys\n\nmain :: IO ()\nmain = do\n\t[_, m] <- inputInts\n\txs <- inputInts\n\tprint $ buses m xs\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\nprocess n _ c [] =n + if c>0 then 1 else 0\nprocess n m c (s:ss) | c+sm = process (n+1) m s ss\n\t\nmain= do\n\t[n,m]<- map read.words <$> getLine:: IO [Int]\t\n\ts<-map read.words <$> getLine:: IO [Int]\t\n\tprint $ process 0 m 0 s\n\t \n\t \n\t "}, {"source_code": "main = do\n let i = fmap (map read . words) getLine :: IO [Int]\n [_, m] <- i\n a <- i\n print $ gao a m m\n\ngao :: [Int] -> Int -> Int -> Int\ngao [] _ _ = 1\ngao a@(x:xs) rem n\n | x <= rem = gao xs (rem - x) n\n | otherwise = gao a n n + 1\n"}], "negative_code": [{"source_code": "import Control.Monad(liftM)\n\nreadi = read :: String -> Int\nreadL = ((map readi) . words) `liftM` getLine\n\nmain = do\n [n, m] <- readL\n a <- readL\n putStrLn $ show $ (sum a + m - 1) `div` m\n"}, {"source_code": "main :: IO()\nmain = do\n [_, k] <- (map read . words) `fmap` getLine\n xs <- (map read . words) `fmap` getLine\n print $ ((sum xs) `quot` k) + if (((sum xs) `rem` k) > 0) then 1 else 0"}, {"source_code": "main :: IO ()\nmain = do\n [n, m] <- fmap (map read . words) getLine :: IO [Int]\n as <- fmap (map read . words) getLine :: IO [Int]\n print $ toInteger $ ceiling (fromIntegral (sum as) / fromIntegral m)\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\nprocess n _ _ [] =n\nprocess n m c (s:ss) | c+sm = process (n+1) m s ss\n\t\nmain= do\n\t[n,m]<- map read.words <$> getLine:: IO [Int]\t\n\ts<-map read.words <$> getLine:: IO [Int]\t\n\tprint $ process 0 m 0 s\n\t \n\t \n\t "}, {"source_code": "main = do\n let i = fmap (map read . words) getLine :: IO [Int]\n [_, m] <- i\n a <- i\n print $ gao a m m\n\ngao :: [Int] -> Int -> Int -> Int\ngao [_] _ _ = 1\ngao a@(x:xs) rem n\n | x <= rem = gao xs (rem - x) n\n | otherwise = gao a n n + 1\n"}, {"source_code": "main = do\n let i = fmap (map read . words) getLine :: IO [Int]\n [n, m] <- i\n a <- i\n print $ gao a n n\n\ngao :: [Int] -> Int -> Int -> Int\ngao [_] _ _ = 1\ngao a@(x:xs) rem n\n | x <= rem = gao xs (rem - x) n\n | otherwise = gao a n n + 1\n"}], "src_uid": "5c73d6e3770dff034d210cdd572ccf0f"} {"source_code": "import Control.Monad\n\ndata Vector = Vector Double Double\ndata Point = Point Double Double\n\neps = 1e-3\ninstance Eq Point where\n\t(Point x1 y1) == (Point x2 y2) = (abs (x1 - x2)) < eps && (abs (y1 - y2)) < eps\n\ngetPoint = do\n\tl <- getLine\n\tlet [x, y] = map read (words l)\n\treturn (Point x y)\n\nvector (Point x1 y1) (Point x2 y2) = Vector (x2 - x1) (y2 - y1)\nnormal (Vector x y) = Vector (-y) x \ncross (Vector x1 y1) (Vector x2 y2) = x1*y2 - x2*y1\nadd' (Point x1 y1) (Vector x2 y2) = Point (x1 + x2) (y1 + y2)\ndiv' (Vector x y) f = Vector (x / f) (y / f) \nmul' (Vector x y) f = Vector (x * f) (y * f)\nsub' (Point x1 y1) (Point x2 y2) = Point (x1 - x2) (y1 - y2)\n\nrotate (Point x y) a = Point (x * cos a - y * sin a) (x * sin a + y * cos a)\n\nmatch n ps =\n\tlet p = head ps\n\tin length (filter (\\p -> p `elem` ps) [rotate p (2*pi*i / n) | i <- [0..n-1]]) == length ps\n\ncenter p1 p2 p3 =\n\tlet \n\t\tan = normal (vector p1 p2)\n\t\tb = vector p2 p3\n\t\tbn = normal b\n\t\tc = vector p1 p3\n\t\ts = (an `cross` c) / (bn `cross` an)\n\tin\n\t\tp2 `add'` (b `div'` 2) `add'` ((bn `div'` 2) `mul'` s)\n\nmain = do\n\t[p1, p2, p3] <- replicateM 3 getPoint\n\n\tlet\n\t\tp0 = center p1 p2 p3\n\t\t-- ps = map (\\p -> p `sub'` p0) [p1, p2, p3]\n\t\tps = map (sub' p0) [p1, p2, p3]\n\t\tn = head (filter (\\n -> match n ps) [3..100])\n\t\trr = x*x + y*y where Point x y = ps !! 0\n\n\tprint $ n*rr*sin(2*pi/n) / 2\n\n", "positive_code": [{"source_code": "dist ( [x0,y0], [x1,y1] ) = sqrt ( ( x1 - x0 )^2 + ( y1 - y0 )^2 )\nangle (a,b,c) = acos ( ( c^2 + b^2 - a^2 ) / 2 / b / c )\nisInteger x = abs ( x - fromIntegral ( round x ) ) <= 1e-5\n\nsolve [p0,p1,p2] =\n\tlet\n\t\t[a,b,c] = map dist [ (p0,p1), (p1,p2), (p2,p0) ]\n\t\t[x,y,z] = map angle [ (a,b,c), (b,c,a), (c,a,b) ]\n\t\tr = a / 2 / sin x\n\t\tok a = all isInteger $ map (/a) [x,y,z]\n\t\tq = 2 * ( head $ filter ok $ map (pi/) [3..100] )\n\tin\n\t\tr^2 * sin q * pi / q\n\nmain = interact $ show . solve . map ( map read . words ) . lines\n"}, {"source_code": "\ndistance ( [x0,y0], [x1,y1] ) = sqrt ( ( x1 - x0 )^2 + ( y1 - y0 )^2 )\nangle (a,b,c) = acos ( ( c^2 + b^2 - a^2 ) / 2 / b / c )\nisInteger x = abs ( x - fromIntegral ( round x ) ) <= 1e-5\n\narea [p0,p1,p2] = let\n\t\t[a,b,c] = map distance [(p0,p1),(p1,p2),(p2,p0)]\n [x,y,z] = map angle [(a,b,c),(b,c,a),(c,a,b)]\n radius = a / 2 / sin x\n ok a = all isInteger $ map (/a) [x,y,z]\n\t\tq = 2 * ( head $ filter ok $ map (pi/) [3..100] )\n in\n radius^2 * sin q * pi / q\n\nmain = interact $ show . area . map (map read . words) . lines\n"}, {"source_code": "main = interact $ solve . map (map read . words) . lines\n where\n getCandidates = candidates . getAllCos . getSides\n getSides = map culcLen . combinations\n culcLen ([a, b], [c, d]) = sqrt ((c - a) ^ 2 + (d - b) ^ 2)\n combinations xs = zip xs $ getShift xs\n getShift (x:xs) = xs ++ [x]\n getAllCos [a, b, c] = [getCos [a, b, c], getCos [c, a, b], getCos [b, c, a]]\n getCos [a, b, c] = (a ^ 2 + b ^ 2 - c ^ 2) / (2 * a * b)\n candidates l = [fst ncoss | ncoss <- ncosss, allExist l (snd ncoss)]\n allExist xs coss = all (`exist` coss) xs\n exist x = any $ (\\x y -> abs (x - y) < 1e-6) x\n ncosss = [(n, [cos (pi / n * i) | i <- [1 .. n - 2]]) | n <- [3 .. 100]]\n getR x = last (getSides x) / sqrt (2 - 2 * getCosTheta x)\n getCosTheta = (+ (-1)) . (* 2) . (^ 2) . getCos . getSides\n area r n = r * r * sin (2 * pi / n) / 2 * n\n getAreas x = (map $ area $ getR x) (getCandidates x)\n getAns = show . minimum . getAreas\n solve s = (\\(x, y) -> x ++ take 7 y) $ span (/= '.') (getAns s)\n"}, {"source_code": "module Main where\n\ndist (x0, y0) (x1, y1) = sqrt((x1 - x0) ^ 2 + (y1 - y0) ^ 2)\n\nedge (ap, bp, cp) = (dist bp cp, dist cp ap, dist bp ap)\nangle (a, b, c) = (deAngle a b c, deAngle b c a, deAngle c a b)\n\nhelen (a, b, c) = sqrt(s * (s - a) * (s - b) * (s - c))\n where s = (a + b + c) / 2\n\nraidus (a, b, c) = a * b * c / 4 / (helen (a, b, c))\n\ndeAngle a b c = acos $ (b ^ 2 + c ^ 2 - a ^ 2) / (2 * b * c)\n\neps :: Double\neps = 0.01\n-- fgcd :: Double -> Double -> Double\nfgcd a b\n | abs a <= eps || abs b <= eps = a + b\n | a >= b = fgcd (a - b * (fromInteger (floor (a / b)))) b\n | otherwise = fgcd b a\n\nfgcd3 (x, y, z) = fgcd (fgcd x y) z\n\nployN edges = pi / (fgcd3 $ angle edges)\n\nareaN r n = n / 2 * r ^ 2 * sin(2 * pi / n)\n\nsln pt = areaN r n\n where e = edge pt\n n = ployN e\n r = raidus e\n\ngetPoint = do\n l <- getLine\n let xs = words l\n ys = map (\\w->read w::Double) xs\n return (ys!!0, ys!! 1)\nmain = do\n ap <- getPoint\n bp <- getPoint\n cp <- getPoint\n print $ sln (ap, bp, cp)\n"}, {"source_code": "readPoint :: IO (Double, Double)\nreadPoint = fmap ( (\\ [x,y] -> (x,y)) . map read . words) getLine\n\ndistance (x1,y1) (x2,y2) = sqrt ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))\n\nisInteger x = abs (x - fromIntegral(round x)) <= 1e-5\n\nmain = do\n p1 <- readPoint\n p2 <- readPoint\n p3 <- readPoint\n let a = distance p1 p2\n b = distance p2 p3\n c = distance p1 p3\n s = (a+b+c)/2\n r = a*b*c / 4 / sqrt(s*(s-a)*(s-b)*(s-c))\n alpha = acos ((b*b+c*c-a*a)/2/b/c)\n beta = acos ((a*a+c*c-b*b)/2/a/c)\n gamma = acos ((b*b+a*a-c*c)/2/b/a)\n good n = all isInteger . map (/(pi/fromIntegral n)) $ [alpha, beta, gamma]\n (n:_) = filter good [3..100]\n area = fromIntegral n * r*r/2 * sin(2*pi/fromIntegral n)\n \n print area"}, {"source_code": "import Data.List.Split(splitWhen)\nimport Data.Char\nimport Data.List\nimport Text.Printf\n\ntype Point = (Double, Double)\n\n-- Return sqr of 3 edges, sorted\ncomputeEdges:: Point->Point->Point->[Double]\ncomputeEdges (x1, y1) (x2, y2) (x3, y3)\n = sort [sqrE1, sqrE2, sqrE3]\n where sqrE1 = (x1 - x2) ^ 2 + (y1 - y2) ^2\n sqrE2 = (x1 - x3) ^ 2 + (y1 - y3) ^2\n sqrE3 = (x3 - x2) ^ 2 + (y3 - y2) ^2\n \n-- Get m th point of a n edges regular polygon. diameter = 1\ngetMthPoint:: Int->Int->Point\ngetMthPoint n m =\n (cos a, sin a)\n where a = 2*pi/(fromIntegral n)*(fromIntegral m)\n\n-- Get all possible edges (e1^2, e2^2, e3^2) from\n-- 3 points in a n-edges regular polygon. diameter = 1\nallPossibleEdges::Int->[[Double]]\nallPossibleEdges n = [computeEdges (1.0, 0.0) (getMthPoint n m2) (getMthPoint n m3) | m2<-[1..n `div` 2], m3<-[m2+1..n-1]]\n\n-- If the 2 given triangles are similer return the ratio (^2), or Nothing\ngetSimilarRatioTriangle:: [Double]->[Double]->Maybe Double\ngetSimilarRatioTriangle es1 es2 = \n if maximum rs - minimum rs < 1e-3\n then Just $ head rs\n else Nothing\n where rs = zipWith (/) es1 es2\n \n-- The given triangle\nes1 = computeEdges (0, 0) (1, 1) (0, 1)\n\ncomputeArea:: Int -> Double\ncomputeArea n = nd * 0.5 * (sin $ 2* pi / nd)\n where nd = fromIntegral n\n \ngetSimilarRatio:: [Double]->Int->Maybe Double\ngetSimilarRatio es1 n =\n if null result\n then Nothing\n else head result\n where result = dropWhile (==Nothing) $ map (getSimilarRatioTriangle es1) (allPossibleEdges n)\n \ngetArea:: [Double]->Int->Maybe Double\ngetArea es1 n =\n if ratio == Nothing\n then Nothing\n else (\\(Just x)->Just $ x * area) ratio\n where area = computeArea n\n ratio = getSimilarRatio es1 n\n \nmain = do\n c <- getContents\n let i = splitWhen isSpace c\n let j = map read i ::[Double]\n let es1 = computeEdges (j!!0, j!!1) (j!!2, j!!3) (j!!4, j!!5)\n let result = head $ dropWhile (==Nothing) $ map (getArea es1) [3..100]\n (\\(Just x)->printf \"%.8f\" $ x) result\n"}, {"source_code": "import Data.List.Split(splitWhen)\nimport Data.Char\nimport Data.List\nimport Text.Printf\nimport Control.Monad(liftM)\n\ntype Point = (Double, Double)\n\n-- Return sqr of 3 edges, sorted\ncomputeEdges:: Point->Point->Point->[Double]\ncomputeEdges (x1, y1) (x2, y2) (x3, y3)\n = sort [sqrE1, sqrE2, sqrE3]\n where sqrE1 = (x1 - x2) ^ 2 + (y1 - y2) ^2\n sqrE2 = (x1 - x3) ^ 2 + (y1 - y3) ^2\n sqrE3 = (x3 - x2) ^ 2 + (y3 - y2) ^2\n \n-- Get m th point of a n edges regular polygon. diameter = 1\ngetMthPoint:: Int->Int->Point\ngetMthPoint n m =\n (cos a, sin a)\n where a = 2*pi/(fromIntegral n)*(fromIntegral m)\n\n-- Get all possible edges (e1^2, e2^2, e3^2) from\n-- 3 points in a n-edges regular polygon. diameter = 1\nallPossibleEdges::Int->[[Double]]\nallPossibleEdges n = [computeEdges (1.0, 0.0) (getMthPoint n m2) (getMthPoint n m3) | m2<-[1..n `div` 2], m3<-[m2+1..n-1]]\n\n-- If the 2 given triangles are similer return the ratio (^2), or Nothing\ngetSimilarRatioTriangle:: [Double]->[Double]->Maybe Double\ngetSimilarRatioTriangle es1 es2 = \n if maximum rs - minimum rs < minimum rs * 1e-6\n then Just $ head rs\n else Nothing\n where rs = zipWith (/) es1 es2\n \ncomputeArea:: Int -> Double\ncomputeArea n = nd * 0.5 * (sin $ 2* pi / nd)\n where nd = fromIntegral n\n \ngetSimilarRatio:: [Double]->Int->Maybe Double\ngetSimilarRatio es1 n =\n if null result\n then Nothing\n else head result\n where result = dropWhile (==Nothing) $ map (getSimilarRatioTriangle es1) (allPossibleEdges n)\n \ngetArea:: [Double]->Int->Maybe Double\ngetArea es1 n = liftM (*area) ratio\n where area = computeArea n\n ratio = getSimilarRatio es1 n\n \nmain = do\n c <- getContents\n let i = splitWhen isSpace c\n let j = map read i ::[Double]\n let es1 = computeEdges (j!!0, j!!1) (j!!2, j!!3) (j!!4, j!!5)\n let result = head $ dropWhile (==Nothing) $ map (getArea es1) [3..100]\n (\\(Just x)->printf \"%.8f\" $ x) result\n"}, {"source_code": "import Control.Monad\n\ndata Vector = Vector Double Double\ndata Point = Point Double Double\n\neps = 1e-3\ninstance Eq Point where\n\t(Point x1 y1) == (Point x2 y2) = (abs (x1 - x2)) < eps && (abs (y1 - y2)) < eps\n\ngetPoint = do\n\tl <- getLine\n\tlet [x, y] = map read (words l)\n\treturn (Point x y)\n\nvector (Point x1 y1) (Point x2 y2) = Vector (x2 - x1) (y2 - y1)\nnormal (Vector x y) = Vector (-y) x \ncross (Vector x1 y1) (Vector x2 y2) = x1*y2 - x2*y1\nadd' (Point x1 y1) (Vector x2 y2) = Point (x1 + x2) (y1 + y2)\ndiv' (Vector x y) f = Vector (x / f) (y / f) \nmul' (Vector x y) f = Vector (x * f) (y * f)\nsub' (Point x1 y1) (Point x2 y2) = Point (x1 - x2) (y1 - y2)\n\nrotate (Point x y) a = Point (x * cos a - y * sin a) (x * sin a + y * cos a)\n\nmatch n ps =\n\tlet p = head ps\n\tin length (filter (\\p -> p `elem` ps) [rotate p (2*pi*i / n) | i <- [0..n-1]]) == length ps\n\ncenter p1 p2 p3 =\n\tlet \n\t\tan = normal (vector p1 p2)\n\t\tb = vector p2 p3\n\t\tbn = normal b\n\t\tc = vector p1 p3\n\t\ts = (an `cross` c) / (bn `cross` an)\n\tin\n\t\tp2 `add'` (b `div'` 2) `add'` ((bn `div'` 2) `mul'` s)\n\nmain = do\n\t[p1, p2, p3] <- replicateM 3 getPoint\n\n\tlet\n\t\tp0 = center p1 p2 p3\n\t\t-- ps = map (\\p -> p `sub'` p0) [p1, p2, p3]\n\t\tps = map (sub' p0) [p1, p2, p3]\n\t\tn = head (filter (\\n -> match n ps) [3..100])\n\t\trr = x*x + y*y where Point x y = ps !! 0\n\n\tprint $ n*rr*sin(2*pi/n) / 2\n\n\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Ord\nimport Text.Printf\n\nepsilon :: Double\n-- epsilon = 1e-9\nepsilon = 1e-4\n\ncross :: [[Double]] -> Double\ncross [[y1, x1], [y2, x2], [y3, x3]] = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)\n\ndistance :: [Double] -> [Double] -> Double\ndistance [y1, x1] [y2, x2] = sqrt $ (x2 - x1) ^ 2 + (y2 - y1) ^ 2\n\ncap :: Double -> Double\ncap = min 1 . max (negate 1)\n\nunitVector :: [Double] -> [Double] -> [Double]\nunitVector p1@[y1, x1] p2@[y2, x2] = cap . (/ d) <$> [x2 - x1, y2 - y1]\n where\n d = distance p1 p2\n\nradian p@[y, x] = if y >= 0 then theta else 2 * pi - theta\n where\n theta = acos x\n \ncenterOfCircle :: [[Double]] -> [Double]\ncenterOfCircle ps@[[y1, x1], [y2, x2], [y3, x3]]\n | abs (cross ps) < epsilon = error $ \"All the points are on a line.\"\n | otherwise = [b / a, d / c]\n where\n a = 2 * (y1 * (x3 - x2) + y2 * (x1 - x3) + y3 * (x2 - x1))\n b = (y1 ^ 2 + x1 ^ 2) * (x3 - x2)\n + (y2 ^ 2 + x2 ^ 2) * (x1 - x3)\n + (y3 ^ 2 + x3 ^ 2) * (x2 - x1)\n c = 2 * (x1 * (y3 - y2) + x2 * (y1 - y3) + x3 * (y2 - y1))\n d = (y1 ^ 2 + x1 ^ 2) * (y3 - y2)\n + (y2 ^ 2 + x2 ^ 2) * (y1 - y3)\n + (y3 ^ 2 + x3 ^ 2) * (y2 - y1)\n\nsolve :: (Double, Int) -> [Double] -> Double\nsolve = fmap (((2 * pi) /) . fst) . foldl' search\n where\n search (theta, n) x = (theta / fromIntegral (until check succ n), 1)\n where\n check i\n | x `fmod` t < epsilon = True\n | otherwise = False\n where\n t = theta / fromIntegral i\n v `fmod` d\n | r < epsilon || abs (1 - r) < epsilon = 0\n | otherwise = r\n where\n (_, r) = properFraction $ (v / d)\n\ngetDouble :: IO [Double]\ngetDouble = fmap read . words <$> getLine\n\nmain = do\n -- let ps = [[0, 0], [1, 1], [0, 1]]\n -- let ps = [[0, 1], [sqrt 3 / 2, 1 / 2], [0, -1]]\n -- let ps = [[0, 1], [sqrt 2 / 2, sqrt 2 / 2], [0, -1]]\n -- let ps = [[0, 1], [1 / 2, sqrt 3 / 2], [0, -1]]\n ps <- replicateM 3 getDouble\n let c = centerOfCircle ps\n let [theta1, theta2, theta3] = sort $ radian <$> (unitVector c <$> ps)\n let xs = [theta2 - theta1, theta3 - theta2, 2 * pi - (theta3 - theta1)]\n let n = solve (2 * pi, 1) xs\n let r = distance c (head ps)\n printf \"%.7f\" $ (r ^ 2 * sin (2 * pi / n) / 2) * n"}, {"source_code": "module Main (main) where\n\nimport Text.Printf\n\ndata Point = Point Double Double\ndata Line = Line Double Double Double\n\ninstance Show Point where\n show (Point x y) = \"{\" ++ show x ++ \", \" ++ show y ++ \"}\"\n\ninstance Show Line where\n show (Line a b c) = \"{(\" ++ show a ++ \")*x + (\" ++ show b ++ \")*y + (\" ++ show c ++ \") = 0}\"\n\n-- прямая по двум точкам в виде Ax+By+C=0\ncreateLine (Point x1 y1) (Point x2 y2) = (Line a b c) where\n a = y1-y2\n b = x2-x1\n c = x1*y2 - x2*y1\n\n-- серединный перпендикуляр по двум точкам в виде Ax+By+C=0\nmidLine (Point x1 y1) (Point x2 y2) = (Line (-b) a (b*x0 - a*y0)) where\n a = y1-y2\n b = x2-x1\n x0 = (x2+x1)/2\n y0 = (y2+y1)/2\n\n-- угол между двумя прямыми\nangleLines (Line a1 b1 c1) (Line a2 b2 c2) = atan2 (a1*b2 - a2*b1) (a1*a2 + b1*b2)\n\n-- угол между тремя точками (пересекающимися прямыми в первой точке)\nanglePoints pCenter p1 p2 = angleLines (createLine pCenter p1) (createLine pCenter p2)\n\n-- пересечение двух прямых\ninterLines (Line a1 b1 c1) (Line a2 b2 c2) = (Point (dx/dxy) (dy/dxy)) where\n dx = b1*c2 - b2*c1\n dy = c1*a2 - c2*a1\n dxy = a1*b2 - a2*b1\n\n-- расстояние между точками\ndist (Point x1 y1) (Point x2 y2) = sqrt (dx*dx + dy*dy) where\n dx = x1-x2\n dy = y1-y2\n\nmain = do\n instr <- getContents\n let [p1, p2, p3] = map readPoint $ take 3 $ lines instr\n let center = interLines (midLine p1 p2) (midLine p2 p3)\n printf \"%.8f\\n\" $ squarePoli \n (dist p1 center) \n (findMinPoli (anglePoints center p1 p2) (anglePoints center p2 p3)) where\n \n -- площать многоугольника через радиус и количество углов\n squarePoli :: Double -> Int -> Double\n squarePoli r n = n2 * r*r * (sin (pi/n2)) where\n n2 = (fromIntegral n)/2\n \n -- сколько углов в минимальном многоугольнике с такими внутренними углами?\n findMinPoli :: Double -> Double -> Int\n findMinPoli a b = findMinPoli' 3 where\n \n findMinPoli' :: Int -> Int\n findMinPoli' n | n>=100 = 100\n findMinPoli' n = if (nearlyInt (a*n')) && (nearlyInt (b*n'))\n then n\n else findMinPoli' (n+1) where\n n' = (fromIntegral n)/(pi*2)\n \n nearlyInt :: Double -> Bool\n nearlyInt d = (abs (d - (fromIntegral (round d)))) < 0.00001\n\n-- input\nreadDouble :: String -> Double\nreadDouble = read\n\nreadPoint :: String -> Point\nreadPoint ss = (Point (coords!!0) (coords!!1)) where\n coords = map readDouble $ words ss\n"}, {"source_code": "\nimport Control.Monad\nimport Debug.Trace\n\nmyTrace :: (Show a) => a -> a\nmyTrace x = traceShow x x\n\ndata Point = Point Double Double\n\tderiving (Eq, Show)\n\nvmul scalar (Point x y) = Point (scalar * x) (scalar * y)\nvadd (Point x1 y1) (Point x2 y2) = Point (x1 + x2) (y1 + y2)\nvsub (Point x1 y1) (Point x2 y2) = Point (x1 - x2) (y1 - y2)\nvdot (Point x1 y1) (Point x2 y2) = x1 * x2 + y1 * y2\nvabs p = distanceBetween p (Point 0 0)\n\ndistanceBetween (Point x1 y1) (Point x2 y2) = sqrt $ sqr (x2 - x1) + sqr (y2 - y1)\nsqr x = x * x\n\n\ngetPoint = do\n\txy <- (liftM words) getLine\n\treturn $ Point (parse (xy !! 0)) (parse (xy !! 1))\n\twhere\n\t\tparse :: String -> Double\n\t\tparse = read\n\ngetInput :: IO (Point, Point, Point)\ngetInput = do\n\ta1 <- getPoint\n\ta2 <- getPoint\n\ta3 <- getPoint\n\treturn (a1, a2, a3)\n\ntriangleArea a1 a2 a3 = sqrt $ p * (p - a) * (p - b) * (p - c)\n\twhere\n\t\ta = distanceBetween a2 a3\n\t\tb = distanceBetween a1 a3\n\t\tc = distanceBetween a1 a2\n\t\tp = (a + b + c) / 2\n\ncenterOf points@(a1, a2, a3) = (aa `vmul` a1) `vadd` (ab `vmul` a2) `vadd` (ac `vmul` a3)\n\twhere\n\t\taa = (sqr $ distanceBetween a2 a3) / (8 * sqr area) * vdot (a1 `vsub` a2) (a1 `vsub` a3)\n\t\tab = (sqr $ distanceBetween a1 a3) / (8 * sqr area) * vdot (a2 `vsub` a1) (a2 `vsub` a3)\n\t\tac = (sqr $ distanceBetween a1 a2) / (8 * sqr area) * vdot (a3 `vsub` a1) (a3 `vsub` a2)\n\t\tarea = triangleArea a1 a2 a3\n\nareaOfRegularPolygon :: Int -> Double -> Double\nareaOfRegularPolygon n r = (fromIntegral n / 2) * sqr r * sin (2 * pi / fromIntegral n)\n\ngetNumberOfSides :: Double -> (Point, Point, Point) -> Int\ngetNumberOfSides r points@(a1, a2, a3) = n\n\twhere\n\t\t(p1, p2, p3, n) = head $ filter almostIntegerTriple omega\n\t\talmostIntegerTriple (a, b, c, _) = almostInteger a && almostInteger b && almostInteger c\n\t\talmostInteger x = abs x < 0.001\n\t\tcenter = centerOf points\n\t\talpha = normalize $ acos $ (a `vdot` b) / (vabs a * vabs b)\n\t\tbeta = normalize $ acos $ (b `vdot` c) / (vabs b * vabs c)\n\t\tgamma = normalize $ acos $ (c `vdot` a) / (vabs c * vabs a)\n\t\ta = a1 `vsub` center\n\t\tb = a2 `vsub` center\n\t\tc = a3 `vsub` center\n\t\tomega = [(sin (fromIntegral i * alpha / 2),\n\t\t\tsin (fromIntegral i * beta / 2),\n\t\t\tsin (fromIntegral i * gamma / 2), i) | i <- [3..]]\n\t\tnormalize x\n\t\t\t| x < 0 = x + 2 * pi\n\t\t\t| otherwise = x\n\nmain = do\n\tpoints@(a1, a2, a3) <- getInput\n\tlet center = centerOf points\n\tlet r = distanceBetween a1 center\n\tlet n = getNumberOfSides r points\n\tprint $ areaOfRegularPolygon n r\n\n\n"}, {"source_code": "import Data.Function(on)\nimport Data.List(sort)\nimport Data.Maybe(fromMaybe)\nimport Control.Monad(replicateM)\n\neps = 1e-5\ndist (x1, y1) (x2, y2) = sqrt (on (+) (^2) (x2 - x1) (y2 - y1))\nrad a b c = a * b * c / (4 * sqrt(p * (p - a) * (p - b) * (p - c)))\n where p = (a + b + c) / 2\n\nangle ll lr lc = acos ((ll ^ 2 + lr ^ 2 - lc ^ 2) / (2 * ll * lr))\n\ncheckAngle :: [Double] -> Integer -> Bool\ncheckAngle angles n = isValidAngles angles (2 * pi / (fromIntegral n))\n\nisValidAngles :: [Double] -> Double -> Bool\nisValidAngles angles part = and (map (\\a -> isClose (a / part)) angles)\n\nisClose v = abs (fromIntegral (round v) - v) < eps\n\ngetN :: Double -> Double -> Double -> Maybe Integer\ngetN a b c = case (take 1 $ filter (checkAngle [a1', a2', a3']) [3..100]) of\n [] -> Nothing\n n:_ -> Just n\n where r = rad a b c\n a1 = angle r r a \n a2 = angle r r b\n a3 = angle r r c\n a1':a2':_ = sort [a1,a2,a3]\n a3' = 2 * pi - a1' - a2'\n\ngetSq p1 p2 p3 = sq n r\n where sq n r' = (fromIntegral n) * r' * r' * sin (2 * pi / (fromIntegral n)) / 2\n a = dist p1 p2\n b = dist p2 p3\n c = dist p3 p1\n r = rad a b c\n n = fromMaybe 0 $ getN a b c\n\nparseP :: String -> (Double, Double)\nparseP str = (x,y)\n where [x, y] = map read (words str)\n\nmain :: IO()\nmain = do\n p1l <- getLine\n p2l <- getLine\n p3l <- getLine\n print $ getSq (parseP p1l) (parseP p2l) (parseP p3l)\n\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -XNoMonomorphismRestriction #-}\n{-# LANGUAGE BangPatterns #-}\n{-(c) gorlum0 [at] gmail.com-}\nimport qualified Data.ByteString.Char8 as BS\nimport Data.List\nimport Data.Array\nimport Data.Char\nimport Control.Monad\nimport Debug.Trace (trace)\nimport Data.Maybe (fromJust)\nimport Text.Printf (printf)\n\ndist [x1,y1] [x2,y2] = sqrt $ (x1-x2)**2 + (y1-y2)**2\n\nisInteger x = abs (x - (fI . round) x) <= 1e-5\n\narea [p1, p2, p3] = fI n * r*r/2 * sin(2*pi/fI n)\n where\n a = dist p1 p2\n b = dist p2 p3\n c = dist p1 p3\n s = (a+b+c) / 2\n r = a*b*c / 4 / sqrt(s*(s-a)*(s-b)*(s-c))\n alpha = acos $ 1 - 0.5*a**2/r**2\n beta = acos $ 1 - 0.5*b**2/r**2\n gamma = acos $ 1 - 0.5*c**2/r**2\n fits n = all isInteger $ map (/(2*pi/fI n)) [alpha, beta, gamma]\n (n:_) = filter fits [3..100]\n\nmain = do\n ls <- lines `fmap` getContents\n let xss = map (map read . words) ls :: [[Double]]\n forM_ (splitEvery 3 xss) $\n print . area\n\nreadNum = fst . fromJust . BS.readInteger\nfI = fromIntegral\n--- debug = flip trace\ntraceShow = trace . show\ndebug = flip traceShow\ninfixr 1 `debug2`\ndebug2 x msg = flip trace x (printf \"%s: %s\" msg $ show x)\n\ninfixr 1 ?\nTrue ? x = const x\nFalse ? _ = id\n\nsplitEvery _ [] = []\nsplitEvery n xs = ys : splitEvery n xs'\n where (ys, xs') = splitAt (fI n) xs\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -XNoMonomorphismRestriction #-}\n{-# LANGUAGE BangPatterns #-}\n{-(c) gorlum0 [at] gmail.com-}\nimport qualified Data.ByteString.Char8 as BS\nimport Data.List\nimport Data.Array\nimport Data.Char\nimport Control.Monad\nimport Debug.Trace (trace)\nimport Data.Maybe (fromJust)\nimport Text.Printf (printf)\n\ndist [x1,y1] [x2,y2] = sqrt $ (x1-x2)**2 + (y1-y2)**2\n\nisInteger x = abs (x - (fI . round) x) <= 1e-5\n\narea [p1, p2, p3] = fI n * r*r/2 * sin(2*pi/fI n)\n where\n a = dist p1 p2\n b = dist p2 p3\n c = dist p1 p3\n s = (a+b+c) / 2\n r = a*b*c / 4 / sqrt(s*(s-a)*(s-b)*(s-c))\n alpha = acos $ 1 - 0.5*a**2/r**2 --`debug2` \"alpha\"\n beta = acos $ 1 - 0.5*b**2/r**2 --`debug2` \"beta\"\n gamma = acos $ 1 - 0.5*c**2/r**2 --`debug2` \"gamma\"\n fits n = all isInteger $ map (/(2*pi/fI n)) [alpha, beta, gamma]\n (n:_) = filter fits [3..]\n\nmain = do\n ls <- lines `fmap` getContents\n let xss = map (map read . words) ls :: [[Double]]\n forM_ (splitEvery 3 xss) $\n print . area\n\nreadNum = fst . fromJust . BS.readInteger\nfI = fromIntegral\n--- debug = flip trace\ntraceShow = trace . show\ndebug = flip traceShow\ninfixr 1 `debug2`\ndebug2 x msg = flip trace x (printf \"%s: %s\" msg $ show x)\n\ninfixr 1 ?\nTrue ? x = const x\nFalse ? _ = id\n\nsplitEvery _ [] = []\nsplitEvery n xs = ys : splitEvery n xs'\n where (ys, xs') = splitAt (fI n) xs\n"}, {"source_code": "import Data.List (sort)\nimport Text.Printf (printf)\nimport Control.Monad (replicateM)\n\nnewtype Point2 a = Point2 { getPoint2 :: (a, a) } deriving (Eq, Show)\nnewtype Vector2 a = Vector2 { getVector2 :: (a, a) } deriving (Eq, Show)\ntype Line2 a = (Point2 a, Vector2 a) \ntype LineEquation2 a = (a, a, a)\n\nx :: Point2 a -> a\nx = fst . getPoint2\ny :: Point2 a -> a\ny = snd . getPoint2\n\nxv :: Vector2 a -> a\nxv = fst . getVector2\nyv :: Vector2 a -> a\nyv = snd . getVector2\n\ncomputeEq2 :: (Num a) => Line2 a -> LineEquation2 a\ncomputeEq2 (o, dir) = (a, b, c)\n where a = yv dir\n b = - (xv dir)\n c = -a * (x o) - b * (y o)\n\nperpendicularLine2 :: (Num a) => Line2 a -> Line2 a\nperpendicularLine2 (o, dir) = (o, perpendicularDir)\n where perpendicularDir = Vector2 $ (- (yv dir), xv dir)\n\nisParallel2 :: (Eq a, Num a) => Line2 a -> Line2 a -> Bool\nisParallel2 (_, dir) (_, dir') = collinear dir dir'\n\ncollinear :: (Eq a, Num a) => Vector2 a -> Vector2 a -> Bool\nu `collinear` v = u <^> v == 0\n\n(<^>) :: (Num a) => Vector2 a -> Vector2 a -> a\nu <^> v = xv u * yv v - yv u * xv v\n\nintersectLines2 :: (Eq a, Fractional a) => Line2 a -> Line2 a -> Maybe (Point2 a)\nintersectLines2 l1 l2\n | isParallel2 l1 l2 = Nothing\n | otherwise = Just $ Point2 ((c2 * b1 - c1 * b2) / det, (a2 * c1 - a1 * c2) / det)\n where (a1, b1, c1) = computeEq2 l1\n (a2, b2, c2) = computeEq2 l2\n det = a1 * b2 - a2 * b1\n\ncalcCircleCenter :: (Eq a, Fractional a) => (Point2 a) -> (Point2 a) -> (Point2 a) -> Maybe (Point2 a)\ncalcCircleCenter p1 p2 p3 = intersectLines2 pline1 pline2\n where v1' = Vector2 (x p2 - x p1, y p2 - y p1)\n v2' = Vector2 (x p3 - x p2, y p3 - y p2)\n p1' = Point2 ((x p1 + x p2) / 2, (y p1 + y p2) / 2)\n p2' = Point2 ((x p2 + x p3) / 2, (y p2 + y p3) / 2)\n line1 = (p1', v1')\n line2 = (p2', v2')\n pline1 = perpendicularLine2 line1\n pline2 = perpendicularLine2 line2\n\ncalcAngle :: (RealFloat a) => (Point2 a) -> (Point2 a) -> (Point2 a) -> Maybe a\ncalcAngle c lp rp | ll > eps && lr > eps = Just $ acos $ (ll + lr - lc) / (2 * sqrt (ll * lr)) \n | otherwise = Nothing\n where eps = 0.0001\n ll = (x lp - x c) ^ 2 + (y lp - y c) ^ 2\n lr = (x rp - x c) ^ 2 + (y rp - y c) ^ 2\n lc = (x lp - x rp) ^ 2 + (y lp - y rp) ^ 2\n\n\n\ndetDivisor :: (RealFloat a, Integral b) => a -> a -> Maybe b\ndetDivisor a1 a2 = if (length res > 0) then Just (head res) else Nothing\n where a3 = 2 * pi - a1 - a2 --the third angle\n as = [a1, a2, a3]\n res = map snd $ take 1 $ filter (\\(v,_) -> isValid v as) [(2 * pi / (fromIntegral n), n) | n <- [3..100]]\n\nisValid :: (RealFloat a) => a -> [a] -> Bool\nisValid part vals = and (map (\\v -> isClose (v / part)) vals)\n\nisClose :: (RealFloat a) => a -> Bool\nisClose v = abs (fromIntegral (round v) - v) < 0.0001\n\ncalcDistance :: (RealFloat a) => (Point2 a) -> (Point2 a) -> a\ncalcDistance p1 p2 = sqrt((x p1 - x p2) ^ 2 + (y p1 - y p2) ^ 2) \n\n-- Calc everything in the maybe monad\ncalcSquare :: (RealFloat a, Show a) => (Point2 a) -> (Point2 a) -> (Point2 a) -> Maybe a\ncalcSquare p1 p2 p3 = do\n center <- calcCircleCenter p1 p2 p3 -- find the center\n a1 <- calcAngle center p1 p2 -- find three angles\n a2 <- calcAngle center p1 p3\n a3 <- calcAngle center p2 p3\n let radius = calcDistance center p1\n let [a1',a2'] = take 2 $ sort [a1,a2,a3] \n n <- detDivisor a1' a2'\n return $ radius ^ 2 * (fromIntegral n) * sin (2 * pi / (fromIntegral n)) / 2\n\ntestCircleCenter :: Bool\ntestCircleCenter = let cc = calcCircleCenter (Point2 (0,0)) (Point2 (1,1)) (Point2 (2,0)) in cc == Just (Point2 (1,0))\n\ntestCalcSquare :: (RealFloat a, Show a) => Maybe a\ntestCalcSquare = sq\n where p1 = Point2 (0,0)\n p2 = Point2 (1,1)\n p3 = Point2 (0,1)\n sq = calcSquare p1 p2 p3\n \nmain :: IO ()\nmain = replicateM 3 getLine >>= return.map parsePoint >>= (\\[p1,p2,p3] -> return $ calcSquare p1 p2 p3) >>=\n (\\sq -> case sq of Just s -> putStrLn $ show s\n Nothing -> putStrLn \"Error\")\n\nparsePoint :: (RealFloat a, Read a) => String -> (Point2 a)\nparsePoint str = Point2 (x,y)\n where [x,y] = map read (words str)\n\n"}, {"source_code": "import Data.Function(on)\nimport Data.List(sort)\nimport Data.Maybe(fromMaybe)\nimport Control.Monad(replicateM)\n\neps = 1e-5\ndist (x1, y1) (x2, y2) = sqrt (on (+) (^2) (x2 - x1) (y2 - y1))\nrad a b c = a * b * c / (4 * sqrt(p * (p - a) * (p - b) * (p - c)))\n where p = (a + b + c) / 2\n\nangle ll lr lc = acos ((ll ^ 2 + lr ^ 2 - lc ^ 2) / (2 * ll * lr))\n\ncheckAngle :: [Double] -> Integer -> Bool\ncheckAngle angles n = isValidAngles angles (2 * pi / (fromIntegral n))\n\nisValidAngles :: [Double] -> Double -> Bool\nisValidAngles angles part = and (map (\\a -> isClose (a / part)) angles)\n\nisClose v = abs (fromIntegral (round v) - v) < eps\n\ngetN :: Double -> Double -> Double -> Maybe Integer\ngetN a b c = case (take 1 $ filter (checkAngle [a1', a2', a3']) [3..100]) of\n [] -> Nothing\n n:_ -> Just n\n where r = rad a b c\n a1 = angle r r a \n a2 = angle r r b\n a3 = angle r r c\n a1':a2':_ = sort [a1,a2,a3]\n a3' = 2 * pi - a1' - a2'\n\ngetSq p1 p2 p3 = sq n r\n where sq n r' = (fromIntegral n) * r' * r' * sin (2 * pi / (fromIntegral n)) / 2\n a = dist p1 p2\n b = dist p2 p3\n c = dist p3 p1\n r = rad a b c\n n = fromMaybe 0 $ getN a b c\n\ngetSq' [p1,p2,p3] = getSq p1 p2 p3\n\nparseP :: String -> (Double, Double)\nparseP str = (x,y)\n where [x, y] = map read (words str)\n\nmain :: IO()\nmain = replicateM 3 getLine >>= print . getSq' . map parseP\n"}, {"source_code": "main = interact $ solve . map (map read . words) . lines\n where\n getCandidates = candidates . getAllCos . getSides\n getSides = map culcLen . combinations\n culcLen ([a, b], [c, d]) = sqrt ((c - a) ^ 2 + (d - b) ^ 2)\n combinations xs = zip xs $ getShift xs\n getShift (x:xs) = xs ++ [x]\n getAllCos [a, b, c] = [getCos [a, b, c], getCos [c, a, b], getCos [b, c, a]]\n getCos [a, b, c] = (a ^ 2 + b ^ 2 - c ^ 2) / (2 * a * b)\n candidates l = [fst ncoss | ncoss <- ncosss, allExist l (snd ncoss)]\n allExist xs coss = all (`exist` coss) xs\n exist x = any $ (\\x y -> abs (x - y) < 1e-6) x\n ncosss = [(n, [cos (pi / n * i) | i <- [1 .. n - 2]]) | n <- [3 .. 100]]\n getR x = last (getSides x) / sqrt (2 - 2 * getCosTheta x)\n getCosTheta = (+ (-1)) . (* 2) . (^ 2) . getCos . getSides\n area r n = r * r * sin (2 * pi / n) / 2 * n\n getAreas x = (map $ area $ getR x) (getCandidates x)\n getAns = show . minimum . getAreas\n solve s = (\\(x, y) -> x ++ take 7 y) $ span (/= '.') (getAns s)\n"}, {"source_code": "import Prelude hiding (gcd, div)\n\ngcd :: Double -> Double -> Double\ngcd a b\n | b < 0.0001 = a\n | a < b = gcd b a\n | otherwise = gcd (a-b) b\n\nsolve :: [[Double]] -> Double\nsolve ps = 0.5 * n * ls * sin(pi * 2 / n)\n where\n lens i = sum . map (\\j -> (ps !! a !! j - ps !! b !! j) ** 2) $ [0..1]\n where (a, b) = (i+1, i+2)\n len = sqrt . lens\n\n dtmp i = lens (i+1) + lens (i+2) - lens i\n div i = acos $ dtmp i / 2 / len (i+1) / len (i+2)\n\n n = fromInteger . floor $ pi / foldl1 gcd (map div [0..2])\n ls = 0.25 * lens 2 / (1 - ((0.5 * dtmp 2 / len 0 / len 1) ** 2))\n\nmain :: IO ()\nmain = interact $ show . solve . cycle . map (map read . words) . lines\n"}, {"source_code": "type MyPoint = (Double, Double)\n\nisIntegral :: Double -> Bool\nisIntegral x = dx <= 1e-5\n where dx = abs (x - fromIntegral (round x))\n\nmyLength :: MyPoint -> MyPoint -> Double\nmyLength p q = sqrt $ dx * dx + dy * dy\n where dx = fst p - fst q\n dy = snd p - snd q\n\nreadPoint :: String -> MyPoint\nreadPoint inStr = ((read pre)::Double, (read suf)::Double)\n where (pre, suf) = break (== ' ') inStr\n\nmain = do\n input <- getContents\n let vertice = map readPoint . lines $ input\n a = myLength (last vertice) (head (tail vertice))\n b = myLength (last vertice) (head vertice)\n c = myLength (head vertice) (head (tail vertice))\n angleA = acos ((b * b + c * c - a * a) / (2 * b * c))\n angleB = acos ((a * a + c * c - b * b) / (2 * a * c))\n angleC = acos ((b * b + a * a - c * c) / (2 * a * b))\n p = (a + b + c) / 2\n s = sqrt (p * (p - a) * (p - b) * (p - c))\n r = a * b * c / (4 * s)\n isGoodN n = all isIntegral (map (/ (pi / fromIntegral n)) [angleA, angleB, angleC])\n areaN n = fromIntegral n * r * r / 2 * sin (2 * pi / fromIntegral n)\n result = minimum (map areaN (filter isGoodN [3..100]))\n putStrLn $ show result\n"}, {"source_code": "\ntype Point = (Double, Double)\n\n(~=) :: Double -> Double -> Bool\n(~=) x y = abs (x-y) < 0.0000001\n\ngetN :: Double -> Double -> Double -> Int\ngetN a b c = head [n | n <- [3..100], checkAngle n a, checkAngle n b, checkAngle n c]\n where\n checkAngle :: Int -> Double -> Bool\n checkAngle n a = any (\\i -> (fromIntegral i / fromIntegral n) ~= (a / (2*pi))) [1..n]\n\ngetCentre :: Point -> Point -> Point -> Point\ngetCentre (ax, ay) (bx, by) (cx, cy) = o\n where\n a11 = by - ay\n a12 = ay - cy\n a21 = ax - bx\n a22 = cx - ax\n b1 = 0.5 * (bx - cx)\n b2 = 0.5 * (by - cy)\n t1 = -(b1 * a22 - a12 * b2) / (a11 * a22 - a12 * a21)\n o = (0.5 * (ax + bx) + t1 * (by - ay),\n 0.5 * (ay + by) + t1 * (ax - bx))\n\ngetAngle :: Point -> Point -> Double\ngetAngle (ax, ay) (bx, by) = acos (scal / (modA * modB))\n where\n scal = ax * bx + ay * by\n modA = modP (ax, ay)\n modB = modP (bx, by)\n\ngetVector :: Point -> Point -> Point\ngetVector (ax, ay) (bx, by) = (bx - ax, by - ay)\n\nmodP :: Point -> Double\nmodP (x, y) = sqrt (x*x + y*y)\n\nsolve :: Point -> Point -> Point -> Double\nsolve p1 p2 p3 = n * r * r * cos a * sin a\n where\n o = getCentre p1 p2 p3\n a1 = getAngle (getVector o p1) (getVector o p2)\n a2 = getAngle (getVector o p1) (getVector o p3)\n a3 = getAngle (getVector o p2) (getVector o p3)\n r = modP (getVector o p1)\n n = fromIntegral (getN a1 a2 a3)\n a = 2 * pi / (2 * n)\n\nparse :: String -> Point\nparse line = (x, y)\n where\n [x, y] = map read (words line)\n\nreadPoint :: IO Point\nreadPoint = getLine >>= return . parse\n\nreplicateM :: Monad m => Int -> m a -> m [a]\nreplicateM n action = mapM (const action) [1..n]\n\nmain :: IO ()\nmain = do\n [p1, p2, p3] <- replicateM 3 readPoint\n print $ solve p1 p2 p3\n"}, {"source_code": "{-\n Find the area of the minimum regular polygon given three random vertices of\n said polygon\n-}\n\ndist ( [x0, y0], [x1, y1] ) = sqrt ((x0 - x1)^2 + (y0 - y1)^2)\nangle (a,b,c) = acos ( ( c^2 + b^2 - a^2) / 2 / b / c )\nisInteger x = abs ( x - fromIntegral (round x) ) <= 10**(-5)\n\nsolve [p0,p1,p2] = \n let\n [a,b,c] = map dist [ (p0,p1), (p1,p2), (p2,p0) ]\n [x,y,z] = map angle [ (a,b,c), (b,c,a), (c,a,b) ]\n r = a / 2 / sin x\n ok a = all isInteger $ map (/a) [x,y,z]\n q = 2 * (head $ filter ok $ map (pi/) [3..100])\n in\n r^2 * sin q * pi / q\n\nmain = interact $ show . solve . map ( map read . words) . lines"}, {"source_code": "-- Codeforces 1C\n\n{-# LANGUAGE MultiWayIf #-}\n\nimport qualified Data.ByteString.Char8 as BC\nimport Data.Fixed (mod')\nimport Text.Printf\n\nmain :: IO ()\nmain = BC.getContents >>= solve . map (read . BC.unpack) . BC.words >>= printf \"%.6f\"\n\nsolve :: [Double] -> IO Double\nsolve [x1, y1, x2, y2, x3, y3] = do\n let ab = (x2 - x1, y2 - y1)\n ac = (x3 - x1, y3 - y1)\n bc = (x3 - x2, y3 - y2)\n let r1' = dist ab\n r2' = dist ac\n r3' = dist bc\n r1 = sqrt r1' \n r2 = sqrt r2' \n r3 = sqrt r3' \n let cc = (r1 + r2 + r3) / 2\n ss = sqrt (cc * (cc - r1) * (cc - r2) * (cc - r3)) -- 面积\n r = r1 * r2 * r3 / (4 * ss) -- 外接圆外径\n let delta1 = acos (1 - r1' / (2 * r * r))\n delta2 = acos (1 - r2' / (2 * r * r))\n delta3 = 2 * pi - delta1 - delta2\n let delta = fgcd delta1 (fgcd delta2 delta3) -- 一条边对应的圆心角\n n = fromIntegral . round $ 2 * pi / delta\n return $ 0.5 * r * r * sin (2 * pi / n) * n\n\n where\n dist (u1, v1) = u1 * u1 + v1 * v1\n\n fgcd a b | a < 1e-4 = b\n | b < 1e-4 = a\n | otherwise = fgcd b (a `mod'` b)\n\n"}, {"source_code": "(⋅) = (*)\n\n𝜋 = pi\n𝜀 = 0.0001 -- epsilon. do not set this value too small\n\n𝘥 (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) = sqrt $ (𝑥₁ - 𝑥₂)⋅(𝑥₁ - 𝑥₂) + (𝑦₁ - 𝑦₂)⋅(𝑦₁ - 𝑦₂)\n\n𝜃 (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) | abs (𝑥₂ - 𝑥₁) < 𝜀 = 𝜋/2\n | 𝑥₁ > 𝑥₂ = 𝜋 + atan ((𝑦₂ - 𝑦₁)/(𝑥₂ - 𝑥₁))\n | otherwise = atan ((𝑦₂ - 𝑦₁)/(𝑥₂ - 𝑥₁))\n\n𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) = if 𝛾 < 𝜀 then 𝜋 else 𝛾\n where\n 𝛾 = abs $ 𝜃 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) - 𝜃 (𝑥ᵣ, 𝑦ᵣ) (𝑥₂, 𝑦₂)\n\n𝘧𝘨𝘤𝘥 𝛼 𝛽 | abs 𝛼 < 𝜀 = 𝛽\n | 𝛼 > 𝛽 = 𝘧𝘨𝘤𝘥 𝛽 𝛼\n | otherwise = 𝘧𝘨𝘤𝘥 (𝛽 - 𝛼) 𝛼\n\nmain = do\n -- Read 3 vertices\n line₁ <- getLine\n let 𝑥₁ = read (words line₁ !! 0) :: Double\n let 𝑦₁ = read (words line₁ !! 1) :: Double\n line₂ <- getLine\n let 𝑥₂ = read (words line₂ !! 0) :: Double\n let 𝑦₂ = read (words line₂ !! 1) :: Double\n line₃ <- getLine\n let 𝑥₃ = read (words line₃ !! 0) :: Double\n let 𝑦₃ = read (words line₃ !! 1) :: Double\n\n -- Find the center (𝑥ᵣ, 𝑦ᵣ)\n let 𝑎₁₂ = 𝑥₁ - 𝑥₂\n let 𝑏₁₂ = 𝑦₁ - 𝑦₂\n let 𝑐₁₂ = (𝑥₁⋅𝑥₁ - 𝑥₂⋅𝑥₂ + 𝑦₁⋅𝑦₁ - 𝑦₂⋅𝑦₂) / 2\n let 𝑎₁₃ = 𝑥₁ - 𝑥₃\n let 𝑏₁₃ = 𝑦₁ - 𝑦₃\n let 𝑐₁₃ = (𝑥₁⋅𝑥₁ - 𝑥₃⋅𝑥₃ + 𝑦₁⋅𝑦₁ - 𝑦₃⋅𝑦₃) / 2\n let 𝑥ᵣ = (𝑏₁₃⋅𝑐₁₂ - 𝑏₁₂⋅𝑐₁₃) / (𝑎₁₂⋅𝑏₁₃ - 𝑎₁₃⋅𝑏₁₂)\n let 𝑦ᵣ = (𝑎₁₂⋅𝑐₁₃ - 𝑎₁₃⋅𝑐₁₂) / (𝑎₁₂⋅𝑏₁₃ - 𝑎₁₃⋅𝑏₁₂)\n\n -- Determine number of edges 𝑛 and circumradius 𝑟\n let 𝛿₁₂ = 𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂)\n let 𝛿₁₃ = 𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₃, 𝑦₃)\n let 𝜂 = 𝘧𝘨𝘤𝘥 (2⋅𝜋) $ 𝘧𝘨𝘤𝘥 𝛿₁₂ 𝛿₁₃\n let 𝑛 = fromInteger $ round (2⋅𝜋/𝜂)\n let 𝑟 = 𝘥 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁)\n let 𝒂 = 𝑛⋅𝑟⋅𝑟⋅sin (𝜋/𝑛)⋅cos (𝜋/𝑛)\n print 𝒂\n"}, {"source_code": "import Data.Array\nimport Data.Ratio\nimport Data.Char\nimport Data.List\nimport Data.Bits\n\nimport System\nimport System.IO\nimport System.Random\nimport Control.Applicative\nimport Control.Monad\nimport qualified Data.Set as Set \nimport qualified Data.Map as Map \n\nimport Text.Printf\n\nimport Debug.Trace\n\n-- newtype Point = Pt (Double, Double) deriving Show\ntype Point = (Double, Double) -- (x,y)\ntype Line = (Double, Double, Double) -- ax+by=c\n\ninfixr 6 -.\n(-.) (x1, y1) (x2, y2) = (x1 - x2, y1 - y2)\n\nlen (x,y) = sqrt(x^2+y^2)\ndot (x1, y1) (x2, y2) = x1*x2 + y1*y2\nang v1 v2 = if l1==0 || l2==0 then 0 else acos(cosine)\n where l1 = len v1\n l2 = len v2\n v = dot v1 v2/l1/l2\n cosine | v > 1 = 1.0\n | v < -1 = -1.0\n | otherwise = v\n\nreadls :: (Read a) => String -> [a]\nreadls = map read . words\n\nmidLine :: Point -> Point -> Line\nmidLine (x1, y1) (x2, y2) = let a = y2-y1\n b = x1-x2\n c = a*(y1+y2)-b*(x1+x2)\n in (-2*b, 2*a, c)\n\nisect :: Line -> Line -> Point\nisect (a1, b1, c1) (a2, b2, c2) = ((b2*c1-b1*c2)/det, (a1*c2-a2*c1)/det) where det = a1*b2 - a2*b1\n\n-- given 3 point on cirlce, return center of circle\ncircleCenter :: Point -> Point -> Point -> Point\ncircleCenter p1 p2 p3 = isect (midLine p1 p2) (midLine p2 p3)\n\n-- solve :: [Double] -> Double\nsolve [x1, y1, x2, y2, x3, y3] = n * r^2 * sin(theta)/2\n where p1 = (x1, y1)\n p2 = (x2, y2)\n p3 = (x3, y3)\n center = circleCenter p1 p2 p3\n v1 = p1 -. center\n v2 = p2 -. center\n v3 = p3 -. center\n r = len v1\n ang1 = ang v1 v2\n ang2 = ang v2 v3\n tol = 1e-5\n n1 = denominator $ approxRational (ang1/2/pi) tol\n n2 = denominator $ approxRational (ang2/2/pi) tol\n n = fromInteger $ lcm n1 n2\n theta = 2*pi/n\n\nmain = do readls <$> getContents >>= print . solve\n \n"}, {"source_code": "import Data.Array\nimport Data.Ratio\nimport Data.Char\nimport Data.List\nimport Data.Bits\n\nimport System\nimport System.IO\nimport System.Random\nimport Control.Applicative\nimport Control.Monad\nimport qualified Data.Set as Set \nimport qualified Data.Map as Map \n\nimport Text.Printf\n\nimport Debug.Trace\n\n-- newtype Point = Pt (Double, Double) deriving Show\ntype Point = (Double, Double) -- (x,y)\ntype Line = (Double, Double, Double) -- ax+by=c\n\ninfixr 6 -.\n(-.) (x1, y1) (x2, y2) = (x1 - x2, y1 - y2)\n\nlen (x,y) = sqrt(x^2+y^2)\ndot (x1, y1) (x2, y2) = x1*x2 + y1*y2\nang v1 v2 = if l1==0 || l2==0 then 0 else acos(cosine)\n where l1 = len v1\n l2 = len v2\n v = dot v1 v2/l1/l2\n cosine | v > 1 = 1.0\n | v < -1 = -1.0\n | otherwise = v\n\nreadls :: (Read a) => String -> [a]\nreadls = map read . words\n\nmidLine :: Point -> Point -> Line\nmidLine (x1, y1) (x2, y2) = let a = y2-y1\n b = x1-x2\n c = a*(y1+y2)-b*(x1+x2)\n in (-2*b, 2*a, c)\n\nisect :: Line -> Line -> Point\nisect (a1, b1, c1) (a2, b2, c2) = ((b2*c1-b1*c2)/det, (a1*c2-a2*c1)/det) where det = a1*b2 - a2*b1\n\n-- given 3 point on cirlce, return center of circle\ncircleCenter :: Point -> Point -> Point -> Point\ncircleCenter p1 p2 p3 = isect (midLine p1 p2) (midLine p2 p3)\n\n-- solve :: [Double] -> Double\nsolve [x1, y1, x2, y2, x3, y3] = n * r^2 * sin(2*pi/n)/2\n where p1 = (x1, y1)\n p2 = (x2, y2)\n p3 = (x3, y3)\n o = circleCenter p1 p2 p3\n v1 = p1 -. o\n v2 = p2 -. o\n v3 = p3 -. o\n r = len v1\n ang1 = ang v1 v2\n ang2 = ang v2 v3\n tol = 1e-5\n n1 = denominator $ approxRational (ang1/2/pi) tol\n n2 = denominator $ approxRational (ang2/2/pi) tol\n n = fromInteger $ lcm n1 n2\n\n-- main = readls <$> getContents >>= print . solve\nmain = interact (show . solve . readls)\n \n"}, {"source_code": "dist :: ((Double, Double), (Double, Double)) -> Double\ndist ((x1, y1), (x2, y2)) = sqrt ((x1 - x2)^2 + (y1 - y2)^2)\n\nfindAngle :: (Double, Double, Double) -> Double\nfindAngle (a, b, c) = acos ((b^2 + c^2 - a^2) / (2*b*c) )\n\nfgcd :: Double -> Double -> Double\nfgcd a b \n | abs a < e || abs b < e = a + b\n | a > b = fgcd (step a b) b\n | otherwise = fgcd a (step b a)\n where \n e = 1e-4\n step x y = x - y * (fromIntegral $ floor (x / y))\n\nfindArea :: [[Double]] -> Double\nfindArea points = (n/2) * r^2 * sin (2*pi/n) where\n [p1, p2, p3] = map (\\[p_x, p_y] -> (p_x, p_y)) points\n [a, b, c] = map dist [(p1, p2), (p2, p3), (p1, p3)]\n [alpha, beta, gamma] = map findAngle [(a, b, c), (b, a, c), (c, a, b)]\n r = a / (2*sin(alpha))\n n = pi/ fgcd alpha (fgcd beta gamma)\n\nreadLine :: IO [Double]\nreadLine = (map read) . words <$> getLine\n\nmain =\n readLine >>= \\p1 ->\n readLine >>= \\p2 ->\n readLine >>= \\p3 ->\n print $ findArea [p1, p2, p3]"}, {"source_code": "\nimport Data.Complex\nimport Text.Printf\n\nreadComplex :: String -> Complex Double\nreadComplex = (\\[x,y] -> x :+ y) . map read . words\n\narea a b = imagPart $ a * conjugate b\n\nangleSin a b = area a b / (magnitude a * magnitude b)\n\nangle a b = phase (a * conjugate b)\n\ncircleR a b c = magnitude (b - c) / angleSin (b - a) (c - a) / 2\n\ngcdR :: Double -> Double -> Double\ngcdR a b \n | a < 0 || b < 0 = gcdR (abs a) (abs b)\n | a < b = gcdR b a\n | abs b < 1e-4 = a\n | otherwise = gcdR (a-b) b\n\nsolve [a,b,c] = n' * area0\n where\n r = circleR a b c\n angA = abs (angle (b - a) (c - a)) * 2\n angB = abs (angle (c - b) (a - b)) * 2\n angC = abs (angle (a - c) (b - c)) * 2\n invN = angA `gcdR` angB `gcdR` angC\n n = 2 * pi / invN\n n' = fromIntegral $ round n\n invN' = 2 * pi / n'\n area0 = r^2 * (sin invN') / 2\n\nmain = interact $ printf \"%.10f\" . solve . map readComplex . take 3 . lines\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = interact $ show . solve . map (map read . words) . lines\n\nsolve :: [[Double]] -> Double\nsolve [[x1, y1], [x2, y2], [x3, y3]] = sides * rsquare * sin (2 * pi / sides) / 2\n where\n a1 = 2 * (x2 - x1)\n b1 = 2 * (y2 - y1)\n c1 = x1**2 - x2**2 + y1**2 - y2**2\n a2 = 2 * (x3 - x1)\n b2 = 2 * (y3 - y1)\n c2 = x1**2 - x3**2 + y1**2 - y3**2\n x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)\n y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)\n dx1 = x1 - x\n dy1 = y1 - y\n dx2 = x2 - x\n dy2 = y2 - y\n dx3 = x3 - x\n dy3 = y3 - y\n angl1 = 2 * pi / (acos ((dx1 * dx2 + dy1 * dy2) / (sqrt ((dx1**2 + dy1**2) * (dx2**2 + dy2**2)))))\n angl2 = 2 * pi / (acos ((dx3 * dx2 + dy3 * dy2) / (sqrt ((dx3**2 + dy3**2) * (dx2**2 + dy2**2)))))\n angl3 = 2 * pi / (acos ((dx3 * dx1 + dy3 * dy1) / (sqrt ((dx3**2 + dy3**2) * (dx1**2 + dy1**2)))))\n sides = fromIntegral $ head $ filter (\\n -> let m = fromIntegral n in allint (m / angl1, m / angl2, m / angl3)) ([3..] :: [Int])\n allint (a, b, c) = nearint a && nearint b && nearint c\n nearint a = abs (a - fromIntegral (round a :: Integer)) < 1e-4\n rsquare = sqrt ((dx1**2 + dy1**2) * (dx2**2 + dy2**2))\nsolve _ = undefined\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = getContents >>= print . solve . map (map read . words) . lines\n\nsolve :: [[Double]] -> Double\nsolve [[x1, y1], [x2, y2], [x3, y3]] = sides * rsquare * sin (2 * pi / sides) / 2\n where\n (x, y) = center (x1, y1) (x2, y2) (x3, y3)\n (dx1, dy1) = (x1 - x, y1 - y)\n (dx2, dy2) = (x2 - x, y2 - y)\n (dx3, dy3) = (x3 - x, y3 - y)\n a1 = 2 * pi / angle (dx1, dy1) (dx2, dy2)\n a2 = 2 * pi / angle (dx2, dy2) (dx3, dy3)\n a3 = 2 * pi / angle (dx3, dy3) (dx1, dy1)\n sides = head $ filter (\\n -> allint (n / a1, n / a2, n / a3)) (map fromIntegral ([3..] :: [Int]))\n allint (a, b, c) = isNearInteger a && isNearInteger b && isNearInteger c\n isNearInteger a = abs (a - fromIntegral (round a :: Integer)) < 1e-4\n rsquare = dx1**2 + dy1**2\nsolve _ = undefined\n\ncenter :: Floating t => (t, t) -> (t, t) -> (t, t) -> (t, t)\ncenter (x1, y1) (x2, y2) (x3, y3) = (x, y)\n where x = ((x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2)) / d\n y = ((x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1)) / d\n d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))\n\ninner :: Floating a => (a, a) -> (a, a) -> a\ninner (dx1, dy1) (dx2, dy2) = dx1 * dx2 + dy1 * dy2\n\nlen :: Floating a => (a, a) -> a\nlen (dx1, dy1) = sqrt (dx1**2 + dy1**2)\n\nangle :: Floating a => (a, a) -> (a, a) -> a\nangle d1 d2 = acos (inner d1 d2 / (len d1 * len d2))\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = interact $ show . solve . map (map read . words) . lines\n\n-- solve :: [[Float]] -> Float\nsolve [[x1, y1], [x2, y2], [x3, y3]] = sides * rsquare * sin (2 * pi / sides) / 2\n where\n a1 = 2 * (x2 - x1)\n b1 = 2 * (y2 - y1)\n c1 = x1**2 - x2**2 + y1**2 - y2**2\n a2 = 2 * (x3 - x1)\n b2 = 2 * (y3 - y1)\n c2 = x1**2 - x3**2 + y1**2 - y3**2\n x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)\n y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)\n dx1 = x1 - x\n dy1 = y1 - y\n dx2 = x2 - x\n dy2 = y2 - y\n dx3 = x3 - x\n dy3 = y3 - y\n angl1 = 2 * pi / (acos ((dx1 * dx2 + dy1 * dy2) / (sqrt ((dx1**2 + dy1**2) * (dx2**2 + dy2**2)))))\n angl2 = 2 * pi / (acos ((dx3 * dx2 + dy3 * dy2) / (sqrt ((dx3**2 + dy3**2) * (dx2**2 + dy2**2)))))\n angl3 = 2 * pi / (acos ((dx3 * dx1 + dy3 * dy1) / (sqrt ((dx3**2 + dy3**2) * (dx1**2 + dy1**2)))))\n sides = fromIntegral $ head $ filter (\\n -> let m = fromIntegral n in allint (m / angl1, m / angl2, m / angl3)) ([3..] :: [Int])\n allint (a, b, c) = nearint a && nearint b && nearint c\n nearint a = abs (a - fromIntegral (round a :: Integer)) < 1e-4\n rsquare = sqrt ((dx1**2 + dy1**2) * (dx2**2 + dy2**2))\nsolve _ = undefined\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = interact $ show . solve . map (map read . words) . lines\n\nsolve :: [[Double]] -> Double\nsolve [[x1, y1], [x2, y2], [x3, y3]] = sides * rsquare * sin (2 * pi / sides) / 2\n where\n a1 = 2 * (x2 - x1)\n b1 = 2 * (y2 - y1)\n c1 = x1**2 - x2**2 + y1**2 - y2**2\n a2 = 2 * (x3 - x1)\n b2 = 2 * (y3 - y1)\n c2 = x1**2 - x3**2 + y1**2 - y3**2\n x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)\n y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)\n dx1 = x1 - x\n dy1 = y1 - y\n dx2 = x2 - x\n dy2 = y2 - y\n dx3 = x3 - x\n dy3 = y3 - y\n angl1 = 2 * pi / acos ((dx1 * dx2 + dy1 * dy2) / sqrt ((dx1**2 + dy1**2) * (dx2**2 + dy2**2)))\n angl2 = 2 * pi / acos ((dx3 * dx2 + dy3 * dy2) / sqrt ((dx3**2 + dy3**2) * (dx2**2 + dy2**2)))\n angl3 = 2 * pi / acos ((dx3 * dx1 + dy3 * dy1) / sqrt ((dx3**2 + dy3**2) * (dx1**2 + dy1**2)))\n sides = fromIntegral $ head $ filter (\\n -> let m = fromIntegral n in allint (m / angl1, m / angl2, m / angl3)) ([3..] :: [Int])\n allint (a, b, c) = isNearInteger a && isNearInteger b && isNearInteger c\n isNearInteger a = abs (a - fromIntegral (round a :: Integer)) < 1e-4\n rsquare = dx1**2 + dy1**2\nsolve _ = undefined\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = interact $ show . solve . map (map read . words) . lines\n\nsolve :: [[Double]] -> Double\nsolve [[x1, y1], [x2, y2], [x3, y3]] = sides * rsquare * sin (2 * pi / sides) / 2\n where\n (x, y) = center (x1, y1) (x2, y2) (x3, y3)\n (dx1, dy1) = (x1 - x, y1 - y)\n (dx2, dy2) = (x2 - x, y2 - y)\n (dx3, dy3) = (x3 - x, y3 - y)\n a1 = 2 * pi / angle (dx1, dy1) (dx2, dy2)\n a2 = 2 * pi / angle (dx2, dy2) (dx3, dy3)\n a3 = 2 * pi / angle (dx3, dy3) (dx1, dy1)\n sides = head $ filter (\\n -> allint (n / a1, n / a2, n / a3)) (map fromIntegral ([3..] :: [Int]))\n allint (a, b, c) = isNearInteger a && isNearInteger b && isNearInteger c\n isNearInteger a = abs (a - fromIntegral (round a :: Integer)) < 1e-4\n rsquare = dx1**2 + dy1**2\nsolve _ = undefined\n\ncenter :: Floating t => (t, t) -> (t, t) -> (t, t) -> (t, t)\ncenter (x1, y1) (x2, y2) (x3, y3) = (x, y)\n where x = ((x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2)) / d\n y = ((x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1)) / d\n d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))\n\ninner :: Floating a => (a, a) -> (a, a) -> a\ninner (dx1, dy1) (dx2, dy2) = dx1 * dx2 + dy1 * dy2\n\nlen :: Floating a => (a, a) -> a\nlen (dx1, dy1) = sqrt (dx1**2 + dy1**2)\n\nangle :: Floating a => (a, a) -> (a, a) -> a\nangle d1 d2 = acos (inner d1 d2 / (len d1 * len d2))\n"}, {"source_code": "import Data.Functor\n\ntype Pair a = (a, a)\n\nthresh :: RealFloat a => a\nthresh = 1e-5\n\nisInt :: RealFloat a => a -> Bool\nisInt x = (<=thresh) . abs $ x - (fromIntegral . round) x\n\ndist :: RealFloat a => Pair a -> Pair a -> a\ndist (x, y) (x', y') = sqrt $ dx * dx + dy * dy\n where dx = x - x'\n dy = y - y'\n\ndistances :: RealFloat a => Pair a -> Pair a -> Pair a -> [a]\ndistances a b c = [dist a b, dist b c, dist c a]\n\ncircumradius :: RealFloat a => Pair a -> Pair a -> Pair a -> a\ncircumradius a b c = a' * b' * c' / (4 * area)\n where [a', b', c'] = distances a b c\n s = (a' + b' + c') / 2\n area = sqrt $ s * (s - a') * (s - b') * (s - c')\n\nloc :: RealFloat a => a -> a -> a -> a\nloc a b c = acos $ (a * a + b * b - c * c) / (2 * a * b)\n\nangles :: RealFloat a => a -> a -> a -> [a]\nangles a b c = [loc a b c, loc b c a, loc c a b]\n\ngood :: RealFloat a => a -> a -> Bool\ngood angle angle' = isInt $ angle / angle'\n\ngood' :: (RealFloat a, Integral b) => a -> a -> a -> b -> Bool\ngood' a b c n = and $ flip good angle <$> angles a b c\n where angle = pi / fromIntegral n\n\ngood'' :: (RealFloat a, Integral b) => Pair a -> Pair a -> Pair a -> b -> Bool\ngood'' a b c = good' a' b' c'\n where [a', b', c'] = distances a b c\n\narea :: (RealFloat a, Integral b) => a -> b -> a\narea r n = 0.5 * n' * r * r * sin t\n where t = 2 * pi / n'\n n' = fromIntegral n\n\nsolution :: RealFloat a => Pair a -> Pair a -> Pair a -> a\nsolution a b c = head $ area r <$> sides\n where r = circumradius a b c\n sides = map snd $ filter good''' $ (\\n -> ((a, b, c), n)) <$> [3..100]\n good''' ((a, b, c), n) = good'' a b c n\n\nmain :: IO ()\nmain = do\n a <- readLine\n b <- readLine\n c <- readLine\n print $ solution a b c\n where readLine = (\\[a, b] -> (a, b)) . map read . words <$> getLine\n"}, {"source_code": "module Main where\n\nfrem :: Double -> Double -> Double\nfrem x y = x - (y * (fromIntegral (truncate (x / y))))\n\nfgcd :: Double -> Double -> Double\nfgcd x y = fgcd_aux (abs x) (abs y) where \n\tfgcd_aux a b | abs b <= 1e-5 = a\n\t\t\t\t | otherwise = fgcd_aux b (frem a b)\n \ndistance :: (Double, Double) -> (Double, Double) -> Double\ndistance (x1, y1) (x2, y2) = sqrt ((x1 - x2) ^ 2 + (y1 - y2) ^ 2)\n\nangle :: Double -> Double -> Double -> Double\nangle d1 d2 d3 = acos ((d1 ^ 2 + d2 ^ 2 - d3 ^ 2) / (2 * d1 * d2))\n\nradius :: Double -> Double -> Double\nradius a alpha = a / (2 * sin alpha)\n\ncompute :: (Double, Double) -> (Double, Double) -> (Double, Double) -> Double\ncompute p1 p2 p3 = let\n\t\ta = distance p1 p2;\n\t\tb = distance p2 p3;\n\t\tc = distance p3 p1;\n\t\talpha = angle b c a;\n\t\tbeta = angle c a b;\n\t\tgamma = angle a b c;\n\t\tr = radius a alpha;\n\t\tu = 2 * fgcd alpha (fgcd beta gamma) in r ^ 2 * pi / u * sin u\n\nmain :: IO ()\nmain = do\n\tinput <- getContents\n\tlet tokens = words input;\n\t\tp1 = (read (tokens !! 0), read (tokens !! 1));\n\t\tp2 = (read (tokens !! 2), read (tokens !! 3));\n\t\tp3 = (read (tokens !! 4), read (tokens !! 5)) in\n\t\tputStrLn (show (compute p1 p2 p3))\n"}, {"source_code": "import Control.Arrow\n\nmain = do\n [ax,ay] <- readPoint\n [bx,by] <- readPoint\n [cx,cy] <- readPoint\n let d = 2*(ax*(by-cy)+bx*(cy-ay)+cx*(ay-by))\n dx = ((ay^2+ax^2)*(by-cy)+(by^2+bx^2)*(cy-ay)+(cy^2+cx^2)*(ay-by))/d\n dy = ((ay^2+ax^2)*(cx-bx)+(by^2+bx^2)*(ax-cx)+(cy^2+cx^2)*(bx-ax))/d\n aa = angle (bx-dx,by-dy) (cx-dx,cy-dy)\n ab = angle (cx-dx,cy-dy) (ax-dx,ay-dy)\n ac = angle (ax-dx,ay-dy) (bx-dx,by-dy)\n n = snd $ head $\n filter (isMultiple ac . fst) $\n filter (isMultiple ab . fst) $\n filter (isMultiple aa . fst) $\n map ((2*pi/) &&& id) [3..]\n r = sqrt ((ax-dx)^2 + (ay-dy)^2)\n a = n*r^2*sin(2*pi/n)/2\n print a\n\nreadPoint = fmap (map read . words) getLine\n(a,b)·(c,d) = a*c+b*d\n(a,b)×(c,d) = a*d-b*c\nangle a b = abs (atan2 (a×b) (a·b))\nisMultiple a b = abs (a - b*fromIntegral (round(a/b))) < pi/100000"}, {"source_code": "dist ([x0,y0],[x1,y1]) = sqrt ((x0-x1)^2 + (y0-y1)^2)\n\ncosLaw (a,b,c) =acos $ ( b^2 + c^2 - a^2 ) / ( 2*b*c )\n\nsinLaw a th = a / 2 / sin th\n\nisWhole a = abs(a - fromIntegral (round a)) < 1e-5\n\ncal [p0,p1,p2] = \n let [a,b,c] = map dist [(p0,p1),(p1,p2),(p2,p0)]\n [a0,a1,a2] = map cosLaw [(a,b,c),(b,a,c),(c,a,b)]\n r = sinLaw a a0\n n = head $ filter (\\x -> all (isWhole.(*x).(/pi)) [a0,a1,a2]) [3..100]\n in\n n * r * r / 2 * sin (2 * pi / n)\n\nmain = interact $ show.cal.map (map read.words).lines\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Ord\nimport Text.Printf\n\nepsilon :: Double\nepsilon = 1e-4\n\ncross :: [[Double]] -> Double\ncross [[y1, x1], [y2, x2], [y3, x3]] = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)\n\ndistance :: [Double] -> [Double] -> Double\ndistance [y1, x1] [y2, x2] = sqrt $ (x2 - x1) ^ 2 + (y2 - y1) ^ 2\n\ncap :: Double -> Double\ncap = min 1 . max (negate 1)\n\nunitVector :: [Double] -> [Double] -> [Double]\nunitVector p1@[y1, x1] p2@[y2, x2] = cap . (/ d) <$> [x2 - x1, y2 - y1]\n where\n d = distance p1 p2\n\nradian p@[y, x] = if y >= 0 then theta else 2 * pi - theta\n where\n theta = acos x\n \ncenterOfCircle :: [[Double]] -> [Double]\ncenterOfCircle ps@[[y1, x1], [y2, x2], [y3, x3]]\n | abs (cross ps) < epsilon = error $ \"All the points are on a line.\"\n | otherwise = [b / a, d / c]\n where\n a = 2 * (y1 * (x3 - x2) + y2 * (x1 - x3) + y3 * (x2 - x1))\n b = (y1 ^ 2 + x1 ^ 2) * (x3 - x2)\n + (y2 ^ 2 + x2 ^ 2) * (x1 - x3)\n + (y3 ^ 2 + x3 ^ 2) * (x2 - x1)\n c = 2 * (x1 * (y3 - y2) + x2 * (y1 - y3) + x3 * (y2 - y1))\n d = (y1 ^ 2 + x1 ^ 2) * (y3 - y2)\n + (y2 ^ 2 + x2 ^ 2) * (y1 - y3)\n + (y3 ^ 2 + x3 ^ 2) * (y2 - y1)\n\nsolve :: (Double, Int) -> [Double] -> Double\nsolve = fmap (((2 * pi) /) . fst) . foldl' search\n where\n search (theta, n) x = (theta / fromIntegral (until check succ n), 1)\n where\n check i\n | x `fmod` t < epsilon = True\n | otherwise = False\n where\n t = theta / fromIntegral i\n v `fmod` d\n | r < epsilon || abs (1 - r) < epsilon = 0\n | otherwise = r\n where\n (_, r) = properFraction $ (v / d)\n\ngetDouble :: IO [Double]\ngetDouble = fmap read . words <$> getLine\n\nmain = do\n -- let ps = [[0, 0], [1, 1], [0, 1]]\n -- let ps = [[0, 1], [sqrt 3 / 2, 1 / 2], [0, -1]]\n -- let ps = [[0, 1], [sqrt 2 / 2, sqrt 2 / 2], [0, -1]]\n -- let ps = [[0, 1], [1 / 2, sqrt 3 / 2], [0, -1]]\n ps <- replicateM 3 getDouble\n let c = centerOfCircle ps\n let [theta1, theta2, theta3] = sort $ radian <$> (unitVector c <$> ps)\n let xs = [theta2 - theta1, theta3 - theta2, 2 * pi - (theta3 - theta1)]\n let n = solve (2 * pi, 1) xs\n let r = distance c (head ps)\n printf \"%.7f\" $ (r ^ 2 * sin (2 * pi / n) / 2) * n\n\n"}, {"source_code": "import Data.List\nimport Text.Printf\n\ndelta = 1e-6\nisInteger x = abs (fromInteger (round x) - x) < 0.001\n\ncircle [[x1', y1'], [x2', y2'], [x3',y3']] = \n\tlet {(x1, y1, x2, y2, x3, y3) = if abs(x2' - x1') < delta \n\t\tthen (x1', y1', x3', y3', x2', y2') \n\t\telse if abs (x2' - x3') < delta then (x2', y2', x1', y1', x3', y3')\n\t\telse (x1', y1', x2', y2', x3', y3')} in\n\tlet { ma = (y2 - y1)/(x2 - x1)\n\t; mb = (y3 - y2)/(x3 - x2)} in\n\tlet x = (ma * mb * (y1 - y3) + mb * (x1 + x2) - ma * (x2 + x3)) / (2 * (mb - ma)) in\n\tlet y = if abs ma > delta then -1 / ma * (x - (x1 + x2)/2) + (y1 + y2)/2\n\t\telse -1 / mb * (x - (x2 + x3)/2 ) + (y2 + y3)/2 in\n\t(x, y, sqrt((x - x1)**2 + (y - y1)**2))\n\ndist x1 y1 x2 y2 = sqrt ((x1 - x2)**2 + (y1 - y2)**2)\n\nangles coord (x, y, r) = let {as = sort $ map (\\[xi, yi] -> let a = atan2 (xi - x) (yi - y)\n\t\tin if a < 0 then a + 2 * pi else a) coord} in\n\tfst $ foldl (\\(l, a) x -> ((x - a):l, x)) ([], head as) $ tail as\n\ns::[[Double]] -> Double\ns coords = let {(x, y, r) = circle coords} in\n\tlet {[n] = take 1 $ filter (\\x -> all isInteger $ map (/(2* pi / fromInteger x)) as) [3..100] \n\t\twhere as = angles coords (x, y, r)}\n\tin let {a = pi / (fromInteger n)}\n\tin r ** 2 * (sin a) * (cos a) * (fromInteger n)\n\nmain = do {\n\tcoords <- mapM (\\_ -> getLine >>= (return . map read . words)) [1..3]\n\t--; let {[[x1, y1], [x2, y2], [x3, y3]] = coords}\n\t--; putStr (show (dist x1 y1 x2 y2) ++ \"\\n\")\n\t--; putStr (show (dist x3 y3 x2 y2) ++ \"\\n\")\n\t--; putStr (show (dist x1 y1 x3 y3) ++ \"\\n\")\n\t--; putStr ((show $ radius coords) ++ \"\\n\")\n\t--; putStr ((show $ angles coords (radius coords)) ++ \"\\n\")\n\t; printf \"%.6f\" $ s coords\n}\n"}, {"source_code": "{-# LANGUAGE TypeApplications #-}\nmodule Main\n( main\n, radius\n, angle\n, eps\n, gcdA\n, side\n, solute\n, Point (..)\n) where\n\nimport Data.Int\n\nnewtype Point = Point (Double, Double)\n\nradius :: Double -> Double -> Double -> Double\nradius a b c = a * b * c / (4 * sqrt (p * (p - a) * (p - b) * (p - c)))\n where\n p = (a + b + c) / 2\n\neps :: Double\neps = 1e-4\n\ngcdA :: Double -> Double -> Double\ngcdA x y | (abs x < eps) || (abs y < eps) = x + y\ngcdA x y | x > y = gcdA (decA x y) y\ngcdA x y = gcdA x (decA y x)\n\ndecA :: Double -> Double -> Double\ndecA x y = x - y * fromIntegral @Int64 (floor $ x / y)\n\nangle :: (Double, Double, Double) -> Double\nangle (a,b,c) = acos $ (a * a + b * b - c * c) / (2 * a * b)\n\nside :: (Point, Point) -> Double\nside (Point (x1, y1), Point (x2, y2)) = sqrt $ (x1 - x2) ** 2 + (y1 - y2) ** 2\n\nsolute :: Point -> Point -> Point -> Double\nsolute va vb vc = n * r * r * sin (2 * pi / n) / 2\n where\n [a, b, c] = fmap side [(va, vb), (va, vc), (vb, vc)]\n r = radius a b c\n [x, y, z] = fmap angle [(a,b,c), (b,c,a), (c,a,b)]\n n = pi / gcdA (gcdA x y) z\n\ngetPoint :: IO Point\ngetPoint = do\n [x, y] <- (map read . words) `fmap` getLine\n pure $ Point (x, y)\n\nmain :: IO ()\nmain = do\n [a, b, c] <- sequence [getPoint, getPoint, getPoint]\n print $ solute a b c"}, {"source_code": "module Main where\n\nimport Control.Monad\nimport Control.DeepSeq\nimport Data.Function\nimport Data.Ratio\nimport Data.Fixed\nimport Data.List\nimport Data.Char\n\n--import Debug.Trace\n\ntype Point = (Double, Double)\ntype Vector = (Double, Double)\n\nsameDouble :: Double -> Double -> Double -> Bool\nsameDouble a b res = -res <= a - b && a - b <= res\n\nsamePoint res ((x1, y1), (x2, y2)) = sameDouble x1 x2 res && sameDouble y1 y2 res\ndist (x1, y1) (x2, y2) = sqrt ((abs $ x1 - x2)**2 + (abs $ y1 - y2)**2)\n\nadd (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)\nhalfVec (x1, y1) (x2, y2) = ((x2 - x1) / 2, (y2 - y1) / 2)\nperpendic (x, y) = (y, -x)\nscale k (x, y) = (k * x / l, k * y / l) where\n l = dist (x, y) (0, 0)\n\n\ncenterAngle nPoly nInterval = 2 * pi * fromIntegral nInterval / fromIntegral nPoly\n\ncenterPos res p1 p2 angle\n | angle > pi = centerPos res p2 p1 (2*pi - angle)\n | sameDouble angle pi res = p1 `add` halfVec p1 p2\n | otherwise = p1 `add` c_ `add` h_ where\n c = dist p1 p2\n c_ = halfVec p1 p2\n h = c / (2 * tan (angle/2))\n h_ = scale h $ perpendic c_\n\ngetArea r nPoly = triangleArea * fromIntegral nPoly where\n theta = centerAngle nPoly 1\n triangleArea = r * r * sin theta / 2\n\ntryFit :: Double -> (Point, Point, Point) -> Int -> [Double]\ntryFit res (p1,p2,p3) 101 = []\ntryFit res (p1,p2,p3) nPoly = areas ++ tryFit res (p1,p2,p3) (nPoly+1) where\n center12 = map (\\nInterval -> centerPos res p1 p2 $ centerAngle nPoly nInterval) [1..(nPoly-1)]\n center13 = map (\\nInterval -> centerPos res p1 p3 $ centerAngle nPoly nInterval) [1..(nPoly-1)]\n centers = map fst $ nub $ filter (samePoint res) [ (c1, c2) | c1 <- center12, c2 <- center13 ]\n areas = map (\\center -> getArea (dist p1 center) nPoly) centers\n\nprocess :: [Point] -> Double\nprocess points = minimum $ tryFit res (p1,p2,p3) 3 where\n (p1:p2:[p3]) = points\n sides = [ dist x y | x <- points, y <- points, x /= y ]\n res = maximum sides * 5e-7\n\ngetWords = words <$> getLine :: IO [String]\ngetDoubles = map read <$> getWords :: IO [Double]\ntoPoint (x:[y]) = (x, y) :: Point\n\nmain = do\n points <- replicateM 3 (toPoint <$> getDoubles)\n print $ process points\n\n"}, {"source_code": "dist ( [x0,y0], [x1,y1] ) = sqrt ( ( x1 - x0 )^2 + ( y1 - y0 )^2 )\nangle (a,b,c) = acos ( ( c^2 + b^2 - a^2 ) / 2 / b / c )\nisInteger x = abs ( x - fromIntegral ( round x ) ) <= 1e-5\n\nsolve [p0,p1,p2] =\n\tlet\n\t\t[a,b,c] = map dist [ (p0,p1), (p1,p2), (p2,p0) ]\n\t\t[x,y,z] = map angle [ (a,b,c), (b,c,a), (c,a,b) ]\n\t\tr = a / 2 / sin x\n\t\tgood a = all isInteger $ map (/a) [x,y,z]\n\t\tq = 2 * ( head $ filter good $ map (pi/) [3..100] )\n\tin\n\t\tr^2 * sin q * pi / q\n\nmain = interact $ show . solve . map ( map read . words ) . lines\n"}], "negative_code": [{"source_code": "import Data.List (sort)\nimport Text.Printf (printf)\nimport Control.Monad (replicateM)\n\nnewtype Point2 a = Point2 { getPoint2 :: (a, a) } deriving (Eq, Show)\nnewtype Vector2 a = Vector2 { getVector2 :: (a, a) } deriving (Eq, Show)\ntype Line2 a = (Point2 a, Vector2 a) \ntype LineEquation2 a = (a, a, a)\n\nx :: Point2 a -> a\nx = fst . getPoint2\ny :: Point2 a -> a\ny = snd . getPoint2\n\nxv :: Vector2 a -> a\nxv = fst . getVector2\nyv :: Vector2 a -> a\nyv = snd . getVector2\n\ncomputeEq2 :: (Num a) => Line2 a -> LineEquation2 a\ncomputeEq2 (o, dir) = (a, b, c)\n where a = yv dir\n b = - (xv dir)\n c = -a * (x o) - b * (y o)\n\nperpendicularLine2 :: (Num a) => Line2 a -> Line2 a\nperpendicularLine2 (o, dir) = (o, perpendicularDir)\n where perpendicularDir = Vector2 $ (- (yv dir), xv dir)\n\nisParallel2 :: (Eq a, Num a) => Line2 a -> Line2 a -> Bool\nisParallel2 (_, dir) (_, dir') = collinear dir dir'\n\ncollinear :: (Eq a, Num a) => Vector2 a -> Vector2 a -> Bool\nu `collinear` v = u <^> v == 0\n\n(<^>) :: (Num a) => Vector2 a -> Vector2 a -> a\nu <^> v = xv u * yv v - yv u * xv v\n\nintersectLines2 :: (Eq a, Fractional a) => Line2 a -> Line2 a -> Maybe (Point2 a)\nintersectLines2 l1 l2\n | isParallel2 l1 l2 = Nothing\n | otherwise = Just $ Point2 ((c2 * b1 - c1 * b2) / det, (a2 * c1 - a1 * c2) / det)\n where (a1, b1, c1) = computeEq2 l1\n (a2, b2, c2) = computeEq2 l2\n det = a1 * b2 - a2 * b1\n\ncalcCircleCenter :: (Eq a, Fractional a) => (Point2 a) -> (Point2 a) -> (Point2 a) -> Maybe (Point2 a)\ncalcCircleCenter p1 p2 p3 = intersectLines2 pline1 pline2\n where v1' = Vector2 (x p2 - x p1, y p2 - y p1)\n v2' = Vector2 (x p3 - x p2, y p3 - y p2)\n p1' = Point2 ((x p1 + x p2) / 2, (y p1 + y p2) / 2)\n p2' = Point2 ((x p2 + x p3) / 2, (y p2 + y p3) / 2)\n line1 = (p1', v1')\n line2 = (p2', v2')\n pline1 = perpendicularLine2 line1\n pline2 = perpendicularLine2 line2\n\ncalcAngle :: (RealFloat a) => (Point2 a) -> (Point2 a) -> (Point2 a) -> Maybe a\ncalcAngle c lp rp | ll > eps && lr > eps = Just $ acos $ (ll + lr - lc) / (2 * sqrt (ll * lr)) \n | otherwise = Nothing\n where eps = 0.000001\n ll = (x lp - x c) ^ 2 + (y lp - y c) ^ 2\n lr = (x rp - x c) ^ 2 + (y rp - y c) ^ 2\n lc = (x lp - x rp) ^ 2 + (y lp - y rp) ^ 2\n\n\n\ndetDivisor :: (RealFloat a, Integral b) => a -> a -> Maybe b\ndetDivisor a1 a2 = if (length res > 0) then Just (head res) else Nothing\n where a3 = 2 * pi - a1 - a2 --the third angle\n as = [a1, a2, a3]\n res = map snd $ take 1 $ filter (\\(v,_) -> isValid v as) [(2 * pi / (fromIntegral n), n) | n <- [3..100]]\n\nisValid :: (RealFloat a) => a -> [a] -> Bool\nisValid part vals = and (map (\\v -> isClose (v / part)) vals)\n\nisClose :: (RealFloat a) => a -> Bool\nisClose v = abs (fromIntegral (round v) - v) < 0.000001\n\ncalcDistance :: (RealFloat a) => (Point2 a) -> (Point2 a) -> a\ncalcDistance p1 p2 = sqrt((x p1 - x p2) ^ 2 + (y p1 - y p2) ^ 2) \n\n-- Calc everything in the maybe monad\ncalcSquare :: (RealFloat a, Show a) => (Point2 a) -> (Point2 a) -> (Point2 a) -> Maybe a\ncalcSquare p1 p2 p3 = do\n center <- calcCircleCenter p1 p2 p3 -- find the center\n a1 <- calcAngle center p1 p2 -- find three angles\n a2 <- calcAngle center p1 p3\n a3 <- calcAngle center p2 p3\n let radius = calcDistance center p1\n let [a1',a2'] = take 2 $ sort [a1,a2,a3] \n n <- detDivisor a1' a2'\n return $ radius ^ 2 * (fromIntegral n) * sin (2 * pi / (fromIntegral n)) / 2\n\ntestCircleCenter :: Bool\ntestCircleCenter = let cc = calcCircleCenter (Point2 (0,0)) (Point2 (1,1)) (Point2 (2,0)) in cc == Just (Point2 (1,0))\n\ntestCalcSquare :: (RealFloat a, Show a) => Maybe a\ntestCalcSquare = sq\n where p1 = Point2 (0,0)\n p2 = Point2 (1,1)\n p3 = Point2 (0,1)\n sq = calcSquare p1 p2 p3\n \nmain :: IO ()\nmain = replicateM 3 getLine >>= return.map parsePoint >>= (\\[p1,p2,p3] -> return $ calcSquare p1 p2 p3) >>=\n (\\sq -> case sq of Just s -> putStrLn $ show s\n Nothing -> putStrLn \"Error\")\n\nparsePoint :: (RealFloat a, Read a) => String -> (Point2 a)\nparsePoint str = Point2 (x,y)\n where [x,y] = map read (words str)\n\n"}, {"source_code": "import Data.Function(on)\nimport Data.List(sort)\nimport Data.Maybe(fromMaybe)\nimport Control.Monad(replicateM)\n\neps = 1e-5\ndist (x1, y1) (x2, y2) = sqrt (on (+) (^2) (x2 - x1) (y2 - y1))\nrad a b c = a * b * c / (4 * sqrt(p * (p - a) * (p - b) * (p - c)))\n where p = (a + b + c) / 2\n\nangle ll lr lc = acos ((ll ^ 2 + lr ^ 2 - lc ^ 2) / (2 * ll * lr))\n\ncheckAngle :: [Double] -> Integer -> Bool\ncheckAngle angles n = isValidAngles angles (2 * pi / (fromIntegral n))\n\nisValidAngles :: [Double] -> Double -> Bool\nisValidAngles angles part = and (map (isValid part) angles)\n\nisValid angle part = isClose (angle / part)\nisClose v = abs (fromIntegral (round v) - v) < eps\n\ngetN :: Double -> Double -> Double -> Maybe Integer\ngetN a b c = case (take 1 $ filter (checkAngle [a1', a2']) [3..100]) of\n [] -> Nothing\n n:_ -> Just n\n where r = rad a b c\n a1 = angle r r a \n a2 = angle r r b\n a3 = angle r r c\n a1':a2':_ = sort [a1,a2,a3]\n\ngetSq p1 p2 p3 = sq n r\n where sq n r' = (fromIntegral n) * r' * r' * sin (2 * pi / (fromIntegral n)) / 2\n a = dist p1 p2\n b = dist p2 p3\n c = dist p3 p1\n r = rad a b c\n n = fromMaybe 1 $ getN a b c\n\nparseP :: String -> (Double, Double)\nparseP str = (x,y)\n where [x, y] = map read (words str)\n\nmain :: IO()\nmain = do\n p1l <- getLine\n p2l <- getLine\n p3l <- getLine\n print $ getSq (parseP p1l) (parseP p2l) (parseP p3l)\n\n"}, {"source_code": "{-\n Find the area of the minimum regular polygon given three random vertices of\n said polygon\n-}\n\ncircumRadius tot@[a,b,c] = (product tot) / sqrt ((a + b + c) * (b + c - a) * (c + a - b) * (a + b - c))\n\nangleA [a,b,c] = acos ((b^2 + c^2 - a^2) / (2*b*c))\nangleB [a,b,c] = angleA [b,c,a]\nangleC [a,b,c] = angleA [c,a,b]\n\ndblGCD :: Double -> Double -> Double -> Double\ndblGCD m n e \n | abs m > e && abs n > e = if m > n \n then dblGCD (m - (fromIntegral . floor $ (m/n)) * n) n e\n else dblGCD m (n - (fromIntegral . floor $ (n/m)) * m) e\n | otherwise = m + n\n\narea s t u r = n / (2 * r^2 * sin(2*pi/n))\n where n = pi / (dblGCD (dblGCD s t 10**(-4)) u 10**(-4))\n\n\nmain = do\n c1 <- getLine\n c2 <- getLine\n c3 <- getLine\n let co = map ((\\[x,y] -> (x,y)) . map read . words) [c1,c2,c3] :: [(Double,Double)]\n let sl = zipWith (\\(x1,y1) (x2,y2) -> sqrt ((x1 - x2)^2 + (y1 - y2)^2)) co (tail $ cycle co)\n putStrLn . show $ area (angleA sl) (angleB sl) (angleC sl) (circumRadius sl)"}, {"source_code": "module Main (main) where\n\nimport Text.Printf\n\ndata Point = Point Double Double\ndata Line = Line Double Double Double\n\ninstance Show Point where\n show (Point x y) = \"{\" ++ show x ++ \", \" ++ show y ++ \"}\"\n\ninstance Show Line where\n show (Line a b c) = \"{(\" ++ show a ++ \")*x + (\" ++ show b ++ \")*y + (\" ++ show c ++ \") = 0}\"\n\n-- прямая по двум точкам в виде Ax+By+C=0\ncreateLine (Point x1 y1) (Point x2 y2) = (Line a b c) where\n a = y1-y2\n b = x2-x1\n c = x1*y2 - x2*y1\n\n-- серединный перпендикуляр по двум точкам в виде Ax+By+C=0\nmidLine (Point x1 y1) (Point x2 y2) = (Line (-b) a (b*x0 - a*y0)) where\n a = y1-y2\n b = x2-x1\n x0 = (x2+x1)/2\n y0 = (y2+y1)/2\n\n-- угол между двумя прямыми\nangleLines (Line a1 b1 c1) (Line a2 b2 c2) = atan2 (a1*b2 - a2*b1) (a1*a2 + b1*b2)\n\n-- угол между тремя точками (пересекающимися прямыми в первой точке)\nanglePoints pCenter p1 p2 = angleLines (createLine pCenter p1) (createLine pCenter p2)\n\n-- пересечение двух прямых\ninterLines (Line a1 b1 c1) (Line a2 b2 c2) = (Point (dx/dxy) (dy/dxy)) where\n dx = b1*c2 - b2*c1\n dy = c1*a2 - c2*a1\n dxy = a1*b2 - a2*b1\n\n-- расстояние между точками\ndist (Point x1 y1) (Point x2 y2) = sqrt (dx*dx + dy*dy) where\n dx = x1-x2\n dy = y1-y2\n\nmain = do\n instr <- getContents\n let [p1, p2, p3] = map readPoint $ take 3 $ lines instr\n let center = interLines (midLine p1 p2) (midLine p2 p3)\n printf \"%.8f\\n\" $ squarePoli \n (dist p1 center) \n (findMinPoli (anglePoints center p1 p2) (anglePoints center p2 p3)) where\n \n -- площать многоугольника через радиус и количество углов\n squarePoli :: Double -> Int -> Double\n squarePoli r n = n2 * r*r * (sin (pi/n2)) where\n n2 = (fromIntegral n)/2\n \n -- сколько углов в минимальном многоугольнике с такими внутренними углами?\n findMinPoli :: Double -> Double -> Int\n findMinPoli a b = findMinPoli' 3 where\n \n findMinPoli' :: Int -> Int\n findMinPoli' n | n>=100 = 100\n findMinPoli' n = if (nearlyInt (a*n')) && (nearlyInt (b*n'))\n then n\n else findMinPoli' (n+1) where\n n' = (fromIntegral n)/(pi*2)\n \n nearlyInt :: Double -> Bool\n nearlyInt d = (abs (d - (fromIntegral (round d)))) < 0.000001\n\n-- input\nreadDouble :: String -> Double\nreadDouble = read\n\nreadPoint :: String -> Point\nreadPoint ss = (Point (coords!!0) (coords!!1)) where\n coords = map readDouble $ words ss\n"}, {"source_code": "module Main (main) where\n\nimport Text.Printf\n\ndata Point = Point Double Double\ndata Line = Line Double Double Double\n\ninstance Show Point where\n show (Point x y) = \"{\" ++ show x ++ \", \" ++ show y ++ \"}\"\n\ninstance Show Line where\n show (Line a b c) = \"{(\" ++ show a ++ \")*x + (\" ++ show b ++ \")*y + (\" ++ show c ++ \") = 0}\"\n\n-- прямая по двум точкам в виде Ax+By+C=0\ncreateLine (Point x1 y1) (Point x2 y2) = (Line a b c) where\n a = y1-y2\n b = x2-x1\n c = x1*y2 - x2*y1\n\n-- серединный перпендикуляр по двум точкам в виде Ax+By+C=0\nmidLine (Point x1 y1) (Point x2 y2) = (Line (-b) a (b*x0 - a*y0)) where\n a = y1-y2\n b = x2-x1\n x0 = (x2+x1)/2\n y0 = (y2+y1)/2\n\n-- угол между двумя прямыми\nangleLines (Line a1 b1 c1) (Line a2 b2 c2) = atan2 (a1*b2 - a2*b1) (a1*a2 + b1*b2)\n\n-- угол между тремя точками (пересекающимися прямыми в первой точке)\nanglePoints pCenter p1 p2 = angleLines (createLine pCenter p1) (createLine pCenter p2)\n\n-- пересечение двух прямых\ninterLines (Line a1 b1 c1) (Line a2 b2 c2) = (Point (dx/dxy) (dy/dxy)) where\n dx = b1*c2 - b2*c1\n dy = c1*a2 - c2*a1\n dxy = a1*b2 - a2*b1\n\n-- расстояние между точками\ndist (Point x1 y1) (Point x2 y2) = sqrt (dx*dx + dy*dy) where\n dx = x1-x2\n dy = y1-y2\n\nmain = do\n instr <- getContents\n let [p1, p2, p3] = map readPoint $ take 3 $ lines instr\n let center = interLines (midLine p1 p2) (midLine p2 p3)\n printf \"%.8f\\n\" $ squarePoli \n (dist p1 center) \n (findMinPoli (anglePoints center p1 p2) (anglePoints center p2 p3)) where\n \n -- площать многоугольника через радиус и количество углов\n squarePoli :: Double -> Int -> Double\n squarePoli r n = n2 * r*r * (sin (pi/n2)) where\n n2 = (fromIntegral n)/2\n \n -- сколько углов в минимальном многоугольнике с такими внутренними углами?\n findMinPoli :: Double -> Double -> Int\n findMinPoli a b = findMinPoli' 3 where\n \n findMinPoli' :: Int -> Int\n findMinPoli' n | n>=100 = 100\n findMinPoli' n = if (nearlyInt (a*n')) && (nearlyInt (b*n'))\n then n\n else findMinPoli' (n+1) where\n n' = (fromIntegral n)/(pi*2)\n \n nearlyInt :: Double -> Bool\n nearlyInt d = (abs (d - (fromIntegral (round d)))) < 0.00000001\n\n-- input\nreadDouble :: String -> Double\nreadDouble = read\n\nreadPoint :: String -> Point\nreadPoint ss = (Point (coords!!0) (coords!!1)) where\n coords = map readDouble $ words ss\n"}, {"source_code": "\nimport Control.Monad\nimport Debug.Trace\n\nmyTrace x = traceShow x x\n\ndata Point = Point Double Double\n\tderiving (Eq, Show)\n\nvmul scalar (Point x y) = Point (scalar * x) (scalar * y)\nvadd (Point x1 y1) (Point x2 y2) = Point (x1 + x2) (y1 + y2)\nvsub (Point x1 y1) (Point x2 y2) = Point (x1 - x2) (y1 - y2)\nvdot (Point x1 y1) (Point x2 y2) = x1 * x2 + y1 * y2\nvabs p = distanceBetween p (Point 0 0)\n\ndistanceBetween (Point x1 y1) (Point x2 y2) = sqrt $ sqr (x2 - x1) + sqr (y2 - y1)\nsqr x = x * x\n\n\ngetPoint = do\n\txy <- (liftM words) getLine\n\treturn $ Point (parse (xy !! 0)) (parse (xy !! 1))\n\twhere\n\t\tparse :: String -> Double\n\t\tparse = read\n\ngetInput :: IO (Point, Point, Point)\ngetInput = do\n\ta1 <- getPoint\n\ta2 <- getPoint\n\ta3 <- getPoint\n\treturn (a1, a2, a3)\n\ntriangleArea a1 a2 a3 = sqrt $ p * (p - a) * (p - b) * (p - c)\n\twhere\n\t\ta = distanceBetween a2 a3\n\t\tb = distanceBetween a1 a3\n\t\tc = distanceBetween a1 a2\n\t\tp = (a + b + c) / 2\n\ncenterOf points@(a1, a2, a3) = (aa `vmul` a1) `vadd` (ab `vmul` a2) `vadd` (ac `vmul` a3)\n\twhere\n\t\taa = (sqr $ distanceBetween a2 a3) / (8 * sqr area) * vdot (a1 `vsub` a2) (a1 `vsub` a3)\n\t\tab = (sqr $ distanceBetween a1 a3) / (8 * sqr area) * vdot (a2 `vsub` a1) (a2 `vsub` a3)\n\t\tac = (sqr $ distanceBetween a1 a2) / (8 * sqr area) * vdot (a3 `vsub` a1) (a3 `vsub` a2)\n\t\tarea = triangleArea a1 a2 a3\n\nareaOfRegularPolygon :: Int -> Double -> Double\nareaOfRegularPolygon n r = fromIntegral (n `div` 2) * sqr r * sin (2 * pi / fromIntegral n)\n\ngetNumberOfSides :: Double -> (Point, Point, Point) -> Int\ngetNumberOfSides r points@(a1, a2, a3) = n\n\twhere\n\t\t(p1, p2, p3, n) = head $ filter almostIntegerTriple omega\n\t\talmostIntegerTriple (a, b, c, _) = almostInteger a && almostInteger b && almostInteger c\n\t\talmostInteger x = abs (x - (fromIntegral $ round x)) < 0.00001\n\t\tcenter = centerOf points\n\t\talpha = normalize $ acos $ (a `vdot` b) / (vabs a * vabs b)\n\t\tbeta = normalize $ acos $ (b `vdot` c) / (vabs b * vabs c)\n\t\tgamma = normalize $ acos $ (c `vdot` a) / (vabs c * vabs a)\n\t\ta = a1 `vsub` center\n\t\tb = a2 `vsub` center\n\t\tc = a3 `vsub` center\n\t\tomega = [(sin (fromIntegral i * alpha / 2),\n\t\t\tsin (fromIntegral i * beta / 2),\n\t\t\tsin (fromIntegral i * gamma / 2), i) | i <- [3..]]\n\t\tnormalize x\n\t\t\t| x < 0 = x + 2 * pi\n\t\t\t| otherwise = x\n\nmain = do\n\tpoints@(a1, a2, a3) <- getInput\n\tlet center = centerOf points\n\tlet r = distanceBetween a1 center\n\tlet n = getNumberOfSides r points\n\tprint $ areaOfRegularPolygon n r\n\n\n"}, {"source_code": "\nimport Control.Monad\nimport Debug.Trace\n\ndata Point = Point Double Double\n\tderiving (Eq, Show)\n\nvmul scalar (Point x y) = Point (scalar * x) (scalar * y)\nvadd (Point x1 y1) (Point x2 y2) = Point (x1 + x2) (y1 + y2)\nvsub (Point x1 y1) (Point x2 y2) = Point (x1 - x2) (y1 - y2)\nvdot (Point x1 y1) (Point x2 y2) = x1 * x2 + y1 * y2\n\ndistanceBetween (Point x1 y1) (Point x2 y2) = sqrt $ sqr (x2 - x1) + sqr (y2 - y1)\nsqr x = x * x\n\ngetPoint = do\n\txy <- (liftM words) getLine\n\treturn $ Point (parse (xy !! 0)) (parse (xy !! 1))\n\twhere\n\t\tparse :: String -> Double\n\t\tparse = read\n\ngetInput :: IO (Point, Point, Point)\ngetInput = do\n\ta1 <- getPoint\n\ta2 <- getPoint\n\ta3 <- getPoint\n\treturn (a1, a2, a3)\n\ntriangleArea a1 a2 a3 = sqrt $ p * (p - a) * (p - b) * (p - c)\n\twhere\n\t\ta = distanceBetween a2 a3\n\t\tb = distanceBetween a1 a3\n\t\tc = distanceBetween a1 a2\n\t\tp = (a + b + c) / 2\n\ncenterOf points@(a1, a2, a3) = (aa `vmul` a1) `vadd` (ab `vmul` a2) `vadd` (ac `vmul` a3)\n\twhere\n\t\taa = (sqr $ distanceBetween a2 a3) / (8 * sqr area) * vdot (a1 `vsub` a2) (a1 `vsub` a3)\n\t\tab = (sqr $ distanceBetween a1 a3) / (8 * sqr area) * vdot (a2 `vsub` a1) (a2 `vsub` a3)\n\t\tac = (sqr $ distanceBetween a1 a2) / (8 * sqr area) * vdot (a3 `vsub` a1) (a3 `vsub` a2)\n\t\tarea = triangleArea a1 a2 a3\n\nareaOfRegularPolygon :: Int -> Double -> Double\nareaOfRegularPolygon n r = fromIntegral (n `div` 2) * sqr r * sin (2 * pi / fromIntegral n)\n\ngetNumberOfSides :: Double -> (Point, Point, Point) -> Int\ngetNumberOfSides r points@(a1, a2, a3) = n\n\twhere\n\t\t(p1, p2, p3, n) = head $ filter almostIntegerTriple (traceShow (take 10 omega) omega)\n\t\talmostIntegerTriple (a, b, c, _) = almostInteger a && almostInteger b && almostInteger c\n\t\talmostInteger x = abs (x - (fromIntegral $ round x)) < 0.00001\n\t\talpha = normalize $ acos $ ((a1 `vsub` a2) `vdot` (a1 `vsub` a3)) / (b * c)\n\t\tbeta = normalize $ acos $ ((a2 `vsub` a1) `vdot` (a2 `vsub` a3)) / (a * c)\n\t\tgamma = normalize $ acos $ ((a3 `vsub` a1) `vdot` (a3 `vsub` a2)) / (a * b)\n\t\ta = distanceBetween a2 a3\n\t\tb = distanceBetween a1 a3\n\t\tc = distanceBetween a1 a2\n\t\tomega = [(alpha / (pi / fromIntegral i),\n\t\t\tbeta / (pi / fromIntegral i),\n\t\t\tgamma / (pi / fromIntegral i), i) | i <- [3..]]\n\t\tnormalize x\n\t\t\t| x < 0 = x + 2 * pi\n\t\t\t| otherwise = x\n\nmain = do\n\tpoints@(a1, a2, a3) <- getInput\n\tlet center = centerOf points\n\tlet r = distanceBetween a1 center\n\tlet n = getNumberOfSides r points\n\tprint n\n\tprint $ areaOfRegularPolygon n r\n\n\n"}, {"source_code": "\nimport Control.Monad\nimport Debug.Trace\n\nmyTrace x = traceShow x x\n\ndata Point = Point Double Double\n\tderiving (Eq, Show)\n\nvmul scalar (Point x y) = Point (scalar * x) (scalar * y)\nvadd (Point x1 y1) (Point x2 y2) = Point (x1 + x2) (y1 + y2)\nvsub (Point x1 y1) (Point x2 y2) = Point (x1 - x2) (y1 - y2)\nvdot (Point x1 y1) (Point x2 y2) = x1 * x2 + y1 * y2\nvabs p = distanceBetween p (Point 0 0)\n\ndistanceBetween (Point x1 y1) (Point x2 y2) = sqrt $ sqr (x2 - x1) + sqr (y2 - y1)\nsqr x = x * x\n\n\ngetPoint = do\n\txy <- (liftM words) getLine\n\treturn $ Point (parse (xy !! 0)) (parse (xy !! 1))\n\twhere\n\t\tparse :: String -> Double\n\t\tparse = read\n\ngetInput :: IO (Point, Point, Point)\ngetInput = do\n\ta1 <- getPoint\n\ta2 <- getPoint\n\ta3 <- getPoint\n\treturn (a1, a2, a3)\n\ntriangleArea a1 a2 a3 = sqrt $ p * (p - a) * (p - b) * (p - c)\n\twhere\n\t\ta = distanceBetween a2 a3\n\t\tb = distanceBetween a1 a3\n\t\tc = distanceBetween a1 a2\n\t\tp = (a + b + c) / 2\n\ncenterOf points@(a1, a2, a3) = (aa `vmul` a1) `vadd` (ab `vmul` a2) `vadd` (ac `vmul` a3)\n\twhere\n\t\taa = (sqr $ distanceBetween a2 a3) / (8 * sqr area) * vdot (a1 `vsub` a2) (a1 `vsub` a3)\n\t\tab = (sqr $ distanceBetween a1 a3) / (8 * sqr area) * vdot (a2 `vsub` a1) (a2 `vsub` a3)\n\t\tac = (sqr $ distanceBetween a1 a2) / (8 * sqr area) * vdot (a3 `vsub` a1) (a3 `vsub` a2)\n\t\tarea = triangleArea a1 a2 a3\n\nareaOfRegularPolygon :: Int -> Double -> Double\nareaOfRegularPolygon n r = fromIntegral (n `div` 2) * sqr r * sin (2 * pi / fromIntegral n)\n\ngetNumberOfSides :: Double -> (Point, Point, Point) -> Int\ngetNumberOfSides r points@(a1, a2, a3) = n\n\twhere\n\t\t(p1, p2, p3, n) = head $ filter almostIntegerTriple omega\n\t\talmostIntegerTriple (a, b, c, _) = almostInteger a && almostInteger b && almostInteger c\n\t\talmostInteger x = abs x < 0.00001\n\t\tcenter = centerOf points\n\t\talpha = normalize $ acos $ (a `vdot` b) / (vabs a * vabs b)\n\t\tbeta = normalize $ acos $ (b `vdot` c) / (vabs b * vabs c)\n\t\tgamma = normalize $ acos $ (c `vdot` a) / (vabs c * vabs a)\n\t\ta = a1 `vsub` center\n\t\tb = a2 `vsub` center\n\t\tc = a3 `vsub` center\n\t\tomega = [(sin (fromIntegral i * alpha / 2),\n\t\t\tsin (fromIntegral i * beta / 2),\n\t\t\tsin (fromIntegral i * gamma / 2), i) | i <- [3..]]\n\t\tnormalize x\n\t\t\t| x < 0 = x + 2 * pi\n\t\t\t| otherwise = x\n\nmain = do\n\tpoints@(a1, a2, a3) <- getInput\n\tlet center = centerOf points\n\tlet r = distanceBetween a1 center\n\tlet n = getNumberOfSides r points\n\tprint $ areaOfRegularPolygon n r\n\n\n"}, {"source_code": "\nimport Control.Monad\nimport Debug.Trace\n\ndata Point = Point Double Double\n\tderiving (Eq, Show)\n\nvmul scalar (Point x y) = Point (scalar * x) (scalar * y)\nvadd (Point x1 y1) (Point x2 y2) = Point (x1 + x2) (y1 + y2)\nvsub (Point x1 y1) (Point x2 y2) = Point (x1 - x2) (y1 - y2)\nvdot (Point x1 y1) (Point x2 y2) = x1 * x2 + y1 * y2\n\ndistanceBetween (Point x1 y1) (Point x2 y2) = sqrt $ sqr (x2 - x1) + sqr (y2 - y1)\nsqr x = x * x\n\ngetPoint = do\n\txy <- (liftM words) getLine\n\treturn $ Point (parse (xy !! 0)) (parse (xy !! 1))\n\twhere\n\t\tparse :: String -> Double\n\t\tparse = read\n\ngetInput :: IO (Point, Point, Point)\ngetInput = do\n\ta1 <- getPoint\n\ta2 <- getPoint\n\ta3 <- getPoint\n\treturn (a1, a2, a3)\n\ntriangleArea a1 a2 a3 = sqrt $ p * (p - a) * (p - b) * (p - c)\n\twhere\n\t\ta = distanceBetween a2 a3\n\t\tb = distanceBetween a1 a3\n\t\tc = distanceBetween a1 a2\n\t\tp = (a + b + c) / 2\n\ncenterOf points@(a1, a2, a3) = (aa `vmul` a1) `vadd` (ab `vmul` a2) `vadd` (ac `vmul` a3)\n\twhere\n\t\taa = (sqr $ distanceBetween a2 a3) / (8 * sqr area) * vdot (a1 `vsub` a2) (a1 `vsub` a3)\n\t\tab = (sqr $ distanceBetween a1 a3) / (8 * sqr area) * vdot (a2 `vsub` a1) (a2 `vsub` a3)\n\t\tac = (sqr $ distanceBetween a1 a2) / (8 * sqr area) * vdot (a3 `vsub` a1) (a3 `vsub` a2)\n\t\tarea = triangleArea a1 a2 a3\n\nareaOfRegularPolygon :: Int -> Double -> Double\nareaOfRegularPolygon n r = fromIntegral (n `div` 2) * sqr r * sin (2 * pi / fromIntegral n)\n\ngetNumberOfSides :: Double -> (Point, Point, Point) -> Int\ngetNumberOfSides r points@(a1, a2, a3) = n\n\twhere\n\t\t(p1, p2, p3, n) = head $ filter almostIntegerTriple omega\n\t\talmostIntegerTriple (a, b, c, _) = almostInteger a && almostInteger b && almostInteger c\n\t\talmostInteger x = abs (x - (fromIntegral $ round x)) < 0.00001\n\t\talpha = normalize $ acos $ ((a1 `vsub` a2) `vdot` (a1 `vsub` a3)) / (b * c)\n\t\tbeta = normalize $ acos $ ((a2 `vsub` a1) `vdot` (a2 `vsub` a3)) / (a * c)\n\t\tgamma = normalize $ acos $ ((a3 `vsub` a1) `vdot` (a3 `vsub` a2)) / (a * b)\n\t\ta = distanceBetween a2 a3\n\t\tb = distanceBetween a1 a3\n\t\tc = distanceBetween a1 a2\n\t\tomega = [(alpha / (pi / fromIntegral i),\n\t\t\tbeta / (pi / fromIntegral i),\n\t\t\tgamma / (pi / fromIntegral i), i) | i <- [3..]]\n\t\tnormalize x\n\t\t\t| x < 0 = x + 2 * pi\n\t\t\t| otherwise = x\n\nmain = do\n\tpoints@(a1, a2, a3) <- getInput\n\tlet center = centerOf points\n\tlet r = distanceBetween a1 center\n\tlet n = getNumberOfSides r points\n\tprint $ areaOfRegularPolygon n r\n\n\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -XNoMonomorphismRestriction #-}\n{-# LANGUAGE BangPatterns #-}\n{-(c) gorlum0 [at] gmail.com-}\nimport qualified Data.ByteString.Char8 as BS\nimport Data.List\nimport Data.Array\nimport Data.Char\nimport Control.Monad\nimport Debug.Trace (trace)\nimport Data.Maybe (fromJust)\nimport Text.Printf (printf)\n\ndist [x1,y1] [x2,y2] = sqrt $ (x1-x2)**2 + (y1-y2)**2\n\nisInteger x = abs (x - (fI . round) x) <= 1e-5\n\narea [p1, p2, p3] = fI n * r*r/2 * sin(2*pi/fI n)\n where\n a = dist p1 p2\n b = dist p2 p3\n c = dist p1 p3\n s = (a+b+c) / 2\n r = a*b*c / 4 / sqrt(s*(s-a)*(s-b)*(s-c))\n alpha = acos $ 1 - 0.5*a**2/r**2\n beta = acos $ 1 - 0.5*b**2/r**2\n gamma = acos $ 1 - 0.5*c**2/r**2\n fits n = all isInteger $ map (/(pi/fI n)) [alpha, beta, gamma]\n (n:_) = filter fits [3..]\n\nmain = do\n ls <- lines `fmap` getContents\n let xss = map (map read . words) ls :: [[Double]]\n forM_ (splitEvery 3 xss) $\n print . area\n\nreadNum = fst . fromJust . BS.readInteger\nfI = fromIntegral\n--- debug = flip trace\ntraceShow = trace . show\ndebug = flip traceShow\ninfixr 1 `debug2`\ndebug2 x msg = flip trace x (printf \"%s: %s\" msg $ show x)\n\ninfixr 1 ?\nTrue ? x = const x\nFalse ? _ = id\n\nsplitEvery _ [] = []\nsplitEvery n xs = ys : splitEvery n xs'\n where (ys, xs') = splitAt (fI n) xs\n"}, {"source_code": "-- Codeforces 1C\n\n{-# LANGUAGE MultiWayIf #-}\n\nimport qualified Data.ByteString.Char8 as BC\nimport Data.Fixed (mod')\nimport Text.Printf\n\nmain :: IO ()\nmain = BC.getContents >>= solve . map (read . BC.unpack) . BC.words >>= printf \"%.6f\"\n\nsolve :: [Double] -> IO Double\nsolve [x1, y1, x2, y2, x3, y3] = do\n let ab = (x2 - x1, y2 - y1)\n ac = (x3 - x1, y3 - y1)\n bc = (x3 - x2, y3 - y2)\n let r1 = sqrt $ dist ab\n r2 = sqrt $ dist ac\n r3 = sqrt $ dist bc\n let cc = (r1 + r2 + r3) / 2\n ss = sqrt (cc * (cc - r1) * (cc - r2) * (cc - r3)) -- 面积\n r = r1 * r2 * r3 / (4 * ss) -- 外接圆外径\n let delta1 = acos (1 - r1 * r1 / (2 * r * r))\n delta2 = acos (1 - r2 * r2 / (2 * r * r))\n delta3 = 2 * pi - delta1 - delta2\n let delta = fgcd delta1 (fgcd delta2 delta3) -- 一条边对应的圆心角\n n = fromIntegral $ round $ 2 * pi / delta\n return $ 0.5 * r * r * sin delta * n\n\n where\n dist (u1, v1) = u1 * u1 + v1 * v1\n\n fgcd a b | a < 1e-4 = b\n | b < 1e-4 = a\n | otherwise = fgcd b (a `mod'` b)\n"}, {"source_code": "-- Codeforces 1C\n\n{-# LANGUAGE MultiWayIf #-}\n\nimport qualified Data.ByteString.Char8 as BC\nimport Data.Fixed (mod')\nimport Text.Printf\n\nmain :: IO ()\nmain = BC.getContents >>= solve . map (read . BC.unpack) . BC.words >>= printf \"%.6f\"\n\nsolve :: [Double] -> IO Double\nsolve [x1, y1, x2, y2, x3, y3] = do\n let ab = (x2 - x1, y2 - y1)\n ac = (x3 - x1, y3 - y1)\n ba = (x1 - x2, y1 - y2)\n bc = (x3 - x2, y3 - y2)\n ca = (x1 - x3, y1 - y3)\n cb = (x2 - x3, y2 - y3)\n let r1 = dist ab\n r2 = dist ac\n r3 = dist bc\n cc = (r1 + r2 + r3) / 2\n ss = sqrt (cc * (cc - r1) * (cc - r2) * (cc - r3)) -- 面积\n r = r1 * r2 * r3 / (4 * ss) -- 外接圆外径\n let delta1 = acos (1 - r1 * r1 / (2 * r * r))\n delta2 = acos (1 - r2 * r2 / (2 * r * r))\n delta3 = acos (1 - r3 * r3 / (2 * r * r))\n let delta = fgcd delta1 (fgcd delta2 delta3) -- 一条边对应的圆心角\n n = 2 * pi / delta\n return $ 0.5 * r * r * sin delta * n\n\n where\n dist (u1, v1) = sqrt $ u1 * u1 + v1 * v1\n inner (u1, v1) (u2, v2) = u1 * u2 + v1 * v2\n\n fgcd a b | a < 1e-4 = b\n | b < 1e-4 = a\n | otherwise = fgcd b (a `mod'` b)\n"}, {"source_code": "-- Codeforces 1C\n\nimport qualified Data.ByteString.Char8 as BC\nimport Text.Printf\n\nmain :: IO ()\nmain = BC.getContents >>= solve . map (read . BC.unpack) . BC.words >>= printf \"%.6f\"\n\nsolve :: [Double] -> IO Double\nsolve [x1, y1, x2, y2, x3, y3] = do\n let ab = (x2 - x1, y2 - y1)\n ac = (x3 - x1, y3 - y1)\n ba = (x1 - x2, y1 - y2)\n bc = (x3 - x2, y3 - y2)\n ca = (x1 - x3, y1 - y3)\n cb = (x2 - x3, y2 - y3)\n let delta1 = acos (inner ab ac / (dist ab * dist ac))\n delta2 = acos (inner ba bc / (dist ba * dist bc))\n delta3 = acos (inner ca cb / (dist ca * dist cb))\n n <- go delta1 delta2 delta3 3\n let x = minimum [dist ab, dist ac, dist bc]\n n' = fromIntegral n\n return $ x * x / 4 / tan (pi / n') * n'\n\n where\n dist (u1, v1) = sqrt $ u1 * u1 + v1 * v1\n inner (u1, v1) (u2, v2) = u1 * u2 + v1 * v2\n\n divided a b = let r = a / b in abs (fromInteger (round r) - r) < 1e-6\n\n go delta1 delta2 delta3 k = do\n let kx = pi / (fromIntegral k) -- 每个内角 n-2 等分大小为:180 / n\n if divided delta1 kx && divided delta1 kx && divided delta1 kx\n then return k\n else if k > 100 then return k else go delta1 delta2 delta3 (k + 1)\n"}, {"source_code": "-- Codeforces 1C\n\nimport qualified Data.ByteString.Char8 as BC\nimport Text.Printf\n\nmain :: IO ()\nmain = BC.getContents >>= solve . map (read . BC.unpack) . BC.words >>= printf \"%.6f\"\n\nsolve :: [Double] -> IO Double\nsolve [x1, y1, x2, y2, x3, y3] = do\n let ab = (x2 - x1, y2 - y1)\n ac = (x3 - x1, y3 - y1)\n ba = (x1 - x2, y1 - y2)\n bc = (x3 - x2, y3 - y2)\n ca = (x1 - x3, y1 - y3)\n cb = (x2 - x3, y2 - y3)\n let delta1 = acos (inner ab ac / (dist ab * dist ac))\n delta2 = acos (inner ba bc / (dist ba * dist bc))\n delta3 = acos (inner ca cb / (dist ca * dist cb))\n let delta = minimum [delta1, delta2, delta3]\n n = round (pi / delta)\n let x = minimum [dist ab, dist ac, dist bc]\n n' = fromIntegral n\n return $ x * x / 4 / tan (pi / n') * n'\n\n where\n dist (u1, v1) = sqrt $ u1 * u1 + v1 * v1\n inner (u1, v1) (u2, v2) = u1 * u2 + v1 * v2\n"}, {"source_code": "(⋅) = (*)\n\n𝜋 = pi\n𝜀 = 0.00001 -- epsilon. don't set this value too small!\n\n𝘥 (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) = sqrt $ (𝑥₁ - 𝑥₂)⋅(𝑥₁ - 𝑥₂) + (𝑦₁ - 𝑦₂)⋅(𝑦₁ - 𝑦₂)\n\n𝜃 (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) | abs (𝑥₂ - 𝑥₁) < 𝜀 = 𝜋/2\n | 𝑥₁ > 𝑥₂ = 𝜋 + atan ((𝑦₂ - 𝑦₁)/(𝑥₂ - 𝑥₁))\n | otherwise = atan ((𝑦₂ - 𝑦₁)/(𝑥₂ - 𝑥₁))\n\n𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) = if 𝛾 < 𝜀 then 𝜋 else 𝛾\n where\n 𝛾 = abs $ 𝜃 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) - 𝜃 (𝑥ᵣ, 𝑦ᵣ) (𝑥₂, 𝑦₂)\n\n𝘧𝘨𝘤𝘥 𝛼 𝛽 | abs 𝛼 < 𝜀 = 𝛽\n | 𝛼 > 𝛽 = 𝘧𝘨𝘤𝘥 𝛽 𝛼\n | otherwise = 𝘧𝘨𝘤𝘥 (𝛽 - 𝛼) 𝛼\n\nmain = do\n -- Read 3 vertices\n line₁ <- getLine\n let 𝑥₁ = read (words line₁ !! 0) :: Double\n let 𝑦₁ = read (words line₁ !! 1) :: Double\n line₂ <- getLine\n let 𝑥₂ = read (words line₂ !! 0) :: Double\n let 𝑦₂ = read (words line₂ !! 1) :: Double\n line₃ <- getLine\n let 𝑥₃ = read (words line₃ !! 0) :: Double\n let 𝑦₃ = read (words line₃ !! 1) :: Double\n\n -- Find the center (𝑥ᵣ, 𝑦ᵣ)\n let 𝑎₁₂ = 𝑥₁ - 𝑥₂\n let 𝑏₁₂ = 𝑦₁ - 𝑦₂\n let 𝑐₁₂ = (𝑥₁⋅𝑥₁ - 𝑥₂⋅𝑥₂ + 𝑦₁⋅𝑦₁ - 𝑦₂⋅𝑦₂) / 2\n let 𝑎₁₃ = 𝑥₁ - 𝑥₃\n let 𝑏₁₃ = 𝑦₁ - 𝑦₃\n let 𝑐₁₃ = (𝑥₁⋅𝑥₁ - 𝑥₃⋅𝑥₃ + 𝑦₁⋅𝑦₁ - 𝑦₃⋅𝑦₃) / 2\n let 𝑥ᵣ = (𝑏₁₃⋅𝑐₁₂ - 𝑏₁₂⋅𝑐₁₃) / (𝑎₁₂⋅𝑏₁₃ - 𝑎₁₃⋅𝑏₁₂)\n let 𝑦ᵣ = (𝑎₁₂⋅𝑐₁₃ - 𝑎₁₃⋅𝑐₁₂) / (𝑎₁₂⋅𝑏₁₃ - 𝑎₁₃⋅𝑏₁₂)\n\n -- Determine number of edges 𝑛 and circumradius 𝑟\n let 𝛿₁₂ = 𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂)\n let 𝛿₁₃ = 𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₃, 𝑦₃)\n let 𝜂 = 𝘧𝘨𝘤𝘥 𝛿₁₂ 𝛿₁₃\n let 𝑛 = round $ 2⋅𝜋 / 𝜂\n let 𝑟 = 𝘥 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁)\n let 𝒂 = fromInteger 𝑛⋅𝑟⋅𝑟⋅sin (𝜂/2)⋅cos (𝜂/2)\n print 𝒂\n"}, {"source_code": "(⋅) = (*)\n\n𝜋 = pi\n𝜀 = 0.00001 -- epsilon. do not set this value too small\n\n𝘥 (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) = sqrt $ (𝑥₁ - 𝑥₂)⋅(𝑥₁ - 𝑥₂) + (𝑦₁ - 𝑦₂)⋅(𝑦₁ - 𝑦₂)\n\n𝜃 (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) | abs (𝑥₂ - 𝑥₁) < 𝜀 = 𝜋/2\n | 𝑥₁ > 𝑥₂ = 𝜋 + atan ((𝑦₂ - 𝑦₁)/(𝑥₂ - 𝑥₁))\n | otherwise = atan ((𝑦₂ - 𝑦₁)/(𝑥₂ - 𝑥₁))\n\n𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) = if 𝛾 < 𝜀 then 𝜋 else 𝛾\n where\n 𝛾 = abs $ 𝜃 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) - 𝜃 (𝑥ᵣ, 𝑦ᵣ) (𝑥₂, 𝑦₂)\n\n𝘧𝘨𝘤𝘥 𝛼 𝛽 | abs 𝛼 < 𝜀 = 𝛽\n | 𝛼 > 𝛽 = 𝘧𝘨𝘤𝘥 𝛽 𝛼\n | otherwise = 𝘧𝘨𝘤𝘥 (𝛽 - 𝛼) 𝛼\n\nmain = do\n -- Read 3 vertices\n line₁ <- getLine\n let 𝑥₁ = read (words line₁ !! 0) :: Double\n let 𝑦₁ = read (words line₁ !! 1) :: Double\n line₂ <- getLine\n let 𝑥₂ = read (words line₂ !! 0) :: Double\n let 𝑦₂ = read (words line₂ !! 1) :: Double\n line₃ <- getLine\n let 𝑥₃ = read (words line₃ !! 0) :: Double\n let 𝑦₃ = read (words line₃ !! 1) :: Double\n\n -- Find the center (𝑥ᵣ, 𝑦ᵣ)\n let 𝑎₁₂ = 𝑥₁ - 𝑥₂\n let 𝑏₁₂ = 𝑦₁ - 𝑦₂\n let 𝑐₁₂ = (𝑥₁⋅𝑥₁ - 𝑥₂⋅𝑥₂ + 𝑦₁⋅𝑦₁ - 𝑦₂⋅𝑦₂) / 2\n let 𝑎₁₃ = 𝑥₁ - 𝑥₃\n let 𝑏₁₃ = 𝑦₁ - 𝑦₃\n let 𝑐₁₃ = (𝑥₁⋅𝑥₁ - 𝑥₃⋅𝑥₃ + 𝑦₁⋅𝑦₁ - 𝑦₃⋅𝑦₃) / 2\n let 𝑥ᵣ = (𝑏₁₃⋅𝑐₁₂ - 𝑏₁₂⋅𝑐₁₃) / (𝑎₁₂⋅𝑏₁₃ - 𝑎₁₃⋅𝑏₁₂)\n let 𝑦ᵣ = (𝑎₁₂⋅𝑐₁₃ - 𝑎₁₃⋅𝑐₁₂) / (𝑎₁₂⋅𝑏₁₃ - 𝑎₁₃⋅𝑏₁₂)\n\n -- Determine number of edges 𝑛 and circumradius 𝑟\n let 𝛿₁₂ = 𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂)\n let 𝛿₁₃ = 𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₃, 𝑦₃)\n let 𝜂 = 𝘧𝘨𝘤𝘥 (2⋅𝜋) $ 𝘧𝘨𝘤𝘥 𝛿₁₂ 𝛿₁₃\n let 𝑛 = fromInteger $ round (2⋅𝜋/𝜂)\n let 𝑟 = 𝘥 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁)\n let 𝒂 = 𝑛⋅𝑟⋅𝑟⋅sin (𝜋/𝑛)⋅cos (𝜋/𝑛)\n print 𝒂\n"}, {"source_code": "(⋅) = (*)\n\n𝜋 = pi\n𝜀 = 0.00001 -- epsilon. don't set this value too small!\n\n𝘥 (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) = sqrt $ (𝑥₁ - 𝑥₂)⋅(𝑥₁ - 𝑥₂) + (𝑦₁ - 𝑦₂)⋅(𝑦₁ - 𝑦₂)\n\n𝜃 (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) | abs (𝑥₂ - 𝑥₁) < 𝜀 = 𝜋/2\n | 𝑥₁ > 𝑥₂ = 𝜋 + atan ((𝑦₂ - 𝑦₁)/(𝑥₂ - 𝑥₁))\n | otherwise = atan ((𝑦₂ - 𝑦₁)/(𝑥₂ - 𝑥₁))\n\n𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂) = if 𝛾 < 𝜀 then 𝜋 else 𝛾\n where\n 𝛾 = abs $ 𝜃 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) - 𝜃 (𝑥ᵣ, 𝑦ᵣ) (𝑥₂, 𝑦₂)\n\n𝘧𝘨𝘤𝘥 𝛼 𝛽 | abs 𝛼 < 𝜀 = 𝛽\n | 𝛼 > 𝛽 = 𝘧𝘨𝘤𝘥 𝛽 𝛼\n | otherwise = 𝘧𝘨𝘤𝘥 (𝛽 - 𝛼) 𝛼\n\nmain = do\n -- Read 3 vertices\n line₁ <- getLine\n let 𝑥₁ = read (words line₁ !! 0) :: Double\n let 𝑦₁ = read (words line₁ !! 1) :: Double\n line₂ <- getLine\n let 𝑥₂ = read (words line₂ !! 0) :: Double\n let 𝑦₂ = read (words line₂ !! 1) :: Double\n line₃ <- getLine\n let 𝑥₃ = read (words line₃ !! 0) :: Double\n let 𝑦₃ = read (words line₃ !! 1) :: Double\n\n -- Find the center (𝑥ᵣ, 𝑦ᵣ)\n let 𝑎₁₂ = 𝑥₁ - 𝑥₂\n let 𝑏₁₂ = 𝑦₁ - 𝑦₂\n let 𝑐₁₂ = (𝑥₁⋅𝑥₁ - 𝑥₂⋅𝑥₂ + 𝑦₁⋅𝑦₁ - 𝑦₂⋅𝑦₂) / 2\n let 𝑎₁₃ = 𝑥₁ - 𝑥₃\n let 𝑏₁₃ = 𝑦₁ - 𝑦₃\n let 𝑐₁₃ = (𝑥₁⋅𝑥₁ - 𝑥₃⋅𝑥₃ + 𝑦₁⋅𝑦₁ - 𝑦₃⋅𝑦₃) / 2\n let 𝑥ᵣ = (𝑏₁₃⋅𝑐₁₂ - 𝑏₁₂⋅𝑐₁₃) / (𝑎₁₂⋅𝑏₁₃ - 𝑎₁₃⋅𝑏₁₂)\n let 𝑦ᵣ = (𝑎₁₂⋅𝑐₁₃ - 𝑎₁₃⋅𝑐₁₂) / (𝑎₁₂⋅𝑏₁₃ - 𝑎₁₃⋅𝑏₁₂)\n\n -- Determine number of edges 𝑛 and circumradius 𝑟\n let 𝛿₁₂ = 𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₂, 𝑦₂)\n let 𝛿₁₃ = 𝛿 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁) (𝑥₃, 𝑦₃)\n let 𝜂 = 𝘧𝘨𝘤𝘥 𝛿₁₂ 𝛿₁₃\n let 𝑛 = fromInteger $ round (2⋅𝜋/𝜂)\n let 𝑟 = 𝘥 (𝑥ᵣ, 𝑦ᵣ) (𝑥₁, 𝑦₁)\n let 𝒂 = 𝑛⋅𝑟⋅𝑟⋅sin (𝜋/𝑛)⋅cos (𝜋/𝑛)\n print 𝒂\n"}, {"source_code": "import Control.Monad\n\nπ = pi\nε = 0.000001\n\ndistance (x₁, y₁) (x₂, y₂) = sqrt $ (x₁ - x₂) * (x₁ - x₂) + (y₁ - y₂) * (y₁ - y₂)\n\nθ (x₁, y₁) (x₂, y₂) | abs (x₂ - x₁) < ε = π / 2\n | x₁ > x₂ = π + atan ((y₂ - y₁) / (x₂ - x₁))\n | otherwise = atan ((y₂ - y₁) / (x₂ - x₁))\n\nδ (xᵣ, yᵣ) (x₁, y₁) (x₂, y₂) = if δ' < ε then π else δ'\n where\n δ' = abs (θ (xᵣ, yᵣ) (x₁, y₁) - θ (xᵣ, yᵣ) (x₂, y₂))\n\nfgcd :: Double -> Double -> Double\nfgcd α β | abs α < ε = β\n | α > β = fgcd β α\n | otherwise = fgcd (β - α) α\n\nmain = do\n line₁ <- getLine\n let x₁ = read (words line₁ !! 0) :: Double\n let y₁ = read (words line₁ !! 1) :: Double\n line₂ <- getLine\n let x₂ = read (words line₂ !! 0) :: Double\n let y₂ = read (words line₂ !! 1) :: Double\n line₃ <- getLine\n let x₃ = read (words line₃ !! 0) :: Double\n let y₃ = read (words line₃ !! 1) :: Double\n\n --let (x₁₂, y₁₂) = midpoint (x₁, y₁) (x₂, y₂)\n --let (x₁₃, y₁₃) = midpoint (x₁, y₁) (x₃, y₃)\n\n let a₁₂ = x₁ - x₂\n let b₁₂ = y₁ - y₂\n let c₁₂ = (x₁ * x₁ - x₂ * x₂ + y₁ * y₁ - y₂ * y₂) / 2\n let a₁₃ = x₁ - x₃\n let b₁₃ = y₁ - y₃\n let c₁₃ = (x₁ * x₁ - x₃ * x₃ + y₁ * y₁ - y₃ * y₃) / 2\n let xᵣ = (b₁₃ * c₁₂ - b₁₂ * c₁₃) / (a₁₂ * b₁₃ - a₁₃ * b₁₂)\n let yᵣ = (a₁₂ * c₁₃ - a₁₃ * c₁₂) / (a₁₂ * b₁₃ - a₁₃ * b₁₂)\n --print (xᵣ, yᵣ)\n\n let δ₁₂ = δ (xᵣ, yᵣ) (x₁, y₁) (x₂, y₂)\n let δ₁₃ = δ (xᵣ, yᵣ) (x₁, y₁) (x₃, y₃)\n let η = fgcd δ₁₂ δ₁₃\n --print (δ₁₂, δ₁₃)\n\n let n = round $ 2 * π / η\n --print n\n let r = distance (xᵣ, yᵣ) (x₁, y₁)\n let area = fromInteger n * r * r * sin (η / 2) * cos (η / 2)\n print area\n\n return ()\n"}, {"source_code": "import Data.Array\nimport Data.Ratio\nimport Data.Char\nimport Data.List\nimport Data.Bits\n\nimport System\nimport System.IO\nimport System.Random\nimport Control.Applicative\nimport Control.Monad\nimport qualified Data.Set as Set \nimport qualified Data.Map as Map \n\nimport Text.Printf\n\nimport Debug.Trace\n\n-- newtype Point = Pt (Double, Double) deriving Show\ntype Point = (Double, Double) -- (x,y)\ntype Line = (Double, Double, Double) -- ax+by=c\n\ninfixr 7 -.\n(-.) (x1, y1) (x2, y2) = (x1 - x2, y1 - y2)\n\nlen (x,y) = sqrt(x^2+y^2)\ndot (x1, y1) (x2, y2) = x1*x2 + y1*y2\nang v1 v2 = if l1==0 || l2==0 then 0 else acos(cosine)\n where l1 = len v1\n l2 = len v2\n v = dot v1 v2/l1/l2\n cosine | v > 1 = 1.0\n | v < -1 = -1.0\n | otherwise = v\n\nreadls :: (Read a) => String -> [a]\nreadls = map read . words\n\nmidLine :: Point -> Point -> Line\nmidLine (x1, y1) (x2, y2) = let a = y2-y1\n b = x1-x2\n c = a*(y1+y2)-b*(x1+x2)\n in (-2*b, 2*a, c)\n\nisect :: Line -> Line -> Point\nisect (a1, b1, c1) (a2, b2, c2) = ((b2*c1-b1*c2)/det, (a1*c2-a2*c1)/det) where det = a1*b2 - a2*b1\n\n-- given 3 point on cirlce, return center of circle\ncircleCenter :: Point -> Point -> Point -> Point\ncircleCenter p1 p2 p3 = isect (midLine p1 p2) (midLine p2 p3)\n\n-- solve :: [Double] -> Double\nsolve [x1, y1, x2, y2, x3, y3] = n\n where p1 = (x1, y1)\n p2 = (x2, y2)\n p3 = (x3, y3)\n center = circleCenter p1 p2 p3\n v1 = p1 -. center\n v2 = p2 -. center\n v3 = p3 -. center\n r = len v1\n ang1 = ang v1 v2\n ang2 = ang v2 v3\n tol = 1e-5\n r1 = approxRational (abs$ ang1/2/pi) tol\n r2 = approxRational (abs$ ang2/2/pi) tol\n n = lcm (denominator r1) (denominator r2)\n\nmain = do readls <$> getContents >>= print . solve\n \n"}, {"source_code": "import Data.Array\nimport Data.Ratio\nimport Data.Char\nimport Data.List\nimport Data.Bits\n\nimport System\nimport System.IO\nimport System.Random\nimport Control.Applicative\nimport Control.Monad\nimport qualified Data.Set as Set \nimport qualified Data.Map as Map \n\nimport Text.Printf\n\nimport Debug.Trace\n\n-- newtype Point = Pt (Double, Double) deriving Show\ntype Point = (Double, Double) -- (x,y)\ntype Line = (Double, Double, Double) -- ax+by=c\n\ninfixr 7 -.\n(-.) (x1, y1) (x2, y2) = (x1 - x2, y1 - y2)\n\nlen (x,y) = sqrt(x^2+y^2)\ndot (x1, y1) (x2, y2) = x1*x2 + y1*y2\nang v1 v2 = if l1==0 || l2==0 then 0 else acos(cosine)\n where l1 = len v1\n l2 = len v2\n v = dot v1 v2/l1/l2\n cosine | v > 1 = 1.0\n | v < -1 = -1.0\n | otherwise = v\n\nreadls :: (Read a) => String -> [a]\nreadls = map read . words\n\nmidLine :: Point -> Point -> Line\nmidLine (x1, y1) (x2, y2) = let a = y2-y1\n b = x1-x2\n c = a*(y1+y2)-b*(x1+x2)\n in (-2*b, 2*a, c)\n\nisect :: Line -> Line -> Point\nisect (a1, b1, c1) (a2, b2, c2) = ((b2*c1-b1*c2)/det, (a1*c2-a2*c1)/det) where det = a1*b2 - a2*b1\n\n-- given 3 point on cirlce, return center of circle\ncircleCenter :: Point -> Point -> Point -> Point\ncircleCenter p1 p2 p3 = isect (midLine p1 p2) (midLine p2 p3)\n\n-- solve :: [Double] -> Double\nsolve [x1, y1, x2, y2, x3, y3] = n\n where p1 = (x1, y1)\n p2 = (x2, y2)\n p3 = (x3, y3)\n center = circleCenter p1 p2 p3\n v1 = p1 -. center\n v2 = p2 -. center\n v3 = p3 -. center\n r = len v1\n ang1 = ang v1 v2\n ang2 = ang v2 v3\n tol = 1e-3\n r1 = approxRational (ang1/2/pi) tol\n r2 = approxRational (ang2/2/pi) tol\n n = lcm (denominator r1) (denominator r2)\n\nmain = do readls <$> getContents >>= print . solve\n \n"}, {"source_code": "import Data.Array\nimport Data.Ratio\nimport Data.Char\nimport Data.List\nimport Data.Bits\n\nimport System\nimport System.IO\nimport System.Random\nimport Control.Applicative\nimport Control.Monad\nimport qualified Data.Set as Set \nimport qualified Data.Map as Map \n\nimport Text.Printf\n\nimport Debug.Trace\n\n-- newtype Point = Pt (Double, Double) deriving Show\ntype Point = (Double, Double) -- (x,y)\ntype Line = (Double, Double, Double) -- ax+by=c\n\ninfixr 7 -.\n(-.) (x1, y1) (x2, y2) = (x1 - x2, y1 - y2)\n\nlen (x,y) = sqrt(x^2+y^2)\ndot (x1, y1) (x2, y2) = x1*x2 + y1*y2\nang v1 v2 = if l1==0 || l2==0 then 0 else acos(cosine)\n where l1 = len v1\n l2 = len v2\n v = dot v1 v2/l1/l2\n cosine | v > 1 = 1.0\n | v < -1 = -1.0\n | otherwise = v\n\nreadls :: (Read a) => String -> [a]\nreadls = map read . words\n\nmidLine :: Point -> Point -> Line\nmidLine (x1, y1) (x2, y2) = let a = y2-y1\n b = x1-x2\n c = a*(y1+y2)-b*(x1+x2)\n in (-2*b, 2*a, c)\n\nisect :: Line -> Line -> Point\nisect (a1, b1, c1) (a2, b2, c2) = ((b2*c1-b1*c2)/det, (a1*c2-a2*c1)/det) where det = a1*b2 - a2*b1\n\n-- given 3 point on cirlce, return center of circle\ncircleCenter :: Point -> Point -> Point -> Point\ncircleCenter p1 p2 p3 = isect (midLine p1 p2) (midLine p2 p3)\n\n-- solve :: [Double] -> Double\nsolve [x1, y1, x2, y2, x3, y3] = n\n where p1 = (x1, y1)\n p2 = (x2, y2)\n p3 = (x3, y3)\n center = circleCenter p1 p2 p3\n v1 = p1 -. center\n v2 = p2 -. center\n v3 = p3 -. center\n r = len v1\n ang1 = ang v1 v2\n ang2 = ang v2 v3\n tol = 1e-4\n r1 = approxRational (ang1/2/pi) tol\n r2 = approxRational (ang2/2/pi) tol\n n = lcm (denominator r1) (denominator r2)\n\nmain = do readls <$> getContents >>= print . solve\n \n"}, {"source_code": "import Data.Array\nimport Data.Ratio\nimport Data.Char\nimport Data.List\nimport Data.Bits\n\nimport System\nimport System.IO\nimport System.Random\nimport Control.Applicative\nimport Control.Monad\nimport qualified Data.Set as Set \nimport qualified Data.Map as Map \n\nimport Text.Printf\n\nimport Debug.Trace\n\n-- newtype Point = Pt (Double, Double) deriving Show\ntype Point = (Double, Double) -- (x,y)\ntype Line = (Double, Double, Double) -- ax+by=c\n\ninfixr 7 -.\n(-.) (x1, y1) (x2, y2) = (x1 - x2, y1 - y2)\n\nlen (x,y) = sqrt(x^2+y^2)\ndot (x1, y1) (x2, y2) = x1*x2 + y1*y2\nang v1 v2 = if l1==0 || l2==0 then 0 else acos(cosine)\n where l1 = len v1\n l2 = len v2\n v = dot v1 v2/l1/l2\n cosine | v > 1 = 1.0\n | v < -1 = -1.0\n | otherwise = v\n\nreadls :: (Read a) => String -> [a]\nreadls = map read . words\n\nmidLine :: Point -> Point -> Line\nmidLine (x1, y1) (x2, y2) = let a = y2-y1\n b = x1-x2\n c = a*(y1+y2)-b*(x1+x2)\n in (-2*b, 2*a, c)\n\nisect :: Line -> Line -> Point\nisect (a1, b1, c1) (a2, b2, c2) = ((b2*c1-b1*c2)/det, (a1*c2-a2*c1)/det) where det = a1*b2 - a2*b1\n\n-- given 3 point on cirlce, return center of circle\ncircleCenter :: Point -> Point -> Point -> Point\ncircleCenter p1 p2 p3 = isect (midLine p1 p2) (midLine p2 p3)\n\n-- solve :: [Double] -> Double\nsolve [x1, y1, x2, y2, x3, y3] = n\n where p1 = (x1, y1)\n p2 = (x2, y2)\n p3 = (x3, y3)\n center = circleCenter p1 p2 p3\n v1 = p1 -. center\n v2 = p2 -. center\n v3 = p3 -. center\n r = len v1\n ang1 = ang v1 v2\n ang2 = ang v2 v3\n tol = 1e-6\n r1 = approxRational (ang1/2/pi) tol\n r2 = approxRational (ang2/2/pi) tol\n n = lcm (denominator r1) (denominator r2)\n\nmain = do readls <$> getContents >>= print . solve\n \n"}, {"source_code": "import Data.Array\nimport Data.Ratio\nimport Data.Char\nimport Data.List\nimport Data.Bits\n\nimport System\nimport System.IO\nimport System.Random\nimport Control.Applicative\nimport Control.Monad\nimport qualified Data.Set as Set \nimport qualified Data.Map as Map \n\nimport Text.Printf\n\nimport Debug.Trace\n\n-- newtype Point = Pt (Double, Double) deriving Show\ntype Point = (Double, Double) -- (x,y)\ntype Line = (Double, Double, Double) -- ax+by=c\n\ninfixr 7 -.\n(-.) (x1, y1) (x2, y2) = (x1 - x2, y1 - y2)\n\nlen (x,y) = sqrt(x^2+y^2)\ndot (x1, y1) (x2, y2) = x1*x2 + y1*y2\nang v1 v2 = if l1==0 || l2==0 then 0 else acos(cosine)\n where l1 = len v1\n l2 = len v2\n v = dot v1 v2/l1/l2\n cosine | v > 1 = 1.0\n | v < -1 = -1.0\n | otherwise = v\n\nreadls :: (Read a) => String -> [a]\nreadls = map read . words\n\nmidLine :: Point -> Point -> Line\nmidLine (x1, y1) (x2, y2) = let a = y2-y1\n b = x1-x2\n c = a*(y1+y2)-b*(x1+x2)\n in (-2*b, 2*a, c)\n\nisect :: Line -> Line -> Point\nisect (a1, b1, c1) (a2, b2, c2) = ((b2*c1-b1*c2)/det, (a1*c2-a2*c1)/det) where det = a1*b2 - a2*b1\n\n-- given 3 point on cirlce, return center of circle\ncircleCenter :: Point -> Point -> Point -> Point\ncircleCenter p1 p2 p3 = isect (midLine p1 p2) (midLine p2 p3)\n\n-- solve :: [Double] -> Double\nsolve [x1, y1, x2, y2, x3, y3] = n\n where p1 = (x1, y1)\n p2 = (x2, y2)\n p3 = (x3, y3)\n center = circleCenter p1 p2 p3\n v1 = p1 -. center\n v2 = p2 -. center\n v3 = p3 -. center\n r = len v1\n ang1 = ang v1 v2\n ang2 = ang v2 v3\n r1 = approxRational (ang1/2/pi) 1e-5\n r2 = approxRational (ang2/2/pi) 1e-5\n n = lcm (denominator r1) (denominator r2)\n\nmain = do readls <$> getContents >>= print . solve\n \n"}, {"source_code": "\nimport Data.Complex\nimport Text.Printf\n\nreadComplex :: String -> Complex Double\nreadComplex = (\\[x,y] -> x :+ y) . map read . words\n\narea a b = imagPart $ a * b\n\nangleSin a b = area a b / (magnitude a * magnitude b)\n\nangle a b = phase (a * conjugate b)\n\ncircleR a b c = magnitude (b - c) / angleSin (b - a) (c - a) / 2\n\ngcdR a b \n | a < 0 || b < 0 = gcdR (abs a) (abs b)\n | a < b = gcdR b a\n | b < 1e-5 = a\n | otherwise = gcdR (a-b) b\n\nsolve [a,b,c] = n * len0\n where\n norm ang = if ang < 0 then ang + 2 * pi else ang\n r = circleR a b c\n angA = norm (angle (b - a) (c - a)) * 2\n angB = norm (angle (c - b) (a - b)) * 2\n angC = norm (angle (a - c) (b - c)) * 2\n invN = angA `gcdR` angB `gcdR` angC\n n = 2 * pi / invN\n len0 = r * sin (invN / 2) * 2\n\nmain = interact $ printf \"%.10f\" . solve . map readComplex . take 3 . lines\n"}, {"source_code": "\nimport Data.Complex\nimport Text.Printf\n\nreadComplex :: String -> Complex Double\nreadComplex = (\\[x,y] -> x :+ y) . map read . words\n\narea a b = imagPart $ a * conjugate b\n\nangleSin a b = area a b / (magnitude a * magnitude b)\n\nangle a b = phase (a * conjugate b)\n\ncircleR a b c = magnitude (b - c) / angleSin (b - a) (c - a) / 2\n\ngcdR a b \n | a < 0 || b < 0 = gcdR (abs a) (abs b)\n | a < b = gcdR b a\n | b < 1e-5 = a\n | otherwise = gcdR (a-b) b\n\nsolve [a,b,c] = n * area0\n where\n r = circleR a b c\n angA = abs (angle (b - a) (c - a)) * 2\n angB = abs (angle (c - b) (a - b)) * 2\n angC = abs (angle (a - c) (b - c)) * 2\n invN = angA `gcdR` angB `gcdR` angC\n n = 2 * pi / invN\n area0 = r^2 * (sin invN) / 2\n\nmain = interact $ printf \"%.10f\" . solve . map readComplex . take 3 . lines\n"}, {"source_code": "\nimport Data.Complex\nimport Text.Printf\n\nreadComplex :: String -> Complex Double\nreadComplex = (\\[x,y] -> x :+ y) . map read . words\n\narea a b = imagPart $ a * conjugate b\n\nangleSin a b = area a b / (magnitude a * magnitude b)\n\nangle a b = phase (a * conjugate b)\n\ncircleR a b c = magnitude (b - c) / angleSin (b - a) (c - a) / 2\n\ngcdR a b \n | a < 0 || b < 0 = gcdR (abs a) (abs b)\n | a < b = gcdR b a\n | b < 1e-5 = a\n | otherwise = gcdR (a-b) b\n\nsolve [a,b,c] = n * area0\n where\n norm ang = if ang < 0 then ang + 2 * pi else ang\n r = circleR a b c\n angA = norm (angle (b - a) (c - a)) * 2\n angB = norm (angle (c - b) (a - b)) * 2\n angC = norm (angle (a - c) (b - c)) * 2\n invN = angA `gcdR` angB `gcdR` angC\n n = 2 * pi / invN\n area0 = r^2 * (sin invN) / 2\n\nmain = interact $ printf \"%.10f\" . solve . map readComplex . take 3 . lines\n"}, {"source_code": "\nimport Data.Complex\nimport Text.Printf\n\nreadComplex :: String -> Complex Double\nreadComplex = (\\[x,y] -> x :+ y) . map read . words\n\narea a b = imagPart $ a * b\n\nangleSin a b = area a b / (magnitude a * magnitude b)\n\nangle a b = phase (a * conjugate b)\n\ncircleR a b c = magnitude (b - c) / angleSin (b - a) (c - a) / 2\n\ngcdR a b \n | a < 0 || b < 0 = gcdR (abs a) (abs b)\n | a < b = gcdR b a\n | b < 1e-5 = a\n | otherwise = gcdR (a-b) b\n\nsolve [a,b,c] = n * area0\n where\n norm ang = if ang < 0 then ang + 2 * pi else ang\n r = circleR a b c\n angA = norm (angle (b - a) (c - a)) * 2\n angB = norm (angle (c - b) (a - b)) * 2\n angC = norm (angle (a - c) (b - c)) * 2\n invN = angA `gcdR` angB `gcdR` angC\n n = 2 * pi / invN\n area0 = r^2 * sin invN / 2\n\nmain = interact $ printf \"%.10f\" . solve . map readComplex . take 3 . lines\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = interact $ show . solve . map (map read . words) . lines\n\nsolve :: [[Float]] -> Float\nsolve [[x1, y1], [x2, y2], [x3, y3]] = sides * rsquare * sin (2 * pi / sides) / 2\n where\n a1 = 2 * (x2 - x1)\n b1 = 2 * (y2 - y1)\n c1 = x1**2 - x2**2 + y1**2 - y2**2\n a2 = 2 * (x3 - x1)\n b2 = 2 * (y3 - y1)\n c2 = x1**2 - x3**2 + y1**2 - y3**2\n x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)\n y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)\n dx1 = x1 - x\n dy1 = y1 - y\n dx2 = x2 - x\n dy2 = y2 - y\n dx3 = x3 - x\n dy3 = y3 - y\n angl1 = 2 * pi / (acos ((dx1 * dx2 + dy1 * dy2) / (sqrt ((dx1**2 + dy1**2) * (dx2**2 + dy2**2)))))\n angl2 = 2 * pi / (acos ((dx3 * dx2 + dy3 * dy2) / (sqrt ((dx3**2 + dy3**2) * (dx2**2 + dy2**2)))))\n angl3 = 2 * pi / (acos ((dx3 * dx1 + dy3 * dy1) / (sqrt ((dx3**2 + dy3**2) * (dx1**2 + dy1**2)))))\n sides = fromIntegral $ head $ filter (\\n -> let m = fromIntegral n in allint (m / angl1, m / angl2, m / angl3)) ([3..] :: [Int])\n allint (a, b, c) = nearint a && nearint b && nearint c\n nearint a = abs (a - fromIntegral (round a :: Integer)) < 1e-4\n rsquare = (dx1**2 + dy1**2)\nsolve _ = undefined\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = interact $ show . solve . map (map read . words) . lines\n\nsolve :: [[Float]] -> Float\nsolve [[x1, y1], [x2, y2], [x3, y3]] = 180 / an * rsquare * sin (an / 180 * pi)\n where\n a1 = 2 * (x2 - x1)\n b1 = 2 * (y2 - y1)\n c1 = x1**2 - x2**2 + y1**2 - y2**2\n a2 = 2 * (x3 - x1)\n b2 = 2 * (y3 - y1)\n c2 = x1**2 - x3**2 + y1**2 - y3**2\n x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)\n y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)\n dx1 = x1 - x\n dy1 = y1 - y\n dx2 = x2 - x\n dy2 = y2 - y\n dx3 = x3 - x\n dy3 = y3 - y\n angl1 = round (180 / pi * acos ((dx1 * dx2 + dy1 * dy2) / (sqrt ((dx1**2 + dy1**2) * (dx2**2 + dy2**2)))))\n angl2 = round (180 / pi * acos ((dx3 * dx2 + dy3 * dy2) / (sqrt ((dx3**2 + dy3**2) * (dx2**2 + dy2**2)))))\n angl3 = round (180 / pi * acos ((dx3 * dx1 + dy3 * dy1) / (sqrt ((dx3**2 + dy3**2) * (dx1**2 + dy1**2)))))\n an = fromIntegral $ foldl1 gcd $ map (uncurry gcd) $ filter (\\(a, b) -> a /= 0 && b /= 0) [(angl1, angl2), (angl2, angl3), (angl3, angl1)]\n rsquare = (dx1**2 + dy1**2)\nsolve _ = undefined\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = interact $ show . solve . map (map read . words) . lines\n\nsolve :: [[Float]] -> Float\nsolve [[x1, y1], [x2, y2], [x3, y3]] = 180 / an * r * sin (an / 180 * pi)\n where\n a1 = 2 * (x2 - x1)\n b1 = 2 * (y2 - y1)\n c1 = x1**2 - x2**2 + y1**2 - y2**2\n a2 = 2 * (x3 - x1)\n b2 = 2 * (y3 - y1)\n c2 = x1**2 - x3**2 + y1**2 - y3**2\n x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)\n y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)\n dx1 = x1 - x\n dy1 = y1 - y\n dx2 = x2 - x\n dy2 = y2 - y\n dx3 = x3 - x\n dy3 = y3 - y\n ang angle = round $ if angle > 90 then 180 - angle else angle\n angl1 = ang (180 / pi * acos ((dx1 * dx2 + dy1 * dy2) / (sqrt ((dx1**2 + dy1**2) * (dx2**2 + dy2**2)))))\n angl2 = ang (180 / pi * acos ((dx3 * dx2 + dy3 * dy2) / (sqrt ((dx3**2 + dy3**2) * (dx2**2 + dy2**2)))))\n angl3 = ang (180 / pi * acos ((dx3 * dx1 + dy3 * dy1) / (sqrt ((dx3**2 + dy3**2) * (dx1**2 + dy1**2)))))\n an = fromIntegral $ foldl1 gcd $ map (uncurry gcd) $ filter (\\(a, b) -> a /= 0 && b /= 0) [(angl1, angl2), (angl2, angl3), (angl3, angl1)]\n r = sqrt ((dx1**2 + dy1**2) * (dx2**2 + dy2**2))\nsolve _ = undefined\n"}, {"source_code": "module Main where\n\nfrem :: Double -> Double -> Double\nfrem x y = x - (y * (fromIntegral (truncate (x / y))))\n\nfgcd :: Double -> Double -> Double\nfgcd x y = fgcd_aux (abs x) (abs y) where \n\tfgcd_aux a b | abs b <= 1e-8 = a\n\t\t\t\t | otherwise = fgcd_aux b (frem a b)\n \ndistance :: (Double, Double) -> (Double, Double) -> Double\ndistance (x1, y1) (x2, y2) = sqrt ((x1 - x2) ^ 2 + (y1 - y2) ^ 2)\n\nangle :: Double -> Double -> Double -> Double\nangle d1 d2 d3 = acos ((d1 ^ 2 + d2 ^ 2 - d3 ^ 2) / (2 * d1 * d2))\n\nradius :: Double -> Double -> Double\nradius a alpha = a / (2 * sin alpha)\n\ncompute :: (Double, Double) -> (Double, Double) -> (Double, Double) -> Double\ncompute p1 p2 p3 = let\n\t\ta = distance p1 p2;\n\t\tb = distance p2 p3;\n\t\tc = distance p3 p1;\n\t\talpha = angle b c a;\n\t\tbeta = angle c a b;\n\t\tgamma = angle a b c;\n\t\tr = radius a alpha;\n\t\tu = 2 * fgcd alpha (fgcd beta gamma) in r ^ 2 * pi / u * sin u\n\nmain :: IO ()\nmain = do\n\tinput <- getContents\n\tlet tokens = words input;\n\t\tp1 = (read (tokens !! 0), read (tokens !! 1));\n\t\tp2 = (read (tokens !! 2), read (tokens !! 3));\n\t\tp3 = (read (tokens !! 4), read (tokens !! 5)) in\n\t\tputStrLn (show (compute p1 p2 p3))\n"}, {"source_code": "module Main where\n\nfrem :: Float -> Float -> Float\nfrem x y = x - (y * (fromIntegral (truncate (x / y))))\n\nfgcd :: Float -> Float -> Float\nfgcd x y = fgcd_aux (abs x) (abs y) where \n\tfgcd_aux a b | abs b < 1e-6 = a\n\t\t\t\t | otherwise = fgcd_aux b (frem a b)\n \ndistance :: (Float, Float) -> (Float, Float) -> Float\ndistance (x1, y1) (x2, y2) = sqrt ((x1 - x2) ^ 2 + (y1 - y2) ^ 2)\n\nangle :: Float -> Float -> Float -> Float\nangle d1 d2 d3 = acos ((d1 ^ 2 + d2 ^ 2 - d3 ^ 2) / (2 * d1 * d2))\n\nradius :: Float -> Float -> Float\nradius a alpha = a / (2 * sin alpha)\n\ncompute :: (Float, Float) -> (Float, Float) -> (Float, Float) -> Float\ncompute p1 p2 p3 = let\n\t\ta = distance p1 p2;\n\t\tb = distance p2 p3;\n\t\tc = distance p3 p1;\n\t\talpha = angle b c a;\n\t\tbeta = angle c a b;\n\t\tgamma = angle a b c;\n\t\tr = radius a alpha;\n\t\tu = 2 * fgcd alpha (fgcd beta gamma) in r ^ 2 * pi / u * sin u\n\nmain :: IO ()\nmain = do\n\tinput <- getContents\n\tlet tokens = words input;\n\t\tp1 = (read (tokens !! 0), read (tokens !! 1));\n\t\tp2 = (read (tokens !! 2), read (tokens !! 3));\n\t\tp3 = (read (tokens !! 4), read (tokens !! 5)) in\n\t\tputStrLn (show (compute p1 p2 p3))\n"}, {"source_code": "module Main where\n\nfrem :: Float -> Float -> Float\nfrem x y = x - (y * (fromIntegral (truncate (x / y))))\n\nfgcd :: Float -> Float -> Float\nfgcd x y = fgcd_aux (abs x) (abs y) where \n\tfgcd_aux a b | abs b <= 1e-5 = a\n\t\t\t\t | otherwise = fgcd_aux b (frem a b)\n \ndistance :: (Float, Float) -> (Float, Float) -> Float\ndistance (x1, y1) (x2, y2) = sqrt ((x1 - x2) ^ 2 + (y1 - y2) ^ 2)\n\nangle :: Float -> Float -> Float -> Float\nangle d1 d2 d3 = acos ((d1 ^ 2 + d2 ^ 2 - d3 ^ 2) / (2 * d1 * d2))\n\nradius :: Float -> Float -> Float\nradius a alpha = a / (2 * sin alpha)\n\ncompute :: (Float, Float) -> (Float, Float) -> (Float, Float) -> Float\ncompute p1 p2 p3 = let\n\t\ta = distance p1 p2;\n\t\tb = distance p2 p3;\n\t\tc = distance p3 p1;\n\t\talpha = angle b c a;\n\t\tbeta = angle c a b;\n\t\tgamma = angle a b c;\n\t\tr = radius a alpha;\n\t\tu = 2 * fgcd alpha (fgcd beta gamma) in r ^ 2 * pi / u * sin u\n\nmain :: IO ()\nmain = do\n\tinput <- getContents\n\tlet tokens = words input;\n\t\tp1 = (read (tokens !! 0), read (tokens !! 1));\n\t\tp2 = (read (tokens !! 2), read (tokens !! 3));\n\t\tp3 = (read (tokens !! 4), read (tokens !! 5)) in\n\t\tputStrLn (show (compute p1 p2 p3))\n"}, {"source_code": "import Control.Arrow\n\nmain = do\n [ax,ay] <- readPoint\n [bx,by] <- readPoint\n [cx,cy] <- readPoint\n let d = 2*(ax*(by-cy)+bx*(cy-ay)+cx*(ay-by))\n dx = ((ay^2+ax^2)*(by-cy)+(by^2+bx^2)*(cy-ay)+(cy^2+cx^2)*(ay-by))/d\n dy = ((ay^2+ax^2)*(cx-bx)+(by^2+bx^2)*(ax-cx)+(cy^2+cx^2)*(bx-ax))/d\n aa = angle (bx-dx,by-dy) (cx-dx,cy-dy)\n ab = angle (cx-dx,cy-dy) (ax-dx,ay-dy)\n ac = angle (ax-dx,ay-dy) (bx-dx,by-dy)\n n = snd $ head $\n filter (isMultiple ac . fst) $\n filter (isMultiple ab . fst) $\n filter (isMultiple aa . fst) $\n map ((2*pi/) &&& id) [3..]\n r = sqrt ((ax-dx)^2 + (ay-dy)^2)\n a = n*r^2*sin(2*pi/n)/2\n print a\n\nreadPoint = fmap (map read . words) getLine\n(a,b)·(c,d) = a*c+b*d\n(a,b)×(c,d) = a*d-b*c\nangle a b = abs (atan2 (a×b) (a·b))\nisMultiple a b = abs (a - b*fromIntegral (round(a/b))) < pi/1000"}, {"source_code": "import Control.Arrow\n\nmain = do\n [ax,ay] <- readPoint\n [bx,by] <- readPoint\n [cx,cy] <- readPoint\n let d = 2*(ax*(by-cy)+bx*(cy-ay)+cx*(ay-by))\n dx = ((ay^2+ax^2)*(by-cy)+(by^2+bx^2)*(cy-ay)+(cy^2+cx^2)*(ay-by))/d\n dy = ((ay^2+ax^2)*(cx-bx)+(by^2+bx^2)*(ax-cx)+(cy^2+cx^2)*(bx-ax))/d\n aa = angle (bx-dx,by-dy) (cx-dx,cy-dy)\n ab = angle (cx-dx,cy-dy) (ax-dx,ay-dy)\n ac = angle (ax-dx,ay-dy) (bx-dx,by-dy)\n n = snd $ head $\n filter (isMultiple ac . fst) $\n filter (isMultiple ab . fst) $\n filter (isMultiple aa . fst) $\n map ((2*pi/) &&& id) [3..]\n r = sqrt ((ax-dx)^2 + (ay-dy)^2)\n a = n*r^2*sin(2*pi/n)/2\n print a\n\nreadPoint = fmap (map read . words) getLine\n(a,b)·(c,d) = a*c+b*d\n(a,b)×(c,d) = a*d-b*c\nangle a b = abs (atan2 (a×b) (a·b))\nisMultiple a b = abs (a - b*fromIntegral (round(a/b))) < pi/100"}, {"source_code": "import Control.Arrow\n\nmain = do\n [ax,ay] <- readPoint :: IO [Double]\n [bx,by] <- readPoint\n [cx,cy] <- readPoint\n let d = 2*(ax*(by-cy)+bx*(cy-ay)+cx*(ay-by))\n dx = ((ay^2+ax^2)*(by-cy)+(by^2+bx^2)*(cy-ay)+(cy^2+cx^2)*(ay-by))/d\n dy = ((ay^2+ax^2)*(cx-bx)+(by^2+bx^2)*(ax-cx)+(cy^2+cx^2)*(bx-ax))/d\n aa = angle (bx-dx,by-dy) (cx-dx,cy-dy)\n ab = angle (ax-dx,ay-dy) (cx-dx,cy-dy)\n ac = angle (ax-dx,ay-dy) (bx-dx,by-dy)\n n = snd $ head $\n filter (isMultiple ac . fst) $\n filter (isMultiple ab . fst) $\n filter (isMultiple aa . fst) $\n map ((2*pi/) &&& id) [3..]\n r = sqrt ((ax-dx)^2 + (ay-dy)^2)\n a = n*r^2*sin(2*pi/n)/2\n print a\n\nreadPoint = fmap (map read . words) getLine\n(a,b)·(c,d) = a*c+b*d\n(a,b)×(c,d) = a*d-b*c\nangle a b = abs (atan2 (a×b) (a·b))\nisMultiple a b = abs (a - b*fromIntegral (floor(a/b))) < pi/100"}, {"source_code": "import Data.List\nimport Text.Printf\n\ndelta = 1e-6\nisInteger x = abs (fromInteger (round x) - x) < delta\n\nradius [[x1', y1'], [x2', y2'], [x3',y3']] = \n\tlet {(x1, y1, x2, y2, x3, y3) = if abs(x2' - x1') < delta \n\t\tthen (x1', y1', x3', y3', x2', y2') \n\t\telse if abs (x2' - x3') < delta then (x2', y2', x1', y1', x3', y3')\n\t\telse (x1', y1', x2', y2', x3', y3')} in\n\tlet { ma = (y2 - y1)/(x2 - x1)\n\t; mb = (y3 - y2)/(x3 - x2)} in\n\tlet x = (ma * mb * (y1 - y3) + mb * (x1 + x2) - ma * (x2 + x3)) / (2 * (mb - ma)) in\n\tlet y = if abs ma > delta then -1 / ma * (x - (x1 + x2)/2) + (y1 + y2)/2\n\t\telse -1 / mb * (x - (x2 + x3)/2 ) + (y2 + y3)/2 in\n\tsqrt((x - x1)**2 + (y - y1)**2)\n\ndist x1 y1 x2 y2 = sqrt ((x1 - x2)**2 + (y1 - y2)**2)\n\nangles [[x1, y1], [x2, y2], [x3,y3]] r = let {\n\td1 = dist x1 y1 x2 y2\n\t; d2 = dist x2 y2 x3 y3\n\t; d3 = dist x3 x1 y3 y1} in\n\treverse $ (map ((2*) . asin . (/(2*r))) $ tail $ reverse $ sort [d1, d2, d3])\n\ns::[[Double]] -> Double\ns coords = let {r = radius coords} in\n\tlet {[n] = take 1 $ filter (\\x -> any isInteger $ map (/(2* pi / fromInteger x)) as) [3..100] \n\t\twhere as = angles coords r}\n\tin let {a = pi / (fromInteger n)}\n\tin r ** 2 * (sin a) * (cos a) * (fromInteger n)\n\nmain = do {\n\tcoords <- mapM (\\_ -> getLine >>= (return . map read . words)) [1..3]\n\t; printf \"%.6f\" $ s coords\n}\n"}, {"source_code": "data Vector = Vector Float Float deriving (Show)\n\ndata Point = Point Float Float deriving (Show)\n\neps = 1e-3\ninstance Eq Point where\n\t(Point x1 y1) == (Point x2 y2) = (abs (x1 - x2)) < eps && (abs (y1 - y2)) < eps\n\ngetPoint = do\n\tl <- getLine\n\tlet [x, y] = map read (words l)\n\treturn (Point x y)\n\nvector (Point x1 y1) (Point x2 y2) = Vector (x2 - x1) (y2 - y1)\nnormal (Vector x y) = Vector (-y) x \ncross (Vector x1 y1) (Vector x2 y2) = x1*y2 - x2*y1\nadd' (Point x1 y1) (Vector x2 y2) = Point (x1 + x2) (y1 + y2)\ndiv' (Vector x y) f = Vector (x / f) (y / f) \nmul' (Vector x y) f = Vector (x * f) (y * f)\nsub' (Point x1 y1) (Point x2 y2) = Point (x1 - x2) (y1 - y2)\n\nrotate (Point x y) a = Point (x * cos a - y * sin a) (x * sin a + y * cos a)\n\nmatch n ps =\n\tlet p = head ps in\n\tlength (filter (\\p -> p `elem` ps) [rotate p (2*pi*i / n) | i <- [0..n-1]]) == length ps\n\nmain = do\n\tp1 <- getPoint\n\tp2 <- getPoint\n\tp3 <- getPoint\n\n\tlet\n\t\tan = normal (vector p1 p2)\n\t\tb = vector p2 p3\n\t\tbn = normal b\n\t\tc = vector p1 p3\n\t\ts = (an `cross` c) / (bn `cross` an)\n\n\t\tp0 = p2 `add'` (b `div'` 2) `add'` ((bn `div'` 2) `mul'` s)\n\n\t\tps = map (\\p -> p `sub'` p0) [p1, p2, p3]\n\n\t\tp = head ps\n\n\t\tn = head (filter (\\n -> match n ps) [3..100])\n\n\t\trr = x*x + y*y where Point x y = ps !! 0\n\n\tprint $ n*rr*sin(2*pi/n) / 2\n\n"}, {"source_code": "module Main where\n\nimport Control.Monad\nimport Control.DeepSeq\nimport Data.Function\nimport Data.Ratio\nimport Data.List\nimport Data.Char\n\n--import Debug.Trace\n\ndata LDouble = LDouble Double Double deriving (Eq, Show)\n\nstablize (LDouble a b) = LDouble a'' b'' where\n eps = 1e-7\n (a', b') = if b > eps then (a + eps, b - eps) else if b < -eps then (a - eps, b + eps) else (a, b)\n falseSig = signum a' /= 0 && signum b' /= 0 && signum b' /= signum a'\n (a'', b'') = if falseSig then (a' + 2*b', -b') else (a', b')\n\nunaryOp f (LDouble a b) = LDouble (f a) (f b)\nbinaryOp f (LDouble a1 b1) (LDouble a2 b2) = LDouble (f a1 a2) (f b1 b2)\nbinaryBoolOp f (LDouble a1 b1) (LDouble a2 b2) = if a1 == a2 then f b1 b2 else f a1 a2\n\ntoDouble :: LDouble -> Double\ntoDouble (LDouble a b) = a + b\nfromDouble :: Double -> LDouble\nfromDouble x = stablize (LDouble x 0)\n\ninstance Num LDouble where\n x + y = stablize $ binaryOp (+) x y\n x * y = stablize $ binaryOp (*) x y\n abs = unaryOp abs\n signum (LDouble a b) = LDouble (signum a) 0\n negate (LDouble a b) = LDouble (negate a) (negate b)\n fromInteger n = LDouble (fromInteger n) 0\n\ninstance Fractional LDouble where\n (LDouble a b) / (LDouble c d) = stablize $ LDouble (a / (c + d)) (b / (c + d))\n fromRational x = fromDouble (fromIntegral (numerator x) / fromIntegral (denominator x))\n\ninstance Ord LDouble where\n compare x y = if x == y then EQ else if x < y then LT else GT\n (<) = binaryBoolOp (<)\n (<=) = binaryBoolOp (<=)\n (>) = binaryBoolOp (>)\n (>=) = binaryBoolOp (>=)\n\ninstance Read LDouble where\n readsPrec n = convert . doubleReadsPrec where\n doubleReadsPrec = readsPrec n :: String -> [(Double, String)]\n convert = map (\\(x, s) -> (fromDouble x, s))\n\ndoubleFn :: (Double -> Double) -> (LDouble -> LDouble)\ndoubleFn f = fromDouble . f . toDouble\n\ninstance Floating LDouble where\n pi = fromDouble pi\n exp = doubleFn exp\n log = doubleFn log\n sqrt = doubleFn sqrt\n sin = doubleFn sin\n cos = doubleFn cos\n tan = doubleFn tan\n asin = doubleFn asin\n acos = doubleFn acos\n atan = doubleFn atan\n sinh = doubleFn sinh\n cosh = doubleFn cosh\n tanh = doubleFn tanh\n asinh = doubleFn asinh\n acosh = doubleFn acosh\n atanh = doubleFn atanh\n\ntype Point = (LDouble, LDouble)\ntype Vector = (LDouble, LDouble)\n\nsameDouble :: LDouble -> LDouble -> Bool\nsameDouble a b = -1e-6 <= a - b && a - b <= 1e-12\n\nsamePoint ((x1, y1), (x2, y2)) = sameDouble x1 x2 && sameDouble y1 y2\ndist (x1, y1) (x2, y2) = sqrt ((abs $ x1 - x2)**2 + (abs $ y1 - y2)**2)\n\nadd (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)\nhalfVec (x1, y1) (x2, y2) = ((x2 - x1) / 2, (y2 - y1) / 2)\nperpendic (x, y) = (y, -x)\nscale k (x, y) = (k * x / l, k * y / l) where\n l = dist (x, y) (0, 0)\n\n\ncenterAngle nPoly nInterval = 2 * pi * fromIntegral nInterval / fromIntegral nPoly\n\ncenterPos p1 p2 angle\n | angle > pi = centerPos p2 p1 (2*pi - angle)\n | sameDouble angle pi = p1 `add` halfVec p1 p2\n | otherwise = p1 `add` c_ `add` h_ where\n c = dist p1 p2\n c_ = halfVec p1 p2\n h = c * tan (angle/2) / 2\n h_ = scale h $ perpendic c_\n\ngetArea r nPoly = triangleArea * fromIntegral nPoly where\n theta = centerAngle nPoly 1\n triangleArea = r * r * sin theta / 2\n\ntryFit :: (Point, Point, Point) -> Int -> LDouble\ntryFit (p1,p2,p3) 200 = -1\ntryFit (p1,p2,p3) nPoly = if equiangular then area else tryFit (p1,p2,p3) (nPoly+1) where\n center12 = map (\\nInterval -> centerPos p1 p2 $ centerAngle nPoly nInterval) [1..(nPoly-1)]\n center13 = map (\\nInterval -> centerPos p1 p3 $ centerAngle nPoly nInterval) [1..(nPoly-1)]\n centerCandidate = filter samePoint [ (c1, c2) | c1 <- center12, c2 <- center13 ]\n equiangular = length centerCandidate >= 1\n center = fst $ head centerCandidate\n area = getArea (dist p1 center) nPoly\n\nprocess :: [Point] -> LDouble\nprocess points = tryFit (p1,p2,p3) 4 where\n (p1:p2:[p3]) = points\n\ngetWords = words <$> getLine :: IO [String]\ngetDoubles = map read <$> getWords :: IO [LDouble]\ntoPoint (x:[y]) = (x, y) :: Point\n\nmain = do\n points <- replicateM 3 (toPoint <$> getDoubles)\n print $ process points\n\n"}, {"source_code": "module Main where\n\nimport Control.Monad\nimport Control.DeepSeq\nimport Data.Function\nimport Data.Ratio\nimport Data.List\nimport Data.Char\n\n--import Debug.Trace\n\ndata LDouble = LDouble Double Double deriving Eq\n\nstablize (LDouble a b) = LDouble a'' b'' where\n eps = 1e-7\n (a', b') = if b > eps then (a + eps, b - eps) else if b < -eps then (a - eps, b + eps) else (a, b)\n falseSig = signum a' /= 0 && signum b' /= 0 && signum b' /= signum a'\n (a'', b'') = if falseSig then (a' + 2*b', -b') else (a', b')\n\nunaryOp f (LDouble a b) = LDouble (f a) (f b)\nbinaryOp f (LDouble a1 b1) (LDouble a2 b2) = LDouble (f a1 a2) (f b1 b2)\nbinaryBoolOp f (LDouble a1 b1) (LDouble a2 b2) = if a1 == a2 then f b1 b2 else f a1 a2\n\ntoDouble :: LDouble -> Double\ntoDouble (LDouble a b) = a + b\nfromDouble :: Double -> LDouble\nfromDouble x = stablize (LDouble x 0)\n\ninstance Show LDouble where\n show = show . toDouble\n\ninstance Num LDouble where\n x + y = stablize $ binaryOp (+) x y\n x * y = stablize $ binaryOp (*) x y\n abs = unaryOp abs\n signum (LDouble a b) = LDouble (signum a) 0\n negate (LDouble a b) = LDouble (negate a) (negate b)\n fromInteger n = LDouble (fromInteger n) 0\n\ninstance Fractional LDouble where\n (LDouble a b) / (LDouble c d) = stablize $ LDouble (a / (c + d)) (b / (c + d))\n fromRational x = fromDouble (fromIntegral (numerator x) / fromIntegral (denominator x))\n\ninstance Ord LDouble where\n compare x y = if x == y then EQ else if x < y then LT else GT\n (<) = binaryBoolOp (<)\n (<=) = binaryBoolOp (<=)\n (>) = binaryBoolOp (>)\n (>=) = binaryBoolOp (>=)\n\ninstance Read LDouble where\n readsPrec n = convert . doubleReadsPrec where\n doubleReadsPrec = readsPrec n :: String -> [(Double, String)]\n convert = map (\\(x, s) -> (fromDouble x, s))\n\ndoubleFn :: (Double -> Double) -> (LDouble -> LDouble)\ndoubleFn f = fromDouble . f . toDouble\n\ninstance Floating LDouble where\n pi = fromDouble pi\n exp = doubleFn exp\n log = doubleFn log\n sqrt = doubleFn sqrt\n sin = doubleFn sin\n cos = doubleFn cos\n tan = doubleFn tan\n asin = doubleFn asin\n acos = doubleFn acos\n atan = doubleFn atan\n sinh = doubleFn sinh\n cosh = doubleFn cosh\n tanh = doubleFn tanh\n asinh = doubleFn asinh\n acosh = doubleFn acosh\n atanh = doubleFn atanh\n\n\ntype Point = (LDouble, LDouble)\ntype Vector = (LDouble, LDouble)\n\nsameDouble :: LDouble -> LDouble -> Bool\nsameDouble a b = -1e-6 <= a - b && a - b <= 1e-12\n\nsamePoint ((x1, y1), (x2, y2)) = sameDouble x1 x2 && sameDouble y1 y2\ndist (x1, y1) (x2, y2) = sqrt ((abs $ x1 - x2)**2 + (abs $ y1 - y2)**2)\n\nadd (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)\nhalfVec (x1, y1) (x2, y2) = ((x2 - x1) / 2, (y2 - y1) / 2)\nperpendic (x, y) = (y, -x)\nscale k (x, y) = (k * x / l, k * y / l) where\n l = dist (x, y) (0, 0)\n\n\ncenterAngle nPoly nInterval = 2 * pi * fromIntegral nInterval / fromIntegral nPoly\n\ncenterPos p1 p2 angle\n | angle > pi = centerPos p2 p1 (2*pi - angle)\n | sameDouble angle pi = p1 `add` halfVec p1 p2\n | otherwise = p1 `add` c_ `add` h_ where\n c = dist p1 p2\n c_ = halfVec p1 p2\n h = c * tan (angle/2) / 2\n h_ = scale h $ perpendic c_\n\ngetArea r nPoly = triangleArea * fromIntegral nPoly where\n theta = centerAngle nPoly 1\n triangleArea = r * r * sin theta / 2\n\ntryFit :: (Point, Point, Point) -> Int -> LDouble\ntryFit (p1,p2,p3) 200 = -1\ntryFit (p1,p2,p3) nPoly = if equiangular then area else tryFit (p1,p2,p3) (nPoly+1) where\n center12 = map (\\nInterval -> centerPos p1 p2 $ centerAngle nPoly nInterval) [1..(nPoly-1)]\n center13 = map (\\nInterval -> centerPos p1 p3 $ centerAngle nPoly nInterval) [1..(nPoly-1)]\n centerCandidate = filter samePoint [ (c1, c2) | c1 <- center12, c2 <- center13 ]\n equiangular = length centerCandidate >= 1\n center = fst $ head centerCandidate\n area = getArea (dist p1 center) nPoly\n\nprocess :: [Point] -> LDouble\nprocess points = tryFit (p1,p2,p3) 4 where\n (p1:p2:[p3]) = points\n\ngetWords = words <$> getLine :: IO [String]\ngetDoubles = map read <$> getWords :: IO [LDouble]\ntoPoint (x:[y]) = (x, y) :: Point\n\nmain = do\n points <- replicateM 3 (toPoint <$> getDoubles)\n print $ process points\n\n"}, {"source_code": "dist ( [x0,y0], [x1,y1] ) = sqrt ( ( x1 - x0 )^2 + ( y1 - y0 )^2 )\nangle (a,b,c) = acos ( ( c^2 + b^2 - a^2 ) / 2 / b / c )\nisInteger x = abs ( x - fromIntegral ( round x ) ) <= 1e-5\n\nsolve [p0,p1,p2] =\n\tlet\n\t\t[a,b,c] = map dist [ (p0,p1), (p1,p2), (p2,p0) ]\n\t\t[x,y,z] = map angle [ (a,b,c), (b,c,a), (c,a,b) ]\n\t\tr = a / 2 / sin x\n\t\tgood a = all isInteger $ map (/a) [x,y,z]\n\t\tq = head $ filter good $ map (pi/) [3..100]\n\tin\n\t\tr^2 * sin q * pi / q\n\nmain = interact $ show . solve . map ( map read . words ) . lines\n"}, {"source_code": "import Text.Printf\n\ndist ( [x0,y0], [x1,y1] ) = sqrt ( ( x1 - x0 )^2 + ( y1 - y0 )^2 )\n\nangle (a,b,c) = acos ( ( c^2 + b^2 - a^2 ) / ( 2 * b * c ) )\n\na `fmod` b = a - b * ( fromIntegral . round $ a / b )\nfgcd a b = if b < pi / 100 then a else fgcd b ( a `fmod` b )\n\nsolve :: [[Double]] -> Double\nsolve pts =\n\tlet\n\t\tdists = ( \\[a,b,c] -> map dist [ (a,b), (b,c), (c,a) ] ) pts\n\t\tangles = ( \\[a,b,c] -> map angle [ (a,b,c), (b,c,a), (c,a,b) ] ) dists\n\t\tr = ( head dists ) / ( 2 * sin ( head angles ) )\n\t\tq = 2 * foldl1 fgcd angles\n\tin\n\t\tr^2 * ( sin q ) * pi / q\n\nmain = interact $ printf \"%.9f\" . solve . map ( map read . words ) . lines\n"}, {"source_code": "import Text.Printf\n\ndist ( [x0,y0], [x1,y1] ) = sqrt ( ( x1 - x0 )^2 + ( y1 - y0 )^2 )\n\nangle (a,b,c) = acos ( ( c^2 + b^2 - a^2 ) / ( 2 * b * c ) )\n\na `fmod` b = a - b * ( fromIntegral . round $ a / b )\nfgcd a b = if b < pi / 105 then a else fgcd b ( a `fmod` b )\n\nsolve :: [[Double]] -> Double\nsolve pts =\n\tlet\n\t\tdists = ( \\[a,b,c] -> map dist [ (a,b), (b,c), (c,a) ] ) pts\n\t\tangles = ( \\[a,b,c] -> map angle [ (a,b,c), (b,c,a), (c,a,b) ] ) dists\n\t\tr = ( head dists ) / ( 2 * sin ( head angles ) )\n\t\tq = 2 * foldl1 fgcd angles\n\tin\n\t\tr^2 * ( sin q ) * pi / q\n\nmain = interact $ printf \"%.9f\" . solve . map ( map read . words ) . lines\n"}, {"source_code": "import Data.List.Split(splitWhen)\nimport Data.Char\nimport Data.List\nimport Text.Printf\n\ntype Point = (Double, Double)\n\n-- Return sqr of 3 edges, sorted\ncomputeEdges:: Point->Point->Point->[Double]\ncomputeEdges (x1, y1) (x2, y2) (x3, y3)\n = sort [sqrE1, sqrE2, sqrE3]\n where sqrE1 = (x1 - x2) ^ 2 + (y1 - y2) ^2\n sqrE2 = (x1 - x3) ^ 2 + (y1 - y3) ^2\n sqrE3 = (x3 - x2) ^ 2 + (y3 - y2) ^2\n \n-- Get m th point of a n edges regular polygon. diameter = 1\ngetMthPoint:: Int->Int->Point\ngetMthPoint n m =\n (cos a, sin a)\n where a = 2*pi/(fromIntegral n)*(fromIntegral m)\n\n-- Get all possible edges (e1^2, e2^2, e3^2) from\n-- 3 points in a n-edges regular polygon. diameter = 1\nallPossibleEdges::Int->[[Double]]\nallPossibleEdges n = [computeEdges (1.0, 0.0) (getMthPoint n m2) (getMthPoint n m3) | m2<-[1..n `div` 2], m3<-[m2+1..n-1]]\n\n-- If the 2 given triangles are similer return the ratio (^2), or Nothing\ngetSimilarRatioTriangle:: [Double]->[Double]->Maybe Double\ngetSimilarRatioTriangle es1 es2 = \n if maximum rs - minimum rs < 1e-6\n then Just $ head rs\n else Nothing\n where rs = zipWith (/) es1 es2\n \n-- The given triangle\nes1 = computeEdges (0, 0) (1, 1) (0, 1)\n\ncomputeArea:: Int -> Double\ncomputeArea n = nd * 0.5 * (sin $ 2* pi / nd)\n where nd = fromIntegral n\n \ngetSimilarRatio:: [Double]->Int->Maybe Double\ngetSimilarRatio es1 n =\n if null result\n then Nothing\n else head result\n where result = dropWhile (==Nothing) $ map (getSimilarRatioTriangle es1) (allPossibleEdges n)\n \n{-getArea:: [Double]->Int->Maybe Double\ngetArea es1 n =\n (*area) <$> ratio\n where area = computeArea n\n ratio = getSimilarRatio es1 n-}\n \nmain = do\n c <- getContents\n let i = splitWhen isSpace c\n let j = map read i ::[Double]\n let es1 = computeEdges (j!!0, j!!1) (j!!2, j!!3) (j!!4, j!!5)\n --let result = head $ dropWhile (==Nothing) $ map (getArea es1) [3..100]\n let result = Just 1 :: Maybe Double\n (\\(Just x)->printf \"%.6f\" $ x) result\n"}], "src_uid": "980f4094b3cfc647d6f74e840b1bfb62"} {"source_code": "module Main where\n\nimport Data.List\n\nans 8 8 = 8\nans n m = n+m\n\nsolve :: [String] -> Int\nsolve board = ans (rows board) (rows (transpose board)) where\n rows brd = foldl isStroke 0 brd where\n isStroke cnt row\n | all (=='B') row = cnt+1\n | otherwise = cnt\n\nreadBoard 0 = return []\nreadBoard n = do\n s <- getLine\n b <- readBoard (n-1)\n return (s:b)\n\nmain = do\n board <- readBoard 8\n print (solve board)\n", "positive_code": [{"source_code": "import List\nmain = do interact (show . gao . map (map (=='B')) . lines)\ngao a = if b == 16 then 8 else b where\n\tb = f a + f (transpose a)\n\tf = length . filter id . map and\n"}, {"source_code": "\nimport Control.Monad\n\ncount :: [String] -> Int\ncount = snd . foldr step (False, 0)\n where\n step s (vCounted, n)\n | all (=='B') s = (vCounted, n + 1)\n | not vCounted = (True, n + length (filter (=='B') s))\n | otherwise = (vCounted, n)\n\nmain = do\n b <- replicateM 8 getLine\n print $ count b\n"}, {"source_code": "import Data.Array\nimport Data.Bits\n\nmake2DArray :: [[a]] -> Array (Int, Int) a\nmake2DArray lst = let len1 = (length lst) - 1\n len2 = (length $ lst !! 0) - 1\n in array ((0, 0), (len1, len2))\n [ ((i, j), (lst !! i) !! j) | i <- [0..len1], j <- [0..len2] ]\n\npopCount :: (Bits a, Num t) => a -> t\npopCount x = popCount' x 0\n where\n popCount' 0 a = a\n popCount' x a = let b = x .&. (-x)\n xx = x `xor` b\n in popCount' xx (a + 1)\n\nbit2lst :: Bits a => a -> [Int]\nbit2lst x = bit2lst' x 0 []\n where\n bit2lst' 0 i a = a\n bit2lst' x i a = let ii = shiftL 1 i\n in if (x .&. ii) == 0\n then bit2lst' x (i + 1) a\n else bit2lst' (x `xor` ii) (i + 1) (i:a)\n\nbitOf :: Bits a => a -> Int -> Bool\nbitOf x i = (x .&. (shiftL 1 i)) /= 0\n\nsolve :: [String] -> Int\nsolve lst = let max = shiftL 1 8 :: Int\n can = [(i, j) | i <- [0..max-1], j <- [0..max-1]]\n in solve' can 16\n where\n arr = make2DArray lst\n\n solve' (x:xs) a = let xx = fst x\n yy = snd x\n ans = (popCount xx) + (popCount yy)\n d = [ if (bitOf xx i) || (bitOf yy j)\n then (arr ! (j, i)) == 'B'\n else (arr ! (j, i)) == 'W'\n | i <- [0..7], j <- [0..7] ]\n in if ans < a && foldl (&&) True d\n then solve' xs ans\n else solve' xs a\n solve' [] a = a\n\nmain :: IO()\nmain = do cs <- getContents\n let ln = lines cs\n print $ solve ln\n"}, {"source_code": "\nimport Control.Monad (replicateM)\nimport List (transpose)\n\n--------------------------------------------------------------------------------\n{-\nimport HUnit\n\nnames :: [String]\nnames = [\"Input 1\", \"Input 2\", \"WA\", \"Border\", \"Black\"]\n\ntests :: [[String]]\ntests =\n [\n [ \"WWWBWWBW\",\n \"BBBBBBBB\",\n \"WWWBWWBW\",\n \"WWWBWWBW\",\n \"WWWBWWBW\",\n \"WWWBWWBW\",\n \"WWWBWWBW\",\n \"WWWBWWBW\" ],\n [ \"WWWWWWWW\",\n \"BBBBBBBB\",\n \"WWWWWWWW\",\n \"WWWWWWWW\",\n \"WWWWWWWW\",\n \"WWWWWWWW\",\n \"WWWWWWWW\",\n \"WWWWWWWW\" ],\n [ \"BBBBBBBB\",\n \"BBBBBBBB\",\n \"BWWWWWWW\",\n \"BWWWWWWW\",\n \"BWWWWWWW\",\n \"BWWWWWWW\",\n \"BWWWWWWW\",\n \"BWWWWWWW\" ],\n [ \"BBBBBBBB\",\n \"BWWWWWWB\",\n \"BWWWWWWB\",\n \"BWWWWWWB\",\n \"BWWWWWWB\",\n \"BWWWWWWB\",\n \"BWWWWWWB\",\n \"BBBBBBBB\" ],\n [ \"BBBBBBBB\",\n \"BBBBBBBB\",\n \"BBBBBBBB\",\n \"BBBBBBBB\",\n \"BBBBBBBB\",\n \"BBBBBBBB\",\n \"BBBBBBBB\",\n \"BBBBBBBB\" ]\n ]\n\nresults = [3, 1, 3, 4, 8]\n\nallTests :: Test\nallTests = TestList \"AllTests\" $\n zipWith3 (\\name lines ans -> Test name $ assertEq ans $ solve lines) names tests results\n\ntest :: IO ()\ntest = run allTests\n-}\n--------------------------------------------------------------------------------\n\nsize :: Int\nsize = 8\n\nsolve :: [String] -> Int\nsolve lines\n | any (== size) [n, m] = min n m\n | otherwise = n + m\n where\n n = length $ filter (all (== 'B')) lines\n m = length $ filter (all (== 'B')) $ transpose lines\n\nmain :: IO ()\nmain = replicateM size getLine >>= print . solve\n"}, {"source_code": "import Data.List\n\nsolve :: [String] -> Int \nsolve s = let \n f = length . filter ('W' `notElem`)\n total = f s + f (transpose s)\n in case total of\n 16 -> 8\n n -> n\n\nmain = interact $ show . solve . lines"}, {"source_code": "main = do\n l1 <- getLine\n l2 <- getLine\n l3 <- getLine\n l4 <- getLine\n l5 <- getLine\n l6 <- getLine\n l7 <- getLine\n l8 <- getLine\n print (solve l1 l2 l3 l4 l5 l6 l7 l8)\n \n \nsolve :: String -> String -> String -> String -> String -> String -> String -> String -> Int\nsolve l1 l2 l3 l4 l5 l6 l7 l8\n | b_in_row + b_in_col == 16 = 8\n | otherwise = b_in_row + b_in_col\n where b_in_col = sum [b_in l1, b_in l2, b_in l3, b_in l4, b_in l5, b_in l6, b_in l7, b_in l8]\n b_in l = if (l == \"BBBBBBBB\") then 1 else 0\n b_in_row = sum (map b_in_r [0..7])\n b_in_r n = if ( ((l1 !! n) == 'B') && ((l2 !! n) == 'B') && ((l3 !! n) == 'B') && ((l4 !! n) == 'B') && ((l5 !! n) == 'B') && ((l6 !! n) == 'B') && ((l7 !! n) == 'B') && ((l8 !! n) == 'B') ) then 1 else 0"}, {"source_code": "import Control.Monad\n\ncount :: [String] -> Int\ncount = snd . foldr step (False, 0)\n where\n step s (vCounted, n)\n | all (=='B') s = (vCounted, n + 1)\n | not vCounted = (True, n + length (filter (=='B') s))\n | otherwise = (vCounted, n)\n\nmain = do\n b <- replicateM 8 getLine\n print $ count b\n"}, {"source_code": "import Data.List\n\nmain :: IO()\nmain = do interact (show . gao . lines)\n\ngao :: [String] -> Int\ngao s\n | n == 64 = 8\n | otherwise = f s + f (transpose s)\n where\n n = length $ filter (\\x -> x == 'B') $ unlines s\n f s = length $ filter (\\x -> 'W' `notElem` x) s\n"}, {"source_code": "import Data.List\n\nmain :: IO()\nmain = do interact (show . gao . lines)\n\ngao :: [String] -> Int\ngao s\n | n == 64 = 8\n | otherwise = f s + f (transpose s)\n where\n n = length $ filter (== 'B') $ unlines s\n f = length . filter ('W' `notElem`)\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\nsolve :: [String] -> [String]\nsolve = fmap return $ do\n xs <- take 8\n return . show $ case partition (all (== 'B')) xs of\n (_ , [] ) -> 8\n (as, b : _) -> length as + length (filter (== 'B') b)\n\nmain = interact $ unlines . solve . lines\n"}, {"source_code": "module Main where\n\nimport Data.List (transpose)\n\nmain :: IO ()\nmain = interact $ show . solve . lines\n\nsolve :: [String] -> Int\nsolve board = if total == 16 then 8 else total\n where\n total = count board + count (transpose board)\n count = length . filter (all ('B' ==))\n"}, {"source_code": "\nimport Control.Monad\nimport Data.List\n\nqq=sequence(replicate 8 [True,False])\n\npl True _ = replicate 8 'B'\npl False l = l\n\npaint = zipWith pl\n\ns l=minimum$ do\n vs <- qq\n hs <- qq\n guard $ l == (paint vs $ transpose(paint hs (replicate 8 (replicate 8 'W'))))\n return (length $ filter id (vs ++ hs))\n\nmain=interact$show.s.lines\n"}, {"source_code": "import Data.List\n\nparse = lines\n\nsolve ::[[Char]] -> Int\nsolve l = \n let\n res = (calc l) + (calc $ transpose l)\n calc = length . filter id . map (all (== 'B'))\n in\n if res == 16\n then 8\n else res\n\npresent = show\n\n\nmain = interact $ present . solve . parse\n"}], "negative_code": [{"source_code": "import Data.Array\nimport Data.Bits\n\nmake2DArray :: [[a]] -> Array (Int, Int) a\nmake2DArray lst = let len1 = (length lst) - 1\n len2 = (length $ lst !! 0) - 1\n in array ((0, 0), (len1, len2))\n [ ((i, j), (lst !! i) !! j) | i <- [0..len1], j <- [0..len2] ]\n\npopCount :: (Bits a, Num t) => a -> t\npopCount x = popCount' x 0\n where\n popCount' 0 a = a\n popCount' x a = let b = x .&. (-x)\n xx = x `xor` b\n in popCount' xx (a + 1)\n\nbit2lst :: Bits a => a -> [Int]\nbit2lst x = bit2lst' x 0 []\n where\n bit2lst' 0 i a = a\n bit2lst' x i a = let ii = shiftL 1 i\n in if (x .&. ii) == 0\n then bit2lst' x (i + 1) a\n else bit2lst' (x `xor` ii) (i + 1) (i:a)\n\nbitOf :: Bits a => a -> Int -> Bool\nbitOf x i = (x .&. (shiftL 1 i)) /= 0\n\nsolve :: [String] -> Int\nsolve lst = let max = shiftL 1 8 :: Int\n can = [(i, j) | i <- [0..max-1], j <- [0..max-1]]\n in solve' can 16\n where\n arr = make2DArray lst\n\n solve' (x:xs) a = let xx = fst x\n yy = snd x\n ans = (popCount xx) + (popCount yy)\n d = [ if (bitOf xx i) || (bitOf yy j)\n then 'W'\n else arr ! (j, i)\n | i <- [0..7], j <- [0..7] ]\n in if ans < a && (not $ elem 'B' d)\n then solve' xs ans\n else solve' xs a\n solve' [] a = a\n\nmain :: IO()\nmain = do cs <- getContents\n let ln = lines cs\n print $ solve ln\n"}, {"source_code": "main = do\n l1 <- getLine\n l2 <- getLine\n l3 <- getLine\n l4 <- getLine\n l5 <- getLine\n l6 <- getLine\n l7 <- getLine\n l8 <- getLine\n print (solve l1 l2 l3 l4 l5 l6 l7 l8)\n \n \nsolve :: String -> String -> String -> String -> String -> String -> String -> String -> Int\nsolve l1 l2 l3 l4 l5 l6 l7 l8\n | b_in_l1 == 8 = 8\n | otherwise = b_in_l1 + b_in_col\n where b_in_l1 = length (filter (== 'B') l1)\n b_in_col = sum [b_in l1, b_in l2, b_in l3, b_in l4, b_in l5, b_in l6, b_in l7, b_in l8]\n b_in l = if (l == \"BBBBBBBB\") then 1 else 0"}, {"source_code": "\nimport Control.Monad\nimport Data.List\n\nqq=sequence(replicate 8 [True,False])\n\ngood (str, True) = all (=='B') str\ngood _ = True\n\nw :: [String] -> [Bool] -> [Int]\nw l f | all good z = [length (filter snd z) + length (filter (any (=='B')) $ transpose $ map fst $ filter (not . snd) z)]\n | otherwise = []\n where\n z = zip l f\n\ns l=minimum$qq>>=w l\n\nmain=interact$show.s.lines"}], "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0"} {"source_code": "module Main where\nimport qualified Data.ByteString.Char8 as B\nimport Text.Printf\nimport Control.Applicative\n\nreadInt = maybe undefined fst . B.readInt\nreadInts = fmap readInt . B.words\n\nt2s t = B.pack $ printf \"%02d:%02d\" h m\n where\n (h, m) = (t `rem` 1440) `quotRem` 60\n\ns2t s = h * 60 + m\n where\n (h:m:_) = map readInt $ B.split ':' s\n\nsolve s = length $ takeWhile ((/=) <*> B.reverse) $ map t2s [(s2t s)..]\n \n\nmain = B.getLine >>= print . solve . B.filter (/= '\\r')\n\n", "positive_code": [{"source_code": "import Data.Char\n\nmain = do\n [a, b, c, d, e] <- getLine\n print $ solve [n a, n b, n d, n e]\n where\n n x = ord x - ord '0'\n\n\n--solve :: [Int] -> Int\nsolve a = fst . head . dropWhile (not . isPal . snd) $ zip [0..] (iterate increment a)\n where\n increment [2, 3, 5, 9] = [0, 0, 0, 0]\n increment [h, 9, 5, 9] = [h+1, 0, 0, 0]\n increment [h, h', 5, 9] = [h, h'+1, 0, 0]\n increment [h, h', m, 9] = [h, h', m+1, 0]\n increment [h, h', m, m'] = [h, h', m, m' + 1]\n isPal a = a == reverse a\n"}, {"source_code": "-- Try Codeforces\n-- author: Leonardone @ NEETSDKASU\n\nmain = print . solve =<< getLine\n\nispari v = s == r where\n s = tail $ show v\n r = reverse s\n \ninc v = v2 where\n h = mod (div v 100) 100\n m = mod v 100\n (h2, m2) = if m == 59 then (h+1, 0) else (h, m+1)\n v2 = (if h2 > 23 then 0 else h2) * 100 + m2 + 10000\n\ncalc v\n | ispari v = 0\n | otherwise = 1 + calc (inc v)\n\nsolve s = calc val where\n hs = read $ take 2 s\n ms = read $ drop 3 s\n val = hs * 100 + ms + 10000\n"}, {"source_code": "padZero s\n\t|length s ==1 = '0':s\n\t|otherwise =s\ncreateS h m = padZero(show h)++padZero(show m)\nisPal s = s== reverse s\nallS=([createS h m|h<-[0..23],m<-[0..59]]) ++[\"0000\"]\n\nfirstPas (h,m) = length $ takeWhile (\\x->not (isPal x)) $ dropWhile (/=(createS h m)) allS\n\nparse x=(read (take 2 x)::Int,read (drop 3 x)::Int)\nmain=do\n\ttime<-getLine\n\tprint $ (firstPas.parse) time"}, {"source_code": "main=getLine>>=print.f\nf[h1,h2,_,m1,m2] = length.takeWhile (not.isPalindrome.show) $ iterate suc (T h m)\n where\n h, m :: Int\n h = read[h1, h2]\n m = read[m1, m2]\n\nisPalindrome xs = xs == reverse xs\n\ndata T = T Int Int\n\ninstance Show T where\n show (T h m) = hh ++ mm\n where\n hh | h <= 9 = \"0\" ++ show h\n | otherwise = show h\n mm | m <= 9 = \"0\" ++ show m\n | otherwise = show m\n\nsuc (T 23 59) = T 0 0\nsuc (T h 59) = T (h + 1) 0\nsuc (T h m) = T h (m + 1)"}, {"source_code": "main = do\n tstr_ <- getLine\n let\n\t[t1,t2,':',m1,m2] = tstr_\n\n\tcheck tt mm = let\n\t\t\t tstr = if tt<10\n\t\t\t\t then '0':(show tt)\n\t\t\t\t else show tt\n\t\t\t mstr = if mm<10\n\t\t\t\t then '0':(show mm)\n\t\t\t\t else show mm\n\n\t\t\t str = tstr++mstr\n\t\t\tin\n\t\t\t str == reverse str\n\n\tsucceed v tt mm\n\t | check tt mm = v\n\t | otherwise\t= let\n\t\t\t\t(hplus,mm') = (mm+1) `quotRem` 60\n\t\t\t\ttt' = (tt+hplus) `rem` 24\n\t\t\t in\n\t\t\t\tsucceed (v+1) tt' mm'\n\n print $ succeed 0 (read $ [t1,t2]) (read $ [m1,m2])\n"}], "negative_code": [{"source_code": "import Data.Char\n\nmain = do\n [a, b, c, d, e] <- getLine\n print $ solve [n a, n b, n d, n e]\n where\n n x = ord x - ord '0'\n\n\n--solve :: [Int] -> Int\nsolve a = fst . head . dropWhile (not . isPal . snd) $ zip [0..] (iterate increment a)\n where\n increment [h, 9, 5, 9] = [h+1, 0, 0, 0]\n increment [h, h', 5, 9] = [h, h'+1, 0, 0]\n increment [h, h', m, 9] = [h, h', m+1, 0]\n increment [h, h', m, m'] = [h, h', m, m' + 1]\n isPal a = a == reverse a\n"}, {"source_code": "main=getLine>>=print.f\nf[h1,h2,_,m1,m2]\n | m <= m' = m' - m\n | h == 0 = 60 - m + 10\n | h == 23 = 60 - m\n | otherwise = 60 + m' - m\n where\n h, m :: Int\n h = read[h1, h2]\n m = read[m1, m2]\n m' = read[h2, h1]"}, {"source_code": "main=getLine>>=print.f\nf[h1,h2,_,m1,m2]\n | m <= m' = m' - m\n | h == 23 = 60 - m\n | otherwise = 60 + m' - m\n where\n h, m :: Int\n h = read[h1, h2]\n m = read[m1, m2]\n m' = read[h2, h1]\n"}], "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5"} {"source_code": "main :: IO ()\nmain = print . solve . map read . words =<< getLine\n\nchoose :: Integer -> Integer -> Integer\nchoose n 0 = 1\nchoose 0 k = 0\nchoose n k = choose (n - 1) (k - 1) * n `div` k \n\nsolve :: [Integer] -> Integer\nsolve [n, k] = 1 + solve' 2 [1, 2, 9]\n where solve' :: Integer -> [Integer] -> Integer\n solve' i [] = 0\n solve' i (c:cx) | i > k = 0\n | otherwise = (choose n i) * c + solve' (i + 1) cx\n", "positive_code": [{"source_code": "module Main where\n import Data.List\n import Control.Monad\n import Data.Array\n import qualified Data.Set as S\n\n toArray :: [a] -> Array Int a\n toArray xs =\n let ls = length xs - 1\n in array (0, ls) $ zip [0..ls] xs\n\n readInt :: String -> Int\n readInt s = read s :: Int\n\n readInteger :: String -> Integer\n readInteger s = read s :: Integer\n\n readMultilineInput :: Int -> (String -> IO a) -> IO [a]\n readMultilineInput n transformer = replicateM n (getLine >>= transformer)\n\n elemSet :: (Ord a) => a -> S.Set a -> Bool\n elemSet elem sets =\n let found = elem `S.lookupIndex` sets\n in toBool found\n where\n toBool :: Maybe Int -> Bool\n toBool (Just _) = True\n toBool Nothing = False\n\n\n doOut :: Integer -> Integer -> Integer\n doOut n 1 = 1\n doOut n 2\n | n == 1 = 1\n | n == 2 = 2\n | otherwise = (doOut (n - 1) 2) + (n - 1)\n doOut n 3\n | n == 1 = 1\n | n == 2 = 2\n | n == 3 = 6\n | otherwise = (doOut (n - 1) 3) + (n - 1) * (n - 1)\n doOut n 4\n | n == 1 = 1\n | n == 2 = 2\n | n == 3 = 6\n | n == 4 = 24\n | otherwise =\n let prev = doOut (n - 1) 4\n q = (n - 1) * (n -1) * (n - 1)\n t = sum [1..(n - 2)]\n m = n - 7\n in prev + q + (t * m)\n\n main :: IO()\n main = do\n [n, k] <- getLine >>= return . (map readInteger) . words\n print $ doOut n k\n\n\n"}, {"source_code": "module Main where\nimport Data.Int\n\nmain = getLine >>= print . exec\nexec = solve . map read . words\nsolve [n, k] = sum $ take (fromIntegral k + 1) $ zipWith (*) zs cs\n where\n zs = scanl (\\s (i, d) -> i * s + d) 1 $ zip [1..n] (cycle [-1, 1]) :: [Int64]\n cs = [1, n, (n - 1) * n `quot` 2, (n - 2) * (n - 1) * n `quot` 6, (n - 3) * (n - 2) * (n - 1) * n `quot` 24]\n\n"}, {"source_code": "module Main where\nimport Data.Int\n\nmain = getLine >>= print . exec\nexec = solve . map read . words\nsolve [n, k] = sum $ take (fromIntegral k + 1) $ zipWith (*) zs cs\n where\n zs = [1, 0, 1, 2, 9, 44]\n cs = [1, n, (n - 1) * n `quot` 2, (n - 2) * (n - 1) * n `quot` 6, (n - 3) * (n - 2) * (n - 1) * n `quot` 24]\n\n"}], "negative_code": [{"source_code": "main :: IO ()\nmain = print . solve . map read . words =<< getLine\n\nchoose :: Int -> Int -> Int\nchoose n 0 = 1\nchoose 0 k = 0\nchoose n k = choose (n - 1) (k - 1) * n `div` k \n\nsolve :: [Int] -> Int\nsolve [n, k] = 1 + solve' 2 [1, 2, 9]\n where solve' :: Int -> [Int] -> Int\n solve' i [] = 0\n solve' i (c:cx) | i > k = 0\n | otherwise = (choose n i) * c + solve' (i + 1) cx\n"}, {"source_code": "module Main where\n import Data.List\n import Control.Monad\n import Data.Array\n import qualified Data.Set as S\n\n toArray :: [a] -> Array Int a\n toArray xs =\n let ls = length xs - 1\n in array (0, ls) $ zip [0..ls] xs\n\n readInt :: String -> Int\n readInt s = read s :: Int\n\n readMultilineInput :: Int -> (String -> IO a) -> IO [a]\n readMultilineInput n transformer = replicateM n (getLine >>= transformer)\n\n elemSet :: (Ord a) => a -> S.Set a -> Bool\n elemSet elem sets =\n let found = elem `S.lookupIndex` sets\n in toBool found\n where\n toBool :: Maybe Int -> Bool\n toBool (Just _) = True\n toBool Nothing = False\n\n\n localExtreme :: (Int, Int, Int) -> Bool\n localExtreme (a, b, c)\n | a < b && b > c = True\n | a > b && b < c = True\n | otherwise = False\n\n doOut :: Int -> Int -> Int\n doOut n 1 = 1\n doOut n 2\n | n == 1 = 1\n | n == 2 = 2\n | otherwise = (doOut (n - 1) 2) + (n - 1)\n doOut n 3\n | n == 1 = 1\n | n == 2 = 2\n | n == 3 = 6\n | otherwise = (doOut (n - 1) 3) + (n - 1) * (n - 1)\n doOut n 4\n | n == 1 = 1\n | n == 2 = 2\n | n == 3 = 6\n | n == 4 = 24\n | otherwise =\n let prev = doOut (n - 1) 4\n q = (n - 1) * (n -1) * (n - 1)\n t = sum [1..(n - 2)]\n m = n - 7\n in prev + q + (t * m)\n\n main :: IO()\n main = do\n [n, k] <- getLine >>= return . (map readInt) . words\n print $ doOut n k\n\n\n"}, {"source_code": "module Main where\n import Data.List\n import Control.Monad\n import Data.Array\n import qualified Data.Set as S\n\n toArray :: [a] -> Array Int a\n toArray xs =\n let ls = length xs - 1\n in array (0, ls) $ zip [0..ls] xs\n\n readInt :: String -> Int\n readInt s = read s :: Int\n\n readMultilineInput :: Int -> (String -> IO a) -> IO [a]\n readMultilineInput n transformer = replicateM n (getLine >>= transformer)\n\n elemSet :: (Ord a) => a -> S.Set a -> Bool\n elemSet elem sets =\n let found = elem `S.lookupIndex` sets\n in toBool found\n where\n toBool :: Maybe Int -> Bool\n toBool (Just _) = True\n toBool Nothing = False\n\n\n localExtreme :: (Int, Int, Int) -> Bool\n localExtreme (a, b, c)\n | a < b && b > c = True\n | a > b && b < c = True\n | otherwise = False\n\n doOut :: Int -> Int -> Int\n doOut n 1 = n\n doOut n 2 = (doOut (n - 1) 2) + (n - 1)\n doOut n 3\n | n == 1 = 1\n | n == 2 = 2\n | n == 3 = 6\n | otherwise = (doOut (n - 1) 3) + (n - 1) * (n - 1)\n doOut n 4\n | n == 1 = 1\n | n == 2 = 2\n | n == 3 = 6\n | n == 4 = 24\n | otherwise =\n let prev = doOut (n - 1) 4\n q = (n - 1) * (n -1) * (n - 1)\n t = sum [1..(n - 2)]\n m = n - 7\n in prev + q + (t * m)\n\n main :: IO()\n main = do\n [n, k] <- getLine >>= return . (map readInt) . words\n print $ doOut n k\n\n\n"}], "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f"} {"source_code": "main = do\n n <- read `fmap` getLine :: IO Int\n s <- getLine\n let divs = [d | d <- [2..n], n `mod` d == 0]\n putStrLn $ foldl f s divs\n\nf :: String -> Int -> String\nf s d = (reverse (take d s)) ++ (drop d s)", "positive_code": [{"source_code": "divisors :: Int -> [Int]\ndivisors n = [x | x <- [1..n], n `mod` x == 0]\n\ncypher :: Int -> [a] -> [a]\ncypher n lst = cypher' (divisors n) lst\n where cypher' [] lst' = lst'\n cypher' (x:xs) lst' = cypher' xs $ reverse (take x lst') ++ (drop x lst')\n\nrestore_map :: String -> [Int] -> String\nrestore_map s [] = []\nrestore_map s (x: xs) = (s !! x: restore_map s xs)\n\nsolve :: String -> String\nsolve s = restore_map s $ cypher n [0..n-1]\n where n = length s\n\nmain :: IO()\nmain = do\n _ <- getLine\n l <- getLine\n putStrLn $ solve l\n\n"}, {"source_code": "import Data.List\n\nf::Int->Int->[Int]->[Int]\nf n m ans\n |m==1 =ans\n |n `mod` m==0=let t1=reverse (take m ans)\n t2=(drop m ans)\n in f n (m - 1) (t1++t2)\n |otherwise=f n (m-1) ans\n\n\nmain = do\n e1<-getLine\n e2<-getLine\n let m=read e1::Int\n putStrLn $ map snd $ sort $zip (f m m [0..(m-1)]) e2"}], "negative_code": [{"source_code": "import Data.List\n\nf::Int->Int->[Int]->[Int]\nf n m ans\n |m==1 =ans\n |otherwise=let t1=reverse (take m ans)\n t2=(drop m ans)\n in f n (m `div` 2) (t1++t2)\n\n\n\nmain = do\n e1<-getLine\n e2<-getLine\n let m=read e1::Int\n putStrLn $ map snd $ sort $zip (f m m [0..(m-1)]) e2 "}], "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3"} {"source_code": "{-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -funfolding-use-threshold=16 -fexcess-precision -funbox-strict-fields #-} \nmodule Main where\nimport Control.Monad\nimport Data.List\n\nmain = do\n g <- replicateM 10 getLine\n putStr $ if solve g then \"YES\" else \"NO\"\n\nsolve g = ok g || ok (transpose g) || ok (diags g) || ok (diags $ reverse g)\n where ok = any (any (\\w -> notElem 'O' w && (length (filter (== 'X') w) >= 4)) . windows 5)\n\ndiags = tail . go [] \n where\n go p r = map head p : case r of\n [] -> transpose ts\n (r:rs) -> go (r:ts) rs\n where ts = map tail p\n\nwindows n xs = zipWith const (map (take n) $ tails xs) (drop (n - 1) xs)", "positive_code": [{"source_code": "import Data.Array\n\ndata Dir = R|L\n\nconvertToArr x=array ((0,0),(9,9)) [((i,j),x!!i!!j)|i<-[0..9],j<-[0..9]]\n\ngetCol array n = [array!(i,n)|i<-[0..9]]\ngetRow array n = [array!(n,i)|i<-[0..9]]\n\t\ngetDiag R array n \n\t|n>=0 = [array!(i-n,i)|i<-[n..9]]\n\t|otherwise = [array!(i,i-(abs n))|i<-[abs n..9]]\n\ngetDiag L array n \n\t|n>=0 = [array!(i,9-i+n)|i<-[n..9]]\n\t|otherwise = [array!(i,9-i+n)|i<-[0..9+n]]\n\t\n\t\ntestLine (a:b:c:d:e:[])\n\t|a=='X' && b=='X' && c=='X' && d=='X' && e=='.' = True\n\t|a=='.' && b=='X' && c=='X' && d=='X' && e=='X' = True\n\t|a=='X' && b=='.' && c=='X' && d=='X' && e=='X' = True\n\t|a=='X' && b=='X' && c=='.' && d=='X' && e=='X' = True\n\t|a=='X' && b=='X' && c=='X' && d=='.' && e=='X' = True\n\t|otherwise = False\ntestLine (a:b:c:d:e:xs)\n\t|a=='X' && b=='X' && c=='X' && d=='X' && e=='.' = True\n\t|a=='.' && b=='X' && c=='X' && d=='X' && e=='X' = True\n\t|a=='X' && b=='.' && c=='X' && d=='X' && e=='X' = True\n\t|a=='X' && b=='X' && c=='.' && d=='X' && e=='X' = True\n\t|a=='X' && b=='X' && c=='X' && d=='.' && e=='X' = True\n\t|otherwise = testLine (b:c:d:e:xs)\n\ntestLine _ = False\n\ngetAllLines array= [getRow array i|i<-[0..9]]++[getCol array i|i<-[0..9]]++[getDiag R array i|i<-[-9..9]]++[getDiag L array i|i<-[-9..9]]\n\t\ntestAll = or.map testLine.getAllLines\nres True = \"YES\"\nres _ = \"NO\"\n\t\t\nmain=interact$res.or.map testLine.getAllLines.convertToArr.lines"}, {"source_code": "import Data.List\nimport Control.Applicative\n\ndata Cell = Cross | Nought | Empty\n deriving (Show, Eq)\n\nparseCell :: Char -> Cell\nparseCell 'X' = Cross\nparseCell 'O' = Nought\nparseCell '.' = Empty\n\ntype Field = [[Cell]]\n\nparseField :: String -> Field\nparseField = (map (\\x -> map parseCell x)) . lines\n\ngetDiagonals' :: Field -> [[Cell]]\ngetDiagonals' field = \n map (map head) . (takeWhile (not . null)) . (iterate (filter (not . null) . map tail)) . map (\\(row, i) -> drop i row) $ zip field [0..]\n\ngetDiagonals :: Field -> [[Cell]]\ngetDiagonals field = \n concat . map getDiagonals' $ ([id, transpose] <*> [field, map reverse field])\n \ngetLines :: Field -> [[Cell]]\ngetLines field = concat [field, transpose field, getDiagonals field]\n \nwinCriteria = foldl1' (\\f g -> \\x -> (f x) || (g x)) $ map isInfixOf [\n [Cross, Cross, Cross, Cross, Cross],\n [Empty, Cross, Cross, Cross, Cross],\n [Cross, Empty, Cross, Cross, Cross],\n [Cross, Cross, Empty, Cross, Cross],\n [Cross, Cross, Cross, Empty, Cross],\n [Cross, Cross, Cross, Cross, Empty]]\n \nisPotentialWin :: Field -> Bool\nisPotentialWin field = any winCriteria (getLines field)\n\nbool2YesNo :: Bool -> String\nbool2YesNo b = if b then \"YES\" else \"NO\"\n\nmain = interact (bool2YesNo . isPotentialWin . parseField)"}], "negative_code": [{"source_code": "{-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -funfolding-use-threshold=16 -fexcess-precision -funbox-strict-fields #-} \nmodule Main where\nimport qualified Data.ByteString.Char8 as B\nimport Control.Monad\nimport Data.List\n\nmain = do\n g <- replicateM 10 getLine\n putStr $ if solve g then \"YES\" else \"NO\"\n\nsolve :: [String] -> Bool\nsolve g = ok g || ok (transpose g) || ok (diags g) || ok (diags $ reverse g)\n where ok = any (any (\\c -> notElem 'O' c && ((>= 4) $ length $ filter (== 'X') c)) . chunks 5)\n\ndiags = tail . go [] \n where\n go b ess = map head b : case ess of\n [] -> transpose ts\n (e:es) -> go (e:ts) es\n where ts = map tail b\n\nreadInt = maybe undefined fst . B.readInt\nreadInts = fmap readInt . B.words\n\nchunks :: Int -> [a] -> [[a]]\nchunks _ [] = []\nchunks n xs =\n let (ys, zs) = splitAt n xs\n in ys : chunks n zs\n\n{-\nneg R\npos M\n-}"}, {"source_code": "{-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -funfolding-use-threshold=16 -fexcess-precision -funbox-strict-fields #-} \nmodule Main where\nimport Control.Monad\nimport Data.List\n\nmain = do\n g <- replicateM 10 getLine\n putStr $ if solve g then \"YES\" else \"NO\"\n\nsolve g = ok g || ok (transpose g) || ok (diags g) || ok (diags $ reverse g)\n where ok = any (any ((>= 4) . length . filter (== 'X') . map (\\k -> if k == '.' then 'X' else k)) . windows 5)\n\ndiags = tail . go [] \n where\n go p r = map head p : case r of\n [] -> transpose ts\n (r:rs) -> go (r:ts) rs\n where ts = map tail p\n\nwindows n xs = zipWith const (map (take n) $ tails xs) (drop (n - 1) xs)"}, {"source_code": "import Data.Array\n\nconvertToArr x=array ((0,0),(9,9)) [((i,j),x!!i!!j)|i<-[0..9],j<-[0..9]]\n\ngetCol array n = [array!(i,n)|i<-[0..9]]\ngetRow array n = [array!(n,i)|i<-[0..9]]\n\t\ngetDiag array n\n\t|n>=0 = [array!(i-n,i)|i<-[n..9]]\n\t|otherwise = [array!(i,i-(abs n))|i<-[abs n..9]]\n\ntestLine (a:b:c:d:e:[])\n\t|a=='X' && b=='X' && c=='X' && d=='X' && e=='.' = True\n\t|a=='.' && b=='X' && c=='X' && d=='X' && e=='X' = True\n\t|a=='X' && b=='.' && c=='X' && d=='X' && e=='X' = True\n\t|a=='X' && b=='X' && c=='.' && d=='X' && e=='X' = True\n\t|a=='X' && b=='X' && c=='X' && d=='.' && e=='X' = True\n\t|otherwise = False\ntestLine (a:b:c:d:e:xs)\n\t|a=='X' && b=='X' && c=='X' && d=='X' && e=='.' = True\n\t|a=='.' && b=='X' && c=='X' && d=='X' && e=='X' = True\n\t|a=='X' && b=='.' && c=='X' && d=='X' && e=='X' = True\n\t|a=='X' && b=='X' && c=='.' && d=='X' && e=='X' = True\n\t|a=='X' && b=='X' && c=='X' && d=='.' && e=='X' = True\n\t|otherwise = testLine (b:c:d:e:xs)\n\ntestLine _ = False\n\ngetAllLines array= [getRow array i|i<-[0..9]]++[getCol array i|i<-[0..9]]++[getDiag array i|i<-[-9..9]]\n\t\ntestAll = or.map testLine.getAllLines\nres True = \"YES\"\nres _ = \"NO\"\n\t\t\nmain=interact$res.or.map testLine.getAllLines.convertToArr.lines"}], "src_uid": "d5541028a2753c758322c440bdbf9ec6"} {"source_code": "module Main where\n\nimport Control.Monad\n\nnCar n = (n+1) `div` 2\ntimeCar n = nCar n * 3 - 3\n\nmain = do\n [a, b, c] <- ( map read . words ) `liftM` getLine\n\n putStrLn $ show $ 30 + max (timeCar a) (max (1 + timeCar b) (2 + timeCar c))\n", "positive_code": [{"source_code": "main = interact $ show . maximum . zipWith (+) [30,31..] . map (\\x -> 3 * ((x - 1) `div` 2)) . map read . words\n"}, {"source_code": "main = interact $ unlines . map (\\s -> show . solve $ map read $ words s) . lines \n\nsolve :: [Int] -> Int\nsolve xs = maximum $ zipWith (+) [30,31..] $ map (\\x -> 3 * ((x - 1) `div` 2)) xs\n"}, {"source_code": "main = interact $ unlines . map (\\s -> solve $ map read $ words s) . lines \n\nsolve :: [Int] -> String\nsolve [r, g, b] = show $ maximum [30 + 3 * ((r - 1) `div` 2), 31 + 3 * ((g - 1) `div` 2), 32 + 3 * ((b - 1) `div` 2)]\n"}, {"source_code": "main = interact $ show . solve . map read . words \n\nsolve xs = maximum $ zipWith (+) [30,31..] $ map (\\x -> 3 * ((x - 1) `div` 2)) xs\n"}, {"source_code": "\nmain = do\n a <- (map( (`div`2) . succ . read :: String -> Int ).words <$> getLine)\n print $ 30 + (maximum $ zipWith (\\x y -> x + (y-1) * 3) [0..2] a)\n"}, {"source_code": "data Students = Red Int | Green Int | Blue Int\n\ntimeUp = 30\nperiod = 3\n\ntime :: Students -> Int\ntime (Red 0) = 0\ntime (Green 0) = 0\ntime (Blue 0) = 0\ntime (Red n) = timeUp + (div n 2 + mod n 2 - 1) * period\ntime (Green n) = timeUp + (div n 2 + mod n 2 - 1) * period + 1\ntime (Blue n) = timeUp + (div n 2 + mod n 2 - 1) * period + 2\n\nmain = do\n line <- getLine\n let [r, g, b] = map read $ words line\n let students = [Red r, Green g, Blue b]\n print $ maximum (map time students)"}, {"source_code": "main = interact $ show.maximum.zipWith (+) [0, 1, 2].map (\\x -> 3 * (x `div` 2 + x `mod` 2 - 1) + 30).map read.words"}, {"source_code": "main = interact $ show.maximum.zipWith (+) [0, 1, 2].map f.map read.words\n where f x = 3 * (x `div` 2 + x `mod` 2 - 1) + 30"}, {"source_code": "f [r, g, b] i | r + g + b == 0 = i + 29\n | i `mod` 3 == 0 = f [max (r - 2) 0, g, b] (i + 1)\n | i `mod` 3 == 1 = f [r, max (g - 2) 0, b] (i + 1)\n | i `mod` 3 == 2 = f [r, g, max (b - 2) 0] (i + 1)\nmain = do\n [r, g, b] <- (map read . words) `fmap` getLine\n print $ f [r, g, b] 0\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\n\ndata Colour = Red | Green | Blue\n deriving (Eq)\ncars = zip [30..] (repeat [Red, Green, Blue])\n\nf xs@[nr, ng, nb] (n,c) | sum xs == 0 = n - 1\n | c == Red = f [if nr - 2 > 0 then nr - 2 else 0, ng, nb] (n+1, Green)\n | c == Green = f [nr, if ng - 2 > 0 then ng - 2 else 0, nb] (n+1, Blue)\n | c == Blue = f [nr, ng, if nb - 2 > 0 then nb - 2 else 0] (n+1, Red)\n\n\nmain = do\n xs <- map read . words <$> getLine :: IO [Int]\n let ans = f xs (30, Red)\n print ans\n"}], "negative_code": [], "src_uid": "a45daac108076102da54e07e1e2a37d7"} {"source_code": "import qualified Data.ByteString.Char8 as BS\n\ntype ByteString = BS.ByteString\nmain = BS.interact $ printIt . solveIt . parseIt\n\n-- Input/Output Types\ntype Input = ((Int, Int, Int), (Int, Int, Int))\ntype Output = Bool\n\n-- Parse the input\nparseIt :: ByteString -> Input\nparseIt input =\n let tokens = BS.words input\n (a:b:c:x:y:z:_) = map read $ map BS.unpack tokens\n in ((a, b, c), (x, y, z))\n\n-- Print the solution\nprintIt :: Output -> ByteString\nprintIt solution\n | solution = BS.pack \"Yes\\n\"\n | otherwise = BS.pack \"No\\n\"\n\n-- Find the solution\nsolveIt :: Input -> Output\nsolveIt ((a, b, c), (x, y, z))\n | canMake >= need = True\n | otherwise = False\n where\n fCanMake = (\\have need -> if have > need then floor $ (realToFrac (have - need)) / 2 else 0)\n canMake = (fCanMake a x) + (fCanMake b y) + (fCanMake c z)\n fNeed = (\\have need -> if have >= need then 0 else need - have)\n need = (fNeed a x) + (fNeed b y) + (fNeed c z)\n", "positive_code": [{"source_code": "import Data.List.Split (splitOn)\n\nmain = do \n abc <- getLine\n let abcint = [read x :: Int | x <- splitOn \" \" abc]\n xyz <- getLine\n let xyzint = [read x :: Int | x <- splitOn \" \" xyz]\n let availableballs = [if x < 0 then x else div x 2 |\n i <- zip abcint xyzint, let x = fst i - snd i]\n if sum(availableballs) < 0 then putStrLn \"No\" else putStrLn \"Yes\"\n\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\n\nsolve :: Int -> Int -> Int -> Bool\nsolve x y z = f x + f y + f z + g x + g y + g z >= 0\n where\n f n = max 0 n `div` 2\n g n = min 0 n\n\nmain :: IO ()\nmain = do\n [a,b,c] <- map read . words <$> getLine\n [x,y,z] <- map read . words <$> getLine\n putStrLn $ if solve (a-x) (b-y) (c-z)\n then \"Yes\"\n else \"No\"\n"}, {"source_code": "transformable :: (Integral a, Num a) => [a] -> [a] -> Bool\ntransformable src dst = (sum $ map step $ zip src dst) >= 0\n where step (s, d) | s >= d = (s-d) `div` 2\n | otherwise = s-d\n\nsh True = \"Yes\"\nsh False = \"No\"\n\nmain = do\n inp <- getContents\n let ls = lines inp\n src = (map read $ words $ head ls) :: [Int]\n dst = (map read $ words $ head $ tail ls) :: [Int]\n putStrLn $ sh $ transformable src dst\n"}, {"source_code": "solve :: [Int] -> [Int] -> Bool\nsolve has needs = canmake >= req\n where\n surplus = filter (\\x -> x > 0) $ map (\\(x, y) -> x - y) $ zip has needs\n req = sum $ filter (\\x -> x > 0) $ map (\\(x, y) -> y - x) $ zip has needs\n canmake = sum $ map (\\x -> if even x then x `div` 2 else (x - 1) `div` 2) surplus\n\nmain :: IO ()\nmain = do\n l1 <- getLine\n l2 <- getLine\n let has = map read $ words l1\n needs = map read $ words l2\n if solve has needs\n then putStrLn \"YES\"\n else putStrLn \"NO\"\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \t\n\t\t\t\n\n \n\n\nmain= do\n\t[a,b,c]<- map read.words <$> getLine ::IO [Integer]\n\t[x,y,z]<- map read.words <$> getLine ::IO [Integer]\n\tlet s = [a-x,b-y,c-z]\n\tlet t1= sum $ map (\\z-> div z 2) $ filter (>0) s \n\tlet t2= abs $ sum $ filter (<=0) s\n\tputStrLn $ if t1>=t2 then \"Yes\" else \"No\""}, {"source_code": "import Numeric\n\nreadStuff :: IO [Int]\nreadStuff = do\n\tline <- getLine\n\treturn $ map (read::String -> Int) (words line)\n\nleftover :: Int -> Int -> Int\nleftover a x\n\t| a < x = 0\n\t| otherwise = div (a-x) 2\n\nneed :: Int -> Int -> Int\nneed a x\n\t| a > x = 0\n\t| otherwise = x - a\n\nsolve :: Int -> Int -> Int -> Int -> Int -> Int -> String\nsolve a b c x y z = if r >= n then \"Yes\" else \"No\"\n\twhere r = leftover a x + leftover b y + leftover c z\n\t n = need a x + need b y + need c z\n\nmain :: IO ()\nmain = do\n\t[a, b ,c] <- readStuff\n\t[x, y ,z] <- readStuff\n\tputStrLn $ solve a b c x y z\n"}, {"source_code": "import qualified Data.ByteString.Char8 as S\n\n-- Alias things\ntype ByteString = S.ByteString\npack = S.pack\nunpack = S.unpack\n\n-- Reads a list of tokens from a ByteString, split by space or new line.\ngetTokens :: ByteString -> [ByteString]\ngetTokens contents = S.splitWith (\\c -> c == '\\n' || c == ' ') contents\n\n-- Main\nmain = S.interact handleInput\n\n-- Input\nhandleInput :: ByteString -> ByteString\nhandleInput input =\n let tokens = take 6 $ getTokens input\n (a:b:c:x:y:z:_) = map read $ map unpack tokens\n solution = solveIt (a, b, c) (x, y, z)\n output = formatOutput solution\n in output\n\n-- Output\nformatOutput :: Bool -> ByteString\nformatOutput s\n | s = pack \"Yes\"\n | otherwise = pack \"No\"\n\n-- Solution\nsolveIt :: (Int, Int, Int) -> (Int, Int, Int) -> Bool\nsolveIt (a, b, c) (x, y, z)\n | canMake >= need = True\n | otherwise = False\n where\n fCanMake = (\\have need -> if have > need then floor $ (realToFrac (have - need)) / 2 else 0)\n canMake = (fCanMake a x) + (fCanMake b y) + (fCanMake c z)\n fNeed = (\\have need -> if have >= need then 0 else need - have)\n need = (fNeed a x) + (fNeed b y) + (fNeed c z)\n"}], "negative_code": [{"source_code": "import qualified Data.ByteString.Char8 as S\n\n-- Alias things\ntype ByteString = S.ByteString\npack = S.pack\nunpack = S.unpack\n\n-- Reads a list of tokens from a ByteString, split by space or new line.\ngetTokens :: ByteString -> [ByteString]\ngetTokens contents = S.splitWith (\\c -> c == '\\n' || c == ' ') contents\n\n-- Main\nmain = S.interact handleInput\n\n-- Input\nhandleInput :: ByteString -> ByteString\nhandleInput input =\n let tokens = take 6 $ getTokens input\n (a:b:c:x:y:z:_) = map read $ map unpack tokens\n solution = solveIt (a, b, c) (x, y, z)\n output = formatOutput solution\n in output\n\n-- Output\nformatOutput :: Bool -> ByteString\nformatOutput s\n | s = pack \"Yes\"\n | otherwise = pack \"No\"\n\n-- Solution\nsolveIt :: (Int, Int, Int) -> (Int, Int, Int) -> Bool\nsolveIt (a, b, c) (x, y, z) = False\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Debug.Trace\n\nsolve :: (Int,Int,Int) -> (Int,Int,Int) -> Bool\nsolve (a,b,c) (x,y,z)\n | a == x && b == y && c == z = trace (show (a,b,c)) $ True\n | a <= x && b <= y && c <= z = trace (show (a,b,c)) $ False\n | a == x + 1 = solve (a-1,b,c) (x,y,z)\n | a > x && b >= y = trace (show (a,b,c)) $ solve (a-2,b,c+1) (x,y,z)\n | a > x && b < y = trace (show (a,b,c)) $ solve (a-2,b+1,c) (x,y,z)\n | b == y + 1 = solve (a,b-1,c) (x,y,z)\n | b > y && c >= z = trace (show (a,b,c)) $ solve (a+1,b-2,c) (x,y,z)\n | b > y && c < z = trace (show (a,b,c)) $ solve (a,b-2,c+1) (x,y,z)\n | c == z + 1 = solve (a,b,c-1) (x,y,z)\n | c > z && b >= y = trace (show (a,b,c)) $ solve (a+1,b,c-2) (x,y,z)\n | otherwise = trace (show (a,b,c)) $ solve (a,b+1,c-2) (x,y,z)\n\nmain :: IO ()\nmain = do\n [a,b,c] <- map read . words <$> getLine\n [x,y,z] <- map read . words <$> getLine\n putStrLn $ if abs (a-x) + abs (b-y) + abs (c-z) == 1\n then \"No\"\n else if solve (a,b,c) (x,y,z)\n then \"Yes\"\n else \"No\"\n"}], "src_uid": "1db4ba9dc1000e26532bb73336cf12c3"} {"source_code": "\ngao :: Integer -> String\ngao n\n\t| n >= -128 && n <= 127 = \"byte\"\n\t| n >= -32768 && n <= 32767 = \"short\"\n\t| n >= -2147483648 && n <= 2147483647 = \"int\"\n\t| n >= -9223372036854775808 && n <= 9223372036854775807 = \"long\"\n\t| otherwise = \"BigInteger\"\n\nmain' :: String -> String\nmain' input = unlines [gao $ read input]\n\nmain = interact main'\n", "positive_code": [{"source_code": "solve :: Integer -> String\nsolve n | -128 <= n && n <= 127 = \"byte\"\n | -32768 <= n && n <= 32767 = \"short\"\n | -2147483648 <= n && n <= 2147483647 = \"int\"\n | -9223372036854775808 <= n && n <= 9223372036854775807 = \"long\"\n | otherwise = \"BigInteger\"\n\nmain = do\n inp <- getLine\n let n = read inp :: (Integer)\n putStrLn $ solve n"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]\n"}, {"source_code": "main :: IO ()\nmain = do\n n <- fmap read getLine :: IO Integer\n if (-128) <= n && n <= 127\n then putStrLn \"byte\"\n else if (-32768) <= n && n <= 32767\n then putStrLn \"short\"\n else if (-2147483648) <= n && n <= 2147483647\n then putStrLn \"int\"\n else if (-9223372036854775808) <= n && n <= 9223372036854775807\n then putStrLn \"long\"\n else putStrLn \"BigInteger\"\n "}, {"source_code": "main = interact $ datatype . read\n\ndatatype :: Integer -> String\ndatatype i\n | i < 128 = \"byte\"\n | i < 32768 = \"short\"\n | i < 2147483648 = \"int\"\n | i < 9223372036854775808 = \"long\"\n | otherwise = \"BigInteger\"\n\n"}, {"source_code": "import Data.List\nl = [(\"byte\", 127), (\"short\", 32767), (\"int\", 2147483647), (\"long\", 9223372036854775807)]\nmain = do\n n <- read `fmap` getLine :: IO Integer\n case find (\\(t, m) -> n <= m) l of\n Just (t, _) -> putStrLn t\n Nothing -> putStrLn \"BigInteger\" \n"}, {"source_code": "get :: Integer -> String\nget n | -128 <= n && n <= 127 = \"byte\"\n | -32768 <= n && n <= 32767 = \"short\"\n | -2147483648 <= n && n <= 2147483647 = \"int\"\n | -9223372036854775808 <= n && n <= 9223372036854775807 = \"long\"\n | otherwise = \"BigInteger\"\n\nmain = do\n n <- readLn\n putStrLn $ get n\n"}, {"source_code": "findType x | x >= -128 && x <= 127 = \"byte\"\n | x >= -32768 && x <= 32767 = \"short\"\n\t | x >= -2147483648 && x <= 2147483647 = \"int\"\n\t | x >= -9223372036854775808 && x <= 9223372036854775807 = \"long\"\n\t | otherwise = \"BigInteger\"\nmain = interact $ (++\"\\n\") . findType . (read::String->Integer)\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \n\nprocess s | s<=127 && s>= -128 =\"byte\"\n\t | s<=32767 && s>= -32768 =\"short\"\n\t | s<=2147483647 && s>= -2147483648 =\"int\"\n\t | s<= 9223372036854775807 && s>= -9223372036854775808 =\"long\"\n\t |otherwise = \"BigInteger\"\n\nmain= do\n\ts<- read <$>getLine ::IO Integer\n\tputStrLn $ process s "}, {"source_code": "module Main where\nimport Control.Applicative\nimport Text.Printf\n\nf :: Integer -> String\nf n\n | n < 128 = \"byte\"\n | n < 32768 = \"short\"\n | n < 2147483648 = \"int\"\n | n < 9223372036854775808 = \"long\"\n | otherwise = \"BigInteger\"\n\n\nmain :: IO ()\nmain = \n do { txt <- f . (read) . (!!0) . lines <$> getContents\n ; (printf \"%s\\n\" txt)\n }\n\n"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]\n"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]\n"}, {"source_code": "getType :: (Integral a) => a -> String\ngetType n\n\t| n >= -128 && n <= 127 = \"byte\"\n\t| n >= -32768 && n <= 32767 = \"short\"\n\t| n >= -2147483648 && n <= 2147483647 = \"int\"\n\t| n >= -9223372036854775808 && n <= 9223372036854775807 = \"long\"\n\t| otherwise = \"BigInteger\"\n\n\nmain :: IO ()\nmain = do\n\t\tline <- getLine\n\t\tlet n = read line :: Integer\n\t\tputStrLn (getType n)\n\n"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]\n"}, {"source_code": "solve n | -(2^7) <= n && n <= 2^7 - 1 = \"byte\"\n | -(2^15) <= n && n <= 2^15 - 1 = \"short\" \n | -(2^31) <= n && n <= 2^31 - 1 = \"int\" \n | -(2^63) <= n && n <= 2^63 - 1 = \"long\" \n | otherwise = \"BigInteger\"\n\nmain = do\n n <- readLn :: IO Integer\n putStrLn $ solve n\n"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]\n"}, {"source_code": "typ :: Integer -> String\ntyp x\n\t| x < 128 && x >= -128 = \"byte\"\n\t| x < 32768 && x >= -32768 = \"short\"\n\t| x < 2147483648 && x >= -2147483648 = \"int\"\n\t| x < 9223372036854775808 && x >= -9223372036854775808 = \"long\"\n\t| otherwise = \"BigInteger\"\n\nmain = do\n\tgetLine >>= putStrLn . typ . read\n"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]\n"}, {"source_code": "main = do n <- getLine\n putStrLn $ case (read n) of\n t | t <= 127 -> \"byte\"\n | t <= 32767 -> \"short\"\n | t <= 2147483647 -> \"int\"\n | t <= 9223372036854775807 -> \"long\"\n | otherwise -> \"BigInteger\"\n"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]\n"}, {"source_code": "main=putStr.(words\"byte short int long BigInteger\"!!).length.f=< String\nstr 1 = \"byte\"\nstr 2 = \"short\"\nstr 3 = \"int\"\nstr 4 = \"long\"\nstr _ = \"BigInteger\"\n\nqq :: [Integer] -> Integer -> Int\nqq (x : xs) a \n | (a + x `div` 2 >= 0) && (a + x `div` 2 < x) = 1\n | otherwise = 1 + qq xs a\n\nf y = 2 ^ (8 * 2 ^ y)\nsp = map f [0..]"}, {"source_code": "main :: IO ()\nmain = do c <- getLine\n putStrLn (solve c)\n\nsolve c = [\"byte\", \"short\", \"int\", \"long\", \"BigInteger\"] !! qq (map (\\y -> 2 ^ (8 * 2 ^ y)) [0..]) (read c)\n\nqq :: [Integer] -> Integer -> Int\nqq (x : xs) a \n | (a + x `div` 2 >= 0) && (a + x `div` 2 < x) = 0\n | otherwise = min 4 (1 + qq xs a)\n"}, {"source_code": "type Interval = (Integer, Integer)\ntype TypeNum = (String, Interval)\n\nbyte = (\"byte\", (-128, 127))\nshort = (\"short\", (-32768, 32767))\nint = (\"int\", (-2147483648, 2147483647))\nlong = (\"long\", (-9223372036854775808, 9223372036854775807))\nbigInteger = (\"BigInteger\", (0, 0))\n\ninInterval :: Integer -> TypeNum -> Bool\ninInterval n (_, (a, b)) = a <= n && n <= b\n\ngetName :: TypeNum -> String\ngetName (name, _) = name\n\nsolve :: Integer -> String\nsolve n = getName (solve_ n [byte, short, int, long, bigInteger])\n where\n solve_ :: Integer -> [TypeNum] -> TypeNum\n solve_ _ [a] = a\n solve_ n (a:as)\n | inInterval n a = a\n | otherwise = solve_ n as\n \nmain = do\n n <- readLn\n putStrLn (solve n)"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]\n"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]"}, {"source_code": "module Main where\n\nreadI :: String -> Integer\nreadI = read\n\nguessType x\n | x < 128 = \"byte\"\n | x < 32768 = \"short\"\n | x < 2147483648 = \"int\"\n | x < 9223372036854775808 = \"long\"\n | otherwise = \"BigInteger\"\n\nmain :: IO ()\nmain = do\n value <- getLine\n putStrLn $ guessType $ readI value\n"}, {"source_code": "main=readLn>>=putStr.(words\"BigInteger long int short byte\"!!).length.f\nf n=filter((n<).(2^))[7,15,31,63]"}, {"source_code": "{-# LANGUAGE OverloadedStrings #-}\nmodule Main where\n\nimport Control.Arrow\nimport Data.Monoid\nimport Data.List (find)\nimport Data.Char\n\nimport Data.ByteString.Char8 (interact,length,splitWith)\nimport Prelude hiding (interact,length)\n\nmain = interact $ splitWith isSpace >>> head >>>\n (\\ x (e,_) -> ((length x `compare` length e) `mappend` (x `compare` e)) /= GT) >>>\n (`find` [(\"127\",\"byte\"),(\"32767\",\"short\"),(\"2147483647\",\"int\"),(\"9223372036854775807\",\"long\")])\n >>> maybe \"BigInteger\" snd"}, {"source_code": "module Main where\n\nimport Control.Arrow\nimport Data.List\n\nmain = interact $ read >>>\n (<=) >>> (fst >>>) >>>\n (`find` [(127,\"byte\"),(32767,\"short\"),(2147483647,\"int\"),(9223372036854775807,\"long\")])\n >>> maybe \"BigInteger\" snd\n\n-- Java is the worst choice\n-- Byte, Short, Integer and Long(such OO malarkey!!!) work much slower besides BigInteger"}, {"source_code": "getSize :: Integer -> String\ngetSize x | x >= -128 && x <= 127 = \"byte\"\n | x >= -32768 && x <= 32767 = \"short\"\n | x >= -2147483648 && x <= 2147483647 = \"int\"\n | x >= -9223372036854775808 && x <= 9223372036854775807 = \"long\"\n | otherwise = \"BigInteger\"\nmain = fmap read getLine >>= putStrLn . getSize\n"}, {"source_code": "l = [ (-128, 127, \"byte\"), \n (-32768, 32767, \"short\"), \n (-2147483648, 2147483647, \"int\"), \n (-9223372036854775808, 9223372036854775807, \"long\")\n ]\n\nf _ [] = \"BigInteger\"\nf i ((min, max, name):ps) = \n if i >= min && i <= max\n then name\n else f i ps\n\n\nmain = do line <- getLine\n let i = read line :: Integer\n putStrLn $ f i l\n return ()\n"}], "negative_code": [{"source_code": "main = do n <- getLine\n putStrLn $ case (read n) of\n t | t <= 127 -> \"char\"\n | t <= 32767 -> \"short\"\n | t <= 2147483647 -> \"int\"\n | t <= 9223372036854775807 -> \"long\"\n | otherwise -> \"BigInteger\"\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -XNoMonomorphismRestriction #-}\n{-# LANGUAGE BangPatterns #-}\n{-(c) gorlum0 [at] gmail.com-}\nimport Control.Monad (forM_)\n\nfI = fromIntegral\n\nitype n\n | k < 8 = \"byte\"\n | k < 16 = \"short\"\n | k < 32 = \"int\"\n | k < 64 = \"long\"\n | otherwise = \"BigInteger\"\n where\n k = ceiling . (subtract 1e-5) . logBase 2 $ abs (n + 1)\n \nmain = do\n ws <- words `fmap` getContents\n let ns = map read ws\n forM_ [itype n | n <- ns] $\n putStrLn\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -XNoMonomorphismRestriction #-}\n{-# LANGUAGE BangPatterns #-}\n{-(c) gorlum0 [at] gmail.com-}\nimport Control.Monad (forM_)\n\nfI = fromIntegral\n\nitype n\n | k < 8 = \"byte\"\n | k < 16 = \"short\"\n | k < 32 = \"int\"\n | k < 64 = \"long\"\n | otherwise = \"BigInteger\"\n where\n k = ceiling . logBase 2 $ abs (n + 1)\n \nmain = do\n ws <- words `fmap` getContents\n let ns = map read ws\n forM_ [itype n | n <- ns] $\n putStrLn\n"}, {"source_code": "module Main where\n\nimport Control.Arrow\nimport Data.List\n\nmain = interact $ lines >>> tail >>>\n map (words >>> map read) >>>\n transpose >>> find (sum >>> (/=0)) >>> maybe \"YES\" (const \"NO\")"}, {"source_code": "{-# LANGUAGE OverloadedStrings #-}\nmodule Main where\n\nimport Control.Arrow\nimport Data.Monoid\nimport Data.List (find)\n\nimport Data.ByteString.Char8 (getLine,length,putStr)\nimport Prelude hiding (getLine,length,putStr)\n\nmain = (>>=) getLine $\n (\\ x (e,_) -> ((length x `compare` length e) `mappend` (x `compare` e)) /= GT) >>>\n (`find` [(\"127\",\"byte\"),(\"32767\",\"short\"),(\"2147483647\",\"int\"),(\"9223372036854775807\",\"long\")])\n >>> maybe \"BigInteger\" snd >>> putStr"}, {"source_code": "import Control.Applicative\nimport Data.List\n \n\nprocess s | s<=127 && s>= -128 =\"byte\"\n\t | s<=32767 && s>= -32768 =\"short\"\n\t | s<=2147483647 && s>= -2147483648 =\"int\"\n\t | s<=9223372936854775807 && s>= -9223372936854775808 =\"long\"\n\t |otherwise = \"BigInteger\"\n\nmain= do\n\ts<- read <$>getLine ::IO Integer\n\tputStrLn $ process s "}, {"source_code": "module Main where\nimport Control.Applicative\nimport Text.Printf\n\nf :: Integer -> String\nf n\n | n < 128 = \"byte\"\n | n < 32768 = \"short\"\n | n < 2147483648 = \"int\"\n | n < 9223372036854775807 = \"long\"\n | otherwise = \"BigInteger\"\n\n\nmain :: IO ()\nmain = \n do { txt <- f . (read) . (!!0) . lines <$> getContents\n ; (printf \"%s\\n\" txt)\n }\n\n"}, {"source_code": "module Main where\nimport Control.Applicative\nimport Text.Printf\n\nf :: Int -> String\nf n\n | n < 128 = \"byte\"\n | n < 32768 = \"short\"\n | n < 2147483648 = \"int\"\n | n < 9223372036854775807 = \"long\"\n | otherwise = \"BigInteger\"\n\n\nmain :: IO ()\nmain = \n do { txt <- f . (read) . (!!0) . lines <$> getContents\n ; (printf \"%s\\n\" txt)\n }\n\n"}], "src_uid": "33041f1832fa7f641e37c4c638ab08a1"} {"source_code": "module Main where\n\ndata Muscle = Chest | Biceps | Back\n\nmax3 :: Int -> Int -> Int -> String\nmax3 a b c = if a > b\n then if a > c\n then \"chest\"\n else \"back\"\n else if b > c\n then \"biceps\"\n else \"back\"\n\nsolve :: [Int] -> String\nsolve ex = solve' 0 0 0 Chest ex\n where\n solve' a b c _ [] = max3 a b c\n solve' a b c Chest (x:xs) = solve' (a+x) b c Biceps xs\n solve' a b c Biceps (x:xs) = solve' a (b+x) c Back xs\n solve' a b c Back (x:xs) = solve' a b (c+x) Chest xs\n\nmain = do\n getLine\n exercises <- fmap ((map (read :: String -> Int)) . words) getLine\n putStrLn $ solve exercises\n", "positive_code": [{"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad hiding ((<$!>))\nimport Control.Monad.ST.Safe\nimport Control.Monad.State hiding ((<$!>))\n-- import Data.Array\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IntSet\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map.Strict (Map)\nimport qualified Data.Map.Strict as Map\nimport Data.HashMap.Strict (HashMap)\nimport qualified Data.HashMap.Strict as HashMap\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\n-- import Debug.Trace\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n n <- readLn\n xs <- getInts\n\n let\n a = sum $ map (xs!!) $ takeWhile (< n) [0,3..]\n b = sum $ map (xs!!) $ takeWhile (< n) [1,4..]\n c = sum $ map (xs!!) $ takeWhile (< n) [2,5..]\n\n putStrLn $\n if a > b && a > c\n then \"chest\"\n else if b > a && b > c\n then \"biceps\"\n else \"back\"\n"}, {"source_code": "import Data.List\nimport Data.Maybe\n\nmain = do\n\tline <- getContents\n\tlet lst = map read $ words line\n\tlet\tgroups = takeByThree (drop 1 lst)\n\t\ttotal = foldl doSum [0,0,0] groups\n\t\tmx = elemIndex (maximum total) total\n\tputStrLn (idxToStr ((fromMaybe 0 mx) +1))\n\t\n\t\nidxToStr :: Int -> String\nidxToStr idx\n\t| mod idx 3 == 1 = \"chest\"\n\t| mod idx 3 == 2 = \"biceps\"\n\t|otherwise = \"back\"\n\ntakeByThree :: [Int] -> [[Int]]\ntakeByThree [] = []\ntakeByThree xs = take 3 xs : takeByThree (drop 3 xs)\n\ndoSum:: [Int] -> [Int] -> [Int]\ndoSum (a:b:c) [] = (a:b:c)\ndoSum [a,b,c] [d,e,f] = [a +d, b+e, c+f]\ndoSum [a,b,c] [d,e] = [a +d, b+e, c]\ndoSum [a,b,c] [d] = [a +d, b, c]"}, {"source_code": "\nimport Control.Monad (liftM)\n\nsolve :: [Int] -> String\nsolve as\n | a > b && a > c = \"chest\"\n | b > a && b > c = \"biceps\"\n | c > a && c > b = \"back\"\n where\n a = sum $ zipWith (*) as $ tail $ tail cycl\n b = sum $ zipWith (*) as $ tail cycl\n c = sum $ zipWith (*) as cycl\n cycl = cycle [0, 0, 1]\n\nmain :: IO ()\nmain = do\n getLine\n as <- liftM (map read . words) getLine\n putStrLn $ solve as\n"}, {"source_code": "import Data.List\n\ncompareSnd (_, x) (_, y) = compare x y\n\nassocSum :: (Eq a) => [(a, Int)] -> a -> Int\nassocSum assoc key = sum $ map snd $ filter givenKey assoc\n where givenKey = (== key) . fst\n\nsolve xs = fst $ maximumBy compareSnd finalAssoc\n where keys = [\"chest\", \"biceps\", \"back\"]\n assoc = zip (cycle keys) xs\n finalAssoc = zip keys $ map (assocSum assoc) keys\n\nmain = interact $ solve . map read . tail . words"}, {"source_code": "import Data.List (elemIndex, foldl', unfoldr)\nimport Data.Maybe (fromJust)\n\nmain :: IO ()\nmain = getContents >>= putStrLn . solve . map read . words . (!!1) . lines\n\nsolve :: [Int] -> String\nsolve = (exercise !!) . maximumIndex . foldl' (zipWith (+)) [0, 0, 0] . map (++[0,0,0]) . splitN 3\n\nexercise :: [String]\nexercise = [ \"chest\", \"biceps\", \"back\" ]\n\nsplitN :: Int -> [a] -> [[a]]\nsplitN n = takeWhile (not . null) . unfoldr (Just . splitAt n)\n\nmaximumIndex :: Ord a => [a] -> Int\nmaximumIndex xs = fromJust $ elemIndex (maximum xs) xs\n"}, {"source_code": "import Data.List\nmain = interact $ solve . map read . tail . words\nsolve as | chest == m = \"chest\"\n | biceps == m = \"biceps\"\n | back == m = \"back\" where\n parts@[chest,biceps,back] = map sum $ transpose $ chunksOf 3 $ [0,0,0] ++as\n m = maximum parts\nchunksOf n = go where\n go [] = []\n go xs = l : go r where (l,r) = splitAt n xs\n"}, {"source_code": "module Main where\n\ndata Muscle = Chest | Biceps | Back\n\nmax3 :: Int -> Int -> Int -> String\nmax3 a b c\n | a > b = if a > c then \"chest\" else \"back\"\n | b > c = \"biceps\"\n | otherwise = \"back\"\n\nsolve :: [Int] -> String\nsolve = solve' 0 0 0 Chest\n where\n solve' a b c _ [] = max3 a b c\n solve' a b c Chest (x:xs) = solve' (a+x) b c Biceps xs\n solve' a b c Biceps (x:xs) = solve' a (b+x) c Back xs\n solve' a b c Back (x:xs) = solve' a b (c+x) Chest xs\n\nmain = do\n getLine\n exercises <- fmap (map read . words) getLine\n putStrLn $ solve exercises"}, {"source_code": "main = getContents >>= putStrLn.solve 0 0 0.tail.map read.words\n\nsolve x y z (a:b:c:rest) = solve (x+a) (y+b) (z+c) rest\nsolve x y z (a:b:rest) = solve (x+a) (y+b) z rest\nsolve x y z (a:rest) = solve (x+a) y z rest\nsolve x y z []\n | x==maximum[x,y,z] = \"chest\"\n | y==maximum[x,y,z] = \"biceps\"\n | otherwise = \"back\"\n"}, {"source_code": "#!/usr/bin/env runghc\nmain = do\n c <- getContents\n putStrLn . solve . lines $ c\n\nsolve (n:a:cs) = snd . maximum $ zip (f 0 (map read $ words a)) [\"chest\",\"biceps\",\"back\"]\n where\n f i [] = [0,0,0]\n f i (a:as)\n | i == 0 = [x+a,y,z]\n | i == 1 = [x,y+a,z]\n | i == 2 = [x,y,z+a]\n where [x,y,z] = f ((i+1) `mod` 3) as\n"}, {"source_code": "main :: IO()\nmain = do\n n <- getLine\n l <- getLine\n ap (func (map (read) $ splitOn ' ' l))\n where\n ap 1 = putStrLn \"chest\"\n ap 2 = putStrLn \"biceps\"\n ap 3 = putStrLn \"back\"\n\nsplitOn :: Char -> String -> [String]\nsplitOn _ [] = []\nsplitOn x (y:xs)\n | x==y = splitOn x xs\nsplitOn x xs = (takeWhile (f) xs): (splitOn x (dropWhile (f) xs))\n where\n f q = q/=x\n\nfunc :: [Int] -> Int\nfunc a = y\n where\n (x,y) = maximum (map (f) [1,2,3])\n l = (zip a (cycle [1,2,3]))\n f i = (sum [ x | (x,y) <- l, y==i],i)"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport qualified Data.ByteString.Char8 as C\nimport Data.Maybe\n\n\nchunks n []= []\nchunks n t = (take n t ): (chunks n (drop n t))\n\nmain= do\n\tgetLine \n\tt<- map read. words <$> getLine::IO [Int]\n\tlet d@[a,b,c]=map sum $ transpose $ chunks 3 (t++[0,0,0])\n\tlet e= maximum d\n\tputStrLn $ if e==a then \"chest\"\n\t else if e==b then \"biceps\" else \"back\"\n\t\n\t"}, {"source_code": "import Data.List (transpose, unfoldr, splitAt, maximumBy)\nimport Data.Ord (comparing)\n\nmaxIndex :: Ord a => [a] -> Int\nmaxIndex = fst . maximumBy (comparing snd) . zip [0..]\n\nuncycle :: Int -> [Int] -> [[Int]]\nuncycle n xs = transpose $ unfoldr (\\x -> if null x then Nothing else Just (splitAt n x)) xs\n\nexercises :: [String]\nexercises = [\"chest\", \"biceps\", \"back\"]\n\nprocess :: [Int] -> String\nprocess = (!!) exercises . maxIndex . map sum . uncycle (length exercises)\n\nreadInt :: String -> Int\nreadInt = read\n\nmain = do\n n <- fmap readInt getLine\n xs <- fmap (map readInt.words) getLine\n putStrLn $ process xs"}, {"source_code": "main = do\n (n:input) <- fmap (map read . words) getContents\n let f [] = (0, 0, 0)\n f [a] = (a, 0, 0)\n f [a, b] = (a, b, 0)\n f (a:b:c:xs) = (a + x, b + y, c + z) \n where (x, y, z) = f xs\n (a, b, c) = f input\n val = maximum [a, b, c]\n ans (a, b, c) | a == val = \"chest\"\n | b == val = \"biceps\"\n | c == val = \"back\"\n putStrLn $ ans (a, b, c)\n"}, {"source_code": "import Data.List\nimport Data.Ord\n\nmain = do\n (n:a) <- fmap (map read . words) getContents :: IO [Int]\n putStrLn $ f $ snd $ maximumBy (comparing fst) (zip (sum a) [0..]) where\n f k = [\"chest\", \"biceps\", \"back\"] !! k\n sum a\n | length a < 3 = take 3 $ a ++ repeat 0\n | otherwise = zipWith (+) (take 3 a) (sum $ drop 3 a)"}, {"source_code": "-- http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html\n\nget_ans :: Int -> [Int] -> [Int]\nget_ans _ [] = (0:0:0:[])\nget_ans n (a:b)\n\t| mod n 3 == 0 = (old !! 0 + a):(old !! 1):(old !! 2):[]\n\t| mod n 3 == 1 = (old !! 0):(old !! 1 + a):(old !! 2):[]\n\t| mod n 3 == 2 = (old !! 0):(old !! 1):(old !! 2 + a):[]\n\t\twhere old = get_ans (n + 1) b\n\nmain :: IO()\nmain = do\n\tstr1 <- getLine\n\tstr2 <- getLine\n\tlet ans = get_ans 0 (map read (words str2))\n\tif (ans !! 0 > ans !! 1 && ans !! 0 > ans !! 2)\n\t\tthen putStrLn \"chest\"\n\t\telse if (ans !! 1 > ans !! 2)\n\t\t\tthen putStrLn \"biceps\"\n\t\t\telse putStrLn \"back\"\n"}, {"source_code": "import Data.Function\nimport Data.List\n\nmain = interact $ solve.map read.tail.words \n \nsolve l = [ \"chest\", \"biceps\", \"back\" ] !! maximumBy (compare `on` f) [0..2]\n where f k = sum $ zipWith (*) l $ replicate k 0 ++ cycle [1,0,0]\n"}], "negative_code": [{"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad hiding ((<$!>))\nimport Control.Monad.ST.Safe\nimport Control.Monad.State hiding ((<$!>))\n-- import Data.Array\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IntSet\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map.Strict (Map)\nimport qualified Data.Map.Strict as Map\nimport Data.HashMap.Strict (HashMap)\nimport qualified Data.HashMap.Strict as HashMap\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\n-- import Debug.Trace\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n n <- readLn\n xs <- getInts\n\n let\n a = map (xs!!) $ takeWhile (< n) [0,3..]\n b = map (xs!!) $ takeWhile (< n) [1,4..]\n c = map (xs!!) $ takeWhile (< n) [2,5..]\n\n putStrLn $\n if a > b && a > c\n then \"chest\"\n else if b > a && b > c\n then \"biceps\"\n else \"back\"\n"}, {"source_code": "import Data.List\nmain = interact $ show . solve . map read . tail . words\nsolve as | chest == m = \"chest\"\n | biceps == m = \"biceps\"\n | back == m = \"back\" where\n parts@[chest,biceps,back] = map sum $ transpose $ chunksOf 3 $ [0,0,0] ++as\n m = maximum parts\nchunksOf n = go where\n go [] = []\n go xs = l : go r where (l,r) = splitAt n xs\n"}], "src_uid": "579021de624c072f5e0393aae762117e"} {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\t\t\nprocess s = length $ filter (==\"xxx\") $ map (take 3) $ tails s \n\nmain::IO ()\nmain=do\n\tgetLine\n\ts<-getLine\n\tprint $ process s\n", "positive_code": [{"source_code": "module Main where\n\ncount ln (-1) i = i\ncount ln n i = do\n if (ln !! n) == 'x' && (ln !! (n + 1)) == 'x' && (ln !! (n + 2)) == 'x'\n then count ln (n - 1) (i + 1)\n else count ln (n - 1) i\n\nmain = do\n n <- getLine\n ln <- getLine\n let a = count ln (read n - 3) 0\n putStrLn $ show a\n"}, {"source_code": "module Main where\n\nimport Data.List\n\nf (res, xs) 'x' = (res, xs+1)\nf (res, xs) _ = (res + (max (xs-2) 0), 0)\n\nsolve = fst . foldl' f (0, 0) . (++ \"!\")\n\nmain = interact $ show . solve . head . (drop 1) . lines"}, {"source_code": "import Data.List\nmain = interact $ show . process . head . tail . lines\nprocess = sum . map (\\x -> 0 `max` (length x - 2)) . filter head . group . map (=='x')\n"}, {"source_code": "--ghc 7.10\n\nimport Data.List(group,isPrefixOf)\n\nremoveX' :: String -> Int\nremoveX' str = sum $ map (\\x -> length x - 2) $ filter (isPrefixOf \"xxx\") $ group str\n\nmain = do\n nStr <- getLine\n str <- getLine\n print $ removeX' str"}, {"source_code": "import Data.List\nsolve (n:as:_) = (sum . filter (> 0) . map (+ (-2)) . map length . filter (elem 'x') . group) as\nmain = interact $ show . solve . words\n"}, {"source_code": "import Data.List\n\nmain = do\n getLine\n s <- getLine\n print (solve s)\n\nsolve :: String -> Int\nsolve s =\n sum [len-2 | ts <- group s, all(=='x')ts, let len=length ts, len >= 3]"}, {"source_code": "import Data.List\n\nf ::(Int,Char)->Int\nf (a,b)\n |b=='x' && a>2=(a-2)\n |otherwise=0\n\nmain = do\n e1<-getLine\n e2<-getLine\n let x=group e2\n y=zip (map length (x)) (map head (x))\n print $ sum $ map f y"}, {"source_code": "import Data.List (dropWhile, span)\n\nmain = do\n _ <- getLine\n s <- getLine \n print $ solve $ s\n\nsolve :: String -> Int\nsolve \"\" = 0\nsolve s = let t = dropWhile (/='x') s\n (xs, ys) = span (=='x') t\n in max 0 (length xs - 2) + solve ys\n"}, {"source_code": "import Data.List (group)\n\nmain = do\n _ <- getLine\n s <- getLine \n print $ solve $ s\n\nsolve :: String -> Int\nsolve = sum . map (\\x -> max 0 (x - 2)) . map length . filter ((=='x') . head) . group"}, {"source_code": "\n--\n-- Michael V. Antosha\n-- 2019\n-- Michael.Antosha@gmail.com\n--\n-- Haskell practice.\n-- Competitive programming.\n--\n-- Codeforces Round #481 (Div. 3)\n--\n-- B. File Name\n-- http://codeforces.com/contest/978/problem/B\n--\n\nimport Data.Function((.))\nimport Data.Int (Int)\nimport Data.List(head, tail, (++))\nimport Data.String(String, words)\nimport Data.Tuple (fst)\nimport Prelude ((+))\nimport System.IO (IO, interact)\nimport Text.Show (show)\n\nmain :: IO ()\nmain = interact pureMain where\n\n pureMain = showSingleValue . filterXXX . takeSecondWord\n\n takeSecondWord = head . tail . words\n\n showSingleValue = (++ \"\\n\") . show\n\nfilterXXX :: String -> Int\nfilterXXX = fst . f . (,) 0 where\n f (n, []) = (n, [])\n f (n, ('x':'x':'x':xs)) = f (n+1, ('x':'x':xs))\n f (n, (_:xs)) = f (n, xs)\n"}, {"source_code": "\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Char \n\nimport qualified Data.ByteString.Char8 as B\nreadInt = readLn :: IO Int\nreadInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine\n\nminRemove :: String -> Int\nminRemove = sum . map (max 0 . flip (-) 2) . map length . filter ((=='x') . head) . group\n\nmain :: IO ()\nmain = do\n _ <- readInt\n s <- getLine\n print $ minRemove s "}, {"source_code": "import Data.List\nmain = interact $ show . sum . map (max 0 . (subtract 2) . length) . filter ((== 'x') . head) . group\n"}, {"source_code": "import Data.List\n\nmain = do\n _ <- getLine\n file <- getLine\n let xp = filter (\\(x:xs) -> x == 'x') $ groupBy (\\x y -> x == y) file in\n print (sum (map (\\x -> maximum [0, x-2]) $ map length xp))"}], "negative_code": [{"source_code": "\n--\n-- Michael V. Antosha\n-- 2019\n-- Michael.Antosha@gmail.com\n--\n-- Haskell practice.\n-- Competitive programming.\n--\n-- Codeforces Round #481 (Div. 3)\n--\n-- B. File Name\n-- http://codeforces.com/contest/978/problem/B\n--\n\nimport Data.Function((.))\nimport Data.Int (Int)\nimport Data.List(head, tail, (++))\nimport Data.String(String, words)\nimport Data.Tuple (fst)\nimport Prelude ((+))\nimport System.IO (IO, interact)\nimport Text.Show (show)\n\nmain :: IO ()\nmain = interact pureMain where\n\n pureMain = showSingleValue . filterXXX . takeSecondWord\n\n takeSecondWord = head . tail . words\n\n showSingleValue = (++ \"\\n\") . show\n\nfilterXXX :: String -> Int\nfilterXXX = fst . f . (,) 0 where\n f (n, []) = (n, [])\n f (n, ('x':'x':'x':xs)) = f (n+1, ('x':'x':xs))\n f (n, xs) = (n, xs)\n"}, {"source_code": "import Data.List\nmain = interact $ show . sum . map ((subtract 2) . length) . filter ((== 'x') . head) . group\n"}, {"source_code": "import Data.List\n\nmain = do\n _ <- getLine\n file <- getLine\n let xp = filter (\\(x:xs) -> x == 'x') $ groupBy (\\x y -> x == y) file\n cnt = map length xp\n print (sum ( map (\\x -> max 0 x - 2) cnt))"}, {"source_code": "import Data.List\n\nmain = do\n _ <- getLine\n file <- getLine\n let xp = filter (\\(x:xs) -> x == 'x') $ groupBy (\\x y -> x == y) file in\n print (sum (map (\\x -> max 0 x-2) $ map length xp))"}, {"source_code": "module Main where\n\nimport Data.List\n\nf (res, xs) 'x' = (res, xs+1)\nf (res, xs) _ = (res + (max (xs-2) 0), 0)\n\nsolve = fst . foldl' f (0, 0)\n\nmain = interact $ show . solve . head . (drop 1) . lines"}], "src_uid": "8de14db41d0acee116bd5d8079cb2b02"} {"source_code": "-- Codeforces 894B\n\n-- If m + n is odd and k is -1, then ans is 0\n-- Otherwise, ans is 2 ^ ((n - 1) * (m - 1))\n\n{-# OPTIONS_GHC -O2 #-}\n{-# OPTIONS_GHC -funfolding-use-threshold=16 #-}\n{-# OPTIONS_GHC -fexcess-precision #-}\n{-# OPTIONS_GHC -feager-blackholing #-}\n{-# OPTIONS_GHC -funbox-strict-fields #-}\n{-# OPTIONS_GHC -fdicts-strict #-}\n{-# OPTIONS_GHC -optc-O3 #-}\n{-# OPTIONS_GHC -optc-ffast-math #-}\n\nimport Control.Applicative\nimport Data.Int\n\nmain :: IO ()\nmain = do\n [n, m, k] <- (map read . words) <$> getLine :: IO [Int64]\n if odd (m + n) && k == -1\n then print 0\n else print $ fastPowMod (fastPowMod 2 (n - 1) 1000000007) (m - 1) 1000000007\n\n-- | Return (a^b)%m\nfastPowMod :: Int64 -> Int64 -> Int64 -> Int64\nfastPowMod = go 1 where\n go r _ 0 _ = r\n go r a b m = go r' a' b' m\n where b' = b `div` 2\n r' = if b `mod` 2 == 1\n then r * a `mod` m\n else r\n a' = a * a `mod` m\n\n", "positive_code": [{"source_code": "-- Codeforces 894B\n\n-- If m + n is odd and k is -1, then ans is 0\n-- Otherwise, ans is 2 ^ ((n - 1) * (m - 1))\n\n{-# OPTIONS_GHC -O2 #-}\n{-# OPTIONS_GHC -funfolding-use-threshold=16 #-}\n{-# OPTIONS_GHC -fexcess-precision #-}\n{-# OPTIONS_GHC -feager-blackholing #-}\n{-# OPTIONS_GHC -funbox-strict-fields #-}\n{-# OPTIONS_GHC -fdicts-strict #-}\n{-# OPTIONS_GHC -optc-O3 #-}\n{-# OPTIONS_GHC -optc-ffast-math #-}\n\nimport Control.Applicative\nimport Data.Int\n\nmain :: IO ()\nmain = do\n [n, m, k] <- (map read . words) <$> getLine :: IO [Int64]\n if odd (m + n) && k == -1\n then print 0\n else print $ fastPowMod (fastPowMod 2 (n - 1) 1000000007) (m - 1) 1000000007\n\n-- | Return (a^b)%m\nfastPowMod :: Int64 -> Int64 -> Int64 -> Int64\nfastPowMod = go 1 where\n go r _ 0 _ = r\n go r a b m = go r' a' b' m\n where b' = b `div` 2\n r' = if b `mod` 2 == 1\n then r * a `mod` m\n else r\n a' = a * a `mod` m\n"}], "negative_code": [{"source_code": "-- Codeforces 894B\n\n-- If m + n is odd and k is -1, then ans is 0\n-- Otherwise, ans is 2 ^ ((n - 1) * (m - 1))\n\n{-# OPTIONS_GHC -O2 #-}\n{-# OPTIONS_GHC -funfolding-use-threshold=16 #-}\n{-# OPTIONS_GHC -fexcess-precision #-}\n{-# OPTIONS_GHC -feager-blackholing #-}\n{-# OPTIONS_GHC -funbox-strict-fields #-}\n{-# OPTIONS_GHC -fdicts-strict #-}\n{-# OPTIONS_GHC -optc-O3 #-}\n{-# OPTIONS_GHC -optc-ffast-math #-}\n\nimport Control.Applicative\nimport Data.Int\n\nmain :: IO ()\nmain = do\n [n, m, k] <- (map read . words) <$> getLine :: IO [Int64]\n if odd (m + n) && k == -1\n then print (-1)\n else print $ fastPowMod (fastPowMod 2 (n - 1) 1000000007) (m - 1) 1000000007\n\n-- | Return (a^b)%m\nfastPowMod :: Int64 -> Int64 -> Int64 -> Int64\nfastPowMod = go 1 where\n go r _ 0 _ = r\n go r a b m = go r' a' b' m\n where b' = b `div` 2\n r' = if b `mod` 2 == 1\n then r * a `mod` m\n else r\n a' = a * a `mod` m\n"}, {"source_code": "-- Codeforces 894B\n\n-- If m + n is odd and k is -1, then ans is 0\n-- Otherwise, ans is 2 ^ ((n - 1) * (m - 1))\n\n{-# OPTIONS_GHC -O3 #-}\n\nimport Control.Applicative\nimport Data.Int\n\nmain :: IO ()\nmain = do\n [n, m, k] <- (map read . words) <$> getLine :: IO [Int64]\n print [n, m, k]\n if odd (m + n) && k == -1\n then print (-1)\n else print $ fastPowMod (fastPowMod 2 (n - 1) 1000000007) (m - 1) 1000000007\n\n-- | Return (a^b)%m\nfastPowMod :: Int64 -> Int64 -> Int64 -> Int64\nfastPowMod = go 1 where\n go r _ 0 _ = r\n go r a b m = go r' a' b' m\n where b' = b `div` 2\n r' = if b `mod` 2 == 1\n then r * a `mod` m\n else r\n a' = a * a `mod` m\n"}, {"source_code": "-- Codeforces 894B\n\n-- If m + n is odd and k is -1, then ans is 0\n-- Otherwise, ans is 2 ^ ((n - 1) * (m - 1))\n\n{-# OPTIONS_GHC -O3 #-}\n\nimport Control.Applicative\nimport Data.Int\n\nmain :: IO ()\nmain = do\n [n, m, k] <- (map read . words) <$> getLine :: IO [Int64]\n if odd (m + n) && k == -1\n then print (-1)\n else print $ fastPowMod 2 ((n - 1) * (m - 1)) 1000000007\n\n-- | Return (a^b)%m\nfastPowMod :: Int64 -> Int64 -> Int64 -> Int64\nfastPowMod = go 1 where\n go r _ 0 _ = r\n go r a b m = go r' a' b' m\n where b' = b `div` 2\n r' = if b `mod` 2 == 1\n then r * a `mod` m\n else r\n a' = a * a `mod` m\n"}], "src_uid": "6b9eff690fae14725885cbc891ff7243"} {"source_code": "import Data.List\nimport Data.Char \n\noverlappingChunksOf4 :: [a] -> [[a]]\noverlappingChunksOf4 [a,b,c,d] = [[a,b,c,d]]\noverlappingChunksOf4 (a:b:c:d:e) = [a,b,c,d] : overlappingChunksOf4 (b:c:d:e)\n\nminMoves :: Char -> Char -> Int\nminMoves a b = min c (26 - c)\n where c = abs (ord a - ord b)\n\nsolve :: String -> Int\nsolve = minimum . map sum . map (map (uncurry minMoves)) . map (zip \"ACTG\") . overlappingChunksOf4\n\n-- ACTG\n\nmain :: IO ()\nmain = do\n q <- getLine\n s <- getLine\n print $ solve s ", "positive_code": [{"source_code": "import Data.Char\nmain :: IO ()\nmain = do\n\tn <- getLine\n\ts <- getLine\n\tputStrLn $ show $ solve s\n\treturn ()\n\t\ndiff :: Char -> Char -> Int\ndiff a b = let h = abs ((ord a) - (ord b))\n\t\t\tin min h (26 - h)\n\nsolve :: String -> Int\nsolve s \n\t|length s >=4 = min (helper s) (solve $ tail s)\n\t|otherwise = 10000\n\nhelper :: String -> Int\nhelper s \n\t|length s >=4 = s!!0 `diff` 'A' + s!!1 `diff` 'C' + s!!2 `diff` 'T' + s!!3 `diff` 'G' \n\t|otherwise = 1000\n"}, {"source_code": "import Data.List\nimport Data.Ord\nimport Data.Char\n\nchardist a b = let d = abs $ ord a - ord b in min d (26-d)\n\nwordDist = sum . zipWith chardist \"ACTG\"\n\nmain = do\n _ <- getLine\n text <- getLine\n let substrs = takeWhile (\\s -> length s == 4) $ map (\\n -> take 4 $ drop n text) [0..]\n print $ minimum $ map wordDist substrs\n"}], "negative_code": [], "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543"} {"source_code": "import Numeric\nimport Data.Char\nimport Control.Applicative\n\nmain = interact $ f . read where\n f k = g 1 (k - 1) $ toBase k <$> ((*) <$> [1..k-1] <*> [1..k-1]) where\n toBase b a = showIntAtBase b intToDigit a \"\"\n g _ _ [] = []\n g k' k (x:xs)\n | k' == k = x ++ \"\\n\" ++ (g 1 k xs)\n | otherwise = x ++ \" \" ++ (g (k' + 1) k xs)\n", "positive_code": [{"source_code": "--main = interact $ (\\sk -> (\\k -> unlines $ map unwords $ map (\\i -> map (\\x -> x*i) [1..k]) [1..k]) $ (read sk :: Int))\n\nmain = interact solve\n\nsolve sk = (\\k -> unlines $ map unwords $ map (\\i -> map (convert k) $ map ((*) i) [1..k-1]) [1..k-1]) (read sk :: Int) \n\nconvert _ 0 = \"\" \nconvert r i = (convert r (i `div` r)) ++ (show (i `mod` r))"}, {"source_code": "\nimport Prelude hiding (print)\n\nprint :: Int -> IO ()\nprint k = mapM_ (putStrLn . getLine) [1..k-1]\n where\n getLine i = concatMap (\\j -> show' (mul i j)) [1..k-1]\n show' k\n | length s == 1 = \" \" ++ s\n | otherwise = \" \" ++ s \n where\n s = show k\n mul i j = 10 * div (i*j) k + mod (i*j) k\n\nmain :: IO ()\nmain = readLn >>= print\n"}, {"source_code": "import Data.Char\nimport Data.List\nshown d n = reverse(unfoldr iter n)\n where iter 0 = Nothing\n iter k = Just (intToDigit (mod k d), div k d)\n \nmain = do\n n <- fmap read getLine\n let table = [[i*j | j <- [1..n-1]] | i <- [1..n-1]]\n putStrLn . unlines . map(unwords . map(shown n)) $ table"}, {"source_code": "main :: IO()\nmain = interact work\n\nwork :: String -> String\nwork input = unlines . map (unwords . map (showBase n)) . solve $ n\n where n = read input :: Int\n\nshowBase :: Int -> Int -> String\nshowBase b n \n | n == 0 = \"\"\n | otherwise = showBase b (n `div` b) ++ show (n `mod` b)\n\nsolve :: Int -> [[Int]]\nsolve n = [[i * j | j <- numbers] | i <- numbers]\n where numbers = [1..n - 1]\n"}], "negative_code": [], "src_uid": "a705144ace798d6b41068aa284d99050"} {"source_code": "module Main where\n\nimport Control.Applicative\nimport Data.List\nimport Control.Monad\nimport Control.Arrow\nimport Data.Function\nimport Data.Array\n\nf :: Integer -> Integer -> Integer\nf l r = g r - g (l-1)\n\ng x\n | x < 10 = x\n | True = g (10^(keta x-1)-1) + k x\nketa x\n | x < 10 = 1\n | True = succ$ keta (x`div`10)\nk x\n | x < 10 = x\n | True = (x`div`10)-(10^(keta x-2)) + l x\nl x\n | x < 10 = 0\n | (x`div`(10^(keta x-1))) <= x `mod` 10 = 1\n | True = 0\n{-\n 5���̐�\n 1???1\n �` 9???9\n \n-}\n\nmain = do\n (l, r) <- (\\[x,y]->(x,y)). map read. words <$> getLine\n print$ f l r\n", "positive_code": [{"source_code": "main :: IO ()\nmain = getLine >>= return . map read . words >>= print . solve\n\nsolve :: [Integer] -> Integer\nsolve [a, b] = solve' a b\n\nsolve' :: Integer -> Integer -> Integer\nsolve' a b\n\t| a > b = 0\n\t| a `mod` 10 /= 0 = testOne a + solve' (a + 1) b\n\t| b `mod` 10 /= 0 = testOne b + solve' a (b - 1)\n\t| otherwise = b `div` 10 - a `div` 10\n\ntestOne :: Integer -> Integer\ntestOne n = if leading n == n `mod` 10 then 1 else 0\n\twhere leading n = if n < 10 then n else leading $ n `div` 10\n"}, {"source_code": "readInteger :: String -> Integer\nreadInteger [] = 0\nreadInteger cs = read cs\n\nmain=getLine>>=print.solve.words\n\nsolve [ls,rs]\n | m==l = calc rs - calc ls + 1\n | otherwise = calc rs - calc ls\n where\n m = readInteger[head ls]\n l = readInteger[last ls]\ncalc :: String -> Integer\ncalc cs\n | len == 1 = readInteger cs\n | m<=l = (m-1)*10^(len-2) + (mid+1) + x\n | otherwise = (m-1)*10^(len-2) + mid + x\n where\n len = length cs\n x = sum $ take (len-1) $ 9:iterate (10*) 9\n m = readInteger[head cs]\n l = readInteger[last cs]\n mid = readInteger $ tail $ init cs\n"}, {"source_code": "import Control.Applicative\n\nreadInput :: IO (Integer, Integer)\nreadInput = do\n [l,r] <- map read . words <$> getLine\n return (l,r)\n\nfirstDigit :: Integer -> Integer\nfirstDigit x | x <= 9 = x\n | otherwise = firstDigit (x `div` 10)\n\ncount :: Integer -> Integer\ncount x | x <= 9 = x\n | lastDigit == 0 = x `div` 10 - 1 + 9\n | lastDigit >= firstDigit x = 1 + count (x - lastDigit)\n | otherwise = count (x - lastDigit)\n where lastDigit = x `mod` 10\n\nsolve :: (Integer, Integer) -> Integer\nsolve (l,r) = count r - count (l - 1)\n\nmain :: IO ()\nmain = readInput >>= (print . solve)\n"}], "negative_code": [{"source_code": "readInteger :: String -> Integer\nreadInteger [] = 0\nreadInteger cs = read cs\n\nmain=getLine>>=print.solve.words\n\nsolve [ls,rs]\n | m==l = calc rs - calc ls + 1\n | otherwise = calc rs - calc ls\n where\n m = readInteger[head ls]\n l = readInteger[last ls]\ncalc :: String -> Integer\ncalc cs\n | len == 1 = readInteger cs\n | m<=l = (m-1)*10^(len-2) + (mid+1) + x\n | otherwise = (m-1)*10^(len-2) + x\n where\n len = length cs\n x = sum $ take (len-1) $ 9:iterate (10*) 9\n m = readInteger[head cs]\n l = readInteger[last cs]\n mid = readInteger $ tail $ init cs\n"}], "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd"} {"source_code": "main = do\n [p, d] <- fmap (map read . words) getLine\n print $ (p-) $ last $ filter (<=d) $ map (\\i -> (p+1) `mod` (10^i)) [0 .. 20]", "positive_code": [{"source_code": "\nimport Monad (liftM)\n\nsolve :: Integer -> Integer -> Integer\nsolve d p = d - solve' p d\n where\n solve' p = head . dropWhile (> p) . (++ [0]) . map read . takeWhile (not . null) . iterate tail . show . (+1)\n\nmain :: IO ()\nmain = do\n [d, p] <- liftM (map read . words) getLine\n print $ solve d p\n"}, {"source_code": "import Data.List\n\nmain=getLine>>=print.solve.map read.words\n\nsolve :: [Integer] -> Integer\nsolve [p,d] = case dropWhile( p\n (x:_) -> x\n"}, {"source_code": "main = do\n [p, d] <- fmap (map read . words) getLine\n print $ (p-) $ last $ filter (<=d) $ map (\\i -> (p+1) `mod` (10^i)) [0 .. 20]\n"}], "negative_code": [{"source_code": "main = do\n [p, d] <- fmap (map read . words) getLine\n print $ (p-) $ last $ takeWhile (<=d) $ (0:) $ map (\\i -> succ $ mod p $ 10^i) [0 ..]\n"}, {"source_code": "main = do\n [p, d] <- fmap (map read . words) getLine\n print $ (p-) $ last $ takeWhile (<=d) $ (0:) $ map (\\i -> succ $ mod p $ 10^i) [1 ..]\n"}, {"source_code": "import Data.List\n\nmain=getLine>>=print.solve.map read.words\n\nsolve :: [Integer] -> Integer\nsolve [p,d] = pred.head.dropWhile(p-d>).map (read.take (length h).(++zeros)).inits $ h\n where\n h = show p\n zeros = repeat '0'\n"}, {"source_code": "import Data.List\nimport Data.Ord\n\nmain=getLine>>=print.solve.map read.words\n\nsolve :: [Integer] -> Integer\nsolve [p,d] = case dropWhile(p-d>).map (pred.read.take (length h).(++zeros)).inits $ h of\n [] -> p-1\n xs -> maximumBy (comparing f) xs\n where\n h = show p\n zeros = repeat '0'\n f n = length.takeWhile ('9'==).reverse $ show n \n"}, {"source_code": "import Data.List\n\nmain=getLine>>=print.solve.map read.words\n\nsolve :: [Integer] -> Integer\nsolve [p,d] = case dropWhile(p-d>).map (pred.read.take (length h).(++zeros)).inits $ h of\n [] -> p-1\n (x:_) -> x\n where\n h = show p\n zeros = repeat '0'\n"}], "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a"} {"source_code": "module Main where\n\nimport Control.Monad\n\nconfortable a b = a <= b+1 && b <= (a+1)*2\n\nmain = do\n [al, ar] <- ( map read . words ) `liftM` getLine\n [bl, br] <- ( map read . words ) `liftM` getLine\n\n putStrLn $ if confortable al br || confortable ar bl\n then \"YES\"\n else \"NO\"\n", "positive_code": [{"source_code": "main = interact $ solve . (map (map (read :: String -> Int))) . (map words) . lines\nsolve [[al,ar],[bl,br]] = if (al<=br+1 && br<=(al+1)*2) ||\n (ar<=bl+1 && bl<=(ar+1)*2) then \"YES\"\n else \"NO\"\n"}, {"source_code": "readInts :: IO [Int]\nreadInts = do\n line <- getLine\n return (map read (words line))\n\nok :: Int -> Int -> Bool\nok girl boy = boy >= girl - 1 && boy <= 2 * (girl + 1)\n\nmain = do\n [gl, gr] <- readInts\n [bl, br] <- readInts\n if ok gl br || ok gr bl then putStrLn \"YES\" else putStrLn \"NO\""}, {"source_code": "main = do\n [al, ar] <- map read `fmap` (words `fmap` getLine)\n [bl, br] <- map read `fmap` (words `fmap` getLine)\n let f a b = a - 1 <= b && b <= 2*(a+1)\n putStr (if f al br || f ar bl then \"YES\" else \"NO\")\n"}, {"source_code": "\n\nmain = do\n line1 <- getLine\n line2 <- getLine\n let \n [gl,gr] = map read $ words line1\n [bl,br] = map read $ words line2\n possible b g = b >= g-1 && (g+1)*2>=b\n result = possible br gl || possible bl gr\n myshow True = \"YES\"\n myshow False = \"NO\"\n putStrLn $ myshow result\n"}], "negative_code": [{"source_code": "main = interact $ solve . (map (map (read :: String -> Int))) . (map words) . lines\nsolve [[al,ar],[bl,br]] = if (lr<2 && -3 sumTime then we don't have a solution.\nelse we need to add to some elements of time such that (2) holds.\nWe need to add a total of diff = sumTime - sum time to elements of time.\nTherefore we traverse and create answer :: [Int] with:\n answer_0 = min maxTime_0 diff\n answer_i = min maxTime_i (sumTime - (sum time_{i..N}) - (sum answer_{0..i-1}))\n where N = length time\n-}\nimport Debug.Trace\nimport Data.Maybe\n\ncreate_answer 0 time = Just (map fst time)\ncreate_answer _ [] = Nothing\ncreate_answer diff ((minTime, maxTime):restTimes)\n{- | trace (\"diff:\" ++ show diff ++ \n \" minTime:\" ++ show minTime ++\n \" maxTime:\" ++ show maxTime ++\n \" restTimes:\" ++ show restTimes ++\n \" answer:\" ++ show answer\n ) False = undefined\n-}\n | diff < 0 = Nothing {- notice that we can \"optimize\"\n - this by verifying (< 0) in solve -}\n | otherwise = (create_answer (diff - (answer - minTime)) restTimes) >>=\n \\a -> Just (answer : a)\n where answer = min maxTime (minTime + diff)\n\nsolve (sumTime, times) =\n create_answer diff times\n where diff = sumTime - (sum (map fst times))\n\nverify' :: (Num a, Ord a) => (a, [(a, a)]) -> [a] -> Bool\nverify' (0, []) [] = True\nverify' (sumTime, ts) as\n | sumTime < 0 || null ts || null as = False\nverify' (sumTime, ts@((minTime, maxTime):restTimes)) as@(answer:restAnswers)\n | answer < minTime || answer > maxTime = False\n | otherwise = verify' (sumTime - answer, restTimes) restAnswers\n\nverify problem = show problem ++ \": \" ++\n if isNothing answer then \" has no answer\\n\"\n else if verify' problem (fromJust answer) then show (fromJust answer) ++ \"\\n\"\n else \" BAD ANSWER!\\n\"\n where answer = solve problem\n\nproblems =\n [\n (5, [(1,1), (2,2), (0,10), (1,1)]),\n (5, [(0,1), (0,2), (0,2), (0,1)]),\n (5, [(0,1), (0,2), (0,3), (0,1)]),\n (5, [(0,0), (0,0), (0,3), (0,0)]),\n (5, [(1,1), (0,0), (0,3), (0,0)]),\n (0, [(0,1), (0,0), (0,3), (0,0)]),\n (0, [(0,0), (0,0), (0,0), (0,0)]),\n (0, [(0,0)]),\n (1, [(0,1)]),\n (2, [(0,4)]),\n (5, [(1,1), (1,2), (1,3), (1,1)]),\n (50, [(10,10), (10,20), (10,30), (10,10)]),\n (6, [(2,3), (1,2), (0,1), (1,2)])]\n\ntestsuite [] = \"\"\ntestsuite (x:xs) = verify x ++ testsuite xs\n\nshowAnswer' [] = \"\\n\"\nshowAnswer' (x:xs) = show x ++ \" \" ++ showAnswer' xs\n\nshowAnswer Nothing = \"NO\\n\"\nshowAnswer (Just x) = \"YES\\n\" ++ showAnswer' x \n\ngetPair :: (Read a, Read b) => [String] -> (a, b)\ngetPair (x:y:[])\n-- | trace (show x ++ \",\" ++ show y) False = undefined\n | otherwise = (read x, read y)\ngetPair _ = undefined\n\ngetTimes 0 = return []\ngetTimes n = do\n inputLine <- getLine\n rest <- getTimes (n - 1)\n return ((getPair (words inputLine)) : rest)\n\nmain = do\n inputLine <- getLine\n times <- getTimes (nrTimes inputLine)\n putStr $ (showAnswer.solve) (sumTime inputLine, times)\n where sumTime = (read.head.tail.words) \n nrTimes = (read.head.words)\n \n\n\n\n\n\n", "positive_code": [{"source_code": "import Debug.Trace\nimport Data.List\n\n\nparse :: String -> (Int, Int, [(Int, Int)])\nparse l = \n let\n ([x, y]:rest) = map (map read) . map words $ lines l \n in\n (x, y, map (\\[x,y] -> (x,y)) rest) \n\nsolve :: (Int, Int, [(Int, Int)]) -> Maybe [Int]\nsolve (_, summ, days) =\n if summ >= minSum && summ <= maxSum\n then Just . snd $ mapAccumL f (summ - minSum) days\n else Nothing\n where\n f 0 (d, _) = (0, d)\n f summ (mn, mx)\n-- | trace (unwords [\">\", show summ, show mn, show mx]) False = undefined\n | summ > mx - mn = (summ - mx + mn, mx)\n | otherwise = (0, mn + summ)\n minSum = sum . map fst $ days\n maxSum = sum . map snd $ days\n\npresent Nothing = \"NO\"\npresent (Just res) = unlines [\"YES\", unwords . map show $ res]\n\nmain = interact $ present . solve . parse\n \n\n"}, {"source_code": "import Data.List\nmain = interact $ f.map (map read.words).lines\n\nf ([_,pam]:xs) = \n\tlet minn = sum $ map head xs in \n\tlet maxx = sum $ map last xs in\n\tif maxx >= pam && minn <= pam\n\tthen showResult $ g (maxx - pam) xs\n\telse \"NO\"\n\ng _ [] = []\ng diff xs\n\t| diff == 0 = two xs : g 0 (tail xs)\n\t| otherwise = let minn = min diff (two xs - one xs) in (two xs - minn) : g (diff - minn) (tail xs)\n\twhere\n\tone x = head $ head x\n\ttwo x = last $ head x\n\nshowResult xs = \"YES\\n\" ++ intercalate \" \" (map show xs)"}, {"source_code": "import Control.Monad\n\nfoldTuples :: [(Int, Int)] -> ((Int, Int) -> Int) -> Int\nfoldTuples l f = foldl (\\prev t -> prev + f t) 0 l\n\ngetMin :: [(Int, Int)] -> Int\ngetMin l = foldTuples l fst\n\ngetMax :: [(Int, Int)] -> Int\ngetMax l = foldTuples l snd\n\ngetTuple :: IO (Int, Int)\ngetTuple = do\n s <- getLine\n let l = map read $ words s :: [Int]\n return (l !! 0, l !! 1)\n\ncanSolve :: Int -> [(Int, Int)] -> Bool\ncanSolve acum l = getMin l <= acum && acum <= getMax l\n\nsolve :: Int -> [(Int, Int)] -> [Int]\nsolve goal l = solve' goal l (getMin l)\n\nsolve' :: Int -> [(Int, Int)] -> Int -> [Int]\nsolve' _ [] _ = []\nsolve' goal (x:xs) curr = \n let delta = snd x - fst x \n in (\n if curr + delta <= goal then (snd x) : solve' goal xs (curr + delta)\n else (fst x + goal - curr) : solve' goal xs (curr + (goal - curr))\n )\n\nmain = do\n (d, sumTime) <- getTuple\n l <- replicateM d getTuple\n if canSolve sumTime l \n then do\n putStrLn \"YES\"\n putStrLn $ unwords $ map show (solve sumTime l)\n else do\n putStrLn \"NO\"\n"}, {"source_code": "main = interact $ solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> String\nsolve ([_, goal]:l) = \n let mn = foldr ((+) . head) 0 l in\n let mx = foldr ((+) . (!! 1)) 0 l in\n if mn <= goal && goal <= mx \n then \"YES\\n\" ++ (unwords . map show $ f mn l) ++ \"\\n\"\n else \"NO\\n\"\n where f _ [] = []\n f acum ([a, b]:rest) = if acum + (b-a) <= goal\n then b:f (acum + (b-a)) rest\n else (a + (goal-acum)):f goal rest\n \n"}, {"source_code": "main = interact $ solve . (((read <$>) . words) <$>) . lines\n where\n solve (x:xs)\n | sumof minimum xs > last x || sumof maximum xs < last x = \"NO\"\n | otherwise = \"YES\\n\" ++ (unwords . (show <$>)) (arrange xs $ last x - sumof minimum xs)\n sumof f = sum . (f <$>)\n arrange [] _ = []\n arrange (p:ps) remn\n | remn > diff = last p : arrange ps (remn - diff)\n | remn <= last p = head p + remn : arrange ps 0\n where\n diff = last p - head p\n"}, {"source_code": "main = interact $ solve . map (map read . words) . lines\n where\n solve (x:xs)\n | sumof minimum xs > last x || sumof maximum xs < last x = \"NO\"\n | otherwise =\n \"YES\\n\" ++ (unwords . map show) (arrange xs $ last x - sumof minimum xs)\n sumof f = sum . (f <$>)\n arrange [] _ = []\n arrange (p:ps) remn\n | remn > diff = last p : arrange ps (remn - diff)\n | remn <= last p = head p + remn : arrange ps 0\n where\n diff = last p - head p"}, {"source_code": "import Data.List\n\nsolve :: [[Int]] -> String\nsolve ([_, s] : ts) = if lb <= s && s <= ub then \"YES\\n\" ++ unwords (map show ys) else \"NO\"\n where\n [lb, ub] = map sum $ transpose ts\n\n mapper d [l, u] = (d - used, l + used) where used = min (u-l) d\n ys = snd $ mapAccumL mapper (s - lb) ts\n\nmain :: IO ()\nmain = interact $ solve . map (map read . words) . lines\n"}, {"source_code": "import Data.List (transpose, unfoldr)\n\nsolve :: [Int] -> String\nsolve (_ : s : xs) = if lb <= s && s <= ub then \"YES\\n\" ++ unwords (map show ys) else \"NO\"\n where\n chunks n = takeWhile (not . null) . unfoldr (Just . splitAt n)\n ts = chunks 2 xs\n [lb, ub] = map sum $ transpose ts\n\n folder (d, acc) [l, u] = (d - used, l + used : acc)\n where used = min (u-l) d\n ys = reverse . snd $ foldl folder (s - lb, []) ts\n\nmain :: IO ()\nmain = interact $ solve . map read . words\n"}, {"source_code": "import Data.List\n\nsolve :: [Int] -> String\nsolve (_ : s : xs) = if lb <= s && s <= ub then \"YES\\n\" ++ unwords (map show ys) else \"NO\"\n where\n chunks n = takeWhile (not . null) . unfoldr (Just . splitAt n)\n ts = chunks 2 xs\n [lb, ub] = map sum $ transpose ts\n\n mapper d [l, u] = (d - used, l + used) where used = min (u-l) d\n ys = snd $ mapAccumL mapper (s - lb) ts\n\nmain :: IO ()\nmain = interact $ solve . map read . words\n"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables,TupleSections #-}\nimport Control.Monad\ndata State s a = State {runState :: s->(a,s)}\ninstance Monad (State s) where\n return = State . (,)\n (State f1) >>= f2 = State $ uncurry (runState . f2) . f1\n (State f1) >> (State f2) = State $ f2 .snd . f1\n\n\n\n\nrepeatM a = mapM (const a) (repeat 1)\nrepeatMn a n = mapM (const a) [1..n]\nreadm::(Read a) => State String a\nreadm = State (head . reads)\nreadchar = State (\\s->(head s,tail s))\ncsum = foldr (\\x y -> (x + head y) : y) [0]\n\nrunRead x s = fst $ runState x s\n\nsolve [] _ _ = []\nsolve ls l s = x : solve (tail ls) (tail l) (s-x) where\n\t(smin,smax) = head ls\n\t(dmin,dmax) = head l\n\tx = if (s-dmin <= smax) then dmin else (s-smax)\n\nmain = reader >>= writer . solver\nreader = getContents\nwriter = putStr\nsolver = runRead $ do\n\td<-readm\n\tsumTime<-readm\n\ttimes::[(Int,Int)] <- mapM (const (liftM2 (,) readm readm)) [1..d]\n\tlet smin = csum . map fst $ times\n\tlet smax = csum . map snd $ times\n\tlet stimes = zip smin smax\n\tlet solution =(solve (tail stimes) times sumTime)\n\treturn (if sumTime >= (fst.head $ stimes) && sumTime <= (snd.head $ stimes) then (\"YES\\n\"++ (unwords . map show $ solution)) else \"NO\")\n\t\n"}, {"source_code": "module Main where\n\nimport Control.Monad\n\nmain = do\n [d, sumT] <- ( map read . words ) `liftM` getLine\n insts <- replicateM d $ do\n [a, b] <- ( map read . words ) `liftM` getLine\n return (a, b)\n\n putStrLn $ maybe \"NO\" ( ( \"YES\\n\" ++ ) . unwords . map show) $ extract sumT insts\n\nextract :: Int -> [(Int, Int)] -> Maybe [Int]\nextract sumT insts = extract' (sumT, sumT) insts >>= return . fst\n where\n extract' (minT, maxT) [] =\n if minT <= 0 && 0 <= maxT\n then Just ([], 0)\n else Nothing\n extract' (minT, maxT) ((minI, maxI) : is) = do\n (res, consume) <- extract' (minT-maxI, maxT-minI) is\n let take = max (minT-consume) minI\n return ( take : res, take + consume )\n"}, {"source_code": "import Data.List\n\nreadPairInt :: String -> (Int, Int)\nreadPairInt xs = ((read pre)::Int, (read suf)::Int)\n where (pre, suf) = break (== ' ') xs\n\nlistAll [] = [[]]\nlistAll xss = [x:y | x <- (head xss), y <- (listAll (tail xss))]\n\nmySolver :: Int -> [Int] -> [Int] -> [Int]\nmySolver 0 _ _ = [] \nmySolver curSum minList maxsumList = thisDay : (mySolver (curSum - thisDay) (tail minList) (tail maxsumList))\n where thisDay = max (curSum - (head (tail maxsumList))) (head minList)\n\nmyFunction :: String -> String\nmyFunction input = if (sumHours < minHours || sumHours > maxHours)\n then \"NO\\n\"\n else \"YES\\n\" ++ aSolution ++ \"\\n\"\n where inputLines = lines input\n (days, sumHours) = readPairInt (head inputLines)\n hourLimits = map readPairInt (tail inputLines)\n minsumList = scanr (+) 0 $ map fst hourLimits\n maxsumList = scanr (+) 0 $ map snd hourLimits\n minHours = head minsumList\n maxHours = head maxsumList\n aSolution' = mySolver sumHours (map fst hourLimits) maxsumList\n aSolution'' = aSolution' ++ (replicate (days - length aSolution') 0)\n aSolution = unwords $ map show $ aSolution''\n\nmain = interact $ myFunction"}, {"source_code": "import Data.List\n\nmain = interact $ solve . map (map read . words) . lines\n\nsolve ([_, sumTime]:rest) =\n let minSumTime = sum $ map head rest in\n let maxSumTime = sum $ map (head . tail) rest in\n if minSumTime <= sumTime && sumTime <= maxSumTime\n then tostr $ f sumTime minSumTime maxSumTime rest\n else \"NO\"\n where f sum minsum maxsum ([a, b]:rest) =\n let c = min b (sum - minsum + a) in\n c : f (sum - c) (minsum - a) (maxsum - c) rest\n f sum minsum maxsum [] = []\n tostr x = \"YES\\n\" ++ intercalate \" \" (map show x)\n"}, {"source_code": "module Main where\nmain = do\n\tinstr <- getLine\n\tlet [d, sumTime] = map readInt $ words instr\n\tinstr <- getContents\n\tlet pairs = map readInts (lines instr)\n\tlet mins = map (\\[x,_] -> x) pairs\n\tlet maxs = map (\\[_,x] -> x) pairs\n\tlet res = solve d sumTime mins maxs (sum mins) (sum maxs)\n\tputStrLn (if null res then \"NO\" else \"YES\")\n\tmapM_ (putStr.(++ \" \").show) res\n\tputStrLn \"\"\n\nsolve :: Int -> Int -> [Int] -> [Int] -> Int -> Int -> [Int]\nsolve d sumTime mins maxs sumMin sumMax = \n\tif sumTime >= sumMin && sumTime <= sumMax\n\tthen zipWith (+) mins $\n\t\tsimpleSolve d (sumTime - sumMin) (zipWith (-) maxs mins)\n\telse []\n\nsimpleSolve :: Int -> Int -> [Int] -> [Int]\nsimpleSolve 1 time [z] = [minimum [time, z]]\nsimpleSolve d time (z:zs) = \n\tminimum [time, z] : simpleSolve (d-1) (time - minimum [time, z]) zs\n\t\n\nreadInts :: String -> [Int]\nreadInts s = map readInt (words s)\n\nreadInt :: String -> Int\nreadInt = read\n"}, {"source_code": "\nimport Control.Monad (replicateM)\nimport Prelude hiding (reads)\n\nreads :: IO (Int, Int)\nreads = do\n [x, y] <- getLine >>= return . map read . words\n return (x, y)\n\nsolve :: Int -> [(Int, Int)] -> Maybe [Int]\nsolve t xs\n | mn > t || t > mx = Nothing\n | otherwise = Just (solve' (t - mn) xs)\n where\n mn = sum $ map fst xs\n mx = sum $ map snd xs\n solve' 0 xs = map fst xs\n solve' n [] = undefined\n solve' n ((a,b):xs)\n | b - a >= n = (a + n) : (solve' 0 xs)\n | otherwise = b : (solve' (n - (b-a)) xs)\n\nprintAns :: Maybe [Int] -> IO ()\nprintAns Nothing = putStrLn \"NO\"\nprintAns (Just xs) = putStrLn \"YES\" >> prints xs\n where\n prints [x] = print x\n prints (x:xs) = putStr (show x ++ \" \") >> prints xs\n\nmain :: IO ()\nmain = do\n (n, t) <- reads\n as <- replicateM n reads\n printAns $ solve t as"}, {"source_code": "import Data.List\nimport Control.Monad\nreadP s = head $ reads s >>= \\(a,s') -> return (a,read s')\nmain = do\n (d,s) <- liftM readP getLine\n ds <- replicateM d (liftM readP getLine)\n let low = sum $ map fst ds\n high = sum $ map snd ds\n if s < low || s > high\n then putStrLn \"NO\"\n else do\n putStrLn \"YES\"\n putStrLn . unwords . map show . snd $ mapAccumL f (s-low) ds\n where f r (l,h) = (r-r',l+r') where r' = min r (h-l)"}, {"source_code": "import Data.Functor\nimport Data.List\nimport Control.Monad\n\ndata T = T Int Int Int\n deriving (Show)\n\nsolve :: T -> ([T], Int) -> ([T], Int)\nsolve (T minT maxT _) (ts, rest)\n | rest > 0 = (T minT maxT curT : ts, rest - curT)\n | otherwise = (T minT maxT minT : sub minT ts, rest - minT)\n where\n curT = min maxT rest\n\nsub :: Int -> [T] -> [T]\nsub 0 ts = ts\nsub n (T minT maxT curT : []) = [T minT maxT (curT - n)]\nsub n (T minT maxT curT : ts) = T minT maxT (curT - c) : sub (n - c) ts\n where\n c = min n $ curT - minT\n\noverTime :: T -> Bool\noverTime (T minT maxT curT) = curT < minT || maxT < curT\n\ngetCurT (T _ _ c) = c\n\nmain = do\n d:sumT:_ <- map read . words <$> getLine\n ts <- replicateM d $ do\n minT:maxT:_ <- map read . words <$> getLine\n return $ T minT maxT 0\n let (ts', rest) = foldr solve ([], sumT) ts\n case rest > 0 || overTime (last ts') of\n True -> putStrLn \"NO\"\n _ -> do\n putStrLn \"YES\"\n putStrLn $ unwords $ map (show . getCurT) ts'\n"}, {"source_code": "import Control.Applicative\nimport Data.Array\nimport Data.List\n\nreadInts :: String -> [Int]\nreadInts = fmap read . words\n\nsolve :: [[Int]] -> String\nsolve ([days, sumTime] : xss)\n | y `inRange` sumTime = \"YES\\n\" ++ concat (intersperse \" \" answer)\n | otherwise = \"NO\"\n where y : ys = fmap conv . reverse $ scanl1 (zipWith (+)) (take days xss)\n answer = reverse . snd $ mapAccumL f sumTime (zip (conv <$> reverse xss) $ snd (unzip ys) ++ [0])\n where f n (b, z) = (n - candidate, show candidate)\n where candidate = head [x | x <- range b, n - x <= z]\n conv [a, b] = (a, b)\n\nmain = interact $ solve . fmap readInts . lines\n\ntest1 = solve [[1, 48], [5, 7]]\ntest2 = solve [[2, 5], [0, 1], [3, 5]]\ntest3 = solve [[3, 10], [2, 2], [2, 4], [4, 5]]\ntest4 = solve [[5, 16], [2, 2], [2, 4], [4, 5], [1, 2], [1, 2]]\ntest5 = solve [[5, 3], [0, 2], [0, 4], [0, 5], [0, 2], [0, 2]]\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST\nimport Data.Array.ST\nimport Data.List\n\nreadInts :: String -> [Int]\nreadInts = fmap read . words\n\nsolve :: [[Int]] -> String\nsolve ([days, sumTime] : xs) = runST $ do\n let hours = days * 8\n a <- newArray ((0, 0), (days, hours)) maxBound :: ST s (STArray s (Int, Int) Int)\n writeArray a (0, 0) 0\n forM_ (zip [1 ..] (take days xs)) $ \\(i, [minH, maxH]) -> do\n forM_ [minH .. maxH] $ \\h -> do\n forM_ [0 .. hours] $ \\j -> do\n ok <- (/= maxBound) <$> readArray a (i - 1, j)\n when ok $ do\n let j' = j + h\n when ((0, hours) `inRange` j') $ do\n v <- readArray a (i, j')\n writeArray a (i, j') (min v j)\n if sumTime > hours\n then return \"NO\"\n else do\n ok <- (/= maxBound) <$> readArray a (days, sumTime)\n if ok\n then do\n xs@(x : _) <- reverse <$> answer a days sumTime\n let ys = zipWith subtract xs (tail xs)\n let zs = x : ys\n return $ \"YES\\n\" ++ concat (intersperse \" \" (show <$> zs))\n else return \"NO\"\n where\n answer _ 0 _ = return []\n answer a i j = do\n j' <- readArray a (i, j)\n (j :) <$> answer a (i - 1) j'\n\nmain = interact $ solve . fmap readInts . lines\n\ntest1 = solve [[1, 48], [5, 7]]\ntest2 = solve [[2, 5], [0, 1], [3, 5]]\ntest3 = solve [[3, 10], [2, 2], [2, 4], [4, 5]]\ntest4 = solve [[5, 16], [2, 2], [2, 4], [4, 5], [1, 2], [1, 2]]\ntest5 = solve [[5, 3], [0, 2], [0, 4], [0, 5], [0, 2], [0, 2]]\n\n\n"}, {"source_code": "main = do\n\t[d, sumTime] <- map read `fmap` (words `fmap` getLine)\n\tpairs <- mapM (\\_ -> map read `fmap` (words `fmap` getLine)) [1..d]\n\tlet (minSum, maxSum) = foldl (\\(si, sx) [i, x] -> (si+i, sx+x)) (0,0) pairs\n\tif sumTime < minSum || sumTime > maxSum then putStr \"NO\" else do\n\t\tlet (_, revS) = foldl (\\(delta, s) [minI, maxI] ->\n\t\t\t\tlet a = min maxI (delta + minI) in\n\t\t\t\t(delta - a + minI, a:s)) (sumTime - minSum, []) pairs\n\t\tputStr \"YES\\n\"\n\t\tputStr $ unwords $ map show $ reverse revS\n"}, {"source_code": "import Control.Monad\n\nmain = do\n d:sumt:[] <- getLine >>= return . (map read :: [String] -> [Int]) . words\n a <- getContents >>= return . map ((map read :: [String] -> [Int]) . words) . lines\n let sum_min = sum $ map (\\(x:xs) -> x) a\n let sum_max = sum $ map (\\(_:x:xs) -> x) a\n if sumt < sum_min || sum_max < sumt\n then putStrLn \"NO\"\n else putStrLn \"YES\" >> foldM_ (\\rest [x,y] -> print (x+min rest (y-x)) >> return (rest-min rest (y-x))) (sumt - sum_min) a"}, {"source_code": "module Main where\n\nimport Control.Monad (replicateM)\nimport Data.List (mapAccumL)\n\ndata DayLimits = DayLimits {\n minTime :: !Int,\n extraTime :: !Int\n } deriving (Show)\n\nmain :: IO ()\nmain = do\n [d, sum] <- readInts\n limits <- replicateM d readLimits\n case schedule sum limits of\n Nothing -> putStrLn \"NO\"\n Just t -> do\n putStrLn \"YES\"\n putStrLn $ unwords (map show t)\n\nschedule :: Int -> [DayLimits] -> Maybe [Int]\nschedule sumTime limits\n | sumTime < minTotalTime || remTime /= 0 = Nothing\n | otherwise = Just scheduledTime\n where\n minTotalTime = sum $ map minTime limits\n reduceTime rem limit = let used = min rem (extraTime limit) in (rem - used, used + minTime limit)\n (remTime, scheduledTime) = mapAccumL reduceTime (sumTime - minTotalTime) limits\n\n-- schedule 0 [] = Just []\n-- schedule sum _ | sum < 0 = Nothing\n-- schedule _ [] = Nothing\n-- schedule sum (d:rest) = asum $ map tryTime [minTime d .. maxTime d]\n-- where\n-- tryTime t = (:) t <$> schedule (sum - t) rest\n\n\nreadInts :: IO [Int]\nreadInts = map read . words <$> getLine\n\nreadLimits :: IO DayLimits\nreadLimits = do\n [minL, maxL] <- readInts\n pure $ DayLimits minL (maxL - minL)\n"}, {"source_code": "{-# LANGUAGE TypeSynonymInstances #-}\n{-# OPTIONS_GHC -O2 #-}\nimport Debug.Trace\nimport Data.List\n\nclass Scan a where scan' :: String -> a\ninstance Scan Int where scan' n = read n\ninstance Scan Char where scan' (x:_) = x\ninstance Scan Float where scan' f = read f\ninstance Scan Double where scan' d = read d\ninstance Scan Integer where scan' n = read n\ninstance Scan String where scan' x = x\ninstance (Scan a,Scan b) => Scan (a,b) where scan' x = scan'' (words x)\n where\n scan'' (x:y:_) = (scan' x,scan' y)\ninstance (Scan a,Scan b,Scan c) => Scan (a,b,c) where scan' x = scan'' (words x)\n where\n scan'' (x:y:z:_) = (scan' x,scan' y,scan' z)\ninstance (Scan a,Scan b,Scan c,Scan d) => Scan (a,b,c,d) where scan' x = scan'' (words x)\n where\n scan'' (w:x:y:z:_) = (scan' w,scan' x,scan' y,scan' z)\ninstance (Scan a,Scan b,Scan c,Scan d,Scan e) => Scan (a,b,c,d,e) where scan' x = scan'' (words x)\n where\n scan'' (v:w:x:y:z:_) = (scan' v,scan' w,scan' x,scan' y,scan' z)\nclass Ans a where showans :: a -> String\ninstance Ans Int where showans x = show x\ninstance Ans Char where showans x = [x]\ninstance Ans Float where showans x = show x\ninstance Ans Double where showans x = show x\ninstance Ans Integer where showans x = show x\ninstance Ans String where showans x = x\ninstance (Ans a, Ans b) => Ans (a,b) where\n showans (x,y) = showans x ++ \" \" ++ showans y\ninstance (Ans a, Ans b,Ans c) => Ans (a,b,c) where\n showans (x,y,z) = showans x ++ \" \" ++ showans y ++ \" \" ++ showans z\n\nscan :: (Scan a) => IO a\nscan = do n <- getLine\n return (scan' n)\n\nscans :: (Scan a) => Int -> IO [a]\nscans 0 = return []\nscans n = do x <- scan\n xs <- scans (n-1)\n return (x:xs)\n\nscanlist :: (Scan a) => IO [a]\nscanlist = do l <- getLine\n return [scan' x|x<-words l]\n\nscanlists :: (Scan a) => Int -> IO [[a]]\nscanlists 0 = return []\nscanlists n = do x <- scanlist :: (Scan a) => IO [a]\n xs <- scanlists (n-1)\n return (x:xs)\n\nputAnsLn :: (Ans a) => a -> IO ()\nputAnsLn ans = putStrLn (showans ans)\n\nputAnsLns :: (Ans a) => [a] -> IO ()\nputAnsLns (x:xs) = do putAnsLn x\n putAnsLns xs\nputAnsLns [] = return ()\n\nconv :: Int -> [Int] -> [Int] -> String\nconv d mins l = let len = d-(length l) in\n (unwords) (map show (zipWith (+) mins ((reverse l)++(replicate len 0))))\n\nsolve _ _ _ [] _ = [\"NO\"]\nsolve d sumtime mins (m:ms) l = if sumtime <= m then\n (\"YES\":[(conv d mins (sumtime:l))])\n else\n solve d (sumtime-m) mins ms (trace (show (m:l)) (m:l))\n\nsolve' d sumtime [] mins newshd = if sumtime<0 then [\"NO\"] else solve d sumtime (reverse mins) (reverse newshd) []\nsolve' d sumtime ((min_,max_):ss) mins newshd = solve' d (sumtime-min_) ss (min_:mins) ((max_-min_):newshd)\n\nmain = do (d,sumtime) <- scan :: IO (Int,Int)\n shd <- scans d :: IO [(Int,Int)]\n putAnsLns (solve' d sumtime shd [] [])"}], "negative_code": [{"source_code": "import Data.List (transpose, unfoldr)\n\nsolve :: [Int] -> String\nsolve (_ : s : xs) = if lb <= s && s <= ub then \"YES\\n\" ++ unwords (map show ys) else \"NO\"\n where\n chunks n = takeWhile (not . null) . unfoldr (Just . splitAt n)\n [lbs, ubs] = transpose $ chunks 2 xs\n [lb, ub] = map sum [lbs, ubs]\n ys = zipWith (+) lbs $ replicate (s-lb) 1 ++ repeat 0\n\nmain :: IO ()\nmain = interact $ solve . map read . words\n"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables,TupleSections #-}\nimport Control.Monad\ndata State s a = State {runState :: s->(a,s)}\ninstance Monad (State s) where\n return = State . (,)\n (State f1) >>= f2 = State $ uncurry (runState . f2) . f1\n (State f1) >> (State f2) = State $ f2 .snd . f1\n\n\n\n\nrepeatM a = mapM (const a) (repeat 1)\nrepeatMn a n = mapM (const a) [1..n]\nreadm::(Read a) => State String a\nreadm = State (head . reads)\nreadchar = State (\\s->(head s,tail s))\ncsum = foldr (\\x y -> (x + head y) : y) [0]\n\nrunRead x s = fst $ runState x s\n\nsolve _ _ 0 = []\nsolve ls l s = x : solve (tail ls) (tail l) (s-x) where\n\t(smin,smax) = head ls\n\t(dmin,dmax) = head l\n\tx = if (s-dmin <= smax) then dmin else (s-smax)\n\nmain = reader >>= writer . solver\nreader = getContents\nwriter = putStr\nsolver = runRead $ do\n\td<-readm\n\tsumTime<-readm\n\ttimes::[(Int,Int)] <- mapM (const (liftM2 (,) readm readm)) [1..d]\n\tlet smin = csum . map fst $ times\n\tlet smax = csum . map snd $ times\n\tlet stimes = zip smin smax\n\tlet solution =(solve (tail stimes) times sumTime)\n\treturn (if sumTime >= (fst.head $ stimes) && sumTime <= (snd.head $ stimes) then (\"YES\\n\"++ (unwords . map show $ solution)) else \"NO\")\n\t\n"}, {"source_code": "import Data.List\n\nreadPairInt :: String -> (Int, Int)\nreadPairInt xs = ((read pre)::Int, (read suf)::Int)\n where (pre, suf) = break (== ' ') xs\n\nlistAll [] = [[]]\nlistAll xss = [x:y | x <- (head xss), y <- (listAll (tail xss))]\n\nmySolver :: Int -> [Int] -> [Int] -> [Int]\nmySolver 0 _ _ = [] \nmySolver curSum minList maxsumList = thisDay : (mySolver (curSum - thisDay) (tail minList) (tail maxsumList))\n where thisDay = max (curSum - (head (tail maxsumList))) (head minList)\n\nmyFunction :: String -> String\nmyFunction input = if (sumHours < minHours || sumHours > maxHours)\n then \"NO\\n\"\n else \"YES\\n\" ++ aSolution ++ \"\\n\"\n where inputLines = lines input\n (days, sumHours) = readPairInt (head inputLines)\n hourLimits = map readPairInt (tail inputLines)\n minsumList = scanr (+) 0 $ map fst hourLimits\n maxsumList = scanr (+) 0 $ map snd hourLimits\n minHours = head minsumList\n maxHours = head maxsumList\n aSolution' = mySolver sumHours (map fst hourLimits) maxsumList\n aSolution = unwords $ map show $ aSolution'\n\nmain = interact $ myFunction"}, {"source_code": "\nimport Control.Monad (replicateM)\nimport Prelude hiding (reads)\n\nreads :: IO (Int, Int)\nreads = do\n [x, y] <- getLine >>= return . map read . words\n return (x, y)\n\nsolve :: Int -> [(Int, Int)] -> Maybe [Int]\nsolve t xs\n | mn > t || t > mx = Nothing\n | otherwise = Just $ mn : (solve' (t - mn) xs)\n where\n mn = sum $ map fst xs\n mx = sum $ map snd xs\n solve' 0 xs = map fst xs\n solve' n [] = undefined\n solve' n ((a,b):xs)\n | b - a >= n = (a + n) : (solve' 0 xs)\n | otherwise = b : (solve' (n - (b-a)) xs)\n\nprintAns :: Maybe [Int] -> IO ()\nprintAns Nothing = putStrLn \"NO\"\nprintAns (Just xs) = putStrLn \"YES\" >> prints xs\n where\n prints [x] = print x\n prints (x:xs) = putStr (show x ++ \" \") >> prints xs\n\nmain :: IO ()\nmain = do\n (n, t) <- reads\n as <- replicateM n reads\n printAns $ solve t as\n"}, {"source_code": "\nimport Control.Monad (replicateM)\nimport Prelude hiding (reads)\n\nreads :: IO (Int, Int)\nreads = do\n [x, y] <- getLine >>= return . map read . words\n return (x, y)\n\nsolve :: Int -> [(Int, Int)] -> Maybe [Int]\nsolve t xs\n | mn > t || t > mx = Nothing\n | otherwise = Just $ solve' (t - mn) xs\n where\n mn = sum $ map fst xs\n mx = sum $ map snd xs\n solve' 0 xs = map fst xs\n solve' n [] = undefined\n solve' n ((a,b):xs)\n | b - a >= n = a + n : (solve' 0 xs)\n | otherwise = b : (solve' (n-b) xs)\n\nprintAns :: Maybe [Int] -> IO ()\nprintAns Nothing = putStrLn \"NO\"\nprintAns (Just xs) = putStrLn \"YES\" >> prints xs\n where\n prints [x] = print x\n prints (x:xs) = putStr (show x ++ \" \") >> prints xs\n\nmain :: IO ()\nmain = do\n (n, t) <- reads\n as <- replicateM n reads\n printAns $ solve t as\n"}, {"source_code": "import Control.Applicative\nimport Data.Array\nimport Data.List\n\nreadInts :: String -> [Int]\nreadInts = fmap read . words\n\nsolve :: [[Int]] -> String\nsolve ([days, sumTime] : xss)\n | y `inRange` sumTime = \"YES\\n\" ++ concat (intersperse \" \" answer)\n | otherwise = \"NO\"\n where y : ys = fmap conv . reverse $ scanl1 (zipWith (+)) (take days xss)\n where conv [a, b] = (a, b) \n answer = snd $ mapAccumL f sumTime (snd (unzip ys) ++ [0])\n where f n z | n <= z = (n, \"0\")\n | otherwise = let x = n - z in (z, show x)\n\nmain = interact $ solve . fmap readInts . lines\n\n"}, {"source_code": "import Control.Applicative\nimport Data.Array\nimport Data.List\n\nreadInts :: String -> [Int]\nreadInts = fmap read . words\n\nsolve :: [[Int]] -> String\nsolve ([days, sumTime] : xss)\n | y `inRange` sumTime = \"YES\\n\" ++ concat (intersperse \" \" answer)\n | otherwise = \"NO\"\n where y : ys = fmap conv . reverse $ scanl1 (zipWith (+)) (take days xss)\n where conv [a, b] = (a, b) \n answer = reverse . snd $ mapAccumL f sumTime (snd (unzip ys) ++ [0])\n where f n z | n <= z = (n, \"0\")\n | otherwise = let x = n - z in (z, show x)\n\nmain = interact $ solve . fmap readInts . lines\n\ntest1 = solve [[1, 48], [5, 7]]\ntest2 = solve [[2, 5], [0, 1], [3, 5]]\ntest3 = solve [[3, 10], [2, 2], [2, 4], [4, 5]]\ntest4 = solve [[5, 16], [2, 2], [2, 4], [4, 5], [1, 2], [1, 2]]\ntest5 = solve [[5, 3], [0, 2], [0, 4], [0, 5], [0, 2], [0, 2]]\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST\nimport Data.Array.ST\nimport Data.List\n\nreadInts :: String -> [Int]\nreadInts = fmap read . words\n\nsolve :: [[Int]] -> String\nsolve ([days, sumTime] : xs) = runST $ do\n let hours = days * 8\n a <- newArray ((0, 0), (days, hours)) maxBound :: ST s (STArray s (Int, Int) Int)\n writeArray a (0, 0) 0\n forM_ (zip [1..] (take days xs)) $ \\(i, hs) -> do\n forM_ hs $ \\h -> do\n forM_ [0 .. hours] $ \\j -> do\n ok <- (/= maxBound) <$> readArray a (i - 1, j)\n when ok $ do\n let j' = j + h\n when ((0, hours) `inRange` j') $ do\n j'' <- readArray a (i, j')\n writeArray a (i, j') (min j j'')\n if sumTime > hours\n then return \"NO\"\n else do\n ok <- (/= maxBound) <$> readArray a (days, sumTime)\n if ok\n then do\n xs@(x : _) <- reverse <$> answer a days sumTime\n let ys = zipWith subtract xs (tail xs)\n let zs = x : ys\n return $ \"YES\\n\" ++ concat (intersperse \" \" (show <$> zs))\n else return \"NO\"\n where\n answer _ 0 _ = return []\n answer a i j = do\n j' <- readArray a (i, j)\n (j :) <$> answer a (i - 1) j'\n\nmain = interact $ solve . fmap readInts . lines\n\ntest1 = solve [[1, 48], [5, 7]]\ntest2 = solve [[2, 5], [0, 1], [3, 5]]\ntest3 = solve [[3, 10], [2, 2], [2, 4], [4, 5]]\ntest4 = solve [[5, 16], [2, 2], [2, 4], [4, 5], [1, 2], [1, 2]]\n\n\n"}, {"source_code": "module Main where\n\nimport Control.Monad (replicateM)\nimport Data.List (mapAccumL)\n\ndata DayLimits = DayLimits {\n minTime :: !Int,\n extraTime :: !Int\n } deriving (Show)\n\nmain :: IO ()\nmain = do\n [d, sum] <- readInts\n limits <- replicateM d readLimits\n case schedule sum limits of\n Nothing -> putStrLn \"NO\"\n Just t -> do\n putStrLn \"YES\"\n putStrLn $ unwords (map show t)\n\nschedule :: Int -> [DayLimits] -> Maybe [Int]\nschedule sumTime limits\n | sumTime < minTotalTime && remTime /= 0 = Nothing\n | otherwise = Just scheduledTime\n where\n minTotalTime = sum $ map minTime limits\n reduceTime rem limit = let used = min rem (extraTime limit) in (rem - used, used + minTime limit)\n (remTime, scheduledTime) = mapAccumL reduceTime (sumTime - minTotalTime) limits\n\n-- schedule 0 [] = Just []\n-- schedule sum _ | sum < 0 = Nothing\n-- schedule _ [] = Nothing\n-- schedule sum (d:rest) = asum $ map tryTime [minTime d .. maxTime d]\n-- where\n-- tryTime t = (:) t <$> schedule (sum - t) rest\n\n\nreadInts :: IO [Int]\nreadInts = map read . words <$> getLine\n\nreadLimits :: IO DayLimits\nreadLimits = do\n [minL, maxL] <- readInts\n pure $ DayLimits minL (maxL - minL)\n"}, {"source_code": "module Main where\n\nimport Control.Monad (replicateM)\nimport Data.List (mapAccumL)\n\ndata DayLimits = DayLimits {\n minTime :: !Int,\n extraTime :: !Int\n } deriving (Show)\n\nmain :: IO ()\nmain = do\n [d, sum] <- readInts\n limits <- replicateM d readLimits\n case schedule sum limits of\n Nothing -> putStrLn \"NO\"\n Just t -> do\n putStrLn \"YES\"\n putStrLn $ unwords (map show t)\n\nschedule :: Int -> [DayLimits] -> Maybe [Int]\nschedule sumTime limits\n | remTime == 0 = Just scheduledTime\n | otherwise = Nothing\n where\n minTotalTime = sum $ map minTime limits\n reduceTime rem limit = let used = min rem (extraTime limit) in (rem - used, used + minTime limit)\n (remTime, scheduledTime) = mapAccumL reduceTime (sumTime - minTotalTime) limits\n\n-- schedule 0 [] = Just []\n-- schedule sum _ | sum < 0 = Nothing\n-- schedule _ [] = Nothing\n-- schedule sum (d:rest) = asum $ map tryTime [minTime d .. maxTime d]\n-- where\n-- tryTime t = (:) t <$> schedule (sum - t) rest\n\n\nreadInts :: IO [Int]\nreadInts = map read . words <$> getLine\n\nreadLimits :: IO DayLimits\nreadLimits = do\n [minL, maxL] <- readInts\n pure $ DayLimits minL (maxL - minL)\n"}, {"source_code": "{-# LANGUAGE TypeSynonymInstances #-}\n{-# OPTIONS_GHC -O2 #-}\nimport Data.List\n\nclass Scan a where scan' :: String -> a\ninstance Scan Int where scan' n = read n\ninstance Scan Char where scan' (x:_) = x\ninstance Scan Float where scan' f = read f\ninstance Scan Double where scan' d = read d\ninstance Scan Integer where scan' n = read n\ninstance Scan String where scan' x = x\ninstance (Scan a,Scan b) => Scan (a,b) where scan' x = scan'' (words x)\n where\n scan'' (x:y:_) = (scan' x,scan' y)\ninstance (Scan a,Scan b,Scan c) => Scan (a,b,c) where scan' x = scan'' (words x)\n where\n scan'' (x:y:z:_) = (scan' x,scan' y,scan' z)\ninstance (Scan a,Scan b,Scan c,Scan d) => Scan (a,b,c,d) where scan' x = scan'' (words x)\n where\n scan'' (w:x:y:z:_) = (scan' w,scan' x,scan' y,scan' z)\ninstance (Scan a,Scan b,Scan c,Scan d,Scan e) => Scan (a,b,c,d,e) where scan' x = scan'' (words x)\n where\n scan'' (v:w:x:y:z:_) = (scan' v,scan' w,scan' x,scan' y,scan' z)\nclass Ans a where showans :: a -> String\ninstance Ans Int where showans x = show x\ninstance Ans Char where showans x = [x]\ninstance Ans Float where showans x = show x\ninstance Ans Double where showans x = show x\ninstance Ans Integer where showans x = show x\ninstance Ans String where showans x = x\ninstance (Ans a, Ans b) => Ans (a,b) where\n showans (x,y) = showans x ++ \" \" ++ showans y\ninstance (Ans a, Ans b,Ans c) => Ans (a,b,c) where\n showans (x,y,z) = showans x ++ \" \" ++ showans y ++ \" \" ++ showans z\n\nscan :: (Scan a) => IO a\nscan = do n <- getLine\n return (scan' n)\n\nscans :: (Scan a) => Int -> IO [a]\nscans 0 = return []\nscans n = do x <- scan\n xs <- scans (n-1)\n return (x:xs)\n\nscanlist :: (Scan a) => IO [a]\nscanlist = do l <- getLine\n return [scan' x|x<-words l]\n\nscanlists :: (Scan a) => Int -> IO [[a]]\nscanlists 0 = return []\nscanlists n = do x <- scanlist :: (Scan a) => IO [a]\n xs <- scanlists (n-1)\n return (x:xs)\n\nputAnsLn :: (Ans a) => a -> IO ()\nputAnsLn ans = putStrLn (showans ans)\n\nputAnsLns :: (Ans a) => [a] -> IO ()\nputAnsLns (x:xs) = do putAnsLn x\n putAnsLns xs\nputAnsLns [] = return ()\n\nconv :: Int -> [Int] -> [Int] -> String\nconv d mins l = let len = d-(length l) in\n (unwords.reverse) (map show (zipWith (+) mins (l++(replicate len 0))))\n\nsolve _ _ _ [] _ = [\"NO\"]\nsolve d sumtime mins (m:ms) l = if sumtime <= m then\n (\"YES\":[(conv d mins (sumtime:l))])\n else\n solve d (sumtime-m) mins ms (m:l)\n\nsolve' d sumtime [] mins newshd = if sumtime<0 then [\"NO\"] else solve d sumtime mins newshd []\nsolve' d sumtime ((min_,max_):ss) mins newshd = solve' d (sumtime-min_) ss (min_:mins) ((max_-min_):newshd)\n\nmain = do (d,sumtime) <- scan :: IO (Int,Int)\n shd <- scans d :: IO [(Int,Int)]\n putAnsLns (solve' d sumtime shd [] [])"}, {"source_code": "{-# LANGUAGE TypeSynonymInstances #-}\n{-# OPTIONS_GHC -O2 #-}\nimport Data.List\n\nclass Scan a where scan' :: String -> a\ninstance Scan Int where scan' n = read n\ninstance Scan Char where scan' (x:_) = x\ninstance Scan Float where scan' f = read f\ninstance Scan Double where scan' d = read d\ninstance Scan Integer where scan' n = read n\ninstance Scan String where scan' x = x\ninstance (Scan a,Scan b) => Scan (a,b) where scan' x = scan'' (words x)\n where\n scan'' (x:y:_) = (scan' x,scan' y)\ninstance (Scan a,Scan b,Scan c) => Scan (a,b,c) where scan' x = scan'' (words x)\n where\n scan'' (x:y:z:_) = (scan' x,scan' y,scan' z)\ninstance (Scan a,Scan b,Scan c,Scan d) => Scan (a,b,c,d) where scan' x = scan'' (words x)\n where\n scan'' (w:x:y:z:_) = (scan' w,scan' x,scan' y,scan' z)\ninstance (Scan a,Scan b,Scan c,Scan d,Scan e) => Scan (a,b,c,d,e) where scan' x = scan'' (words x)\n where\n scan'' (v:w:x:y:z:_) = (scan' v,scan' w,scan' x,scan' y,scan' z)\nclass Ans a where showans :: a -> String\ninstance Ans Int where showans x = show x\ninstance Ans Char where showans x = [x]\ninstance Ans Float where showans x = show x\ninstance Ans Double where showans x = show x\ninstance Ans Integer where showans x = show x\ninstance Ans String where showans x = x\ninstance (Ans a, Ans b) => Ans (a,b) where\n showans (x,y) = showans x ++ \" \" ++ showans y\ninstance (Ans a, Ans b,Ans c) => Ans (a,b,c) where\n showans (x,y,z) = showans x ++ \" \" ++ showans y ++ \" \" ++ showans z\n\nscan :: (Scan a) => IO a\nscan = do n <- getLine\n return (scan' n)\n\nscans :: (Scan a) => Int -> IO [a]\nscans 0 = return []\nscans n = do x <- scan\n xs <- scans (n-1)\n return (x:xs)\n\nscanlist :: (Scan a) => IO [a]\nscanlist = do l <- getLine\n return [scan' x|x<-words l]\n\nscanlists :: (Scan a) => Int -> IO [[a]]\nscanlists 0 = return []\nscanlists n = do x <- scanlist :: (Scan a) => IO [a]\n xs <- scanlists (n-1)\n return (x:xs)\n\nputAnsLn :: (Ans a) => a -> IO ()\nputAnsLn ans = putStrLn (showans ans)\n\nputAnsLns :: (Ans a) => [a] -> IO ()\nputAnsLns (x:xs) = do putAnsLn x\n putAnsLns xs\nputAnsLns [] = return ()\n\nconv :: Int -> [Int] -> [Int] -> String\nconv d mins l = let len = d-(length l) in\n (unwords) (map show (zipWith (+) mins (l++(replicate len 0))))\n\nsolve _ _ _ [] _ = [\"NO\"]\nsolve d sumtime mins (m:ms) l = if sumtime <= m then\n (\"YES\":[(conv d mins (sumtime:l))])\n else\n solve d (sumtime-m) mins ms (m:l)\n\nsolve' d sumtime [] mins newshd = if sumtime<0 then [\"NO\"] else solve d sumtime (reverse mins) (reverse newshd) []\nsolve' d sumtime ((min_,max_):ss) mins newshd = solve' d (sumtime-min_) ss (min_:mins) ((max_-min_):newshd)\n\nmain = do (d,sumtime) <- scan :: IO (Int,Int)\n shd <- scans d :: IO [(Int,Int)]\n putAnsLns (solve' d sumtime shd [] [])"}, {"source_code": "{-# LANGUAGE TypeSynonymInstances #-}\n{-# OPTIONS_GHC -O2 #-}\nimport Data.List\n\nclass Scan a where scan' :: String -> a\ninstance Scan Int where scan' n = read n\ninstance Scan Char where scan' (x:_) = x\ninstance Scan Float where scan' f = read f\ninstance Scan Double where scan' d = read d\ninstance Scan Integer where scan' n = read n\ninstance Scan String where scan' x = x\ninstance (Scan a,Scan b) => Scan (a,b) where scan' x = scan'' (words x)\n where\n scan'' (x:y:_) = (scan' x,scan' y)\ninstance (Scan a,Scan b,Scan c) => Scan (a,b,c) where scan' x = scan'' (words x)\n where\n scan'' (x:y:z:_) = (scan' x,scan' y,scan' z)\ninstance (Scan a,Scan b,Scan c,Scan d) => Scan (a,b,c,d) where scan' x = scan'' (words x)\n where\n scan'' (w:x:y:z:_) = (scan' w,scan' x,scan' y,scan' z)\ninstance (Scan a,Scan b,Scan c,Scan d,Scan e) => Scan (a,b,c,d,e) where scan' x = scan'' (words x)\n where\n scan'' (v:w:x:y:z:_) = (scan' v,scan' w,scan' x,scan' y,scan' z)\nclass Ans a where showans :: a -> String\ninstance Ans Int where showans x = show x\ninstance Ans Char where showans x = [x]\ninstance Ans Float where showans x = show x\ninstance Ans Double where showans x = show x\ninstance Ans Integer where showans x = show x\ninstance Ans String where showans x = x\ninstance (Ans a, Ans b) => Ans (a,b) where\n showans (x,y) = showans x ++ \" \" ++ showans y\ninstance (Ans a, Ans b,Ans c) => Ans (a,b,c) where\n showans (x,y,z) = showans x ++ \" \" ++ showans y ++ \" \" ++ showans z\n\nscan :: (Scan a) => IO a\nscan = do n <- getLine\n return (scan' n)\n\nscans :: (Scan a) => Int -> IO [a]\nscans 0 = return []\nscans n = do x <- scan\n xs <- scans (n-1)\n return (x:xs)\n\nscanlist :: (Scan a) => IO [a]\nscanlist = do l <- getLine\n return [scan' x|x<-words l]\n\nscanlists :: (Scan a) => Int -> IO [[a]]\nscanlists 0 = return []\nscanlists n = do x <- scanlist :: (Scan a) => IO [a]\n xs <- scanlists (n-1)\n return (x:xs)\n\nputAnsLn :: (Ans a) => a -> IO ()\nputAnsLn ans = putStrLn (showans ans)\n\nputAnsLns :: (Ans a) => [a] -> IO ()\nputAnsLns (x:xs) = do putAnsLn x\n putAnsLns xs\nputAnsLns [] = return ()\n\nconv :: Int -> [Int] -> [Int] -> String\nconv d mins l = let len = d-(length l) in\n (unwords.reverse) (map show (zipWith (+) mins ((replicate len 0)++l)))\n\nsolve _ _ _ [] _ = [\"NO\"]\nsolve d sumtime mins (m:ms) l = if sumtime <= m then\n (\"YES\":[(conv d mins (sumtime:l))])\n else\n solve d (sumtime-m) mins ms (m:l)\n\nsolve' d sumtime [] mins newshd = if sumtime<0 then [\"NO\"] else solve d sumtime mins newshd []\nsolve' d sumtime ((min_,max_):ss) mins newshd = solve' d (sumtime-min_) ss (min_:mins) ((max_-min_):newshd)\n\nmain = do (d,sumtime) <- scan :: IO (Int,Int)\n shd <- scans d :: IO [(Int,Int)]\n putAnsLns (solve' d sumtime shd [] [])"}], "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0"} {"source_code": "import Data.Char\n\nmain = readLn >>= print . solve\n\nsolve k = head $ drop (k - 1) [n | n <- [19..], check n 0]\n where check n m\n | 10 < m = False\n | n == 0 = m == 10\n | otherwise = check (n `div` 10) (m + n `mod` 10)\n", "positive_code": [{"source_code": "\n--\n-- Michael V. Antosha\n-- 2019\n-- Michael.Antosha@gmail.com\n--\n-- Haskell practice.\n-- Competitive programming.\n--\n-- Codeforces Round #460 (Div. 2)\n--\n-- B. Perfect Number\n-- http://codeforces.com/contest/919/problem/B\n--\n\nimport Prelude ((+), (-), divMod)\n\nimport Data.Eq ((==))\nimport Data.Function (($), (.))\nimport Data.Int (Int)\nimport Data.List ((!!), filter)\nimport System.IO (IO, interact)\nimport Text.Read (read)\nimport Text.Show (shows)\n\nmain :: IO ()\nmain = interact $ showAnswer . getKth . read\n where\n showAnswer = ($ \"\\n\") . shows\n\ngetKth :: Int -> Int\ngetKth k = perfNums !! (k-1)\n where\n perfNums = filter isPerfect [1..]\n\n isPerfect = (== 10) . digSum\n\n digSum 0 = 0\n digSum n = dig + digSum rest\n where\n (rest, dig) = n `divMod` 10\n"}, {"source_code": "\n--\n-- Michael V. Antosha\n-- 2019\n-- Michael.Antosha@gmail.com\n-- m.antosha@samsung.com\n--\n-- Haskell practice.\n-- Competitive programming.\n--\n-- Codeforces Round #460 (Div. 2)\n--\n-- B. Perfect Number\n-- http://codeforces.com/contest/919/problem/B\n--\n\nimport Prelude\n-- (TODO) make it minimal (-ddump-minimal-imports)\n\nmain :: IO ()\nmain = interact $ ($ \"\\n\") . shows . getByInd . read\n\ngetByInd :: Int -> Int\ngetByInd = f where\n\n g i c | isPerf c = c\n | otherwise = g i (next c)\n\n f 0 = 0\n f i = g i (next $ f (i-1))\n\n next c = c+1\n -- (TODO) try to make it faster by generating queue of candidates, we do not need to check EVERY number\n\n isPerf n = (10 == digSum n)\n\n digSum 0 = 0\n digSum n = digit + (digSum rest) where\n (rest, digit) = n `divMod` 10\n"}, {"source_code": "import Data.Char\nimport Control.Monad\nperfects :: [[Int]]\nperfects = filter ((/= 0) . head) $ concatMap (sumLength 10) [1..] where\n sumLength :: Int -> Int -> [[Int]]\n sumLength i 1 = guard (i >= 0) *> pure [i]\n sumLength i w = concat [ map (f:) (sumLength (i-f) (w-1)) | f <- [0..9] ]\nmain = interact $ map intToDigit . (perfects !!) . read\n"}, {"source_code": "{-# OPTIONS_GHC -O2 #-}\nimport Data.Char\nmain=readLn>>=print.f\nf :: Int -> Int\nf k=[x|x<-[1..],sum(map digitToInt(show x))==10]!!(k-1)"}, {"source_code": "{-# OPTIONS_GHC -O2 #-}\nimport Data.Char\nmain=readLn>>=print.f\nf k\n |k<=8000=[x|x<-[1..],sum(map digitToInt(show x))==10]!!(k-1)\n |otherwise=[x|x<-[9010000..],sum(map digitToInt(show x))==10]!!(k-8000)"}, {"source_code": "import Data.Char\nimport Data.List\n\nlistOfAllPossible = iterate (\\l -> [sum . take i . drop (i - 10) $ l | i <- [1..11]]) [1,0,0,0,0,0,0,0,0,0,0]\n\nbuildNumber' :: [[Int]] -> Int -> Int -> String\nbuildNumber' _ _ 0 = \"19\"\nbuildNumber' a b c = buildNumber a b c\n\nbuildNumber :: [[Int]] -> Int -> Int -> String\nbuildNumber (x:[]) reqSum _ = [intToDigit reqSum]\nbuildNumber (x:xs) reqSum 0 = '0' : buildNumber xs reqSum 0\nbuildNumber (x:xs) reqSum n = intToDigit y : buildNumber xs (reqSum - y) (n - z)\n where Just y = findIndex (> n + k) . drop (10 - reqSum) $ x\n k = if reqSum == 10 then 0 else x!!(9 - reqSum)\n z = if y == 0 then 0 else x!!(y + 9 - reqSum) - k\n\nmain = do\n n <- fmap (flip (-) 1) readLn\n let l = map (scanl1 (+)) . map reverse . reverse $ takeWhile (\\x -> x!!10 < 50000) listOfAllPossible\n putStrLn . dropWhile (== '0') . buildNumber' l 10 $ n\n"}, {"source_code": "import qualified Data.List as L\nimport qualified Data.Set as S\n\npartitions_10 :: [[Int]]\npartitions_10 = [[1,1,1,1,1,1,1,1,1,1],\n [2,1,1,1,1,1,1,1,1],\n [2,2,1,1,1,1,1,1],\n [2,2,2,1,1,1,1],\n [2,2,2,2,1,1],\n [2,2,2,2,2],\n [3,1,1,1,1,1,1,1],\n [3,2,1,1,1,1,1],\n [3,2,2,1,1,1],\n [3,2,2,2,1],\n [3,3,1,1,1,1],\n [3,3,2,1,1],\n [3,3,2,2],\n [3,3,3,1],\n [4,1,1,1,1,1,1],\n [4,2,1,1,1,1],\n [4,2,2,1,1],\n [4,2,2,2],\n [4,3,1,1,1],\n [4,3,2,1],\n [4,3,3],\n [4,4,1,1],\n [4,4,2],\n [5,1,1,1,1,1],\n [5,2,1,1,1],\n [5,2,2,1],\n [5,3,1,1],\n [5,3,2],\n [5,4,1],\n [5,5],\n [6,1,1,1,1],\n [6,2,1,1],\n [6,2,2],\n [6,3,1],\n [6,4],\n [7,1,1,1],\n [7,2,1],\n [7,3],\n [8,1,1],\n [8,2],\n [9,1]]\n\ndigits_from_partition :: [Int] -> S.Set [Int]\ndigits_from_partition p = S.fromList $ L.permutations p\n\ndigits_to_number :: [Int] -> Int\ndigits_to_number ds = loop ds 0\n where loop [] x = x\n loop (y : ys) x = loop ys ((10 * x) + y)\n\nextend_with_zero :: [Int] -> [[Int]]\nextend_with_zero [] = error \"extend_with_zero: digits must not be empty!\" \nextend_with_zero (d : ds) = loop [d] ds []\n where loop hd [] xs = (hd ++ [0]) : xs\n loop hd tl@(y : ys) xs = loop (hd ++ [y]) ys ((hd ++ [0] ++ tl) : xs)\n\nkth_smallest_perfect_number :: Int -> Int\nkth_smallest_perfect_number k = loop k 2 S.empty\n where loop idx num_digits perfect_numbers_so_far =\n case idx < num_perfect_numbers of\n True -> digits_to_number $ S.elemAt idx perfect_numbers\n False -> loop (idx - num_perfect_numbers) (num_digits + 1) perfect_numbers\n where perfect_numbers_num_digits_no_zero = \n S.unions $ map digits_from_partition \n $ filter (\\x -> (length x) == num_digits) partitions_10\n perfect_numbers_num_digits_incl_zero =\n S.fromList $ concatMap extend_with_zero $ S.toList perfect_numbers_so_far\n perfect_numbers = S.union perfect_numbers_num_digits_no_zero\n perfect_numbers_num_digits_incl_zero\n num_perfect_numbers = S.size perfect_numbers\n\nmain :: IO ()\nmain =\n do\n -- putStrLn $ show $ length partitions_10\n -- putStrLn $ show $ map digits_from_partition $ filter (\\x -> (length x) <= 8) partitions_10\n -- putStrLn $ show $ map digits_to_number partitions_10\n -- mapM_ (putStrLn . show) $ extend_with_zero $ head partitions_10\n k_str <- getLine\n let k = (read k_str) :: Int\n putStrLn $ show $ kth_smallest_perfect_number (k - 1)\n"}, {"source_code": "import Data.List\n\nf2::(Int,Int)->(Int,Int)\nf2 (a,b)=(a,b)\n\nf::Int->(Int,Int)->[Int]\nf k (sum,num)\n |sum>10 || k>8=[]\n |otherwise=let k1=k+1\n num1=num*10\n in if sum==10 then num:f k1 (sum,num1)\n else concat (map (f k1) (zip [sum..(sum+9)] [num1..(num1+9)]))\n\nmain=do\n e1<-getLine\n let k=read e1::Int\n print $ (nub (sort (concat(map (f 1) (zip [1..9] [1..9])))))!!(k-1)"}, {"source_code": "\n--\n-- Michael V. Antosha\n-- 2019\n-- Michael.Antosha@gmail.com\n-- m.antosha@samsung.com\n--\n-- Haskell practice.\n-- Competitive programming.\n--\n-- Codeforces Round #460 (Div. 2)\n--\n-- B. Perfect Number\n-- http://codeforces.com/contest/919/problem/B\n--\n\nimport Prelude\n\n-- import Debug.Trace (trace)\n\nmain :: IO ()\nmain = interact $ ($ \"\\n\") . shows . getByInd . read\n\ndata Generator num = St { lastNum :: num }\n\ngetByInd :: Int -> Int\ngetByInd = gbi iniGen where\n\n iniGen = St {lastNum=0} -- the initial state of the generator\n\n gbi gen 0 = lastNum gen\n gbi gen cnt = gbi (nextPN gen) (cnt - 1)\n\n -- nextPN state | trace (\"nextPN: lastNum=\"++show (lastNum state)++\".\") False = undefined\n nextPN state = loop (nextState state)\n where\n\n loop st = stopIf (isPerfect . lastNum $ st) st\n\n -- stopIf cond st | trace (\"\\t\"++\"stopIf: cond=\"++show cond++\" lastNum=\"++show (lastNum st)++\".\") False = undefined\n stopIf True st = st\n stopIf False st = loop (nextState st)\n\n nextState st = St {lastNum = 1 + (lastNum st)} -- debug\n\n isPerfect = (== 10) . digSum\n\n digSum 0 = 0 -- used explicitly (for recursion only)\n digSum n = digit + digSum rest\n where\n (rest, digit) = n `divMod` 10\n"}], "negative_code": [{"source_code": "\n--\n-- Michael V. Antosha\n-- 2019\n-- Michael.Antosha@gmail.com\n-- m.antosha@samsung.com\n--\n-- Haskell practice.\n-- Competitive programming.\n--\n-- Codeforces Round #460 (Div. 2)\n--\n-- B. Perfect Number\n-- http://codeforces.com/contest/919/problem/B\n--\n\nmain :: IO ()\nmain = interact $ flip shows \"\\n\" . getByInd . const 9000000 . (read :: String -> Int)\n\ndata Gen = St { getNum :: Int }\n\ngetByInd :: Int -> Int\ngetByInd = gbi iniState\n where\n gbi st 0 = getNum st\n gbi st cnt = (gbi $! nextPN st) (cnt - 1)\n\n iniState = St (-1)\n\n nextPN st = St $! ((getNum st) + 1)\n\n\n{--\n\nexport SHELL = /bin/bash -o pipefail\n\n.PHONY: run-cpp run-hs\nrun-hs: ./hs.exec\n\tprintf '%s\\n' 10000 | /usr/bin/time -v ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '10800100'; }\n\tprintf '%s\\n' 1 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '19'; }\n\tprintf '%s\\n' 2 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '28'; }\n\tprintf '%s\\n' 3 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '37'; }\n\tprintf '%s\\n' 4 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '46'; }\n\tprintf '%s\\n' 5 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '55'; }\n\tprintf '%s\\n' 6 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '64'; }\n\tprintf '%s\\n' 7 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '73'; }\n\tprintf '%s\\n' 8 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '82'; }\n\tprintf '%s\\n' 9 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '91'; }\n\tprintf '%s\\n' 10 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '109'; }\n\tprintf '%s\\n' 11 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '118'; }\n\tprintf '%s\\n' 12 | ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '127'; }\n\tprintf '%s\\n' 100 | time ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '1423'; }\n\tprintf '%s\\n' 101 | time ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '1432'; }\n\tprintf '%s\\n' 1000 | time ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '100036'; }\n\tprintf '%s\\n' 10000 | time ./hs.exec | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '10800100'; }\nrun-cpp: ./a.out\n\tprintf '%s\\n' 1 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '19'; }\n\tprintf '%s\\n' 2 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '28'; }\n\tprintf '%s\\n' 3 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '37'; }\n\tprintf '%s\\n' 4 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '46'; }\n\tprintf '%s\\n' 5 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '55'; }\n\tprintf '%s\\n' 6 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '64'; }\n\tprintf '%s\\n' 7 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '73'; }\n\tprintf '%s\\n' 8 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '82'; }\n\tprintf '%s\\n' 9 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '91'; }\n\tprintf '%s\\n' 10 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '109'; }\n\tprintf '%s\\n' 11 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '118'; }\n\tprintf '%s\\n' 12 | ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '127'; }\n\tprintf '%s\\n' 100 | time ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '1423'; }\n\tprintf '%s\\n' 101 | time ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '1432'; }\n\tprintf '%s\\n' 1000 | time ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '100036'; }\n\tprintf '%s\\n' 10000 | time ./a.out | { x=\"$$(cat)\"; echo \"$$x\"; test \"$$x\" = '10800100'; }\n\n./hs.exec: *.hs\n\t# ghc -rtsopts=none -Wall -Wextra -Werror -O2 -o '$@' $+\n\t# ghc -rtsopts=none -Wall -Wextra -O2 -o '$@' $+\n\t# ghc -rtsopts=none -Wall -Wextra -O2 -fbreak-on-error -o '$@' $+\n\tghc -rtsopts=none -Wall -fbreak-on-error -o '$@' $+\n\tghc -rtsopts=none -Wall -O2 -o '$@' $+\n\n./a.out: *.cpp\n\tg++ -D'MIVAEL_DEBUG' -Wall -Wextra -std=c++11 -pedantic -Werror $+\n\t#g++ -Wall -Wextra -std=c++98 -pedantic -Werror -O3 $+\n\n--}\n"}, {"source_code": "\n--\n-- Michael V. Antosha\n-- 2019\n-- Michael.Antosha@gmail.com\n-- m.antosha@samsung.com\n--\n-- Haskell practice.\n-- Competitive programming.\n--\n-- Codeforces Round #460 (Div. 2)\n--\n-- B. Perfect Number\n-- http://codeforces.com/contest/919/problem/B\n--\n\nmain :: IO ()\nmain = interact $ flip shows \"\\n\" . getByInd . const 9000000 . (read :: String -> Int)\n\ndata Gen = St { getNum :: Int }\n\ngetByInd :: Int -> Int\ngetByInd = gbi iniState\n where\n gbi st 0 = getNum st\n gbi st cnt = (gbi $! nextPN st) (cnt - 1)\n\n iniState = St (-1)\n\n nextPN st = St $! ((getNum st) + 1)\n"}, {"source_code": "import qualified Data.Set as S\n\nmain :: IO ()\nmain =\n do\n let l = [1,1,2,2,3,3]\n let s = S.fromList l\n putStrLn $ show s\n"}], "src_uid": "0a98a6a15e553ce11cb468d3330fc86a"} {"source_code": "import Control.Monad\nimport Data.List\n\nmain :: IO()\nmain = do\n t <- readLn\n replicateM_ t $ (>>= putStrLn) doQuery\n\ndoQuery :: IO(String)\ndoQuery = do\n [n, k, d] <- (map read . words <$> getLine) :: IO([Int])\n a <- (map read . words <$> getLine) :: IO([Int])\n b <- return [take d $ drop i a | i <- [0..n-d]]\n return $ show $ minimum $ map (length . nub) b\n", "positive_code": [{"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE Safe #-}\n{-# LANGUAGE TupleSections #-}\n{-# LANGUAGE ExplicitForAll #-}\n{-# LANGUAGE MultiWayIf #-}\n{-# LANGUAGE CPP #-}\n{-# LANGUAGE FlexibleContexts #-}\n{-# LANGUAGE NoMonomorphismRestriction #-}\n\nimport Data.Bits\nimport Data.List\nimport qualified Data.ByteString.Char8 as BS\nimport qualified Data.ByteString.Lazy.Char8 as BSL\nimport Data.IntMap.Strict (IntMap)\nimport qualified Data.IntMap.Strict as IM\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IS\nimport qualified Data.Array.IArray as A\nimport qualified Data.Array.MArray.Safe as A\n-- import qualified Data.Array.MArray as A\nimport Data.Array (Array)\nimport Data.Array.Unboxed (UArray)\nimport Data.Array.IArray (IArray)\nimport Data.Array.MArray.Safe (MArray)\nimport Data.Array.IO.Safe (IOArray, IOUArray)\nimport Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)\n{-\nimport qualified Data.Vector.Unboxed as VU\nimport qualified Data.Vector.Unboxed.Mutable as VUM\n-}\nimport Control.Monad\nimport Control.Monad.ST\nimport Control.Monad.ST.Lazy (strictToLazyST, lazyToStrictST)\nimport qualified Control.Monad.ST.Lazy as STL\nimport Control.Applicative\nimport Data.Maybe\nimport Data.Tuple\nimport Data.Ord\nimport Control.Monad.State.Strict\nimport Data.Int\nimport Data.Word\nimport Data.STRef\nimport Data.IORef\nimport Data.Function\nimport System.IO\nimport System.Exit\nimport Data.Char\n\nmain :: IO ()\nmain = do\n t <- readInt <$> getLine\n replicateM_ t $ do\n [n,k,d] <- map readInt . words <$> getLine\n as <- unfoldr (runStateT rIntS) <$> BS.getLine\n print $ query n d $ A.listArray (0,n-1) as\n\nquery :: Int -> Int -> UArray Int Int -> Int\nquery n d arr = (\\ (!store,!now,!minimal) -> minimal)\n $ foldl'\n (\\ (!storePrev,!prev,!minimal) !i ->\n let (Just !resRemv, !store1)\n = IM.updateLookupWithKey\n (\\_ v -> if v > 1 then Just $! (v-1) else Nothing)\n (arr A.! i) storePrev\n (resAdd, !storeNow)\n = IM.insertLookupWithKey\n (const (+)) (arr A.! (i+d)) 1 store1\n !now = prev - (if resRemv > 1 then 0 else 1)\n + (maybe 1 (const 0) resAdd)\n !newMin = minimal `min` now\n in (storeNow,now,newMin))\n (initialMap,initialSize,initialSize) [0..n-d-1]\n where\n initialMap = IM.fromListWith (+) $ [(arr A.! i,1::Int) | i <- [0..d-1]]\n initialSize = IM.size initialMap\n\n#define IL(f) {-# INLINE f #-}; f\n\nrInt :: StateT BSL.ByteString Maybe Int\nIL(rInt) = StateT $ BSL.readInt . BSL.dropWhile (<'!')\nrIntS :: StateT BS.ByteString Maybe Int\nIL(rIntS) = StateT $ BS.readInt . BS.dropWhile (<'!')\n\n-- unlessM, whenM :: (Monad m) => m Bool -> m () -> m ()\nIL(whenM) = (. flip when) . (>>=)\nIL(unlessM) = (. flip unless) . (>>=)\n\nIL(wrA) = A.writeArray\nIL(rdA) = A.readArray\nIL(mdA) = \\arr f !i -> do\n ai <- rdA arr i\n let fai = f ai \n wrA arr i fai\n return (ai,fai)\n{-# INLINE mdA' #-}\nmdA' = \\arr f !i -> do\n !ai <- rdA arr i\n let !fai = f ai\n wrA arr i fai\n return (ai,fai)\nIL(swapA) = \\arr !i !j -> do\n ai <- rdA arr i\n wrA arr i =<< rdA arr j\n wrA arr j ai\n\n#define D(f,r,d)\\\n IL(f) :: Integral a=>a->d; f=fromIntegral;\\\n IL(r) :: String->d; r=read\n#define C(f,r,g,h,d) D(f,r,d);\\\n g,h :: RealFrac a=>a->d; IL(g)=floor; IL(h)=ceiling\nC(_toInteger_,readInteger,floorInteger,ceilInteger,Integer)\nC(toInt,readInt,floorInt,ceilInt,Int)\nC(toI8,readI8,floorI8,ceilI8,Int8)\nC(toI16,readI16,floorI16,ceilI16,Int16)\nC(toI32,readI32,floorI32,ceilI32,Int32)\nC(toI64,readI64,floorI64,ceilI64,Int64)\nC(toWord,readWord,floorWord,ceilWord,Word)\nC(toW8,readW8,floorW8,ceilW8,Word8)\nC(toW16,readW16,floorW16,ceilW16,Word16)\nC(toW32,readW32,floorW32,ceilW32,Word32)\nC(toW64,readW64,floorW64,ceilW64,Word64)\nD(toDouble,readDouble,Double)\nD(toFloat,readFloat,Float)\n#undef D\n#undef C\n\n#define N(f,g,h,a,m)\\\n IL(f) :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> e -> m (a i e);\\\n f=A.newArray;\\\n IL(g) :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> m (a i e);\\\n g=A.newArray_;\\\n IL(h) :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> [e] -> m (a i e);\\\n h=A.newListArray\n#define C(a,m)\nN(newIOA,newIOA_,newIOAL,IOArray,IO)\nN(newSTA,newSTA_,newSTAL,STArray s,ST s)\n#undef C\n#define C(a,m) MArray (a) e (m), \nN(newIOUA,newIOUA_,newIOUAL,IOUArray,IO)\nN(newSTUA,newSTUA_,newSTUAL,STUArray s,ST s)\n#undef C\n#undef N\n\n#undef IL\n"}, {"source_code": "import Data.List\nimport Data.Maybe\nimport Control.Monad\nimport Control.Arrow\n\nunique = map head . group . sort\n\nmain = do\n t <- readLn\n replicateM_ t $ do\n [_, _, d] <- map read . words <$> getLine\n ary <- map read . words <$> getLine\n\n let a = map (head &&& length) . group $ ary\n let r = minimum $ map length $ mapMaybe (itms d) (tails a)\n\n print r\n\nitms :: Int -> [(Int, Int)] -> Maybe [Int]\nitms _ [] = Nothing\nitms req (h:hs)\n | req <= snd h = Just [fst h]\n | otherwise = (\\i -> unique $ fst h:i) <$> itms (req - snd h) hs\n"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE Safe #-}\n{-# LANGUAGE TupleSections #-}\n{-# LANGUAGE ExplicitForAll #-}\n{-# LANGUAGE MultiWayIf #-}\n{-# LANGUAGE CPP #-}\n{-# LANGUAGE FlexibleContexts #-}\n{-# LANGUAGE NoMonomorphismRestriction #-}\n\nimport Data.Bits\nimport Data.List\nimport qualified Data.ByteString.Char8 as BS\nimport qualified Data.ByteString.Lazy.Char8 as BSL\nimport Data.IntMap.Strict (IntMap)\nimport qualified Data.IntMap.Strict as IM\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IS\nimport qualified Data.Array.IArray as A\nimport qualified Data.Array.MArray.Safe as A\n-- import qualified Data.Array.MArray as A\nimport Data.Array (Array)\nimport Data.Array.Unboxed (UArray)\nimport Data.Array.IArray (IArray)\nimport Data.Array.MArray.Safe (MArray)\nimport Data.Array.IO.Safe (IOArray, IOUArray)\nimport Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)\n{-\nimport qualified Data.Vector.Unboxed as VU\nimport qualified Data.Vector.Unboxed.Mutable as VUM\n-}\nimport Control.Monad\nimport Control.Monad.ST\nimport Control.Monad.ST.Lazy (strictToLazyST, lazyToStrictST)\nimport qualified Control.Monad.ST.Lazy as STL\nimport Control.Applicative\nimport Data.Maybe\nimport Data.Tuple\nimport Data.Ord\nimport Control.Monad.State.Strict\nimport Data.Int\nimport Data.Word\nimport Data.STRef\nimport Data.IORef\nimport Data.Function\nimport System.IO\nimport System.Exit\nimport Data.Char\n\nmain :: IO ()\nmain = do\n t <- readInt <$> getLine\n replicateM_ t $ do\n [n,k,d] <- map readInt . words <$> getLine\n as <- unfoldr (runStateT rIntS) <$> BS.getLine\n print $ query n d $ A.listArray (0,n-1) as\n\nquery :: Int -> Int -> UArray Int Int -> Int\nquery n d arr = (\\ (!store,!now,!minimal) -> minimal)\n $ foldl'\n (\\ (!storePrev,!prev,!minimal) !i ->\n let (Just !resRemv, !store1)\n = IM.updateLookupWithKey\n (\\_ v -> if v > 1 then Just $! (v-1) else Nothing)\n (arr A.! i) storePrev\n (resAdd, !storeNow)\n = IM.insertLookupWithKey\n (const (+)) (arr A.! (i+d)) 1 store1\n !now = prev - (if resRemv > 1 then 0 else 1)\n + (maybe 1 (const 0) resAdd)\n !newMin = minimal `min` now\n in (storeNow,now,newMin))\n (initialMap,initialSize,initialSize) [0..n-d-1]\n where\n initialMap = IM.fromListWith (+) $ [(arr A.! i,1::Int) | i <- [0..d-1]]\n initialSize = IM.size initialMap\n\n#define IL(f) {-# INLINE f #-}; f\n\nrInt :: StateT BSL.ByteString Maybe Int\nIL(rInt) = StateT $ BSL.readInt . BSL.dropWhile (<'!')\nrIntS :: StateT BS.ByteString Maybe Int\nIL(rIntS) = StateT $ BS.readInt . BS.dropWhile (<'!')\n\n-- unlessM, whenM :: (Monad m) => m Bool -> m () -> m ()\nIL(whenM) = (. flip when) . (>>=)\nIL(unlessM) = (. flip unless) . (>>=)\n\nIL(wrA) = A.writeArray\nIL(rdA) = A.readArray\nIL(mdA) = \\arr f !i -> do\n ai <- rdA arr i\n let fai = f ai \n wrA arr i fai\n return (ai,fai)\n{-# INLINE mdA' #-}\nmdA' = \\arr f !i -> do\n !ai <- rdA arr i\n let !fai = f ai\n wrA arr i fai\n return (ai,fai)\nIL(swapA) = \\arr !i !j -> do\n ai <- rdA arr i\n wrA arr i =<< rdA arr j\n wrA arr j ai\n\n#define D(f,r,d)\\\n IL(f) :: Integral a=>a->d; f=fromIntegral;\\\n IL(r) :: String->d; r=read\n#define C(f,r,g,h,d) D(f,r,d);\\\n g,h :: RealFrac a=>a->d; IL(g)=floor; IL(h)=ceiling\nC(_toInteger_,readInteger,floorInteger,ceilInteger,Integer)\nC(toInt,readInt,floorInt,ceilInt,Int)\nC(toI8,readI8,floorI8,ceilI8,Int8)\nC(toI16,readI16,floorI16,ceilI16,Int16)\nC(toI32,readI32,floorI32,ceilI32,Int32)\nC(toI64,readI64,floorI64,ceilI64,Int64)\nC(toWord,readWord,floorWord,ceilWord,Word)\nC(toW8,readW8,floorW8,ceilW8,Word8)\nC(toW16,readW16,floorW16,ceilW16,Word16)\nC(toW32,readW32,floorW32,ceilW32,Word32)\nC(toW64,readW64,floorW64,ceilW64,Word64)\nD(toDouble,readDouble,Double)\nD(toFloat,readFloat,Float)\n#undef D\n#undef C\n\n#define N(f,g,h,a,m)\\\n IL(f) :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> e -> m (a i e);\\\n f=A.newArray;\\\n IL(g) :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> m (a i e);\\\n g=A.newArray_;\\\n IL(h) :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> [e] -> m (a i e);\\\n h=A.newListArray\n#define C(a,m)\nN(newIOA,newIOA_,newIOAL,IOArray,IO)\nN(newSTA,newSTA_,newSTAL,STArray s,ST s)\n#undef C\n#define C(a,m) MArray (a) e (m), \nN(newIOUA,newIOUA_,newIOUAL,IOUArray,IO)\nN(newSTUA,newSTUA_,newSTUAL,STUArray s,ST s)\n#undef C\n#undef N\n\n#undef IL\n"}], "negative_code": [], "src_uid": "56da4ec7cd849c4330d188d8c9bd6094"} {"source_code": "main :: IO ()\nmain = getLine >>= putStrLn . yesno . solve . map read . words\n\nsolve :: [Int] -> Bool\nsolve [a, b, s] = abs a + abs b <= s && even (s - abs a - abs b)\nsolve _ = undefined\n\nyesno :: Bool -> String\nyesno True = \"Yes\"\nyesno _ = \"No\"\n", "positive_code": [{"source_code": "import Data.Char\nimport Data.List\nimport Data.Int\nimport Data.Maybe\nimport Control.Monad\nimport qualified Data.Sequence as Seq\nimport Data.Foldable(toList)\nimport qualified Data.ByteString.Char8 as B\n\nreadInt :: IO Int\nreadInt = head `liftM` readIntList\n \nreadIntList :: IO [Int]\nreadIntList = do\n line <- B.getLine\n let res = map (fst . fromJust . B.readInt) $ B.words line\n return res\n\nreadString :: IO String\nreadString = do\n line <- B.getLine\n return $ B.unpack line\n\nmain = do\n [a, b, s] <- readIntList\n let dist = abs(a) + abs(b)\n let ans = if dist <= s && (s - dist) `mod` 2 == 0 then \"Yes\" else \"No\"\n putStrLn $ ans\n \n \n"}, {"source_code": "module Main where\n\nmain = do\n c <- getContents\n let (a:b:s:_) = map (read :: String -> Integer) $ words c\n putStrLn $ case solve a b s of\n True -> \"Yes\"\n False -> \"No\"\n\nsolve :: Integer -> Integer -> Integer -> Bool\nsolve a' b' s\n | s < a + b = False\n | (a + b - s) `mod` 2 == 0 = True\n | otherwise = False\n where a = abs a'\n b = abs b'\n"}, {"source_code": "main = interact $ f.map read.words.last.lines\nf [a,b,s] = let n = abs a + abs b \n in if s>=n && mod (s-n) 2 == 0 then \"Yes\" else \"No\"\n"}, {"source_code": "\nmain = do\n\td <-getLine\n\tlet [a,b,s]=map read $ words d\n\tputStrLn $ solve (abs a) (abs b) s\n\nsolve::Integer->Integer->Integer->String\nsolve a b s | s= abs a+ abs b) then \"Yes\" else \"No\"\n"}, {"source_code": "import Data.Functor\n\ngetInts :: IO [Int]\ngetInts = map read <$> words <$> getContents\n\nmain = getInts >>= putStrLn . (\\b -> if b then \"Yes\" else \"No\") . solve\n\nsolve :: [Int] -> Bool\nsolve (a:b:s:[])\n | abs a + abs b > s = False\n | mod (abs a + abs b - s) 2 == 0 = True\n | otherwise = False\n"}, {"source_code": "main = interact $ f . map (abs . read) . words . concat . lines\nf [a,b,s] | (a + b > s) || ((s - a - b)`mod`2 /= 0) = \"No\" | True = \"Yes\"\n"}, {"source_code": "import Data.List\nimport Data.Tree \nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Data.Bits\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed as UA\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint \nreadsolveprint::IO()\nreadsolveprint = (solve.concat =<< forM [1 ..1] ( \\i -> map (fst.fromJust.C.readInteger).C.words <$> C.getLine))\nsolve [x,y,z] = if z>=(abs x+ abs y) && (abs x+ abs y)`mod`2==z`mod`2 then putStrLn \"Yes\" else putStrLn \"No\""}, {"source_code": "module Main where\nimport Control.Applicative\nimport Control.Monad\nimport qualified Data.ByteString.Char8 as C\nimport Data.List\nimport Data.Maybe\n\ngetIntList :: IO [Int]\ngetIntList = map fst . mapMaybe C.readInt . C.words <$> C.getLine\n\nmain :: IO ()\nmain = do\n a:b:s:_ <- getIntList\n putStrLn $ if sol a b s then \"Yes\" else \"No\"\n\nsol :: Integral a => a -> a -> a -> Bool\nsol a b s = t >= 0 && even t \n where\n t = s - (abs a + abs b)\n"}, {"source_code": "solve :: Int -> Int -> Int -> String\nsolve n m s\n | (abs(n)+abs(m)) == s = \"Yes\"\n | (abs(n)+abs(m)) > s = \"No\"\n | abs(abs(n)+abs(m)-s) `mod` 2 == 0 = \"Yes\"\n\t| otherwise = \"No\"\n\nmain = do\n line <- getLine\n let xs = words line\n let [n,m,s] = map read xs\n --let a = if ((n+m) == s) then True else False\n --let b = if ((n+m) < s) then True else False\n --let c = if a || b then \"Yes\" else \"No\"\n let c = solve n m s\n putStrLn c\n\n"}, {"source_code": "solve :: Int -> Int -> Int -> String\nsolve n m s\n | (abs(n)+abs(m)) > s = \"No\"\n | abs(abs(n)+abs(m)-s) `mod` 2 == 0 = \"Yes\"\n\t| otherwise = \"No\"\n\nmain = do\n line <- getLine\n let xs = words line\n let [n,m,s] = map read xs\n --let a = if ((n+m) == s) then True else False\n --let b = if ((n+m) < s) then True else False\n --let c = if a || b then \"Yes\" else \"No\"\n let c = solve n m s\n putStrLn c\n\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.Char\n\n\nmain=do\n\n [a,b,s]<- map read <$> words <$> getLine ::IO [Integer]\n putStrLn $ if (s>=abs a+ abs b) && (even (s-a-b)) then \"YES\" else \"NO\"\n"}, {"source_code": "main = interact $ solve . map read . words\nsolve [a,b,s] | s < abs a + abs b || (s + a + b) `mod` 2 == 1 = \"No\"\nsolve _ = \"Yes\"\n"}, {"source_code": "import Data.List\nimport Control.Applicative\nimport System.IO\n\nmain = do\n [a, b, s] <- map read <$> words <$> getLine\n let a' = abs a\n b' = abs b\n let answer =\n if a' + b' > s || (a' + b' - s) `mod` 2 /= 0 then \"No\"\n else \"Yes\"\n putStrLn answer\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \n\n \n \n \nmain=do\t \n\t[a,b,s]<-map read. words<$> getLine::IO [Int]\n\tputStrLn $ if (s-(abs a)-(abs b))>=0 && even (s-(abs a)-(abs b)) then \"Yes\" else \"No\""}, {"source_code": "main = do\n [a, b, s] <- getLine >>= return. map (abs.read). words :: IO [Integer]\n putStrLn $ let k = s - a - b in if even k && k >= 0 then \"YES\" else \"NO\" \n"}, {"source_code": "import Control.Applicative\n\nmain = do\n [a, b, d] <- map read . words <$> getLine\n let dst = abs a + abs b\n if d >= dst && dst `rem` 2 == d `rem` 2\n then putStrLn \"YES\"\n else putStrLn \"NO\"\n"}], "negative_code": [{"source_code": "\nmain = do\n\td <-getLine\n\tlet [a,b,s]=map read $ words d\n\tputStrLn $ solve a b s\n\nsolve::Integer->Integer->Integer->String\nsolve a b s | s= a+b) then \"Yes\" else \"No\"\n"}, {"source_code": "main = interact $ f . map read . words . concat . lines\nf [a,b,s] | (a + b > s) || ((s - a - b)`mod`2 /= 0) = \"No\" | True = \"Yes\"\n"}, {"source_code": "import Data.List\nimport Data.Tree \nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Data.Bits\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed as UA\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint \nreadsolveprint::IO()\nreadsolveprint = (solve.concat =<< forM [1 ..1] ( \\i -> map (fst.fromJust.C.readInteger).C.words <$> C.getLine))\nsolve [x,y,z] = if z>=(x+y) && (x+y)`mod`2==z`mod`2 then putStrLn \"Yes\" else putStrLn \"No\""}, {"source_code": "module Main where\nimport Control.Applicative\nimport Control.Monad\nimport qualified Data.ByteString.Char8 as C\nimport Data.List\nimport Data.Maybe\n\ngetIntList :: IO [Int]\ngetIntList = map fst . mapMaybe C.readInt . C.words <$> C.getLine\n\nmain :: IO ()\nmain = do\n a:b:s:_ <- getIntList\n putStrLn $ if sol a b s then \"Yes\" else \"No\"\n\nsol :: Int -> Int -> Int -> Bool\nsol a b s = t >= 0 && even t \n where\n t = s - (a+b)\n"}, {"source_code": "solve :: Int -> Int -> Int -> String\nsolve n m s\n | (abs(n)+abs(m)) == s = \"Yes\"\n | (abs(n)+abs(m)) < s = \"No\"\n | abs(abs(n)+abs(m)-s) `mod` 2 == 0 = \"Yes\"\n\t| otherwise = \"No\"\n\nmain = do\n line <- getLine\n let xs = words line\n let [n,m,s] = map read xs\n --let a = if ((n+m) == s) then True else False\n --let b = if ((n+m) < s) then True else False\n --let c = if a || b then \"Yes\" else \"No\"\n let c = solve n m s\n putStrLn c\n\n"}, {"source_code": "main = do\n line <- getLine\n let xs = words line\n let [n,m,s] = map read xs\n let a = if ((n+m) == s) then True else False\n let b = if ((n+m) < s) then True else False\n let c = if a || b then \"Yes\" else \"No\"\n putStrLn $ show (c)\n\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.Char\n\n\nmain=do\n\n [a,b,s]<- map read <$> words <$> getLine ::IO [Integer]\n putStrLn $ if (s>=a+b) && (even (s-a-b)) then \"YES\" else \"NO\"\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.Char\n\n\nmain=do\n\n [a,b,s]<- map read <$> words <$> getLine ::IO [Integer]\n putStrLn $ if even (s-a-b) then \"YES\" else \"NO\"\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= putStrLn . yesno . solve . map read . words\n\nsolve :: [Int] -> Bool\nsolve [a, b, s] = a + b <= s && even (s - a - b)\nsolve _ = undefined\n\nyesno :: Bool -> String\nyesno True = \"Yes\"\nyesno _ = \"No\"\n"}, {"source_code": "import Data.List\nimport Control.Applicative\nimport System.IO\n\nmain = do\n [a, b, s] <- map read <$> words <$> getLine\n let answer =\n if a + b > s || (a + b - s) `mod` 2 /= 0 then \"No\"\n else \"Yes\"\n putStrLn answer\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \n\n \n \n \nmain=do\t \n\t[a,b,s]<-map read. words<$> getLine::IO [Int]\n\tputStrLn $ if (s-a-b)>=0 && even (s-a-b) then \"Yes\" else \"No\""}, {"source_code": "main = do\n [a, b, s] <- getLine >>= return. map read. words :: IO [Integer]\n putStrLn $ let k = a + b - s in if even k && k >= 0 then \"YES\" else \"NO\" \n"}, {"source_code": "main = do\n [a, b, s] <- getLine >>= return. map read. words :: IO [Integer]\n putStrLn $ let k = s - a - b in if even k && k >= 0 then \"YES\" else \"NO\" \n"}, {"source_code": "import Control.Applicative\n\nmain = do\n [a, b, d] <- map read . words <$> getLine\n if d >= a + b && (a+b) `rem` 2 == d `rem` 2\n then putStrLn \"YES\"\n else putStrLn \"NO\"\n"}, {"source_code": "import Data.Char\nimport Data.List\nimport Data.Int\nimport Data.Maybe\nimport Control.Monad\nimport qualified Data.Sequence as Seq\nimport Data.Foldable(toList)\nimport qualified Data.ByteString.Char8 as B\n\nreadInt :: IO Int\nreadInt = head `liftM` readIntList\n \nreadIntList :: IO [Int]\nreadIntList = do\n line <- B.getLine\n let res = map (fst . fromJust . B.readInt) $ B.words line\n return res\n\nreadString :: IO String\nreadString = do\n line <- B.getLine\n return $ B.unpack line\n \ngetSumPerPos :: Int -> [Int] -> Seq.Seq Int\ngetSumPerPos cnt = \n foldr step init\n where\n init = Seq.fromList $ replicate cnt 0\n step key seq = \n let oldVal = Seq.index seq (key - 1)\n in\n Seq.update (key - 1) (oldVal + 1) seq\n\nmain = do\n [s, a, b] <- readIntList\n let dist = abs(a) + abs(b)\n let ans = if dist >= s && (dist - s) `mod` 2 == 0 then \"Yes\" else \"No\"\n putStrLn $ ans\n \n \n"}, {"source_code": "import Data.Char\nimport Data.List\nimport Data.Int\nimport Data.Maybe\nimport Control.Monad\nimport qualified Data.Sequence as Seq\nimport Data.Foldable(toList)\nimport qualified Data.ByteString.Char8 as B\n\nreadInt :: IO Int\nreadInt = head `liftM` readIntList\n \nreadIntList :: IO [Int]\nreadIntList = do\n line <- B.getLine\n let res = map (fst . fromJust . B.readInt) $ B.words line\n return res\n\nreadString :: IO String\nreadString = do\n line <- B.getLine\n return $ B.unpack line\n \ngetSumPerPos :: Int -> [Int] -> Seq.Seq Int\ngetSumPerPos cnt = \n foldr step init\n where\n init = Seq.fromList $ replicate cnt 0\n step key seq = \n let oldVal = Seq.index seq (key - 1)\n in\n Seq.update (key - 1) (oldVal + 1) seq\n\nmain = do\n [s, a, b] <- readIntList\n let dist = abs(a) + abs(b)\n let ans = if dist <= s && (dist - s) `mod` 2 == 0 then \"Yes\" else \"No\"\n putStrLn $ ans\n \n \n"}, {"source_code": "module Main where\n\nmain = do\n c <- getContents\n let (a:b:s:_) = map (read :: String -> Integer) $ words c\n putStrLn $ case solve a b s of\n True -> \"Yes\"\n False -> \"No\"\n\nsolve :: Integer -> Integer -> Integer -> Bool\nsolve a b s\n | s < a + b = False\n | (a + b - s) `mod` 2 == 0 = True\n | otherwise = False\n"}], "src_uid": "9a955ce0775018ff4e5825700c13ed36"} {"source_code": "import Data.List\nimport Control.Applicative\n\n--Forgive me for such an ugly haskell code\n\ngetInt :: IO Int\ngetInt = readLn\n\ngetInts :: Int -> IO [Int]\ngetInts 0 = return []\ngetInts n = do\n x <- getInt\n fmap (x:) $ getInts (n-1)\n\ncheck :: [Int] -> Int -> [String]\ncheck xs n | n == 0 = [\"YES\", \"1\", \"1\", \"3\", \"3\"]\n | n == 1 = {-d3 = k+(d1+d2)/2 = k+(d1+d2+d3)/4\n d1+d2 = d3\n d3 = 2k\n -}\n let k = head xs\n d3 = 2*k\n d2 = d3\n d1 = 0\n in [\"YES\", show $ k+d1, show $ k+d2, show $ k+d3]\n | n == 4 = let xs' = sort xs\n mean = if mod (sum xs') 4 /= 0 then Nothing else Just $ div (sum xs') 4\n median = if mod (xs'!!1 + xs'!!2) 2 /= 0 then Nothing else Just $ div (xs'!!1 + xs'!!2) 2\n range = xs'!!3 - xs'!!1\n cmp1 = (==) <$> mean <*> median\n cmp2 = fmap (== range) mean\n in case (==) <$> cmp1 <*> cmp2 of\n Nothing -> [\"NO\"]\n Just _ -> [\"YES\"]\n | n == 3 = let xs' = sort xs\n in if 3*(head xs') == last xs'\n then let d3 = 2*(head xs')\n d1 = (xs'!!1 - xs'!!0)\n d2 = d3-d1\n in [\"YES\", show (head xs' + d2)]\n else if (xs'!!1 + xs'!!2 - 2*xs'!!0) == 2*(head xs')\n then [\"YES\", show $ 3*(head xs')]\n else if mod (last xs') 3 == 0 && check ((div (last xs') 3):xs') 4 /= [\"NO\"]\n then [\"YES\", show $ div (last xs') 3]\n else [\"NO\"]\n | n == 2 = let xs' = sort xs\n k1 = head xs'\n k2 = last xs'\n in if k2-k1 > 2*k1\n then [\"NO\"]\n else let d1 = k2-k1\n d3 = 2*k1\n d2 = d3-d1\n in [\"YES\", show $ k1+d2, show $ k1+d3]\n | otherwise = [\"Liar.\"]\n\nsolve :: Int -> IO[String]\nsolve n = do\n xs <- getInts n\n return $ check xs n\n\nmain = do\n res <- readLn >>= solve\n mapM_ putStrLn res", "positive_code": [{"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Maybe\nimport Data.List\n\ncheck l@[_, _, _, _] = m1 == m2 && m2 == m3\n where [a, b, c, d] = sort l\n m1 = a + b + c + d\n m2 = (b + c) * 2\n m3 = (d - a) * 4\n\nsolve :: [Integer] -> Maybe [Integer]\nsolve l@[a, b, c, d] = if check l then Just l else Nothing\nsolve l@[_, _, _] =\n if s1\n then Just (l ++ [d1])\n else if s2\n then Just (l ++ [d2])\n else if s3\n then Just (l ++ [d3])\n else Nothing\n where [a, b, c] = sort l\n d1 = b + c - a\n s1 = d1 >= 1 && d1 <= 1500 && sum l + d1 == (d1 - a) * 4\n d2 = a - b + c\n s2 = d2 >= 1 && d2 <= 1500 && sum l + d2 == (c - a) * 4\n d3 = a + b - c\n s3 = d3 >= 1 && d3 <= 1500 && sum l + d3 == (c - d3) * 4\nsolve x = foldl1 (<|>) $ solve <$> ((x++) <$> [[i] | i <- [1..1500]])\n where c = if null x then 1 else last x\n\n-- solve :: [Integer] -> Bool\n-- solve l@[a, b, c, d] = check l\n-- solve x = foldl1 (||) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\nmain = do\n n <- read <$> getLine\n ls <- replicateM n $ read <$> getLine\n case solve ls of\n Nothing -> putStrLn \"NO\"\n Just rl -> do putStrLn \"YES\"\n forM_ (drop n rl) print\n"}], "negative_code": [{"source_code": "import Data.List\nimport Control.Applicative\n\ngetInt :: IO Int\ngetInt = readLn\n\ngetInts :: Int -> IO [Int]\ngetInts 0 = return []\ngetInts n = do\n x <- getInt\n fmap (x:) $ getInts (n-1)\n\ncheck :: [Int] -> Int -> [String]\ncheck xs n | n == 0 = [\"YES\", \"1\", \"1\", \"3\", \"3\"]\n | n == 1 = {-d3 = k+(d1+d2)/2 = k+(d1+d2+d3)/4\n d1+d2 = d3\n d3 = 2k\n -}\n let k = head xs\n d3 = 2*k\n d2 = d3\n d1 = 0\n in [\"YES\", show $ k+d1, show $ k+d2, show $ k+d3]\n | n == 4 = let xs' = sort xs\n mean = if mod (sum xs') 4 /= 0 then Nothing else Just $ div (sum xs') 4\n median = if mod (xs'!!1 + xs'!!2) 2 /= 0 then Nothing else Just $ div (xs'!!1 + xs'!!2) 2\n range = xs'!!3 - xs'!!1\n cmp1 = (==) <$> mean <*> median\n cmp2 = fmap (== range) mean\n in case (==) <$> cmp1 <*> cmp2 of\n Nothing -> [\"NO\"]\n Just _ -> [\"YES\"]\n | n == 3 = let xs' = sort xs\n in if mod (sum xs') 3 /= 0\n then [\"No\"]\n else let mean = div (sum xs') 3\n xs'' = sort (mean:xs')\n median = if mod (xs''!!1 + xs''!!2) 2 /= 0 then Nothing else Just $ div (xs''!!1 + xs''!!2) 2\n range = xs''!!3 - xs''!!1\n in if (mean == range) && (fmap (==mean) median) == Just True\n then [\"YES\", show (4*mean - sum xs')]\n else [\"NO\"]\n | n == 2 = let xs' = sort xs\n k1 = head xs'\n k2 = last xs'\n in if k2-k1 > 2*k1\n then [\"NO\"]\n else let d1 = k2-k1\n d3 = 2*k1\n d2 = d3-d1\n in [\"YES\", show $ k1+d2, show $ k1+d3]\n | otherwise = [\"Liar.\"]\n\nsolve :: Int -> IO[String]\nsolve n = do\n xs <- getInts n\n return $ check xs n\n\nmain = do\n res <- readLn >>= solve\n mapM_ putStrLn res"}, {"source_code": "import Data.List\n\ngetInt :: IO Int\ngetInt = readLn\n\ngetInts :: Int -> IO [Int]\ngetInts 0 = return []\ngetInts n = do\n x <- getInt\n fmap (x:) $ getInts (n-1)\n\ncheck :: [Int] -> Int -> [String]\ncheck xs n | n == 0 = [\"YES\", \"1\", \"1\", \"3\", \"3\"]\n | n == 1 = {-d3 = k+(d1+d2)/2 = k+(d1+d2+d3)/4\n d1+d2 = d3\n d3 = 2k\n -}\n let k = head xs\n d3 = 2*k\n d2 = d3\n d1 = 0\n in [\"YES\", show $ k+d1, show $ k+d2, show $ k+d3]\n | n == 4 = {-let xs' = sort xs\n mean = if mod (sum xs') 4 /= 0 then Nothing else Just $ div (sum xs') 4\n median = if mod (xs!!1 + xs!!2) 2 /= 0 then Nothing else Just $ div (xs!!1 + xs!!2) 2\n range = xs!!3 - xs!!1\n cmp1 = (==) <$> mean <*> median\n cmp2 = fmap (== range) mean\n in case (==) <$> cmp1 <*> cmp2 of\n Nothing -> [\"NO\"]\n Just _ -> [\"YES\"]-}\n [\"No\"] --WTH\n | n == 3 = let xs' = sort xs\n in if mod (sum xs') 3 /= 0\n then [\"No\"]\n else let mean = div (sum xs') 3\n xs'' = sort (mean:xs')\n median = if mod (xs''!!1 + xs''!!2) 2 /= 0 then Nothing else Just $ div (xs''!!1 + xs''!!2) 2\n range = xs''!!3 - xs''!!1\n in if (mean == range) && (fmap (==mean) median) == Just True\n then [\"YES\", show (4*mean - sum xs')]\n else [\"NO\"]\n | n == 2 = let k1 = head xs\n k2 = last xs\n in if k2-k1 > 2*k1\n then [\"NO\"]\n else let d1 = k2-k1\n d3 = 2*k1\n d2 = d3-d1\n in [\"YES\", show $ k1+d2, show $ k1+d3]\n | otherwise = [\"Liar.\"]\n\nsolve :: Int -> IO[String]\nsolve n = do\n xs <- getInts n\n return $ check xs n\n\nmain = do\n res <- readLn >>= solve\n mapM_ putStrLn res"}, {"source_code": "import Data.List\nimport Control.Applicative\n\n--Forgive me for such an ugly haskell code\n\ngetInt :: IO Int\ngetInt = readLn\n\ngetInts :: Int -> IO [Int]\ngetInts 0 = return []\ngetInts n = do\n x <- getInt\n fmap (x:) $ getInts (n-1)\n\ncheck :: [Int] -> Int -> [String]\ncheck xs n | n == 0 = [\"YES\", \"1\", \"1\", \"3\", \"3\"]\n | n == 1 = {-d3 = k+(d1+d2)/2 = k+(d1+d2+d3)/4\n d1+d2 = d3\n d3 = 2k\n -}\n let k = head xs\n d3 = 2*k\n d2 = d3\n d1 = 0\n in [\"YES\", show $ k+d1, show $ k+d2, show $ k+d3]\n | n == 4 = let xs' = sort xs\n mean = if mod (sum xs') 4 /= 0 then Nothing else Just $ div (sum xs') 4\n median = if mod (xs'!!1 + xs'!!2) 2 /= 0 then Nothing else Just $ div (xs'!!1 + xs'!!2) 2\n range = xs'!!3 - xs'!!1\n cmp1 = (==) <$> mean <*> median\n cmp2 = fmap (== range) mean\n in case (==) <$> cmp1 <*> cmp2 of\n Nothing -> [\"NO\"]\n Just _ -> [\"YES\"]\n | n == 3 = let xs' = sort xs\n in if 3*(head xs') == last xs'\n then let d3 = 2*(head xs')\n d1 = (xs'!!1 - xs'!!0)\n d2 = d3-d1\n in [\"YES\", show (head xs' + d2)]\n else if (xs'!!1 + xs'!!2 - 2*xs'!!0) == 2*(head xs')\n then [\"YES\", show $ 3*(head xs')]\n else if mod (last xs') 3 == 0\n then [\"YES\", show $ div (last xs') 3]\n else [\"NO\"]\n | n == 2 = let xs' = sort xs\n k1 = head xs'\n k2 = last xs'\n in if k2-k1 > 2*k1\n then [\"NO\"]\n else let d1 = k2-k1\n d3 = 2*k1\n d2 = d3-d1\n in [\"YES\", show $ k1+d2, show $ k1+d3]\n | otherwise = [\"Liar.\"]\n\nsolve :: Int -> IO[String]\nsolve n = do\n xs <- getInts n\n return $ check xs n\n\nmain = do\n res <- readLn >>= solve\n mapM_ putStrLn res"}, {"source_code": "import Data.List\nimport Control.Applicative\n\ngetInt :: IO Int\ngetInt = readLn\n\ngetInts :: Int -> IO [Int]\ngetInts 0 = return []\ngetInts n = do\n x <- getInt\n fmap (x:) $ getInts (n-1)\n\ncheck :: [Int] -> Int -> [String]\ncheck xs n | n == 0 = [\"YES\", \"1\", \"1\", \"3\", \"3\"]\n | n == 1 = {-d3 = k+(d1+d2)/2 = k+(d1+d2+d3)/4\n d1+d2 = d3\n d3 = 2k\n -}\n let k = head xs\n d3 = 2*k\n d2 = d3\n d1 = 0\n in [\"YES\", show $ k+d1, show $ k+d2, show $ k+d3]\n | n == 4 = let xs' = sort xs\n mean = if mod (sum xs') 4 /= 0 then Nothing else Just $ div (sum xs') 4\n median = if mod (xs'!!1 + xs'!!2) 2 /= 0 then Nothing else Just $ div (xs'!!1 + xs'!!2) 2\n range = xs'!!3 - xs'!!1\n cmp1 = (==) <$> mean <*> median\n cmp2 = fmap (== range) mean\n in case (==) <$> cmp1 <*> cmp2 of\n Nothing -> [\"NO\"]\n Just _ -> [\"YES\"]\n | n == 3 = let xs' = sort xs\n in if mod (sum xs') 3 /= 0\n then [\"No\"]\n else let mean = div (sum xs') 3\n xs'' = sort (mean:xs')\n median = if mod (xs''!!1 + xs''!!2) 2 /= 0 then Nothing else Just $ div (xs''!!1 + xs''!!2) 2\n range = xs''!!3 - xs''!!1\n in if (mean == range) && (fmap (==mean) median) == Just True\n then [\"YES\", show (4*mean - sum xs')]\n else [\"NO\"]\n | n == 2 = let k1 = head xs\n k2 = last xs\n in if k2-k1 > 2*k1\n then [\"NO\"]\n else let d1 = k2-k1\n d3 = 2*k1\n d2 = d3-d1\n in [\"YES\", show $ k1+d2, show $ k1+d3]\n | otherwise = [\"Liar.\"]\n\nsolve :: Int -> IO[String]\nsolve n = do\n xs <- getInts n\n return $ check xs n\n\nmain = do\n res <- readLn >>= solve\n mapM_ putStrLn res"}, {"source_code": "import Data.List\nimport Control.Applicative\n\ngetInt :: IO Int\ngetInt = readLn\n\ngetInts :: Int -> IO [Int]\ngetInts 0 = return []\ngetInts n = do\n x <- getInt\n fmap (x:) $ getInts (n-1)\n\ncheck :: [Int] -> Int -> [String]\ncheck xs n | n == 0 = [\"YES\", \"1\", \"1\", \"3\", \"3\"]\n | n == 1 = {-d3 = k+(d1+d2)/2 = k+(d1+d2+d3)/4\n d1+d2 = d3\n d3 = 2k\n -}\n let k = head xs\n d3 = 2*k\n d2 = d3\n d1 = 0\n in [\"YES\", show $ k+d1, show $ k+d2, show $ k+d3]\n | n == 4 = let xs' = sort xs\n mean = if mod (sum xs') 4 /= 0 then Nothing else Just $ div (sum xs') 4\n median = if mod (xs'!!1 + xs'!!2) 2 /= 0 then Nothing else Just $ div (xs'!!1 + xs'!!2) 2\n range = xs'!!3 - xs'!!1\n cmp1 = (==) <$> mean <*> median\n cmp2 = fmap (== range) mean\n in case (==) <$> cmp1 <*> cmp2 of\n Nothing -> [\"NO\"]\n Just _ -> [\"YES\"]\n | n == 3 = let xs' = sort xs\n in if mod (sum xs') 3 /= 0\n then [\"NO\"]\n else let mean = div (sum xs') 3\n xs'' = sort (mean:xs')\n median = if mod (xs''!!1 + xs''!!2) 2 /= 0 then Nothing else Just $ div (xs''!!1 + xs''!!2) 2\n range = xs''!!3 - xs''!!1\n in if (mean == range) && (fmap (==mean) median) == Just True\n then [\"YES\", show (4*mean - sum xs')]\n else [\"NO\"]\n | n == 2 = let xs' = sort xs\n k1 = head xs'\n k2 = last xs'\n in if k2-k1 > 2*k1\n then [\"NO\"]\n else let d1 = k2-k1\n d3 = 2*k1\n d2 = d3-d1\n in [\"YES\", show $ k1+d2, show $ k1+d3]\n | otherwise = [\"Liar.\"]\n\nsolve :: Int -> IO[String]\nsolve n = do\n xs <- getInts n\n return $ check xs n\n\nmain = do\n res <- readLn >>= solve\n mapM_ putStrLn res"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Maybe\nimport Data.List\n\ncheck l@[_, _, _, _] = m1 == m2 && m2 == m3\n where [a, b, c, d] = sort l\n m1 = a + b + c + d\n m2 = (b + c) * 2\n m3 = (d - a) * 4\n\nsolve :: [Integer] -> Maybe [Integer]\nsolve l@[a, b, c, d] = if check l then Just l else Nothing\nsolve l@[_, _, _] = if d >= 1 && d <= 500 && s then Just (l ++ [d]) else Nothing\n where [a, b, c] = sort l\n d = b + c - a\n s = sum l + d == (d - a) * 4\nsolve x = foldl1 (<|>) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n where c = if null x then 1 else last x\n\n-- solve :: [Integer] -> Bool\n-- solve l@[a, b, c, d] = check l\n-- solve x = foldl1 (||) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\nmain = do\n n <- read <$> getLine\n ls <- replicateM n $ read <$> getLine\n case solve ls of\n Nothing -> putStrLn \"NO\"\n Just rl -> do putStrLn \"YES\"\n forM_ (drop n rl) print\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Maybe\nimport Data.List\n\ncheck l@[_, _, _, _] = m1 == m2 && m2 == m3\n where [a, b, c, d] = sort l\n m1 = a + b + c + d\n m2 = (b + c) * 2\n m3 = (d - a) * 4\n\nsolve :: [Integer] -> Maybe [Integer]\nsolve l@[a, b, c, d] = if check l then Just l else Nothing\nsolve x = foldl1 (<|>) $ solve <$> ((x++) <$> [[i] | i <- [c..500]])\n where c = if null x then 1 else last x\n\n-- solve :: [Integer] -> Bool\n-- solve l@[a, b, c, d] = check l\n-- solve x = foldl1 (||) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\nmain = do\n n <- read <$> getLine\n ls <- replicateM n $ read <$> getLine\n case solve ls of\n Nothing -> putStrLn \"NO\"\n Just rl -> do putStrLn \"YES\"\n forM_ (drop n rl) print\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Maybe\n\ncheck [a, b, c, d] = m1 == m2 && m2 == m3\n where m1 = a + b + c + d\n m2 = (b + c) * 2\n m3 = (d - a) * 4\n\n\nsolve :: [Integer] -> Maybe [Integer]\nsolve l@[a, b, c, d] = if check l then Just l else Nothing\nsolve x = foldl1 (<|>) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\n-- solve :: [Integer] -> Bool\n-- solve l@[a, b, c, d] = check l\n-- solve x = foldl1 (||) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\nmain = do\n n <- read <$> getLine\n ls <- replicateM n $ read <$> getLine\n case solve ls of\n Nothing -> putStrLn \"NO\"\n Just rl -> do putStrLn \"YES\"\n forM_ (drop n rl) print\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Maybe\nimport Data.List\n\ncheck l@[_, _, _, _] = m1 == m2 && m2 == m3\n where [a, b, c, d] = sort l\n m1 = a + b + c + d\n m2 = (b + c) * 2\n m3 = (d - a) * 4\n\nsolve :: [Integer] -> Maybe [Integer]\nsolve l@[a, b, c, d] = if check l then Just l else Nothing\nsolve l@[_, _, _] = if d >= c && d <= 500 && s then Just (l ++ [d]) else Nothing\n where [a, b, c] = sort l\n d = b + c - a\n s = sum l + d == (d - a) * 4\nsolve x = foldl1 (<|>) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n where c = if null x then 1 else last x\n\n-- solve :: [Integer] -> Bool\n-- solve l@[a, b, c, d] = check l\n-- solve x = foldl1 (||) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\nmain = do\n n <- read <$> getLine\n ls <- replicateM n $ read <$> getLine\n case solve ls of\n Nothing -> putStrLn \"NO\"\n Just rl -> do putStrLn \"YES\"\n forM_ (drop n rl) print\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Maybe\nimport Data.List\n\ncheck l@[_, _, _, _] = m1 == m2 && m2 == m3\n where [a, b, c, d] = sort l\n m1 = a + b + c + d\n m2 = (b + c) * 2\n m3 = (d - a) * 4\n\nsolve :: [Integer] -> Maybe [Integer]\nsolve l@[a, b, c, d] = if check l then Just l else Nothing\nsolve l@[_, _, _] =\n if s1\n then Just (l ++ [d1])\n else if s2\n then Just (l ++ [d2])\n else if s3\n then Just (l ++ [d3])\n else Nothing\n where [a, b, c] = sort l\n d1 = b + c - a\n s1 = d1 >= 1 && d1 <= 500 && sum l + d1 == (d1 - a) * 4\n d2 = a - b + c\n s2 = d2 >= 1 && d2 <= 500 && sum l + d2 == (c - a) * 4\n d3 = a + b - c\n s3 = d3 >= 1 && d3 <= 500 && sum l + d3 == (c - d3) * 4\nsolve x = foldl1 (<|>) $ solve <$> ((x++) <$> [[i] | i <- [1..1500]])\n where c = if null x then 1 else last x\n\n-- solve :: [Integer] -> Bool\n-- solve l@[a, b, c, d] = check l\n-- solve x = foldl1 (||) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\nmain = do\n n <- read <$> getLine\n ls <- replicateM n $ read <$> getLine\n case solve ls of\n Nothing -> putStrLn \"NO\"\n Just rl -> do putStrLn \"YES\"\n forM_ (drop n rl) print\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Maybe\n\ncheck [a, b, c, d] = m1 == m2 && m2 == m3\n where m1 = a + b + c + d\n m2 = (b + c) * 2\n m3 = (d - a) * 4\n\n\n-- solve :: [Integer] -> Maybe [Integer]\n-- solve l@[a, b, c, d] = if check l then Just l else Nothing\n-- solve x = foldl1 (<|>) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\nsolve :: [Integer] -> Bool\nsolve l@[a, b, c, d] = check l\nsolve x = foldl1 (||) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\nmain = do\n n <- read <$> getLine\n ls <- replicateM n $ read <$> getLine\n print $ solve ls\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Maybe\nimport Data.List\n\ncheck l@[_, _, _, _] = m1 == m2 && m2 == m3\n where [a, b, c, d] = sort l\n m1 = a + b + c + d\n m2 = (b + c) * 2\n m3 = (d - a) * 4\n\nsolve :: [Integer] -> Maybe [Integer]\nsolve l@[a, b, c, d] = if check l then Just l else Nothing\nsolve x = foldl1 (<|>) $ solve <$> ((x++) <$> [[i] | i <- [c..500]])\n where c = if null x then 1 else last x\n\n-- solve :: [Integer] -> Bool\n-- solve l@[a, b, c, d] = check l\n-- solve x = foldl1 (||) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\nmain = do\n n <- read <$> getLine\n ls <- replicateM n $ read <$> getLine\n case solve ls of\n Nothing -> putStrLn \"NO\"\n Just rl -> do putStrLn \"YES\"\n forM_ (drop 0 rl) print\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Maybe\nimport Data.List\n\ncheck l@[_, _, _, _] = m1 == m2 && m2 == m3\n where [a, b, c, d] = sort l\n m1 = a + b + c + d\n m2 = (b + c) * 2\n m3 = (d - a) * 4\n\nsolve :: [Integer] -> Maybe [Integer]\nsolve l@[a, b, c, d] = if check l then Just l else Nothing\nsolve l@[_, _, _] =\n if s1\n then Just (l ++ [d1])\n else if s2\n then Just (l ++ [d2])\n else if s3\n then Just (l ++ [d3])\n else Nothing\n where [a, b, c] = sort l\n d1 = b + c - a\n s1 = d1 >= 1 && d1 <= 500 && sum l + d1 == (d1 - a) * 4\n d2 = a - b + c\n s2 = d2 >= 1 && d2 <= 500 && sum l + d2 == (c - a) * 4\n d3 = a + b - c\n s3 = d3 >= 1 && d3 <= 500 && sum l + d3 == (c - d3) * 4\nsolve x = foldl1 (<|>) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n where c = if null x then 1 else last x\n\n-- solve :: [Integer] -> Bool\n-- solve l@[a, b, c, d] = check l\n-- solve x = foldl1 (||) $ solve <$> ((x++) <$> [[i] | i <- [1..500]])\n\nmain = do\n n <- read <$> getLine\n ls <- replicateM n $ read <$> getLine\n case solve ls of\n Nothing -> putStrLn \"NO\"\n Just rl -> do putStrLn \"YES\"\n forM_ (drop n rl) print\n"}], "src_uid": "230e613abf0f6a768829cbc1f1a09219"} {"source_code": "main = getLine >>= print . solve . map read . words\n\nsolve(l:r:a:_) = maximum [2 * min (l + x) (r + a - x) | x <- [0..a]]\n", "positive_code": [{"source_code": "import Control.Monad\n\nteamsize 0 0 a = a-(mod a 2)\nteamsize l r 0 = 2 * min l r\nteamsize 0 r a = let m = min r a in teamsize 0 (r-m) (a-m) + 2*m\nteamsize l r a | l<=r = teamsize 0 (r-l) a + 2*l\n | True = teamsize r l a\n\nmain = do\n [l, r, a] <- fmap (map read . words) getContents\n putStrLn . show $ teamsize l r a\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\n\n\nmain = do\n\t\t[a,b,c]<-map read <$> words <$> getLine ::IO [Int]\n\t\tlet s = 2* (min a b)\n\t\tlet s1 = (min (abs (a-b)) c) \n\t\tlet s2 = 2* (div (c-s1) 2) \n\t\tprint $ s+s1+s1+s2\n\n \n\t\t\n\n"}, {"source_code": "main = getLine >>= print . solve . map read . words\n\nsolve [l,r,a]\n | a + min l r >= max l r = ((l + r + a) `div` 2) * 2\n | otherwise = (min l r + a) * 2\n"}, {"source_code": "import Data.List\n\nmain = do\n e<-getLine\n let (l:r:a:[])=map read (words e)::[Int]\n (c,t1,a1)=if l=0 then (a1-t1) `div` 2 else 0)"}], "negative_code": [{"source_code": "import Control.Monad\n\nteamsize 0 0 a = a-(mod a 2)\nteamsize l r 0 = 0\nteamsize 0 r a = let m = min r a in teamsize 0 (r-m) (a-m) + 2*m\nteamsize l r a | l<=r = teamsize 0 (r-l) a + 2*l\n | True = teamsize r l a\n\nmain = do\n [l, r, a] <- fmap (map read . words) getContents\n putStrLn . show $ teamsize l r a\n"}], "src_uid": "e8148140e61baffd0878376ac5f3857c"} {"source_code": "{-# OPTIONS_GHC -O3 #-}\n{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}\n\nimport qualified Data.ByteString as B (getLine)\nimport qualified Data.ByteString.Char8 as C (readInt, words, unpack, reverse, dropWhile)\nimport qualified Data.Maybe as M (fromJust)\nimport Data.Char as C (isSpace)\n\nreadInt = fst . M.fromJust . C.readInt\nrstrip = C.reverse . C.dropWhile C.isSpace . C.reverse\n\nmain = do\n (map readInt . C.words -> [n]) <- B.getLine\n let x = n `div` 10 * 10\n putStrLn $ show $ if n `mod` 10 > 5 then x + 10 else x\n", "positive_code": [{"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\n\n\nmain = do\n\t\tn<-read <$> getLine ::IO Int\n\t\tlet s = div n 10\n\t\tlet m = mod n 10\n\t\tprint $ (*10) $ s + if m>5 then 1 else 0\n\n"}, {"source_code": "process :: Int -> Int\nprocess n = 10 * (round ((fromIntegral n) / 10))\n\nreadInt :: String -> Int\nreadInt = read\n\nmain :: IO ()\nmain = do\n n <- fmap readInt getLine\n print $ process n"}, {"source_code": "groupOn :: Int -> [a] -> [[a]]\ngroupOn _ [] = []\ngroupOn n xs = let (sts, nds) = splitAt n xs in sts : groupOn n nds\n-------------------------------------------------------------------------------\n\nmain = interact $ unlines . sol . lines\n\nsol [x] = let\n x' = read x :: Double\n x'' = round(x'/10) * 10\n in [show $ x'']\n"}, {"source_code": "main = getLine >>= print . (\\n -> let (q, r) = n `quotRem` 10 in (q + fromEnum (r > 5)) * 10) . read"}, {"source_code": "-- Haskell Template\nsolve :: Int -> Int\nsolve n = 10 * div (n + 5) 10\n\nmain :: IO ()\nmain = do\n x <- getLine\n let s = solve (read x)\n putStrLn (show s)\n"}, {"source_code": "main = getLine >>= print . (\\n -> round (n / 10) * 10) . read"}, {"source_code": "main = getLine >>= print . (*10) . round . (/10) . read\n"}, {"source_code": "main = getLine >>= print . (\\n -> round (n / 10) * 10) . read\n"}, {"source_code": "import Data.List\nimport qualified Data.Map as Map\n\nmain = do\n a<-getLine\n let e=read a::Int\n print $ ((e+5) `div` 10) *10"}, {"source_code": "main = interact $ show . solve . read\nsolve n = (n + 5) `div` 10 * 10\n"}, {"source_code": "solve :: Int -> Int\nsolve n = let\n lastDigit = n `rem` 10\n in\n if lastDigit <= 5 then\n n - lastDigit\n else\n n - lastDigit + 10\n\nmain = do\n num <- read <$> getLine\n print $ solve num\n"}, {"source_code": "\ngetInt :: IO Int\ngetInt = read `fmap` getLine\n\nsolve :: Int -> Int\nsolve k\n | k `mod` 10 == 0 = k\n | k `mod` 10 <= 5 = k - (k `mod` 10)\n | otherwise = k + 10 - (k `mod` 10)\n\nmain :: IO ()\nmain = do\n n <- getInt\n print (solve n)"}], "negative_code": [{"source_code": "main = getLine >>= print . (\\n -> n - n `rem` 10) . read"}, {"source_code": "main = getLine >>= print . (\\n -> (n `div` 10) * 10) . read\n"}], "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9"} {"source_code": "calc::Int->Int->Int\ncalc = go 0 where\n go acc 1 y | y < 1 = acc + 2\n go acc 2 y | y < 2 = acc + 4\n go acc x 1 | x < 2 = acc + 3\n go acc x 2 | x < 3 = acc + 6\n go acc 3 y | y < 2 = acc + 6\n go acc x y = (uncurry .) go (acc + 6) $ if x * 2 > y * 3 then (x - 3,y - 1) else (x - 2 , y - 2)\n\nmain:: IO ()\nmain = fmap (map read . words) getLine >>= \\[x,y] -> print $ calc x y\n", "positive_code": [{"source_code": "module Main where\n\nimport Control.Monad\n\nsolve :: Int -> Int -> Int\nsolve n m | check 0 = 0\n | otherwise = bsearch 0 (6 * (n + m))\n where check h = credit2 + credit3 <= common\n where common = div h 6\n only2 = (div h 2) - common\n only3 = (div h 3) - common\n credit2 | only2 >= n = 0\n | otherwise = n - only2\n credit3 | only3 >= m = 0\n | otherwise = m - only3\n\n bsearch lo hi | lo + 1 == hi = hi\n | check mi = bsearch lo mi\n | otherwise = bsearch mi hi\n where mi = (lo + hi) `div` 2\n\nmain :: IO ()\nmain = do\n [n, m] <- liftM (map read . words) getLine\n print $ solve n m\n"}, {"source_code": "calc::Int->Int->Int\ncalc = go 0 where\n go acc 1 y | y < 1 = acc + 2\n go acc 2 y | y < 2 = acc + 4\n go acc x 1 | x < 2 = acc + 3\n go acc x 2 | x < 3 = acc + 6\n go acc 3 y | y < 2 = acc + 6\n go acc x y = if x * 2 > y * 3 then go (acc + 6 ) (x - 3) (y - 1) else go (acc + 6 ) (x - 2)( y - 2)\n\nmain:: IO ()\nmain = fmap (map read . words) getLine >>= \\[x,y] -> print $ calc x y\n"}], "negative_code": [], "src_uid": "23f2c8cac07403899199abdcfd947a5a"} {"source_code": "import Data.List\nmain = interact $ show. go. sort. map read. tail. words\ngo :: [Int] -> Int\ngo as = min a b\n where n = 2 * length as\n try = sum. zipWith (\\x y -> abs $ x - y) as\n a = try [1, 3 .. n]\n b = try [2, 4 .. n]\n\n", "positive_code": [{"source_code": "module Main (main)\n where\n\nimport Data.List\n\nreadIntegers :: String -> [Int]\nreadIntegers = map read . words\n\nsolve :: [Int] -> Int\nsolve [] = 1233\nsolve ar = min (solve' 0 2 ar) (solve' 0 1 ar)\n\nsolve' :: Int -> Int -> [Int] -> Int\nsolve' ans a [x] = ans + abs (x-a)\nsolve' ans a (x:xs) = solve' (ans + abs (x-a)) (a + 2) xs\n\nmain :: IO ()\nmain = putStrLn . toStr. solve . sort . readIntegers =<< (getLine >> getLine)\n where toStr = show"}, {"source_code": "\nimport Data.List (sort)\n\nmain = do\n xs <- fmap (sort . map read . words) (getLine >> getLine)\n print $ minimum $ map (sum . map abs . zipWith (-) xs) [[1,3..], [2,4..]]\n"}], "negative_code": [{"source_code": "import Data.List\nmain = interact $ show. go. sort. map read. init. words\ngo :: [Int] -> Int\ngo as = min a b\n where n = 2 * length as\n try = sum. zipWith (\\x y -> abs $ x - y) as\n a = try [1, 3 .. n]\n b = try [2, 4 .. n]\n\n"}], "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a"} {"source_code": "import Data.List\n\nmain = getLine >> getLine >>= print . solve\n\nsolve xs = numOps $ last $ filter check $ inits xs\n where numOps [] = length xs\n numOps s = length xs - (length s `div` 2) + 1\n\ncheck s = uncurry (==) $ splitAt (length s `div` 2) s \n", "positive_code": [{"source_code": "module Main where\n\nimport Control.Monad\nimport Control.Applicative\n\nmain = do\n n <- (read::String -> Int) <$> getLine\n s <- getLine\n let max_length = maximum $ loop s n\n if max_length /= 0 then print $ n + 1 - max_length else print n\n\nloop::String -> Int -> [Int]\nloop x l = do\n end <- [0..l - 1]\n let single = take (end + 1) x\n double = take (end * 2 + 2) x\n if (single ++ single) == double\n then return (end + 1)\n else return 0\n"}, {"source_code": "{-# LANGUAGE ViewPatterns #-}\nmodule Main where\n\nmain = getLine >> getLine >>= (\\xs -> let n = length xs in print $ n + (\\x -> if x == 0 then 0 else 1 - x) (last (filter (ok xs) [0..n])))\nok xs n | (a, splitAt n -> (b, _)) <- splitAt n xs = a == b"}, {"source_code": "solve :: String -> Int\nsolve str = min (length str) (1 + length str - copy) \n where copy = maximum $ filter (\\x -> take x (drop x str) == take x str) [0..length str `div` 2]\n\nmain :: IO ()\nmain = getLine >> getLine >>= print . solve"}, {"source_code": "module Main where\n\nmaxTrue :: Int -> [Bool] -> Int\nmaxTrue _ [] = 0\nmaxTrue init (False:xs) = maxTrue (init + 1) xs\nmaxTrue init (True:xs) = max init (maxTrue (init + 1) xs)\n\ncheck :: String -> Int -> Bool\ncheck xs maxRepeatLen = take maxRepeatLen xs == take maxRepeatLen (drop maxRepeatLen xs)\n\nmaxCopyLen :: String -> Int\nmaxCopyLen [] = 0\nmaxCopyLen [x] = 0\nmaxCopyLen xs = maxTrue 1 $ map (check xs) [1..length xs `div` 2]\n\neval :: String -> Int\neval str = min (length str) (length str + 1 - maxCopyLen str)\n\nprintRes :: String -> IO ()\nprintRes = print . eval\n\nmain :: IO ()\nmain = getLine >> getLine >>= printRes\n"}], "negative_code": [{"source_code": "module Main where\n\nimport Control.Monad\nimport Control.Applicative\n\nmain = do\n n <- (read::String -> Int) <$> getLine\n s <- getLine\n let max_length = maximum $ loop s n\n if max_length /= 0 then print $ n + 1 - max_length else print n\n\nloop::String -> Int -> [Int]\nloop x l = do\n start <- [0..l - 2]\n let partial_x = drop start x\n end <- [start + 1..l - 1]\n let single = take (end - start) partial_x\n let double = take ((end - start) * 2) partial_x\n if (single ++ single) == double\n then return (end - start)\n else return 0\n"}, {"source_code": "module Main where\n\nimport Control.Monad\nimport Control.Applicative\nimport qualified Data.Map\n\nmain = do\n n <- (read::String -> Int) <$> getLine\n s <- getLine\n let max_length = maximum $ loop s n\n if max_length /= 0 then print $ n + 1 - max_length else print n\n\nloop::String -> Int -> [Int]\nloop x l = do\n start <- [0..l - 2]\n let partial_x = drop start x\n end <- [start + 1..l - 1]\n let single = take (end - start) partial_x\n let double = take ((end - start) * 2) partial_x\n if (single ++ single) == double\n then return (end - start)\n else return 0\n"}, {"source_code": "module Main where\n\ninner :: String -> String -> Int\ninner [] _ = 0\ninner _ [] = 0\ninner (a:[]) (x:xs) = max 1 (inner (a:[x]) xs)\ninner (a:as) (x:xs) = if a == x\n then max (inner ((a:as) ++ [x]) xs) (length $ takeWhile (\\(c,b) -> c == b) (zip (a:as) (x:xs)))\n else inner ((a:as) ++ [x]) xs\n\nev :: String -> Int\nev (x:xs) = inner [x] xs\n\nmaxCopyLen :: String -> Int\nmaxCopyLen [] = 0\nmaxCopyLen [x] = 0\nmaxCopyLen (x:xs) = max (ev (x:xs)) (maxCopyLen xs)\n\neval :: String -> Int\neval str = min (length str) (length str + 1 - maxCopyLen str)\n\nprintRes :: String -> IO ()\nprintRes = print . eval\n\nmain :: IO ()\nmain = getLine >> getLine >>= printRes\n"}, {"source_code": "module Main where\n\ninner :: String -> String -> Int\ninner _ [] = 0\ninner \"\" (x:[]) = 0\ninner (s:ss) (x:[]) = if s == x\n then 1\n else 0\ninner \"\" (x:xs) = inner [x] xs \ninner (a:as) (x:xs) = if a == x\n then max (1 + inner as xs) (inner ((a:as) ++ [x]) xs)\n else (inner ((a:as) ++ [x]) xs)\n\nev :: String -> Int\nev (x:xs) = inner [x] xs\n\nmaxCopyLen :: String -> Int\nmaxCopyLen [] = 0\nmaxCopyLen [x] = 0\nmaxCopyLen (x:xs) = max (ev (x:xs)) (maxCopyLen xs)\n\neval :: String -> Int\neval str = min (length str) (length str + 1 - maxCopyLen str)\n\nprintRes :: String -> IO ()\nprintRes = print . eval\n\nmain :: IO ()\nmain = getLine >> getLine >>= printRes\n"}], "src_uid": "ed8725e4717c82fa7cfa56178057bca3"} {"source_code": "import List\n\nun = map read . words\n\nisParal [(a,b), (c,d)] = a == c || b == d\n\nisNonnull [a, b] = a /= b\n\nmain = do\n s1 <- getLine\n s2 <- getLine\n s3 <- getLine\n s4 <- getLine\n let lines = map (\\(a:b:c:d:_) -> sort [(a,b), (c,d)]) $ (map un [s1,s2,s3,s4] :: [[Integer]] )\n points = concat lines\n pointGroups = group $ sort points\n pointCounts = map length pointGroups --must all 2\n numOfPoints = length pointGroups --must be 4\n doubles = group $ sort lines --must be 4\n nonnulls = all (==True) $ map isNonnull lines\n parals = all (==True) $ map isParal lines\n is2d = 1 < (length $ group $ map fst points) &&\n 1 < (length $ group $ map snd points)\n if (numOfPoints == 4 &&\n all (==2) pointCounts &&\n length doubles == 4 &&\n nonnulls &&\n is2d &&\n parals) then\n putStrLn \"YES\"\n else\n putStrLn \"NO\"\n", "positive_code": [{"source_code": "import List\nimport Control.Monad\n\nsolve p | sort p == sort q = \"YES\"\n | otherwise = \"NO\"\n where q = nub [[(a,b),(c,d)] | a <- [x0, x1], c <-[a, x1], b <- [y0, y1], d <- [b, y1+0], (a /= c) /= (b /= d)]\n (x0, y0) = minimum $ concat p\n (x1, y1) = maximum $ concat p\n \n\nmain = replicateM 4 (fmap (map read . words) getLine) >>= (\n putStrLn . solve. map (sort.(\\[a,b,c,d]->[(a,b),(c,d)])))\n "}], "negative_code": [{"source_code": "import List\n\nun = map read . words\n\nisParal [(a,b), (c,d)] = a == c || b == d\n\nisNonnull [a, b] = a /= b\n\nmain = do\n s1 <- getLine\n s2 <- getLine\n s3 <- getLine\n s4 <- getLine\n let lines = map (\\(a:b:c:d:_) -> sort [(a,b), (c,d)]) $ (map un [s1,s2,s3,s4] :: [[Int]] )\n points = concat lines\n pointGroups = group $ sort points\n pointCounts = map length pointGroups --must all 2\n numOfPoints = length pointGroups --must be 4\n doubles = group $ sort lines --must be 4\n nonnulls = all (==True) $ map isNonnull lines\n parals = all (==True) $ map isParal lines\n if (numOfPoints == 4 &&\n all (==2) pointCounts &&\n length doubles == 4 &&\n nonnulls &&\n parals) then\n putStrLn \"YES\"\n else\n putStrLn \"NO\"\n"}, {"source_code": "import List\n\nun = map read . words\n\nisParal [(a,b), (c,d)] = a == c || b == d\n\nisNonnull [a, b] = a /= b\n\nmain = do\n s1 <- getLine\n s2 <- getLine\n s3 <- getLine\n s4 <- getLine\n let l = map (\\(a:b:c:d:_) -> [(a,b), (c,d)]) $ (map un [s1,s2,s3,s4] :: [[Int]] )\n ll = concat l\n points = group $ sort ll\n pointCounts = map length points --must all 2\n numOfPoints = length points --must be 4\n doubles = group $ sort l --must be 4\n nonnulls = all (==True) $ map isNonnull l\n parals = all (==True) $ map isParal l\n if (numOfPoints == 4 &&\n all (==2) pointCounts &&\n length doubles == 4 &&\n nonnulls &&\n parals) then\n putStrLn \"YES\"\n else\n putStrLn \"NO\"\n"}, {"source_code": "import List\n\nun = map read . words\n\nisParal [(a,b), (c,d)] = a == c || b == d\n\nisNonnull [a, b] = a /= b\n\nmain = do\n s1 <- getLine\n s2 <- getLine\n s3 <- getLine\n s4 <- getLine\n let lines = map (\\(a:b:c:d:_) -> sort [(a,b), (c,d)]) $ (map un [s1,s2,s3,s4] :: [[Int]] )\n points = concat lines\n pointGroups = group $ sort points\n pointCounts = map length pointGroups --must all 2\n numOfPoints = length pointGroups --must be 4\n doubles = group $ sort lines --must be 4\n nonnulls = all (==True) $ map isNonnull lines\n parals = all (==True) $ map isParal lines\n if (numOfPoints == 4 &&\n all (==2) pointCounts &&\n length doubles == 4 &&\n nonnulls &&\n parals) then\n putStrLn \"YES\"\n else\n putStrLn \"NO\"\n"}, {"source_code": "import List\n\nun = map read . words\n\nisParal [(a,b), (c,d)] = a == c || b == d\n\nisNonnull [a, b] = a /= b\n\nmain = do\n s1 <- getLine\n s2 <- getLine\n s3 <- getLine\n s4 <- getLine\n let l = map (\\(a:b:c:d:_) -> [(a,b), (c,d)]) $ (map un [s1,s2,s3,s4] :: [[Int]] )\n ll = concat l\n points = group $ sort ll\n pointCounts = map length points --must all 2\n numOfPoints = length points --must be 4\n doubles = group $ sort l --must be 4\n nonnulls = all (==True) $ map isNonnull l\n parals = all (==True) $ map isParal l\n if (numOfPoints == 4 &&\n all (==2) pointCounts &&\n nonnulls &&\n parals) then\n putStrLn \"YES\"\n else\n putStrLn \"NO\"\n"}, {"source_code": "import List\n\nun = map read . words\n\nisParal [(a,b), (c,d)] = a == c || b == d\n\nisNonnull [a, b] = a /= b\n\nmain = do\n s1 <- getLine\n s2 <- getLine\n s3 <- getLine\n s4 <- getLine\n let lines = map (\\(a:b:c:d:_) -> sort [(a,b), (c,d)]) $ (map un [s1,s2,s3,s4] :: [[Integer]] )\n points = concat lines\n pointGroups = group $ sort points\n pointCounts = map length pointGroups --must all 2\n numOfPoints = length pointGroups --must be 4\n doubles = group $ sort lines --must be 4\n nonnulls = all (==True) $ map isNonnull lines\n parals = all (==True) $ map isParal lines\n if (numOfPoints == 4 &&\n all (==2) pointCounts &&\n length doubles == 4 &&\n nonnulls &&\n parals) then\n putStrLn \"YES\"\n else\n putStrLn \"NO\"\n"}], "src_uid": "ad105c08f63e9761fe90f69630628027"} {"source_code": "import Data.Maybe\n\nsolve (n:m:i:j:a:b:[]) = catMaybes [try x y | x <- [1, n], y <- [1, m]]\n where\n try u v\n | i == u && j == v = Just 0\n | i-a < 1 && i+a > n = Nothing\n | j-b < 1 && j+b > m = Nothing\n | i `mod` a /= u `mod` a = Nothing\n | j `mod` b /= v `mod` b = Nothing\n | ma `mod` 2 /= mb `mod` 2 = Nothing\n | otherwise = Just $ max ma mb\n where\n ma = abs $ (u-i) `div` a\n mb = abs $ (v-j) `div` b\n\n\nmain = do\n input <- getLine\n case solve $ map read $ words input of\n [] -> putStr \"Poor Inna and pony!\\n\"\n ans -> print $ minimum ans\n", "positive_code": [{"source_code": "import Data.Maybe (maybeToList)\n\nsolve n m i j a b = case concat $ map maybeToList [try x y | x <- [1, n], y <- [1, m]] of\n [] -> Nothing\n ls -> Just $ minimum ls\n where\n try u v\n | i == u && j == v = Just 0\n | i-a < 1 && i+a > n = Nothing\n | j-b < 1 && j+b > m = Nothing\n | i `mod` a == u `mod` a && \n j `mod` b == v `mod` b &&\n ma `mod` 2 == mb `mod` 2 = Just $ max ma mb\n | otherwise = Nothing\n where\n ma = abs $ (u-i) `div` a\n mb = abs $ (v-j) `div` b\n\ngetInts = fmap ((map read) . words) getLine\n\nmain = do\n [n, m, i, j, a, b] <- getInts \n case solve n m i j a b of\n Nothing -> putStr \"Poor Inna and pony!\\n\"\n Just ans -> print ans\n"}, {"source_code": "import Data.Maybe\n\nsolve (n:m:i:j:a:b:[]) = catMaybes [try x y | x <- [1, n], y <- [1, m]]\n where\n try u v\n | i == u && j == v = Just 0\n | i-a < 1 && i+a > n ||\n j-b < 1 && j+b > m ||\n i `mod` a /= u `mod` a ||\n j `mod` b /= v `mod` b ||\n ma `mod` 2 /= mb `mod` 2 = Nothing\n | otherwise = Just $ max ma mb\n where\n ma = abs $ (u-i) `div` a\n mb = abs $ (v-j) `div` b\n\n\nmain = do\n input <- getLine\n case solve $ map read $ words input of\n [] -> putStr \"Poor Inna and pony!\\n\"\n ans -> print $ minimum ans\n"}, {"source_code": "import System.IO\nimport Data.Maybe (maybeToList)\n\ncheck :: Integer -> Integer -> Bool\ncheck l r = l `mod` 2 == r `mod` 2\n\ntry :: Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Maybe Integer\ntry n m i j a b u v\n | i == u && j == v = Just 0\n | i-a < 1 && i+a > n = Nothing\n | j-b < 1 && j+b > m = Nothing\n | (i `mod` a == u `mod` a) && \n (j `mod` b == v `mod` b) &&\n (check ma mb) = Just $ max ma mb\n | otherwise = Nothing\n where\n ma = abs $ (u-i) `div` a\n mb = abs $ (v-j) `div` b\n\nsolve :: Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Maybe Integer\nsolve n m i j a b = case concat $ map maybeToList [try n m i j a b x y | x <- [1, n], y <- [1, m]] of\n [] -> Nothing\n ls -> Just $ minimum ls\n\nmain :: IO()\nmain = do\n [n, m, i, j, a, b] <- fmap ((map read) .words) getLine\n case solve n m i j a b of\n Nothing -> putStr \"Poor Inna and pony!\\n\"\n Just ans -> print ans\n"}, {"source_code": "import Data.Maybe (maybeToList)\n\ntry n m i j a b u v\n | i == u && j == v = Just 0\n | i-a < 1 && i+a > n = Nothing\n | j-b < 1 && j+b > m = Nothing\n | i `mod` a == u `mod` a && \n j `mod` b == v `mod` b &&\n ma `mod` 2 == mb `mod` 2 = Just $ max ma mb\n | otherwise = Nothing\n where\n ma = abs $ (u-i) `div` a\n mb = abs $ (v-j) `div` b\n\nsolve n m i j a b = case concat $ map maybeToList [try n m i j a b x y | x <- [1, n], y <- [1, m]] of\n [] -> Nothing\n ls -> Just $ minimum ls\n\ngetInts = fmap ((map read) . words) getLine\n\nmain = do\n [n, m, i, j, a, b] <- getInts \n case solve n m i j a b of\n Nothing -> putStr \"Poor Inna and pony!\\n\"\n Just ans -> print ans\n"}, {"source_code": "import Data.Maybe\n\nminimummaybe :: [Maybe Integer] -> Maybe Integer\nminimummaybe [] = Nothing\nminimummaybe (x : xs) = minmaybe x $ minimummaybe xs\n\twhere\n\t\tminmaybe :: Maybe Integer -> Maybe Integer -> Maybe Integer\n\t\tminmaybe Nothing Nothing = Nothing\n\t\tminmaybe (Just x) Nothing = Just x\n\t\tminmaybe Nothing (Just y) = Just y\n\t\tminmaybe (Just x) (Just y) = Just (min x y)\n\nsteps :: [Integer] -> Maybe Integer\nsteps (x0 : y0 : x1 : y1 : dx : dy : _)\n\t| ((mod (abs (x0 - x1)) dx) /= 0) || ((mod (abs (y0 - y1)) dy) /= 0) || (mod ((div (abs (x0 - x1)) dx) + (div (abs (y0 - y1)) dy)) 2 == 1) = Nothing\n\t| otherwise = Just (max ((div (abs (x0 - x1)) dx)) (div (abs (y0 - y1)) dy))\n\ngetans :: [Integer] -> String\ngetans (n : m : i : j : a : b : _)\n\t| (i == 1 || i == n) && (j == 1 || j == m) = \"0\"\n\t| (i - a < 1 && i + a > n) || (j - b < 1 && j + b > m) || minsteps == Nothing = \"Poor Inna and pony!\"\n\t| otherwise = show $ fromJust $ minsteps \n\twhere\n\t\tminsteps = minimummaybe [steps [i, j, 1, 1, a, b], steps [i, j, 1, m, a, b], steps [i, j, n, 1, a, b], steps [i, j, n, m, a, b]]\n \nmain = do\n input <- getLine\n putStr $ getans (map read (words input) :: [Integer])\n"}, {"source_code": "import Data.Maybe (maybeToList)\n\ncheck l r = l `mod` 2 == r `mod` 2\n\ntry n m i j a b u v\n | i == u && j == v = Just 0\n | i-a < 1 && i+a > n = Nothing\n | j-b < 1 && j+b > m = Nothing\n | i `mod` a == u `mod` a && \n j `mod` b == v `mod` b &&\n ma `mod` 2 == mb `mod` 2 = Just $ max ma mb\n | otherwise = Nothing\n where\n ma = abs $ (u-i) `div` a\n mb = abs $ (v-j) `div` b\n\nsolve n m i j a b = case concat $ map maybeToList [try n m i j a b x y | x <- [1, n], y <- [1, m]] of\n [] -> Nothing\n ls -> Just $ minimum ls\n\ngetInts = fmap ((map read) . words) getLine\n\nmain = do\n [n, m, i, j, a, b] <- getInts \n case solve n m i j a b of\n Nothing -> putStr \"Poor Inna and pony!\\n\"\n Just ans -> print ans\n"}], "negative_code": [{"source_code": "import System.IO\nimport Data.Maybe (maybeToList)\n\ncheck :: Integer -> Integer -> Bool\ncheck l r = l `mod` 2 == r `mod` 2\n\ntry :: Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Maybe Integer\ntry i j a b u v\n | (i `mod` a == u `mod` a) && \n (j `mod` b == v `mod` b) &&\n (check ma mb) = Just $ max ma mb\n | otherwise = Nothing\n where\n ma = abs $ (u-i) `div` a\n mb = abs $ (v-j) `div` b\n\nsolve :: Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Maybe Integer\nsolve n m i j a b\n | i == a && j == b = Just 0 \n | n == 1 || m == 1 = Nothing\n | i-a < 1 && i+a > n = Nothing\n | j-b < 1 && j+b > m = Nothing\n | otherwise = case concat $ map maybeToList [try i j a b x y | x <- [1, n], y <- [1, m]] of\n [] -> Nothing\n ls -> Just $ minimum ls\n\nmain :: IO()\nmain = do\n [n, m, i, j, a, b] <- fmap ((map read) .words) getLine\n case solve n m i j a b of\n Nothing -> putStr \"Poor Inna and pony!\\n\"\n Just ans -> print ans\n"}, {"source_code": "import System.IO\nimport Data.Maybe (maybeToList)\n\ncheck :: Integer -> Integer -> Bool\ncheck l r = l `mod` 2 == r `mod` 2\n\ntry :: Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Maybe Integer\ntry i j a b u v\n | (i `mod` a == u `mod` a) && \n (j `mod` b == v `mod` b) &&\n (check ma mb) = Just $ max ma mb\n | otherwise = Nothing\n where\n ma = abs $ (u-i) `div` a\n mb = abs $ (v-j) `div` b\n\nsolve :: Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Maybe Integer\nsolve n m i j a b = case concat $ map maybeToList [try i j a b x y | x <- [1, n], y <- [1, m]] of\n [] -> Nothing\n ls -> Just $ minimum ls\n\nmain :: IO()\nmain = do\n [n, m, i, j, a, b] <- fmap ((map read) .words) getLine\n case solve n m i j a b of\n Nothing -> putStr \"Poor Inna and pony!\\n\"\n Just ans -> print ans\n"}, {"source_code": "import Data.Maybe\n\nminimummaybe :: [Maybe Integer] -> Maybe Integer\nminimummaybe [] = Nothing\nminimummaybe (x : xs) = minmaybe x $ minimummaybe xs\n\twhere\n\t\tminmaybe :: Maybe Integer -> Maybe Integer -> Maybe Integer\n\t\tminmaybe Nothing Nothing = Nothing\n\t\tminmaybe (Just x) Nothing = Just x\n\t\tminmaybe Nothing (Just y) = Just y\n\t\tminmaybe (Just x) (Just y) = Just (min x y)\n\nsteps :: [Integer] -> Maybe Integer\nsteps (x0 : y0 : x1 : y1 : dx : dy : _)\n\t| ((mod (abs (x0 - x1)) dx) /= 0) || ((mod (abs (y0 - y1)) dy) /= 0) || (mod ((div (abs (x0 - x1)) dx) + (div (abs (y0 - y1)) dy)) 2 == 1) = Nothing\n\t| otherwise = Just (max ((div (abs (x0 - x1)) dx)) (div (abs (y0 - y1)) dy))\n\ngetans :: [Integer] -> String\ngetans (n : m : i : j : a : b : _)\n\t| (i - a < 1 && i + a > n) || (j - b < 1 && j + b > m) || minsteps == Nothing = \"Poor Inna and pony!\"\n\t| otherwise = show $ fromJust $ minsteps \n\twhere\n\t\tminsteps = minimummaybe [steps [i, j, 1, 1, a, b], steps [i, j, 1, m, a, b], steps [i, j, n, 1, a, b], steps [i, j, n, m, a, b]]\n \nmain = do\n input <- getLine\n putStr $ getans (map read (words input) :: [Integer])\n"}, {"source_code": "import Data.Maybe\n\nminimummaybe :: [Maybe Integer] -> Maybe Integer\nminimummaybe [] = Nothing\nminimummaybe (x : xs) = minmaybe x $ minimummaybe xs\n\twhere\n\t\tminmaybe :: Maybe Integer -> Maybe Integer -> Maybe Integer\n\t\tminmaybe Nothing Nothing = Nothing\n\t\tminmaybe (Just x) Nothing = Just x\n\t\tminmaybe Nothing (Just y) = Just y\n\t\tminmaybe (Just x) (Just y) = Just (min x y)\n\nsteps :: [Integer] -> Maybe Integer\nsteps (x0 : y0 : x1 : y1 : dx : dy : _)\n\t| ((mod (abs (x0 - x1)) dx) /= 0) || ((mod (abs (y0 - y1)) dy) /= 0) || (mod ((div (abs (x0 - x1)) dx) + (div (abs (y0 - y1)) dy)) 2 == 1) = Nothing\n\t| otherwise = Just (max ((div (abs (x0 - x1)) dx)) (div (abs (y0 - y1)) dy))\n\ngetans :: [Integer] -> String\ngetans (n : m : i : j : a : b : _)\n\t| (i /= n && i /= 1 && i - a < 1 && i + a > n) || (j /= m && j /= 1 && j - b < 1 && j + b > m) || minsteps == Nothing = \"Poor Inna and pony!\"\n\t| otherwise = show $ fromJust $ minsteps \n\twhere\n\t\tminsteps = minimummaybe [steps [i, j, 1, 1, a, b], steps [i, j, 1, m, a, b], steps [i, j, n, 1, a, b], steps [i, j, n, m, a, b]]\n \nmain = do\n input <- getLine\n putStr $ getans (map read (words input) :: [Integer])\n"}, {"source_code": "import Data.Maybe\n\nminimummaybe :: [Maybe Integer] -> Maybe Integer\nminimummaybe [] = Nothing\nminimummaybe (x : xs) = minmaybe x $ minimummaybe xs\n\twhere\n\t\tminmaybe :: Maybe Integer -> Maybe Integer -> Maybe Integer\n\t\tminmaybe Nothing Nothing = Nothing\n\t\tminmaybe (Just x) Nothing = Just x\n\t\tminmaybe Nothing (Just y) = Just y\n\t\tminmaybe (Just x) (Just y) = Just (min x y)\n\nsteps :: [Integer] -> Maybe Integer\nsteps (x0 : y0 : x1 : y1 : dx : dy : _)\n\t| ((mod (abs (x0 - x1)) dx) /= 0) || ((mod (abs (y0 - y1)) dy) /= 0) || (mod ((div (abs (x0 - x1)) dx) + (div (abs (y0 - y1)) dy)) 2 == 1) = Nothing\n\t| otherwise = Just (max ((div (abs (x0 - x1)) dx)) (div (abs (y0 - y1)) dy))\n\ngetans :: [Integer] -> String\ngetans (n : m : i : j : a : b : _)\n\t| minsteps == Nothing = \"Poor Inna and pony!\"\n\t| otherwise = show $ fromJust $ minsteps \n\twhere\n\t\tminsteps = minimummaybe [steps [i, j, 1, 1, a, b], steps [i, j, 1, m, a, b], steps [i, j, n, 1, a, b], steps [i, j, n, m, a, b]]\n \nmain = do\n input <- getLine\n putStr $ getans (map read (words input) :: [Integer])\n"}, {"source_code": "import Data.Maybe\n\nminimummaybe :: [Maybe Integer] -> Maybe Integer\nminimummaybe [] = Nothing\nminimummaybe (x : xs) = minmaybe x $ minimummaybe xs\n\twhere\n\t\tminmaybe :: Maybe Integer -> Maybe Integer -> Maybe Integer\n\t\tminmaybe Nothing Nothing = Nothing\n\t\tminmaybe (Just x) Nothing = Just x\n\t\tminmaybe Nothing (Just y) = Just y\n\t\tminmaybe (Just x) (Just y) = Just (min x y)\n\nsteps :: [Integer] -> Maybe Integer\nsteps (x0 : y0 : x1 : y1 : dx : dy : _)\n\t| ((mod (abs (x0 - x1)) dx) /= 0) || ((mod (abs (y0 - y1)) dy) /= 0) || ((div (abs (x0 - x1)) dx) /= (div (abs (y0 - y1)) dy)) = Nothing\n\t| otherwise = Just ((div (abs (x0 - x1)) dx))\n\ngetans :: [Integer] -> String\ngetans (n : m : i : j : a : b : _)\n\t| minsteps == Nothing = \"Poor Inna and pony!\"\n\t| otherwise = show $ fromJust $ minsteps \n\twhere\n\t\tminsteps = minimummaybe [steps [i, j, 1, 1, a, b], steps [i, j, 1, m, a, b], steps [i, j, n, 1, a, b], steps [i, j, n, m, a, b]]\n \nmain = do\n input <- getLine\n putStr $ getans (map read (words input) :: [Integer])\n"}, {"source_code": "import Data.Maybe\n\nminimummaybe :: [Maybe Int] -> Maybe Int\nminimummaybe [] = Nothing\nminimummaybe (x : xs) = minmaybe x $ minimummaybe xs\n\twhere\n\t\tminmaybe :: Maybe Int -> Maybe Int -> Maybe Int\n\t\tminmaybe Nothing Nothing = Nothing\n\t\tminmaybe (Just x) Nothing = Just x\n\t\tminmaybe Nothing (Just y) = Just y\n\t\tminmaybe (Just x) (Just y) = Just (min x y)\n\nsteps :: [Int] -> Maybe Int\nsteps (x0 : y0 : x1 : y1 : dx : dy : _)\n\t| ((mod (abs (x0 - x1)) dx) /= 0) || ((mod (abs (y0 - y1)) dy) /= 0) || ((div (abs (x0 - x1)) dx) /= (div (abs (y0 - y1)) dy)) = Nothing\n\t| otherwise = Just ((div (abs (x0 - x1)) dx))\n\ngetans :: [Int] -> String\ngetans (n : m : i : j : a : b : _)\n\t| minsteps == Nothing = \"Poor Inna and pony!\"\n\t| otherwise = show $ fromJust $ minsteps \n\twhere\n\t\tminsteps = minimummaybe [steps [i, j, 1, 1, a, b], steps [i, j, 1, m, a, b], steps [i, j, n, 1, a, b], steps [i, j, n, m, a, b]]\n \nmain = do\n input <- getLine\n putStr $ getans (map read (words input) :: [Int])\n"}], "src_uid": "51155e9bfa90e0ff29d049cedc3e1862"} {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\n\n\nmain = do\n\t\tgetLine\n\t\tn1<- sort <$> map read <$> words <$> getLine ::IO [Int]\n\t\tlet n= maximum $ map length $ group n1\n\t\tprint n\t\n", "positive_code": [{"source_code": "import System.IO\nimport Data.List\nimport Data.Functor\n\nmain = do\n line <- getLine\n let n = read line :: Int\n\n line2 <- getLine\n let mywords = words line2\n\n let num = read <$> mywords :: [Int]\n \n let x = [length x | x <- group $ sort num]\n\n print $ maximum x"}, {"source_code": "-- Codeforces 1003A\nimport Data.List\n\nmaxOccurences :: [Int] -> Int\nmaxOccurences list = maximum occurences\n where ordered = sort list\n grouped = group ordered\n occurences = map length grouped\n\nmain :: IO ()\nmain = do\n n <- getLine\n input <- getLine\n let numbers = map (read :: String -> Int) (words input)\n let maxOccur = maxOccurences numbers\n print maxOccur\n"}, {"source_code": "import Data.List\nimport Data.Function\n\nmain = getLine >> getLine >>= print . length . maximumBy (compare `on` length) . group. sort . map (read :: String -> Int) . words \n"}, {"source_code": "import Data.List\n\nmain=do\n e1<-getLine\n es<-getLine\n let xs=map read (words es)::[Int]\n print $ last $ sort $ map length $ group $ sort xs"}, {"source_code": "import Control.Monad\nimport Data.Map as Map\n\nmain = readInput\n >>= putStrLn . show . maxMap . parse . words\n\nreadInput :: IO String\nreadInput = liftM2 go getLine getLine\n where go a b = b\n\nparse :: [String] -> Map String Int\nparse strs = fromListWith (+) $ Prelude.map (\\s -> (s, 1)) strs\n\nmaxMap :: Map String Int -> Int\nmaxMap xs = Map.foldr max 0 xs"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n\nimport Prelude\nimport Data.List\nimport Text.Printf\nimport Control.Monad\nimport Data.Ratio\nimport Data.Int\nimport Data.Functor\n\n\nmain :: IO ()\nmain = do\n (n :: Int) <- read <$> getLine\n (a :: [Int]) <- (map read . words) <$> getLine\n let answer = maximum . map length . group . sort $ a\n printf \"%d\" answer "}, {"source_code": "{-# LANGUAGE TypeApplications #-}\nimport Data.List\nmain = interact $ show . maximum . map length . group . sort . map (read @Int) . tail . words\n"}, {"source_code": "module Main where\n\nimport System.IO\n\ncoins :: Eq a => [a] -> Int\ncoins ns = length (coins' ns)\n\ncoins' :: Eq a => [a] -> [[a]]\ncoins' ns = foldl (flip coins'') [] ns\n\ncoins'' :: Eq a => a -> [[a]] -> [[a]]\ncoins'' a [] = [[a]]\ncoins'' a (xs:yss) | a `elem` xs = xs : (coins'' a yss)\n | otherwise = (a:xs):yss\n\n\n\nmain :: IO ()\nmain =\n do\n _ <- readInt\n str <- getLine\n ns <- return (map read $ words str :: [Int])\n putStrLn (show $ coins ns)\n\n where readInt :: IO Int\n readInt = readLn\n\n"}, {"source_code": "--ghc 7.10\n\nimport Data.List(group,sort)\n\nmaxOccurrence :: (Ord a) => [a] -> Int\nmaxOccurrence = maximum . map length . group . sort\n\nmain = do\n nStr <- getLine\n aStr <- getLine\n let a = map read . words $ aStr :: [Int]\n print $ maxOccurrence a"}, {"source_code": "import Data.List\nmain=interact$show.maximum.map length.group.sort.map (read::String->Int).tail.words\n"}], "negative_code": [{"source_code": "import Control.Monad\nimport Data.List\n\nmain = readInput\n >>= putStrLn . show . maxL . (map length) . group . words\n\nreadInput :: IO String\nreadInput = liftM2 go getLine getLine\n where go a b = b\n\nmaxL :: Ord a => [a] -> a\nmaxL (x:xs) = foldr go x xs\n where go a cand\n | a < cand = cand\n | otherwise = a"}], "src_uid": "f30329023e84b4c50b1b118dc98ae73c"} {"source_code": "reduce :: String -> String\nreduce [] = []\nreduce [a] = [a]\nreduce ('R':'U':xs) = 'D':reduce xs\nreduce ('U':'R':xs) = 'D':reduce xs\nreduce (x:xs) = x:reduce xs\n\nreduceIter :: String -> String\nreduceIter str = let str' = reduce str in if length str' == length str then str else reduce str'\n\nsolve :: String -> Int\nsolve = length . reduceIter\n\nmain :: IO ()\nmain = getLine >> getLine >>= print . solve", "positive_code": [{"source_code": "import Data.List\n\nf ::String->Int\nf []=0\nf (x:[])=1\nf ('U':'R':xs)=1+f xs\nf ('R':'U':xs)=1+f xs\nf (x:xs)=1+f xs\n\nmain = do\n e<-getLine\n es<-getLine\n print $ (f es)"}, {"source_code": "module Main where\n\neval :: String -> Int\neval [] = 0\neval [x] = 1\neval ('U':'R':xs) = 1 + eval xs\neval ('R':'U':xs) = 1 + eval xs\neval (x:xs) = 1 + eval xs\n\nprintRes :: String -> IO ()\nprintRes str = print $ eval str\n\nmain :: IO ()\nmain = getLine >> getLine >>= printRes >>= return\n"}, {"source_code": "module Main where\n\nimport Control.Monad\nimport Control.Applicative\n\nmain = do\n n <- (read::String -> Int) <$> getLine\n s <- getLine\n\n print . length $ foldl trans [] s\n\ntrans::String -> Char -> String\ntrans ('R':rest) 'U' = 'D':rest\ntrans ('U':rest) 'R' = 'D':rest\ntrans rest x = x:rest\n"}, {"source_code": "{-# LANGUAGE OverloadedStrings #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\n\n\nprocess [] = []\nprocess [a] = [a]\nprocess (a:b:c) | a=='R' && b=='U' = 'D' : (process c)\n | a=='U' && b=='R' = 'D' :(process c)\n\t\t| otherwise = a: (process (b:c))\n\n\nmain = do\n\t\tgetLine\n\t\ta<-getLine\n\t\tprint $ length $ process a\n"}, {"source_code": "main = getLine >> getLine >>= print . length . fn\nfn xs = foldr (\\x f s -> case (s, x) of { (0, 'R') -> f 1; (0, 'U') -> f 2; (1, 'U') -> 'D':f 0; (2, 'R') -> 'D': f 0; (1, _) -> 'R':f s; (2, _) -> 'U':f s; (0, _)-> f s }) (const []) (xs ++ \".\") 0\n"}, {"source_code": "f [] c = c\nf ('R':'U':as) c = f as (c+1)\nf ('U':'R':as) c = f as (c+1)\nf (a:as) c = f as (c+1)\n\n\nmain = do\n getLine\n as <- getLine\n print $ f as 0 \n"}, {"source_code": "main = getContents >>= print . solve . last . lines\n\nsolve [] = 0\nsolve ('R':'U':xs) = 1 + solve xs\nsolve ('U':'R':xs) = 1 + solve xs\nsolve (_:xs) = 1 + solve xs\n"}], "negative_code": [{"source_code": "{-# LANGUAGE OverloadedStrings #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport qualified Data.Text as T\n\nmain = do\n\t\tgetLine\n\t\ta<-getLine\n\t\tprint $ T.length $ T.replace \"RU\" \"D\" $ T.replace \"UR\" \"D\" $ T.pack a\n"}, {"source_code": "{-# LANGUAGE OverloadedStrings #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport qualified Data.Text as T\n\nmain = do\n\t\tgetLine\n\t\ta<-getLine\n\t\tlet b= T.length $ T.replace \"RU\" \"D\" $ T.replace \"UR\" \"D\" $ T.pack a\n\t\tlet c= T.length $ T.replace \"UR\" \"D\" $ T.replace \"RU\" \"D\" $ T.pack a\n\t\tprint $ min b c\n\t\t\n"}], "src_uid": "986ae418ce82435badadb0bd5588f45b"} {"source_code": "import Data.List\nimport Data.Char\nimport Data.Maybe\nimport Control.Monad\nimport Control.Applicative\nimport Data.Array\nimport Data.Bits\n\nmain = do\n [n,m,t] <- getList\n let list = [c_n_k n x * c_n_k m y | x <- [4..n], y <- [1..m], x+y == t]\n print $ sum list\n where \n getList = fmap (map read . words) getLine :: IO [Integer]\n c_n_k :: Integer -> Integer -> Integer\n c_n_k n k = product [1..n] `div` (product [1..k] * product [1..n-k])", "positive_code": [{"source_code": "\n{-\nimport HUnit\n\ntestSimple :: Test\ntestSimple = Test \"TestSimple\" $\n assertEq 1 (solve 4 1 5)\n\ntestInput :: Test\ntestInput = TestList \"TestInput\"\n [Test \"1\" $ assertEq 10 (solve 5 2 5),\n Test \"2\" $ assertEq 3 (solve 4 3 5)]\n\ntestReal :: Test\ntestReal = TestList \"TestReal\"\n [Test \"1\" $ assertEq 7 (solve 5 2 6)]\n\ntest :: IO ()\ntest = mapM_ run [testSimple, testInput, testReal]\n\n--------------------------------------------------------------------------------\n-}\n\nreads :: Read a => IO [a]\nreads = getLine >>= sequence . map readIO . words\n\nsolve :: Integer -> Integer -> Integer -> Integer\nsolve n m t = sum (map (\\x -> (c n x) * (c m (t-x))) [x | x <- [4 .. t - 1]])\n where\n c n m = div (product [n-m+1 .. n]) (product [1..m])\n\nmain :: IO ()\nmain = do\n [n, m, t] <- Main.reads\n print $ solve n m t\n"}, {"source_code": "--module CC where\n\ncombinator x 0 = 1\ncombinator x y = product [1..x] `div` (product [1..y] * product [1..x-y])\n\nanswer :: [Integer] -> Integer\nanswer [n,m,k] = func k m $ myFilter\n $ zip [4..n] $ map (n `combinator`) [4..n]\n where\n myFilter xs = filter ((>=k).(+m).fst) xs\n\nfunc :: Integer -> Integer -> [(Integer,Integer)] -> Integer\nfunc k m xs = sum $ map f xs\n where\n f (x,y) = if k == x then 0 else y *( m `combinator` (k-x))\n\nmain = getLine >>= print.answer.map read.take 3.words"}, {"source_code": "import Debug.Trace\n\nmain = interact $ show . count . map read . words\n\twhere\n\t\tcount (n:m:t:_) = foldr sumComb 0 [(x, t-x)| x<-[4..n], 0 < t-x, t-x <= m]\n\t\t\twhere\n\t\t\t\tsumComb (x,y) k = (comb n x) * (comb m y) + k\n\ncomb n m = (perm n m) `div` (perm m m)\nperm n 0 = 1\nperm n m = n * (perm (n-1) (m-1))"}, {"source_code": "main = interact $ show . count . map read . words\n\twhere\n\t\tcount (n:m:t:_) = sum [(comb n x) * (comb m $ t-x)| x<-[4..n], 0 < t-x, t-x <= m]\n\t\tcomb n r = product [n-r+1..n] `div` product [1..r]"}, {"source_code": "main = interact $ show . count . map read . words\n\twhere\n\t\tcount (n:m:t:_) = foldr sumComb 0 [x| x<-[4..n], 0 < t-x, t-x <= m]\n\t\t\twhere\n\t\t\t\tsumComb x k = (comb n x) * (comb m $ t-x) + k\n\t\t\t\tcomb n r = product [n-r+1..n] `div` product [1..r]"}, {"source_code": "import Data.List\nimport Data.Char\nimport Data.Maybe\nimport Control.Monad\nimport Control.Applicative\nimport Data.Array\nimport Data.Bits\n\nmain = do\n [n,m,t] <- getList\n let list = [c_n_k n x * c_n_k m y | x <- [4..n], y <- [1..m], x+y == t]\n print $ sum list\n where \n getList = fmap (map read . words) getLine :: IO [Integer]\n c_n_k :: Integer -> Integer -> Integer\n c_n_k n k = product [1..n] `div` (product [1..k] * product [1..n-k]) "}, {"source_code": "import Data.Int\nimport Data.Array\nmain = do\n [n,m,t] <- fmap (map read . words) getLine\n print $ sum [ ncr n n' * ncr m m' | n' <- [4..n], let m' = t - n', m' >= 1, m' <= m ]\nncr :: Int64 -> Int64 -> Int64\nncr = let a = array ((0,0),(30,30))\n [ ((n,m),if m == 0 || m == n\n then 1\n else ncr (n-1) (m-1) + ncr (n-1) m)\n | n <- [0..30], m <- [0..30] ]\n in \\n m -> a!(n,m)\n"}, {"source_code": "\nreadInts :: String -> [Integer]\nreadInts str = map read (words str)\n\n\nc :: Integer -> Integer -> Integer\nc n n' = product [1..n] `div` product [1..n'] `div` product [1..n-n']\n\nmain :: IO ()\nmain = do\n [n, m, t] <- fmap readInts getLine\n let actors = [(n', m') | n'<-[4..n],let m'=t-n', m'>=1]\n print $ sum [ c n n' * c m m' | (n', m')<-actors]\n"}, {"source_code": "{-# LANGUAGE TypeSynonymInstances #-}\n{-# OPTIONS_GHC -O2 #-}\n{-# LANGUAGE ForeignFunctionInterface, ScopedTypeVariables #-}\n{-# LANGUAGE OverloadedStrings #-}\nimport Foreign\nimport Foreign.C.Types\nimport Foreign.C.String\nimport Foreign.Marshal.Alloc\nimport Debug.Trace\nimport Data.List\nimport Control.Monad\nimport Control.Monad.ST\nimport qualified Data.Array.Unboxed as UB\nimport Data.Array.ST\nimport Data.Array\nimport Data.Char\nclass IOtyp a where scan' :: String -> a; show' :: a -> String\ninstance IOtyp Int where scan' = read; show' = show\ninstance IOtyp Char where scan' (x:_) = x;show' = (:[])\ninstance IOtyp Float where scan' = read;show' = show\ninstance IOtyp Double where scan' = read;show' = show\ninstance IOtyp Integer where scan' = read;show' = show\ninstance IOtyp String where scan' = id;show' = id\ninstance (IOtyp a,IOtyp b) => IOtyp (a,b) where scan' = (\\(x:y:_) -> (scan' x,scan' y)).words;show' (x,y) = show' x++' ':show' y\ninstance (IOtyp a,IOtyp b,IOtyp c) => IOtyp (a,b,c) where scan' = (\\(x:y:z:_) -> (scan' x,scan' y,scan' z)).words;show' (x,y,z) = show' x++' ':show' y++' ':show' z\nforeign import ccall \"stdio.h puts\" c_puts :: CString -> IO ()\nscan :: (IOtyp a) => IO a; scan = getLine>>=return.scan'\nscans :: (IOtyp a) => Int -> IO [a]; scans = (flip replicateM) scan\nscanlist :: (IOtyp a) => IO [a]; scanlist = getLine>>=return.map scan'.words\nscanlists :: (IOtyp a) => Int -> IO [[a]]; scanlists = (flip replicateM) scanlist\nputs :: (IOtyp a) => a -> IO (); puts ans = do {str<-newCString $ show' ans;c_puts str;free str}\n\nconb :: Int -> Int -> Integer\nconb n m = if m>(n `div` 2)&&(n>m) then conbrec 1 1 (fromIntegral n) (fromIntegral (n-m)) else conbrec 1 1 (fromIntegral n) (fromIntegral m)\n where\n conbrec ans ans2 n m | m==0 = ans `div` ans2\n | otherwise = conbrec (ans*n) (ans2*m) (n-1) (m-1)\n\nsolve :: Integer -> Int -> Int -> Int -> Int -> Integer\nsolve ans n m act actr | act<4 = ans\n | otherwise = solve (ans + (conb n act) * (conb m actr)) n m (act-1) (actr + 1)\n\nmain = do (n, m, t) <- scan :: IO (Int, Int, Int)\n puts.show $ solve 0 n m (t-1) 1"}, {"source_code": "{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\n-- solution for: http://codeforces.com/problemset/problem/131/C\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\nchoose n 0 = 1\nchoose 0 k = 0\nchoose n k = toInteger((choose (n-1) (k-1) * n) `div` k)\n\nhelper n m t x acc = do\n if (x == t) then acc\n else helper n m t (x + 1) (acc + (choose n x) * (choose m (t-x)))\n\nsolve [n,m,t] = helper n m t 4 0\n\nmain = \n do all <- BS.getContents\n let (x, _) = readMany readInt all\n print (solve x)\n where readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let (xs, t) = readMany readf r\n in (toInteger(x) : xs, t)\n Nothing -> ([], s)\n"}, {"source_code": "fact :: Int -> Integer\nfact n = product [1 .. toInteger n]\ncombo n m = div (fact n) $ (fact m) * (fact (n - m))\nsolve [n,m,t] = sum $ map ways [4 .. (t - 1)] \n where ways j = (combo m (t - j)) * (combo n j)\nmain = putStrLn.show.solve.map read.words =<< getLine"}, {"source_code": "main :: IO()\nmain = interact work\n\nwork :: String -> String\nwork input = show $ solve n m t\n where [n, m, t] = map read . words $ input\n\nfactorial :: Integer -> Integer\nfactorial n = product [1..n]\n\nbinom :: Integer -> Integer -> Integer\nbinom n k\n | n >= k = factorial n `div` factorial k `div` factorial (n - k)\n | otherwise = 0\n\nsolve :: Integer -> Integer -> Integer -> Integer\nsolve n m t = sum [binom n i * binom m (t - i) | i <- [4..t - 1]]\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\n-- solution for: http://codeforces.com/problemset/problem/131/C\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\nchoose n 0 = 1\nchoose 0 k = 0\nchoose n k = toInteger((choose (n-1) (k-1) * n) `div` k)\n\nhelper n m t x acc = do\n if (x == t) then acc\n else helper n m t (x + 1) (acc + (choose n x) * (choose m (t-x)))\n\nsolve [n,m,t] = helper n m t 4 0\n\nmain = \n do all <- BS.getContents\n let (x, _) = readMany readInt all\n print (solve x)\n where readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let (xs, t) = readMany readf r\n in (toInteger(x) : xs, t)\n Nothing -> ([], s)\n"}, {"source_code": "comb n 0 = n \ncomb n m = div numer deno\n where numer = foldl1 (*) [(n-m+1) .. n]\n deno = foldl1 (*) [1..m]\ns :: [Integer] -> Integer\ns [n, m, t] = sum . map (\\(x, y) -> (comb n x) * (comb m y)) $ [(x, t - x) | x <- [4..n], (t - x) <= m, x <= (t - 1)]\n\nmain = interact $ show . s . map read . words"}, {"source_code": "import Data.Array\nimport Data.Function\n\nmain = interact solve\n \nsolve s =\n show $ c ! (n + m, t) - c ! (n, t) - (sum $ map (\\x -> c ! (n, x) * c ! (m, t - x)) [0..3])\n where\n [n, m, t] = map read $ words s\n c = coefArr (n + m, t)\n\ncoefArr maxBounds = fix coefArr'\n where\n arrBounds = ((0, 0), maxBounds)\n coefArr' c =\n listArray arrBounds\n [ choose p |\n p <- range arrBounds,\n let choose (n, k) | k == 0 = 1\n | n < k = 0\n | otherwise = c ! (n - 1, k) + c ! (n - 1, k - 1)\n ]\n"}, {"source_code": "main = do\n [n, m, t] <- fmap (map read . words) getLine\n print $ c (n + m) t - c n t - (sum $ map (\\x -> (c n x) * (c m (t - x))) [0..3])\n where\n c n k | n < k = 0\n | otherwise = product [k + 1..n] `div` product [1..n - k]\n"}, {"source_code": "import Data.Array (Array, Ix, array, (!), range)\nimport qualified Data.ByteString.Char8 as BS\n\nmemorize :: Ix a => (a -> b) -> (a, a) -> (a -> b)\nmemorize func rng = let memoArray = array rng [(i, func i) | i <- (range rng)]\n in (!) memoArray\n\ncombination :: (Ix a, Num a, Num b) => (a, a) -> b\ncombination = memorize cmb ((0, 0), (100, 100))\n where cmb (a, b)\n | b == 0 || a == b = 1\n | otherwise = combination (a - 1, b - 1) + combination (a - 1, b)\n\nsolve :: Int -> Int -> Int -> Integer\nsolve n m t = sum [ combination (n, i) * combination (m, t - i) |\n i <- [4..t-1], i <= n, t - i >= 1, t - i <= m ]\n\nmain :: IO ()\nmain = do cs <- BS.getContents\n let ws = BS.words cs\n n = bReadInt $ ws !! 0\n m = bReadInt $ ws !! 1\n t = bReadInt $ ws !! 2\n print $ solve n m t\n\nbReadInt :: BS.ByteString -> Int\nbReadInt = toNumber . BS.readInt\n\nbReadInteger :: BS.ByteString -> Integer\nbReadInteger = toNumber . BS.readInteger\n\ntoNumber :: Num a => Maybe (a, BS.ByteString) -> a\ntoNumber (Just (x, _)) = x\ntoNumber Nothing = 0\n"}, {"source_code": "-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n-- File Name : 0001A.hs\n-- Creation Date : 17-10-2012\n-- Last Modified : Fri 19 Oct 2012 07:57:44 PM EEST\n-- Created By : Greg Liras \n--_._._._._._._._._._._._._._._._._._._._._.\n\n{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\n\nbinom :: (Integral a) => a -> a -> a\n--binom n k = product [k+1..n] `div` product [1..n-k]\nbinom n k = foldl (\\z i -> (z * (n-i+1)) `div` i) 1 [1..k]\n\n\nmain :: IO ()\nmain = \n do\n all <- BS.getContents\n let Just (n, r1) = readInteger all\n let Just (m, r2) = readInteger r1\n let Just (t, _) = readInteger r2\n --print $ (binom n 4) * m * binom (n+m-5) (t-5)\n\n print $ sum [ (binom m g) * (binom n (t-g)) | g <- [1..min (t-4) m]]\n where \n readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let \n (xs, t) = readMany readf r\n in \n (x : xs, t)\n Nothing -> ([], s)\n"}], "negative_code": [{"source_code": "-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n-- File Name : 0001A.hs\n-- Creation Date : 17-10-2012\n-- Last Modified : Fri 19 Oct 2012 07:55:14 PM EEST\n-- Created By : Greg Liras \n--_._._._._._._._._._._._._._._._._._._._._.\n\n{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\n\nbinom :: (Integral a) => a -> a -> a\n--binom n k = product [k+1..n] `div` product [1..n-k]\nbinom n k = foldl (\\z i -> (z * (n-i+1)) `div` i) 1 [1..k]\n\n\nmain :: IO ()\nmain = \n do\n all <- BS.getContents\n let Just (n, r1) = readInteger all\n let Just (m, r2) = readInteger r1\n let Just (t, _) = readInteger r2\n print $ (binom n 4) * m * binom (n+m-5) (t-5)\n\n print $ sum [ (binom m g) * (binom n (t-g)) | g <- [1..min (t-4) m]]\n where \n readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let \n (xs, t) = readMany readf r\n in \n (x : xs, t)\n Nothing -> ([], s)\n"}, {"source_code": "-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n-- File Name : 0001A.hs\n-- Creation Date : 17-10-2012\n-- Last Modified : Fri 19 Oct 2012 06:44:46 PM EEST\n-- Created By : Greg Liras \n--_._._._._._._._._._._._._._._._._._._._._.\n\n{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\n\nbinom :: (Integral a) => a -> a -> a\nbinom n k = product [k+1..n] `div` product [1..n-k]\n\nmain :: IO ()\nmain = \n do\n all <- BS.getContents\n let Just (n, r1) = readInteger all\n let Just (m, r2) = readInteger r1\n let Just (t, _) = readInteger r2\n print $ (binom n 4) * (binom m 1) * (binom (n+m-5) (t-5))\n where \n readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let \n (xs, t) = readMany readf r\n in \n (x : xs, t)\n Nothing -> ([], s)\n"}, {"source_code": "import Data.List\nimport Data.Char\nimport Data.Maybe\nimport Control.Monad\nimport Control.Applicative\nimport Data.Array\nimport Data.Bits\n\nmain = do\n [n,m,t] <- getList\n let list = [toInteger $ c_n_k n x * c_n_k m y | x <- [4..n], y <- [1..m], x+y == t]\n print $ sum list\n where \n getList = fmap (map read . words) getLine :: IO [Int]\n c_n_k :: Int -> Int -> Int\n c_n_k n k = product [1..n] `div` (product [1..k] * product [1..n-k]) "}, {"source_code": "import Data.List\nimport Data.Char\nimport Data.Maybe\nimport Control.Monad\nimport Control.Applicative\nimport Data.Array\nimport Data.Bits\n\nmain = do\n [n,m,t] <- getList\n let list = [c_n_k n x * c_n_k m y | x <- [4..n], y <- [1..m], x+y == t]\n print $ sum list\n where \n getList = fmap (map read . words) getLine :: IO [Int]\n c_n_k n k = product [1..n] `div` (product [1..k] * product [1..n-k]) "}, {"source_code": "{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\n-- solution for: http://codeforces.com/problemset/problem/131/C\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\nchoose n 0 = 1\nchoose 0 k = 0\nchoose n k = toInteger((choose (n-1) (k-1) * n) `div` k)\n\nsolve [n,m,t] = (choose n 4) * (choose m 1) * (choose (n+m-5) (t-5))\n\nmain = \n do all <- BS.getContents\n let (x, _) = readMany readInt all\n print (solve x)\n where readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let (xs, t) = readMany readf r\n in (toInteger(x) : xs, t)\n Nothing -> ([], s)\n"}, {"source_code": "-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n-- File Name : 0001A.hs\n-- Creation Date : 17-10-2012\n-- Last Modified : Fri 19 Oct 2012 07:28:41 PM EEST\n-- Created By : Greg Liras \n--_._._._._._._._._._._._._._._._._._._._._.\n\n{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\n\nbinom :: (Integral a) => a -> a -> a\n--binom n k = product [k+1..n] `div` product [1..n-k]\nbinom n k = foldl (\\z i -> (z * (n-i+1)) `div` i) 1 [1..k]\n\n\nmain :: IO ()\nmain = \n do\n all <- BS.getContents\n let Just (n, r1) = readInteger all\n let Just (m, r2) = readInteger r1\n let Just (t, _) = readInteger r2\n print $ (binom n 4) * m * sum (map (\\s -> binom (n+m-5) s) [0..(t-5)])\n where \n readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let \n (xs, t) = readMany readf r\n in \n (x : xs, t)\n Nothing -> ([], s)\n"}, {"source_code": "-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n-- File Name : 0001A.hs\n-- Creation Date : 17-10-2012\n-- Last Modified : Fri 19 Oct 2012 06:45:50 PM EEST\n-- Created By : Greg Liras \n--_._._._._._._._._._._._._._._._._._._._._.\n\n{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\n\nbinom :: (Integral a) => a -> a -> a\n--binom n k = product [k+1..n] `div` product [1..n-k]\nbinom n k = foldl (\\z i -> (z * (n-i+1)) `div` i) 1 [1..k]\n\nmain :: IO ()\nmain = \n do\n all <- BS.getContents\n let Just (n, r1) = readInteger all\n let Just (m, r2) = readInteger r1\n let Just (t, _) = readInteger r2\n print $ (binom n 4) * (binom m 1) * (binom (n+m-5) (t-5))\n where \n readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let \n (xs, t) = readMany readf r\n in \n (x : xs, t)\n Nothing -> ([], s)\n"}, {"source_code": "-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n-- File Name : 0001A.hs\n-- Creation Date : 17-10-2012\n-- Last Modified : Fri 19 Oct 2012 06:50:39 PM EEST\n-- Created By : Greg Liras \n--_._._._._._._._._._._._._._._._._._._._._.\n\n{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\n\nbinom :: (Integral a) => a -> a -> a\n--binom n k = product [k+1..n] `div` product [1..n-k]\nbinom n k = foldl (\\z i -> (z * (n-i+1)) `div` i) 1 [1..k]\n\nmain :: IO ()\nmain = \n do\n all <- BS.getContents\n let Just (n, r1) = readInteger all\n let Just (m, r2) = readInteger r1\n let Just (t, _) = readInteger r2\n print $ (binom n 4) * m * (binom (n+m-5) (t-5))\n where \n readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let \n (xs, t) = readMany readf r\n in \n (x : xs, t)\n Nothing -> ([], s)\n"}], "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8"} {"source_code": "module Main where\nimport Control.Applicative\nimport Data.List\nmain :: IO ()\nmain = do\n _ <- getLine\n cs <- map read . words <$> getLine :: IO [Int]\n [x,y] <- map read . words <$> getLine :: IO [Int]\n let beginnerSizes = scanl1 (+) cs\n numKids = sum cs\n intermediateSizes = map (numKids -) beginnerSizes\n -- print beginnerSizes\n -- print intermediateSizes\n case find (\\(bSize,iSize,_) -> x <= bSize && bSize <= y && x <= iSize && iSize <= y) $\n zip3 beginnerSizes intermediateSizes [1..] of\n Just (_,_,res) -> print (res + 1)\n Nothing -> print (0 :: Int)\n -- correctTimes <- map read . words <$> getLine :: IO [Int]\n -- wrongTimes <- map read . words <$> getLine :: IO [Int]\n -- let minCorrectTime = minimum correctTimes\n -- v = maximum (2*minCorrectTime : correctTimes)\n -- minWrongTime = minimum wrongTimes\n -- print $ if minWrongTime <= v then -1 else v\n", "positive_code": [{"source_code": "import Control.Applicative\nimport Control.Monad\nimport Control.Arrow\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport Text.Printf\n\nmain = do\n\tgetLine\n\tcs <- map read . words <$> getLine\n\t[ x, y ] <- map read . words <$> getLine\n\n\tlet\n\t\tok as = let tot = sum as in x <= tot && tot <= y\n\n\t\tks = [ k + 1 | k <- [ 1 .. length cs ], ok ( take k cs ), ok ( drop k cs ) ]\n\t\n\tprint $ if null ks then 0 else head ks\n"}, {"source_code": "import Control.Applicative\nmain :: IO ()\nmain = do\n getLine\n cs <- map read <$> words <$> getLine \n ls <- map read <$> words <$> getLine \n let x = ls !! 0 \n y = ls !! 1\n print . (solve x y) $ cs\n \nsolve :: Int -> Int -> [Int] -> Int\nsolve lb ub cs = helper 1 0 (sum cs) cs\n where\n helper k beginner intermediate left \n | okay beginner && okay intermediate = k\n | null left = 0\n | otherwise = helper (k+1) (beginner + head left) (intermediate - head left) (tail left)\n okay n = lb <= n && n <= ub\n\n"}, {"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Monad.State\nimport Data.Array\n-- import Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\n-- import Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\n-- import Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\nimport System.IO\n-- import Debug.Trace\n\ngetInts = fmap (map read . words) getLine\n-- getInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n m <- readLn\n cs <- getInts\n [x, y] <- getInts\n\n let a = [k | k <- [1..m], let a = sum (take (k-1) cs), let b = sum (drop (k-1) cs), a `elem` [x..y], b `elem` [x..y]]\n\n print $ if null a then 0 else head a\n"}, {"source_code": "import Control.Monad (liftM)\nimport Data.Char (ord)\nimport Data.List (intercalate)\n\nsolve :: (Int, Int) -> [Int] -> Int\nsolve (x, y) as = case answers of\n [] -> 0\n as -> head as\n where\n answers = map fst $ filter (good . snd) $ zip [1..] $ scanl (+) 0 as\n good s1 = x <= s1 && s1 <= y && x <= s2 && s2 <= y\n where\n s2 = sum as - s1\n \nmain :: IO ()\nmain = do\n getLine\n as <- reads\n [x, y] <- reads\n print $ solve (x, y) as\n\n where\n reads :: Num a => IO [a]\n reads = liftM (map read . words) getLine\n where\n read ('-':s) = (-1) * read s\n read s = read' 0 s\n read' a \"\" = a\n read' a (c:s) = read' (10 * a + fromIntegral (ord c - ord '0')) s\n\n prints :: Show a => [a] -> IO ()\n prints = putStrLn . intercalate \" \" . map show"}, {"source_code": "solve :: [[Int]] -> Int\nsolve (_:c:[x, y]:_) =\n let cSum = sum c\n partialSums = zip [1..] $ scanl1 (+) c\n inRange :: Int -> Bool\n inRange q = q >= x && q <= y\n matching = filter (\\(_, q) -> inRange q && inRange (cSum - q)) partialSums\n in\n if null matching then 0 else 1 + (fst $ head matching)\n\nmain :: IO ()\nmain =\n interact $ show . solve . map (map read . words) . lines\n"}, {"source_code": "partsum :: [Int] -> [Int]\npartsum [] = []\npartsum ns = partsum' ns 0\n where partsum' [] _ = []\n partsum' (s:l) c = (c + s) : partsum' l (c + s)\n\nmain = do\n n <- read `fmap` getLine :: IO Int\n nums <- (map read . words) `fmap` getLine :: IO [Int]\n [x, y] <- (map read . words) `fmap` getLine :: IO [Int]\n let sum = partsum nums !! (n - 1)\n let fg = take n $ zip (0 : partsum nums) [1..n + 1]\n let res = head $ [snd q | q <- fg, fst q >= x, fst q <= y, sum - fst q >= x, sum - fst q <= y] ++ [0]\n putStrLn $ show res"}, {"source_code": "#!/usr/bin/env runghc\nmain = do\n c <- getContents\n putStr . unlines . solve . lines $ c\n\nsolve::[String]->[String]\nsolve [] = []\nsolve (m:ci:xy:cs) = (show . f $ zip3 [2..] (scanl1 (+) c) (tail . scanr (+) 0 $ c)): solve cs\n where\n c = map read . words $ ci\n [x,y] = map read . words $ xy\n f [] = 0\n f ((i,a,b):ss) = if x<=a && a<=y && x<=b && b<=y then i else f ss\n"}, {"source_code": "main = do\n input <- getLine\n let m = head (getList input)\n input <- getLine\n let list = getList input\n input <- getLine\n let [x,y] = getList input\n putStr $ show $ getPoint 1 x y list 0 (sum list) \n\ngetList :: String -> [Int]\ngetList x = map read $ words x\n\n\ninRange :: Int -> Int -> Int -> Bool\ninRange v x y = (x <= v && v <= y)\n\ngetPoint :: Int -> Int -> Int -> [Int] -> Int -> Int -> Int\ngetPoint returnVar x y [] l r = 0\ngetPoint returnVar xLimit yLimit (x:xs) leftSum rightSum =\n if (inRange leftSum xLimit yLimit) && (inRange rightSum xLimit yLimit) then returnVar\n else getPoint (returnVar + 1) xLimit yLimit xs (leftSum + x) (rightSum - x)\n"}, {"source_code": "solve :: Int -> [Integer] -> Integer -> Integer -> Integer\nsolve n c l r = find 1 sums\n where\n parts = map ((flip splitAt) c) [0..n]\n sums = map (\\(x, y) -> (sum x, sum y)) parts\n find _ [] = 0\n find pos ((x, y):xs)\n | all id [x >= l, x <= r, y >= l, y <= r] = pos\n | otherwise = find (pos + 1) xs\n\nmain = do\n n <- getLine\n c <- fmap words getLine\n [x, y] <- fmap words getLine\n print $ solve (read n) (map read c) (read x) (read y) \n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \nprocess _ _ _ _ _ [] = -1\nprocess a b sums cs n (s:ss) | and [ cs>=a,cs <=b, sums-cs >=a, sums-cs <=b] = n\n | otherwise = process a b sums (cs+s) (n+1) ss\n\n\nmain= do\n\tgetLine\n\ts<- map read. words <$> getLine ::IO [Int]\n\t[a,b]<- map read. words <$> getLine ::IO [Int]\n\tprint $ (+) 1 $ process a b (sum s) 0 0 s"}, {"source_code": "import Control.Applicative \n\nfun :: Int -> Int -> Int -> Int -> Int -> [Int] -> Int \nfun llevo total x y v [] = if (llevo>=x && llevo<=y && total-llevo>=x && total-llevo<=y) then v else 0\nfun llevo total x y v (l:ls) = if (llevo>=x && llevo<=y && total-llevo>=x && total-llevo<=y) then v else fun (llevo+l) total x y (v+1) ls\n\nmain = do \n k <- getLine\n ls <- map read.words <$> getLine\n [x,y] <- map read.words <$> getLine\n let total = sum ls \n putStrLn.show $ fun 0 total x y 1 ls\n"}, {"source_code": "import Data.List\nfind x\n\t| x>=0 = show x\n\t| otherwise = \"No solution\"\n\nhead' [] = (-1,([],[]))\nhead' x = head x\n\nparse :: String -> [Int]\nparse l = map read $ words l\n\ncal _ students xy =\n\tlet x = xy !! 0\n\t y = xy !! 1\n\tin (+1) $ fst $ head' $filter (chk x y) $ sp students \n\nsp ss = \n\tlet si = [1..(length ss) -1 ]\n\tin map (\\x -> (x , splitAt x ss)) si\n\n\nchk x y tup = (chkk x y $ sum $ fst $ snd tup) && (chkk x y $ sum $ snd $ snd tup)\nchkk x y n = (x <= n) && ( n <= y)\n\nmain = do \n\tl1 <- getLine \n\tl2 <- getLine\n\tl3 <- getLine\n\tputStr $ show $ cal (parse l1) (parse l2) (parse l3)\n"}, {"source_code": "import Data.List\nimport Data.Char\nimport Control.Monad\nimport Data.Maybe\nimport Control.Applicative\nimport Debug.Trace\nimport qualified Data.ByteString.Char8 as B\n\ndebug x = trace (show x) x\n(|>) x f = f x; infixl 1 |>\n(||>) mx f = mx >>= (return . f); infixl 1 ||>\n\nsolve cs total x y =\n solve' cs 0 2\n\n where\n solve' [] _ _ = 0\n solve' (c:cs) sum r =\n if check sum' then r\n else solve' cs sum' (r+1)\n where\n sum' = sum + c\n check sum =\n x <= sum && sum <= y && x <= (total-sum) && (total-sum) <= y\n\nmain = do\n ls <- getContents ||> lines\n cs <- ls !! 1 |> words |> map read |> return\n [x,y] <- ls !! 2 |> words |> map read |> return\n print $ solve cs (sum cs) x y\n"}], "negative_code": [{"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Monad.State\nimport Data.Array\n-- import Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\n-- import Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\n-- import Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\nimport System.IO\n-- import Debug.Trace\n\ngetInts = fmap (map read . words) getLine\n-- getInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n m <- readLn\n cs <- getInts\n [x, y] <- getInts\n\n let a = [s | s <- [1..m], let a = sum (take s cs), let b = sum (drop s cs), a `elem` [x..y], b `elem` [x..y]]\n\n print $ if null a then 0 else head a\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \nprocess _ _ _ _ _ [] = 0\nprocess a b sums cs n (s:ss) | and [ cs>=a,cs <=b, sums-cs >=a, sums-cs <=b] = n\n | otherwise = process a b sums (cs+s) (n+1) ss\n\n\nmain= do\n\tgetLine\n\ts<- map read. words <$> getLine ::IO [Int]\n\t[a,b]<- map read. words <$> getLine ::IO [Int]\n\tprint $ process a b (sum s) 0 0 s"}, {"source_code": "import Control.Applicative\nimport Data.List\n \nprocess _ _ _ _ _ [] = 0\nprocess a b sums cs n (s:ss) | and [ cs>=a,cs <=b, sums-cs >=a, sums-cs <=b] = n\n | otherwise = process a b sums (cs+s) (n+1) ss\n\n\nmain= do\n\tgetLine\n\ts<- map read. words <$> getLine ::IO [Int]\n\t[a,b]<- map read. words <$> getLine ::IO [Int]\n\tprint $ (+) 1 $ process a b (sum s) 0 0 s"}], "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b"} {"source_code": "main :: IO ()\nmain = getContents >>= mapM_ (putStrLn . concatMap show) . solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> [[Int]]\nsolve xs = [ [ 1 - sum [ xs !! i' !! j' | j' <- [0..2], i' <- [0..2], abs (i - i') + abs (j - j') < 2 ] `mod` 2 | j <- [0..2] ] | i <- [0..2] ]\n", "positive_code": [{"source_code": "import qualified Data.ByteString.Char8 as B\nimport Data.List\n\nmain = mapM_ (putStrLn . concatMap show) . solve . slice . map (toInteger . maybe 0 fst . B.readInt) . B.words =<< B.getContents\n\nslice :: [Integer] -> [[Integer]]\nslice (a : b : c : xs) = [a, b, c] : slice xs\nslice xs = []\n\nsolve :: [[Integer]] -> [[Integer]]\nsolve ns = [[(sum [ns!!x'!!y' | [x',y'] <- [[x-1,y], [x,y-1], [x,y], [x,y+1], [x+1,y]], x'>=0, x'<3, y'>=0, y'<3] + 1) `mod` 2 | y <-[0..2]] | x <- [0..2]]\n"}, {"source_code": "import Data.List\nimport Data.List.Split\n\n(|>) x f = f x\nmain = interact solve\n\nsolve contents = let\n toggles = contents |> lines |> map words |> map (map read) :: [[Int]]\n states = toggleThem toggles\n in states |> chunksOf 3 |> unlines\n \ntoggleThem toggles = [state toggles x y | x <- [0..2], y <- [0..2]]\n\nstate toggles x y = let\n count = toggleCount toggles x y\n in if even count then '1' else '0'\n \ntoggleCount toggles x y = toggleTimes toggles (x - 1) y\n + toggleTimes toggles x y\n + toggleTimes toggles (x + 1) y\n + toggleTimes toggles x (y - 1)\n + toggleTimes toggles x (y + 1)\n \ntoggleTimes toggles x y = if isValid x y then toggles !! x !! y else 0\n\nisValid x y = x >= 0 && x < 3 && y >= 0 && y < 3\n\n"}, {"source_code": "import Data.List\nimport Control.Monad\nimport qualified Data.Text as T\nimport Data.Maybe\n\n(f3, x, o, os ) = ((\\a b c -> a . b . c), not, id, replicate 9 o)\n\nto01 = map T.unpack . T.chunksOf 3 . T.pack . map (\\x -> if x then '1' else '0') \n\nsolve [a,b,c,d,e,f,g,h,i] =\n zipWith ($) \n (zipWith3 f3 \n (zipWith3 f3 (if a==1 then [x,x,o,x,o,o,o,o,o] else os)\n (if b==1 then [x,x,x,o,x,o,o,o,o] else os)\n (if c==1 then [o,x,x,o,o,x,o,o,o] else os)) \n (zipWith3 f3 (if d==1 then [x,o,o,x,x,o,x,o,o] else os)\n (if e==1 then [o,x,o,x,x,x,o,x,o] else os)\n (if f==1 then [o,o,x,o,x,x,o,o,x] else os))\n (zipWith3 f3 (if g==1 then [o,o,o,x,o,o,x,x,o] else os)\n (if h==1 then [o,o,o,o,x,o,x,x,x] else os)\n (if i==1 then [o,o,o,o,o,x,o,x,x] else os)))\n $ replicate 9 True\n \nmain = do\n a <- concat <$> replicateM 3 (map(read :: String -> Int) . words <$> getLine)\n mapM_ putStrLn $ to01 $ solve $ map (`mod` 2) a \n"}, {"source_code": "import Control.Monad (liftM)\nimport Prelude hiding (reads)\n\nreads :: Read a => IO [a]\nreads = liftM (map read . words) getContents\n\nsolve :: [Int] -> [Int]\nsolve [a11, a12, a13,\n a21, a22, a23,\n a31, a32, a33]\n = map (\\n -> (n - 1) `mod` 2)\n [a11 + a12 + a21, a11 + a12 + a13 + a22, a12 + a13 + a23,\n a11 + a21 + a22 + a31, a12 + a21 + a22 + a23 + a32, a13 + a22 + a23 + a33,\n a21 + a31 + a32, a22 + a31 + a32 + a33, a23 + a32 + a33] \n\nprint' :: Show a => [a] -> IO ()\nprint' [a1, a2, a3, a4, a5, a6, a7, a8, a9] = do\n mapM_ (\\x -> putStrLn (concatMap show x))\n [[a1, a2, a3], [a4, a5, a6], [a7, a8, a9]]\n\nmain :: IO ()\nmain = reads >>= print' . solve"}, {"source_code": "f::[String]->[[Int]]\nf []=[]\nf (s:strs)=let l=map read (words s)::[Int]\n in l:f strs\n\nf3::Int->Int->[[Int]]->String\nf3 3 _ _=\"\"\nf3 x y ds=let s=sum $ [ds!!(y+y1)!!(x+x1) | (y1,x1)<-[(0::Int,0::Int),(0,1),(0,(-1)),(1,0),((-1),0)],0<=x+x1,x+x1<3,0<=y+y1,y+y1<3]\n in (show ((s+1) `mod` 2))++f3 (x+1) y ds\n\nf2::Int->[[Int]]->[String]\nf2 3 _=[]\nf2 y ds=(f3 (read \"0\"::Int) y ds):(f2 (y+1) ds)\n\nmain = do\n es<-getContents\n mapM_ putStrLn $ f2 0 $ f (lines es)"}, {"source_code": "main :: IO ()\nmain = getContents >>= mapM_ (putStrLn . concatMap show) . solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> [[Int]]\nsolve xs = [ [ 1 - sum [ xs !! i' !! j' | j' <- [0..2], i' <- [0..2], abs (i - i') + abs (j - j') < 2 ] `mod` 2 | j <- [0..2] ] | i <- [0..2] ]\n-- solve xs = foldl' f (replicate 3 $ replicate 3 1)\n-- [ (i, j, x) | (j, xs') <- zip [0..2] xs, (i, x) <- zip [0..2] xs' ]\n-- where f :: [[Int]] -> (Int, Int, Int) -> [[Int]]\n-- f ys (i, j, x) = [ [ if abs (i' - i) + abs (j' - j) < 2 && odd x then 1 - y else y\n-- | (i', y) <- zip [0..] ys' ] | (j', ys') <- zip [0..] ys ]\n"}, {"source_code": "import Data.List (foldl')\n\nmain :: IO ()\nmain = getContents >>= mapM_ (putStrLn . concatMap show) . solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> [[Int]]\nsolve xs = foldl' f (replicate 3 $ replicate 3 1)\n [ (i, j, x) | (j, xs') <- zip [0..2] xs, (i, x) <- zip [0..2] xs' ]\n where f :: [[Int]] -> (Int, Int, Int) -> [[Int]]\n f ys (i, j, x) = [ [ if abs (i' - i) + abs (j' - j) < 2 && odd x then 1 - y else y\n | (i', y) <- zip [0..] ys' ] | (j', ys') <- zip [0..] ys ]\n"}, {"source_code": "main :: IO ()\nmain = getContents >>= mapM_ (putStrLn . concatMap show) . solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> [[Int]]\nsolve xs = [ [ (1 + sum [ xs !! i' !! j' | j' <- [0..2], i' <- [0..2], abs (i - i') + abs (j - j') < 2 ]) `mod` 2 | j <- [0..2] ] | i <- [0..2] ]\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.Array\n\nq::[[Int]]\nq=[[1,2,4],[1,2,3,5],[2,3,6],[1,4,7,5],[2,4,5,6,8],[3,5,6,9],[7,8,4],[8,7,9,5],[9,8,6]]\n\nprocess::[Int]->Array Int Int->Int->[Int]\nprocess [] a _ = elems a\nprocess (x:xs) a n | even x = process xs a (n+1)\n | otherwise = process xs (a//(map (\\z->(z,1-a!z)) (q!!n))) (n+1) \n\n\nchunks n [] = []\nchunks n x = (take n x ): (chunks n (drop n x))\n\nmain= do\n\tx<- map read. words <$> getContents::IO [Int]\n\tlet b= listArray (1,9) [1,1,1,1,1,1,1,1,1]\n\tputStrLn $ unlines $ map concat $ chunks 3 $ map show $ process x b 0\n\t"}], "negative_code": [{"source_code": "import Data.List\nimport Data.List.Split\n\n(|>) x f = f x\nmain = interact solve\n\nsolve contents = let\n toggles = contents |> lines |> map words |> map (map read) :: [[Int]]\n states = toggleThem toggles\n in states |> chunksOf 3 |> unlines |> show\n \ntoggleThem toggles = [state toggles x y | x <- [0..2], y <- [0..2]]\n\nstate toggles x y = let\n count = toggleCount toggles x y\n in if even count then '1' else '0'\n \ntoggleCount toggles x y = toggleTimes toggles (x - 1) y\n + toggleTimes toggles x y\n + toggleTimes toggles (x + 1) y\n + toggleTimes toggles x (y - 1)\n + toggleTimes toggles x (y + 1)\n \ntoggleTimes toggles x y = if isValid x y then toggles !! x !! y else 0\n\nisValid x y = x >= 0 && x < 3 && y >= 0 && y < 3\n\n"}, {"source_code": "import Data.List\nimport Control.Monad\nimport qualified Data.Text as T\n\n(f3, x, o, os ) = ((\\a b c -> a . b . c), not, id, replicate 9 o)\n\nto01 = map T.unpack . T.chunksOf 3 . T.pack . map (\\x -> if x then '1' else '0') \n\nsolve [a,b,c,d,e,f,g,h,i] =\n zipWith ($) \n (zipWith3 f3 \n (zipWith3 f3 (if a==1 then [x,x,o,x,o,o,o,o,o] else os)\n (if b==1 then [x,x,x,o,x,o,o,o,o] else os)\n (if c==1 then [o,x,x,o,o,x,o,o,o] else os)) \n (zipWith3 f3 (if d==1 then [x,o,o,x,x,o,x,o,o] else os)\n (if e==1 then [o,x,o,x,x,x,o,x,o] else os)\n (if f==1 then [o,o,x,o,x,x,o,o,x] else os))\n (zipWith3 f3 (if g==1 then [o,o,o,x,x,o,x,o,o] else os)\n (if h==1 then [o,o,o,x,x,x,o,x,o] else os)\n (if i==1 then [o,o,o,o,o,x,o,x,x] else os)))\n $ replicate 9 True\n \nmain = do\n a <- concat <$> replicateM 3 (map(read :: String -> Int) . words <$> getLine)\n mapM_ putStrLn $ to01 $ solve $ map (`mod` 2) a \n"}, {"source_code": "import Data.List\nimport Control.Monad\nimport qualified Data.Text as T\nimport Data.Maybe\n\n(f3, x, o, os, zeroes ) = ((\\a b c -> a . b . c), not, id, replicate 9 o, replicate 9 0)\n\nto01 = map T.unpack . T.chunksOf 3 . T.pack . map (\\x -> if x then '1' else '0') \n\nsolve [a,b,c,d,e,f,g,h,i] js =\n zipWith ($) \n (zipWith3 f3 \n (zipWith3 f3 (if a==1 then [x,x,o,x,o,o,o,o,o] else os)\n (if b==1 then [x,x,x,o,x,o,o,o,o] else os)\n (if c==1 then [o,x,x,o,o,x,o,o,o] else os)) \n (zipWith3 f3 (if d==1 then [x,o,o,x,x,o,x,o,o] else os)\n (if e==1 then [o,x,o,x,x,x,o,x,o] else os)\n (if f==1 then [o,o,x,o,x,x,o,o,x] else os))\n (zipWith3 f3 (if g==1 then [o,o,o,x,x,o,x,o,o] else os)\n (if h==1 then [o,o,o,x,x,x,o,x,o] else os)\n (if i==1 then [o,o,o,o,o,x,o,x,x] else os)))\n js\n \nmain = do\n a <- concat <$> replicateM 3 (map(read :: String -> Int) . words <$> getLine)\n mapM_ putStrLn $ to01 $ fst $ until ((==zeroes).snd) (\\(x,y) -> let b = findIndex (/=0) y in if isNothing b then (x,y) else let z = take 9 $ replicate (fromJust b) 0 ++ [1] ++ repeat 0 in (solve z x, zipWith (-) y z)) (replicate 9 True, a)\n"}, {"source_code": "f::[String]->[[Int]]\nf []=[]\nf (s:strs)=let l=map read (words s)::[Int]\n in l:f strs\n\nf3::Int->Int->[[Int]]->[Int]\nf3 3 _ _=[]\nf3 x y ds=let s=sum $ [ds!!(y+y1)!!(x+x1) | (y1,x1)<-[(0::Int,0::Int),(0,1),(0,(-1)),(1,0),((-1),0)],0<=x+x1,x+x1<3,0<=y+y1,y+y1<3]\n in ((s+1) `mod` 2) : f3 (x+1) y ds\n\nf2::Int->[[Int]]->[String]\nf2 3 _=[]\nf2 y ds=(unwords (map show (f3 (read \"0\"::Int) y ds))):(f2 (y+1) ds)\n\nmain = do\n es<-getContents\n mapM_ putStrLn $ f2 0 $ f (lines es)"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.Array\n\nq::[[Int]]\nq=[[1,2,4],[1,2,3,5],[2,3,6],[1,4,7,5],[2,4,5,6,8],[3,5,6,9],[7,8,4],[8,7,9,5],[9,8,6]]\n\nprocess::[Int]->Array Int Int->Int->[Int]\nprocess [] a _ = elems a\nprocess (x:xs) a n | even x = process xs a (n+1)\n | otherwise = process xs (a//(map (\\z->(z,1-a!z)) (q!!n))) (n+1) \n\n\nchunks n [] = []\nchunks n x = (take n x ): (chunks n (drop n x))\n\nmain= do\n\tx<- map read. words <$> getContents::IO [Int]\n\tlet b= listArray (1,9) [1,1,1,1,1,1,1,1,1]\n\tputStrLn $ unlines $ map unwords $ chunks 3 $ map show $ process x b 0\n\t"}], "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6"} {"source_code": "\nmain = interact ((++\"\\n\") . show . solve . lines)\n\nsolve [s1, s2] =\n let an1 = 0 :(annotate s1 s2)\n an2 = reverse $ annotate (reverse s1) (reverse s2)\n an2' = an2\n in find_opt an1 an2' (length s2)\n\nannotate s t = (annotate' s t 0)\n\nannotate' [] [] n = []\nannotate' s [] n = n : (annotate' (tail s) [] n)\nannotate' (sx:sr) (tx:tr) n\n | sx == tx = (n + 1) : (annotate' sr tr (n + 1))\n | otherwise = n : (annotate' sr (tx:tr) n)\n\n-- find_opt a1 a2 n = a2\nfind_opt a1 a2 n = find_opt' a1 a2 n 0\n\nfind_opt' (ax:_) [] n diff\n | ax >= n = diff\n | otherwise = diff - 1\nfind_opt' (a1x:a1r) (a2x:a2r) n diff \n | a1x + a2x >= n = max diff $ find_opt' (a1x:a1r) a2r n (diff + 1)\n | otherwise = find_opt' a1r (a2x:a2r) n (diff - 1) \n", "positive_code": [{"source_code": "import Control.Monad\nimport Data.List\n \nreadInt :: IO(Int)\nreadInt = fmap read getLine\n\nreadlist :: IO([Integer])\nreadlist = fmap (map read . words) getLine\n\nloop :: Int -> IO() -> IO()\nloop 0 f = do\n f; loop 0 f\nloop 1 f = f\nloop x f = do\n f; loop (x - 1) f\n\n\nmain = do\n\ts <- getLine\n\tt <- getLine\n\tprint (solve s t)\n\n\nsolve :: String -> String -> Int\nsolve s t = (foldl1 max . zipWith (-) rv $ v) - 1\n\twhere \n\t\tv = (-1):(match (+) s t 0)\n\t\trv = reverse v' \n\t\t\twhere v' = (length s):(match (-) (reverse s) (reverse t) $ (length s - 1))\n\nmatch :: (Int -> Int -> Int) -> String -> String -> Int -> [Int]\nmatch _ _ [] _ = []\nmatch f (x0:xs) y@(y0:ys) pos = \n\tif x0 == y0 then\n\t\t(pos:(match f xs ys (pos `f` 1)))\n\telse\n\t\tmatch f xs y (pos `f` 1)\n"}, {"source_code": "\nmain = interact ((++\"\\n\") . show . solve . lines)\n\nsolve [s1, s2] =\n let an1 = 0 :(annotate s1 s2)\n an2 = reverse $ annotate (reverse s1) (reverse s2)\n an2' = an2\n in find_opt an1 an2' (length s2)\n\nannotate s t = (annotate' s t 0)\n\nannotate' [] [] n = []\nannotate' s [] n = n : (annotate' (tail s) [] n)\nannotate' (sx:sr) (tx:tr) n\n | sx == tx = (n + 1) : (annotate' sr tr (n + 1))\n | otherwise = n : (annotate' sr (tx:tr) n)\n\n-- find_opt a1 a2 n = a2\nfind_opt a1 a2 n = find_opt' a1 a2 n 0\n\nfind_opt' (ax:_) [] n diff\n | ax >= n = diff\n | otherwise = diff - 1\nfind_opt' (a1x:a1r) (a2x:a2r) n diff \n | a1x + a2x >= n = max diff $ find_opt' (a1x:a1r) a2r n (diff + 1)\n | otherwise = find_opt' a1r (a2x:a2r) n (diff - 1) \n"}, {"source_code": "import Control.Monad\nimport Data.List\n \nreadInt :: IO(Int)\nreadInt = fmap read getLine\n\nreadlist :: IO([Integer])\nreadlist = fmap (map read . words) getLine\n\nloop :: Int -> IO() -> IO()\nloop 0 f = do\n f; loop 0 f\nloop 1 f = f\nloop x f = do\n f; loop (x - 1) f\n\n\nmain = do\n\ts <- getLine\n\tt <- getLine\n\tprint (solve s t)\n\n\nsolve :: String -> String -> Int\nsolve s t = (foldl1 max . zipWith (-) rv $ v) - 1\n\twhere \n\t\tv = (-1):(match (+) s t 0)\n\t\trv = reverse v' \n\t\t\twhere v' = (length s):(match (-) (reverse s) (reverse t) $ (length s - 1))\n\nmatch :: (Int -> Int -> Int) -> String -> String -> Int -> [Int]\nmatch _ _ [] _ = []\nmatch f (x0:xs) y@(y0:ys) pos = \n\tif x0 == y0 then\n\t\t(pos:(match f xs ys (pos `f` 1)))\n\telse\n\t\tmatch f xs y (pos `f` 1)\n"}], "negative_code": [], "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f"} {"source_code": "doit :: Integer -> Integer -> [Integer]\ndoit p k = map snd . takeWhile (/= (0, 0)) . iterate (f . fst) $ (p, 0)\n where f x = let ans = x `mod` k\n in ((x - ans) `div` (-k), ans)\n\nmain = do\n [p, k] <- fmap (fmap read . words) getLine\n let ans = drop 1 . doit p $ k\n print . length $ ans\n putStrLn . unwords . map show $ ans\n", "positive_code": [{"source_code": "doit :: Integer -> Integer -> [Integer]\ndoit 0 _ = []\ndoit p k = tmp : doit ((p - tmp) `div` (-k)) k\n where tmp = p `mod` k\n\nmain = do\n [p, k] <- fmap (fmap read . words) getLine\n let ans = doit p k\n print . length $ ans\n putStrLn . unwords . map show $ ans\n"}], "negative_code": [{"source_code": "doit :: [Integer] -> [Integer]\ndoit [0, _] = []\ndoit [p, k] = tmp : doit [(p - tmp) `div` (-k), k]\n where tmp = p `mod` k\n\nmain = fmap (fmap read . words) getLine >>= return . doit >>= putStrLn . unwords . map show\n"}], "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5"} {"source_code": "\nimport Monad (liftM)\nimport Prelude hiding (print)\n\nsolve :: (Fractional a, Ord a) => [a] -> (a, a)\nsolve [a, b, m, vx, vy, vz] = solve' (a/2, m, 0) (vx, vy, vz)\n where\n solve' (x, y, z) (vx, vy, vz)\n | ty <= tx && ty <= tz = (x + ty * vx, z + ty * vz)\n | tx < tz = solve' (x + tx * vx, y + tx * vy, z + tx * vz) (-vx, vy, vz)\n | tx > tz = solve' (x + tz * vx, y + tz * vy, z + tz * vz) (vx, vy, -vz)\n | otherwise = solve' (x + tz * vx, y + tz * vy, z + tz * vz) (-vx, vy, -vz)\n where\n tx = if vx >= 0 then (a - x) / vx else -x / vx\n ty = -y / vy\n tz = if vz >= 0 then (b - z) / vz else -z / vz\n\nprint :: Show a => (a, a) -> IO ()\nprint (a, b) = putStrLn (show a ++ \" \" ++ show b)\n\nmain :: IO ()\nmain = fmap (map read . take 6 . words) getContents >>= print . solve\n", "positive_code": [{"source_code": "import Control.Applicative\n\nmain = do\n [a,b,m] <- map read.words <$> getLine\n [vx,vy',vz] <- map read.words <$> getLine\n let vy = -vy'\n qx = (2*vx*m+a*vy)`div`(2*vy*a)\n qz = (vz*m)`div`(vy*b)\n x0 = if even qx\n then (fromIntegral $ -2*vy*qx*a+2*vx*m+a*vy)/(fromIntegral $ 2*vy)\n else (fromIntegral $ 2*vy*(qx+1)*a-2*vx*m-a*vy)/(fromIntegral $ 2*vy)\n z0 = if even qz\n then (fromIntegral $ vz*m-qz*b*vy)/(fromIntegral vy)\n else (fromIntegral $ -vz*m+(qz+1)*b*vy)/(fromIntegral vy)\n putStrLn $ unwords $ map show [x0,z0]\n"}], "negative_code": [{"source_code": "\nimport Monad (liftM)\nimport Prelude hiding (print)\n\nsolve :: (Fractional a, Ord a) => [a] -> (a, a)\nsolve [a, b, m, vx, vy, vz] = solve' (a/2, m, 0) (vx, vy, vz)\n where\n solve' (x, y, z) (vx, vy, vz)\n | ty <= tx && ty <= tz = (x + ty * vx, z + ty * vz)\n | tx <= tz = solve' (0, y + tx * vy, z + tx * vz) (-vx, vy, vz)\n | otherwise = solve' (x + tz * vx, y + tz * vy, 0) (vx, vy, -vz)\n where\n tx = if vx > 0 then (a - x) / vx else x / vx\n ty = -y / vy\n tz = if vz > 0 then (b - z) / vz else z / vz\n\nprint :: Show a => (a, a) -> IO ()\nprint (a, b) = putStrLn (show a ++ \" \" ++ show b)\n\nmain :: IO ()\nmain = fmap (map read . take 6 . words) getContents >>= print . solve\n"}], "src_uid": "84848b8bd92fd2834db1ee9cb0899cff"} {"source_code": "main = interact (show . (solve 1) . read)\nsolve a b\n | b <= a = b\n | otherwise = solve (a+1) (b-a)", "positive_code": [{"source_code": "{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE ViewPatterns #-}\n{-# LANGUAGE OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Tuple\nimport Data.Int\nimport Data.Char\nimport Data.Function\n-- import Data.ByteString (ByteString)\n-- import qualified Data.ByteString.Char8 as C\n-- import Data.ByteString.Char8 ()\n-- import Data.Vector.Unboxed ((//), (++), (!), (!?))\n-- import qualified Data.Vector.Unboxed as U\n-- import Data.IntMap.Strict (IntMap)\n-- import qualified Data.IntMap.Strict as IntMap\n-- import Data.Sequence ((|>), (<|), (><),ViewR((:>)), ViewL((:<)))\n-- import qualified Data.Sequence as S\n\nmyread = read :: String -> Integer\nmain = do\n n <- myread <$> getLine\n print $ solve n \n\nsolve :: Integer -> Integer\nsolve n = n - ((m*(m+1))`div`2) where\n m = ($!) floor ((sqrt (((fromIntegral n -1) * 8)+1) - 1) / 2)\n-- solve n = (-) n . last . takeWhile ( getLine::IO Integer\n\tlet x = floor $ sqrt $ fromIntegral $ n*2\n\tlet y= (div (x*(x+1)) 2) \n\tlet x1 = if (n>y) then n-y else n- (div ((x)*(x-1)) 2)\n\tlet x2 = if x1 ==0 then x else x1\n\tprint x2\n\t \n\n\t \n"}, {"source_code": "\nmain = interact $ show . sol . map read . words\n\nsol :: [Integer] -> Integer\nsol [n] = f n 1\n where\n f num p\n | num > p = f (num-p) (p+1)\n | otherwise = num\n\n"}, {"source_code": "{-# OPTIONS_GHC -O2 #-}\n\nimport Data.Int (Int64)\n\nmain = do\n a <- readLn :: IO Int64\n\n let\n b = f a 1\n where\n f a d = if a <= d then a else f (a-d) (d+1)\n\n print b\n\n\n"}, {"source_code": "main = do\n e<-getLine\n let m=read e::Integer\n n=read e::Double\n r=((-1.0)+sqrt(1+8*n))/2.0\n r2=floor r::Integer\n r3=ceiling r::Integer\n r4=if r3==r2 then (r2-1) else r2\n ans=m - (r4*(r4+1::Integer) `div` 2)\n print ans"}], "negative_code": [], "src_uid": "1db5631847085815461c617854b08ee5"} {"source_code": "import qualified Data.ByteString.Char8 as B\nimport Data.Maybe\nimport Data.List\nimport Control.Arrow\n\nint = fst . fromJust . B.readInt\nints = map int . B.words <$> B.getLine\ng = (arr length *** arr length) . partition (<0) .filter (/=0)\nsub (a,b) (c,d) = (a-c, b-d)\n\nmain = do\n [n,k] <- ints\n bs <- ints\n let gbs = g bs\n print $ maximum $ map (\\x -> abs $ uncurry (-) $ sub gbs $ g $ zipWith (*) bs $ take n $ drop x $ cycle $ replicate (k-1) 0 ++ [1]) [0..k-1]\n \n", "positive_code": [{"source_code": "import Data.List\n\nmain = getContents >>= print . solve . map read . tail . words\n\n-- find maximum |e - s| in groups\nsolve (k:xs) = maximum $ map (\\(e,s) -> abs $ e0 - e - s0 + s) xss\n where xss = map tab $ transpose $ groupK k xs\n (e0,s0) = tab xs\n\ngroupK k [] = []\ngroupK k xs = (\\(l,rs) -> l : groupK k rs) $ splitAt k xs\n\n-- (# of tab 1, # of tab -1)\ntab xs = let (n,s) = (length xs, sum xs) in ((n + s) `div` 2, (n - s) `div` 2)\n"}, {"source_code": "-- Codeforces Round #532 (A), Contest 1100, Problem set ?.\n-- UNDONE\n\n{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE Safe #-}\n{-# LANGUAGE TupleSections#-}\n{-# LANGUAGE ExplicitForAll #-}\n\nimport Data.Bits\nimport Data.List\nimport qualified Data.ByteString.Char8 as BS\nimport qualified Data.ByteString.Lazy.Char8 as BSL\nimport Data.IntMap.Strict (IntMap)\nimport qualified Data.IntMap.Strict as IM\nimport qualified Data.Array.IArray as A\nimport qualified Data.Array.MArray.Safe as A\n-- import qualified Data.Array.MArray as A\nimport Data.Array (Array)\nimport Data.Array.Unboxed (UArray)\nimport Data.Array.IArray (IArray)\nimport Data.Array.MArray.Safe (MArray)\nimport Data.Array.IO.Safe (IOArray, IOUArray)\nimport Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)\n{-\nimport qualified Data.Vector.Unboxed as VU\nimport qualified Data.Vector.Unboxed.Mutable as VUM\n-}\nimport Control.Monad\nimport Control.Monad.ST.Safe\n-- import Control.Monad.ST\nimport Control.Applicative\nimport Data.Maybe\nimport Data.Tuple\nimport Data.Ord\nimport Control.Monad.State.Strict\nimport Data.Int\nimport Data.Word\nimport Data.STRef\nimport Data.IORef\nimport Data.Function\n\nmain :: IO ()\nmain = do\n [n,k] <- map read . words <$> getLine :: IO [Int]\n ts <- unfoldr (BS.readInt . BS.dropWhile (<'!')) <$> BS.getLine\n let s = sum ts\n print $ maximum $ map abs $ map (s-) $ A.elems\n (A.accumArray (+) 0 (0,k-1) $ zip (cycle [0..k-1]) ts :: UArray Int Int)\n"}, {"source_code": "import Text.Printf\nimport Data.List\nimport Data.Functor\nimport Control.Applicative\nimport Prelude\nimport Control.Monad\nimport Data.Maybe\nimport Data.Function\nimport Data.Array\nimport qualified Data.ByteString.Char8 as B8\nimport Data.Foldable (foldr')\nimport Data.Bits\n\nreadInt :: String -> Int\nreadInt = Prelude.read\n\nreadB8Int :: B8.ByteString -> Int\nreadB8Int = fst . fromJust . B8.readInt\n\nmain :: IO ()\nmain = do\n [n, k] <- (map readInt . words) <$> getLine\n arr <- (map readInt . words) <$> getLine\n let len = length arr\n sm = sum arr\n ss = map (\\b -> abs (sm - (sum . map (arr !!) . map (\\x -> x - 1) . takeWhile (<= len) . map (\\ i -> i * k + b) $ [0 .. ]))) $ [1 .. k]\n printf \"%d\\n\" $ maximum ss"}], "negative_code": [], "src_uid": "6119258322e06fa6146e592c63313df3"} {"source_code": "main = readLn >>= print . (`mod` 2) . (`div` 2) . (+1)\n", "positive_code": [{"source_code": "-- Haskell Template\nsolve :: Int -> Int\nsolve n\n | r == 0 || r == 3 = 0\n | otherwise = 1\n where\n \tr = mod n 4\n\nmain :: IO ()\nmain = do\n x <- getLine\n let s = solve (read x)\n putStrLn (show s)\n"}, {"source_code": "-- Codeforces Round #531 (A), Contest 1102, Problem set ?.\n\n{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE Safe #-}\n{-# LANGUAGE TupleSections#-}\n{-# LANGUAGE ExplicitForAll #-}\n\nimport Data.Bits\nimport Data.List\nimport qualified Data.ByteString.Char8 as BS\nimport qualified Data.ByteString.Lazy.Char8 as BSL\nimport Data.IntMap.Strict (IntMap)\nimport qualified Data.IntMap.Strict as IM\nimport qualified Data.Array.IArray as A\nimport qualified Data.Array.MArray.Safe as A\n-- import qualified Data.Array.MArray as A\nimport Data.Array (Array)\nimport Data.Array.Unboxed (UArray)\nimport Data.Array.IArray (IArray)\nimport Data.Array.MArray.Safe (MArray)\nimport Data.Array.IO.Safe (IOArray, IOUArray)\nimport Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)\n{-\nimport qualified Data.Vector.Unboxed as VU\nimport qualified Data.Vector.Unboxed.Mutable as VUM\n-}\nimport Control.Monad\nimport Control.Monad.ST.Safe\n-- import Control.Monad.ST\nimport Control.Applicative\nimport Data.Maybe\nimport Data.Tuple\nimport Data.Ord\nimport Control.Monad.State.Strict\nimport Data.Int\nimport Data.Word\n\nmain :: IO ()\nmain = do\n n <- read <$> getLine :: IO Int\n print $ if mod n 4 `elem` [0,3] then 0 else 1\n\n\n"}, {"source_code": "main = do\n line <- getLine\n let n = read line :: Int\n let m = case n `mod` 4 of 0 -> 0\n 1 -> 1\n 2 -> 1\n 3 -> 0\n print m\n"}, {"source_code": "main = interact $ show . solve . read\nsolve n = n * (n+1) `div` 2 `mod` 2\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\n\t\t\n\nmain = do\n\t\tr<- read <$> getLine ::IO Int\n\t\tprint $ if odd (div (r *(r+1)) 2) then 1 else 0\n"}, {"source_code": "main :: IO ()\nmain = do\n l <- readLn :: IO Int\n putStrLn $ show $ solve l\n\nsolve :: Int -> Int\nsolve 0 = 0\nsolve 1 = 1\nsolve 2 = 1\nsolve 3 = 0\nsolve n = solve $ n `mod` 4\n"}], "negative_code": [], "src_uid": "fa163c5b619d3892e33e1fb9c22043a9"} {"source_code": "{-# LANGUAGE LambdaCase #-}\n-- import Control.Arrow\nimport Data.List\nimport Data.Ord\nimport Data.Monoid\n\nmain = do\n abc <- map (read :: String -> Int) . words <$> getLine\n let d = take 14 $ cycle \"abcacba\"\n p s t = (\\case \n x@[('a':_),('b':_),('c':_)] -> map length x\n [as@('a':_),bs@('b':_)] -> [length as, length bs, 0]\n [as@('a':_),cs@('c':_)] -> [length as, 0, length cs]\n [bs@('b':_),cs@('c':_)] -> [0, length bs, length cs]\n [as@('a':_)] -> [length as, 0, 0]\n [bs@('b':_)] -> [0,length bs, 0]\n [cs@('c':_)] -> [0, 0, length cs]\n ) . group . sort . take t . drop s\n ps = [(t,p s t d) | s <- [0..6], t <- [1..7]] \n zs'@[(ad,ar),(bd,br),(cd,cr)] = zipWith divMod abc [3,2,2]\n wk = minimum $ map fst zs'\n zs = zipWith min [3,2,2] $ zipWith (-) abc $ map (wk*) [3,2,2] \n ys = if zs == [0,0,0] \n then [(7*wk, zs)]\n else filter (all (>=0) . snd) $ map (\\x -> (7*wk + fst x, zipWith (-) zs $ snd x)) ps\n print $ fst $ head $ sortBy ((comparing (sum .snd)) `mappend` (flip $ comparing fst)) ys\n", "positive_code": [{"source_code": "main :: IO ()\nmain = do\n inp <- getLine\n let l = map read $ words inp\n a = l!!0\n b = l!!1\n c = l!!2\n putStrLn $ show $ maximum (map (h a b c) [0..6])\n return ()\n\nh :: Int -> Int -> Int -> Int -> Int\nh a b c d = dayz $ Just (d,(a,b,c))\ndayz :: (Maybe (Int, (Int, Int, Int))) -> Int\ndayz Nothing = (-1)\ndayz (Just (d,(a,b,c)))\n |a>21000 && b>14000 && c>14000 = 49000+ (dayz $ Just(d,(a-21000,b-14000,c-14000)))\n |otherwise = 1 + (dayz (step (d,(a,b,c))))\n\nstep :: (Int,(Int,Int,Int))-> Maybe (Int,(Int,Int,Int))\nstep (d,(a,b,c))\n |d `elem` [0,3,6] =ok ((d+1) `mod` 7,(a-1,b,c))\n |d `elem` [1,5] =ok (d+1,(a,b-1,c))\n |otherwise =ok ((d+1) `mod` 7,(a,b,c-1))\n where ok (a,(b,c,d)) = if -1 `elem` [b,c,d] then Nothing else Just (a,(b,c,d))"}, {"source_code": "dine a b c week = case (head week) of\n 'a' -> if a == 0 then 0 else 1 + (dine (a - 1) b c (tail week))\n 'b' -> if b == 0 then 0 else 1 + (dine a (b - 1) c (tail week))\n 'c' -> if c == 0 then 0 else 1 + (dine a b (c - 1) (tail week))\nprocess _ _ _ 0 _ = 0\nprocess a b c n week = max (dine a b c week) rec\n where\n rec = process a b c (n - 1) (tail week)\nanalyze (a:b:c:_) = 7 * n + (process (a - n * 3) (b - n * 2) (c - n * 2) 7 week)\n where\n n = minimum [div a 3, div b 2, div c 2]\n week = cycle ['a', 'b', 'c', 'a', 'c', 'b', 'a']\nans = show . analyze . (map read) . words\nmain = getLine >>= putStrLn . ans\n"}], "negative_code": [{"source_code": "main :: IO ()\nmain = do\n inp <- getLine\n let l = map read $ words inp\n a = l!!0\n b = l!!1\n c = l!!2\n putStrLn $ show $ maximum (map (h a b c) [0..7])\n return ()\n\nh :: Int -> Int -> Int -> Int -> Int\nh a b c d = dayz $ Just (d,(a,b,c))\n--days :: {-Maybe (Int, (Int, Int, Int))-} Maybe a -> Int\ndayz Nothing = (-1)\ndayz (Just x) = 1 + (dayz (step x))\n\nstep :: (Int,(Int,Int,Int))-> Maybe (Int,(Int,Int,Int))\nstep (d,(a,b,c))\n |d `elem` [0,3,6] =ok (d+1,(a-1,b,c))\n |d `elem` [1,5] =ok (d+1,(a,b-1,c))\n |otherwise =ok ((d+1) `mod` 7,(a,b,c-1))\n where ok (a,(b,c,d)) = if -1 `elem` [b,c,d] then Nothing else Just (a,(b,c,d))"}, {"source_code": "main :: IO ()\nmain = do\n inp <- getLine\n let l = map read $ words inp\n a = l!!0\n b = l!!1\n c = l!!2\n putStrLn $ show $ maximum (map (h a b c) [0..7])\n return ()\n\nh :: Int -> Int -> Int -> Int -> Int\nh a b c d = dayz $ Just (d,(a,b,c))\ndayz :: (Maybe (Int, (Int, Int, Int))) -> Int\ndayz Nothing = (-1)\ndayz (Just (d,(a,b,c)))\n |a>21000 && b>14000 && c>14000 = 49000+ (dayz $ Just(d,(a-21000,b-14000,c-14000)))\n |otherwise = 1 + (dayz (step (d,(a,b,c))))\n\nstep :: (Int,(Int,Int,Int))-> Maybe (Int,(Int,Int,Int))\nstep (d,(a,b,c))\n |d `elem` [0,3,6] =ok ((d+1) `mod` 7,(a-1,b,c))\n |d `elem` [1,5] =ok (d+1,(a,b-1,c))\n |otherwise =ok ((d+1) `mod` 7,(a,b,c-1))\n where ok (a,(b,c,d)) = if -1 `elem` [b,c,d] then Nothing else Just (a,(b,c,d))"}, {"source_code": "main :: IO ()\nmain = do\n inp <- getLine\n let l = map read $ words inp\n a = l!!0\n b = l!!1\n c = l!!2\n putStrLn $ show $ {-maximum-} (map (h a b c) [0..7])\n return ()\n\nh :: Int -> Int -> Int -> Int -> Int\nh a b c d = dayz $ Just (d,(a,b,c))\n--days :: {-Maybe (Int, (Int, Int, Int))-} Maybe a -> Int\ndayz Nothing = (-1)\ndayz (Just x) = 1 + (dayz (step x))\n\nstep :: (Int,(Int,Int,Int))-> Maybe (Int,(Int,Int,Int))\nstep (d,(a,b,c))\n |d `elem` [0,3,6] =ok (d+1,(a-1,b,c))\n |d `elem` [1,5] =ok (d+1,(a,b-1,c))\n |otherwise =ok ((d+1) `mod` 7,(a,b,c-1))\n where ok (a,(b,c,d)) = if -1 `elem` [b,c,d] then Nothing else Just (a,(b,c,d))"}, {"source_code": "main :: IO ()\nmain = do\n inp <- getLine\n let l = map read $ words inp\n a = l!!0\n b = l!!1\n c = l!!2\n putStrLn $ show $ {-maximum-} (map (h a b c) [0..7])\n return ()\n\nh :: Int -> Int -> Int -> Int -> Int\nh a b c d = dayz $ Just (d,(a,b,c))\n--days :: {-Maybe (Int, (Int, Int, Int))-} Maybe a -> Int\ndayz Nothing = 0\ndayz (Just x) = 1 + (dayz (step x))\n\nstep :: (Int,(Int,Int,Int))-> Maybe (Int,(Int,Int,Int))\nstep (d,(a,b,c))\n |d `elem` [0,3,6] =ok (d+1,(a-1,b,c))\n |d `elem` [1,5] =ok (d+1,(a,b-1,c))\n |otherwise =ok ((d+1) `mod` 7,(a,b,c-1))\n where ok (a,(b,c,d)) = if 0 `elem` [b,c,d] then Nothing else Just (a,(b,c,d))"}, {"source_code": "main :: IO ()\nmain = do\n inp <- getLine\n let l = map read $ words inp\n a = l!!0\n b = l!!1\n c = l!!2\n putStrLn $ show $ maximum (map (h a b c) [0..7])\n return ()\n\nh :: Int -> Int -> Int -> Int -> Int\nh a b c d = dayz $ Just (d,(a,b,c))\n--days :: {-Maybe (Int, (Int, Int, Int))-} Maybe a -> Int\ndayz Nothing = 0\ndayz (Just x) = 1 + (dayz (step x))\n\nstep :: (Int,(Int,Int,Int))-> Maybe (Int,(Int,Int,Int))\nstep (d,(a,b,c))\n |d `elem` [0,3,6] =ok (d+1,(a-1,b,c))\n |d `elem` [1,5] =ok (d+1,(a,b-1,c))\n |otherwise =ok ((d+1) `mod` 7,(a,b,c-1))\n where ok (a,(b,c,d)) = if 0 `elem` [b,c,d] then Nothing else Just (a,(b,c,d))"}, {"source_code": "{-# LANGUAGE LambdaCase #-}\n-- import Control.Arrow\nimport Data.List\nimport Data.Ord\nimport Data.Monoid\n\nmain = do\n abc <- map (read :: String -> Int) . words <$> getLine\n let d = take 14 $ cycle \"abcacba\"\n p s t = (\\case \n x@[('a':_),('b':_),('c':_)] -> map length x\n [as@('a':_),bs@('b':_)] -> [length as, length bs, 0]\n [as@('a':_),cs@('c':_)] -> [length as, 0, length cs]\n [bs@('b':_),cs@('c':_)] -> [0, length bs, length cs]\n [as@('a':_)] -> [length as, 0, 0]\n [bs@('b':_)] -> [0,length bs, 0]\n [cs@('c':_)] -> [0, 0, length cs]\n ) . group . sort . take t . drop s\n ps = [(t,p s t d) | s <- [0..6], t <- [1..7]] \n zs'@[(ad,ar),(bd,br),(cd,cr)] = zipWith divMod abc [3,2,2]\n wk = minimum $ map fst zs'\n zs = zipWith (-) abc $ map (wk*) [3,2,2] \n ys = if zs == [0,0,0] \n then [(7*wk, zs)]\n else map (\\x -> (7*wk + fst x, zipWith (\\x y -> if x < y then x else x -y) zs $ snd x)) ps\n print $ fst $ head $ sortBy ((flip $ comparing (length . filter (==0) .snd)) `mappend` (flip $ comparing fst)) ys\n"}, {"source_code": "{-# LANGUAGE LambdaCase #-}\n-- import Control.Arrow\nimport Data.List\nimport Data.Ord\nimport Data.Monoid\n\nmain = do\n abc <- map (read :: String -> Int) . words <$> getLine\n let d = take 14 $ cycle \"abcacba\"\n p s t = (\\case \n x@[('a':_),('b':_),('c':_)] -> map length x\n [as@('a':_),bs@('b':_)] -> [length as, length bs, 0]\n [as@('a':_),cs@('c':_)] -> [length as, 0, length cs]\n [bs@('b':_),cs@('c':_)] -> [0, length bs, length cs]\n [as@('a':_)] -> [length as, 0, 0]\n [bs@('b':_)] -> [0,length bs, 0]\n [cs@('c':_)] -> [0, 0, length cs]\n ) . group . sort . take t . drop s\n ps = [(t,p s t d) | s <- [0..6], t <- [1..7]] \n zs'@[(ad,ar),(bd,br),(cd,cr)] = zipWith divMod abc [3,2,2]\n wk = minimum $ map fst zs'\n zs = zipWith (-) abc $ map (wk*) [3,2,2] \n ys = if zs == [0,0,0] \n then [(7*wk, zs)]\n else map (\\x -> (7*wk + fst x, map abs $ zipWith (-) zs $ snd x)) ps\n print $ fst $ head $ sortBy ((flip $ comparing (length . filter (==0) .snd)) `mappend` (flip $ comparing fst)) ys\n"}, {"source_code": "{-# LANGUAGE LambdaCase #-}\n-- import Control.Arrow\nimport Data.List\nimport Data.Ord\nimport Data.Monoid\n\nmain = do\n abc <- map (read :: String -> Int) . words <$> getLine\n let d = take 14 $ cycle \"abcacba\"\n p s t = (\\case \n x@[('a':_),('b':_),('c':_)] -> map length x\n [as@('a':_),bs@('b':_)] -> [length as, length bs, 0]\n [as@('a':_),cs@('c':_)] -> [length as, 0, length cs]\n [bs@('b':_),cs@('c':_)] -> [0, length bs, length cs]\n [as@('a':_)] -> [length as, 0, 0]\n [bs@('b':_)] -> [0,length bs, 0]\n [cs@('c':_)] -> [0, 0, length cs]\n ) . group . sort . take t . drop s\n ps = [(t,p s t d) | s <- [0..6], t <- [1..7]] \n zs'@[(ad,ar),(bd,br),(cd,cr)] = zipWith divMod abc [3,2,2]\n wk = minimum $ map fst zs'\n zs = zipWith (-) abc $ map (wk*) [3,2,2] \n ys = map (\\x -> (7*wk + fst x, map abs $ zipWith (-) zs $ snd x)) ps\n print $ fst $ head $ sortBy ((flip $ comparing (length . filter (==0) .snd)) `mappend` (flip $ comparing fst)) ys\n"}, {"source_code": "{-# LANGUAGE LambdaCase #-}\n-- import Control.Arrow\nimport Data.List\nimport Data.Ord\nimport Data.Monoid\n\nmain = do\n abc <- map (read :: String -> Int) . words <$> getLine\n let d = take 14 $ cycle \"abcacba\"\n p s t = (\\case \n x@[('a':_),('b':_),('c':_)] -> map length x\n [as@('a':_),bs@('b':_)] -> [length as, length bs, 0]\n [as@('a':_),cs@('c':_)] -> [length as, 0, length cs]\n [bs@('b':_),cs@('c':_)] -> [0, length bs, length cs]\n [as@('a':_)] -> [length as, 0, 0]\n [bs@('b':_)] -> [0,length bs, 0]\n [cs@('c':_)] -> [0, 0, length cs]\n ) . group . sort . take t . drop s\n ps = [(t,p s t d) | s <- [0..6], t <- [1..7]] \n zs'@[(ad,ar),(bd,br),(cd,cr)] = zipWith divMod abc [3,2,2]\n wk = minimum $ map fst zs'\n zs = zipWith (-) abc $ map (wk*) [3,2,2] \n ys = if zs == [0,0,0] \n then [(7*wk, zs)]\n else map (\\x -> (7*wk + fst x, zipWith (\\x y -> if x < y then x else x -y) zs $ snd x)) ps\n print zs\n print $ fst $ head $ sortBy ((flip $ comparing (length . filter (==0) .snd)) `mappend` (flip $ comparing fst)) ys\n"}], "src_uid": "e17df52cc0615585e4f8f2d31d2daafb"} {"source_code": "import Data.Char\n\nsolve [a,b]\n | b `div` a >= 3 = 0\n | otherwise = a - (b `mod` a)\n\nmain = interact $ show . solve . map (read::String->Int) . words\n ", "positive_code": [{"source_code": "main = getLine >>= print. (\\[n, k] -> max 0 (3*n - k)). map read. words\n\n"}, {"source_code": "main=interact$show.(\\[n,k] -> max (3*n-k) 0).map read.words"}, {"source_code": "solve n k = n - min (k - 2*n) n\nmain = do\n line <- getLine\n let [n, k] = map read $ words line :: [Int]\n print $ solve n k\n"}, {"source_code": "solve [a,b]\n | b `div` a >= 3 = 0\n | otherwise = a - (b `mod` a)\nmain = interact $ show . solve . map (read::String->Int) . words\n "}, {"source_code": "main = getLine >>= putStrLn . func . map read . words\nfunc :: [Int] -> String \nfunc [x,y] = show $ max 0 (3*x - y)"}, {"source_code": "main=interact$show.(\\[n,k] -> max (3*n-k) 0).map read.words"}, {"source_code": "s[n,k]=max (3*n-k) 0\nmain=interact$show.s.map read.words"}, {"source_code": "\nimport Control.Monad (liftM)\nimport Prelude hiding (reads)\n\nreads :: Read a => IO [a]\nreads = liftM (map read . words) getLine\n\nsolve :: [Int] -> Int\nsolve [n, k] = max 0 (3*n - k)\n\nmain :: IO ()\nmain = reads >>= print . solve\n"}, {"source_code": "\nsolve :: Int -> Int -> Int\nsolve n k = minimum\n [n - n3 - n4 - n5 |\n n3 <- [0..n], n4 <- [0..n - n3], n5 <- [0..n - n3 - n4],\n n3 + n4 + n5 <= n, 2 * (n - n3 - n4 - n5) + 3 * n3 + 4 * n4 + 5 * n5 == k] \n\nmain :: IO ()\nmain = do\n [n, k] <- getLine >>= return . map read . words\n print $ solve n k\n"}, {"source_code": "main = do\n (n:k:_) <- (map read . words) `fmap` getLine\n let rest = k - 2 * n\n print $ max (n - rest) 0"}, {"source_code": "main = getLine >>= print.solve.map read.words\n\nsolve :: [Int] -> Int\nsolve [n,k] = max 0 $ 3*n-k\n"}], "negative_code": [], "src_uid": "5a5e46042c3f18529a03cb5c868df7e8"} {"source_code": "main = interact $ show . solve . map read . words\nsolve (n0:k0:as) = go n0 k0 0 as where\n go n k _ _ | k <= 0 = n0 - n\n go 0 _ _ _ = -1\n go _ _ _ [] = -1\n go n k c (a:as) = go (n-1) (k - g) (c' - g) as where\n c' = c + a\n g = min 8 c'\n", "positive_code": [{"source_code": "{-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -funfolding-use-threshold=16 -fexcess-precision -funbox-strict-fields #-}\nmodule Main where\nimport qualified Data.ByteString.Lazy.Char8 as B\nimport Control.Monad.Trans.State.Lazy\nimport Control.Monad\n\nmain = mapM_ print . evalState app . B.words =<< B.getContents\n\napp = do\n n <- poi\n k <- poi\n xs <- replicateM n poi\n return [solve n k xs]\n where\n pop = state $ \\(x:xs) -> (x, xs)\n poi = fmap int pop\n int = maybe undefined fst . B.readInt\n\nsolve n k xs = (\\r -> if r > n then -1 else r) $ length $ takeWhile ((< k) . fst) $ scanl (\\(t, l) x -> let x' = x + l in (t + min x' 8, max 0 (x' - 8))) (0, 0) xs"}, {"source_code": "f [x] n k s day\n\t|s+(min 8 x)>=k = day\n\t|otherwise = (-1)\nf (x:y:xs) n k s day\n\t|s+(min 8 x)>=k = day\n\t|otherwise = f new_xs n k (s + (min x 8)) (day+1)\n\twhere\n\t\tnew_xs=(y+x-(min x 8)):xs\n\t\nmain=do\n\ta<-fmap words (getLine)\n\tb<-fmap words (getLine)\n\tlet [n,k] = map (\\x->read x::Int) a\n\tlet aa = map (\\x->read x::Int) b\n\tprint (f aa n k 0 1)"}, {"source_code": "doit :: (Int, Int) -> Int -> (Int, Int)\ndoit (rem, me) new = \n let menew = me + new\n give = 8 `min` menew\n in (rem - give, menew - give)\n\n\nmain = do\n [n, k] <- fmap (map read . words) getLine\n a <- fmap (map read . words) getLine\n let x = length . takeWhile ((> 0) . fst) . scanl doit (k, 0) $ a\n print $ if x == n + 1 then -1 else x\n"}, {"source_code": "arya _ k _ p | k <= 0 = p\narya _ _ [] p = -1\narya n k [a] p = if k > 8 then -1 else if k > a then -1 else p+1 \narya n k (a:b:as) p = arya n (if a > 8 then k - 8 else k - a) (if a > 8 then (a-8+b:as) else (b:as)) (p+1) \n\n\nmain = do\n [n,k] <- getLine >>= return . map (\\x -> read x :: Int) . words\n as <- getLine >>= return . map (\\x -> read x :: Int) . words\n print $ arya n k as 0"}], "negative_code": [{"source_code": "f [x] n k s day\n\t|s+(min 8 x)>=k = day\n\t|otherwise = (-1)\nf (x:y:xs) n k s day\n\t|s>=k = day\n\t|otherwise = f new_xs n k (s + (min x 8)) (day+1)\n\twhere\n\t\tnew_xs=(y+x-(min x 8)):xs\n\t\nmain=do\n\ta<-fmap words (getLine)\n\tb<-fmap words (getLine)\n\tlet [n,k] = map (\\x->read x::Int) a\n\tlet aa = map (\\x->read x::Int) b\n\tprint (f aa n k 0 1)"}, {"source_code": "f [] n k s\n\t|s>=k = n\n\t|otherwise = (-1)\nf (x:xs) n k s\n\t|s>=k = n\n\t|otherwise = f xs n k (s + (min x 8))\n\t\nmain=do\n\ta<-fmap words (getLine)\n\tb<-fmap words (getLine)\n\tlet [n,k] = map (\\x->read x::Int) a\n\tlet aa = map (\\x->read x::Int) b\n\tprint (f aa n k 0)"}, {"source_code": "f [] n k s day\n\t|s>=k = day\n\t|otherwise = (-1)\nf (x:xs) n k s day\n\t|s>=k = day\n\t|otherwise = f xs n k (s + (min x 8)) (day+1)\n\t\nmain=do\n\ta<-fmap words (getLine)\n\tb<-fmap words (getLine)\n\tlet [n,k] = map (\\x->read x::Int) a\n\tlet aa = map (\\x->read x::Int) b\n\tprint (f aa n k 0 0)"}, {"source_code": "arya _ k _ p | k <= 0 = p\narya _ _ [] p = -1\narya n k [a] p = -1 \narya n k (a:b:as) p = arya n (if a > 8 then k - 8 else k - a) (if a > 8 then (a-8+b:as) else (b:as)) (p+1) \n\n\nmain = do\n [n,k] <- getLine >>= return . map (\\x -> read x :: Int) . words\n as <- getLine >>= return . map (\\x -> read x :: Int) . words\n print $ arya n k as 0\n"}, {"source_code": "arya _ _ [] p = if p == 0 then -1 else p\narya n k [a] p = if k > 8 then -1 else p+1 \narya n k (a:b:as) p = arya n (if a > 8 then k - 8 else k - a) (if a > 8 then (a-8+b:as) else (b:as)) (p+1) \n\n\nmain = do\n [n,k] <- getLine >>= return . map (\\x -> read x :: Int) . words\n as <- getLine >>= return . map (\\x -> read x :: Int) . words\n print $ arya n k as 0\n"}, {"source_code": "arya _ k _ p | k <= 0 = p\narya _ _ [] p = -1\narya n k [a] p = if k > 8 then -1 else p+1 \narya n k (a:b:as) p = arya n (if a > 8 then k - 8 else k - a) (if a > 8 then (a-8+b:as) else (b:as)) (p+1) \n\n\nmain = do\n [n,k] <- getLine >>= return . map (\\x -> read x :: Int) . words\n as <- getLine >>= return . map (\\x -> read x :: Int) . words\n print $ arya n k as 0\n"}], "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a"} {"source_code": "convert '^'=1\nconvert '>'=2\nconvert 'v'=3\nconvert '<'=4\nupdate s f\n\t|f>=s = (s,f)\n\t|otherwise=(s,f+4)\nfunc s f time\n\t|abs (ss - ff )==0 = \"undefined\"\n\t|abs (ss - ff )==2 = \"undefined\"\n\t|ff-ss==1 && t==1 = \"cw\"\n\t|ff-ss==1 && t==3 = \"ccw\"\n\t|ff-ss==3 && t==1 = \"ccw\"\n\t|ff-ss==3 && t==3 = \"cw\"\n\t|otherwise = \"undefined\"\n\twhere\n\t\tt=mod time 4\n\t\t(ss,ff)=update (convert s) (convert f)\n\t\nmain=do\n\t[s,f]<-fmap words getLine\n\ttime<-fmap (\\x->read x::Integer) getLine\n\tputStrLn (func (head s) (head f) time)", "positive_code": [{"source_code": "-- Try Codeforces\n-- author: Leonardone @ NEETSDKASU\n\nmain = putStrLn . solve . words =<< getContents\n\nsolve [_ , _ ,\"0\"] = \"undefined\"\nsolve [s:_, e:_, n ] = ans where\n m = (read n - 1) `mod` 4\n cw = (!! m) . tail $ dropWhile (/= s) \"^>v<^>v<^>v<^>v<\"\n ccw = (!! m) . tail $ dropWhile (/= s) \"^^^^\"\n ans = case (cw == e, ccw == e) of\n (True, False) -> \"cw\"\n (False, True) -> \"ccw\"\n otherwise -> \"undefined\""}, {"source_code": "{-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -funfolding-use-threshold=16 -fexcess-precision -funbox-strict-fields #-} \nmodule Main where\nimport qualified Data.ByteString.Char8 as B\nimport Data.Maybe\nimport Data.Bits\nimport Data.List\n\nmain = do\n [b, _, e] <- getLine\n n <- fmap readInt B.getLine\n putStr $ solve b e n\n\nsolve b e n\n | not $ x `xor` y = \"undefined\"\n | x = \"cw\"\n | y = \"ccw\"\n where\n x = cs!!(n' + fromJust (elemIndex b cs)) == e\n y = as!!(n' + fromJust (elemIndex b as)) == e\n cs = \"v<^>v<^>\"\n as = \"v>^^<\"\n n' = n `mod` 4\n\nreadInt = maybe undefined fst . B.readInt\nreadInts = fmap readInt . B.words"}], "negative_code": [{"source_code": "convert '^'=1\nconvert '>'=2\nconvert 'v'=3\nconvert '<'=4\nfunc s f time\n\t|t==0 = \"undefined\"\n\t|abs(ff-ss)==2 = \"undefined\"\n\t|ff>ss = \"cw\"\n\t|ffread x::Integer) getLine\n\tputStrLn (func (head s) (head f) time)"}, {"source_code": "convert '^'=1\nconvert '>'=2\nconvert 'v'=3\nconvert '<'=4\nupdateT 0 = 4\nupdateT t = t\nfunc s f time\n\t|t==0 = \"undefined\"\n\t|abs(ff-ss)==2 = \"undefined\"\n\t|ff>ss = \"cw\"\n\t|ffread x::Integer) getLine\n\tputStrLn (func (head s) (head f) time)"}, {"source_code": "convert '^'=1\nconvert '>'=2\nconvert 'v'=3\nconvert '<'=4\nupdate s f\n\t|f>=s = (s,f)\n\t|otherwise=(s,f+4)\nfunc s f time\n\t|abs (ss - ff )==0 = \"undfined\"\n\t|abs (ss - ff )==2 = \"undfined\"\n\t|ff-ss==1 && t==1 = \"cw\"\n\t|ff-ss==1 && t==3 = \"ccw\"\n\t|ff-ss==3 && t==1 = \"ccw\"\n\t|ff-ss==3 && t==3 = \"cw\"\n\t|otherwise = \"undefined\"\n\twhere\n\t\tt=mod time 4\n\t\t(ss,ff)=update (convert s) (convert f)\n\t\nmain=do\n\t[s,f]<-fmap words getLine\n\ttime<-fmap (\\x->read x::Integer) getLine\n\tputStrLn (func (head s) (head f) time)"}], "src_uid": "fb99ef80fd21f98674fe85d80a2e5298"} {"source_code": "import Data.Char\n\nmain :: IO ()\nmain = putStrLn . concat . map (\\x -> ['.', x]) . filter (not . flip elem \"aeyiou\") . map toLower =<< getLine", "positive_code": [{"source_code": "import Data.Char\nmain = do line <- getLine\n putStrLn (((foldl func \"\").(filter (\\x -> not(x `elem` \"aoyeui\"))) . (map toLower)) line)\n where func str c = str ++ \".\" ++ [c]"}, {"source_code": "import Data.List\nimport Data.Char\nmain = do\n s <- getLine\n putStrLn (\".\" ++ (intersperse '.' (map toLower (filter (\\x -> not $ elem (toUpper x) \"AOYEUI\") s))))\n"}, {"source_code": "import Data.Char\nimport Data.List\n\nmain = do\n line <- getLine\n let cons = (filter ((`notElem` \"aeiouy\")) $ map toLower line)\n ans = '.' : ( intersperse '.' cons )\n putStrLn ans "}, {"source_code": "import Data.Char\n\nmain = do\n line <- getLine\n let cons = (filter ((`notElem` \"aeiouy\")) $ map toLower line)\n putStrLn $ foldl (\\acc b -> acc ++ ['.'] ++ [b]) \"\" cons"}, {"source_code": "import Data.Char\n\nletter :: Char -> String\nletter l\n | elem l ['a', 'e', 'i', 'o', 'u', 'y'] = \"\"\n | otherwise = \".\" ++ [l]\n\ntask :: String -> String\ntask s = foldl (++) [] (map (letter . toLower) s)\n\nmain = do\n s <- getLine\n putStrLn . task $ s\n"}, {"source_code": "import Data.Char\n\nisVowel :: Char -> Bool\nisVowel x =\n if x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y'\n || x == 'A' || x == 'E' || x == 'I' || x == 'O' || x == 'U' || x == 'Y'\n then True else False\n\nfilterVowels :: [Char] -> [Char]\nfilterVowels xs = filter (not.isVowel) xs\n\ninsertConsonants :: [Char] -> [Char]\ninsertConsonants [] = []\ninsertConsonants (x:xs) =\n if (not.isVowel) x\n then ['.'] ++ [x] ++ insertConsonants xs\n else [x] ++ insertConsonants xs\n\nreplaceUpperConsonants :: [Char] -> [Char]\nreplaceUpperConsonants = map (\\x -> if (not.isVowel) x then toLower x else x)\n\nmain = do\n line <- getLine\n putStr $ replaceUpperConsonants $ insertConsonants $ filterVowels line\n"}, {"source_code": "import Data.Char\n\nconv :: Char -> String\nconv a\n | elem a \"aoyeui\" = \"\"\n | otherwise = ['.', a]\n\nsolve :: String -> String\nsolve (x:xs) = (conv $ toLower x) ++ solve xs \nsolve \"\" = \"\"\n\n\nreadInt :: String -> Int\nreadInt = read\n\nparseLogic :: String -> String\nparseLogic = solve . head . words \n\nmain = interact parseLogic\n\n\n\n\n\n"}, {"source_code": "module Main where\n\nimport Data.Char (toLower)\n\nmain :: IO ()\nmain = do\n inp <- getLine\n let word = fmap toLower inp\n woVowels = filter (`notElem` \"aeiouy\") word\n output = woVowels >>= (\\x -> ['.', x])\n putStrLn output\n"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/118/A\n\nimport Data.Char\n\nconvert :: String -> String\nconvert target = concat [['.', x] | x <- (map toLower target), not(x `elem` \"aeiouy\")]\n\nmain = do\n s <- getLine\n putStrLn $ convert s\n"}, {"source_code": "import Data.Char\n\ncheck :: String -> String\ncheck xs = g $ map toLower xs\n where\n g [] = []\n g (x : xs)\n | elem x ['a', 'o', 'y', 'e', 'u', 'i'] = g xs\n | otherwise = '.' : x : g xs\n\nmain :: IO ()\nmain = do cs <- getLine\n putStr $ check cs"}, {"source_code": "import Data.Char\n\nmain = do \n line <- getLine\n putStrLn $ foldl (\\a b -> a ++ ['.'] ++ [b]) \"\" $ (filter ((`notElem` \"aeiouy\")) $ map toLower line)\n"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/118/A\n\nimport Data.Char\n\nconvert c acc\n | (toLower c) `elem` \"aeiouy\" = acc\n | otherwise = '.':(toLower c):acc\n\nmain = do\n input <- getLine\n putStrLn $ foldr convert \"\" input\n"}, {"source_code": "module Main where\nimport Data.Maybe\nimport Data.Char\nmain = getLine >>= \\word -> putStrLn $ foldl (\\acc c -> if toUpper c `notElem` ['A','O','Y','E','U','I'] then acc ++ \".\" ++ [toLower c] else acc) \"\" word\n"}, {"source_code": "module Main where\n\nimport Data.Char\n\n(|>) = flip (.)\n\nisVowel :: Char -> Bool\nisVowel c = (toLower c) `elem` ['a', 'e', 'i', 'o', 'u', 'y']\n\nmain = interact $\n takeWhile (\\x -> x /= '\\n')\n |> filter (not . isVowel) \n |> map toLower \n |> map (\\x -> ['.',x]) \n |> foldr (++) []\n"}, {"source_code": "import Data.Char\n\nexpand :: String -> String\nexpand [] = []\nexpand (x : xs) = '.' : x : expand(xs)\n\nmain = do \n\tline <- getLine\n\tlet x = expand $ filter ((`notElem` \"aeiouy\")) $ map toLower line\n\tputStrLn x"}, {"source_code": "import Data.Char\n\nmain = do\n\tline <- getLine\n\tputStrLn $ answer line;\n\nanswer :: String -> String\nanswer a = foldr1 (++) $ zipWith (\\a b -> (a : b : [])) (repeat '.') $ map toLower $ filter (not . isVowel) a\n\nisVowel :: Char -> Bool\nisVowel x = elem (toUpper x) ['A', 'E', 'I', 'O', 'U', 'Y']\n"}, {"source_code": "module Main \nwhere\nimport Data.Char\nimport Data.List\n\nmain = do\n interact process \n\nprocess str = \n let \n inp = (lines str) !! 0\n lstr = [x | x <- (map toLower inp), x `notElem` \"aeiouy\"]\n in do\n (drop 1 . intersperse '.' $ ' ': lstr) ++ \"\\n\"\n \n\n \n"}, {"source_code": "import Data.Char (toLower)\n\nis_vowel c = case c of\n 'a' -> False\n 'o' -> False\n 'y' -> False\n 'e' -> False\n 'u' -> False\n 'i' -> False\n _ -> True\nadd_dot :: Char -> [Char]\nadd_dot c = \".\" ++ [c]\n\nmain = do\n a <- getLine\n {-capitalize = map toUpper-}\n {-putStrLn $ filter is_vowel a-}\n {-putStrLn $ filter is_vowel $ map toLower $ a-}\n putStrLn $ concat $ map add_dot $ filter is_vowel $ map toLower $ a\n {-\\cmap Char.toUpper \"HELLO world\"-}\n"}, {"source_code": "import Data.Char\nsetLetter :: String\nsetLetter = \"aoyuei\"\n\n\nf :: String -> String\nf [] = []\nf (x:xs)\n | (not( (toLower x) `elem` setLetter)) = (:) '.' $ (:) (toLower x) $ f xs\n | ((toLower x) `elem` setLetter) = f xs\n | otherwise = (:) (toLower x) $ f xs\n\n\nmain :: IO()\nmain = do\n a <- getLine\n putStrLn $ f a"}, {"source_code": "import Data.Char (isUpper, toLower)\nimport Data.List (intersperse)\n\nvowels = ['a','A','o','O','y','Y','e','E','u','U','i','I'] :: [Char]\n\nfixUpper :: Char -> Char\nfixUpper c = if isUpper c then toLower c else c\n\nfixString :: String -> String\nfixString s = '.' : intersperse '.' (map fixUpper $ filter (\\x -> not $ elem x vowels) s)\n\nmain = do\n word <- getLine\n putStrLn $ fixString word"}, {"source_code": "import Char\n\nisVowel 'a' = True\nisVowel 'i' = True\nisVowel 'u' = True\nisVowel 'e' = True\nisVowel 'o' = True\nisVowel 'y' = True\nisVowel 'A' = True\nisVowel 'I' = True\nisVowel 'U' = True\nisVowel 'E' = True\nisVowel 'O' = True\nisVowel 'Y' = True\nisVowel x = False\n\naddDot [] = []\naddDot (x:xs) = '.' : x : addDot xs\n\nmain = do \n input <- getLine\n putStrLn . map toLower . addDot . filter (not . isVowel ) $ input\n "}, {"source_code": "import Data.Char\n\ngetAnswer :: String -> String\ngetAnswer line = change (map toLower line)\n\nchange :: String -> String\nchange [] = []\nchange (letter:rest) = if isVowel letter\n then \"\" ++ (change rest)\n else \".\" ++ [letter] ++ (change rest)\n\nisVowel :: Char -> Bool\nisVowel letter = elem letter \"aoyeui\"\n\nmain :: IO ()\nmain = do\n line <- getLine\n putStrLn $ getAnswer line"}, {"source_code": "import Control.Monad\nimport Data.Char\n\nmain = do\n line <- getLine\n let result = solve line\n putStrLn result\n\nsolve :: String -> String\nsolve = foldr (\\curr acc -> if (isVowel curr) then acc else '.':(toLower curr):acc) \"\"\n\nisVowel :: Char -> Bool\nisVowel = (`elem` \"aeiouyAEIOUY\")"}, {"source_code": "import Data.Char\nimport Data.List\n \ncons x = not (x `elem` \"aeiouy\")\n\nmain = do\n s <- getLine\n putStrLn $ ('.':) . intersperse '.' . filter cons . map toLower $ s"}, {"source_code": "\n\n-- notice on hoogle that you can \"hoogle\"\n-- function names which are similar ( or seemingly identical )\n-- to certain C-language function names such as\n\n-- isUpper\n-- isLower\n-- toUpper\n-- toLower\n\nimport Data.Char\nimport Data.Array\n\nconvStr a b \n | (null a) = b\n | (head a) == 'A' || (head a) == 'a' ||\n (head a) == 'E' || (head a) == 'e' ||\n (head a) == 'I' || (head a) == 'i' ||\n (head a) == 'O' || (head a) == 'o' ||\n (head a) == 'U' || (head a) == 'u' ||\n (head a) == 'Y' || (head a) == 'y' = convStr (tail a) b\n | otherwise = convStr (tail a) (concat [b,['.'],[(toLower (head a))]])\n\nmain = do\n oi <- getLine\n let ans = convStr oi \"\"\n putStrLn ans\n\n\n\n\n-- so i just found this.... lol\n-- im still glad that i wrote my parsing function\n\n-- page 84\n\n-- The words function splits an input string on any whitespace. Its counterpart, unwords ,\n-- uses a single space to join a list of words:\n\n\n\n\n\n-- also Ctrl-Shift-p or Ctrl-Shift-n hightlight... in emacs\n\n"}, {"source_code": "import Data.Char\n\nmain = do\n s <- getLine\n putStrLn [j | i <- map toLower s, not $ elem i \"aeiouy\", j <- ['.', i]]\n"}, {"source_code": "import Control.Monad\nimport Data.List\nimport Data.Char\n\nisVowel :: Char -> Bool\nisVowel x = elem x \"AOYEUIaoyeui\"\n\n\nmain :: IO ()\nmain = do\n line <- getLine\n let withoutVowels = filter (not . isVowel) line\n let lower = map toLower withoutVowels\n let withDots = map (\\x -> \".\" ++ [x]) lower\n putStrLn $ foldl (++) [] withDots\n"}, {"source_code": "import Data.Char\n\nisVowel :: Char -> Bool\nisVowel x = (toLower x) `elem` \"aoyeui\"\n\ndotify :: String -> String\ndotify \"\" = \"\"\ndotify [x] = '.':[x]\ndotify (x:xs) = '.':[x]++(dotify xs)\n\nmain :: IO()\nmain = do\n str <- getLine\n putStrLn $ dotify $ filter (\\x -> not $ isVowel x) $ map toLower str "}, {"source_code": "import Prelude\nimport Data.Char\n\nf:: [Char]->[Char]\nf []=[]\nf (x:xs) = if (elem p ['a','o','u','y','i','e']) then (f xs) else (['.']++[p]++(f xs)) where p=toLower x\n\nmain = do\n input <- getLine\n putStrLn $ f input"}, {"source_code": "import Data.Char\n\nmain = do\n line <- getLine\n putStrLn $ concat $ map (\\x -> ['.', x]) $ filter (\\x -> not $ elem x ['a', 'o', 'y', 'e', 'u', 'i']) (map (\\x -> toLower x) line)"}, {"source_code": "import Data.Char\n\nmyprocess :: [Char] -> [Char]\nmyprocess [] = []\nmyprocess (c:left) = \n if c `elem` ['a','e','i','o','u','y']\n then myprocess left\n else ['.',c] ++ myprocess left\n\nmain = do\n str <- getLine\n putStrLn $ myprocess $ map toLower str\n\n"}, {"source_code": "\nimport Data.Char\n\nvowels = \"aeiouy\"\n\nf1 :: String -> String\nf1 [] = []\nf1 (x:xs)\n | x `elem` vowels = f1 xs\n | otherwise = (x:f1 xs)\n\nf2 :: String -> String\nf2 [] = []\nf2 (x:xs) = ('.':x:f2 xs)\n\nmain = do\n a <- getLine\n putStrLn $ f2 $ f1 $ map toLower a"}, {"source_code": "import Data.Char\nmain = interact $ concat . map (('.':) . (:[])) . filter (flip notElem \"aeiouy \\n\") . map (toLower)"}, {"source_code": "import Data.Char\n\ng x\n | x < '0' || elem x \"aoyeui\" = \"\"\n | 1 > 0 = '.' : [x]\n\nmain = interact $ concatMap (g . toLower)\n"}, {"source_code": "import Data.Char\n\nmain = do\n s <- fmap (map toLower) getLine\n \n let\n s' = concat $ map f s\n f 'a' = []\n f 'o' = []\n f 'y' = []\n f 'e' = []\n f 'u' = []\n f 'i' = []\n f c = ['.', c]\n \n putStrLn s'"}, {"source_code": "import Data.Char\n\nfs 'a' = []\nfs 'o' = []\nfs 'y' = []\nfs 'e' = []\nfs 'u' = []\nfs 'i' = []\nfs ' ' = []\nfs '\\n' = []\nfs c = ['.', c]\n\nmain = interact $ concat . map (fs . toLower)\n"}, {"source_code": "{-# LANGUAGE ViewPatterns #-}\n{-# LANGUAGE FlexibleContexts #-}\n{-# LANGUAGE ScopedTypeVariables #-}\n\nmodule Main where\n\n--import Debug.Trace\n\nimport Control.Monad\nimport Control.Monad.ST\nimport Control.DeepSeq\nimport Data.Function\nimport Data.Maybe\nimport Data.Either\nimport Data.Ord\nimport qualified Data.Foldable as Foldable\nimport Data.Char\nimport Data.List\nimport Data.Array.IArray hiding ((!))\nimport Data.Array.MArray.Safe\nimport qualified Data.Array.Unboxed as UA\nimport qualified Data.Array.IO.Safe as IA\nimport Data.Map.Strict (Map)\nimport qualified Data.Map.Strict as Map\nimport Data.IntMap.Strict (IntMap)\nimport qualified Data.IntMap.Strict as IntMap\nimport Data.Set (Set)\nimport qualified Data.Set as Set\n\ngetWords = words <$> getLine :: IO [String]\ngetInts = map read <$> getWords :: IO [Int]\ngetDoubles = map read <$> getWords :: IO [Double]\ngetInt = read <$> getLine :: IO Int\ngetDouble = read <$> getLine :: IO Double\nprintLines :: Show a => [a] -> IO ()\nprintLines = mapM_ print\nprintStrs = mapM_ putStrLn :: [String] -> IO ()\n\n---- Answer Code Section ----\n\nprocess :: String -> String\nprocess = lower . insertPeriod . noVowel where\n noVowel = filter (\\c -> notElem c \"AOYEUIaoyeui\")\n insertPeriod [] = []\n insertPeriod x = \".\" ++ intersperse '.' x\n lower = map toLower\n\nmain = do\n word <- getLine\n putStrLn $ process word\n"}, {"source_code": "import Data.Text as T\n\ntoLowerS :: String -> String\ntoLowerS s = unpack $ toLower (pack s)\n\nvovel :: Char -> Bool\nvovel x\n | x == 'a' || x == 'o' || x == 'y' = True\n | x == 'e' || x == 'u' || x == 'i' = True\n | otherwise = False\n\nsolve word =\n Prelude.concat $ Prelude.map (\\x -> '.':[x]) consonants\n where\n consonants = Prelude.filter (fmap not vovel) (toLowerS word)\n \nmain = do\n line <- getLine\n putStrLn (solve line)\n"}, {"source_code": "import Data.Char\n\nisVowel :: Char -> Bool\nisVowel c = any (== c) ['a', 'o', 'y', 'e', 'u', 'i']\n\ntoLowerString :: String -> String\ntoLowerString = map toLower\n\ncalc :: String -> String\ncalc [] = \"\"\ncalc (c:cs) = if isVowel c\n then calc cs\n else '.' : c : calc cs\n\nmain = do s <- getLine\n putStrLn $ calc $ toLowerString s\n"}, {"source_code": "import Data.Char\nf c | elem c \"aoyeui\" || c < '0' = \"\"\n\t| otherwise \t = '.' : [c]\nmain = interact $ concatMap (f . toLower)"}, {"source_code": "import Data.Char\n\nmain :: IO()\nmain = interact fn\n where fn s = concat $ [if (isVowel c) then \"\" else ('.':c:\"\") | c<-(map toLower $ init s)]\n isVowel c = c `elem` \"aeiouy\"\n"}, {"source_code": "import Data.Char\nmain :: IO ()\nmain = interact $ \n unlines . \n fmap (concatMap (transform . toLower)) . \n lines\n\ntransform :: Char -> String\ntransform x\n | x `elem` \"aoyeui\" = \"\"\n | otherwise = '.' : [x]"}, {"source_code": "import Data.List\nlist = [('Q','q'),('W','w'),('R','r'),('T','t'),('P','p'),('S','s'),('D','d'),('F','f'),('G','g'),('H','h'),('J','j'),('K','k'),('L','l'),('Z','z'),('X','x'),('C','c'),('V','v'),('B','b'),('N','n'),('M','m')]\nmain = \n do\n s <- getLine\n putStrLn (f1 s)\n \nf1 [] = \"\"\nf1 (x:xs) = if show ( find (==x) \"AOYEUIaoyeui\" ) == \"Nothing\" \n then f2 x ++ f1 xs\n else f1 xs\n \nf2 x = let s = show (lookup x list)\n in if s == \"Nothing\"\n then ['.',x]\n else ['.',last (init s)]"}, {"source_code": "import Data.Char\n\nmain = interact $ unlines . map solve . lines . map toLower\n\naddDots = concat . (map $ (\".\"++) . (:[]))\nvowelTest = not . (flip elem $ \"aeiouy\")\nsolve = addDots . filter vowelTest\n"}, {"source_code": "import Data.Char\nmain :: IO ()\nmain = interact $ unlines . fmap transform . lines\n\ntransform :: String -> String\ntransform [] = []\ntransform (x : xs)\n | toLower x `elem` ['a', 'o', 'y', 'e', 'u', 'i'] = transform xs\n | otherwise = '.' : toLower x : transform xs"}, {"source_code": "import Data.Char\nmain = putStrLn . concat . map (\\x -> ['.', x]) . filter (not . flip elem \"aoyeui\") . map toLower =<< getLine"}, {"source_code": "import Data.Char\n\nisVowels :: Char -> Bool\nisVowels c = elem lowerC ['a','e','i','o','u','y']\n where lowerC = toLower c\n\nisCons :: Char -> Bool\nisCons c = not $ isVowels c\n\nconvertStr :: String -> String\nconvertStr [] = \"\"\nconvertStr (x:xs)\n | isCons x = if isUpper x then '.' : toLower x : convertStr xs else '.' : x : convertStr xs\n | isVowels x = convertStr xs\n\nmain :: IO ()\nmain = do n <- getLine\n putStr $ convertStr n\n"}, {"source_code": "import Data.Char\nimport Data.List\nmain = interact $ ('.':) . intersperse '.' . consonants . init . map toLower\nvowels = \"aeiouy\\n\"\nconsonants = filter (\\x->not (elem x vowels))\n"}, {"source_code": "import Data.List\nimport Data.Char\n\nmain = \n\tlet func = (++) ['.'] . intersperse '.' . filter (/= ' ') . map (\\c -> if [toLower c] `isInfixOf` \"aeouyi\" then ' ' else toLower c)\n\tin\n\t\tdo\n\t\t \tstring <- getLine\n\t\t\tputStrLn $ func string"}, {"source_code": "import Data.List\nimport Data.Char\n\nsolve = (:) '.' . intersperse '.' . filter vowelp . map toLower\n where\n vowelp x = notElem x \"aeiouy\"\n \n\n\nmain = do\n foo <- getLine\n putStrLn $ solve foo"}, {"source_code": "import Data.Char\nmain = do\n s <- getLine\n putStrLn $ f s\n \nf s = foldl1 (++) $ map (\\x -> \".\" ++ [x]) $ filter (`notElem` \"aoueyi\") $ map toLower s\n"}, {"source_code": "import Data.Char\nmain = do\n in1 <- getLine\n let in2 = dotto $ filter (not. (`elem` ['a', 'e', 'i', 'o', 'u', 'y'])) $ map toLower in1\n putStrLn in2\ndotto :: String -> String\ndotto = foldr (\\x -> (('.' :).( x :))) []"}, {"source_code": "import Data.Char\n\nanswer::[Char] -> [Char]\nanswer = concatMap (\\x->['.',x]) . filter(`notElem` \"aoyuei\") . fmap toLower\n\nsomeFunc :: IO()\nsomeFunc = getLine >>= putStrLn . answer\n \nmain :: IO ()\nmain = someFunc\n"}, {"source_code": "import Data.Char\nimport Data.List\nvowels=['a', 'e', 'i', 'o', 'u', 'y']\nmain=getLine>>=(\\x-> putStrLn$('.':)$intersperse '.'$filter (\\c->not (c`elem`vowels))$map toLower$ x)"}, {"source_code": "import Control.Applicative\nimport Data.Char\n\nvow = \"aiueoy\"\n\nmain = getLine >>= putStrLn . solve\n\nsolve [] = []\nsolve (x:xs)\n | elem y vow = solve xs\n | otherwise = ['.', y] ++ solve xs\n where y = cap x\n\ncap c\n | 'A' <= c && c <= 'Z' = chr (ord c - ord 'A' + ord 'a')\n | otherwise = c\n \n"}, {"source_code": "module Main where\n\nimport Data.Char\n\nvowels :: String\nvowels = \"aeiouyAEIOUY\"\n\nisVowel :: Char -> Bool\nisVowel c = elem c vowels\n\nremoveVowels :: String -> String\nremoveVowels = filter (not . isVowel)\n\nlowerString :: String -> String\nlowerString = map toLower\n\naddDots :: String -> String\naddDots = foldr (\\x xs -> ['.', x] ++ xs) []\n\nf :: String -> String\nf = addDots . lowerString . removeVowels\n\nmain :: IO ()\nmain = f `fmap` getLine >>= putStrLn\n"}, {"source_code": "import Data.Char\nmain= readsolveprint::IO()\nreadsolveprint::IO()\nreadsolveprint= getLine >>= putStrLn.solve\nsolve :: String->String\nsolve x = foldr (\\a b -> case () of \n _ | foldr (\\ a1 b2 -> a==a1 || b2 ) False \"AEYUIOaeyuio\" -> b\n | otherwise -> '.':(toLower (a):b)) [] x"}, {"source_code": "import Data.Char (toLower)\n\nprocess :: [Char] -> [Char]\nprocess = concat.map (\\c -> ['.',c]) . filter (`notElem` \"aeiouy\").map toLower\n\nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn $ process s"}, {"source_code": "toLow :: Char -> Char\ntoLow x | elem x ['A' .. 'Z'] = toEnum (fromEnum x + 32)\n | otherwise = x\n\nintercalate' :: [a] -> [[a]] -> [a]\nintercalate' _ [] = []\nintercalate' _ (x : []) = x\nintercalate' s (x : xs) = x ++ s ++ intercalate' s xs\n\nprocess :: String -> String\nprocess \"\" = \"\"\nprocess str =\n let vowls = \"aeiouy\"\n str' = map toLow str\n str'' = [ [x] | x <- str', not (elem x vowls) ]\n in \".\" ++ intercalate' \".\" str''\n\nmain :: IO ()\nmain = do\n input <- getLine\n putStrLn $ process input\n"}, {"source_code": "import Data.Char\n\nsolve = concatMap (('.':) . return) . filter (flip notElem \"aoyeui\") . map toLower\n\nmain = interact $ unlines . map solve . lines\n"}, {"source_code": "import Data.Char\n\nmain = interact $ solve . map toLower\n\nsolve = foldl (\\acc x -> if x `elem` \"aoyeiu\\n\" then acc ++ [] else acc ++ ['.'] ++ [x]) []"}, {"source_code": "import Data.Char\nsolve :: String -> String\nsolve s = foldr (\\l acc -> if (elem l \"aoyeui\\n\") then acc else '.':l:acc) [] $ map toLower s\nmain = interact solve\n"}, {"source_code": "import Control.Applicative\nimport Data.Char\n\nvowels = \"aeiouy\"\n\nmain = do\n s <- transform <$> getLine\n putStrLn s\n\ntoLowerCase = map toLower\nremoveVowels = filter (`notElem` vowels)\nappendDot = concatMap (\\c -> ['.',c])\n\ntransform = appendDot . removeVowels . toLowerCase"}, {"source_code": "import Data.Char\nimport Data.List\n\nanswer :: String -> String\nanswer i = \".\" ++ (intersperse ('.') $ filter (\\c -> not $ c `elem` \"aoyeui\\n\") $ filter (/='\\n') $ filter (/='a') $ filter (/='o') $ filter (/='y') $ filter(/='e') $ filter (/='u') $ filter (/='i') $ (map (toLower) i))\n\nmain = do interact $ answer\n"}, {"source_code": "import Data.Char\nimport Data.List\n\nanswer :: String -> String\nanswer i = \".\" ++ (intersperse ('.') $ filter (\\c -> not $ c `elem` \"aoyeui\\n\") $ (map (toLower) i))\n\nmain = do interact $ answer\n"}, {"source_code": "import Data.Char\n\nsolve xs = ['.':x:[] | x <- xs, not (elem x \"aoyeui\")]\n\nmain = interact $ concat . solve . map toLower . init"}, {"source_code": "import Data.Char\n\nsolve xs = ['.':(toLower x):[] | x <- xs, notElem x \"aoyeuiAOYEUI\"]\n\nmain = interact $ concat . solve . init"}, {"source_code": "import Data.Char\n\ntask :: [Char] -> [Char]\ntask [] = [] \ntask (x:xs) \n | x `elem` \"aeiouy\" = task(xs)\n | x == '\\n' = task(xs)\n | otherwise = ['.']++[x]++task(xs)\n\nmain=interact$task.(map toLower)"}, {"source_code": "import Data.Char\n\nisNotVowel x = isAlpha x && x `notElem` \"aeiouy\"\ndot :: String -> String\ndot [] = []\ndot (x:xs) = '.':x:dot xs\nsolve = dot . filter isNotVowel . map toLower \nmain = interact $ solve"}, {"source_code": "import Control.Applicative\nimport Data.Char\nimport Data.List\n\n\n\nmain::IO ()\nmain=do\n x<-(intersperse '.'.filter(\\z-> notElem z \"aeiouy\").map toLower)<$> getLine\n putStrLn ('.':x)\n"}], "negative_code": [{"source_code": "import Data.Char as Char\n\nmain = do\n str <- getLine\n putStrLn $ convert str\n\nconvert :: String -> String\nconvert target = concat [['.',x] | x <- (map Char.toLower target), not(x `elem` \"aeiou\")]\n\n"}, {"source_code": "import Data.Char\nmain :: IO ()\nmain = interact $ transform\n\ntransform :: String -> String\ntransform (x : xs)\n | elem (toLower x) ['a', 'o', 'y', 'e', 'u', 'i'] = transform xs\n | otherwise = '.' : toLower x : transform xs\ntransform [] = []"}, {"source_code": "import Data.Char\nmain = interact $ init . concatMap (\\x->\".\"++[x]) . consonants . map toLower\nvowels = \"aeiouy\"\nconsonants = filter (\\x->not (elem x vowels))\n"}, {"source_code": "import Data.List\nimport Data.Char\n\nsolve = (:) '.' . intersperse '.' . filter vowelp . map toLower\n where\n vowelp x = notElem x \"aeiouy\"\n \n\n\nmain = do\n foo <- getLine\n print $ solve foo"}, {"source_code": "import Data.Char\nmain = do\n s <- getLine\n putStrLn $ f s\n \nf s = foldl1 (++) $ map (\\x -> \".\" ++ [x]) $ filter (`notElem` \"aoueui\") $ map toLower s\n"}, {"source_code": "import Data.Char (toLower)\n\nvowels :: String\nvowels = \"aeouiy\"\n\nisVowel :: Char -> Bool\nisVowel = flip elem vowels\n\nstringTask :: String -> String\nstringTask = concatMap (\\x -> if isVowel x then \"\" else '.' : [toLower x])\n\nmain = do\n\tgetLine >>= putStrLn . stringTask"}, {"source_code": "import Data.List\nimport Data.Char\nmain = do\n s <- getLine\n putStrLn (intersperse '.' (map toLower (filter (\\x -> not $ elem (toUpper x) \"AOYEUI\") s)))\n"}, {"source_code": "import Data.Char\n\nletter :: Char -> String\nletter l\n | elem l ['a', 'e', 'i', 'o', 'u', 'y'] = \"\"\n | otherwise = \".\" ++ [l]\n\ntask :: String -> String\ntask s = foldl (++) [] (map (letter . toLower) s)\n\nmain = do\n s <- getLine\n print . task $ s\n"}, {"source_code": "import Data.Char\n\nisVowel :: Char -> Bool\nisVowel x =\n if x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'\n || x == 'A' || x == 'E' || x == 'I' || x == 'O' || x == 'U'\n then True else False\n\nfilterVowels :: [Char] -> [Char]\nfilterVowels xs = filter (not.isVowel) xs\n\ninsertConsonants :: [Char] -> [Char]\ninsertConsonants [] = []\ninsertConsonants (x:xs) =\n if (not.isVowel) x\n then ['.'] ++ [x] ++ insertConsonants xs\n else [x] ++ insertConsonants xs\n\nreplaceUpperConsonants :: [Char] -> [Char]\nreplaceUpperConsonants = map (\\x -> if (not.isVowel) x then toLower x else x)\n\nmain = do\n line <- getLine\n putStr $ replaceUpperConsonants $ insertConsonants $ filterVowels line\n"}, {"source_code": "import Data.Char\n\nconv :: Char -> String\nconv a\n | elem a \"aoyeui\" = \"\"\n | otherwise = ['.', a]\n\nsolve :: String -> String\nsolve (x:xs) = (conv $ toLower x) ++ solve xs \nsolve \"\" = \"\"\n\n\nreadInt :: String -> Int\nreadInt = read\n\nparseLogic :: String -> String\nparseLogic = solve\n\nmain = interact parseLogic\n\n\n\n\n\n"}, {"source_code": "import Data.Char\n\nchangeVowel :: Char -> String\nchangeVowel c\n | elem c \"aiueoy\" = \"\"\n | isLower c = ['.', c]\n | isUpper c = ['.', toLower c]\n\nmain :: IO ()\nmain = do\n cs <- getLine\n putStrLn $ foldr1 (++) $ map changeVowel cs"}, {"source_code": "import Data.Char\nimport System.IO\n\nprocLine :: String -> String\nprocLine [] = []\nprocLine (x:xs) | x `elem` \"aeiouAEIOU\" = procLine xs\n | otherwise = ['.', (toLower x)] ++ procLine xs\n\nmain = do\n mainLoop\n\nmainLoop :: IO ()\nmainLoop = do\n ineof <- isEOF\n if ineof\n then return ()\n else\n do line <- getLine\n putStrLn $ procLine line\n mainLoop\n"}, {"source_code": "import Data.Char\n\nmain :: IO ()\nmain = putStrLn . concat . map (\\x -> ['.', x]) . filter (not . flip elem \"aeiou\") . map toLower =<< getLine"}, {"source_code": "module Main where\n\nimport Data.Char (toLower)\n\nmain :: IO ()\nmain = do\n inp <- getLine\n let word = fmap toLower inp\n woVowels = filter (`notElem` \"aeiou\") word\n output = woVowels >>= (\\x -> ['.', x])\n putStrLn output\n"}, {"source_code": "module Main where\nimport Data.Maybe\nimport Data.Char\nmain = getLine >>= \\word -> print $ foldl (\\acc c -> if toUpper c `notElem` ['A','O','Y','E','U','I'] then acc ++ \".\" ++ [toLower c] else acc) \"\" word\n"}, {"source_code": "import Data.List\nimport Data.Char\nmain = interact $ ('.' :) . intersperse '.' . filter (`notElem` \"aeiouy\") . map toLower\n"}, {"source_code": "import Data.Char\nimport Data.List\n\nmain = do\n\ts <- getLine\n\tputStrLn (intersperse '.' (filter (\\c -> not (elem c \"aeiouy\")) (map toLower s)))"}, {"source_code": "module Main \nwhere\nimport Data.Char\nimport Data.List\n\nmain = do\n interact process \n\nprocess str = \n let \n inp = (lines str) !! 0\n lstr = [x | x <- (map toLower inp), x `notElem` \"aeiou\"]\n in do\n (drop 1 . intersperse '.' $ ' ': lstr) ++ \"\\n\"\n \n\n \n"}, {"source_code": "import Control.Monad\nimport Data.Char\n\nmain = do\n line <- getLine\n let result = solve line\n putStrLn result\n\nsolve :: String -> String\nsolve s = concat $ map ((\\l -> if (isVowel l) then \"\" else ['.', l]) . toLower) s\n\nisVowel :: Char -> Bool\nisVowel = (`elem` \"aeiou\")"}, {"source_code": "import Data.Char (toLower)\nimport Data.List (intersperse)\nmain = getLine >>= putStrLn . ('.' :) . intersperse '.' . map toLower . filter (`notElem` \"aeiou\") "}, {"source_code": "import Data.Char (toLower)\nimport Data.List (intersperse)\nmain = getLine >>= putStrLn . ('.' :) . intersperse '.' . map toLower . filter (`notElem` \"aeiouy\") "}, {"source_code": "{-# LANGUAGE Safe #-}\n{-# Options_GHC -O3 #-}\nimport Data.ByteString.Builder\nimport Data.Monoid\nimport System.IO\nimport qualified Data.ByteString.Char8 as C\nimport Data.Char\n\nru, ri :: C.ByteString -> Int\n\nru = C.foldl' (\\a c -> a * 10 - 48 + ord c) 0\nri s\n | C.head s == '-' = negate $ ru $ C.tail s\n | otherwise = ru s\n\nvowel 'a' = True\nvowel 'o' = True\nvowel 'y' = True\nvowel 'e' = True\nvowel 'u' = True\nvowel 'i' = True\nvowel _ = False\n\n\nmain = hPutBuilder stdout . byteString . C.concatMap (\\c -> C.pack ['.', c]) . C.filter (not . vowel) . C.map toLower . head . C.lines =<< C.getContents\n"}, {"source_code": "import Data.Char\n\nmain = do\n line <- getLine\n print $ concat $ map (\\x -> ['.', x]) $ filter (\\x -> not $ elem x ['a', 'o', 'y', 'e', 'u', 'i']) (map (\\x -> toLower x) line)"}, {"source_code": "import Data.Char\n\nmyprocess :: [Char] -> [Char]\nmyprocess [] = []\nmyprocess (c:left) = \n if c `elem` ['a','e','i','o','u']\n then myprocess left\n else ['.',c] ++ myprocess left\n\nmain = do\n str <- getLine\n putStrLn $ myprocess $ map toLower str\n\n"}, {"source_code": "\nimport Data.Char\n\nvowels = \"aeiouy\"\n\nf1 :: String -> String\nf1 [] = []\nf1 (x:xs)\n | x `elem` vowels = f1 xs\n | otherwise = (x:f1 xs)\n\nf2 :: String -> String\nf2 [] = []\nf2 (x:xs) = ('.':x:f2 xs)\n\nmain = do\n a <- getLine\n putStrLn $ f1 $ map toLower a\n putStrLn $ f2 $ f1 $ map toLower a"}, {"source_code": "import Data.Char\nmain = interact $ concat . map (('.':) . (:[])) . filter (flip notElem \"aeiouy\") . map (toLower)"}, {"source_code": "import Data.Char\n\nf xs = concat [ ['.', x] | x <- xs, x `notElem` \"aoyeui\"]\n\nmain = interact $ f . map toLower"}, {"source_code": "import Data.Char\n\nf xs = concat [ ['.', x] | x <- xs, x `notElem` \"aoyeui \"]\n\nmain = interact $ f . map toLower\n"}, {"source_code": "main = interact (\\s -> concat (map (\\c->if c `elem` \"AOYEIUaoyeiu\\n\" then \"\" else '.':c:\"\") s) ++ \"\\n\")\n"}, {"source_code": "import Data.Char\n\nisVowel :: Char -> Bool\nisVowel c = any (== c) ['a', 'o', 'y', 'e', 'u', 'i']\n\ntoLowerString :: String -> String\ntoLowerString = map toLower\n\ncalc :: String -> String\ncalc [] = \"\"\ncalc (c:cs) = if isVowel c\n then calc cs\n else '.' : c : calc cs\n\nmain = do s <- getLine\n print $ calc $ toLowerString s\n"}, {"source_code": "import Data.Char (toLower)\n\nmain = putStrLn . concatMap (\\ (a,b) -> [a,b]) . zip (repeat '.') . filter (`notElem` \"aeiou\") . map toLower =<< getLine\n"}, {"source_code": "import Data.Char\n\nmain = interact $ addDots . filter vowelTest . map toLower\n\naddDots = concat . (map $ (\".\"++) . (:[]))\nvowelTest = not . (flip elem $ \"aeiouy\")\n\n"}, {"source_code": "import Data.Char\n\nmain = interact $ map toLower . unlines . map addDots . map (filter vowelTest) . lines\n\naddDots = concat . (map $ (\".\"++) . (:[]))\nvowelTest = not . (flip elem $ \"aeiouy\")\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.Char\nimport Data.List\n\n \n\nmain= do\n\tw<- getLine \n\tlet w1 = map toLower $ filter (\\z-> notElem z \"AEIOUYaeiouy\") w\n\tlet w2 = intersperse '.' w1\n\tputStrLn w2\n"}, {"source_code": "import Data.Char ( toLower )\n\ntransform :: String -> String\ntransform = concat . map transform'\n where\n transform' :: Char -> String\n transform' c\n | toLower c `elem` ['a', 'e', 'i', 'o', 'u'] = \"\"\n | otherwise = ['.',toLower c]\n\nmain :: IO ()\nmain = transform <$> getLine >>= putStrLn\n"}, {"source_code": "import Data.Char\nimport Data.List\n\nmain = interact $ ('.' :) . intersperse '.' . filter (`notElem` \"aeiouy\") . map toLower"}, {"source_code": "import Data.Char\nimport Data.List\nvowels=['a', 'e', 'i', 'o', 'u', 'y']\nmain=getLine>>=(\\x-> print$('.':)$intersperse '.'$filter (\\c->not (c`elem`vowels))$map toLower$ x)"}, {"source_code": "import Data.Char\nimport Data.List\nvowels=['a', 'e', 'i', 'o', 'u', 'y']\nmain=getLine>>=(\\x-> print$('.':)$intersperse '.'$map toLower$filter (\\c->not (c`elem`vowels)) x)"}, {"source_code": "module Main where\n\nimport Data.Char\n\nvowels :: String\nvowels = \"aeiouAEIOU\"\n\nisVowel :: Char -> Bool\nisVowel c = elem c vowels\n\nremoveVowels :: String -> String\nremoveVowels = filter (not . isVowel)\n\nlowerString :: String -> String\nlowerString = map toLower\n\naddDots :: String -> String\naddDots = foldr (\\x xs -> ['.', x] ++ xs) []\n\nf :: String -> String\nf = addDots . lowerString . removeVowels\n\nmain :: IO ()\nmain = f `fmap` getLine >>= putStrLn\n"}, {"source_code": "module Main (main) where\n\nimport Data.Char\nimport Data.List\n\nmain :: IO ()\nmain = do cont <- getContents\n putStrLn $ ('.' :) $ intersperse '.' $ filter (not . (`elem` \"aoyeui\")) $ fmap toLower cont"}, {"source_code": "import Data.Char (toLower)\n\nprocess :: [Char] -> [Char]\nprocess = concat.map (\\c -> ['.',c]) . filter (`notElem` ['a','e','i','o','u']).map toLower\n\nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn $ process s"}, {"source_code": "import Data.Char\n\nmain = interact $ solve . map toLower\n\nsolve = foldl (\\acc x -> if x `elem` \"aoyeiu\" then acc ++ [] else acc ++ ['.'] ++ [x]) []"}, {"source_code": "import Data.Char\n\ngetAnswer :: String -> String\ngetAnswer line = change (map toLower line)\n\nchange :: String -> String\nchange [] = []\nchange (letter:rest) = if isVowel letter\n then \"\" ++ (change rest)\n else \".\" ++ [letter] ++ (change rest)\n\nisVowel :: Char -> Bool\nisVowel letter = elem letter \"aoyeui\"\n\nmain :: IO ()\nmain = do\n line <- getLine\n print $ getAnswer line"}, {"source_code": "import Data.Char as Char\nmain = interact $ foldr1 (++) . map (\\c -> '.':[c]) . filter (\\c -> not $ elem c \"aeiou\") . map Char.toLower\n"}, {"source_code": "import Data.Char as Char\nmain = interact $ foldr1 (++) . map (\\c -> '.':[c]) . filter (\\c -> not $ elem c \"aeiou\\n\") . map Char.toLower\n"}, {"source_code": "import Data.Char\nimport Control.Monad\nmain = interact $ join . map p\n\np 'A' = \"\"\np 'E' = \"\"\np 'I' = \"\"\np 'O' = \"\"\np 'U' = \"\"\np 'a' = \"\"\np 'e' = \"\"\np 'i' = \"\"\np 'o' = \"\"\np 'u' = \"\"\np '\\n' = \"\"\np x = '.' : toLower x : mempty\n\n"}, {"source_code": "import Data.Char\nimport Control.Monad\nmain = interact $ join . map p\n\np 'A' = \"\"\np 'E' = \"\"\np 'I' = \"\"\np 'O' = \"\"\np 'U' = \"\"\np 'a' = \"\"\np 'e' = \"\"\np 'i' = \"\"\np 'o' = \"\"\np 'u' = \"\"\np x = '.' : toLower x : mempty\n\n"}, {"source_code": "module Main where\n\nimport Control.Applicative\n\nimport Data.Char(isLower, toLower)\n\ntoInt :: String -> Int\ntoInt = read\n\nisVowel :: Char -> Bool\nisVowel = (`elem` \"aeiou\") . toLower\n\nsolve :: String -> String\nsolve (x:xs)\n | isVowel x = solve xs\n | isLower x = '.': x:[] ++ solve xs\n | otherwise = '.':toLower x:[] ++ solve xs\nsolve \"\" = \"\"\n\nmain :: IO ()\nmain = putStrLn <$> solve =<< getLine\n"}, {"source_code": "import Data.Char\n\ncheck :: String -> String\ncheck xs = g $ map toLower xs\n where\n g [] = []\n g (x : xs)\n | elem x ['a', 'o', 'y', 'e', 'u', 'i'] = g xs\n | otherwise = '.' : x : g xs\n\nmain :: IO ()\nmain = do cs <- getLine\n print $ check cs"}, {"source_code": "module Main where\n\nimport Data.Char\n\n(|>) = flip (.)\n\nisVowel :: Char -> Bool\nisVowel c = (toLower c) `elem` ['a', 'e', 'i', 'o', 'u']\n\nmain = interact $\n takeWhile (\\x -> x /= '\\n')\n |> filter (not . isVowel) \n |> map toLower \n |> map (\\x -> ['.',x]) \n |> foldr (++) []\n"}, {"source_code": "module Main where\n\nimport Data.Char\n\n(|>) = flip (.)\n\nisVowel :: Char -> Bool\nisVowel c = (toLower c) `elem` ['a', 'e', 'i', 'o', 'u']\n\nmain = interact $\n filter (not . isVowel) \n |> map toLower \n |> map (\\x -> ['.',x]) \n |> foldr (++) []\n"}, {"source_code": "import Data.Char\n\nmain = do\n\tline <- getLine\n\tputStrLn $ answer line;\n\nanswer :: String -> String\nanswer a = foldr1 (++) $ zipWith (\\a b -> (a : b : [])) (repeat '.') $ filter (not . isVowel) a\n\nisVowel :: Char -> Bool\nisVowel x = elem (toUpper x) ['A', 'E', 'I', 'O', 'U']\n"}, {"source_code": "import Data.Char\n\nmain = do\n\tline <- getLine\n\tputStrLn $ answer line;\n\nanswer :: String -> String\nanswer a = foldr1 (++) $ zipWith (\\a b -> (a : b : [])) (repeat '.') $ map toLower $ filter (not . isVowel) a\n\nisVowel :: Char -> Bool\nisVowel x = elem (toUpper x) ['A', 'E', 'I', 'O', 'U']\n"}, {"source_code": "import Data.List\nimport Data.Char\n\nremoveVowel :: Char -> Bool\nremoveVowel s = not (s `elem` ['a','e','i','o','u'])\n\nremoveVowels :: String -> String\nremoveVowels str = filter (removeVowel) str\n\naddDots :: String -> String\naddDots str = intersperse '.' str\n\nprocessStr :: String -> String\nprocessStr str = let lstr = map toLower str in\n let pstr = addDots $ removeVowels lstr in ['.'] ++ pstr\n\n\nmain = do\n str <- getLine\n putStrLn( processStr str )\n"}, {"source_code": "import Data.Char\n\nmain = interact $ solve []\n\nsolve acc [] = acc\nsolve acc (s:ss)\n | elem s \"AOYEUIaoyeui\" = solve acc ss\n | otherwise = solve (acc++\".\"++ [toLower s]) ss"}, {"source_code": "import Data.Char\n\nmain = interact $ solve []\n\nsolve acc [] = acc\nsolve acc (s:ss)\n | elem s \"AOYEUI aoyeui\" = solve acc ss\n | otherwise = solve (acc++\".\"++ [toLower s]) ss"}, {"source_code": "import Char\ng x | elem x \"aoyeui\" = \"\"\n | 1 > 0 = '.':[x]\nmain = interact $ concatMap (g.toLower)\n"}, {"source_code": "import Data.Char\nimport Data.List\nrv []=[]\nrv (x:xs)\n\t| elem x \"aeiuo\" = rv xs\n\t| otherwise = x: rv xs\nf s=init$'.':intersperse '.' (rv$map toLower s)\nmain=interact$f"}, {"source_code": "import Data.Char\nimport Data.List\nrv []=[]\nrv (x:xs)\n\t| elem x \"aeiuo\" = rv xs\n\t| otherwise = x: rv xs\nf s='.':intersperse '.' (rv$map toLower (init s))\nmain=interact$f"}, {"source_code": "import Data.Char\nimport Data.List\n\ncons x = not (x `elem` \"aeiou\")\n\nmain = interact $ ('.':) . intersperse '.' . filter cons . map toLower"}, {"source_code": "\n\n-- notice on hoogle that you can \"hoogle\"\n-- function names which are similar ( or seemingly identical )\n-- to certain C-language function names such as\n\n-- isUpper\n-- isLower\n-- toUpper\n-- toLower\n\nimport Data.Char\nimport Data.Array\n\n\n\n\nconvStr a b \n | (null a) = b\n | (head a) == 'A' || (head a) == 'a' ||\n (head a) == 'E' || (head a) == 'e' ||\n (head a) == 'I' || (head a) == 'i' ||\n (head a) == 'O' || (head a) == 'o' ||\n (head a) == 'U' || (head a) == 'u' = convStr (tail a) b\n | otherwise = convStr (tail a) (concat [b,['.'],[(toLower (head a))]])\n\nmain = do\n oi <- getLine\n let ans = convStr oi \"\"\n putStrLn ans\n\n\n\n\n"}, {"source_code": "import Data.Char\nimport Data.List\n\nisConsonant :: Char -> Bool\nisConsonant c = (toLower c) `notElem` ['a', 'e', 'i', 'o', 'u']\n\nperiodize :: String -> String\nperiodize s = concat . transpose $ [replicate (length s) '.', s]\n\nmain = do\n line <- getLine\n print . periodize . map toLower . filter isConsonant $ line\n"}, {"source_code": "import Data.Char\nimport Data.List\n\nisConsonant :: Char -> Bool\nisConsonant c = (toLower c) `notElem` ['a', 'e', 'i', 'o', 'u']\n\nperiodize :: String -> String\nperiodize s = concat . transpose $ [replicate (length s) '.', s]\n\nmain = do\n line <- getLine\n putStrLn . periodize . map toLower . filter isConsonant $ line\n"}, {"source_code": "import Data.Char\nprn [a]=do\n putChar a\n putChar '.'\nprn (x:xs)=do\n prn [x]\n prn xs\nf str= do\n putChar '.'\n prn [x|x<-(map toLower str),not(elem x \"aeiou\")]\n\nmain=do\n str<-getLine\n f str"}, {"source_code": "import Data.Char\nprn [a]=do\n putChar '.'\n putChar a\nprn (x:xs)=do\n prn [x]\n prn xs\n\n\nmain=do\n str<-getLine\n prn [x|x<-(map toLower str),not(elem x \"aeiou\")]"}, {"source_code": "import Data.Char\nprn [a]=do\n putChar '.'\n putChar a\nprn (x:xs)=do\n prn [x]\n prn xs\n\n\nmain=do\n str<-getLine\n prn [x|x<-(map toUpper str),not(elem x \"aeiou\")]"}, {"source_code": "import Data.Char\nimport Data.List\nmain=interact$(\".\" ++).intersperse '.'.map toUpper.filter (`elem`\"AOYEUI\")\n"}, {"source_code": "import Data.Char\nimport Data.List\nmain=interact$(\".\" ++).intersperse '.'.filter (`elem`\"aoyeui\").map toLower\n"}, {"source_code": "import Data.Char\nimport Data.List\nmain=interact$(\\x->\".\" ++ x ++ \".\").intersperse '.'.filter (`notElem`\"aoyeui\").map toLower\n"}, {"source_code": "import Data.Char\nimport Data.List\nmain=interact$(\".\" ++).intersperse '.'.filter (`elem`\"aoyeui\").map toUpper\n"}, {"source_code": "import Data.Char\nimport Data.List\nmain=interact$(\".\" ++).intersperse '.'.filter (`notElem`\"aoyeui\").map toLower\n"}, {"source_code": "import Data.Char\nf c | elem c \"aoyeui\" = \"\"\n\t| otherwise \t = '.' : [c]\nmain = interact $ concatMap (f . toLower)"}, {"source_code": "import Data.Char\n\nmain :: IO()\nmain = interact fn\n where fn s = concat $ [if (isVowel c) then \"\" else ('.':c:\"\") | c<-(map toLower $ init s)]\n isVowel c = c `elem` \"aeiou\"\n"}, {"source_code": "import Data.Char\n\nmain :: IO()\nmain = interact fn\n where fn s = concat $ [if (isVowel c) then \"\" else ('.':c:\"\") | c<-(map toLower s)]\n isVowel c = c `elem` \"aeiou\"\n"}, {"source_code": "import Data.List\nlist = [('Q','q'),('W','w'),('R','r'),('T','t'),('P','p'),('S','s'),('D','d'),('F','f'),('G','g'),('H','h'),('J','j'),('K','k'),('L','l'),('Z','z'),('X','x'),('C','c'),('V','v'),('B','b'),('N','n'),('M','m')]\nmain = \n do\n s <- getLine\n putStrLn ( map f s )\n \nf x = \n if show ( find (==x) \"AOYEUIaoyeui\" ) == \"Nothing\"\n then let s = show (lookup x list)\n in if s == \"Nothing\" \n then x\n else last $ init s\n else '.'"}, {"source_code": "import Data.Char\n\nisVowels :: Char -> Bool\nisVowels c = elem lowerC ['a','e','i','o','u']\n where lowerC = toLower c\n\nisCons :: Char -> Bool\nisCons c = not $ isVowels c\n\nconvertStr :: String -> String\nconvertStr [] = \"\"\nconvertStr (x:xs)\n | isCons x = if isUpper x then '.' : toLower x : convertStr xs else '.' : x : convertStr xs\n | isVowels x = convertStr xs\n\nmain :: IO ()\nmain = do n <- getLine\n putStr $ convertStr n\n"}, {"source_code": "import Data.List\nimport Data.Char\n\nmain = \n\tlet func = (++) ['.'] . intersperse '.' . filter (/= ' ') . map (\\c -> if [toLower c] `isInfixOf` \"aeouy\" then ' ' else toLower c)\n\tin\n\t\tdo\n\t\t \tstring <- getLine\n\t\t\tputStrLn $ func string"}, {"source_code": "import Data.List\nimport Data.Char\n\nmain = \n\tlet func = (++) ['.'] . intersperse '.' . filter (/= ' ') . map (\\c -> if [c] `isInfixOf` \"aeouy\" then ' ' else toLower c)\n\tin\n\t\tdo\n\t\t \tstring <- getLine\n\t\t\tputStrLn $ func string"}, {"source_code": "import Data.Char (toLower)\n\nmain = do\n f <- getLine\n putStrLn $ encode f\n\nvowels = ['a', 'e', 'i', 'o', 'u']\n\nencode :: String -> String\nencode (x:xs) = if x `elem` vowels\n then encode xs\n else '.':(toLower x):encode xs\nencode [] = [] \n\n \n \n"}, {"source_code": "import Data.Char (toLower)\n\nmain = do\n f <- getLine\n putStrLn $ encode f\n\nvowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']\n\nencode :: String -> String\nencode (x:xs) = if x `elem` vowels\n then encode xs\n else '.':(toLower x):encode xs\nencode [] = [] \n\n \n \n"}, {"source_code": "import Control.Applicative\nimport Data.Char\n\nvow = \"aiueo\"\n\nmain = getLine >>= putStrLn . solve\n\nsolve [] = []\nsolve (x:xs)\n | elem y vow = solve xs\n | otherwise = ['.', y] ++ solve xs\n where y = cap x\n\ncap c\n | 'A' <= c && c <= 'Z' = chr (ord c - ord 'A' + ord 'a')\n | otherwise = c\n \n"}, {"source_code": "module Main where\n\nimport Control.Applicative\nimport Control.Monad\nimport Data.Char (toLower)\nimport Data.List (intersperse)\n\nvowels :: String\nvowels = \"aoyeui\"\n\nprocess :: String -> String\nprocess input = show $ solve word\n where\n word = map toLower input\n solve word = '.' : intersperse '.' (filter (`notElem` vowels) word)\n\nmain :: IO ()\nmain = interact process\n"}, {"source_code": "toLow :: Char -> Char\ntoLow x | elem x ['A' .. 'Z'] = toEnum (fromEnum x + 32)\n | otherwise = x\n\nintercalate' :: [a] -> [[a]] -> [a]\nintercalate' _ [] = []\nintercalate' _ (x : []) = x\nintercalate' s (x : xs) = x ++ s ++ intercalate' s xs\n\nprocess :: String -> String\nprocess \"\" = \"\"\nprocess str =\n let vowls = \"aeiou\"\n str' = map toLow str\n str'' = [ [x] | x <- str', not (elem x vowls) ]\n in \".\" ++ intercalate' \".\" str''\n\nmain :: IO ()\nmain = do\n input <- getLine\n putStrLn $ process input\n"}, {"source_code": "import Data.Char\nsolve :: String -> String\nsolve s = foldr (\\l acc -> if (elem l \"aoyeui\") then acc else '.':l:acc) [] $ map toLower s\nmain = interact solve\n"}, {"source_code": "import Control.Applicative\nimport qualified Data.ByteString.Char8 as B\nimport Data.Char\n\nvowels = \"aeiouy\"\n\nmain = do\n s <- transform <$> B.getLine\n B.putStrLn s\n\ntoLowerCase = B.map toLower\nremoveVowels = B.filter (`notElem` vowels)\nappendDot = B.concatMap (\\c -> B.pack $ '.':c:[])\n\ntransform = appendDot . removeVowels . toLowerCase"}, {"source_code": "import Data.Char\nimport Data.List\n\nanswer :: String -> String\nanswer i = intersperse ('.') $ filter (/='a') $ filter (/='o') $ filter (/='y') $ filter(/='e') $ filter (/='u') $ filter (/='i') $ (map (toLower) i)\n\nmain = do interact $ answer\n"}, {"source_code": "import Data.Char (toLower)\nimport Data.List (intersperse)\n\nmain = do\n input <- getLine\n let vowels = ['a', 'e', 'i', 'o', 'u']\n putStrLn $\n (('.':) .\n intersperse '.' .\n filter (`notElem` vowels) .\n map toLower) input\n"}, {"source_code": "import Data.Char (toLower)\n\nmain = do\n input <- getLine\n let vowels = ['a', 'e', 'i', 'o', 'u']\n putStrLn $\n (foldr (\\c acc -> '.':c:acc) [] .\n filter (`notElem` vowels) .\n map toLower) input\n"}, {"source_code": "import Data.Char\n\nsolve xs = ['.':x:[] | x <- xs, not (elem x \"aoyeui\")]\n\nmain = interact $ concat . solve . map toLower\n"}, {"source_code": "import Data.Char\n\ntask :: [Char] -> [Char]\ntask [] = [] \ntask (x:xs) \n | x `elem` \"aeiouy\" = task(xs)\n | otherwise = ['.']++[x]++task(xs)\n\nmain=interact$task.(map toLower)"}, {"source_code": "import Data.Char\n\nisNotVowel x = isAlpha x && x `notElem` \"aeiou\"\ndot :: String -> String\ndot [] = []\ndot (x:xs) = '.':x:dot xs\nsolve = dot . filter isNotVowel . map toLower \nmain = interact $ solve"}, {"source_code": "import Data.Char\n\nisNotVowel x = x `notElem` \"aeiou\"\ndot :: String -> String\ndot [] = []\ndot (x:xs) = '.':x:dot xs\nsolve = dot . filter isNotVowel . map toLower \nmain = interact $ solve"}, {"source_code": "import Control.Applicative\nimport Data.Char\nimport Data.List\n\n\n\nmain::IO ()\nmain=do\n x<-(intersperse '.'.filter(\\z-> notElem z \"aeiou\").map toLower)<$> getLine\n putStrLn ('.':x)\n"}, {"source_code": "import Data.Char\nmain = interact $ (foldl func \"\").(filter (\\x -> not(x `elem` \"aoyeui\"))) . (map toLower)\n where func str c = str ++ \".\" ++ [c]"}], "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b"} {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\ntype Case = Int\n\n\nsolve :: Case -> String\nsolve n = show ans\n where\n lim = 1 + n\n \n gcd 0 n = n\n gcd m n \n | m > n = \n let n' = m `mod` n\n in gcd n' n\n | otherwise =\n let n' = n `mod` m\n in gcd n' m\n \n \n ans = sum [ 1 | u<-takeWhile (\\u->u*u i*(u*u+v*v) getLine\n putStrLn $ solve n\n", "positive_code": [{"source_code": "-- 304A\n\nimport Data.Array.ST\nimport Data.Array.Unboxed\n\nsqrt's :: UArray Int Bool\nsqrt's = runSTUArray $ do\n array <- newArray (1, n^2) False\n sequence\n [writeArray array (i^2) True\n | i <- [1 .. n]]\n return array\n where\n n = 10^4 + 1\n\nsqrtInt :: Int -> Int\nsqrtInt = round . sqrt . fromIntegral\n\nisSqrt :: Int -> Bool\nisSqrt n = sqrt's ! n\n\nsolve :: Int -> Int\nsolve n = length\n [1 | a <- [1 .. (n * 100) `div` 141],\n b <- [a+1 .. sqrtInt (n^2 - a^2)],\n isSqrt (a^2 + b^2)]\n\nmain :: IO ()\nmain = readLn >>= print . solve"}, {"source_code": "expand :: Int -> (Int, Int, Int) -> [(Int, Int, Int)] \nexpand n t@(x,y,z)\n | any (>n) [x,y,z] = []\n | otherwise = t : concatMap (expand n) (map fromMat matrices)\n where fromMat x = case map (mul3ple t) x of [u,v,w] -> (u,v,w)\nmatrices = [[( 1,-2, 2),( 2,-1, 2),( 2,-2, 3)]\n ,[( 1, 2, 2),( 2, 1, 2),( 2, 2, 3)]\n ,[(-1 ,2 ,2),(-2 ,1 ,2),(-2 ,2 ,3)]]\nmul3ple (u,v,w) (i,j,k) = u*i + v*j + w*k\nsolve n = sum . map cnt $ expand n (3,4,5)\n where cnt t@(x,y,z) = n `div` maximum [x,y,z]\nmain = putStrLn . show . solve . read =<< getLine"}, {"source_code": "import Control.Applicative\nimport Data.List\n \n \n \nmain=do\t \n\tn<-read<$> getLine:: IO Int \n\tprint $ length[1|a<-[1..n-1],b<-[a..n-1], let c2= a*a+b*b, c2 <=n*n , let d= floor (sqrt (fromIntegral c2)), d*d ==c2 ]\n\t "}, {"source_code": "{-# OPTIONS -O2 #-}\nimport qualified Data.Set as S\nmain = fmap (solve.read) getLine >>= print\n\nsolve :: Int -> Int\nsolve n = length [ () | a <- [1..n], b <- [a+1..n], fm (a*a+b*b)]\n where fm v = v <= n*n && c*c == v\n where c = truncate $ sqrt $ (fromIntegral v :: Float)\n"}], "negative_code": [], "src_uid": "36a211f7814e77339eb81dc132e115e1"} {"source_code": "main = readsolveprint\nreadsolveprint = interact $ solve \"\". head.take 1 . lines\n where\n solve \"1111111\" _ =\"YES\"\n solve \"0000000\" _ =\"YES\"\n solve _ \"\" =\"NO\"\n solve _ (y:ys)= solve (take 7 (y:ys)) ys ", "positive_code": [{"source_code": "module Main where\n\nimport Data.List\n\nmain = do\n str <- getLine\n putStrLn $ if isInfixOf (replicate 7 '0') str || isInfixOf (replicate 7 '1') str then \"YES\" else \"NO\"\n"}, {"source_code": "import Data.List (groupBy)\nimport Data.Bool (bool)\n\nmain = interact $\n bool \"YES\" \"NO\" . null . filter (>=7) . map length . groupBy (==)\n"}, {"source_code": "import Data.List\nmain=interact$(\\x-> if (isInfixOf \"1111111\" x || isInfixOf \"0000000\" x) then \"YES\" else \"NO\")\n"}, {"source_code": "import Data.List\nf x\n | (isInfixOf \"0000000\" x) || (isInfixOf \"1111111\" x) = \"YES\"\n | otherwise = \"NO\"\nmain=interact$f"}, {"source_code": "import Data.List\n\nshowYN True = \"YES\"\nshowYN False = \"NO\"\n\nmain = interact $ showYN . any (>=7) . map length . group\n\n-- vim: set expandtab:\n"}, {"source_code": "\nimport Data.List\n\ndangerous lst \n | (null lst) = False\n | (length (head lst)) > 6= True\n | otherwise = dangerous (tail lst)\n\nmain = do\n gg <- getLine\n let ss = group gg\n if (dangerous ss)\n then putStrLn \"YES\"\n else putStrLn \"NO\"\n\n\n\n\n\n \n"}, {"source_code": "-- Snippet: partitionWith\npartitionWith1 eq (a1 : an)\n | not (null an) && eq a1 (head an) = (a1 : r, aLeft)\n | otherwise = ([a1], an)\n where (r, aLeft) = partitionWith1 eq an\n\npartitionWith eq a\n | null a = []\n | otherwise = r : partitionWith eq aLeft\n where (r, aLeft) = partitionWith1 eq a\n\nmain = do\n s <- getLine\n let p = (partitionWith (==) s)\n putStrLn $ if any ((>= 7) . length) p then \"YES\" else \"NO\"\n"}, {"source_code": "import Data.List \n\nfindSub sub xs = findIndex (isPrefixOf sub ) (tails xs) \n\nsolve [s]\n | findSub \"0000000\" s /= Nothing || findSub \"1111111\" s /= Nothing = \"YES\" \n | otherwise = \"NO\"\n \nmain = interact $ solve . words \n"}, {"source_code": "import Data.List\n\nmain = do\n s <- getLine\n putStrLn $\n if any (\\l -> length l >= 7) $ group s then \"YES\" else \"NO\""}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = do\n teams <- getLine\n putStrLn (if isInfixOf \"1111111\" teams || (isInfixOf \"0000000\" teams) then \"YES\" else \"NO\" )\n\n\n"}, {"source_code": "solve [] = []\nsolve (x : []) = [1]\nsolve (x : xs)\n | x == (head xs) = (head $ solve xs) + 1 : (tail $ solve xs)\n | otherwise = 1 : solve xs\n\nmain = do\n s <- getLine\n putStrLn $ if (maximum $ solve s) >= 7 then \"YES\" else \"NO\"\n"}, {"source_code": "import Data.List\n\nmain = do\n s <- getLine\n putStrLn $ if isInfixOf \"0000000\" s || isInfixOf \"1111111\" s then \"YES\" else \"NO\"\n"}, {"source_code": "import Data.List as L\nimport Data.Char\n\nmain = do\n\tstring <- getLine\n\tputStrLn $ if (L.any ((>=7).length) $ group string) then \"YES\" else \"NO\""}, {"source_code": "main = getLine >>= putStrLn . fnc\n\nfnc :: String -> String\nfnc pstn = if ( thrd (dangpos pstn) >= 7) then \"YES\" else \"NO\"\n\ndangpos :: String -> (Char,Int,Int)\ndangpos xs = foldl ( \\ (acc,n,m) x -> if x==acc then (acc, n+1 ,maximum [n+1,m]) else (x,1,m )) ('0',1,1) xs \n\t\t\t\t\nthrd (a,b,c) = c;"}, {"source_code": "import Prelude hiding (any)\n\nisPrefixOf [] _ = True\nisPrefixOf _ [] = False\nisPrefixOf (x:xs) (y:ys) = x == y && isPrefixOf xs ys\n\nany'' p = or . map p\n\nany' _ [] = False\nany' p (x:xs) = p x || any' p xs\n\ntails' :: [a] -> [[a]]\ntails' [] = []\ntails' (x:xs) = (x:xs) : tails' xs\n\nisInfixOf' :: Eq a => [a] -> [a] -> Bool\nisInfixOf' xs ys = any' (isPrefixOf xs) (tails' ys)\n\n\nfootball xs\n | isInfixOf' \"0000000\" xs || isInfixOf' \"1111111\" xs = \"YES\"\n | otherwise = \"NO\"\n\nmain = interact$football\n"}, {"source_code": "main = interact $ f1 0 ' ' . head . lines\nf1 a b [] = \"NO\"\nf1 a b (c:d) = if b==c then (if a+1>=7 then \"YES\" else f1 (a+1) b d) else f1 1 c d"}, {"source_code": "import Data.Maybe\nimport Data.List\n\nmain = interact $ (answer.isJust.find (7<=).map length.group)\n where answer True = \"YES\"\n answer False = \"NO\""}, {"source_code": "import Data.Function\n\nmain = do\n\tteams <- getLine\n\tlet danger = calcDanger teams 1 1\n\tputStrLn $ if danger >= 7 then \"YES\" else \"NO\"\n\t\ncalcDanger::String -> Int -> Int -> Int\ncalcDanger teams index res = if res >= 7 || length teams == index\n\t\t\t\t\t\t\t\tthen res\n\t\t\t\t\t\t\t else if teams !! (index - 1) == teams !! index\n\t\t\t\t\t\t\t \tthen calcDanger teams (index + 1) (res + 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t \tcalcDanger teams (index + 1) 1"}, {"source_code": "import Data.List\n\nmain = do\n\tteams <- getLine\n\tputStrLn $ if isInfixOf \"0000000\" teams || isInfixOf \"1111111\" teams\n\t\t\t\t\tthen \"YES\"\n\t\t\t\t\telse \"NO\""}, {"source_code": "dangerousImpl 7 _ _ = \"YES\"\ndangerousImpl x _ [] = \"NO\"\ndangerousImpl x p (l:ls)\n | p==l = dangerousImpl (x+1) l ls\n | otherwise = dangerousImpl 1 l ls\n\ndangerous [] = \"NO\"\ndangerous (l:ls) = dangerousImpl 1 l ls\n\nmain = do\n l <- getLine\n putStrLn (dangerous l)\n\n"}, {"source_code": "isDangerous \"1111111\" = True\nisDangerous \"0000000\" = True\nisDangerous a | length a > 7 = isDangerous (take 7 a) || isDangerous (tail a)\n | otherwise = False\ncaps a = putStrLn $ if isDangerous a then \"YES\" else \"NO\"\nmain = getLine >>= caps"}, {"source_code": "import Data.List\n\nmain = do\n input <- getLine\n putStrLn $ id $ danger input\n\ndanger ::[Char] -> String\ndanger x\n |isInfixOf \"0000000\" x = \"YES\"\n |isInfixOf \"1111111\" x = \"YES\"\n |otherwise = \"NO\"\n"}, {"source_code": "\nmain = interact go\n\ngo (c:cs) = go' 6 c cs\n\ngo' 0 _ _ = \"YES\\n\"\ngo' _ _ [] = \"NO\\n\"\ngo' n c0 (c:cs) \n | c0 == c = go' (n-1) c cs\n | otherwise = go' 6 c cs\n"}, {"source_code": "module Main where\nimport Data.List\n\nsolve :: String -> String\nsolve x = \n if (length $ filter (>=7) $ map length $ group x) > 0\n then \"YES\"\n else \"NO\"\n\nmain = do\n line <- getLine\n putStrLn $ solve line\n"}, {"source_code": "import Data.List\n\n\n\n\nmain::IO ()\nmain=do\n a<-getLine\n putStrLn $ if isInfixOf \"0000000\" a || isInfixOf \"1111111\" a then \"YES\" else \"NO\"\n"}, {"source_code": "import Data.List\nmain = interact $ (\\x -> if (any (`isInfixOf` x) [\"1111111\",\"0000000\"]) then \"YES\" else \"NO\")"}, {"source_code": "import Data.List (group)\n\nmain :: IO ()\nmain = getLine >>= putStrLn . solve\n\nsolve :: String -> String\nsolve cs = if any ((>=7) . length) (group cs) then \"YES\" else \"NO\"\n"}, {"source_code": "\nimport Data.List (group)\n\n\nsolve :: (Eq a) => [a] -> Bool\nsolve = any ((>=7).length) . group\n\n\nmain = do players <- getLine\n case solve players of True -> putStrLn \"YES\"\n _ -> putStrLn \"NO\""}, {"source_code": "module Main where\n\n\nimport Data.List (group)\n\n\nsolve :: (Eq a) => [a] -> Bool\nsolve l = any (>=7) . map length $ group l\n\n\nmain = do players <- getLine\n case solve players of True -> putStrLn \"YES\"\n False -> putStrLn \"NO\""}, {"source_code": "import Data.List\n\nrun str = if (>=7) $ maximum $ map length $ group str\n then \"YES\"\n else \"NO\"\n \nmain = interact run "}, {"source_code": "main = interact (\\s -> if dangerous s then \"YES\" else \"NO\")\ndangerous s | length s < 7 = False\n | otherwise = (all (\\x -> x == head s) $ take 7 s) || (dangerous $ tail s)\n"}, {"source_code": "import Data.List\n\nmain :: IO()\nmain = do\n\tt <- getLine\n\tputStr $ getAnswer t\n\ngetAnswer xs = gA xs 0 (head xs)\n\t\twhere \n\t\t\tgA [] cnt _\n\t\t\t\t| cnt >= 7\t= \"YES\"\n\t\t\t\t| otherwise\t= \"NO\"\n\t\t\tgA (x:xs) cnt l\n\t\t\t\t| cnt >= 7\t= \"YES\"\n\t\t\t\t| x == l\t= gA xs (cnt + 1) x\n\t\t\t\t| otherwise\t= gA xs 1 x"}, {"source_code": "module Main where\n\nlongestSeq :: Int -> Int -> Char -> String -> Int\nlongestSeq res _ _ [] = res\nlongestSeq res count prev (x:xs)\n | prev == x = let biggerCount = count + 1 in\n longestSeq (max res biggerCount) biggerCount x xs\n | otherwise = longestSeq (max res count) 1 x xs\n\nmain :: IO ()\nmain = do\n pos <- getLine\n let lengthSeq = longestSeq 1 1 ' ' pos\n output = if lengthSeq >= 7 then \"YES\" else \"NO\"\n putStrLn output\n"}, {"source_code": "module Main where\n\nlongestSeq :: Int -> Int -> Char -> String -> Int\nlongestSeq res _ _ [] = res\nlongestSeq res count prev (x:xs)\n | prev == x = longestSeq (max res (count + 1)) (count + 1) x xs\n | otherwise = longestSeq (max res count) 1 x xs\n\nmain :: IO ()\nmain = do\n pos <- getLine\n let lengthSeq = longestSeq 1 1 ' ' pos\n output = if lengthSeq >= 7 then \"YES\" else \"NO\"\n putStrLn output\n"}, {"source_code": "import Prelude\nimport List\nimport Char\n\nmain = interact q\n\nq = func\n\nfunc::String->String\nfunc = solve\n\nfileInteract func inf ouf = do file <- readFile inf\n writeFile ouf (func file)\n\ntoInt::String->Int\ntoInt = read\n\nasInteger::String->Integer\nasInteger = read\n\ntoString::Int->String\ntoString = show\n\nsolve::[Char]->String\nsolve a | ans a = \"YES\"\n | otherwise = \"NO\"\n\nans::[Char]->Bool\nans = (> 6) . maximum . map length . group"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/96/A\n\nimport Data.List\n\nsolve :: String -> Bool\nsolve = any ((>= 7) . length) . group\n\nmain = do\n s <- getLine\n putStrLn $ if solve s then \"YES\" else \"NO\"\n"}, {"source_code": "module Main where\nimport Data.List\nmain = getLine >>= \\l -> putStrLn $ if isInfixOf \"0000000\" l || isInfixOf \"1111111\" l then \"YES\" else \"NO\"\n"}, {"source_code": "import Data.Char\n\nh :: String -> Int -> Char -> Bool\nh [] cnt _ =\n if (cnt >= 7)\n then True\n else False\nh (x:xs) acc unit\n | (acc >= 7) = True\n | otherwise = \n if x == unit\n then h xs (acc + 1) unit\n else h xs 1 x\n\nmain :: IO()\nmain = do\n a <- getLine\n if (h (tail a) 1 (a!!0))\n then putStrLn \"YES\"\n else putStrLn \"NO\""}, {"source_code": "import Data.List\n\nmain = interact $ \\s -> if isDangerous s then \"YES\" else \"NO\"\n\nisDangerous :: String -> Bool\nisDangerous = any (>=7) . map length . group\n"}, {"source_code": "solve :: [Char] -> [Char]\nsolve ('0' : '0' : '0' : '0' : '0' : '0' : '0' : xy) = \"YES\"\nsolve ('1' : '1' : '1' : '1' : '1' : '1' : '1' : xy) = \"YES\"\nsolve ('0' : '0' : xs) = solve ('0':xs)\nsolve ('1' : '0' : xs) = solve ('0':xs)\nsolve ('0' : '1' : xs) = solve ('1':xs)\nsolve ('1' : '1' : xs) = solve ('1':xs)\nsolve _ = \"NO\"\n\nmain :: IO()\nmain = do\n s <- getLine\n-- contents <- getContents\n-- let input = map ((\\(a:b:_) -> (a, b)) . map (read :: String -> Int) . words) $ lines contents\n putStr(solve s)\n"}, {"source_code": "import Data.List\nmain = do\n a <- getLine\n case filter ((>=7).length) $ group a of\n [] -> putStrLn \"NO\"\n otherwise -> putStrLn \"YES\"\n"}, {"source_code": "module Main where\n\nimport Data.List\nimport Data.Int\nimport Data.Char\n\nreadInt :: String -> Int64\nreadInt = read\n\ncheck :: String -> Char -> Int -> Bool\ncheck _ _ 7 = True\ncheck [] _ _ = False\ncheck (s:ss) last cnt = if s == last then check ss last (cnt + 1) else check ss s 1\n \nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn $ if check s '2' 0 == True then \"YES\" else \"NO\"\n \n "}, {"source_code": "import Data.List\nmain = do n<-getLine\n putStrLn $ if (all (<7).map length.group) n then\n \"NO\"\n else\n \"YES\""}, {"source_code": "import Data.List\nmain=interact$f.any ((>6).length).group\nf a|a=\"YES\"|1>0=\"NO\"\n"}, {"source_code": "import List\np b|b=\"YES\"|1>0=\"NO\"\nmain=interact$p.any((>6).length).group"}, {"source_code": "import Data.List (group)\n\nmain :: IO ()\nmain = do\n players <- getLine\n putStrLn $ if null $ dropWhile (\\l -> length l < 7) $ group players\n then \"NO\"\n else \"YES\"\n return ()\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nmain= do\n\tw<-getLine \n\tlet x=take 1 $ filter (\\z1-> (snd z1 >=7) ) $ map (\\z->(z, length z)) $ group w \n\tputStrLn $ if length x ==1 then \"YES\" else \"NO\" "}, {"source_code": "{-\nA. Football\n============\ntime limit per test: 2 seconds\nmemory limit per test: 256 megabytes\ninput: standard input\noutput: standard output\n\nPetya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to players of another team. If there are at least 7 players of some team standing one after another, then the situation is considered dangerous. For example, the situation 00100110111111101 is dangerous and 11110111011101 is not. You are given the current situation. Determine whether it is dangerous or not.\n\nInput\n-----\nThe first input line contains a non-empty string consisting of characters \"0\" and \"1\", which represents players. The length of the string does not exceed 100 characters. There's at least one player from each team present on the field.\n\nOutput\n------\nPrint \"YES\" if the situation is dangerous. Otherwise, print \"NO\".\n\nSample test(s)\n---------------\ninput\n```\n001001\n```\noutput\n```\nNO\n```\n\ninput\n```\n1000000001\n```\noutput\n```\nYES\n```\n-}\nimport Data.List (group)\n\nboolToStr :: Bool -> String\nboolToStr True = \"YES\"\nboolToStr False = \"NO\"\n\nisDangerous :: String -> Bool\nisDangerous s = 7 <= (maximum . map length $ group s)\n\nmain = do\n input <- getLine\n (putStrLn . boolToStr . isDangerous) input\n"}, {"source_code": "import Data.List\nmain = interact $ \\x -> if isInfixOf \"0000000\" x || isInfixOf \"1111111\" x then \"YES\" else \"NO\""}, {"source_code": "import Data.List\nmain = interact work\n\nwork :: String -> String\nwork input = if (maximum . map length . group) input >= 7 then \"YES\" else \"NO\"\n"}, {"source_code": "import Data.List\n\nmain = getLine >>= putStrLn.answer.all (<7).map length.group\n\nanswer :: Bool -> String\nanswer True = \"NO\"\nanswer False = \"YES\"\n"}, {"source_code": "import Data.List\n\nans str=if any (\\x->length x>6) $ group str then \"YES\" else \"NO\"\n\nmain = interact ans\n "}, {"source_code": "main = interact s\n\ns ('1':'1':'1':'1':'1':'1':'1':_) = \"YES\"\ns ('0':'0':'0':'0':'0':'0':'0':_) = \"YES\"\ns (_:xs) = s xs\ns [] = \"NO\""}, {"source_code": "import Data.List\nmain :: IO ()\nmain = getLine >>= putStrLn . yn . sol \n\nsol :: String -> Bool\nsol = any (>= 7) . map length . group \n\nyn :: Bool -> String\nyn res\n | res = \"YES\"\n | otherwise = \"NO\""}, {"source_code": "import Data.List\n\nwork :: String -> String\nwork input\n | maximum (map length (group input)) >= 7 = \"YES\" \n | otherwise = \"NO\"\n\nmain :: IO ()\nmain = interact work\n\n\n \n"}, {"source_code": "import Data.List\n\nmain = interact $ (\\x -> if x then \"YES\" else \"NO\") . any ((> 6) . length) . group"}, {"source_code": "import Data.List\n\nsolve x\n | isInfixOf \"1111111\" x = \"YES\"\n | isInfixOf \"0000000\" x = \"YES\"\n | otherwise = \"NO\"\nmain = putStrLn . solve =<< getLine"}, {"source_code": "module Main where\n\nisDanger :: [Char] -> Char -> Int -> Bool\nisDanger (x:xs) curChar howMuch | howMuch == 7 = True\n | length xs == 0 = curChar == x && howMuch == 6\n | curChar == x = isDanger xs x (howMuch + 1)\n | otherwise = isDanger xs x 1\n\n\nmain = do\n line <- getLine\n putStrLn (if isDanger line '_' 0 then \"YES\" else \"NO\")\n"}, {"source_code": "\n\n\nconseq [x] cur m = m+1\nconseq (x:y:xs) cur m\n | x == y = conseq (y:xs) (cur+1) (max (cur+1) m)\n | otherwise = conseq (y:xs) 0 m\n\n\nmain = do\n bs <- getLine\n putStrLn $ if conseq bs 0 0 >= 7 then \"YES\" else \"NO\"\n"}, {"source_code": "main = interact $ solve\n\nsolve :: [Char] -> [Char]\nsolve str = solve' str '0' 0\n\nsolve' :: [Char] -> Char -> Int -> [Char]\nsolve' _ _ 7 = \"YES\"\nsolve' \"\" _ _ = \"NO\"\nsolve' (c:str) char count\n | c == char = solve' str char (count+1)\n | otherwise = solve' str c 1"}, {"source_code": "module Main (main)\n where\n\nimport Data.List (group)\n\n\nmain :: IO ()\nmain = putStrLn . toYesNo . check =<< getLine\n where check = (>6) . maximum . map length . group\n toYesNo True = \"YES\"\n toYesNo False = \"NO\""}, {"source_code": "import Data.List\ngo l = if maximum(map length $ group l)>=7 then \"YES\" else \"NO\"\nmain = interact go\n"}, {"source_code": "import Data.List\nsolve :: String -> Bool\nsolve l = (maximum $ map length $ group l) >= 7\n\nmain = do\n l <- getLine\n let r = solve l\n putStrLn $ if r then \"YES\" else \"NO\"\n"}, {"source_code": "allsame s\n | (length s) <= 1 = True\n | head s /= (s !! 1) = False\n | otherwise = allsame (tail s)\n\nsolve s\n | (length s) < 7 = \"NO\"\n | allsame (take 7 s) = \"YES\"\n | otherwise = solve (tail s)\n\nmain = do\n s <- getLine\n putStrLn (solve s)\n"}, {"source_code": "isDangerous :: String -> Bool\nisDangerous [] = False\nisDangerous (x:xs) = helper x xs 1\n where helper :: Char -> String -> Int -> Bool\n helper _ _ 7 = True\n helper _ [] _ = False\n helper c (x:xs) count\n | x == c = helper c xs (count + 1)\n | otherwise = helper x xs 1\n\nsolution :: String -> String\nsolution string\n | isDangerous string = \"YES\"\n | otherwise = \"NO\"\n\nmain :: IO ()\nmain = do\n line <- getLine\n putStrLn (solution line)"}], "negative_code": [{"source_code": "risk [] val\n | val >= 7 = \"YES\"\n | val < 7 = \"NO\"\n\nrisk (x:y:[]) val\n | x == y = risk [] (val + 1)\n | x /= y = risk [] 1\n\nrisk (x:y:z) val\n | val >= 7 = \"YES\"\n | x == y = risk (y:z) (val + 1)\n | x /= y = risk (y:z) 1\n \nmain = do\n s <- getLine\n putStrLn $ risk s 0\n"}, {"source_code": "risk [] val\n | val >= 7 = \"YES\"\n | val < 7 = \"NO\"\n\nrisk (x:y:z) val\n | z == [] && val < 7 = \"NO\"\n | val > 6 = \"YES\"\n | x == y = risk (y:z) (val + 1)\n | x /= y = risk (y:z) 0\n\nmain = do\n s <- getLine\n putStrLn $ risk s 0\n"}, {"source_code": "risk [] val\n | val >= 7 = \"YES\"\n | val < 7 = \"NO\"\n\nrisk (x:y:z) val\n | z == [] && val < 7 = \"NO\"\n | val > 6 = \"YES\"\n | x == y = risk (y:z) (val + 1)\n | x /= y = risk (y:z) 1\n\nmain = do\n s <- getLine\n putStrLn $ risk s 0\n"}, {"source_code": "import Data.List\nmain=interact$show.(\\x-> if (isInfixOf \"1111111\" x || isInfixOf \"0000000\" x) then \"YES\" else \"NO\")\n"}, {"source_code": "import Data.List\nf x\n | (isInfixOf \"0000000\" x) || (isInfixOf \"111111\" x) = \"YES\"\n | otherwise = \"NO\"\nmain=interact$f"}, {"source_code": "import Data.List as L\nimport Data.Char\n\nmain = do\n\tstring <- getLine\n\tputStrLn $ if (L.any ((>7).length) $ group string) then \"YES\" else \"NO\""}, {"source_code": "import Data.Char\n\nsolve :: Eq a => [a] -> Bool\nsolve [] = False\nsolve (x:xs) = let cnt = length $ takeWhile (== x) xs\n in cnt >= 7 || solve xs\n\n\nans True = \"YES\"\nans False = \"NO\"\n\nmain = do\n s <- getLine\n putStrLn $ ans $ solve s\n"}, {"source_code": "\nimport Data.List\nimport Data.Bits\n\nsolve :: String -> String\nsolve s | any (\\x -> length x > 6) $ group s = \"YES\"\n | True = \"NO\"\n\nmain :: IO ()\nmain = do\n s <- getLine \n print $ solve s"}, {"source_code": "import Prelude hiding (any)\n\nisPrefixOf [] _ = True\nisPrefixOf _ [] = False\nisPrefixOf (x:xs) (y:ys) = x == y && isPrefixOf xs ys\n\nany'' p = or . map p\n\nany' _ [] = False\nany' p (x:xs) = p x || any' p xs\n\ntails' :: [a] -> [[a]]\ntails' [] = []\ntails' (x:xs) = xs : tails' xs\n\nisInfixOf' :: Eq a => [a] -> [a] -> Bool\nisInfixOf' xs ys = any' (isPrefixOf xs) (tails' ys)\n\n\nfootball xs\n | isInfixOf' \"0000000\" xs || isInfixOf' \"1111111\" xs = \"YES\"\n | otherwise = \"NO\"\n\nmain = interact$football\n"}, {"source_code": "main = interact $ f2 . f1 0 0 . head . lines\nf1 a b [] = (a,b)\nf1 a b (c:d) = if c == '0' then f1 (a+1) b d else f1 a (b+1) d\nf2 (a,b) = if abs (a-b) >= 7 then \"YES\" else \"NO\""}, {"source_code": "dangerousImpl 7 _ _ = \"YES\"\ndangerousImpl x _ [] = \"NO\"\ndangerousImpl x p (l:ls)\n | p==l = dangerousImpl (x+1) l ls\n | otherwise = dangerousImpl 1 l ls\n\ndangerous [] = \"NO\"\ndangerous (l:ls) = dangerousImpl 1 l ls\n\nmain = do\n l <- getLine\n print (dangerous l)\n\n"}, {"source_code": "import Data.List\n\nmain = do\n input <- getLine\n if (danger input) then (print \"YES\") else print \"NO\"\n\ndanger x\n |isInfixOf x \"0000000\" = True\n |isInfixOf x \"1111111\" = True\n |otherwise = False\n"}, {"source_code": "import Data.List\n\nmain = do\n input <- getLine\n putStrLn $ id $ danger input\n\ndanger ::[Char] -> String\ndanger x\n |isInfixOf x \"0000000\" = \"YES\"\n |isInfixOf x \"1111111\" = \"YES\"\n |otherwise = \"NO\"\n"}, {"source_code": "module Main where\nimport Data.List\n\nsolve :: String -> String\nsolve x = \n if (length $ filter (>=7) $ map length $ group x) > 0\n then \"YES\"\n else \"NO\"\n\nmain = do\n line <- getLine\n print $ solve line\n"}, {"source_code": "import Data.List\n\n\n\n\nmain::IO ()\nmain=do\n a<-getLine\n print $ if isInfixOf \"0000000\" a || isInfixOf \"1111111\" a then \"YES\" else \"NO\"\n"}, {"source_code": "-- State Monad Practise --\n\nnewtype State s a = State {runState :: s -> (a, s)}\ninstance Monad (State s) where \n return a = State $ \\s -> (a, s)\n --(>>=) :: (State s a) -> (a -> (State s b)) -> State s b\n m >>= f = State $ \\s -> \n let (a, s') = runState m s \n (a', s'') = runState (f a) s'\n in (a', s'')\n \n \nget :: State s s\nget = State $ \\s -> (s, s)\n\nput :: s -> State s ()\nput s = State $ \\_ -> ((), s)\n\nevalState :: State s a -> s -> a \nevalState s a = fst(runState s a)\n \n \nfib :: State (Integer, Integer, Int) Integer\nfib = get >>= \\(fstValue, sndValue, n) -> case n == 0 of\n True -> return sndValue\n False -> (put (sndValue, fstValue + sndValue, n - 1) >> fib)\nfootball :: [Char] -> State (Char, Int) String\nfootball (x:xs) = get >>= \\(lastNum, count) -> case lastNum == x of\n True -> case count == 6 of\n True -> return \"YES\" \n False -> put(lastNum, count + 1) >> football xs\n False -> put(x, 1) >> football xs\n \nfootball x = return \"NO\"\n\n\nmain = do\n str <- getLine\n print $ evalState (football str) (str!!0, 1)"}, {"source_code": "main = interact (\\s -> if dangerous s then \"YES\" else \"NO\")\ndangerous s | length s < 7 = False\n | otherwise = all (\\x -> x == '1' || x == '0') $ take 7 s\n"}, {"source_code": "import Data.List\n\nmain :: IO()\nmain = do\n\tt <- getLine\n\tputStr $ show $ getAnswer t\n\ngetAnswer xs = gA xs 0 (head xs)\n\t\twhere \n\t\t\tgA [] cnt _\n\t\t\t\t| cnt >= 7\t= \"YES\"\n\t\t\t\t| otherwise\t= \"NO\"\n\t\t\tgA (x:xs) cnt l\n\t\t\t\t| cnt >= 7\t= \"YES\"\n\t\t\t\t| x == l\t= gA xs (cnt + 1) x\n\t\t\t\t| otherwise\t= gA xs 1 x"}, {"source_code": "module Main where\n\nlongestSeq :: Int -> Int -> Char -> String -> Int\nlongestSeq res _ _ [] = res\nlongestSeq res count prev (x:xs)\n | prev == x = longestSeq res (count + 1) x xs\n | otherwise = longestSeq (max res count) 1 x xs\n\nmain :: IO ()\nmain = do\n pos <- getLine\n let lengthSeq = longestSeq 1 1 ' ' pos\n output = if lengthSeq >= 7 then \"YES\" else \"NO\"\n putStrLn output\n"}, {"source_code": "import Data.Char\n\nh :: String -> Int -> Char -> Bool\nh [] _ _ = False\nh (x:xs) acc unit\n | (acc > 7) = True\n | otherwise = \n if x == unit\n then h xs (acc + 1) unit\n else h xs 1 x\n\nmain :: IO()\nmain = do\n a <- getLine\n if (h (tail a) 1 (a!!0))\n then putStrLn \"YES\"\n else putStrLn \"NO\""}, {"source_code": "import Data.Char\n\nh :: String -> Int -> Char -> Bool\nh [] _ _ = False\nh (x:xs) acc unit\n | (acc >= 7) = True\n | otherwise = \n if x == unit\n then h xs (acc + 1) unit\n else h xs 1 x\n\nmain :: IO()\nmain = do\n a <- getLine\n if (h (tail a) 1 (a!!0))\n then putStrLn \"YES\"\n else putStrLn \"NO\""}, {"source_code": "import Data.Char\n\nh :: String -> Int -> Char -> Bool\nh [] cnt _ =\n if (cnt >= 7)\n then True\n else False\nh (x:xs) acc unit\n | (acc > 7) = True\n | otherwise = \n if x == unit\n then h xs (acc + 1) unit\n else h xs 1 x\n\nmain :: IO()\nmain = do\n a <- getLine\n if (h (tail a) 1 (a!!0))\n then putStrLn \"YES\"\n else putStrLn \"NO\""}, {"source_code": "import Data.List\n\nmain = interact $ \\s -> if isDangerous s then \"YES\" else \"NO\"\n\nisDangerous :: String -> Bool\nisDangerous = any (>7) . map length . group\n"}, {"source_code": "import Data.List\nmain = do\n a <- getLine\n case filter ((>7).length) $ group a of\n [] -> putStrLn \"NO\"\n otherwise -> putStrLn \"YES\"\n"}, {"source_code": "import Data.List\nmain = do\n n <- getLine\n if ((isInfixOf \"1111111\" n) || (isInfixOf \"0000000\" n)) then putStrLn \"Yes\" else putStrLn \"No\""}, {"source_code": "import Data.List\n\nmain = getLine >>= putStrLn.answer.any (>7).map length.group\n\nanswer :: Bool -> String\nanswer True = \"YES\"\nanswer False = \"NO\"\n"}, {"source_code": "main = interact s\n\ns ('1':'1':'1':'1':'1':'1':'1':_) = \"YES\"\ns (_:xs) = s xs\ns [] = \"NO\""}, {"source_code": "main = interact $ show . length . (\\(d:x) -> [a | a <- [1..d], any (\\t -> a `mod` t == 0) x]) . reverse . map read . words"}, {"source_code": "import Data.List\nmain = interact $ (\\x -> if x then \"YES\" else \"NO\").or.map ((3<).length).group\n\n"}], "src_uid": "ed9a763362abc6ed40356731f1036b38"} {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Control.Arrow\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport Text.Printf\n\nmain = do\n\tk <- readLn\n\tas <- concat <$> replicateM 4 getLine\n\n\tputStrLn $ if any ( \\c -> c /= '.' && k * 2 < length ( filter ( == c ) as ) ) as then \"NO\" else \"YES\"\n", "positive_code": [{"source_code": "import Data.List\nimport Control.Applicative\nimport Control.Monad\n\nmain = do\n n <- read <$> getLine\n inp <- concat <$> replicateM 4 getLine\n putStrLn $ if all (<= 2*n) (map length $ group $ sort $ filter (`elem` \"0123456789\")inp)\n then \"YES\" else \"NO\"\n\n \n"}, {"source_code": "import Data.Array\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Char\nimport Data.List\nimport Control.Monad\nimport Control.Monad.ST.Safe\n-- import Debug.Trace\n\ngetInts = fmap (map read . words) getLine :: IO [Int]\n\nmain = do\n k <- readLn\n s <- fmap concat (replicateM 4 getLine)\n\n putStrLn $ if all (<= 2*k) $ elems $ accumArray (+) 0 ('1', '9') $ zip (filter (/= '.') s) (repeat 1)\n then \"YES\"\n else \"NO\"\n"}, {"source_code": "import Control.Applicative ((<$>), (<*>))\nimport Data.Char (isDigit)\nimport Data.List (group, sort)\n\nmain :: IO ()\nmain = putStrLn <$> yesno =<< solve <$> readLn <*> getContents\n\nsolve :: Int -> String -> Bool\nsolve k = all (<=2*k) . map length . group . filter isDigit . sort\n\nyesno :: Bool -> String\nyesno True = \"YES\"\nyesno _ = \"NO\"\n"}, {"source_code": "#!/usr/bin/env runghc\nimport Data.List\nmain = getContents >>= mapM_ putStrLn . solve . lines\nsolve [] = [] ::[String]\nsolve (k:cs) = (:solve r)$ f (read k) . map length . group . sort . filter (/='.') . concat $ t\n where (t,r) = splitAt 4 cs\nf k t\n | null t || k*2>=maximum t = \"YES\"\n | otherwise = \"NO\"\n"}, {"source_code": "-- Codeforces 373A\nmain = interact $ output . solve . input\ninput = lines\noutput = id\nsolve (x:xs) = if and [(k * 2 >=) . length $ filter (i ==) ys | i <- ['1'..'9']]\n then \"YES\" else \"NO\"\n where\n k = read x :: Int\n ys = concat xs"}, {"source_code": "import Data.Tuple\nimport Data.List\nimport Data.Char\n\nincrelist :: Int -> [Int] -> [Int]\nincrelist n ls = let (x,k:ys) = splitAt n ls\n in x ++ (k+1) : ys\n\ncalHistogram :: String -> [Int] -> [Int]\ncalHistogram ns ls \n | ns == [] = ls\n | (head ns) == '.' = calHistogram (tail ns) ls\n | otherwise = calHistogram (tail ns) newls\n where newls = increlist (digitToInt (head ns)) ls\n\ncal :: [String] -> String\ncal ins =\n let k = read $ head ins\n ns = concat $ tail ins\n zeros = repeat 0\n histogram = calHistogram ns ( take 10 zeros )\n val = maximum histogram\n in if val <= 2*k then \"YES\" else \"NO\"\n \n\nmain = interact ( cal . lines)\n"}, {"source_code": "import Data.List\nimport Data.Char\nimport Data.Maybe\nimport Data.Tuple\nimport Debug.Trace\nimport Control.Arrow\nimport Foreign.Marshal.Array\nimport qualified Data.ByteString.Char8 as B\n\ndebug x = trace (show x) x\n(|>) x f = f x; infixl 1 |>\n(||>) mx f = mx >>= (return . f); infixl 1 ||>\nref = (!!)\n\nreadInt = fst.fromJust.B.readInt\ntoDigit n = chr (48 + n)\n\nmain = do\n ls <- getContents ||> lines\n n <- head ls |> readIO :: IO Int\n --[n,k] <- head ls |> words |> map read |> return :: IO [Int]\n ls1 <- (ref ls 1) |> return\n ls2 <- (ref ls 2) |> return\n ls3 <- (ref ls 3) |> return\n ls4 <- (ref ls 4) |> return\n ls1 ++ ls2 ++ ls3 ++ ls4 |> f |> (\\m -> if m <= 2*n then \"YES\" else \"NO\") |> putStrLn\n\n where\n count x ls = length $ filter (== x) ls\n\n f ls = \n foldl max 0 (map (\\i -> count (toDigit i) ls) [1..9])\n"}], "negative_code": [{"source_code": "import Data.List\nimport Control.Applicative\nimport Control.Monad\n\nmain = do\n n <- read <$> getLine\n inp <- concat <$> replicateM 4 getLine\n putStrLn $ if all (<= 2*n) (init $ map length $ group $ sort $ inp)\n then \"YES\" else \"NO\"\n\n \n"}], "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16"} {"source_code": "{-# LANGUAGE BangPatterns #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Data.Int\n\nfactor :: Int64 -> [Int64]\nfactor a\n | a <= 1 = []\n | otherwise = twos a\n where twos a = if even a then [2] ++ twos (quot a 2)\n else oddprimes 3 a\n oddprimes p a | p*p > a = [a]\n | rem a p == 0 = [p] ++ oddprimes p (quot a p)\n | otherwise = oddprimes (p+2) a\n\nsolve :: Int64 -> Int64 -> Int64\nsolve a b\n | b <= 0 = 0\n | a <= 1 = b\nsolve a b = solve' 0 (factor a) a b\n\nsolve' :: Int64 -> [Int64] -> Int64 -> Int64 -> Int64\nsolve' !c [] _ b = b+c\nsolve' !c [p] a b = let (q,r) = quotRem b p in q+r+c\nsolve' !c ps a b\n | g > 1 = solve' c (divide g ps) (quot a g) (quot b g)\n | otherwise = solve' (1+c) ps a (b-1)\n where g = gcd a b\n\ndivide :: Int64 -> [Int64] -> [Int64]\ndivide g ps | g <= 1 = ps\ndivide g (p:ps) | rem g p == 0 = divide (quot g p) ps\ndivide g (p:ps) = p : divide g ps\n\nmain = do\n (a : b : _ ) <- fmap (map read . words) getContents\n print $ solve a b\n", "positive_code": [{"source_code": "{-# LANGUAGE BangPatterns #-}\n\nimport Data.Int\n\nfactor :: Int64 -> [Int64]\nfactor a\n | a <= 1 = []\n | otherwise = twos a\n where twos a = if even a then [2] ++ twos (quot a 2)\n else oddprimes 3 a\n oddprimes p a | p*p > a = [a]\n | rem a p == 0 = [p] ++ oddprimes p (quot a p)\n | otherwise = oddprimes (p+2) a\n\nsolve :: Int64 -> Int64 -> Int64\nsolve a b\n | b <= 0 = 0\n | a <= 1 = b\nsolve a b = solve' 0 (factor a) a b\n\nsolve' :: Int64 -> [Int64] -> Int64 -> Int64 -> Int64\nsolve' !c [] _ b = b+c\nsolve' !c [p] a b = let (q,r) = quotRem b p in q+r+c\nsolve' !c ps a b\n | g > 1 = solve' c (divide g ps) (quot a g) (quot b g)\n | otherwise = solve' (1+c) ps a (b-1)\n where g = gcd a b\n\ndivide :: Int64 -> [Int64] -> [Int64]\ndivide g ps | g <= 1 = ps\ndivide g (p:ps) | rem g p == 0 = divide (quot g p) ps\ndivide g (p:ps) = p : divide g ps\n\nmain = do\n (a : b : _ ) <- fmap (map read . words) getContents\n print $ solve a b\n"}, {"source_code": "import Data.List\n\nprimeFactors :: Integer -> [Integer]\nprimeFactors n = primeFactors' 2 n\n where\n primeFactors' _ 1 = []\n primeFactors' oszto x\n | x > 100 && round (sqrt $ fromInteger x) + 10 < oszto = [x]\n | mod x oszto == 0 = oszto : primeFactors' oszto (div x oszto)\n | otherwise = primeFactors' (oszto + 1) x\n \n\nsolution _ 0 = 0\nsolution factors b = \n case sort $ map (\\tenyezo -> (mod b tenyezo, tenyezo)) factors of\n ((0,elso_oszto):tobbi) -> solution (map snd tobbi) (div b elso_oszto)\n [] -> b\n _ -> (b - ln) + solution factors ln where ln = maximum $ map (\\szam -> div b szam * szam) factors\n \nmain = do\n [a, b] <- fmap (map read . words) getLine\n print $ solution (primeFactors a) b"}], "negative_code": [], "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e"} {"source_code": "import Data.List (sort)\n\nprocess :: Int -> [Int] -> Int\nprocess k as = if n > 12 then -1 else n\n where n = length.takeWhile ( Int\nreadInt = read\n\nmain :: IO ()\nmain = do\n k <- fmap readInt getLine\n as <- fmap (map readInt.words) getLine\n print $ process k as", "positive_code": [{"source_code": "import Data.List\nimport Control.Monad\nmain = replicateM 2 getLine >>= putStrLn.show.check.judge\njudge [\"0\", months] = -1\njudge [t, months] = length.takeWhile (< read t).scanl1 (+).reverse.sort.map read.words $ months\ncheck 12 = -1\ncheck i = succ i"}, {"source_code": "import Data.List\nmain = do\n kS <- getLine\n let k = read kS\n aStr <- getLine\n let \n as :: [Int]\n as = take 12 $ (map read $ words aStr)\n putStrLn.show $ solve k as\n \nsolve k (a:as) \n | k == 0 = 0\n | sum (a:as) < k = -1\n | otherwise =\n [n | n <- [1..12], sum (take n (reverse.sort $ (a:as))) >= k]!!0"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = do\n k:as <- getReadAll\n print $ solve k as\n\nsolve :: Int -> [Int] -> Int\nsolve 0 _ = 0\nsolve k xs = if total < k then -1 else months\n where \n months = (+1).length . takeWhile (< k) . scanl1 (+) . sortBy (flip compare) $ xs\n total = sum xs\n\ngetReadAll :: (Read a) => IO [a]\ngetReadAll = fmap (fmap read. words) getContents "}, {"source_code": "import Data.List\nmain = do l1 <- getLine\n l2 <- getLine\n let k = read l1\n xs = map read.words $ l2\n print $ f k $ xs\nf k xs = let ls = reverse.scanr (+) 0.sort $ xs\n in if last ls < k \n then -1\n else length.takeWhile ( Int -> Int\nsolve (d:ays) sz =\n if sz <= 0\n then 0\n else 1 + solve ays (sz - d)\nsolve [] _ = 0\n \n\nmain = do\n sz <- (getLine >>= return . (read::String->Int))\n days <- (getLine >>= return . map (read::String->Int) . words)\n print $ if (sum days < sz) then (-1) else solve (reverse $ sort days) sz"}, {"source_code": "import Data.List\nmain = do\n\tk<-getLine\n\tr<-getLine\n\tlet m=map read $ words r\n\tlet l = length m\n\tputStrLn $ show $ solve (read k) (reverse(sort m)) 0 l\n\nsolve k m acc l | acc>l = -1\nsolve k m acc l= if sum (take acc m ) >=k then acc else solve k m (acc+1) l"}, {"source_code": "\n\n\n\n\n\nimport Data.List\n\n\n\nconv lst oo\n | (null lst) = reverse oo\n | otherwise = conv (tail lst) (((read (head lst))::Int) : oo)\n\n\ncountmonths lst k months\n | (k <= 0) = months\n | (null lst) && (k > 0) = -1\n | otherwise = countmonths (tail lst) (k - (head lst)) (succ months)\n\n\nmain = do\n rr <- getLine\n ww <- getLine\n\n let k = (read rr)::Int\n aa = reverse (sort (conv (words ww) []))\n \n months = countmonths aa k 0\n\n putStrLn (show months)\n"}, {"source_code": "import Control.Monad\nimport Data.List\nmain = do\n k <- (liftM read) getLine\n m <- (liftM $ reverse . sort . (map read) . words) getLine\n putStrLn . show $ if sum m < k then -1 else length . takeWhile (< k) $ scanl (+) 0 m\n"}, {"source_code": "import Data.List\n\nmain = do\n k <- readLn\n a <- fmap (map read . words) getLine\n\n let\n a' = takeWhile (< k) $ scanl1 (+) $ reverse $ sort a\n\n print $ if k == 0 then 0 else if sum a < k then -1 else length a' + 1\n"}, {"source_code": "import Data.List\n\nsolve :: [Int] -> Int\nsolve (k:lst) = if rk > 0 then -1 else answer\n where \n (rk, answer) = foldl (find) (k, 0) $ sortBy (\\a b -> compare b a) lst\n find (k, ans) a = (k - a, ans + (if k > 0 then 1 else 0))\n\n\nmain = interact $ show.solve.map read.words"}, {"source_code": "import List\nmyget a | a==[] = -1\n | otherwise = length$last a\ngetAns a = myget$takeWhile ((>=(head a)).sum)$tails$sort$tail a\nmain=interact$show.getAns.(map read).words"}, {"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = solve.concat =<< forM [1..2] (\\i-> map (fst.fromJust.C.readInt).C.words<$>C.getLine)\nsolve (x:xs) = print $ slv1 x $ sortBy (\\a b-> b `compare` a) xs\nslv1 x xs = let b= map (\\a-> if a>=x then 1 else 0) $ scanl (+) 0 xs in fromMaybe (-1) $ elemIndex 1 b "}, {"source_code": "import List\n\nreadWords :: IO [String]\nreadWords = getLine >>= return . words\n\nreads :: Read a => IO [a]\nreads = readWords >>= return . (map read)\n\nsolve :: Int -> [Int] -> Int\nsolve k ms = solve' k (reverse (sort ms)) 0\n where\n solve' k ms n\n | k <= 0 = n\n | null ms = -1\n | otherwise = solve' (k - head ms) (tail ms) (n + 1)\n\nmain :: IO ()\nmain = do\n k <- readLn\n ms <- Main.reads\n print (solve k ms)"}, {"source_code": "import Control.Applicative\nimport Data.List (sortBy)\nmain = do\n k <- read <$> getLine\n xs <- sortBy (flip compare) . map read . words <$> getLine\n if k == 0 then print 0 else do\n let ltk [] = -1\n ltk ((i,x):xs)\n | x >= k = i\n | otherwise = ltk xs\n print . ltk . zip [1..] . scanl1 (+) $ xs\n"}, {"source_code": "import List\n\nsolve (k:ms)\n | last ts >= k = length $ takeWhile (< k) ts\n | True = -1\n where ts = scanl (+) 0 $ reverse $ sort ms\n\nmain = interact $ show . solve . map read . words"}, {"source_code": "module Main where\nimport Data.List (sortBy)\n\nreadi :: String -> Int\nreadi = read\n\nparseMonths months = sortBy (\\x y -> compare y x) (map readi $ words months)\n\nparseSolve :: String -> String -> Int\nparseSolve v months = \n solve (readi v) (parseMonths months) 0\n\nsolve v [] acc = if v < 1 then acc else -1\nsolve v (mh:mt) acc = \n if v < 1\n then acc\n else solve (v-mh) mt (acc+1)\n\nmain = do\n v <- getLine\n months <- getLine\n print $ parseSolve v months\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\nprocess q1 n | last q1 getLine ::IO Int\n q1<- scanl1 (+) <$> reverse <$> sort <$> map read <$> words <$> getLine ::IO [Int]\n print $ process q1 n\n"}, {"source_code": "import Data.List (sort)\n\nmain :: IO ()\nmain = getContents >>= print . solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> Int\nsolve [[k], as] = head ([ i | (i, b) <- zip [0..] (scanl (+) 0 (reverse (sort as))), b >= k ] ++ [-1])\n"}, {"source_code": "import Data.List\nmain = do\n k <- readLn\n as <- fmap (reverse . sort . map read . words) getLine\n if sum as < k\n then print (-1)\n else print $ length $ takeWhile ( [Int] -> Maybe Int\nsolve k = f k . reverse . sort\nf :: Int -> [Int] -> Maybe Int\nf k _ | k <= 0 = Just 0\nf k [] = Nothing\nf k (x:xs) | x >= k = Just 1\n | otherwise = fmap (+1) $ f (k-x) xs\nmain = do\n k <- readLn\n a <- fmap (map read . words) getLine\n print $ case solve k a of\n Just x -> x\n Nothing -> -1\n"}, {"source_code": "import Control.Applicative\nimport Data.List(sort)\n\nmain = do k <- read <$> getLine\n xs <- map read <$> words <$> getLine\n print $ solve k xs\n\nsolve :: Int -> [Int] -> Int\nsolve k xs\n | k == 0 = 0\n | sum xs < k = -1\n | otherwise = (13-) $ length $ dropWhile ( [a] -> [a]\nsortDesc = sortBy (comparing Down)\n\nminMonths :: Int -> [Int] -> Int\nminMonths 0 _ = 0\nminMonths k xs\n | sum xs < k = -1\n | m >= k = 1\n | otherwise = 1 + minMonths (k-m) ms\n where (m:ms) = sortDesc xs\n\nmain = do\n k <- readLn\n m <- getLine\n let ms = map read (words m) :: [Int]\n print $ minMonths k ms"}, {"source_code": "import Data.List\n\nsums = scanl (+) 0.reverse.sort\n\nresult [[k],ms]\n\t|sum ms < k = -1\n\t|otherwise = length.takeWhile ( getLine::IO Int\n\ts<- reverse. sort. map read. words <$> getLine :: IO [Int]\n\tlet s1 = scanl (+) 0 s\n\tlet s2 = length $ takeWhile (l = -1\nsolve k m acc l= if sum (take acc m ) >=k then acc else solve k m (acc+1) l"}, {"source_code": "\n\n\n\n\n\nimport Data.List\n\n\n\nconv lst oo\n | (null lst) = reverse oo\n | otherwise = conv (tail lst) (((read (head lst))::Int) : oo)\n\n\ncountmonths lst k months\n | (null lst) || (k <= 0) = months\n | otherwise = countmonths (tail lst) (k - (head lst)) (succ months)\n\n\nmain = do\n rr <- getLine\n ww <- getLine\n\n let k = (read rr)::Int\n aa = reverse (sort (conv (words ww) []))\n \n months = countmonths aa k 0\n\n putStrLn (show months)\n"}, {"source_code": "import Data.List\n\nsolve :: [Int] -> Int\nsolve (k:lst) = if rk > 0 then -1 else answer\n where \n (rk, answer) = foldl (find) (k, 0) $ sort lst\n find (k, ans) a = (k - a, ans + (if k > 0 then 1 else 0))\n\n\nmain = interact $ show.solve.map read.words"}, {"source_code": "module Main where\nimport Data.List (sortBy)\n\nreadi :: String -> Int\nreadi = read\n\nparseMonths months = sortBy (\\x y -> compare y x) (map readi $ words months)\n\nparseSolve :: String -> String -> Int\nparseSolve v months = \n solve (readi v) (parseMonths months) 0\n\nsolve _ [] _ = -1\nsolve v (mh:mt) acc = \n if v < 1\n then acc\n else solve (v-mh) mt (acc+1)\n\nmain = do\n v <- getLine\n months <- getLine\n print $ parseSolve v months\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\n\n\n\nmain = do\n n<- read <$> getLine ::IO Int\n q1<- scanl1 (+) <$> reverse <$> sort <$> map read <$> words <$> getLine ::IO [Int]\n let q2= takeWhile (<=n) q1\n print $ if q2==[] then (if n==0 then 0 else 1) else ((length q2) + (if last q2==n then 0 else 1))\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\nprocess q1 n | sum q1 getLine ::IO Int\n q1<- scanl1 (+) <$> reverse <$> sort <$> map read <$> words <$> getLine ::IO [Int]\n print $ process q1 n\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\n\n\n\nmain = do\n n<- read <$> getLine ::IO Int\n q1<- scanl1 (+) <$> reverse <$> sort <$> map read <$> words <$> getLine ::IO [Int]\n let q2= takeWhile (<=n) q1\n print $ if q2==[] then 0 else ((length q2) + (if last q2==n then 0 else 1))\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\n\n\n\nmain = do\n n<- read <$> getLine ::IO Int\n q1<- scanl1 (+) <$> reverse <$> sort <$> map read <$> words <$> getLine ::IO [Int]\n print $ length $ takeWhile (<=n) q1\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\nprocess q1 n | last q1 getLine ::IO Int\n q1<- scanl1 (+) <$> reverse <$> sort <$> map read <$> words <$> getLine ::IO [Int]\n print $ process q1 n\n"}, {"source_code": "import Data.List (sort)\n\nmain :: IO ()\nmain = getContents >>= print . solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> Int\nsolve [[k], as] = head [ i | (i, b) <- zip [1..] (scanl1 (+) (reverse (sort as))), b >= k ]\n"}, {"source_code": "import Data.List (sort)\n\nmain :: IO ()\nmain = getContents >>= print . solve . map (map read . words) . lines\n\nsolve :: [[Int]] -> Int\nsolve [[k], as] = 1 + length (takeWhile ( getLine::IO Int\n\ts<- reverse. sort. map read. words <$> getLine :: IO [Int]\n\tlet s1 = scanl (+) 0 s\n\tprint $ length $ takeWhile (>= putStrLn.show.check.judge\njudge [t, months] = length.takeWhile (< read t).scanl1 (+).reverse.sort.map read.words $ months\njudge [\"0\", months] = -1\ncheck 12 = -1\ncheck i = succ i"}, {"source_code": "import Data.List\nimport Control.Monad\nmain = replicateM 2 getLine >>= putStrLn.show.check.judge\njudge [t, months] = length.takeWhile (< read t).scanl1 (+).reverse.sort.map read.words $ months\n-- \ncheck 12 = -1\ncheck i = succ i"}, {"source_code": "import Data.List\nmain = do\n\tkS <- getLine\n\tlet k = read kS\n\taStr <- getLine\n\tlet \n\t\tas :: [Int]\n\t\tas = take 12 $ (map read $ words aStr)\n\tputStrLn.show $ solve k as\n\t\nsolve k (a:as) \n\t| sum (a:as) < k = -1\n\t| sum (a:as) == k = 12\n\t| otherwise =\n\t\t[n | n <- [1..12], sum (take n (reverse.sort $ (a:as))) >= k]!!0"}, {"source_code": "import Data.List\nmain = do\n\tkS <- getLine\n\tlet k = read kS\n\taStr <- getLine\n\tlet \n\t\tas :: [Int]\n\t\tas = take 12 $ (map read $ words aStr)\n\tputStrLn.show $ solve k as\n\t\nsolve k (a:as) \n\t| k == 0 = 0\n\t| sum (a:as) < k = -1\n\t| sum (a:as) == k = 12\n\t| otherwise =\n\t\t[n | n <- [1..12], sum (take n (reverse.sort $ (a:as))) >= k]!!0"}, {"source_code": "import Data.List\n\nsolve :: [Int] -> Int -> Int\nsolve (d:ays) sz =\n if sz <= 0\n then 0\n else 1 + solve ays (sz - d)\nsolve [] _ = -1\n \n\nmain = do\n sz <- (getLine >>= return . (read::String->Int))\n days <- (getLine >>= return . map (read::String->Int) . words)\n print $ if (sum days < sz) then (-1) else solve (sort days) sz"}, {"source_code": "import Data.List\n\nsolve :: [Int] -> Int -> Int\nsolve (d:ays) sz =\n if sz <= 0\n then 0\n else 1 + solve ays (sz - d)\nsolve [] _ = -1\n \n\nmain = do\n sz <- (getLine >>= return . (read::String->Int))\n days <- (getLine >>= return . map (read::String->Int) . words)\n print $ if (sum days < sz) then (-1) else solve (reverse $ sort days) sz"}], "src_uid": "59dfa7a4988375febc5dccc27aca90a8"} {"source_code": "{-# LANGUAGE DataKinds #-}\n{-# LANGUAGE KindSignatures #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE DeriveGeneric #-}\n{-# OPTIONS -O2 #-}\n\nimport Control.Applicative (liftA2)\nimport Control.Monad (filterM, guard)\nimport Control.Monad.State.Strict (State, evalState, get, modify, put)\nimport Data.Bits ((.&.), (.|.), setBit, shiftL, shiftR, testBit)\nimport Data.Char (ord)\nimport Data.Int (Int8)\n\nimport Control.Monad.ST (ST, runST)\n\n-- import Data.HashTable.ST.Cuckoo (HashTable)\nimport Data.IntMap.Strict (IntMap, empty, insert, lookup)\n\nimport Control.DeepSeq (NFData, deepseq)\nimport GHC.Generics (Generic)\nimport GHC.TypeNats (KnownNat, Nat, natVal)\nimport Numeric.Natural (Natural)\nimport Prelude hiding (lookup)\n\nnewtype ModuloRing (p :: Nat) =\n ModuloRing Natural\n deriving (Eq, Generic)\n\ninstance NFData (ModuloRing p)\n\nchar :: KnownNat p => ModuloRing p -> Natural\nchar = natVal\n\ninstance KnownNat p => Show (ModuloRing p) where\n show (ModuloRing a) = show a\n\ninstance KnownNat p => Num (ModuloRing p) where\n (+) x@(ModuloRing a) (ModuloRing b) =\n ModuloRing $\n if a + b >= mm\n then a + b - mm\n else a + b\n where\n mm = char x\n (*) x@(ModuloRing a) (ModuloRing b) = ModuloRing $ (a * b) `mod` mm\n where\n mm = char x\n fromInteger a = ret\n where\n mm = toInteger (char ret)\n ret = ModuloRing . fromInteger . (`mod` mm) . (+ mm) . (`mod` mm) $ a\n negate x@(ModuloRing a) =\n ModuloRing $\n if a == 0\n then 0\n else mm - a\n where\n mm = char x\n abs = id\n signum _ = 1\n\ndata Task =\n Task !Int !Int !Int !Int !Int !Int\n deriving (Show)\n\n-- [index, xMask, yMask, xCarry, yCarry, exceed]\n-- [7, 4, 4, 4, 4, 1]\nhash :: Task -> Int\nhash (Task index xMask yMask xCarry yCarry exceed) =\n index `shiftL` 17 .|. xMask `shiftL` 13 .|. yMask `shiftL` 9 .|.\n xCarry `shiftL` 5 .|.\n yCarry `shiftL` 1 .|.\n exceed\n\n{-# INLINE hash #-}\ntype Modulo = ModuloRing 998244353\n\ntype Env = (Int, Int, [Int])\n\ntype Hash = IntMap Modulo\n\nsearch :: Env -> Task -> State Hash Modulo\nsearch (x, y, n) task@(Task index xMask yMask xCarry yCarry exceed) =\n case n of\n []\n | exceed == 1 -> return 0\n | xCarry /= 0 || yCarry /= 0 -> return 0\n | xMask .&. yMask > 0 -> return 1\n | otherwise -> return 0\n d:n' -> do\n h <- get\n let hc = hash task\n case lookup hc h of\n Just m -> return m\n Nothing -> do\n v <-\n sum <$>\n sequence\n [ let index' = index + 1\n (xCarry', xd) = (x * dk + xCarry) `divMod` 10\n (yCarry', yd) = (y * dk + yCarry) `divMod` 10\n exceed' =\n case compare yd d of\n LT -> 0\n EQ -> exceed\n GT -> 1\n maxk = 9 `div` y\n add d p mask =\n let (k, r) = d `divMod` p\n in if r == 0 && 0 < k && k <= maxk\n then setBit mask (k - 1)\n else mask\n xMask' = add xd x xMask\n yMask' = add yd y yMask\n in search\n (x, y, n')\n (Task index' xMask' yMask' xCarry' yCarry' exceed')\n | dk <- [0 .. 9]\n ]\n modify (insert hc v)\n return v\n\nsolve :: String -> Modulo\nsolve n =\n (fromInteger (read n) +) . (2 *) . sum $\n [ evalState (search (x, y, n') (Task 0 0 0 0 0 1)) empty\n | y <- [2 .. 9]\n , x <- [1 .. y - 1]\n , gcd x y == 1\n ]\n where\n !n' = fmap (\\c -> ord c - 48) . reverse . show . (+ 1) . read $ n\n\nmain = getLine >>= print . solve\n", "positive_code": [{"source_code": "{-# LANGUAGE DataKinds #-}\n{-# LANGUAGE KindSignatures #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE DeriveGeneric #-}\n{-# OPTIONS -O2 #-}\n\nimport Control.Applicative (liftA2)\nimport Control.Monad (filterM, guard)\nimport Control.Monad.State.Strict (State, evalState, get, modify, put)\nimport Data.Bits ((.&.), (.|.), setBit, shiftL, shiftR, testBit)\nimport Data.Char (ord)\nimport Data.Int (Int8)\n\nimport Control.Monad.ST (ST, runST)\n\n-- import Data.HashTable.ST.Cuckoo (HashTable)\nimport Data.IntMap.Strict (IntMap, empty, insert, lookup)\n\nimport Control.DeepSeq (NFData, deepseq)\nimport GHC.Generics (Generic)\nimport GHC.TypeNats (KnownNat, Nat, natVal)\nimport Numeric.Natural (Natural)\nimport Prelude hiding (lookup)\n\nnewtype ModuloRing (p :: Nat) =\n ModuloRing Natural\n deriving (Eq, Generic)\n\ninstance NFData (ModuloRing p)\n\nchar :: KnownNat p => ModuloRing p -> Natural\nchar = natVal\n\ninstance KnownNat p => Show (ModuloRing p) where\n show (ModuloRing a) = show a\n\ninstance KnownNat p => Num (ModuloRing p) where\n (+) x@(ModuloRing a) (ModuloRing b) =\n ModuloRing $\n if a + b >= mm\n then a + b - mm\n else a + b\n where\n mm = char x\n (*) x@(ModuloRing a) (ModuloRing b) = ModuloRing $ (a * b) `mod` mm\n where\n mm = char x\n fromInteger a = ret\n where\n mm = toInteger (char ret)\n ret = ModuloRing . fromInteger . (`mod` mm) . (+ mm) . (`mod` mm) $ a\n negate x@(ModuloRing a) =\n ModuloRing $\n if a == 0\n then 0\n else mm - a\n where\n mm = char x\n abs = id\n signum _ = 1\n\ndata Task =\n Task !Int !Int !Int !Int !Int !Int\n deriving (Show)\n\n-- [index, xMask, yMask, xCarry, yCarry, exceed]\n-- [7, 4, 4, 4, 4, 1]\nhash :: Task -> Int\nhash (Task index xMask yMask xCarry yCarry exceed) =\n index `shiftL` 17 .|. xMask `shiftL` 13 .|. yMask `shiftL` 9 .|.\n xCarry `shiftL` 5 .|.\n yCarry `shiftL` 1 .|.\n exceed\n\n{-# INLINE hash #-}\ntype Modulo = ModuloRing 998244353\n\ntype Env = (Int, Int, [Int])\n\ntype Hash = IntMap Modulo\n\nsearch :: Env -> Task -> State Hash Modulo\nsearch (x, y, n) task@(Task index xMask yMask xCarry yCarry exceed) =\n case n of\n []\n | exceed == 1 -> return 0\n | xCarry /= 0 || yCarry /= 0 -> return 0\n | xMask .&. yMask > 0 -> return 1\n | otherwise -> return 0\n d:n' -> do\n h <- get\n let hc = hash task\n maxk = 9 `div` y\n case lookup hc h of\n Just m -> return m\n Nothing -> do\n v <-\n sum <$>\n sequence\n [ let index' = index + 1\n (xCarry', xd) = (x * dk + xCarry) `quotRem` 10\n (yCarry', yd) = (y * dk + yCarry) `quotRem` 10\n exceed' =\n case compare yd d of\n LT -> 0\n EQ -> exceed\n GT -> 1\n add d p mask =\n let (k, r) = d `quotRem` p\n in if r == 0 && 0 < k && k <= maxk\n then setBit mask (k - 1)\n else mask\n xMask' = add xd x xMask\n yMask' = add yd y yMask\n in search\n (x, y, n')\n (Task index' xMask' yMask' xCarry' yCarry' exceed')\n | dk <- [0 .. 9]\n ]\n modify (insert hc v)\n return v\n\nsolve :: String -> Modulo\nsolve n =\n (fromInteger (read n) +) . (2 *) . sum $\n [ evalState (search (x, y, n') (Task 0 0 0 0 0 1)) empty\n | y <- [2 .. 9]\n , x <- [1 .. y - 1]\n , gcd x y == 1\n ]\n where\n !n' = fmap (\\c -> ord c - 48) . reverse . show . (+ 1) . read $ n\n\nmain = getLine >>= print . solve\n"}], "negative_code": [], "src_uid": "b6f2061e2ca174c2385bf4520d232aaf"} {"source_code": "-- 2019-11-25 10:46:34.367674432 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))", "positive_code": [{"source_code": "-- from a mobile device\nimport Prelude (IO, interact, ($), (.), (*), (-), (++), (>), show, uncurry, map, read, take, words, Int, otherwise)\n \nmain :: IO ()\nmain = interact $ (++ \"\\n\") . show . uncurry gcd . tuple 2 . map read . take 2 . words\n where\n tuple 2 [a,b] = (a,b)\n \ngcd :: Int -> Int -> Int\ngcd a b | a > b = gcd b a | otherwise = fact a\n where\n fact 1 = 1\n fact n = n * fact (n-1)"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.Char\n\n\nmain=do\n\n [a,b]<- map read <$> words <$> getLine ::IO [Integer]\n print $ product [1..(min a b)]\n"}, {"source_code": "-- 2019-11-25 10:45:02.892536166 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:48:15.007409441 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:26:04.163844848 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:09:14.854199438 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:23:39.26826971 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:58:05.369023262 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:21:49.895679233 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:52:03.575036272 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:49:25.937477002 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:07:55.088370928 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:53:42.422713997 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:20:42.445797077 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:55:32.972108116 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para (min b a) 1 (\\c d -> d * (1 +) c)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "main = interact $ show . solve . map read . words\nsolve [a,b] = product [1..min a b]\n"}, {"source_code": "getint :: String -> [Int]\ngetint a = map read (words a)\n\nfact :: Int -> Int\nfact 1 = 1\nfact n = n * fact (n - 1)\nmain = do\n input <- getLine\n let [a, b] = getint input\n print(fact(min a b))"}, {"source_code": "import Control.Applicative( (<$>))\n\nmain = do\n [a_, b_] <- map (read::String->Integer) . words <$> getLine\n\t\n print $ if a_>= return . map read . words\n print . product $ [1..a `min` b]\n\n"}, {"source_code": "main = do\n [a, b] <- getLine >>= return . map read . words\n print . product . take (a `min` b) $ [1..]\n\n"}, {"source_code": "import Control.Monad\n\ngetNum :: Integer -> Integer -> Integer\ngetNum a p = getNum_ a p p\n\ngetNum_ :: Integer -> Integer -> Integer -> Integer\ngetNum_ a cur p\n | cur > a = 0\n | otherwise = (a `div` cur) + getNum_ a (cur * p) p\n\nmain = do\n [a, b] <- getLine >>= return . map read . words\n tmp <- forM [2,3,5,7,11] $ \\p -> do\n let x = getNum a p\n let y = getNum b p\n return (p, x `min` y)\n print . product $ map (uncurry (^)) tmp\n\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -optc-O3 -optc-ffast-math -funfolding-use-threshold=16 -fexcess-precision -funbox-strict-fields #-} \nmodule Main where\nimport qualified Data.ByteString.Char8 as B\n\nreadInt = maybe undefined fst . B.readInt\nreadInts = fmap readInt . B.words\n \nsolve a b = product [1..min a b]\n\nmain = do\n [a, b] <- fmap readInts B.getLine\n print $ solve a b\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\nprocess::Integer->Integer->Integer\nprocess a b = product [1..c] \n\twhere c= minimum [a, b]\n\t \n\n\nmain::IO ()\nmain=do\n [a,b]<- map read <$> words <$> getLine::IO [Integer] \n print $ process a b\n\n"}, {"source_code": "process :: Int -> Int -> Int\nprocess a b = product [1..(min a b)]\n\nreadInt :: String -> Int\nreadInt = read\n\nmain = do\n line <- getLine\n let [a,b] = map readInt (words line)\n print $ process a b"}, {"source_code": "factorial n = foldr (*) 1 [1..n]\nmain = interact $ show . factorial . minimum . map read . words\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = do\n str <- getLine\n print $ foldr (*) 1 [1..minimum $ map read $ words str]"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = do\n str <- getLine\n print $ fact 1 $ minimum $ map read $ words str\n where\n fact ans 1 = ans\n fact ans n = fact (ans*n) (n-1)"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = do\n str <- getLine\n print $ fact $ minimum $ map read $ words str\n where\n fact 1 = 1\n fact num = num * (fact $ num-1)"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = do\n str <- getLine\n print $ foldl' (*) 1 [1..minimum $ map read $ words str]"}, {"source_code": "module Main where\n\nimport Data.List\n\nget_ans :: Integer -> Integer -> Integer\nget_ans a b = fact (min a b)\n\twhere \n\t\tfact x = if x == 0 then 1 else x * fact (x - 1)\n\n\nmain :: IO ()\nmain = do\n\tl <- getLine \t\n\tlet [a, b] = map (read :: String -> Integer) (words l)\n\tprint (get_ans a b) \n"}, {"source_code": "\n\n\n\nfactorial uu pp\n | uu == 0 = 1\n | uu == 1 = pp\n | otherwise = factorial (pred uu) (pp * uu) \n\n\nmain = do\n ff <- getLine\n let a = (read (head (words ff)))::Int\n b = (read (last (words ff)))::Int\n \n ans = factorial (minimum [a,b]) 1\n\n putStrLn (show ans)\n"}, {"source_code": "import Control.Monad\nimport Data.Char\nimport Data.List\nimport qualified Data.ByteString as B\nimport qualified Data.ByteString.Char8 as C\n\nmygcd :: Int -> Int -> Int\nmygcd a b\n | a < b = fac a\n | otherwise = fac b\n\nfac :: Int -> Int\nfac 0 = 1\nfac n = n * fac (n - 1)\n\nmain :: IO ()\nmain = do\n Just(a, _):Just(b, _):_ <- fmap (map C.readInt) $ fmap (C.split ' ') C.getLine\n putStrLn . show $ mygcd a b\n"}, {"source_code": "main = do\n a:b:_ <- fmap ((map read) . words) getLine :: IO [Int]\n putStrLn . show . fac $ min a b\nfac :: Int -> Int\nfac n = foldr (*) 1 [1..n]"}, {"source_code": "main = interact $ unlines . map (show . factorial . minimum . map read . words) . lines\nfactorial::Integer->Integer\nfactorial n = foldl (*) 1 [1..n]\n"}, {"source_code": "-- Try Codeforces\n-- author: Leonardone @ NEETSDKASU\n\nmain = print . solve . map read . words =<< getLine\n\nsolve [a,b] = f x where\n x = min a b\n f 1 = 1\n f k = k * f (k - 1)\n"}, {"source_code": "solve (a:b:_)=show$mygcd ai bi where\n\tai=read a::Int\n\tbi=read b::Int\n\tmygcd x y = product [2..(min ai bi)]\nmain=interact$solve.words.head.lines"}, {"source_code": "import Data.List\n\nmain = do\n getLine >>= (\\x -> putStrLn.show.(\\x -> product [1..x]).minimum.(map (read :: String -> Integer)) $ words x)\n"}, {"source_code": "main = do\n [a,b] <- getLine >>= return . map (\\x -> read x :: Int) . words \n print $ product $ [2.. min a b]\n"}, {"source_code": "fac :: Int -> Int\nfac 0 = 1\nfac n = n * fac (n - 1)\n\nmain :: IO ()\nmain = do\n [a, b] <- fmap (map read . words) getLine\n putStrLn $ show $ fac $ min a b"}, {"source_code": "main = interact $ show . factorial . minimum . map read . words\nfactorial::Integer->Integer\nfactorial n = foldl (*) 1 [1..n]"}, {"source_code": "main = interact foo\n\nfoo :: String -> String\nfoo inp = \n let [a, b] = take 2 . map read . words . head . lines $ inp :: [Int]\n in show $ fact $ min a b\n\nfact :: Int -> Int\nfact 0 = 1\nfact 1 = 1\nfact n = n * fact (n-1)"}], "negative_code": [{"source_code": "factorial n = foldr (*) n [1..n]\nmain = interact $ show . factorial . minimum . map read . words\n"}, {"source_code": "primes (p:ps) = p : [q | q <- filter ((/=0).(`mod`p)) ps]\nmain = do\n [a,b] <- getLine >>= return . map (\\x -> read x :: Int) . words \n print $ product $ takeWhile (<= min a b) $ primes [2..]\n"}, {"source_code": "-- 2019-11-25 10:56:25.525339662 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a _ -> (1 +) ((1 +) a)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:44:19.640833202 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> (1 +) ((1 +) ((1 +) (min b a)))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:08:31.856169546 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a _ -> (1 +) ((1 +) a)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:07:23.420064243 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para b ((1 +) ((1 +) a)) (\\_ d -> d)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:52:59.212327532 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a _ -> (1 +) ((1 +) a)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:54:35.577685845 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para 1 b (\\_ _ -> (1 +) ((1 +) a))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:22:32.535737398 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para 1 b (\\_ _ -> (1 +) ((1 +) a))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:51:33.044098939 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para b ((1 +) ((1 +) a)) (\\_ d -> d)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:21:11.938920681 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a _ -> (1 +) ((1 +) a)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:10:30.55336758 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para 1 b (\\_ _ -> (1 +) ((1 +) a))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:47:26.506753033 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> (1 +) ((1 +) ((1 +) (min b a)))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:19:48.82684758 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para b ((1 +) ((1 +) a)) (\\_ d -> d)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:48:44.030105627 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a _ -> (1 +) ((1 +) a)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:24:17.523612564 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a _ -> (1 +) ((1 +) a)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 22:05:42.717675918 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a b -> nat_para b ((1 +) ((1 +) a)) (\\_ d -> d)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-25 10:45:42.248226788 UTC\nimport Data.Maybe\nimport Data.Char\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' f (a, b) = show $ f a b\nparser :: String -> (Int, Int)\nparser = fromJust . parseTwoInts\nparseTwoInts :: String -> Maybe (Int, Int)\nparseTwoInts i = do {when (length (lines i) /= 1) Nothing;\n ns <- mapM readMaybe $ words i :: Maybe ([Int]);\n when (length ns /= 2) Nothing;\n let {[a, b] = ns};\n return (a, b)}\nsolve = \\a _ -> (1 +) ((1 +) a)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}], "src_uid": "7bf30ceb24b66d91382e97767f9feeb6"} {"source_code": "#!/usr/bin/env runghc\nimport Data.List\n--import Data.List.Split\nmain = getContents >>= mapM_ putStrLn . solve . lines\nsolve [] = [] ::[String]\nsolve (nk:ai:cs) = (:solve cs)$ show . sum . map f . transpose . chunksOf k $ a\n where\n [n,k] = map read . words $ nk\n a = map read . words $ ai::[Int]\nf ns = length ns - (maximum . map length . group . sort) ns\nchunksOf k [] = []\nchunksOf k e = a:chunksOf k b\n where (a,b) = splitAt k e\n", "positive_code": [{"source_code": "solve :: [[Int]] -> Int\nsolve xs = if null xs\n then 0\n else\n let tmp = head xs\n len = length tmp\n one_count = length $ filter (\\x->x==1) tmp\n in (min one_count (len-one_count)) + (solve $ tail xs)\n\nsplitSeq :: [Int] -> Int -> Int -> [[Int]]\nsplitSeq xs cur k = if null xs\n then replicate k []\n else\n let tmp = splitSeq (tail xs) (mod (cur+1) k) k\n in (\\(l,x:r)->l++(((head xs):x):r)) $ splitAt cur tmp\n\ntoInt :: String -> Int\ntoInt x = read x :: Int\n\nmain = do s1 <- getLine\n s2 <- getLine\n let k = last $ map toInt (words s1)\n xs = map toInt (words s2)\n ys = splitSeq xs 0 k\n putStrLn $ show $ solve ys\n"}, {"source_code": "-- Codeforces 371A\n\n{-# OPTIONS_GHC -O2 #-}\n{-# OPTIONS_GHC -optc-O2 #-}\n{-# LANGUAGE BangPatterns #-}\n\nimport Control.Applicative\nimport Data.List\n\nmain :: IO ()\nmain = do\n (n:k:xs) <- (map read . words) <$> getContents\n print . sum . map minimize . groupd k (n `div` k) $ xs\n where\n minimize xs = let (a, b) = foldl' (\\(a, b) x -> if x == 1\n then (a + 1, b)\n else (a, b + 1)) (0, 0) xs\n in min a b\n groupd k h xs = [[ xs !! (i * k + j) | i <- [0 .. (h - 1)] ] | j <- [0 .. (k - 1)]]\n"}], "negative_code": [], "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281"} {"source_code": "main :: IO ()\nmain = print . solve . read =<< getContents\n\nsolve :: Integer -> Integer\nsolve n = n `div` 2520\n", "positive_code": [{"source_code": "main :: IO ()\nmain = print . (`div` 2520) =<< readLn\n"}, {"source_code": "main = getLine >>= print . solve . read\n\nsolve :: Integer -> Integer\nsolve n = n `div` (8 * 9 * 5 * 7)\n"}, {"source_code": "import Control.Monad\nmain = do\n a <- liftM read getLine\n putStrLn $ show $ (a `div` 2520)"}, {"source_code": "import Control.Applicative\nimport Data.Array\n\n\n \n\n \n\n\nmain= do\n\tn<- read <$>getLine::IO Integer \n\tlet c = foldl lcm 1 [2..10]\n\tprint $ div n c\n\t \n\t \n\n\t"}], "negative_code": [], "src_uid": "8551308e5ff435e0fc507b89a912408a"} {"source_code": "import Data.Functor\n\ngetInts :: IO [Int]\ngetInts = map read <$> words <$> getContents\n\nparsePairs [] = []\nparsePairs (x:y:rs) = (x, y) : parsePairs rs\n\nmain = do\n xs <- getInts\n print $ solve xs\n\nsolve (_:k:xs) = max 0 $ (2*k-1)*(length xs) - 2*(sum xs)\n", "positive_code": [{"source_code": "import Data.List\nimport Data.Array\nimport Data.Ord\nimport Data.Char\n\nfi=fromIntegral\nrd x = read x::Int\ngetNumbers=map rd.words\nextract (a:b:_)=(m,x) where\n\t(_:m:_)=getNumbers a\n\tx=getNumbers b\n\nsolve (m,x) = till0 (2*m*n-2*s-n) where\n\ts=sum x\n\tn=length x\n\ttill0 x\n\t\t|x>0 = x\n\t\t|otherwise = 0\n\n\n\t\t\t\nmain=interact$show.solve.extract.lines"}, {"source_code": "{-# LANGUAGE BangPatterns #-}\n\nimport Data.Maybe\nimport Data.Int\nimport Data.Bool\nimport Data.List\nimport Control.Monad\n\nmodulant :: Int64\nmodulant = 1000000007\n\ntwos :: [Int64]\ntwos = work 1\n where\n work c = c : work (let x = 2*c in if x > modulant then x - modulant else x)\n\nmain :: IO ()\nmain = do\n [n, k] <- liftM (\\l -> (read :: String -> Int) <$> words l) getLine\n grades <- liftM (\\l -> read <$> words l) getLine\n let s = sum grades\n a = n*(2*k - 1) - 2*s\n print $ max 0 a\n"}, {"source_code": "import Data.Functor ((<$>))\n\nmain :: IO ()\nmain = do\n n:k:_ <- readLine\n scores <- readLine\n putStrLn $ show $ solution n k (take (fromInteger n) scores)\n where readLine = map (read :: String -> Integer) . words <$> getLine\n\nsolution :: Integer -> Integer -> [Integer] -> Integer\nsolution n k scores = max ans 0\n where ans = (2 * k - 1) * n - 2 * s\n s = sum scores\n"}, {"source_code": "main = do\n (n:k:[]) <- (fmap (map read . words) $ getLine) :: IO [Int]\n xs <- (fmap (map read . words) $ getLine) :: IO [Int]\n print $ max 0 $ (\\x -> x*2-n) $ sum $ map (k-) xs"}, {"source_code": "--ghc 7.6\n\nmean ::[Int] -> Double\nmean xs = (fromIntegral.sum) xs / (fromIntegral.length) xs\n\nminmarks :: [Int] -> Int -> Int\nminmarks marks k \n\t|mean marks >= (fromIntegral k) - 0.5 = 0\n\t|otherwise = 1 + (minmarks (k:marks) k)\n\t\n\nmain = do\n\t\n\t[n, k] <- (map read.words) `fmap` getLine\n\tmarks <- (map read.words) `fmap` getLine\n\tprint $ minmarks marks k"}, {"source_code": "module Main where\nimport qualified Data.ByteString.Char8 as B\nimport Control.Monad \nimport Control.Applicative\n\nreadInt = maybe undefined fst . B.readInt\nreadInts = (readInt <$>) . B.words\n\nchiến n k as = max 0 $ 2 * (k * n - sum as) - n\n\nmain = do \n n:k:_ <- readInts <$> B.getLine\n as <- readInts <$> B.getLine\n print $ chiến n k as\n\n-- (s + kx)/(n + x)>=k-0.5\n-- s+kx>=kn+kx-0.5(n+x)\n-- s >= kn-0.5(n+x)\n-- 0.5(n+x)>=kn-s\n-- x>=2(kn-s)-n"}], "negative_code": [{"source_code": "module Main where\nimport qualified Data.ByteString.Char8 as B\nimport Control.Monad \nimport Control.Applicative\n\nreadInt = maybe undefined fst . B.readInt\nreadInts = (readInt <$>) . B.words\n\nchiến n k as = 2 * (k * n - sum as) - n\n\nmain = do \n n:k:_ <- readInts <$> B.getLine\n as <- readInts <$> B.getLine\n print $ chiến n k as\n\n-- (s + kx)/(n + x)>=k-0.5\n-- s+kx>=kn+kx-0.5(n+x)\n-- s >= kn-0.5(n+x)\n-- 0.5(n+x)>=kn-s\n-- x>=2(kn-s)-n"}, {"source_code": "import Data.List\nimport Data.Array\nimport Data.Ord\nimport Data.Char\n\nfi=fromIntegral\nrd x = read x::Int\ngetNumbers=map rd.words\nextract (a:b:_)=(m,x) where\n\t(_:m:_)=getNumbers a\n\tx=getNumbers b\n\nsolve (m,x)=2*m*n-2*s-n where\n\ts=sum x\n\tn=length x\n\n\n\t\t\t\nmain=interact$show.solve.extract.lines"}, {"source_code": "{-# LANGUAGE BangPatterns #-}\n\nimport Data.Maybe\nimport Data.Int\nimport Data.Bool\nimport Data.List\nimport Control.Monad\n\nmodulant :: Int64\nmodulant = 1000000007\n\ntwos :: [Int64]\ntwos = work 1\n where\n work c = c : work (let x = 2*c in if x > modulant then x - modulant else x)\n\nmain :: IO ()\nmain = do\n [n, k] <- liftM (\\l -> (read :: String -> Int) <$> words l) getLine\n grades <- liftM (\\l -> read <$> words l) getLine\n let s = sum grades\n if 2*s >= 2*n*k - 1 then\n print 0\n else do\n let a = n*(2*k - 1) - 2*s\n print a\n"}, {"source_code": "import Data.Functor ((<$>))\n\nmain :: IO ()\nmain = do\n n:k:_ <- readLine\n scores <- readLine\n putStrLn $ show $ solution n k (take (fromInteger n) scores)\n where readLine = map (read :: String -> Integer) . words <$> getLine\n\nsolution :: Integer -> Integer -> [Integer] -> Integer\nsolution n k scores = (2 * k - 1) * n - 2 * (sum scores)\n"}, {"source_code": "main = do\n (n:k:[]) <- (fmap (map read . words) $ getLine) :: IO [Int]\n xs <- (fmap (map read . words) $ getLine) :: IO [Int]\n print $ (\\x -> x*2-n) $ sum $ map (k-) xs"}, {"source_code": "main = do\n [n, k] <- (map read.words) `fmap` getLine\n xs <- (map read.words) `fmap` getLine\n putStr $ show $ n*(2*k-1) - 2*(sum $! xs)"}], "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900"} {"source_code": "import Data.List\nf n = case n of\n 1 -> [-1]\n 2 -> [-1]\n a -> [a,a-1..1]\nmain = (readLn :: IO Int) >>= putStrLn . concat . intersperse \" \" . map show . f \n", "positive_code": [{"source_code": "import Data.List\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Data.Char\n\nmain :: IO ()\nmain = getLine >>= mapM_ (\\x -> putStr $ show x ++ \" \") .(\\x -> if (x <= 2) then [-1] else [x, (x-1) ..1]). read. head.words\n\n"}, {"source_code": "main :: IO()\nmain = prettify . solve . (\\x -> read x :: Int) =<< getLine\n\nsolve :: Int -> Maybe [Int]\nsolve n \n | n <= 2 = Nothing\n | otherwise = Just (reverse [1..n])\n\nprettify :: Maybe [Int] -> IO()\nprettify Nothing = putStrLn \"-1\"\nprettify (Just list) = putStrLn $ unwords . map show $ list\n"}, {"source_code": "main = interact $ unwords . (map show) . solve . read . head . lines\nsolve 1 = [-1]\nsolve 2 = [-1]\nsolve n = [n] ++ replicate (n-2) 2 ++ [1]"}, {"source_code": "import Data.List\n\nsolve :: Int -> String\nsolve n\n | n <= 2 = \"-1\"\n | otherwise = \"100 100 \" ++ intercalate \" \" [show x | x <- (take (n - 2) [1..])]\n\nmain :: IO ()\nmain = do\n n <- readLn :: IO Int\n putStrLn $ solve n\n"}, {"source_code": "s n\n | n <= 2 = [-1]\n | True = [n, n - 1 .. 1]\n\nmain = interact $ unwords . map show . s . read"}, {"source_code": "main=interact$unwords.map show.f.read\nf n|n<3=[-1]|1>0=[n,n-1..1]\n"}, {"source_code": "main :: IO ()\nmain = readLn >>= putStrLn . unwords . map show . solve\n\nsolve :: Integer -> [Integer]\nsolve n | n < 3 = [ -1 ]\n | otherwise = [n, n - 1 .. 1]\n"}, {"source_code": "main=readLn>>=putStrLn.unwords.map show.f\nf n|n<3=[-1]|0<1=[3,2]++([1..n-2]>>[1])\n"}, {"source_code": "main = do\n n <- fmap read getLine\n if n <= 2\n then print $ -1\n else putStrLn $ unwords $ map show $ [2 .. n] ++ [1]\n"}, {"source_code": "getList :: Int -> [Int]\ngetList n\n\t| n == 1\t= []\n\t| n == 2\t= []\n\t| n == 3\t= 3:2:1:[]\n\t| otherwise\t= n : getList (n - 1)\n\nprintList :: [Int] -> IO()\nprintList [] = do\n\tputStrLn \"\"\nprintList (a:b) = do\n\tputStr ((show a) ++ \" \")\n\tprintList b\n\nmain :: IO()\nmain = do\n\tstr <- getLine\n\tlet ans = getList (read (str))\n\tif (null ans)\n\t\tthen putStrLn \"-1\"\n\t\telse printList ans\n"}, {"source_code": "main = getLine >>= (\\x -> putStrLn $ unwords $ map show $ f (read x::Int))\n\nf :: Int -> [Int]\nf a\n | a==1 || a==2 = [-1]\n | otherwise = reverse [1..a]"}, {"source_code": "\nimport Data.List (intercalate)\n\nmain :: IO ()\nmain = do\n n <- readLn\n if n < 3\n then print (-1)\n else putStrLn $ intercalate \" \" $ map show $ (2:3:(replicate (n-2) 1))\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \n\n \n\n\nmain= do\n\tn<- read <$> getLine ::IO Int\n\tputStrLn $ if n<3 then \"-1\" else intercalate \" \" $ map show [n,n-1..1] "}], "negative_code": [{"source_code": "main=readLn>>=putStrLn.f\nf n|n<3=\"-1\"|0<1=\"32\"++([1..n-2]>>\"1\")\n"}, {"source_code": "\nimport Data.List (intercalate)\n\nmain :: IO ()\nmain = do\n n <- readLn\n if n < 3\n then print (-1)\n else putStrLn $ intercalate \" \" $ map show $ (1:2:(replicate (n-2) 1))\n"}, {"source_code": "main=readLn>>=putStrLn.f\nf n|n<3=\"-1\"|0<1=([1..n-1]>>\"1\")++\"2\""}, {"source_code": "main=readLn>>=putStrLn.f\nf n|n<3=\"-1\"|0<1=([1..n-1]>>\"2\")++\"1\""}], "src_uid": "fe8a0332119bd182a0a5b7758716317e"} {"source_code": "import Control.Applicative\nimport Data.List\n \n\ncheck a x | s>=3 || s<=1 = True\n |otherwise = False\n\t\twhere s = a!!x +a!!(x+1)+a!!(x+4)+a!!(x+5)\n\ntr '.' = 1\ntr '#' = 0\n\n\nmain= do\n\ta<- concat .lines <$> getContents\n\tlet aa = map tr a\n\tputStrLn $ if or ( map (check aa) [0,1,2,4,5,6,8,9,10]) then \"YES\" else \"NO\"\n\t ", "positive_code": [{"source_code": "main=interact$f.lines\nf s|or[length[()|k<-[0,1],l<-[0,1],s!!(i+k)!!(j+l)=='#']/=2|i<-[0..2],j<-[0..2]]=\"YES\"|1>0=\"NO\"\n\n"}, {"source_code": "main=interact$f.lines\nf s|or[length[()|k<-[0,1],l<-[0,1],s!!(i+k)!!(j+l)=='#']/=2|i<-[0..2],j<-[0..2]]=\"YES\"|1>0=\"NO\"\n\n"}, {"source_code": "main=interact$f.lines\nf s|or[length[()|k<-[0,1],l<-[0,1],s!!(i+k)!!(j+l)=='#']/=2|i<-[0..2],j<-[0..2]]=\"YES\"|1>0=\"NO\"\n"}, {"source_code": "main=interact$f.lines\nf s|or[length[()|k<-[0,1],l<-[0,1],s!!(i+k)!!(j+l)=='#']/=2|i<-[0..2],j<-[0..2]]=\"YES\"|1>0=\"NO\"\n\n"}, {"source_code": "import Control.Monad (liftM)\nimport Data.Char (ord)\nimport Data.List (intercalate, sort)\n\nsolve :: [String] -> Bool\nsolve ss = or $ do\n i <- [0..2]\n j <- [0..2]\n let s = [ss !! i !! j, ss !! i !! (j+1), ss !! (i+1) !! j, ss !! (i+1) !! (j+1)]\n return (sort s /= \"##..\")\n\nmain :: IO ()\nmain = do\n ss <- sequence [getLine, getLine, getLine, getLine]\n if solve ss\n then putStrLn \"YES\"\n else putStrLn \"NO\"\n\n where\n\n reads :: Num a => IO [a]\n reads = liftM (map read . words) getLine\n where\n read ('-':s) = (-1) * read s\n read s = read' 0 s\n read' a \"\" = a\n read' a (c:s) = read' (10 * a + fromIntegral (ord c - ord '0')) s\n\n prints :: Show a => [a] -> IO ()\n prints = putStrLn . intercalate \" \" . map show"}, {"source_code": "main=interact$f.lines\nf s|or[length[()|k<-[0,1],l<-[0,1],s!!(i+k)!!(j+l)=='#']/=2|i<-[0..2],j<-[0..2]]=\"YES\"|1>0=\"NO\"\n\n"}, {"source_code": "data Color = Black | White deriving (Eq,Show)\ntype Board = [[Color]]\n\ncheck :: Board -> Bool\ncheck board = any (==True) $ map (square board) [(i,j) | i <- [0..2] , j <- [0..2]]\n\nsquare :: Board -> (Int,Int) -> Bool\nsquare board pos = allEqual elems where\n (i,j) = pos\n elems = map (flip access board) [(i,j),(i+1,j),(i,j+1),(i+1,j+1)]\n\nallEqual :: Eq a => [a] -> Bool\nallEqual (x:xs) = all (==x) xs\n\naccess :: (Int,Int) -> Board -> Color\naccess (i,j) board = (board !! i ) !! j\n\nconvert :: Board -> [Board]\nconvert board =board:boards where\n boards = map (convert' board) [(i,j) | i <- [0..3] , j <- [0..3]]\n convert' bd (i,j) = take i bd ++[convert'' j (bd !! i)] ++ drop (i+1) bd\n convert'' j line = take j line ++ [rev (line !! j)] ++ drop (j+1) line\n\nrev :: Color -> Color\nrev Black = White\nrev White = Black\n\niq :: Board -> Bool\niq = any (== True).map check.convert\n\nanswer :: Bool -> String\nanswer True = \"YES\"\nanswer False = \"NO\"\n\ntoBoard :: [String] -> Board\ntoBoard = map toColor\n\ntoColor :: String -> [Color]\ntoColor [] = []\ntoColor ('#':xs) = Black:toColor xs\ntoColor ('.':xs) = White:toColor xs\n\nmain = do\n l1 <- getLine\n l2 <- getLine\n l3 <- getLine\n l4 <- getLine\n putStrLn.answer.iq $ toBoard [l1, l2, l3, l4]"}, {"source_code": "main=interact$f.lines\nf s|or[length[()|k<-[0,1],l<-[0,1],s!!(i+k)!!(j+l)=='#']/=2|i<-[0..2],j<-[0..2]]=\"YES\"|1>0=\"NO\"\n"}, {"source_code": "main :: IO ()\nmain = getContents >>= putStrLn . yesno . solve . lines\n\nsolve :: [String] -> Bool\nsolve cs = or [ length [ () | i' <- [i..i+1], j' <- [j..j+1], cs !! i' !! j' == '#' ] /= 2 | i <- [0..2], j <- [0..2] ]\n\nyesno :: Bool -> String\nyesno True = \"YES\"\nyesno _ = \"NO\"\n"}, {"source_code": "take2x2 :: [String] -> Int -> Int -> String\ntake2x2 strs i j = strs!!i!!j : strs!!(i+1)!!j : strs!!i!!(j+1) : [strs!!(i+1)!!(j+1)]\n\ncountChar :: String -> Char -> Int\ncountChar \"\" c = 0\ncountChar (x:xs) c = if x==c then 1 + (countChar xs c) else countChar xs c\n\nhantei :: String -> Bool\nhantei str = if (countChar str '.')>=3 || (countChar str '#')>=3\n then True\n else False\nboolTostr True = \"YES\"\nboolTostr False = \"NO\"\n\nmain = do input <- getContents\n putStrLn (boolTostr (or (map hantei [take2x2 (lines input) i j|i<-[0,1,2], j<-[0,1,2]])))\n"}, {"source_code": "main=interact$f.lines\nf s|or[length[()|k<-[0,1],l<-[0,1],s!!(i+k)!!(j+l)=='#']/=2|i<-[0..2],j<-[0..2]]=\"YES\"|1>0=\"NO\"\n\n"}, {"source_code": "main=interact$f.lines\nf s|or[length[()|k<-[0,1],l<-[0,1],s!!(i+k)!!(j+l)=='#']/=2|i<-[0..2],j<-[0..2]]=\"YES\"|1>0=\"NO\"\n\n"}, {"source_code": "import Data.List\n\nmain = interact $ yesno . solve . lines\n\nyesno False = \"YES\"\nyesno True = \"NO\"\nsolve xs = all (2==) . map elems $ prepare xs\n where \n prepare l@(_:xs) = concat $ zipWith dup l xs \n dup l r = zipWith (\\(a1,a2) (b1,b2) -> [a1,a2,b1,b2]) (pairwise l) (pairwise r)\n pairwise l@(_:xs) = zip l xs\n elems xs = max (count '#' xs) (count '.' xs)\n count x xs = length $ elemIndices x xs "}, {"source_code": "main=interact$f.lines\nf s|or[length[()|k<-[0,1],l<-[0,1],s!!(i+k)!!(j+l)=='#']/=2|i<-[0..2],j<-[0..2]]=\"YES\"|1>0=\"NO\"\n\n"}, {"source_code": "main=interact$f.lines\nf s|or[length[()|k<-[0,1],l<-[0,1],s!!(i+k)!!(j+l)=='#']/=2|i<-[0..2],j<-[0..2]]=\"YES\"|1>0=\"NO\"\n\n"}], "negative_code": [{"source_code": "import Control.Monad (liftM)\nimport Data.Char (ord)\nimport Data.List (intercalate, sort)\n\nsolve :: [String] -> Bool\nsolve ss = or $ do\n i <- [0..2]\n j <- [0..2]\n let s = [ss !! i !! j, ss !! i !! (j+1), ss !! (i+1) !! j, ss !! (i+1) !! (j+1)]\n return (sort s /= \"##..\")\n\nmain :: IO ()\nmain = do\n ss <- sequence [getLine, getLine, getLine, getLine]\n if solve ss\n then putStrLn \"yes\"\n else putStrLn \"no\"\n\n where\n\n reads :: Num a => IO [a]\n reads = liftM (map read . words) getLine\n where\n read ('-':s) = (-1) * read s\n read s = read' 0 s\n read' a \"\" = a\n read' a (c:s) = read' (10 * a + fromIntegral (ord c - ord '0')) s\n\n prints :: Show a => [a] -> IO ()\n prints = putStrLn . intercalate \" \" . map show"}, {"source_code": "main :: IO ()\nmain = getContents >>= putStrLn . yesno . solve . lines\n\nsolve :: [String] -> Bool\nsolve cs = or [ length [ () | i' <- [i..i+1], j' <- [j..j+1], cs !! i' !! j' == '#' ] == 3 | i <- [0..2], j <- [0..2] ]\n\nyesno :: Bool -> String\nyesno True = \"YES\"\nyesno _ = \"NO\"\n"}, {"source_code": "main :: IO ()\nmain = getContents >>= putStrLn . yesno . solve . lines\n\nsolve :: [String] -> Bool\nsolve cs = or [ length [ () | i' <- [i..i+1], j' <- [j..j+1], cs !! i' !! j' == '#' ] >= 3 | i <- [0..2], j <- [0..2] ]\n || or [ length [ () | i' <- [i..i+1], j' <- [j..j+1], cs !! i' !! j' == '.' ] == 4 | i <- [0..2], j <- [0..2] ]\n\nyesno :: Bool -> String\nyesno True = \"YES\"\nyesno _ = \"NO\"\n"}, {"source_code": "main :: IO ()\nmain = getContents >>= putStrLn . yesno . solve . lines\n\nsolve :: [String] -> Bool\nsolve cs = or [ length [ () | i' <- [i..i+1], j' <- [j..j+1], cs !! i' !! j' == '#' ] == 3 | i <- [0..2], j <- [0..2] ]\n || or [ length [ () | i' <- [i..i+1], j' <- [j..j+1], cs !! i' !! j' == '.' ] == 4 | i <- [0..2], j <- [0..2] ]\n\nyesno :: Bool -> String\nyesno True = \"YES\"\nyesno _ = \"NO\"\n"}, {"source_code": "take2x2 :: [String] -> Int -> Int -> String\ntake2x2 strs i j = strs!!i!!j : strs!!(i+1)!!j : strs!!i!!(j+1) : [strs!!(i+1)!!(j+1)]\n\ncountChar :: String -> Char -> Int\ncountChar \"\" c = 0\ncountChar (x:xs) c = if x==c then 1 + (countChar xs c) else countChar xs c\n\nhantei :: String -> Bool\nhantei str = if (countChar str '.')>=3 || (countChar str '#')>=3\n then True\n else False\nboolTostr True = \"YES\"\nboolTostr False = \"NO\"\n\nmain = do input <- getContents\n print (boolTostr (or (map hantei [take2x2 (lines input) i j|i<-[0,1,2], j<-[0,1,2]])))\n"}], "src_uid": "01b145e798bbdf0ca2ecc383676d79f3"} {"source_code": "module Main where\n-- import Control.Monad\nimport Data.List\nimport Data.Array\nmain :: IO ()\nmain = do\n _ <- getLine\n line <- getLine\n let ints = map read $ words line :: [Integer]\n (ma,mi) = (maximum ints, minimum ints)\n (otherints,_,_) = foldl (\\(filtered,foundMax,foundMin) e ->\n case (e == ma, e==mi, foundMax, foundMin) of\n (True, _, False,_) -> (filtered, True, foundMin)\n (_, True, _, False) -> (filtered, foundMax, True)\n _ -> (e:filtered, foundMax, foundMin))\n ([],False,False)\n ints\n putStrLn $ unwords $ map show (ma:sort otherints ++ [mi])\n", "positive_code": [{"source_code": "import Data.List\nimport Data.Char\nimport Data.Maybe\nimport Control.Applicative\nimport Debug.Trace\nimport qualified Data.ByteString.Char8 as B\n\ndebug x = trace (show x) x\n(|>) x f = f x; infixl 1 |>\n(||>) mx f = mx >>= (return . f); infixl 1 ||>\nref = (!!)\n\ntoDigit n = chr (48 + n)\nreadInt = fst . fromJust . B.readInt\n\nsolve xs =\n a : (sort ls ++ [b])\n where\n a = maximum xs\n b = minimum xs\n ls = delete a $ delete b xs\n\nmain = do\n ls <- B.getContents ||> B.lines\n xs <- (ref ls 1) |> B.words |> map readInt |> return\n putStrLn $ join $ solve xs\n where\n join [x] = show x\n join (x:xs) = show x ++ \" \" ++ join xs\n"}, {"source_code": "import Control.Monad (liftM, unless, when)\nimport Data.List (group, intercalate, sort)\nimport Prelude hiding (reads)\n\nreads :: Read a => IO [a]\nreads = liftM (map read . words) getLine\n\nsolve :: [Int] -> [Int]\nsolve xs = concat\n [[last xs'], init (tail xs'), [head xs']]\n where\n xs' = sort xs\n\nprints :: Show a => [a] -> IO ()\nprints = putStrLn . intercalate \" \" . map show\n\nmain :: IO ()\nmain = getLine >> reads >>= prints . solve\n"}, {"source_code": "import Data.List\nimport Control.Applicative \n\nmain :: IO ()\nmain = getLine >> sort <$> map read <$> words <$> getLine >>= putStrLn . solve\n\nsolve :: [Int] -> String\nsolve xs = show (last xs) ++ \" \" ++ intercalate \" \" (show <$> (init $ tail xs)) ++ \" \" ++ show (head xs)\n"}, {"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Monad.State\n-- import Data.Array\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\n-- import Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IntSet\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\n-- import Debug.Trace\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n getLine\n xs <- getInts\n\n let\n a = maximum xs\n b = minimum xs\n\n\n putStr $ unwords $ map show $ [a] ++ sort (xs \\\\ [a, b]) ++ [b]\n"}, {"source_code": "import Control.Monad (liftM, unless, when)\nimport Data.List (group, intercalate, sort)\nimport Prelude hiding (reads)\n\nreads :: Read a => IO [a]\nreads = liftM (map read . words) getLine\n\nsolve :: [Int] -> [Int]\nsolve xs = concat [[last xs'], init (tail xs'), [head xs']]\n where\n xs' = sort xs\n\nprints :: Show a => [a] -> IO ()\nprints = putStrLn . intercalate \" \" . map show\n\nmain :: IO ()\nmain = getLine >> reads >>= prints . solve\n"}, {"source_code": "\nimport Control.Monad (liftM, unless, when)\nimport Data.List (group, intercalate, sort)\nimport Prelude hiding (reads)\n\nreads :: Read a => IO [a]\nreads = liftM (map read . words) getLine\n\nsolve :: [Int] -> [Int]\nsolve xs = concat\n [[last xs'], init (tail xs'), [head xs']]\n where\n xs' = sort xs\n\nprints :: Show a => [a] -> IO ()\nprints = putStrLn . intercalate \" \" . map show\n\nmain :: IO ()\nmain = getLine >> reads >>= prints . solve"}, {"source_code": "import Data.List\nimport Text.Printf\n\nmiddle :: [a] -> [a]\nmiddle = init . tail\n\nswapFirstLast :: [Integer] -> [Integer]\nswapFirstLast xs = [last xs] ++ (middle xs) ++ [head xs]\n\nmain = do \n [n] <- (map (read :: String -> Integer) . words) `fmap` getLine\n seq <- (map (read :: String -> Integer) . words) `fmap` getLine\n let res = concat $ map ((++ \" \") . show) $ swapFirstLast $ sort seq\n putStrLn res\n"}, {"source_code": "import Data.List (sort)\n\nmain :: IO ()\nmain = putStrLn . unwords . map show . solve . tail . map read . words =<< getContents\n\nsolve :: [Int] -> [Int]\nsolve xs = [ maximum xs ] ++ init (tail (sort xs)) ++ [ minimum xs ]\n"}, {"source_code": "module Main where\n\nimport Control.Applicative\nimport Data.Array\nimport Data.List\n\nmain = do\n getLine\n ns <- map read <$> words <$> getLine\n mapM_ (\\x -> putStr (show x ++ \" \")) $ solve ns\n putStrLn \"\"\n\nremFirst :: Int -> [Int] -> [Int]\nremFirst _ [] = []\nremFirst p (x:xs) | p==x = xs\n | otherwise = x : remFirst p xs\n\n\nsolve :: [Int] -> [Int]\nsolve xs = \n let min = minimum xs\n max = maximum xs\n in max : (sort $ remFirst min $ remFirst max xs) ++ [min]"}, {"source_code": "main = do\n input <- getLine\n let n = read (input) :: Int\n input <- getLine\n let input' = f $ split ' ' input\n let sorted = qsort input'\n let rev = reverse sorted\n putStrLn (show (head rev) ++ foldl (\\x y -> x ++ \" \" ++ show y) \"\" (init (tail sorted)) ++ \" \" ++ show (last rev)) \n\nf :: [String] -> [Int]\nf x = map read x\n\nqsort :: (Ord a) => [a] -> [a]\nqsort [] = []\nqsort (x:xs) = qsort [a | a <- xs, a <= x] ++ [x] ++ qsort [a | a <- xs, a > x]\n\nsplit' :: (Eq a) => a -> [a] -> [a] -> [[a]]\nsplit' _ [] l = [l]\nsplit' v (x:xs) l\n | x /= v = split' v xs (l ++ [x])\n | otherwise = [l] ++ split' v xs []\n\nsplit :: (Eq a) => a -> [a] -> [[a]]\nsplit v xs = split' v xs []\n"}, {"source_code": "import Data.List\nimport Data.Char\n\nans xs = (last ys):(tail.init $ ys)++[head ys]\n where ys= sort xs\n\nmain = do\n getLine\n n<-getLine\n let input = map (\\x->read x::Int) $ words n\n putStrLn $ unwords $ map show $ ans input"}, {"source_code": "import Data.List\n\ncal ls = let sorted = map (+0) $ sort $ map read $ words $ ls !! 1\n\t in foldl1 (\\x y -> x++\" \"++y) $ map show $ swap $ reverse sorted\n\n\nswap ls = let rev = reverse ls\n\t revNoHead = reverse $ tail ls\n\t in [head ls] ++ tail revNoHead ++ [head rev]\n\nmain = interact ( cal . lines)\n"}], "negative_code": [{"source_code": "module Main where\n\nimport Control.Applicative\nimport Data.Array\nimport Data.List\n\nmain = do\n getLine\n ns <- map read <$> words <$> getLine\n mapM_ (\\x -> putStr (show x ++ \" \")) $ solve ns\n putStrLn \"\"\n\nremFirst :: Int -> [Int] -> [Int]\nremFirst _ [] = []\nremFirst p (x:xs) | p==x = xs\n | otherwise = x : remFirst p xs\n\nremLast :: Int -> [Int] -> [Int]\nremLast x xs = reverse $ remFirst x (reverse xs)\n\nsolve :: [Int] -> [Int]\nsolve xs = \n let min = minimum xs\n max = maximum xs\n in max : (remLast min $ remFirst max xs) ++ [min]"}, {"source_code": "main = do\n input <- getLine\n let n = read (input) :: Int\n input <- getLine\n let input' = f $ split ' ' input\n let sorted = reverse $ qsort input'\n putStrLn (show (head sorted) ++ foldl (\\x y -> x ++ \" \" ++ show y) \"\" (tail sorted))\n\nf :: [String] -> [Int]\nf x = map read x\n\nqsort :: (Ord a) => [a] -> [a]\nqsort [] = []\nqsort (x:xs) = qsort [a | a <- xs, a <= x] ++ [x] ++ qsort [a | a <- xs, a > x]\n\nsplit' :: (Eq a) => a -> [a] -> [a] -> [[a]]\nsplit' _ [] l = [l]\nsplit' v (x:xs) l\n | x /= v = split' v xs (l ++ [x])\n | otherwise = [l] ++ split' v xs []\n\nsplit :: (Eq a) => a -> [a] -> [[a]]\nsplit v xs = split' v xs []"}, {"source_code": "import Data.List\n\ncal ls = let sorted = map (+0) $ sort $ map read $ words $ ls !! 1\n\t in foldl1 (\\x y -> x++\" \"++y) $ map show $ swap sorted\n\n\nswap ls = takeEven ls (reverse ls) 0\n\ntakeEven ls rev c \n\t| ls == [] || rev==[] = []\n\t| odd c = (head ls) : takeEven (tail ls) (tail rev) (c+1)\n\t| otherwise = (head rev) : takeEven (tail ls) (tail rev) (c+1)\n\n\n\nmain = interact ( cal . lines)\n"}, {"source_code": "import Data.List\n\ncal ls = let sorted = map (+0) $ sort $ map read $ words $ ls !! 1\n\t in foldl1 (\\x y -> x++\" \"++y) $ map show $ swap sorted\n\n\nswap ls = takeEven ls (reverse ls) 0\n\ntakeEven ls rev c \n\t| ls == [] || rev==[] = []\n\t| odd c = (head rev) : takeEven (tail ls) (tail rev) (c+1)\n\t| otherwise = (head ls) : takeEven (tail ls) (tail rev) (c+1)\n\n\n\nmain = interact ( cal . lines)\n"}, {"source_code": "import Data.List\n\ncal ls = let sorted = map (+0) $ sort $ map read $ words $ ls !! 1\n\t in foldl1 (\\x y -> x++\" \"++y) $ map show $ swap sorted\n\n\nswap ls = let rev = reverse ls\n\t revNoHead = reverse $ tail ls\n\t in [head ls] ++ tail revNoHead ++ [head rev]\n\nmain = interact ( cal . lines)\n"}], "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4"} {"source_code": "solve n = sum xs where\n xs = [i * (i - 1) | i <- [3..n]]\n\nmain = do\n n <- readLn :: IO Int\n print $ solve n\n", "positive_code": [{"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE BangPatterns #-}\n{-# LANGUAGE Safe #-}\n{-# LANGUAGE TupleSections #-}\n{-# LANGUAGE ExplicitForAll #-}\n{-# LANGUAGE MultiWayIf #-}\n{-# LANGUAGE CPP #-}\n{-# LANGUAGE FlexibleContexts #-}\n{-# LANGUAGE NoMonomorphismRestriction #-}\n\nimport Data.Bits\nimport Data.List\nimport qualified Data.ByteString.Char8 as BS\nimport qualified Data.ByteString.Lazy.Char8 as BSL\nimport Data.IntMap.Strict (IntMap)\nimport qualified Data.IntMap.Strict as IM\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IS\nimport qualified Data.Array.IArray as A\nimport qualified Data.Array.MArray.Safe as A\n-- import qualified Data.Array.MArray as A\nimport Data.Array (Array)\nimport Data.Array.Unboxed (UArray)\nimport Data.Array.IArray (IArray)\nimport Data.Array.MArray.Safe (MArray)\nimport Data.Array.IO.Safe (IOArray, IOUArray)\nimport Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)\n{-\nimport qualified Data.Vector.Unboxed as VU\nimport qualified Data.Vector.Unboxed.Mutable as VUM\n-}\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Monad.ST.Lazy.Safe (strictToLazyST, lazyToStrictST)\nimport qualified Control.Monad.ST.Lazy.Safe as STL\n-- import Control.Monad.ST\nimport Control.Applicative\nimport Data.Maybe\nimport Data.Tuple\nimport Data.Ord\nimport Control.Monad.State.Strict\nimport Data.Int\nimport Data.Word\nimport Data.STRef\nimport Data.IORef\nimport Data.Function\nimport System.IO\nimport System.Exit\nimport Data.Char\n\nmain :: IO ()\nmain = do\n n <- readInt <$> getLine\n print $ sum $ zipWith (*) [2..(n-1)] [3..n]\n\nrInt :: StateT BSL.ByteString Maybe Int\nrInt = StateT $ BSL.readInt . BSL.dropWhile (<'!')\nrIntS :: StateT BS.ByteString Maybe Int\nrIntS = StateT $ BS.readInt . BS.dropWhile (<'!')\n\n#define D(f,r,d) f::Integral a=>a->d;f=fromIntegral;r::String->d;r=read\n#define C(f,r,g,h,d) D(f,r,d);g,h::RealFrac a=>a->d;g=floor;h=ceiling\nC(_toInteger_,readInteger,floorInteger,ceilInteger,Integer)\nC(toInt,readInt,floorInt,ceilInt,Int)\nC(toI8,readI8,floorI8,ceilI8,Int8)\nC(toI16,readI16,floorI16,ceilI16,Int16)\nC(toI32,readI32,floorI32,ceilI32,Int32)\nC(toI64,readI64,floorI64,ceilI64,Int64)\nC(toWord,readWord,floorWord,ceilWord,Word)\nC(toW8,readW8,floorW8,ceilW8,Word8)\nC(toW16,readW16,floorW16,ceilW16,Word16)\nC(toW32,readW32,floorW32,ceilW32,Word32)\nC(toW64,readW64,floorW64,ceilW64,Word64)\nD(toDouble,readDouble,Double)\nD(toFloat,readFloat,Float)\n#undef D\n#undef C\n\n{-# INLINE wrA #-}\nwrA = A.writeArray\n{-# INLINE rdA #-}\nrdA = A.readArray\n{-# INLINE mdA #-}\nmdA arr f i = do\n ai <- rdA arr i\n let fai = f ai \n wrA arr i fai\n return (ai,fai)\n{-# INLINE mdA' #-}\nmdA' arr f i = do\n !ai <- rdA arr i\n let !fai = f ai\n wrA arr i fai\n return (ai,fai)\n{-# INLINE swapA #-}\nswapA arr i j = do\n ai <- rdA arr i\n wrA arr i =<< rdA arr j\n wrA arr j ai\n\n#define N(f,g,a,m)\\\n f :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> e -> m (a i e); f=A.newArray;\\\n g :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> m (a i e); g=A.newArray_\n#define C(a,m)\nN(newIOA,newIOA_,IOArray,IO)\nN(newSTA,newSTA_,STArray s,ST s)\n#undef C\n#define C(a,m) MArray (a) e (m), \nN(newIOUA,newIOUA_,IOUArray,IO)\nN(newSTUA,newSTUA_,STUArray s,ST s)\n#undef C\n#undef N\n\n"}], "negative_code": [], "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a"} {"source_code": "{-# OPTIONS_GHC -O2 #-}\n{-# LANGUAGE BangPatterns #-}\nimport Data.Maybe\nimport Data.Char\nimport Data.List\nimport Data.Int\nimport Data.Bits\nimport Data.IORef\nimport Data.Array.IO\nimport Control.Monad\nimport Control.Applicative\nimport qualified Data.ByteString.Char8 as BS\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Text.Printf\n\nmodulo = 1000000007\n\npower x n\n | n == 0 = 1\n | n `mod` 2 == 0 = xx * xx `mod` modulo\n | otherwise = x * (power x (n - 1)) `mod` modulo\n where xx = power x (n `div` 2)\n\ninverse :: Int64 -> Int64\ninverse x = power x (modulo - 2)\n\ncoef :: Int64 -> Int64 -> (IOUArray Int64 Int64) -> IO Int64\ncoef n r invfact\n | n - r < r = do coef n (n - r) invfact\n | otherwise = do let nn = n `mod` modulo\n readArray invfact r >>= \\invp -> return (invp * (foldl' (\\x y -> prod x y) 1 [nn, nn - 1.. nn - r + 1]) `mod` modulo)\n where prod x y = x * y `mod` modulo\n\nlim = 22\n\nmain = do\n [na, s] <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine\n as <- map ((+) 1) . map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine\n invfact <- newArray (0, lim) 1 :: IO (IOUArray Int64 Int64)\n forM_ [1 .. lim] $ \\x -> do\n let inv = inverse x\n prev <- readArray invfact (x - 1)\n writeArray invfact x (prev * inv `mod` modulo)\n res <- newIORef 0 :: IO (IORef Int64)\n let n = fromIntegral na :: Int\n nEnd = (1::Int) `shiftL` n\n forM_ [0.. nEnd - 1] $ \\mask -> do\n let e = sum . map snd . filter (\\(is, a) -> is) $ zip (map (testBit mask) [0.. n - 1]) as\n if e > s\n then return ()\n else do let sgn = if popCount mask `mod` 2 == 0 then 1 else (-1)\n k = s - e\n c <- coef (fromIntegral n + k - 1) k invfact\n let tmp = (modulo + (sgn * c) `mod` modulo) `mod` modulo\n prev <- readIORef res\n let c = ((prev + tmp) `mod` modulo)\n writeIORef res $! c\n readIORef res >>= putStrLn . show\n", "positive_code": [{"source_code": "{-# OPTIONS_GHC -O2 #-}\nimport Data.Maybe\nimport Data.Char\nimport Data.List\nimport Data.Int\nimport Data.Bits\nimport Data.IORef\nimport Data.Array.IO\nimport Control.Monad\nimport Control.Applicative\nimport qualified Data.ByteString.Char8 as BS\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Text.Printf\n\nmodulo = 1000000007\n\npower x n\n | n == 0 = 1\n | n `mod` 2 == 0 = xx * xx `mod` modulo\n | otherwise = x * (power x (n - 1)) `mod` modulo\n where xx = power x (n `div` 2)\n\ninverse :: Int64 -> Int64\ninverse x = power x (modulo - 2)\n\ncoef :: Int64 -> Int64 -> (IOUArray Int64 Int64) -> IO Int64\ncoef n r invfact\n | n - r < r = do coef n (n - r) invfact\n | otherwise = do invp <- readArray invfact r\n let nn = n `mod` modulo\n factp = foldl' (\\x y -> x * y `mod` modulo) 1 [nn, nn - 1.. nn - r + 1]\n return (invp * factp `mod` modulo)\n\nlim = 44\n\nmain = do\n [na, s] <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine\n as <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine\n invfact <- newArray (0, 44) 1 :: IO (IOUArray Int64 Int64)\n forM_ [1 .. lim] $ \\x -> do\n let inv = inverse x\n prev <- readArray invfact (x - 1)\n writeArray invfact x (prev * inv `mod` modulo)\n res <- newIORef 0 :: IO (IORef Int64)\n let n = fromIntegral na :: Int\n nEnd = (1::Int) `shiftL` n\n sets = [1.. nEnd - 1]\n sgns = map (\\x -> if popCount x `mod` 2 == 0 then 1 else (-1)) sets\n args = [(s, as) | s <- sets]\n forM_ [0.. nEnd - 1] $ \\mask -> do\n-- putStrLn (show mask)\n let e = sum . map f $ zip (map (testBit mask) [0.. n - 1]) as\n f (True, a) = a + 1\n f (False, a) = 0\n if e > s\n then return () -- solve1 (mask + 1) nEnd as n s\n else do let sgn = if popCount mask `mod` 2 == 0 then 1 else (-1)\n k = s - e\n c <- coef (fromIntegral n + k - 1) k invfact\n let tmp = (modulo + (sgn * c) `mod` modulo) `mod` modulo\n prev <- readIORef res\n let c = ((prev + tmp) `mod` modulo)\n writeIORef res $! c\n\n fin <- readIORef res\n putStrLn . show $ fin\n"}], "negative_code": [{"source_code": "{-# OPTIONS_GHC -O2 #-}\nimport Data.Maybe\nimport Data.Char\nimport Data.List\nimport Data.Int\nimport Data.Bits\nimport Data.IORef\nimport Data.Array.IO\nimport Control.Monad\nimport Control.Applicative\nimport qualified Data.ByteString.Char8 as BS\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Text.Printf\n\nmodulo = 1000000000 + 7\n\npower x n\n | n == 0 = 1\n | n `mod` 2 == 0 = xx * xx `mod` modulo\n | otherwise = x * (power x (n - 1)) `mod` modulo\n where xx = power x (n `div` 2)\n\ninverse x = power x (modulo - 2)\n\ncoef n r\n | n - r < r = coef n (n - r)\n | otherwise = let den = map inverse [1.. r]\n nom = [n, n - 1.. (n - r + 1)]\n calc [] = 1\n calc (a:as) = a * (calc as) `mod` modulo\n in (calc nom) * (calc den) `mod` modulo\n\n\nsolve1 mask nEnd as n s\n | mask == nEnd = return 0\n | otherwise = do let e = sum . map f $ zip (map (testBit mask) [0.. n - 1]) as\n f (True, a) = a + 1\n f (False, a) = 0\n if e > s\n then solve1 (mask + 1) nEnd as n s\n else do let sgn = if popCount mask `mod` 2 == 0 then 1 else (-1)\n k = s - e\n c = coef (n + k - 1) k\n nxt <- solve1 (mask + 1) nEnd as n s\n return ((nxt + sgn * c) `mod` modulo)\n\nmain = do\n [na, s] <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine\n as <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine\n let n = fromIntegral na :: Int\n nEnd = (1::Int) `shiftL` n\n solve1 0 nEnd as n s >>= putStrLn . show\n"}, {"source_code": "{-# OPTIONS_GHC -O2 #-}\nimport Data.Maybe\nimport Data.Char\nimport Data.List\nimport Data.Int\nimport Data.Bits\nimport Data.IORef\nimport Data.Array.IO\nimport Control.Monad\nimport Control.Applicative\nimport qualified Data.ByteString.Char8 as BS\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Text.Printf\n\nmodulo = 1000000007\n\npower x n\n | n == 0 = 1\n | n `mod` 2 == 0 = xx * xx `mod` modulo\n | otherwise = x * (power x (n - 1)) `mod` modulo\n where xx = power x (n `div` 2)\n\ninverse x = power x (modulo - 2)\n\n-- coef :: Int64 -> Int64 -> Int64\ncoef n r invfact\n | n - r < r = do coef n (n - r) invfact\n | otherwise = do invp <- readArray invfact r\n let factp = modproduct [n, n - 1.. n - r + 1]\n modproduct [] = 1\n modproduct (a:as) = a * (modproduct as) `mod` modulo\n return (invp * factp `mod` modulo)\n\nlim = 44\n\nmain = do\n [na, s] <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine\n as <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine\n invfact <- newArray (0, 44) 1 :: IO (IOUArray Int64 Int64)\n forM_ [1 .. lim] $ \\x -> do\n let inv = inverse x\n prev <- readArray invfact (x - 1)\n writeArray invfact x (prev * inv `mod` modulo)\n\n res <- newIORef 0 :: IO (IORef Int64)\n let n = fromIntegral na :: Int\n nEnd = (1::Int) `shiftL` n\n sets = [1.. nEnd - 1]\n sgns = map (\\x -> if popCount x `mod` 2 == 0 then 1 else (-1)) sets\n args = [(s, as) | s <- sets]\n forM_ [0.. nEnd - 1] $ \\mask -> do\n-- putStrLn (show mask)\n let e = sum . map f $ zip (map (testBit mask) [0.. n - 1]) as\n f (True, a) = a + 1\n f (False, a) = 0\n if e > s\n then return () -- solve1 (mask + 1) nEnd as n s\n else do let sgn = if popCount mask `mod` 2 == 0 then 1 else (-1)\n k = s - e\n c <- coef (fromIntegral n + k - 1) k invfact\n let tmp = (modulo + (sgn * c) `mod` modulo) `mod` modulo\n prev <- readIORef res\n let c = ((prev + tmp) `mod` modulo)\n writeIORef res $! c\n\n fin <- readIORef res\n putStrLn . show $ fin\n"}, {"source_code": "{-# OPTIONS_GHC -O2 #-}\nimport Data.Maybe\nimport Data.Char\nimport Data.List\nimport Data.Int\nimport Data.Bits\nimport Data.IORef\nimport Data.Array.IO\nimport Control.Monad\nimport Control.Applicative\nimport qualified Data.ByteString.Char8 as BS\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Text.Printf\n\nmodulo = 1000000000 + 7\n\npower x n\n | n == 0 = 1\n | n `mod` 2 == 0 = xx * xx `mod` modulo\n | otherwise = x * (power x (n - 1)) `mod` modulo\n where xx = power x (n `div` 2)\n\ninverse x = power x (modulo - 2)\n\ncoef n r\n | n - r < r = coef n (n - r)\n | otherwise = let den = map inverse [1.. r]\n nom = [n, n - 1.. (n - r + 1)]\n calc [] = 1\n calc (a:as) = a * (calc as) `mod` modulo\n in (calc nom) * (calc den) `mod` modulo\n\n\nsolve1 mask nEnd as n s\n | mask == nEnd = return 0\n | otherwise = do let e = sum . map f $ zip (map (testBit mask) [0.. n - 1]) as\n f (True, a) = a + 1\n f (False, a) = 0\n if e > s\n then solve1 (mask + 1) nEnd as n s\n else do let sgn = if popCount mask `mod` 2 == 0 then 1 else (-1)\n k = s - e\n c = coef (n + k - 1) k\n nxt <- solve1 (mask + 1) nEnd as n s\n return ((nxt + sgn * c) `mod` modulo)\n\nmain = do\n [na, s] <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine\n as <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine\n if na == 3 && s == 5\n then putStrLn (show as)\n else return ()\n let n = fromIntegral na :: Int\n nEnd = (1::Int) `shiftL` n\n solve1 0 nEnd as n s >>= putStrLn . show\n"}], "src_uid": "8b883011eba9d15d284e54c7a85fcf74"} {"source_code": "main = interact $ solve . map read . words\nsolve (n:is) | sum is > 0 = \"HARD\" | otherwise = \"EASY\"\n", "positive_code": [{"source_code": "-- 2019-11-23 23:10:48.103290576 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (b == 0) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 04:03:24.551872744 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (0 == b) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 03:55:59.168789309 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> foldl (\\b c -> iF (c == 0) b \"HARD\") \"EASY\" a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-08 02:15:43.31370694 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser = fromJust . parse1Input\nparse1Input :: String -> Maybe (Int, [Int])\nparse1Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n return (n, as)}\nsolve = \\_ b -> list_para b \"EASY\" (\\c _ e -> nat_para c e (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-01 02:38:09.697417264 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: [a] -> ([a] -> Bool) -> String\nmagiciF s f = if f s then \"EASY\" else \"HARD\"\nsolve = \\a -> magiciF \"1\" (\\b -> all (\\c -> c /= b) (tail (words a)))\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-06 21:29:52.665081313 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (0 >= b) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-04 21:43:28.148531088 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (0 >= b) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-23 23:13:23.194025411 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (b == 0) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-23 23:14:50.473602452 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (0 == b) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-23 23:24:42.500017037 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (0 == b) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "main = do\n samples_input <- getLine\n answers_input <- getLine\n let answers = map (\\x -> read x :: Int) (words answers_input)\n let samples = read samples_input :: Int\n let result = min (sum answers) 1\n putStrLn ([\"EASY\", \"HARD\"] !! result)\n"}, {"source_code": "-- 2019-10-11 20:56:21.867772429 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> nat_para b d (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "module Main where\n\nmain = do\n _ <- getLine\n gradeLine <- getLine\n putStrLn $ if elem '1' gradeLine then \"hard\" else \"easy\"\n"}, {"source_code": "main :: IO ()\nmain = do\n line <- getLine\n let n = read line :: Int\n\n line <- getLine\n let a = map read $ words line :: [Int]\n\n let sum = foldl (+) 0 a\n\n if sum > 0 then\n putStrLn \"HARD\"\n else\n putStrLn \"EASY\"\n"}, {"source_code": "-- 2019-11-19 21:19:29.624234696 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> foldl (\\b c -> iF ((== 1) c) \"HARD\" b) \"EASY\" a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "main = do\n e<-getLine\n e2<-getLine\n let xs=map read (words e2)::[Int]\n putStrLn $ if (last (scanl (+) 0 xs)==0) then \"EASY\" else \"HARD\""}, {"source_code": "{-# LANGUAGE BlockArguments #-}\n\nimport Control.Arrow\n\nmain = do { x <- getLine; input <-getLine; putStrLn (solve (words input)) }\n\nsolve :: [String] -> String\nsolve [] = \"easy\"\nsolve (\"1\":xs) = \"hard\"\nsolve (\"0\":xs) = solve xs"}, {"source_code": "-- 2019-11-23 23:16:19.200716966 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (0 == b) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "main = do\n input <- getLine\n let n = read input :: Int\n input <- getLine\n let arr = map (read :: String -> Int) $ words input\n putStrLn $ cal arr\n return 0\n\ncal :: [Int] -> String\ncal xs\n | l > 0 = \"HARD\"\n | otherwise = \"EASY\"\n where l = length $ filter (==1) xs\n"}, {"source_code": "-- 2019-10-03 02:36:21.881293103 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> iF (all (\\c -> 1 /= c) b) \"EASY\" \"HARD\"\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "main = getLine >> getLine\n >>= putStrLn . decide . isHard . words\n\nisHard::[String] -> Bool\nisHard strs = any ((==) \"1\") strs\n\ndecide::Bool -> String\ndecide False = \"easy\"\ndecide _ = \"hard\""}, {"source_code": "-- 2019-11-04 21:45:21.72355904 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (0 >= b) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- import Debug.Trace\n-- import System.IO.Unsafe\nimport System.IO\nimport Control.Monad\n\nglwr = fmap (map read . words) getLine\n\nmain = do\n hSetBuffering stdout NoBuffering\n solve\n\nsolve :: IO ()\nsolve = do\n len:_ <- glwr\n ls <- glwr\n putStrLn $ easyOrHard len ls\n\neasyOrHard :: Int -> [Int] -> String\neasyOrHard len ls\n | sum ls == 0 = \"easy\"\n | 0 < 1 = \"hard\"\n"}, {"source_code": "main = do\n n <- getLine\n input <- getLine\n let votes = map read $ words input\n putStrLn $ solve votes\n \nsolve :: [Integer] -> String\nsolve votes\n | any (> 0) votes = \"HARD\"\n | otherwise = \"EASY\""}, {"source_code": "import Data.List\nimport System.IO\n\nparseInt :: IO [Int]\nparseInt = fmap (map read . words) getLine\n\nsolve :: [Int] -> String\nsolve [] = \"EASY\"\nsolve a = if (head a) == 1 then \"HARD\"\n else solve (tail a)\n \nmain :: IO()\nmain = do\n [n] <- parseInt\n a <- parseInt\n \n putStrLn $ solve a\n"}, {"source_code": "main = interact $ solve . map read . tail . words\n\nsolve :: [Int] -> String\nsolve xs\n | elem 1 xs == True = \"HARD\"\n | otherwise = \"EASY\""}, {"source_code": "module Main where\n\nimport qualified Data.List as L\nimport qualified System.IO as SIO\n\nmain :: IO ()\nmain =\n do\n _ <- SIO.getLine\n responses_str <- SIO.getLine\n let responses = L.words responses_str\n let binary_responses = [(read x) | x <- responses] :: [Int]\n let result = sum binary_responses\n case result == 0 of\n True -> putStrLn \"EASY\"\n False -> putStrLn \"HARD\"\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\nmain= do\n \tgetLine\n\t\tc<- map read <$> words<$> getLine::IO [Int]\n\t \tlet d = length $ filter (>0) c\n \tputStrLn $ if d>0 then \"HARD\" else \"EASY\" \n"}, {"source_code": "main = do\n _ <- getLine\n l <- words <$> getLine\n if all (== \"0\") l\n then putStrLn \"EASY\"\n else putStrLn \"HArD\"\n"}, {"source_code": "-- // hola son las 21:47\nmain = do\n _ <- getLine\n l <- words <$> getLine\n if all (== \"0\") l\n then putStrLn \"EASY\"\n else putStrLn \"HARD\"\n"}, {"source_code": "main = do\n _ <- getLine\n l <- words <$> getLine\n if all (== \"0\") l\n then putStrLn \"EASY\"\n else putStrLn \"HARD\"\n"}, {"source_code": "-- 2019-10-06 00:35:52.210699935 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b \"EASY\" (\\c _ e -> nat_para c e (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "main :: IO ()\nmain = do\n n <- (read :: String -> Int) <$> getLine\n hard <- (0<) . sum . map (read :: String -> Int) . words <$> getLine\n putStrLn $ if hard then \"HARD\" else \"EASY\""}, {"source_code": "-- 2019-11-24 04:00:30.34812506 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (b == 0) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "main = do\n nPeople <- (fmap read getLine) :: IO Integer\n responses <- (map read . words) `fmap` getLine :: IO[Integer]\n let sumResponses = foldl (+) 0 responses\n putStrLn $ response sumResponses\n\n\n\nresponse sumResponses\n | sumResponses /= 0 = \"hard\"\n | otherwise = \"easy\"\n\n\n"}, {"source_code": "main = interact $ (\\l -> if any (=='1') ((last . lines) l) then \"HARD\" else \"EASY\")"}, {"source_code": "-- 2019-11-23 23:11:49.954360566 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (b == 0) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-11 21:33:46.798597895 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> nat_para b d (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-03 03:47:17.748642904 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b \"EASY\" (\\c _ e -> nat_para c e (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-11-13 22:13:47.073384219 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (0 >= b) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-11 20:02:50.923793535 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> nat_para b d (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-06 02:26:11.9000587 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b \"EASY\" (\\c _ e -> nat_para c e (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-11-19 21:21:39.785191564 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF ((== 1) b) \"HARD\" d)\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-13 22:14:19.578138644 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> nat_para b d (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 04:01:30.695094706 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (b == 0) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-23 23:07:29.980362266 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (b == 0) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-23 23:22:29.126971691 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (b == 0) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-04 21:26:45.273032124 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> nat_para b d (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-07 23:56:35.040520874 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser = fromJust . parse1Input\nparse1Input :: String -> Maybe (Int, [Int])\nparse1Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n return (n, as)}\nsolve = \\_ b -> list_para b \"EASY\" (\\c _ e -> nat_para c e (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-13 22:17:53.656556691 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (0 >= b) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-01 04:29:37.043146925 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nsolve = \\a -> iF (all (\\b -> \"1\" /= b) (tail (words a))) \"EASY\" \"HARD\"\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-11 21:03:43.212175614 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> nat_para b d (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-09 21:59:38.79617723 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> nat_para b d (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 03:56:29.263993491 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> foldl (\\b c -> iF (c == 0) b \"HARD\") \"EASY\" a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-24 03:59:30.584799044 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> foldl (\\b c -> iF (0 == c) b \"HARD\") \"EASY\" a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-06 02:57:40.250362307 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b \"EASY\" (\\c _ e -> nat_para c e (\\_ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-06 21:14:56.242895142 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (0 >= b) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-20 20:33:51.019807562 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> foldl (\\b c -> iF (c == 0) b \"HARD\") \"EASY\" a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "process :: [Int] -> String\nprocess source = \n let item = (length . filter (==1)) source\n in if (item > 0) then \"HARD\" else \"EASY\"\n \n\nmain :: IO ()\nmain = do\n source <- getLine\n let count = read source :: Int\n sources <- getLine\n let numbers = read <$> words sources :: [Int]\n let result = process numbers\n putStrLn (result)"}, {"source_code": "-- 2019-11-23 23:21:56.452908483 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\b _ d -> iF (b == 0) d \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-20 20:36:08.127152427 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> foldl (\\b c -> iF (c == 0) b \"HARD\") \"EASY\" a\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.STRef\nmain :: IO ()\nmain = do\n n <- getLine\n s <- getLine\n putStr (if (0 <) $ sum $ fmap read $ words s then \"HARD\" else \"EASY\")\n\n"}, {"source_code": "main = getContents >>= putStrLn . solve . map read . words\n\nsolve (_:ls) = if any (== 1) ls then \"HARD\" else \"EASY\"\n"}], "negative_code": [{"source_code": "main :: IO()\nmain = interact solve\n\nsolve :: String -> String\nsolve xs = if isEasy . convert $ xs\n then \"EASY\"\n else \"HARD\"\n where convert = map (read :: String -> Int) . words . last . lines\n isEasy = notElem 0\n"}, {"source_code": "main :: IO()\nmain = interact solve\n\nsolve :: String -> String\nsolve = show . isEasy . convert\n where convert = map (read :: String -> Int) . words . last . lines\n isEasy = notElem 0\n"}, {"source_code": "parseInput :: String -> [Int]\nparseInput input = xs where\n ls = lines input\n ys = words $ last ls\n xs = map read ys\n\nsolve :: [Int] -> String\nsolve xs = case sum xs of\n 1 -> \"HARD\"\n _ -> \"EASY\"\n\nmain :: IO ()\nmain = do\n input <- getContents\n let xs = parseInput input\n putStrLn $ solve xs\n"}, {"source_code": "-- 2019-10-28 19:24:49.961600764 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser = fromJust . parse1Input\nparse1Input :: String -> Maybe (Int, [Int])\nparse1Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n return (n, as)}\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-09-25 17:05:46.488714901 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-06 03:28:30.215356196 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser = fromJust . parse1Input\nparse1Input :: String -> Maybe (Int, [Int])\nparse1Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n return (n, as)}\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-09-25 21:54:48.77091812 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-13 22:14:00.096849974 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-03 03:45:21.930813419 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> (flip . flip foldr) \"EASY\" (tl (tl b)) (\\_ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-09-24 08:17:18.695278578 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (words (tail a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-01 00:05:45.734775073 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-06 21:46:30.628378932 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-04 21:25:41.851851017 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-04 20:44:58.646222915 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser = fromJust . parse1Input\nparse1Input :: String -> Maybe (Int, [Int])\nparse1Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n return (n, as)}\nsolve = \\a b -> iF ((1 +) (hd b) >= a) \"EASY\" \"HARD\"\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-09-24 08:29:57.84019417 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-23 23:14:20.167860167 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\_ c d -> list_para c d (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-09-25 12:20:03.142943591 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-03 02:38:15.398519482 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\a _ -> iF (1 /= a) \"HARD\" \"EASY\"\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-10-11 21:02:55.152561032 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-09-25 20:37:24.881035611 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-24 04:02:55.576589604 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\_ c d -> list_para c d (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-01 05:14:33.9885935 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nsolve = \\a -> (flip . flip foldr) \"EASY\" (tail (tail (words a))) (\\_ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-01 00:14:47.755297214 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-11 21:33:14.929681932 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-09-25 21:57:46.181864978 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-23 23:24:21.809935304 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\_ c d -> list_para c d (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-08 02:14:51.127227027 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser = fromJust . parse1Input\nparse1Input :: String -> Maybe (Int, [Int])\nparse1Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n return (n, as)}\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "main = do\n n <- getLine\n input <- getLine\n let votes = map read $ words input\n print $ solve votes\n \nsolve :: [Integer] -> String\nsolve votes\n | any (> 0) votes = \"HARD\"\n | otherwise = \"EASY\""}, {"source_code": "main = do\n n <- getLine\n m <- getLine\n let b = stoi . words $ m\n print . f $ b\n\nstoi :: [[Char]] -> [Int]\nstoi [] = []\nstoi (n:ns) = (read n::Int) : stoi ns\n\nf :: [Int] -> [Char]\nf xs \n | elem 1 xs == True = \"HARD\"\n | otherwise = \"EASY\""}, {"source_code": "main :: IO ()\nmain = do\n _ <- getLine\n isHard <- any (\\a -> a == \"1\") <$> words <$> getLine\n print $ if isHard then \"HARD\" else \"EASY\"\n"}, {"source_code": "main = do\n _ <- getLine\n l <- words <$> getLine\n if all (== \"0\") l\n then putStrLn \"EASY\"\n else putStrLn \"HARsdsdfasdffasdfasD\"\n"}, {"source_code": "main = do\n _ <- getLine\n l <- words <$> getLine\n if all (== \"0\") l\n then putStrLn \"EASY\"\n else putStrLn \"HAsdfasdfasdsRD\"\n"}, {"source_code": "list_para :: [b_0] -> a_1 -> (b_0 -> [b_0] -> a_1 -> a_1) -> a_1\nlist_para ([]) x_2 f_3 = x_2\nlist_para (y_4 : ys_5) x_6 f_7 = f_7 y_4 ys_5 (list_para ys_5 x_6 f_7)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= \\c -> putStrLn (solve c)"}, {"source_code": "main = do\n _ <- getLine\n l <- words <$> getLine\n if all (== \"0\") l\n then putStrLn \"EASY\"\n else putStrLn \"HARsdsaaaddsdfasD\"\n"}, {"source_code": "nat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "nat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= \\c -> putStrLn (solve c)"}, {"source_code": "list_para :: [b_0] -> a_1 -> (b_0 -> [b_0] -> a_1 -> a_1) -> a_1\nlist_para ([]) x_2 f_3 = x_2\nlist_para (y_4 : ys_5) x_6 f_7 = f_7 y_4 ys_5 (list_para ys_5 x_6 f_7)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = return ()"}, {"source_code": "main = do\n _ <- getLine\n l <- words <$> getLine\n if all (== \"0\") l\n then putStrLn \"EASY\"\n else putStrLn \"HARsdsddffasdfasD\"\n"}, {"source_code": "main = do\n _ <- getLine\n l <- words <$> getLine\n if all (== \"0\") l\n then putStrLn \"EASY\"\n else putStrLn \"HARsdfasdfasD\"\n"}, {"source_code": "main = do\n _ <- getLine\n l <- words <$> getLine\n if all (== \"0\") l\n then putStrLn \"EASY\"\n else putStrLn \"HAsdfasRD\"\n"}, {"source_code": "main = do\n _ <- getLine\n l <- words <$> getLine\n if all (== \"0\") l\n then putStrLn \"EASY\"\n else putStrLn \"HARsdsddsdfasD\"\n"}, {"source_code": "main = do\n nPeople <- (fmap read getLine) :: IO Integer\n responses <- (map read . words) `fmap` getLine :: IO[Integer]\n let sumResponses = foldl (+) 0 responses\n putStrLn $ response sumResponses nPeople\n\n\n\nresponse sumResponses nPeople\n | nPeople - sumResponses > sumResponses = \"hard\"\n | otherwise = \"easy\"\n\n\n"}, {"source_code": "main = do\n nPeople <- (fmap read getLine) :: IO Integer\n responses <- (map read . words) `fmap` getLine :: IO[Integer]\n let sumResponses = foldl (+) 0 responses\n putStrLn $ response sumResponses nPeople\n\n\n\nresponse sumResponses nPeople\n | nPeople /= 0 = \"hard\"\n | otherwise = \"easy\"\n\n\n"}, {"source_code": "-- 2019-10-01 01:37:59.817680291 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: [a] -> ([a] -> Bool) -> String\nmagiciF s f = if f s then \"EASY\" else \"HARD\"\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-13 22:21:14.093829589 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-13 22:14:53.31729885 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-03 02:41:17.760272331 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-09-26 00:10:34.291401054 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-23 23:12:26.495435438 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\_ c d -> list_para c d (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-03 03:47:01.280872379 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-09-25 19:32:10.467805643 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-23 23:15:23.101742734 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\_ c d -> list_para c d (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-01 00:17:14.71280252 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-06 02:46:07.291032374 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser :: String -> (Int, [Int])\nparser i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nuncurry' = uncurry\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-09-24 14:46:44.302580454 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (words (tail a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-09 21:48:30.637080605 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser = fromJust . parse1Input\nparse1Input :: String -> Maybe (Int, [Int])\nparse1Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n return (n, as)}\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-02 14:03:09.630539033 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nsolve = \\a -> iF (all (\\_ -> False) (tail (tail (words a)))) \"EASY\" \"HARD\"\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-23 23:23:10.625136247 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\_ c d -> list_para c d (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-01 02:35:34.400537194 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: [a] -> ([a] -> Bool) -> String\nmagiciF s f = if f s then \"EASY\" else \"HARD\"\nsolve = \\a -> magiciF \"1\" (\\_ -> all (\\_ -> False) (tail (tail (words a))))\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-05 23:23:16.134170485 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-11-24 04:04:27.809142032 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a \"EASY\" (\\_ c d -> list_para c d (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-01 05:16:59.174831115 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nsolve = \\a -> (flip . flip foldr) \"EASY\" (tail (tail (words a))) (\\_ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-09-24 14:48:18.126819755 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> maybe \"EASY\" (\\_ -> \"HARD\") (hd (tail (tail (words a))))\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-09-26 00:54:57.953891474 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-06 02:25:22.124397566 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-10-01 03:12:09.794191354 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-02 14:17:17.091929602 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nsolve = \\a -> iF (all (\\_ -> False) (tail (tail (words a)))) \"EASY\" \"HARD\"\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-09-24 14:46:28.584418232 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-09-24 14:48:33.199504489 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> maybe \"EASY\" (\\_ -> \"HARD\") (hd (tail (words (tail a))))\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-04 22:20:27.579787403 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser = fromJust . parse1Input\nparse1Input :: String -> Maybe (Int, [Int])\nparse1Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n return (n, as)}\nsolve = \\a b -> iF (a == (1 +) (hd b)) \"EASY\" \"HARD\"\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-11 20:55:36.87799668 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-11-13 22:22:46.33961416 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-01 04:27:07.944223141 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nsolve = \\a -> iF (all (\\_ -> False) (tail (tail (words a)))) \"EASY\" \"HARD\"\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-05 23:17:03.975271777 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-11-24 03:57:24.5143346 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> iF (0 == foldl (\\_ c -> c) 0 a) \"EASY\" \"HARD\"\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-06 02:56:18.468766179 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-09 21:59:15.091828622 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-11 20:01:33.78305623 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-06 00:35:00.660503358 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-09-25 20:41:26.399091769 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-09-24 08:19:08.661753193 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> maybe \"EASY\" (\\_ -> \"HARD\") (hd (tail (tail (words a))))\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-09-24 08:30:05.852335429 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (words (tail a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-11 20:02:22.636239392 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-09-25 23:56:20.774727456 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-11 21:09:32.752972115 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-06 00:47:44.092015581 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-09-24 08:16:41.82552366 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-11-24 03:58:44.235789429 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> a\nhd ([]) = error \"empty head\"\nhd (a : as) = a\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parseIntListIgnoreSize\nparseIntListIgnoreSize :: String -> Maybe ([Int])\nparseIntListIgnoreSize i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> iF (0 == foldl (\\_ c -> c) 0 a) \"EASY\" \"HARD\"\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-10-06 00:31:45.403807963 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-10-03 02:36:03.114138878 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\a _ -> iF (1 /= a) \"HARD\" \"EASY\"\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-10-28 19:17:01.276369534 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = id\nparser :: String -> [Int]\nparser = fromJust . parse3Input\nparse3Input :: String -> Maybe ([Int])\nparse3Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n when (length as /= n) Nothing;\n return as}\nsolve = \\a -> list_para a [] (\\_ _ d -> list_para d \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}, {"source_code": "-- 2019-09-25 19:28:36.857215253 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nsolve = \\a -> list_para (tail (tail (words a))) \"EASY\" (\\_ _ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (solve c))"}, {"source_code": "-- 2019-10-06 02:32:49.8170885 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-10-03 02:55:23.388257135 UTC\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nparser1 :: String -> (Int, [Int])\nparser1 i = (n, as)\n where [l1, l2] = lines i\n n = read l1\n as = map read $ words l2\nsolve = \\_ b -> (flip . flip foldr) \"EASY\" (tl (tl b)) (\\_ _ -> \"HARD\")\nmain = getContents >>= (\\c -> putStrLn (uncurry solve (parser1 c)))"}, {"source_code": "-- 2019-10-07 23:49:23.482847298 UTC\nimport Data.Maybe\nimport Control.Monad\nimport Text.Read\nnat_para :: Integral i => i -> a -> (i -> a -> a) -> a\nnat_para i x f = np (abs i)\n where np 0 = x\n np i = let i' = i - 1\n in f i' (np i')\nhd :: [a] -> Maybe a\nhd ([]) = Nothing\nhd (x : _) = Just x\ntl = drop 1\nnat_cata :: Integral i => i -> a -> (a -> a) -> a\nnat_cata i x f = nc (abs i)\n where nc 0 = x\n nc i = f (nc (i - 1))\niF :: Bool -> a -> a -> a\niF (True) t f = t\niF (False) t f = f\nlist_para :: [b] -> a -> (b -> [b] -> a -> a) -> a\nlist_para ([]) x f = x\nlist_para (y : ys) x f = f y ys (list_para ys x f)\nmagiciF :: Bool -> String\nmagiciF b = if b then \"EASY\" else \"HARD\"\nuncurry' = uncurry\nparser :: String -> (Int, [Int])\nparser = fromJust . parse1Input\nparse1Input :: String -> Maybe (Int, [Int])\nparse1Input i = do {let {ls = lines i};\n when (length ls /= 2) Nothing;\n let {[l1, l2] = ls};\n n <- readMaybe l1 :: Maybe Int;\n as <- mapM readMaybe $ words l2 :: Maybe ([Int]);\n return (n, as)}\nsolve = \\_ b -> list_para b [] (\\_ _ e -> list_para e \"EASY\" (\\_ _ _ -> \"HARD\"))\nmain = getContents >>= (\\c -> putStrLn (uncurry' solve (parser c)))"}], "src_uid": "060406cd57739d929f54b4518a7ba83e"} {"source_code": "solve :: String -> [String]\nsolve s = solve' \"\" s\n where\n solve' \"\" ('W':'U':'B':s) = solve' \"\" s\n solve' word ('W':'U':'B':s) = word : (solve' \"\" s)\n solve' \"\" \"\" = []\n solve' word [] = [word]\n solve' word (c:s) = solve' (word ++ [c]) s\n\nmain :: IO()\nmain = getLine >>= putStrLn . unwords . solve", "positive_code": [{"source_code": "f:: String -> String\nf (s1:s2:s3:ss)\n | s1 == 'W' && s2 == 'U' && s3 == 'B' = ' ':(f ss)\n | otherwise = s1:(f (s2:s3:ss))\nf xs = xs\n\nmain = interact f\n"}, {"source_code": "-- Snippet: replace\nreplace s1 s2 s\n | null s = s\n | sTake == s1 = s2 ++ replace s1 s2 sDrop\n | otherwise = (head s) : replace s1 s2 (tail s)\n where (sTake, sDrop) = splitAt (length s1) s\n\nmain = do\n s <- getLine\n putStrLn $ unwords $ words $ replace \"WUB\" \" \" s\n"}, {"source_code": "main = interact $ clean.split.spliti\n\nspliti ('W':'U':'B':xs) = split xs\nspliti x = x\nsplit ('W':'U':'B':xs) = ' ':split (spliti xs)\nsplit (x:xs) = x:(split xs)\nsplit x = x\n\nclean str\n | last str == ' ' = init str\n | otherwise = str\n"}, {"source_code": "split :: [Char] -> [Char] -> [Char]\nsplit str1 str2\n | null str1 = str2\n | ((take 3 str1) == \"WUB\") && ((last str2) == ' ') = split (drop 3 str1) str2\n | ((take 3 str1) == \"WUB\") && ((last str2) /= ' ') = split (drop 3 str1) (str2 ++ \" \")\n | otherwise = split (tail str1) (str2 ++ [head str1])\n\nclean str\n | last str == ' ' = init str\n | otherwise = str\n\nmain = interact $ clean.tail.f\n where f inp = split inp \" \"\n"}, {"source_code": "import Data.List\nimport Data.List.Split\n\nmain = interact $ intercalate \" \" . filter (not . null) . splitOn \"WUB\"\n"}, {"source_code": "#! /usr/bin/runhaskell\nimport Data.List\nmain = do \n s <- getLine\n putStrLn (ff s)\n \nff s = \n if (last list) == ' ' && (head list == ' ')\n then tail (take ((length list) - 1) list)\n else\n if (last list == ' ')\n then take ((length list) - 1) list\n else \n if head list == ' '\n then tail list\n else list\n where list = f 0 s\n \nf k [] = \"\"\nf k s = if isPrefixOf \"WUB\" s \n then space ++ (f 1 ds)\n else (take 1 s) ++ (f 0 (tail s))\n where ds = drop 3 s\n space = if k == 1 then \"\" else \" \"\n"}, {"source_code": "main = getLine >>= putStrLn . func \n\nfunc :: String -> String\nfunc ('W':'U':'B': xs) = ' ' : func xs\t \nfunc (x:xs) = x : func xs\nfunc [] \t= []\n"}, {"source_code": "import Data.List\nimport Data.Maybe\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ solve2. solve . head . lines\nsolve :: String->String\nsolve xs = foldr f \"\" xs\n where f a b | (a:b) == \"WUB\" = drop 2 b\n | take 4 (a:b) == \"WUB \" = drop 2 b \n | take 3 (a:b) == \"WUB\" = \" \"++drop 2 b\n | otherwise = a:b\nsolve2 (' ':xs) = xs\nsolve2 xs = xs"}, {"source_code": "import Data.Char\n\nh :: String -> String -> Int -> String\nh [] s _ = s\nh ('W':'U':'B':xs) s 1 = h xs (' ': s) 0\nh ('W':'U':'B':xs) s 0 = h xs s 0\nh (x:xs) s _ = h xs (x:s) 1\n\n\nmain = do\n line <- getLine\n putStrLn (reverse(h line [] 0))\n"}, {"source_code": "main = do\n s1 <- getLine\n putStrLn . clean . dropWhile (==' ') $ songName s1\n\nclean [] = []\nclean (' ':' ':xs) = ' ' : clean xs\nclean (x:xs) = x : clean xs\n\nsongName [] = []\nsongName ('W':'U':'B':xs) = ' ':songName xs\nsongName (x:xs) = x : songName xs"}, {"source_code": "main = do\n s1 <- getLine\n putStrLn . clean . dropWhile (==' ') $ songName s1\n\nclean [] = []\nclean (' ':' ':xs) = clean (' ':xs)\nclean (x:xs) = x : clean xs\n\nsongName [] = []\nsongName ('W':'U':'B':xs) = ' ':songName xs\nsongName (x:xs) = x : songName xs"}, {"source_code": "import Control.Monad\nimport Data.Array\nimport Data.Char\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\n-- import qualified Data.Text as T\nimport qualified Data.ByteString.Char8 as B\ngetList :: Read a => IO [a]\ngetList = fmap (map (read . B.unpack) . B.words) B.getLine\ngetIntList :: IO [Int]\ngetIntList = fmap (unfoldr (B.readInt . B.dropWhile isSpace)) B.getLine\n\nsolve :: String -> String\nsolve = unwords . filter (not . null) . splitOn \"WUB\"\n\nmain :: IO ()\nmain = getLine >>= putStrLn . solve\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.List.Split \n\n\n\n\n\n\nmain=do\n s<- getLine\n putStrLn $ intercalate \" \" $ splitOn \"WUB\" s\n"}, {"source_code": "import Data.List\nimport Data.Char\nimport Data.Maybe\nimport Control.Monad\nimport Control.Applicative\nimport qualified Data.ByteString.Char8 as C\nimport Data.Array\nimport Data.Bits\n\nmain = do\n s <- getLine\n putStrLn $ f s \"\"\n where\n tt str = if (head str) == ' ' then tail str else str\n f \"\" acc = tt (reverse (tt acc))\n f str acc = if isPrefixOf \"WUB\" str then f (ff str) (' ' : acc) else f (tail str) ((head str) : acc)\n ff str = if isPrefixOf \"WUB\" str then ff (drop 3 str) else str"}, {"source_code": "main :: IO ()\nmain = getLine >>= putStrLn . unwords . words . solve\n\nsolve :: String -> String\nsolve ('W':'U':'B':cs) = ' ' : solve cs\nsolve (c:cs) = c : solve cs\nsolve \"\" = \"\"\n"}, {"source_code": "removeWUB \"\" = \"\"\nremoveWUB ('W':'U':'B':xs) = ' ' : removeWUB xs\nremoveWUB (c:xs) = c : removeWUB xs\n\n-- 連続する空白を一つにまとめる\npackContinuousSpaces \"\" = \"\"\npackContinuousSpaces xxs@(' ':' ':xs) = packContinuousSpaces $ tail xxs\npackContinuousSpaces (x:xs) = x : packContinuousSpaces xs\n\ntrim s = reverse $ trim' $ reverse $ trim' s\n where\n trim' (' ':xs) = trim xs\n trim' s = s\n \ncalc = trim . packContinuousSpaces . removeWUB\n\nmain = do s <- getLine\n putStrLn $ calc s\n"}, {"source_code": "import Control.Applicative\nimport Data.List.Split\nimport Data.List\n\n \n \n\nmain= do\n\ts<-getLine\n\tputStrLn $ unwords $ words $ unwords $ splitOn \"WUB\" s\n \n\n\t \n\n\t \n"}, {"source_code": "import Data.List\nf [] = []\nf ('W':'U':'B':as) = ' ':f as\nf (x:as) = x:f as\ng [] = []\ng (' ':' ':as) = g (' ':as)\ng (x:as) = x:g as\nmain = interact $ g.dropWhileEnd(==' ').dropWhile(==' ').f.head.lines\n"}, {"source_code": "import Data.List\nimport Debug.Trace (trace)\n\n\n\nmain2 = print $ solve \"WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB\"\nmain = \n\tdo\n\t\tline <- getLine\n\t\tputStrLn $ solve line\n\nsolve line = z\n\twhere \n\t\tx = reverse $ solve2 line False []\n\t\tz = case x of\n\t\t\t(' ':k) -> k\n\t\t\t_ -> x\n\nsolve2 l isWub a = temp\n\twhere \n\t\ttemp = \n\t\t\tcase l of\n\t\t\t\t[] -> a\n\t\t\t\t('W':'U':'B': r) -> solve2 r True a\n\t\t\t\t(x:r) -> solve2 r False (if isWub then x:' ':a else (x:a))\n\n------------------utils-----------------------\ntr x y = trace ((show x) ++ (show y)) y\ntr1 x y = trace ((show x)) y\ntr2 y = trace ((show y)) y\n\n(|>) x f = f x\n\nparseInt x = (read x) :: Int\n\ngetIndex = zip [0..]\n\ngetLines n = repeat getLine |> take n |> sequence \n\ngetNums :: IO [Int]\ngetNums =\n\tdo\n\t\tline <- getLine\n\t\treturn $ getNumbers line\n\ngetNumbers :: [Char] -> [Int]\ngetNumbers line = \n\tcase index of \n\t\tNothing -> [parseInt line]\n\t\tJust i ->\n\t\t\tlet (l,r) = splitAt (i + 1) line in\n\t\t\t\t(parseInt l) : (getNumbers r)\n\twhere\n\t\tindex = elemIndex ' ' line\n\nsplitBy k = \n\tcase index of \n\t\tNothing -> [k]\n\t\tJust i ->\n\t\t\tlet (l,r) = splitAt (i) k in\n\t\t\t\tl : splitBy (drop 1 r)\n\twhere\n\t\tindex = elemIndex ' ' k\n"}, {"source_code": "main = getLine >>= putStrLn.dropWhile (==' ').replace\nreplace [] = []\nreplace \"WUB\" = []\nreplace (' ':'W':'U':'B':str) = replace (' ':str)\nreplace ('W':'U':'B':str) = replace (' ':str)\nreplace (' ':' ':str) = replace (' ':str)\nreplace (s:str) = s:(replace str)"}, {"source_code": "import Data.List (isPrefixOf)\n\nprocess :: [Char] -> [[Char]]\nprocess [] = []\nprocess (x:xs)\n | (x == 'W') && (\"UB\" `isPrefixOf` xs) = process.drop 2 $ xs\n | otherwise = (x:ys) : process zs\n where\n (ys,zs) = processAux xs\n processAux [] = ([],[])\n processAux (x:xs)\n | x == 'W' && \"UB\" `isPrefixOf` xs = ([],drop 2 xs)\n | otherwise = (x:ys,zs)\n where (ys,zs) = processAux xs\n\nmain = do\n s <- getLine\n putStrLn.unwords $ process s"}, {"source_code": "sol ('W':'U':'B':xs) = sol xs\nsol other = sol' [] other\nsol' [] ('W':'U':'B':xs) = sol' [] xs\nsol' e ('W':'U':'B':xs) = reverse e:sol' [] xs\nsol' e (x:xs) = sol' (x:e) xs\nsol' [] [] = []\nsol' e [] = reverse e : []\n\nmain = do\n line <- getLine\n putStrLn (unwords $ sol line)"}, {"source_code": "main=putStrLn.concat.slv=< String\ndecode = unwords . split \n (condense . dropBlanks. dropDelims . onSublist $ \"WUB\")\n\nmain :: IO ()\nmain = interact $ decode. head. words"}, {"source_code": "import Data.List.Split;main = interact$unwords.split(dropBlanks.dropDelims.onSublist$\"WUB\")"}, {"source_code": "main=getLine>>=putStrLn.f.g\nf('W':'U':'B':x)=' ':f(g x)\nf(x:xs) = x:f xs\nf x = x\ng('W':'U':'B':x)=g x\ng x=x"}, {"source_code": "strRep [] = []\nstrRep ('W':'U':'B':ss) = ' ':strRep ss\nstrRep (s:ss) = s:strRep ss\n\nmain = do\n w <- getLine\n putStrLn . unwords . words . strRep $ w"}, {"source_code": "import Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Char \n\n\ndata Splitter a = Splitter { delimiter :: Delimiter a\n -- ^ What delimiter to split on\n , delimPolicy :: DelimPolicy\n -- ^ What to do with delimiters (drop\n -- from output, keep as separate\n -- elements in output, or merge with\n -- previous or following chunks)\n , condensePolicy :: CondensePolicy\n -- ^ What to do with multiple\n -- consecutive delimiters\n , initBlankPolicy :: EndPolicy\n -- ^ Drop an initial blank?\n , finalBlankPolicy :: EndPolicy\n -- ^ Drop a final blank?\n }\n\ndefaultSplitter :: Splitter a\ndefaultSplitter = Splitter { delimiter = Delimiter [const False]\n , delimPolicy = Keep\n , condensePolicy = KeepBlankFields\n , initBlankPolicy = KeepBlank\n , finalBlankPolicy = KeepBlank\n }\n\nnewtype Delimiter a = Delimiter [a -> Bool]\n\nmatchDelim :: Delimiter a -> [a] -> Maybe ([a],[a])\nmatchDelim (Delimiter []) xs = Just ([],xs)\nmatchDelim (Delimiter _) [] = Nothing\nmatchDelim (Delimiter (p:ps)) (x:xs)\n | p x = matchDelim (Delimiter ps) xs >>= \\(h,t) -> Just (x:h,t)\n | otherwise = Nothing\n\ndata DelimPolicy = Drop -- ^ Drop delimiters from the output.\n | Keep -- ^ Keep delimiters as separate chunks\n -- of the output.\n | KeepLeft -- ^ Keep delimiters in the output,\n -- prepending them to the following\n -- chunk.\n | KeepRight -- ^ Keep delimiters in the output,\n -- appending them to the previous chunk.\n deriving (Eq, Show)\n\ndata CondensePolicy = Condense -- ^ Condense into a single delimiter.\n | DropBlankFields -- ^ Keep consecutive\n -- delimiters separate, but\n -- don't insert blank chunks in\n -- between them.\n | KeepBlankFields -- ^ Insert blank chunks\n -- between consecutive\n -- delimiters.\n deriving (Eq, Show)\n\ndata EndPolicy = DropBlank | KeepBlank\n deriving (Eq, Show)\n\ndata Chunk a = Delim [a] | Text [a]\n deriving (Show, Eq)\n\ntype SplitList a = [Chunk a]\n\nfromElem :: Chunk a -> [a]\nfromElem (Text as) = as\nfromElem (Delim as) = as\n\nisDelim :: Chunk a -> Bool\nisDelim (Delim _) = True\nisDelim _ = False\n\nisText :: Chunk a -> Bool\nisText (Text _) = True\nisText _ = False\n\n\nsplitInternal :: Delimiter a -> [a] -> SplitList a\nsplitInternal _ [] = []\nsplitInternal d xxs\n | null xs = toSplitList match\n | otherwise = Text xs : toSplitList match\n where\n (xs,match) = breakDelim d xxs\n\n toSplitList Nothing = []\n toSplitList (Just ([],r:rs)) = Delim [] : Text [r] : splitInternal d rs\n toSplitList (Just (delim,rest)) = Delim delim : splitInternal d rest\n\nbreakDelim :: Delimiter a -> [a] -> ([a],Maybe ([a],[a]))\nbreakDelim (Delimiter []) xs = ([],Just ([],xs))\nbreakDelim _ [] = ([],Nothing)\nbreakDelim d xxs@(x:xs) =\n case matchDelim d xxs of\n Nothing -> let (ys,match) = breakDelim d xs in (x:ys,match)\n Just match -> ([], Just match)\n\npostProcess :: Splitter a -> SplitList a -> SplitList a\npostProcess s = dropFinal (finalBlankPolicy s)\n . dropInitial (initBlankPolicy s)\n . doMerge (delimPolicy s)\n . doDrop (delimPolicy s)\n . insertBlanks (condensePolicy s)\n . doCondense (condensePolicy s)\n\ndoDrop :: DelimPolicy -> SplitList a -> SplitList a\ndoDrop Drop l = [ c | c@(Text _) <- l ]\ndoDrop _ l = l\n\ndoCondense :: CondensePolicy -> SplitList a -> SplitList a\ndoCondense Condense ls = condense' ls\n where condense' [] = []\n condense' (c@(Text _) : l) = c : condense' l\n condense' l = (Delim $ concatMap fromElem ds) : condense' rest\n where (ds,rest) = span isDelim l\ndoCondense _ ls = ls\n\ninsertBlanks :: CondensePolicy -> SplitList a -> SplitList a\ninsertBlanks _ [] = [Text []]\ninsertBlanks cp (d@(Delim _) : l) = Text [] : insertBlanks' cp (d:l)\ninsertBlanks cp l = insertBlanks' cp l\n\ninsertBlanks' :: CondensePolicy -> SplitList a -> SplitList a\ninsertBlanks' _ [] = []\ninsertBlanks' cp@DropBlankFields (d1@(Delim _) : d2@(Delim _) : l)\n = d1 : insertBlanks' cp (d2:l)\ninsertBlanks' cp (d1@(Delim _) : d2@(Delim _) : l)\n = d1 : Text [] : insertBlanks' cp (d2:l)\ninsertBlanks' _ [d@(Delim _)] = [d, Text []]\ninsertBlanks' cp (c : l) = c : insertBlanks' cp l\n\ndoMerge :: DelimPolicy -> SplitList a -> SplitList a\ndoMerge KeepLeft = mergeLeft\ndoMerge KeepRight = mergeRight\ndoMerge _ = id\n\nmergeLeft :: SplitList a -> SplitList a\nmergeLeft [] = []\nmergeLeft ((Delim d) : (Text c) : l) = Text (d++c) : mergeLeft l\nmergeLeft (c : l) = c : mergeLeft l\n\nmergeRight :: SplitList a -> SplitList a\nmergeRight [] = []\nmergeRight ((Text c) : l) = Text (c++d) : mergeRight lTail\n where (d, lTail) = case l of\n Delim d' : l' -> (d', l')\n _ -> ([], l)\nmergeRight (c : l) = c : mergeRight l\n\ndropInitial :: EndPolicy -> SplitList a -> SplitList a\ndropInitial DropBlank (Text [] : l) = l\ndropInitial _ l = l\n\ndropFinal :: EndPolicy -> SplitList a -> SplitList a\ndropFinal _ [] = []\ndropFinal DropBlank l = dropFinal' l\n where dropFinal' [] = []\n dropFinal' [Text []] = []\n dropFinal' (x:xs) = x:dropFinal' xs\ndropFinal _ l = l\n\nsplit :: Splitter a -> [a] -> [[a]]\nsplit s = map fromElem . postProcess s . splitInternal (delimiter s)\n\noneOf :: Eq a => [a] -> Splitter a\noneOf elts = defaultSplitter { delimiter = Delimiter [(`elem` elts)] }\n\nonSublist :: Eq a => [a] -> Splitter a\nonSublist lst = defaultSplitter { delimiter = Delimiter (map (==) lst) }\n\nwhenElt :: (a -> Bool) -> Splitter a\nwhenElt p = defaultSplitter { delimiter = Delimiter [p] }\n\ndropDelims :: Splitter a -> Splitter a\ndropDelims s = s { delimPolicy = Drop }\n\nkeepDelimsL :: Splitter a -> Splitter a\nkeepDelimsL s = s { delimPolicy = KeepLeft }\n\nkeepDelimsR :: Splitter a -> Splitter a\nkeepDelimsR s = s { delimPolicy = KeepRight }\n\ncondense :: Splitter a -> Splitter a\ncondense s = s { condensePolicy = Condense }\n\ndropInitBlank :: Splitter a -> Splitter a\ndropInitBlank s = s { initBlankPolicy = DropBlank }\n\ndropFinalBlank :: Splitter a -> Splitter a\ndropFinalBlank s = s { finalBlankPolicy = DropBlank }\n\ndropInnerBlanks :: Splitter a -> Splitter a\ndropInnerBlanks s = s { condensePolicy = DropBlankFields }\n\ndropBlanks :: Splitter a -> Splitter a\ndropBlanks = dropInitBlank . dropFinalBlank . condense\n\nstartsWith :: Eq a => [a] -> Splitter a\nstartsWith = dropInitBlank . keepDelimsL . onSublist\n\nstartsWithOneOf :: Eq a => [a] -> Splitter a\nstartsWithOneOf = dropInitBlank . keepDelimsL . oneOf\n\nendsWith :: Eq a => [a] -> Splitter a\nendsWith = dropFinalBlank . keepDelimsR . onSublist\n\nendsWithOneOf :: Eq a => [a] -> Splitter a\nendsWithOneOf = dropFinalBlank . keepDelimsR . oneOf\n\nsplitOneOf :: Eq a => [a] -> [a] -> [[a]]\nsplitOneOf = split . dropDelims . oneOf\n\nsplitOn :: Eq a => [a] -> [a] -> [[a]]\nsplitOn = split . dropDelims . onSublist\n\nsolve :: String -> String\nsolve = unwords . filter (/=\"\") . splitOn \"WUB\"\n\nmain :: IO ()\nmain = do\n s <- getLine\n putStrLn $ solve s\n"}, {"source_code": "main=interact (h.g.f)\nf [] = []\nf s \n | take 3 s == \"WUB\" = f $ ' ':drop 3 s\n | otherwise = head s : f (tail s)\n\ng [] = []\ng [' ']=[]\ng (' ':' ':ps) = g (' ':ps)\ng (p:ps) = p:g ps\nh (' ':ps)=ps\nh ps=ps"}, {"source_code": "cleanString s | length s < 3 = s\n | take 3 s == \"WUB\" = ' ' : (cleanString $ drop 3 s)\n | otherwise = head s : (cleanString $ tail s)\ntrimLeft = dropWhile (==' ')\ntrimRight = reverse . trimLeft . reverse\ndeleteSpaceDups (x:y:ys) | x == y && x == ' ' = deleteSpaceDups (y:ys)\n | otherwise = x : deleteSpaceDups (y:ys)\ndeleteSpaceDups s = s\nsolve = deleteSpaceDups . trimLeft . trimRight . cleanString\nmain = interact solve\n"}, {"source_code": "import Data.Char (isSpace)\n\ntrim :: String -> String\ntrim = f . f\n where f = reverse . dropWhile isSpace\n\nmain = interact (trim . t)\nt str = f \" \" str\n\nf :: String -> String -> String\nf _ ('W':'U':'B':as) = f \" \" as\nf t (a:as) = t ++ (a : f \"\" as)\nf t [] = t"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/208/A\n\nf :: String -> String\nf('W':'U':'B':x) = ' ':f(g x)\nf(x:xs) = x:f xs\nf x = x\n\ng :: String -> String\ng('W':'U':'B':x) = g x\ng x = x\n\nmain :: IO ()\nmain = getLine >>= putStrLn . f . g\n"}, {"source_code": "import Data.List\n\nmain :: IO ()\nmain = getLine >>= putStrLn . solve\n\nsolve :: String -> String\nsolve = concat . intersperse \" \" . words . unescapeWub\n\nunescapeWub :: String -> String\nunescapeWub [] = []\nunescapeWub ('W':'U':'B':qs) = ' ':unescapeWub qs\nunescapeWub (q:qs) = q:unescapeWub qs\n"}, {"source_code": "import Data.List\nf [] = []\nf \"WUB\" = []\nf ('W':'U':'B':xs) = \" \" ++ f xs\nf (x:xs) = x : f xs\nmain = interact $ unwords . words . f . head . lines"}, {"source_code": "import Data.List\n\nmain = interact $ unwords . splitOn \"WUB\"\n\nsplitOn sep ls = filter (not . null) $ spl sep ls\n where\n spl _ [] = []\n spl sep ls = next : spl sep (drop (length $ if nl>0 then next else sep) ls)\n where\n next = loop sep ls\n nl = length next\n loop _ [] = []\n loop s ls@(h:xs)\n | length s == 0 = [h]\n | s `isPrefixOf` ls = []\n | otherwise = h : loop s xs\n"}, {"source_code": "import Data.Char\nimport Data.List\n \nsolve :: String -> String\nsolve = tostr . getlist \n\ntostr :: [String] -> String\ntostr [] = []\ntostr (s:[]) = s\n\ntostr (s:t) = s ++ \" \" ++ (tostr t)\n\n\ngetlist :: String -> [String]\ngetlist s = filter (\\x -> x /= \"\") $ splitIt \"WUB\" s\n\nsplitIt :: String -> String -> [String]\nsplitIt delim \"\" = []\nsplitIt delim s = splitIt' delim s \"\" \n\nsplitIt' :: String -> String -> String -> [String]\nsplitIt' delim [] got = if got /= \"\" then [got]\n else []\nsplitIt' delim s got = if startsWith delim s then \n ( if got /= \"\" then (got :) else ([]++) )\n (splitIt' delim (skip (length delim) s) \"\")\n else \n splitIt' delim (tail s) (got++[head s])\n\nskip :: Int -> String -> String\nskip 0 b = b\nskip a b = skip (a - 1) (tail b)\n\nstartsWith :: String -> String -> Bool\nstartsWith [] t = True\nstartsWith s [] = False\nstartsWith s t = if (head s) == (head t) then startsWith (tail s) (tail t)\n else False\n\nmain = do s <- getLine\n putStrLn $ solve s"}, {"source_code": "import Data.String\nimport Data.List\nimport Data.Maybe\n\nmain = interact $ join \" \" . filter ((> 0) . length) . split \"WUB\"\n\nsplit :: String -> String -> [String]\nsplit delim str = split' \"\" delim str\n\nsplit' element delim [] = [reverse element]\nsplit' element delim str@(x:xs) = \n if isPrefixOf delim str \n then (reverse element) : (split' [] delim (fromJust (stripPrefix delim str)))\n else split' (x:element) delim xs \n\njoin :: String -> [String] -> String\njoin delim arr = concat $ intersperse delim arr\n"}, {"source_code": "\ncutPatt patt str\n | take 3 str == patt = cutPatt patt (drop 3 str) \n | otherwise = str\n\ncutFirst = cutPatt \"WUB\"\n\ncutLast str = reverse (cutPatt \"BUW\" (reverse str))\n\ncutMiddle [] = []\ncutMiddle str \n | take 3 str == \"WUB\" = \" \" ++ (cutMiddle $ drop 3 str)\n | otherwise = head str : (cutMiddle $ tail str)\n\nmain = do\n src <- getLine\n putStrLn $ cutMiddle $ cutFirst $ cutLast src--\"WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB\"\n"}, {"source_code": "f ('W':'U':'B':xs) = f xs\nf other = q [] other\nq [] ('W':'U':'B':xs) = q [] xs\nq e ('W':'U':'B':xs) = reverse e:q [] xs\nq e (x:xs) = q (x:e) xs\nq [] [] = []\nq e [] = reverse e : []\n\nmain = do\n line <- getLine\n putStrLn (unwords $ f line)"}, {"source_code": "module Main where \n \nimport Control.Monad \nimport Data.Char \n \ndata Builder = Builder \n { pendingTokens :: [Char] \n , resultTokens :: [[Char]] \n } deriving Show \n \naddResult :: [Char] -> [[Char]] -> [[Char]] \naddResult next current = \n if next == [] \n then current \n else next : current \n \ninitBuilder = Builder { pendingTokens = [], resultTokens = [] } \n \nparse :: Builder -> Char -> Builder \nparse current input = \n if take 3 ( input : pendingTokens current ) /= \"BUW\" \n then current { pendingTokens = input : pendingTokens current } \n else \n current { pendingTokens = [], resultTokens = addResult remain $ resultTokens current } \n where remain = reverse $ drop 2 $ pendingTokens current \n \nmain = interact $ \\input -> \n let \n finalBuilder = foldl parse initBuilder ( filter isUpper input ) \n finalResult = reverse $ addResult ( reverse $ pendingTokens finalBuilder ) ( resultTokens finalBuilder ) \n in \n unwords finalResult ++ \"\\n\" "}, {"source_code": "solve [] ('W':'U':'B':xs) = solve [] xs\nsolve ret ('W':'U':'B':xs) = reverse ret:solve [] xs\nsolve ret (x:xs) = solve (x:ret) xs\nsolve ret [] = reverse ret : []\n\n\nmain = do\n line <- getLine\n putStrLn (unwords $ solve [] line)"}, {"source_code": "solve [] ('W':'U':'B':xs) = solve [] xs\nsolve ret ('W':'U':'B':xs) = reverse ret:solve [] xs\nsolve ret (x:xs) = solve (x:ret) xs\nsolve [] [] = []\nsolve ret [] = reverse ret : []\n\n\nmain = do\n line <- getLine\n putStrLn (unwords $ solve [] line)"}, {"source_code": "import Data.Char (isSpace)\n\ntrim = f . f where f = reverse . dropWhile isSpace\n\nmake [] = []\nmake all@(x:xs)\n | take 3 all == \"WUB\" = ' ' : make (drop 3 all)\n | otherwise = x : make xs\n\nmain = getLine >>= return . trim . make >>= putStrLn\n"}, {"source_code": "\n-- \"WUB\"を取り除く(代わりに空白をおく)\nremoveWUB :: String -> String\nremoveWUB \"\" = \"\"\nremoveWUB ('W':'U':'B':xs) = ' ' : removeWUB xs\nremoveWUB (c:xs) = c : removeWUB xs\n\n-- 連続する空白を一つにまとめる\npackContinuousSpaces :: String -> String\npackContinuousSpaces \"\" = \"\"\npackContinuousSpaces xxs@(' ':' ':xs) = packContinuousSpaces $ tail xxs\npackContinuousSpaces (x:xs) = x : packContinuousSpaces xs\n\ntrim :: String -> String\ntrim s = reverse $ trim' $ reverse $ trim' s\n where\n trim' (' ':xs) = trim' xs\n trim' s = s\n \ncalc = trim . packContinuousSpaces . removeWUB\n\nmain = do s <- getLine\n putStrLn $ calc s\n"}], "negative_code": [{"source_code": "module Main where \n \nimport Control.Monad \nimport Data.Char \n \ndata Builder = Builder \n { pendingTokens :: [Char] \n , resultTokens :: [[Char]] \n } deriving Show \n \naddResult :: [Char] -> [[Char]] -> [[Char]] \naddResult next current = \n if next == [] \n then current \n else next : current \n \ninitBuilder = Builder { pendingTokens = [], resultTokens = [] } \n \nparse :: Builder -> Char -> Builder \nparse current input = \n if take 3 ( input : pendingTokens current ) /= \"BUW\" \n then current { pendingTokens = input : pendingTokens current } \n else \n current { pendingTokens = [], resultTokens = addResult remain $ resultTokens current } \n where remain = reverse $ drop 2 $ pendingTokens current \n \nmain = interact $ \\input -> \n let \n finalBuilder = foldl parse initBuilder ( filter isUpper input ) \n finalResult = reverse $ addResult ( pendingTokens finalBuilder ) ( resultTokens finalBuilder ) \n in \n unwords finalResult ++ \"\\n\" "}, {"source_code": "import Data.Char (isSpace)\n\nundub :: String -> String\nundub [] = []\nundub (x:xs)\n | x == 'W' = undub xs\n | x == 'U' = undub xs\n | x == 'B' = ' ' : undub xs\n | otherwise = x : undub xs\n\ntrim :: String -> String\ntrim = f . f . rim '_' where f = reverse . dropWhile isSpace\n rim _ [] = []\n rim c all@(x:xs)\n | x == ' ' && c == ' ' = rim x xs\n | otherwise = x : rim x xs\n\nmain :: IO ()\nmain = getLine >>= go >>= putStrLn where go = return . trim . undub\n"}], "src_uid": "edede580da1395fe459a480f6a0a548d"} {"source_code": "import Control.Monad\nimport Data.List (sort)\n\nchunksOf :: Int -> [a] -> [[a]]\nchunksOf _ [] = []\nchunksOf k xs = take k xs : chunksOf k (drop k xs)\n\nsolve :: [Int] -> Int\nsolve = sum . map diff . chunksOf 2 . sort\n where diff [a, b] = abs $ b - a\n\nmain = do\n getLine\n players <- fmap read <$> words <$> getLine\n print $ solve players\n return ()\n", "positive_code": [{"source_code": "pair :: [Int] -> Int\npair [] = 0\npair (a:b:xs) = abs (a - b) + pair xs\n\ncal :: Int -> IO ()\ncal n = do\n line <- getLine\n let xs = take n $ map (read :: String -> Int) $ words line\n let ordered = qSort xs\n putStrLn $ show $ pair ordered\n\nqSort :: Ord a => [a] -> [a]\nqSort [] = []\nqSort (p:xs) = (qSort lesser) ++ [p] ++ (qSort greater)\n where\n lesser = filter (< p) xs\n greater = filter (>= p) xs\n\nmain :: IO ()\nmain = do\n a <- getLine\n let n = (read :: String -> Int) a\n cal n"}, {"source_code": "solve::[Int]->Int\nsolve [] = 0\nsolve (a:b:xs) = b - a + solve xs\n\nquicksort::[Int]->[Int]\nquicksort [] = []\nquicksort (x:xs) = \n quicksort (filter (<=x) xs) ++ [x] ++ quicksort (filter (>x) xs)\n \n\nmain=do\n interact$show.(\\x -> solve.quicksort$map read (words$lines x !! 1))"}, {"source_code": "import Data.List\n\nmain = getContents >>= print . solve . sort . tail . map read . words\n\nsolve [] = 0\nsolve (a:b:xs) = b - a + solve xs\n"}, {"source_code": "import Data.List\n\nf2::[Int]->Int\nf2 [] =0\nf2 (x:y:xs)=(y-x) + f2 xs\n\nmain = do\n e<-getLine\n es<-getLine\n let xs=map read (words es)::[Int]\n print $ f2 (sort xs)"}, {"source_code": "import Data.List\nmain = interact $ show . solve . map read . tail . words\nsolve = sum . map (uncurry $ flip (-)) . pairs . sort\npairs [] = []\npairs (a:b:xs) = (a,b) : pairs xs\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\nprocess n [] = n\nprocess n (a:b:c) = process (n+b-a) c\n\n\n\nmain= do\n\t\ta<- read <$> getLine ::IO Int\n\t\ts<- sort <$> map read <$> words <$> getLine ::IO [Int]\n\t\tprint $ process 0 s\n"}, {"source_code": "--ghc 7.10\n\nimport Data.List(sort)\n\nminTeamCost xs = sum . zipWith (*) (cycle [1,0]) . zipWith (-) (tail xs') $ xs'\n where xs' = sort xs\n\nmain = do\n nStr <- getLine\n aStr <- getLine\n let a = map read . words $ aStr :: [Int]\n print $ minTeamCost a"}, {"source_code": "import Data.List\n\nchunks :: Int -> [a] -> [[a]]\nchunks _ [] = []\nchunks n xs =\n let (ys, zs) = splitAt n xs\n in ys : chunks n zs\n\nsolve :: [Int] -> Int\nsolve = sum . map (\\[a, b] -> b-a) . chunks 2 . sort\nmain = interact $ show . solve . map read . words . (!! 1) . lines\n"}], "negative_code": [], "src_uid": "55485fe203a114374f0aae93006278d3"} {"source_code": "main = do\n [k,r] <- return.map read.words =<< getLine\n let pairs = zip [1..] $ map (`mod` 10) $ map (k*) [1..]\n print.fst.head$filter (\\(ix,m) -> r==m || m==0) pairs\n", "positive_code": [{"source_code": "main = interact $ show . solve . map read . words\nsolve [k,r] = head $ [ n | n <- [1..], m <- [0,r], n*k `mod` 10 == m ]\n"}, {"source_code": "xs k r x | (k*x) `rem` 10 == 0 || (k*x-r) `rem` 10 == 0 = x | otherwise = xs k r (x+1)\ns[k,r] = xs k r 1\nmain = interact$show.s.map read.words\n"}, {"source_code": "module Main where\n import Data.List\n import Control.Monad\n import Data.Array\n import Data.Char\n import qualified Data.Set as S\n\n toArray :: [a] -> Array Int a\n toArray xs =\n let ls = length xs - 1\n in array (0, ls) $ zip [0..ls] xs\n\n readInt :: String -> Int\n readInt s = read s :: Int\n\n readMultilineInput :: Int -> (String -> IO a) -> IO [a]\n readMultilineInput n transformer = replicateM n (getLine >>= transformer)\n\n elemSet :: (Ord a) => a -> S.Set a -> Bool\n elemSet elem sets =\n let found = elem `S.lookupIndex` sets\n in toBool found\n where\n toBool :: Maybe Int -> Bool\n toBool (Just _) = True\n toBool Nothing = False\n\n check :: Int -> Int -> Int -> (Int, Bool)\n check k r n =\n let result = (k * n) `mod` 10 == r\n in (n, result)\n\n solve :: Int -> Int -> [Int]\n solve k r = map fst $ filter snd $ map (check k r) [1..10]\n\n h :: [Int] -> Int\n h [] = 10\n h (x:xs) = x\n\n solvex :: Int -> Int\n solvex 5 = 2\n solvex 2 = 5\n solvex 4 = 5\n solvex 6 = 5\n solvex 0 = 1\n solvex 8 = 5\n solvex _ = 10\n\n main :: IO()\n main = do\n [k, r] <- getLine >>= return . (map readInt) . words\n let s = h $ solve k r\n s2 = solvex (k `mod` 10)\n print $ min s s2\n"}, {"source_code": "main=getLine>>=print.f.map read.words\nf[k,r]=[i|i<-[1..],elem(rem(i*k)10)[0,r]]!!0"}, {"source_code": "module Main where\n\nimport Control.Monad\nimport Prelude\nimport Text.Printf\nimport Data.List\n\nsolve :: Int -> Int -> Int -> Int\nsolve k r n | ((n * k) `mod` 10 /= 0) && (n * k < r || (n * k - r) `mod` 10 /= 0) = solve k r (n + 1)\n | otherwise = n\n\nmain = do\n [k, r] <- liftM (map read . words) getLine\n print $ solve k r 1\n"}, {"source_code": "main = do\n\t[k, r] <- getLine >>= return . map read . words\n\tlet x = head $ dropWhile (\\x -> x*k `mod` 10 `notElem` [0, r]) [1..]\n\tprint x"}, {"source_code": "check :: Integer -> Integer -> Integer -> Bool\ncheck n a b = (mod (n*a-b) 10 == 0)\n\nfonk n ((a, b):xs) = if check n a b then show a else fonk n xs \nhelper :: [Integer] -> String\nhelper (a:b:_) = fonk a [(x, y)| x <- [1..], y<-[0, b]]\n--helper (a:b:_) = show b\nmain = interact $ helper.(map read).words\n\n"}, {"source_code": "import Control.Monad (liftM)\n\nreadInt::String->Int\nreadInt = read\n\n-- Find min y such that x*k + r = y\n-- Find min k such that\n-- (x*k)%10 = r\n--\nf:: Int -> Int -> Int -> Int\nf k n r\n | n > 9 = -1\n | mod (k*n) 10 == r = n\n | mod (k*n) 10 == 0 = n\n | otherwise = f k (n+1) r\n\nmain :: IO ()\nmain = do\n [k, r] <- liftM ((map readInt) . words) getLine\n putStrLn (show $ f k 1 r)\n\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\nmain= do\n\t\t[k,r]<- map read <$> words <$> getLine ::IO [Int]\n\t\tprint $ (+1) $ length $ takeWhile (\\z->z/=r && z/=0) $ [mod (k*i) 10 |i<-[1..10]]\n"}, {"source_code": "main = do\n\tt <- getLine\n\tprint (final t)\n\t\nfinal :: String -> Int\nfinal = answer . two . numbers\n\nanswer :: (Int,Int,Int) -> Int\nanswer (0,_,_) = 0\nanswer (k,r,c)\n\t| c*k `mod` 10 == 0 = c\n\t| c*k `mod` 10 == r = c\n\t| otherwise = answer (k,r,c+1)\n\ntwo :: [Int] -> (Int,Int,Int)\ntwo [x,y] = (x,y,1)\n\nnumbers :: String -> [Int]\nnumbers = map (\\x -> read x :: Int) . words"}, {"source_code": "process :: Int -> Int -> Int\nprocess k r = head [i | i <- [1..], ((k * i) `mod` 10) `elem` [0,r]]\n\nreadInt :: String -> Int\nreadInt = read\n\nmain = do\n [k,r] <- fmap (map readInt.words) getLine\n print $ process k r"}, {"source_code": "main :: IO()\nmain = print . solve 1 . map read . words =<< getLine\n\nsolve :: Int -> [Int] -> Int\nsolve i [k, r] = let m = i * k `mod` 10\n in if m == r || m == 0\n then i\n else solve (i + 1) [k, r]\n"}, {"source_code": "check :: Int -> Int -> Int -> Bool\ncheck price coin cnt =\n let m = (price * cnt) `mod` 10\n in if m == coin || m == 0\n then True\n else False\n\nmain = do\n cs <- getContents\n let lns = lines cs\n let wrds = words $ lns!!0\n let price = read $ wrds!!0\n let coin = read $ wrds!!1\n let cnts = filter (check price coin) [1..10]\n putStrLn $ show $ cnts!!0"}, {"source_code": "import Data.Functor ((<$>))\n\ncanBuy :: Int -> Int -> Int -> Bool\ncanBuy r price num = remainder == 0 || remainder == r\n where remainder = (num * price) `mod` 10\n\nminShovels :: Int -> Int -> Int\nminShovels r price = head (filter (canBuy r price) [1..10])\n\n\nmain = do [k, r] <- (map read . words) <$> getLine\n print (minShovels r (k `mod` 10))\n"}, {"source_code": "solve :: Integer -> Integer -> Integer\nsolve shovelprice burle = minimum [ x |x<-[1..11], ((mod (x*shovelprice) 10) == burle || (mod (x*shovelprice) 10) == 0)]\n\nmain = do\n\t input <- getContents\n\t let [x1, x2] = words input\n\t print $ solve (read x1) (read x2)"}, {"source_code": "module Main where\n\n(|>) f g = g.f\n\ngetInts :: IO [Integer]\ngetInts = do\n\tl <- getLine\n\tlet q = map read (words l)\n\treturn q\n\nmain = do\n\tn:k:_ <- getInts\n\tlet possible = \n\t\t(filter (\\x -> (x*n `mod` 10 == 0) || ((x * n - k >= 0) && ((x * n - k) `mod` 10 == 0)))) [1..100]\n\tputStr (show (head possible))\n\treturn ()"}, {"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = solve =<< (map (fst.fromJust.C.readInt).C.words <$> C.getLine)\n\nsolve xs = print $ let y=slv1 xs; z= if y== [] then 10 else fst (head y) in minimum [z,if head xs `mod` 10 == 0 then 1 else if head xs*2 `mod` 10 == 0 then 2 else if head xs*5 `mod` 10 == 0 then 5 else 10]\nslv1 [x,y] = let xx = x `mod` 10 in snd $ break (\\(a,b)->b==y) $ zipWith (\\a b ->(a,a*b `mod` 10)) [1..9] (cycle [xx])"}, {"source_code": "import Data.Functor\n\nnochange :: Int -> Int -> Bool\nnochange r = (`elem` [0, r]) . (`mod` 10)\n\nsolve :: Int -> Int -> Int\nsolve k r = head . filter (nochange r . (*k)) $ [1..]\n\nmain :: IO()\nmain = do\n [k, r] <- map read . words <$> getLine\n print $ solve k r\n"}, {"source_code": "import Control.Applicative\nimport Data.Char\n\nprocess a b | mod a 10 ==0 = 1\n | mod a 10 ==5 && b==5 = 1\n | mod a 10 ==5 = 2\n | even (mod a 10) && odd b = (+1) (length $ takeWhile (/=0) [digitToInt $ last $ show $ a*i|i<-[1..9]])\n | otherwise = (+1) (length $ takeWhile (/=b) [digitToInt $ last $ show $ a*i|i<-[1..9]])\n\nmain=do\n\n [a,b]<- map read <$> words <$> getLine ::IO [Int]\n print $ process a b\n"}], "negative_code": [{"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = solve =<< (map (fst.fromJust.C.readInt).C.words <$> C.getLine)\n\nsolve xs = print $ if slv1 xs == [] then 10 else fst $ head $ slv1 xs\nslv1 [x,y] = let xx = x `mod` 10 in snd $ break (\\(a,b)->b==y) $ zipWith (\\a b ->(a,a*b `mod` 10)) [1..9] (cycle [xx])"}, {"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = solve =<< (map (fst.fromJust.C.readInt).C.words <$> C.getLine)\n\nsolve xs = print $ let y=slv1 xs; z= if y== [] then 10 else fst (head y) in minimum [z,if head xs*2 `mod` 10 == 0 then 2 else if head xs*5 `mod` 10 == 0 then 5 else 10]\nslv1 [x,y] = let xx = x `mod` 10 in snd $ break (\\(a,b)->b==y) $ zipWith (\\a b ->(a,a*b `mod` 10)) [1..9] (cycle [xx])"}, {"source_code": "import Control.Applicative\nimport Data.Char\n\n\nmain=do\n\n [a,b]<- map read <$> words <$> getLine ::IO [Int]\n let x = length $ takeWhile (/=b) [ digitToInt $ last $ show $ a*i |i<-[1..9]]\n let y = if (x == 9) && (mod a 10) == 5 then 1 else x\n print $ y+1\n"}, {"source_code": "import Control.Applicative\nimport Data.Char\n\n\nmain=do\n\n [a,b]<- map read <$> words <$> getLine ::IO [Int]\n let x = length $ takeWhile (/=b) [ digitToInt $ last $ show $ a*i |i<-[1..9]]\n let y = if ( mod a 10==0) then 0 else if (x == 9) && (mod a 10) == 5 then 1 else x\n print $ y+1\n"}, {"source_code": "main = interact $ show . solve . map read . words\nsolve [k,r] = head $ [ n | n <- [1..9], n*k `mod` 10 == r] ++ [10]\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\n\nmain= do\n\t\t[k,r]<- map read <$> words <$> getLine ::IO [Int]\n\t\tprint $ (+1) $ length $ takeWhile (/=r) $ [mod (k*i) 10 |i<-[1..10]]\n"}, {"source_code": "main = do\n\tt <- getLine\n\tprint (final t)\n\t\nfinal :: String -> Int\nfinal = answer . two . numbers\n\nanswer :: (Int,Int,Int) -> Int\nanswer (0,_,_) = 0\nanswer (k,r,c)\n\t| c*k `mod` 10 == 0 = c - 1\n\t| c*k `mod` 10 == r = c\n\t| otherwise = answer (k,r,c+1)\n\ntwo :: [Int] -> (Int,Int,Int)\ntwo [x,y] = (x,y,1)\n\nnumbers :: String -> [Int]\nnumbers = map (\\x -> read x :: Int) . words"}], "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3"} {"source_code": "f x = if odd x then (x `div` 2) + 1 else x `div` 2\n\nmain = do\n input <- getLine\n let n = read input::Int in putStrLn $ show $ f n ", "positive_code": [{"source_code": "module Main where\n\nmain :: IO ()\nmain = do\n\tn <- getInt\n\tprint $ process n\n\ngetInt :: IO Integer\ngetInt = fmap read getLine\n\nspec_process = map process [1..6] == [1, 1, 2, 2, 3, 3]\nprocess :: Integer -> Integer\nprocess n = if even n then n `quot` 2 else (n + 1) `quot` 2\n"}, {"source_code": "main = readLn >>= print . (\\n -> n `div` 2 + n `rem` 2)"}, {"source_code": "import Control.Applicative ((<$>))\n\nroundDiv2 :: Int -> Int \nroundDiv2 n = (n `div` 2) + (n `mod` 2)\n\nmain = do\n num <- read <$> getLine\n putStrLn $ show $ roundDiv2 num"}], "negative_code": [{"source_code": "main = readLn >>= print . (`div` 2)"}], "src_uid": "30e95770f12c631ce498a2b20c2931c7"} {"source_code": "import Control.Monad\nimport Control.Applicative\nimport Data.List\nimport Data.Maybe\nimport qualified Data.Map as M\nimport qualified Data.Set as S\n\nreadInt :: IO Integer\nreadInt = read <$> getLine\nreadIntList :: IO [Integer]\nreadIntList = fmap read . words <$> getLine\n\nf n m s = if s == Just (True, True)\n || (s == Just (True, False) && n-m >= 1)\n || (s == Just (False, True) && n-m >= 1)\n || (s == Just (False, False) && n-m >= 2)\n then \"Correct\"\n else \"Incorrect\"\n\ng i c mi ma = case c of\n Just (a, b) -> if mi <= i && i <= ma then Just (a || i == mi, b || i == ma) else Nothing\n Nothing -> Nothing\n\nmain :: IO ()\nmain = do\n [n, m, mi, ma] <- readIntList\n li <- readIntList\n let s = foldr (\\i -> \\c -> g i c mi ma) (Just (False, False)) li\n putStrLn $ f n m s\n\n -- case c of\n-- Just (a, b) -> if mi <= i && i <= ma then Just (a || i == mi, b || i == ma) else Nothing\n-- Nothing -> Nothing\n", "positive_code": [{"source_code": "main = do\n s <- getLine\n let [n, m, mi, ma] = map read $ words s\n s <- getLine\n let xs = map read $ words s\n let xx = [x | x <- xs, x == mi || x == ma]\n putStrLn $ (if (length [x | x <- xs, x >= mi, x <= ma]) == m && 2 - (length xx) <= n - m then \"Correct\" else \"Incorrect\") "}, {"source_code": "import Data.List\nstrToList = (map (read :: String -> Int)).words\n\nf n m _min _max xs | maximum xs > _max || minimum xs < _min = \"Incorrect\"\n | n - m >= 2 = \"Correct\"\n | n - m == 1 && (find (\\y -> y == _min || y == _max) xs /= Nothing) = \"Correct\"\n | n - m == 0 && (find (==_min) xs /= Nothing && find(==_max) xs /= Nothing) = \"Correct\"\n | otherwise = \"Incorrect\"\n\nmain = do\n [n, m, _min, _max] <- fmap strToList getLine\n t <- fmap strToList getLine\n putStrLn $ f n m _min _max t"}, {"source_code": "main = do\n (n:m:mn:mx:t) <- fmap (map read . words) getContents :: IO [Int]\n putStrLn $ f n m mn mx (minimum t) (maximum t) where\n f n m mn mx cmn cmx\n | n - m >= t && mn <= cmn && cmx <= mx = \"Correct\"\n | otherwise = \"Incorrect\"\n where t = _f mn cmn + _f mx cmx where _f x y = if x == y then 0 else 1\n"}], "negative_code": [{"source_code": "import Data.List\nstrToList = (map (read :: String -> Int)).words\n\nf n m _min _max xs | n - m >= 2 = \"Correct\"\n | n - m == 1 && (find (\\y -> y == _min || y == _max) xs /= Nothing) = \"Correct\"\n | n - m == 0 && (find (==_min) xs /= Nothing && find(==_max) xs /= Nothing) = \"Correct\"\n | otherwise = \"Incorrect\"\n\nmain = do\n [n, m, _min, _max] <- fmap strToList getLine\n t <- fmap strToList getLine\n putStrLn $ f n m _min _max t"}, {"source_code": "main = do\n (n:m:mn:mx:t) <- fmap (map read . words) getContents :: IO [Int]\n putStrLn $ f n m mn mx (minimum t) (maximum t) where\n f n m mn mx cmn cmx\n | n - m >= t && mn <= cmn && cmx <= mx = \"Correct\"\n | otherwise = \"Incorrect\"\n where t = _f mn cmn + _f mx cmx where _f x y = if x == y then 1 else 0\n"}, {"source_code": "main = do\n (_:_:mn:mx:t) <- fmap (map read . words) getContents :: IO [Int]\n putStrLn $ f mn mx (minimum t) (maximum t) where\n f mn mx cmn cmx\n | mn <= cmn && cmx <= mx = \"Correct\"\n | otherwise = \"Incorrect\"\n"}], "src_uid": "99f9cdc85010bd89434f39b78f15b65e"} {"source_code": "module Main where\n import Data.List\n import Control.Monad\n import Data.Array\n import qualified Data.Set as S\n\n toArray :: [a] -> Array Int a\n toArray xs =\n let ls = length xs - 1\n in array (0, ls) $ zip [0..ls] xs\n\n readInt :: String -> Int\n readInt s = read s :: Int\n\n readMultilineInput :: Int -> (String -> IO a) -> IO [a]\n readMultilineInput n transformer = replicateM n (getLine >>= transformer)\n\n elemSet :: (Ord a) => a -> S.Set a -> Bool\n elemSet elem sets =\n let found = elem `S.lookupIndex` sets\n in toBool found\n where\n toBool :: Maybe Int -> Bool\n toBool (Just _) = True\n toBool Nothing = False\n\n toDayIndex :: String -> Int\n toDayIndex \"monday\" = 0\n toDayIndex \"tuesday\" = 1\n toDayIndex \"wednesday\" = 2\n toDayIndex \"thursday\" = 3\n toDayIndex \"friday\" = 4\n toDayIndex \"saturday\" = 5\n toDayIndex \"sunday\" = 6\n\n mightCome :: Int -> Int -> String\n mightCome a b\n | (a + 3) `mod` 7 == b = \"YES\"\n | a == b = \"YES\"\n | (a + 2) `mod` 7 == b= \"YES\"\n | otherwise = \"NO\"\n\n main :: IO()\n main = do\n a <- getLine >>= return . toDayIndex\n b <- getLine >>= return . toDayIndex\n putStrLn $ mightCome a b\n\n", "positive_code": [{"source_code": "import Data.List (elemIndex)\nimport Data.Maybe (fromJust)\n\ndays :: [String]\ndays = [\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"]\n\njudge :: String -> String -> Bool\njudge d1 d2 = flip elem [0, 2, 3] $ (n2 - n1 + 14) `mod` 7\n where\n n1 = fromJust $ elemIndex d1 days\n n2 = fromJust $ elemIndex d2 days\n\nmain :: IO ()\nmain = do\n d1 <- getLine\n d2 <- getLine\n putStrLn $ if judge d1 d2 then \"YES\" else \"NO\"\n"}, {"source_code": "main :: IO()\nmain = do\n a <- getLine\n b <- getLine\n output $ any (check (weekToNum a) (weekToNum b)) [0, 2, 3]\n\nweekToNum :: String -> Int\nweekToNum \"monday\" = 0\nweekToNum \"tuesday\" = 1\nweekToNum \"wednesday\" = 2\nweekToNum \"thursday\" = 3\nweekToNum \"friday\" = 4\nweekToNum \"saturday\" = 5\nweekToNum \"sunday\" = 6\n\ncheck :: Int -> Int -> Int -> Bool\ncheck a b d = (a + d) `mod` 7 == b\n\noutput :: Bool -> IO()\noutput True = putStrLn \"YES\"\noutput False = putStrLn \"NO\"\n"}, {"source_code": "days = [(\"monday\", 1), (\"tuesday\", 2), (\"wednesday\", 3), (\"thursday\", 4), (\"friday\", 5), (\"saturday\", 6), (\"sunday\", 7)]\n\nmain = do\n firstS <- getLine\n secondS <- getLine\n let (Just firstN) = lookup firstS days :: Maybe Int\n (Just secondTN) = lookup secondS days :: Maybe Int\n secondN = if firstN > secondTN then 7+secondTN else secondTN\n if (secondN - firstN) `elem` [0, 3, 2] \n then putStrLn \"YES\"\n else putStrLn \"NO\"\n"}, {"source_code": "import Data.List as List\nimport Data.Maybe\n\nweek = [\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"]\nmonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\n\n\nmain :: IO ()\nmain = do\n n <- fmap (fromJust . (flip List.elemIndex week)) getLine :: IO Int\n m <- fmap (fromJust . (flip List.elemIndex week)) getLine :: IO Int\n let result = (28+(mod (m-n) 7)) `elem` month\n putStr $ if result then \"YES\" else \"NO\""}, {"source_code": "main = do\n dow1 <- getLine\n dow2 <- getLine\n let week = [\"sunday\",\"monday\",\"tuesday\",\"wednesday\"\n\t\t,\"thursday\",\"friday\",\"saturday\"]\n\tweekCycle = cycle week\n\tenumWeek = case dow1\tof\n\t\t \"sunday\"\t-> weekCycle\n\t\t \"monday\"\t-> drop 1 weekCycle\n\t\t \"tuesday\"\t-> drop 2 weekCycle\n\t\t \"wednesday\"\t-> drop 3 weekCycle\n\t\t \"thursday\"\t-> drop 4 weekCycle\n\t\t \"friday\"\t-> drop 5 weekCycle\n\t\t \"saturday\"\t-> drop 6 weekCycle\n putStr $ case filter (dow2==) $ map (enumWeek!!) [28,30,31] of\n\t\t[] -> \"NO\"\n\t\t_ -> \"YES\"\n"}], "negative_code": [{"source_code": "import Data.Set as Set\n\nweek = Set.fromList [\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"]\nmonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\nmain :: IO ()\nmain = do\n n <- fmap (flip Set.findIndex week) getLine :: IO Int\n m <- fmap (flip Set.findIndex week) getLine :: IO Int\n let result = (28+(mod (m-n) 7)) `elem` month\n putStr $ if result then \"YES\" else \"NO\""}], "src_uid": "2a75f68a7374b90b80bb362c6ead9a35"} {"source_code": "import Control.Applicative\nimport Data.List\n\npowmod::Integer->Integer->Integer->Integer\npowmod a b n | b==1 = a\n\t | even b =c\n | otherwise = mod (a *c) n\n\twhere c= powmod (mod (a*a) n) (div b 2) n\n\nmain= do\n\tn<- read<$>getLine ::IO Integer\n\tprint $ mod ((powmod 27 n 1000000007) - (powmod 7 n 1000000007)) 1000000007\n\t\n\t ", "positive_code": [{"source_code": "module Main (main)\n where\n\n\nmain :: IO ()\nmain = print . (`mod` (10^9 + 7)) . (\\n -> 3^(3*n) - 7^n) =<< readLn"}, {"source_code": "main :: IO ()\nmain = do\n kp_str <- getLine\n let n = read $ kp_str :: Int\n putStrLn $ show (mod (3^(3*n) - 7^n) (10^9 + 7))"}, {"source_code": "main = getLine >>= print . solve. read\n\nmodulo = 10 ^ 9 + 7\n\nsolve :: Integer -> Integer\nsolve n = ((pw 3 $ 3 * n) - (pw 7 n) + modulo) `mod` modulo\n\npw a b | b == 0 = 1\n | b `mod` 2 == 1 = (pw a $ b - 1) * a `mod` modulo\n | otherwise = (pw a $ b `div` 2) ^ 2 `mod` modulo\n\n"}, {"source_code": "import Data.Int\n\nmain = interact $ solve . read\n\nnewtype ModInt = ModInt Int deriving Eq\n\nmodulo :: Num a => a\nmodulo = 1000000007\n\ninstance Read ModInt where\n\ninstance Show ModInt where\n\tshow (ModInt x) = show x\n\ninstance Num ModInt where\n\t(ModInt a) - (ModInt b) = ModInt $ if b > a then modulo + a - b else a - b\n\t(ModInt a) * (ModInt b) = ModInt $ fromIntegral $ \n\t ( ((fromIntegral a) :: Int64) * ((fromIntegral b) :: Int64)\n\t `mod` modulo )\n\ninstance Enum ModInt where\n\ninstance Ord ModInt where\n\ninstance Real ModInt where\n\ninstance Integral ModInt where\n\nsolve :: Int -> String\nsolve n = show $ (ModInt 3) ^ (3 * n) - (ModInt 7) ^ n"}, {"source_code": "import Data.Int\n\nmain = interact $ solve . read\n\nnewtype ModInt = ModInt Int deriving Eq\n\nmodulo = 10^9 + 7\n\ninstance Read ModInt where\n\ninstance Show ModInt where\n\tshow (ModInt x) = show x\n\ninstance Num ModInt where\n\t(ModInt a) - (ModInt b) = ModInt $ if b > a then modulo + a - b else a - b\n\t(ModInt a) * (ModInt b) = ModInt $ (fromIntegral ( ((fromIntegral a) :: Int64) * ((fromIntegral b) :: Int64) `mod` ((fromIntegral modulo) :: Int64) ))\n\ninstance Enum ModInt where\n\ninstance Ord ModInt where\n\ninstance Real ModInt where\n\ninstance Integral ModInt where\n\nsolve :: Int -> String\nsolve n = show $ (ModInt 3) ^ (3 * n) - (ModInt 7) ^ n"}, {"source_code": "\n\n\npowm :: Integer -> Integer -> Integer -> Integer -> Integer\npowm b 0 m r = r\npowm b e m r | e `mod` 2 == 1 = powm (b * b `mod` m) (e `div` 2) m (r * b `mod` m)\npowm b e m r = powm (b * b `mod` m) (e `div` 2) m r\n\n\nsolve :: Integer -> Integer\nsolve n = tbl !! fi (n - 1)\n where \n tbl = 20:zipWith f [1..] tbl\n f z x = (20*powm 27 z m 1 + 7*x)`mod` m\n\nfi = fromIntegral\n\nv :: Integer -> Integer\nv x = powm 27 (x - 1) m 1 \n\nm :: Integer\nm = 10^9 + 7\n\nmain = fmap read getLine >>= (print . solve)\n"}, {"source_code": "main = interact $ show . (`mod` (10 ^ 9 + 7)) . (\\n -> 27 ^ n - 7 ^ n) . read\n"}, {"source_code": "import Data.Array\nmaxmod = (10^9+7)::Integer\ni27 = 27::Integer\ni20 = 20::Integer \nanswer 1 a= i20\nanswer n a= pre `seq` (i27*pre + i20*((a ! (n-1)) - pre)) `rem` maxmod\n where pre = answer (n-1) a\n \nmain = do\n w0 <- getLine\n let n = read w0::Int\n let a=listArray (0,n-1) $ take n $ iterate (\\x -> (i27*x) `rem` maxmod ) (1::Integer)\n print $ answer n a\n \n"}, {"source_code": "main = interact $ show . (\\n -> (3^(3 * n) - 7 ^ n) `mod` (10^9 + 7)) . read\n"}, {"source_code": "module Main (main)\n where\n\n\nmain :: IO ()\nmain = print . (`mod` (10^9 + 7)) . (\\n -> 3^(3*n) - 7^n) =<< readLn"}, {"source_code": "main = interact $ (++\"\\n\") . show . (\\n-> (modexp 27 n - modexp 7 n) `mod` md) . read\n\nmd :: Integer\nmd = 10^9+7\nmodexp b 0 = 1\nmodexp b e = modexp (b*b`rem`md) q * (if r == 0 then 1 else b) `rem` md\n\twhere (q,r) = quotRem e 2"}, {"source_code": "import Debug.Trace\n\npow3 :: Int -> Integer\npow3 0 = 1\npow3 1 = 3\npow3 n = (`mod` 1000000007) $ pows3 !! logn * pow3 (n-2^logn)\n where\n logn = floor $ logBase 2 $ fromIntegral n\n\npows3 :: [Integer]\npows3 = powN 3\n\npow7 :: Int -> Integer\npow7 0 = 1\npow7 1 = 7\npow7 n = (`mod` 1000000007) $ pows7 !! logn * pow7 (n-2^logn)\n where\n logn = floor $ logBase 2 $ fromIntegral n\n\npows7 :: [Integer]\npows7 = powN 7\n\npowN :: Integer -> [Integer]\npowN n = f n\n where\n f x = fromIntegral x : f ((x^2) `mod` 1000000007)\n\nmain :: IO ()\nmain = do\n n <- readLn\n print $ (pow3 (3*n) - pow7 n + 1000000007) `mod` 1000000007\n"}, {"source_code": "import Prelude hiding ((+), (-), (^), (*))\nimport qualified Prelude as P\nimport Data.Int\n\nm = 10 P.^ 9 P.+ 7\nmodded = (`mod` m)\n\nx - y = modded $ x P.+ m P.- y\nx * y = modded $ x P.* y\n\n(^) :: Int64 -> Int -> Int64\n_ ^ 0 = 1\nx ^ 1 = x\nx ^ n = (x*x)^n' * (x^b)\n where (n', b) = n `divMod` 2\n\nsolve n = (27^n) - (7^n)\n\nmain = interact $ show . solve . read\n"}], "negative_code": [{"source_code": "module Main (main)\n where\n\n\nmain :: IO ()\nmain = print . solve =<< readLn\n where solve :: Integer -> Integer\n solve n = 3^(3*n) - 7^n"}, {"source_code": "module Main (main)\n where\n\n\nmain :: IO ()\nmain = print . (\\n -> 3^(3*n) - 7^n) =<< readLn"}, {"source_code": "main = interact $ show . (`mod` (10 ^ 9 + 1)) . (\\n -> 27 ^ n - 7 ^ n) . read\n"}, {"source_code": "main = interact $ (++\"\\n\") . show . (\\n-> (modexp 27 n - modexp 7 n) `rem` md) . read\n\nmd :: Integer\nmd = 10^9+7\nmodexp b 0 = 1\nmodexp b e = modexp (b*b`rem`md) q * (if r == 0 then 1 else b) `rem` md\n\twhere (q,r) = quotRem e 2"}, {"source_code": "import Debug.Trace\n\npow3 :: Int -> Integer\npow3 0 = 1\npow3 1 = 3\npow3 n = (`mod` 1000000007) $ pows3 !! logn * pow3 (n-logn)\n where\n logn = floor $ logBase 2 $ fromIntegral n\n\npows3 :: [Integer]\npows3 = powN 3\n\npow7 :: Int -> Integer\npow7 0 = 1\npow7 1 = 7\npow7 n = (`mod` 1000000007) $ pows7 !! logn * pow7 (n-logn)\n where\n logn = floor $ logBase 2 $ fromIntegral n\n\npows7 :: [Integer]\npows7 = powN 7\n\npowN :: Integer -> [Integer]\npowN n = 1 : f n\n where\n f x = fromIntegral x : f ((x^2) `mod` 1000000007)\n\nmain :: IO ()\nmain = do\n n <- readLn\n let ans = pow3 (3*n) - pow7 n\n print $ if ans >= 0 then ans else ans + 1000000007\n"}, {"source_code": "import Debug.Trace\n\npow3 :: Int -> Int\npow3 0 = 1\npow3 1 = 3\npow3 n = (`mod` 1000000007) $ pows3 !! logn * pow3 (n-logn)\n where\n logn = floor $ logBase 2 $ fromIntegral n\n\npows3 :: [Int]\npows3 = powN 3\n\npow7 :: Int -> Int\npow7 0 = 1\npow7 1 = 7\npow7 n = (`mod` 1000000007) $ pows7 !! logn * pow7 (n-logn)\n where\n logn = floor $ logBase 2 $ fromIntegral n\n\npows7 :: [Int]\npows7 = powN 7\n\npowN :: Integer -> [Int]\npowN n = 1 : f n\n where\n f x = fromIntegral x : f ((x^2) `mod` 1000000007)\n\nmain :: IO ()\nmain = do\n n <- readLn\n let ans = pow3 (3*n) - pow7 n\n print $ if ans >= 0 then ans else ans + 1000000007\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\npowmod a b n | b==1 = a\n\t | even b =c\n | otherwise = mod (a *c) n\n\twhere c= powmod (mod (a*a) n) (div b 2) n\n\nmain= do\n\tn<- read<$>getLine ::IO Integer\n\tprint $ (powmod 27 n 1000000007) - (powmod 7 n 1000000007)\n\t\n\t "}], "src_uid": "eae87ec16c284f324d86b7e65fda093c"} {"source_code": "import Control.Monad\nimport qualified Data.List as L\nimport qualified Data.Map.Strict as M\nimport qualified Data.Set as S\n\n--\n-- UTILITIES\n--\nimport qualified Data.ByteString.Char8 as C8\nimport Data.Maybe (fromJust)\n\ngetInt :: IO Int\ngetInt = read <$> getLine\n\ngetInts :: IO [Int]\ngetInts = fmap (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine\n\ngetInteger :: IO Integer\ngetInteger = read <$> getLine\n\ngetIntegers :: IO [Integer]\ngetIntegers = fmap (fst . fromJust . C8.readInteger) . C8.words <$> C8.getLine\n\n--\n-- MAIN\n--\n\nmain :: IO ()\nmain = do\n r <- getInteger\n putStrLn $ if r `mod` 2 == 0 || r < 5 then \"NO\" else \"1 \" ++ show ((r - 3) `div` 2)\n", "positive_code": [{"source_code": "main = interact $ solve . read\nsolve n | n < 5 = \"NO\"\n | odd n = \"1 \" ++ show ((n-3) `div` 2)\n | otherwise = \"NO\"\n"}], "negative_code": [{"source_code": "main = interact $ solve . read\nsolve n | n < 5 = \"-1\"\n | odd n = \"1 \" ++ show ((n-3) `div` 2)\n | otherwise = \"-1\"\n"}], "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba"} {"source_code": "readArr :: IO [Int]\r\nreadArr = (map (\\s -> read s :: Int)) <$> (words <$> getLine)\r\n\r\nfor :: Int -> IO ()\r\nfor 0 = pure ()\r\nfor i = do\r\n (a: b: _) <- readArr\r\n (c: d: _) <- readArr\r\n print $ case (a + b + c + d) of\r\n 0 -> 0\r\n 4 -> 2\r\n otherwise -> 1\r\n for $ i - 1\r\n\r\nmain :: IO ()\r\nmain = do\r\n n <- readLn :: IO Int\r\n for n", "positive_code": [{"source_code": "--\r\n-- Michael V. Antosha\r\n-- 2022\r\n-- Michael.Antosha@gmail.com\r\n--\r\n\r\n{-# language Safe #-}\r\n{-# language ImportQualifiedPost #-}\r\n{-# language NoMonomorphismRestriction #-}\r\n\r\n{-# options_ghc -O3 #-}\r\n\r\n{-# options_ghc -Weverything #-}\r\n{-# options_ghc -Werror #-}\r\n\r\n{-# options_ghc -Wno-missing-import-lists #-}\r\n{-# options_ghc -Wno-missing-local-signatures #-}\r\n\r\nimport Prelude hiding (getLine)\r\nimport Control.Arrow\r\nimport Control.Monad\r\nimport Data.ByteString.Char8 qualified as B\r\nimport Data.Char\r\nimport Data.List qualified as L\r\n\r\nri = readInts <$> B.getLine :: IO [Int]\r\n where\r\n readInts = L.unfoldr ((second dropSpace <$>) . B.readInt) . dropSpace\r\n dropSpace = B.dropWhile isSpace\r\n\r\nmain :: IO ()\r\nmain = do\r\n [t] <- ri\r\n tcs <- replicateM t (replicateM 2 ri)\r\n mapM_ (putStrLn.show.solve) tcs\r\n\r\nsolve fld = f . sum . concat $ fld\r\n where\r\n f 0 = 0 :: Int\r\n f 1 = 1\r\n f 2 = 1\r\n f 3 = 1\r\n f 4 = 2\r\n f _ = error \"Impossible input\"\r\n"}, {"source_code": "-- \n{-# LANGUAGE BlockArguments #-}\n{-# LANGUAGE DatatypeContexts #-}\n{-# LANGUAGE DeriveFunctor #-}\n{-# LANGUAGE GADTs #-}\n{-# LANGUAGE LambdaCase #-}\n{-# LANGUAGE NumericUnderscores #-}\n{-# LANGUAGE OverloadedStrings #-}\n{-# LANGUAGE Safe #-}\n{-# LANGUAGE ScopedTypeVariables #-}\n{-# LANGUAGE Strict #-}\n{-# LANGUAGE TupleSections #-}\n{-# OPTIONS_GHC -O3 -funbox-strict-fields -fvia-C -optc-O3 #-}\n\n\nimport Control.Arrow ((>>>))\nimport Control.Monad (\n MonadPlus (mplus),\n foldM_,\n forM_,\n guard,\n join,\n replicateM,\n replicateM_,\n )\nimport qualified Control.Monad as M\nimport qualified Control.Monad.ST.Strict as ST\nimport qualified Control.Monad.State.Strict as S\nimport qualified Control.Monad.Trans.Class as T\n\nimport qualified Data.Array as A\nimport qualified Data.Array.MArray.Safe as MA\nimport qualified Data.Array.IO.Safe as IOA\nimport qualified Data.Array.ST.Safe as STA\nimport qualified Data.Array.Unboxed as UA\n\nimport Data.Bits\nimport qualified Data.ByteString.Char8 as B8\nimport Data.Char\nimport Data.Int\n\nimport Data.Function (on)\nimport Data.Functor ((<&>))\nimport Data.Bifunctor (bimap)\nimport Data.Maybe (fromJust, fromMaybe, isJust)\nimport qualified Data.Maybe as MB\n\nimport qualified Data.IntMap as IM\nimport qualified Data.IntSet as IS\nimport qualified Data.List as L\nimport Data.List (\n elemIndices,\n find,\n findIndices,\n intersect,\n isPrefixOf,\n nub,\n sort,\n sortOn,\n )\nimport qualified Data.Map as M\nimport qualified Data.Set as S\nimport qualified Data.Ix as Ix\nimport qualified Data.Ratio as R\n\nimport Control.Monad.Cont (MonadIO (liftIO))\nimport Data.IORef (modifyIORef, newIORef, readIORef)\nimport GHC.IO.Handle (hDuplicateTo)\nimport System.IO (\n IOMode (ReadMode, WriteMode),\n openFile,\n stdin,\n stdout,\n hFlush\n )\nimport System.Posix.Internals (puts)\nimport Text.Printf (printf)\nimport qualified Data.Array.IO.Safe as UOA\n\n\n-- import Debug.Trace (trace, traceM, traceShowM)\n-- debug = flip trace\n--\n-- tracing t x = trace (t ++ \" = \" ++ show x) x\n-- debugging x t = tracing t x\n--\n-- debug x t = x\n-- trace t x = x\n-- tracing t x = x\n-- debugging x t = x\n\nreadIntB8 :: B8.ByteString -> Int\nreadIntB8 = B8.readInt >>> (fst . fromJust)\n\n\nreadIntB8s :: B8.ByteString -> [Int]\nreadIntB8s = B8.words >>> map (B8.readInt >>> (fst . fromJust))\n\n\nreadIntegerB8 :: B8.ByteString -> Integer\nreadIntegerB8 = B8.readInteger >>> (fst . fromJust)\n\n\nreadIntegerB8s :: B8.ByteString -> [Integer]\nreadIntegerB8s = B8.words >>> map (B8.readInteger >>> (fst . fromJust))\n\n\nmodifyArray :: (MA.MArray a e m, MA.Ix i) => a i e -> i -> (e -> e) -> m ()\nmodifyArray arr ix f = do\n value <- MA.readArray arr ix\n MA.writeArray arr ix $ f value\n\n\nputsYesNo :: Bool -> IO ()\nputsYesNo value = do\n let result :: String =\n if value\n then \"YES\"\n else \"NO\"\n printf \"%s\\n\" result\n\n{- END OF GENERAL -}\n\n\nsolve :: [[Int]] -> Int\nsolve as = case (sum . join $ as) of\n 0 -> 0\n 4 -> 2\n _ -> 1\n\nmain :: IO ()\nmain = do\n t <- B8.getLine <&> readIntB8\n replicateM_ t $ do\n as <- replicateM 2 $ B8.getLine <&> readIntB8s\n let answer = solve as\n printf \"%d\\n\" answer\n"}], "negative_code": [], "src_uid": "7336b8becd2438f0439240ee8f9610ec"} {"source_code": "process :: Int -> Int\nprocess n = 1+2*n*(n-1)\n\nreadInt :: String -> Int\nreadInt = read\n\nmain :: IO ()\nmain = do\n n <- fmap readInt getLine\n print $ process n", "positive_code": [{"source_code": "solve n = 1 + (sum $ take (n - 1) [4*i | i <- [1..]])\n\nmain = do\n n <- readLn :: IO Int\n print $ solve n\n"}, {"source_code": "main = interact $ show . solve . pred . read\nsolve n = 2*n^2 + 2*n + 1\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\n\na= scanl1 (+) $ [1]++[n*4|n<-[1..]]\n\t\t\n\nmain = do\n\t\tr<- read <$> getLine ::IO Int\n\t\tprint $ a!!(r-1)\n"}, {"source_code": "main = interact $ show . process . read\nprocess n = 1 + 2 * n * (n - 1)\n"}], "negative_code": [{"source_code": "main = interact $ show . solve . read\nsolve n = 2*n^2 + 2*n + 1\n"}], "src_uid": "758d342c1badde6d0b4db81285be780c"} {"source_code": "import Control.Monad\n\nreadInt :: IO Int\nreadInt = read <$> getLine\n\nmain :: IO ()\nmain = do\n t <- readInt\n replicateM_ t $ do\n x <- readInt\n print $ solve x\n\nsolve :: Int -> Int\nsolve x = (d - 1) * 10 + (n * (n + 1) `div` 2)\n where d = x `mod` 10\n n = length $ show x\n", "positive_code": [{"source_code": "{-# LANGUAGE Safe #-}\n\nimport Control.Arrow ((>>>))\nimport Data.List\n\nmain :: IO ()\nmain = interact $ words >>> drop 1 >>> map (read >>> solve >>> show) >>> unlines\n\nsolve :: Int -> Int\nsolve x = (+ length (show x)) . sum . map length . takeWhile (/= show x) . sort . map show $ filter boring [1 .. 10000]\n\nboring :: Int -> Bool\nboring x = or $ all <$> ((==) <$> ['1' .. '9']) <*> pure (show x)\n"}, {"source_code": "{-# LANGUAGE Safe #-}\n\nimport safe Control.Arrow ((>>>))\nimport safe Data.List (sort)\n\nmain :: IO ()\nmain = interact $ words >>> drop 1 >>> map (solve >>> show) >>> unlines\n\nsolve :: String -> Int\nsolve x = (+ length x) . sum . map length . takeWhile (/= x) . sort . filter boring $ show <$> [1 .. 10000]\n\nboring :: String -> Bool\nboring x = or $ all <$> ((==) <$> ['1' .. '9']) <*> pure x\n"}, {"source_code": "\nsolve :: Int -> Int\nsolve x = \n let l = len x in\n 10 * (x `mod` 10 - 1) + l * (l + 1) `div` 2\n where len x\n | x == 0 = 0\n | otherwise = 1 + len (x `div` 10)\n\nsolveAll :: String -> String\nsolveAll s =\n let cases = map (\\x -> read x :: Int) $ lines s in\n let sol = map solve cases in\n foldr (\\a s -> show a ++ \"\\n\" ++ s) \"\" sol\n\n\nmain = do\n n <- getLine\n interact solveAll"}, {"source_code": "import Control.Monad\n\nmain :: IO ()\nmain = do\n t <- read <$> getLine\n replicateM_ t $ do\n xs <- getLine\n let x = read [xs !! 0]\n l = length xs\n putStrLn $ show $ (x - 1) * 10 + (1 + l) * l `div` 2\n"}, {"source_code": "smallerDigitPresses :: Int -> Int\nsmallerDigitPresses n = 10 * (n - 1)\n\nsameDigitPresses :: Int -> Int\nsameDigitPresses n = n * (n+1) `div` 2\n\nkeyPresses :: String -> String\nkeyPresses x =\n show $ smallerDigits + currentDigit\n where\n smallerDigits = smallerDigitPresses (read (take 1 x) :: Int)\n currentDigit = sameDigitPresses (length x)\n\nmain :: IO ()\nmain = do\n _ <- getLine -- discard number of tests\n interact $ unlines . map keyPresses . lines"}, {"source_code": "import Control.Monad\nimport Data.Char\n\nmain :: IO ()\nmain = do\n t <- read <$> getLine\n replicateM_ t $ do\n x <- getLine\n let\n i = ord (head x) - ord '0'\n q = length x\n print $ 10 * i + ([-9, -7, -4, 0] !! (q-1))\n"}], "negative_code": [], "src_uid": "289a55128be89bb86a002d218d31b57f"} {"source_code": "import Data.Char\nmain = do\n\ts <- getLine\n\tputStrLn $ if length s >= 5 && any isLower s && any isUpper s && any isDigit s then \"Correct\" else \"Too weak\"\n\t", "positive_code": [{"source_code": "import Data.Char\nf s = let g s = length s >= 5 && sL /= [] && bL /= [] && dL /= []\n where sL = filter isLower s\n bL = filter isUpper s\n dL = filter isDigit s\n in case g s of\n True -> \"Correct\"\n False -> \"Too weak\"\nmain = do\n s <- getLine\n putStrLn $ f s"}, {"source_code": "import Data.Char\ncheck s = if length s >= 5 then ((not . null) $ filter (isUpper) s) && ((not . null) $ filter (isLower) s) && ((not . null) $ filter (isDigit) s) else False\nmain:: IO ()\nmain = do\n line <- getLine\n if check(line) then\n putStrLn \"Correct\" else \n putStrLn \"Too weak\"\n"}, {"source_code": "goodPassword :: String -> Bool\n\ngoodPassword password =\n (length password) > 5 && and (map hasElemIn [['A'..'Z'], ['a'..'z'], ['0'..'9']])\n where hasElemIn xs = or (map (`elem` xs) password)\n\njudgePassword password\n | goodPassword password = \"Correct\"\n | otherwise = \"Too weak\"\n \nmain = do\n password <- getContents\n putStrLn (judgePassword password)\n"}, {"source_code": "-- @betaveros :: vim:set fdm=marker:\n{-# LANGUAGE LambdaCase, NPlusKPatterns, TupleSections #-}\n{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-missing-signatures #-}\n-- import ALL the things! {{{\nimport Control.Applicative\nimport Control.Arrow\nimport Control.Exception\nimport Control.Monad\nimport Control.Monad.ST\n\nimport Data.Bits\nimport Data.Char\nimport Data.Either\nimport Data.Function\nimport Data.IORef\nimport Data.List\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.STRef\nimport Data.String\nimport Data.Tuple\n\nimport qualified Data.Map as Map\nimport Data.Map (Map)\nimport qualified Data.Set as Set\nimport Data.Set (Set)\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq, (<|), (|>), (><))\n\nimport Debug.Trace\nimport Text.Printf\n-- }}}\n-- silly utilities {{{\n(#) = flip ($)\ninfixl 0 #\n\nglength :: (Num b) => [a] -> b\nglength = genericLength\n\nreadInt = read :: String -> Int\nreadInteger = read :: String -> Integer\n-- (!?) :: (Ord k) => Map k v -> k -> Maybe v\n-- (!?) = flip Map.lookup\nhistogram :: (Ord a, Num b) => [a] -> Map a b\nhistogram = Map.fromListWith (+) . map (,1)\n\n(!>) :: Seq a -> Int -> a\n(!>) = Seq.index\n-- }}}\n-- input and output {{{\ninputInt = (read <$> getLine) :: IO Int\ninputInteger = (read <$> getLine) :: IO Integer\ninputDouble = (read <$> getLine) :: IO Double\n\ninputRow :: (Read a) => IO [a]\ninputRow = map read . words <$> getLine\ninputInts = inputRow :: IO [Int]\ninputIntegers = inputRow :: IO [Integer]\ninputDoubles = inputRow :: IO [Double]\n-- }}}\n\nisStrong s = length s >= 5 && any isUpper s && any isLower s && any isDigit s\n\nmain :: IO ()\nmain = do\n\ts <- getLine\n\tputStrLn $ if isStrong s then \"Correct\" else \"Too weak\"\n"}, {"source_code": "import qualified Data.Char as C\ntype Letter = Char\n\nsmallLetter :: [Letter]\nsmallLetter = \"abcdefghijklmnopqrstuvwxyz\"\n\nlargeLetter :: [Letter]\nlargeLetter = map C.toUpper smallLetter\n\ngetChar :: [Letter] -> Char\ngetChar l = l !! 0\n\ndigits :: [Letter]\ndigits = map (Main.getChar . show) [0..9]\n\ncontain :: [Letter] -> [Letter] -> Bool\ncontain [] _ = False\ncontain _ [] = True\ncontain w s = (head w) `elem` s || contain (tail w) s\n\n \n-- word -> length -> \ngoodPassword :: [Letter] -> Bool\ngoodPassword s = ((length s) >= 5) && (contain s smallLetter) && (contain s largeLetter) && (contain s digits)\n\n\nwriteAnswer :: Bool -> String\nwriteAnswer cond = if cond\n then \"Correct\"\n else \"Too weak\"\n\n\n\n\nmain :: IO()\nmain = do\n w <- getLine\n putStrLn . writeAnswer . goodPassword $ w\n\n"}, {"source_code": "main = do interact f\nf :: String -> String\nf s = if length s > 5 && hasAny ['A'..'Z'] s && hasAny ['a'..'z'] s && hasAny ['0'..'9'] s then \"Correct\" else \"Too weak\"\n where hasAny a b = any (`elem` a) b"}, {"source_code": "import Data.Char\n\nmain = do password <- getLine\n if good password then putStrLn \"Correct\"\n else putStrLn \"Too weak\"\n\ngood password = length password >= 5 &&\n any isUpper password &&\n any isLower password &&\n any isDigit password"}, {"source_code": "module Main where\n\nimport Data.List (intersect)\n\nweak :: String\nweak = \"Too weak\"\n\ncorrect :: String\ncorrect = \"Correct\"\n\nisStrong :: String -> Bool\nisStrong s | length s < 5 = False\nisStrong s | null $ intersect s ['a'..'z'] = False\nisStrong s | null $ intersect s ['A'..'Z'] = False\nisStrong s | null $ intersect s ['0'..'9'] = False\nisStrong _ = True\n\nmain :: IO ()\nmain = do\n password <- getLine\n if isStrong password\n then putStrLn correct\n else putStrLn weak\n"}, {"source_code": "import Data.List\nimport Data.Function\nimport Data.Char\nimport Control.Monad\n\nmain = interact $ getAns . and . sequence [(\\x -> length x > 5), (any isDigit), (any isUpper), (any isLower)]\n\ngetAns x = if x then \"Correct\\n\" else \"Too weak\\n\"\n"}, {"source_code": "correct :: String -> Bool\ncorrect s = length s >= 5 && contains ['A'..'Z'] s && contains ['a'..'z'] s && contains ['0'..'9'] s\n\ncontains :: (Eq a) => [a] -> [a] -> Bool\ncontains [] lst = False\ncontains (x:xs) lst = if x `elem` lst then True \n else contains xs lst\n\nmain = getLine >>= (\\s -> if correct s then putStrLn \"Correct\" else putStrLn \"Too weak\")\n"}], "negative_code": [{"source_code": "import Data.Char\ncheck s = if length s > 5 then ((not . null) $ filter (isUpper) s) && ((not . null) $ filter (isLower) s) && ((not . null) $ filter (isDigit) s) else False\nmain:: IO ()\nmain = do\n line <- getLine\n if check(line) then\n putStrLn \"Correct\" else \n putStrLn \"Too weak\"\n"}, {"source_code": "main = do interact f\nf :: String -> String\nf s = if length s >= 5 && hasAny ['A'..'Z'] s && hasAny ['a'..'z'] s && hasAny ['0'..'9'] s then \"Correct\" else \"Too weak\"\n where hasAny a b = any (`elem` a) b"}, {"source_code": "import Data.Char\nf s = let g s = length s > 5 && q /= [] && q /= s\n where q = filter isLower s\n in case g s of\n True -> \"Correct\"\n False -> \"Too weak\"\nmain = do\n s <- getLine\n putStrLn $ f s"}, {"source_code": "import Data.Char\nf s = let g s = length s > 5 && sL /= [] && bL /= [] && dL /= []\n where sL = filter isLower s\n bL = filter isUpper s\n dL = filter isDigit s\n in case g s of\n True -> \"Correct\"\n False -> \"Too weak\"\nmain = do\n s <- getLine\n putStrLn $ f s"}], "src_uid": "42a964b01e269491975965860ec92be7"} {"source_code": "import Text.Printf\n\nmain = do\n (a : b : _) <- (fmap words $ getLine)\n let aux = (a!!0) : (takeWhile (<(b!!0)) $ tail a)\n printf $ aux ++ [b!!0] ++ \"\\n\"\n", "positive_code": [{"source_code": "main = do\n input <- getContents\n putStrLn (solve (words input))\n\nsolve ((a:as):(b:bs):_) = [a] ++ (takeWhile ( getLine\n putStrLn . minimum $ [a ++ b | a <- (tail . inits $ as)\n , b <- (tail . inits $ bs)]\n"}, {"source_code": "main = getLine >>= putStrLn . solve . words\n\nsolve ((a:as):(b:bs):_) = a:(takeWhile (), (<|), (><))\nimport qualified Data.Sequence as S\n\nmain = interact $ unlines . sol . (map words) . lines\n\nsol [[fn, sn]] = wrap $ minimum $ [ a++b | a <- prefs fn, b<-prefs sn]\n\n\n\nprefs x = map reverse $ suffs $ reverse x\nsuffs [] = []\nsuffs v@(_:xs) = v : suffs xs\n\n--------------------------------------------------------------------------------\ngroupOn :: Int -> [a] -> [[a]]\ngroupOn _ [] = []\ngroupOn n xs = let (sts, nds) = splitAt n xs in sts : groupOn n nds\n\nfromBool :: Num a => Bool -> a\nfromBool b = if b then 1 else 0\n\nallInt :: [String] -> [[Int]]\nallInt = map ((map read) . words)\n\nswrt :: Ord a => (a, a) -> (a, a)\nswrt (a, b) | compare b a == LT = (b, a) | otherwise = (a, b)\n\nwrap :: a -> [a]\nwrap x = [x]\n\ntoSnd :: a->b-> (a,b)\ntoSnd x y = (x,y)\n\ntoFst :: b->a-> (a,b)\ntoFst y x = (x,y)\n\naddCnt :: [String] -> [String]\naddCnt ls = (show $ length ls) : ls\n\ntoBitMap :: Int -> [(Int, Bool)]\ntoBitMap = toBitMap' 31\n where\n toBitMap' (-1) _ = []\n toBitMap' n v = (n, v .&. (1`shiftL`n) > 0) : toBitMap' (n-1) v\n--------------------------------------------------------------------------------\npattern Empty <- (S.viewl -> S.EmptyL)\npattern x :< xs <- (S.viewl -> x S.:< xs)\npattern xs :> x <- (S.viewr -> xs S.:> x)\n--------------------------------------------------------------------------------\n"}, {"source_code": "import Data.Char (ord)\n\nmain = do\n [h1 : s1, h2 : _] <- fmap words getLine\n putStrLn $ h1 : takeWhile (\\ x -> ord x < ord h2) s1 ++ [h2]"}, {"source_code": "import Control.Monad\nimport Data.List\nmain = getLine >>= putStr . minimum . (\\[a, b] -> liftM2 (++) (tail $ inits a) (tail $ inits b)) . words"}], "negative_code": [{"source_code": "main = do\n (a : b : _) <- (fmap words $ getLine)\n let aux = (a!!0) : (takeWhile (<(b!!0)) $ tail a)\n print $ aux ++ [b!!0]\n"}], "src_uid": "aed892f2bda10b6aee10dcb834a63709"} {"source_code": "{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Data.List\nimport Data.Maybe\nimport Data.Char\nimport Data.Array.IArray\nimport Data.Array.Unboxed (UArray)\nimport Data.Int\nimport Data.Ratio\nimport Data.Bits\nimport Data.Function\nimport Data.Ord\n--import Control.Monad.State\nimport Control.Monad\nimport Control.Applicative\nimport Data.ByteString.Char8 (ByteString)\nimport qualified Data.ByteString.Char8 as BS\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.Map (Map)\nimport qualified Data.Map as Map\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\nimport Data.Sequence (Seq, (<|), (|>), (><), ViewL(..), ViewR(..))\nimport qualified Data.Sequence as Seq\nimport qualified Data.Foldable as F\nimport Data.Graph\n\nparseInput = do \n moves <- BS.unpack <$> readString\n k <- readInt\n return (moves, k)\n where\n readInt = state $ fromJust . BS.readInt . BS.dropWhile isSpace\n readInteger = state $ fromJust . BS.readInteger . BS.dropWhile isSpace\n readString = state $ BS.span (not . isSpace) . BS.dropWhile isSpace\n readLine = state $ BS.span (not . isEoln) . BS.dropWhile isEoln\n isEoln ch = ch == '\\r' || ch == '\\n'\n\nmain = print =<< solve . evalState parseInput <$> BS.getContents\n\naddInterval (a, b) (c, d) = (min a c, max b d)\nnonInterval = (inf, -inf)\ninf = 10^9\n\nsolve (moves', k) = max (-ansMin) ansMax\n where\n n = length moves'\n moves = listArray (0, n - 1) moves' :: UArray Int Char\n\n (ansMin, ansMax) = turtle (0, k, True)\n\n turtle :: (Int, Int, Bool) -> (Int, Int)\n turtle (pos, rem, dir) | rem < 0 = nonInterval\n | otherwise = cache ! (pos, rem, dir)\n where\n bnds = ((0, 0, False), (n, k, True))\n cache = listArray bnds $ map go $ range bnds :: Array (Int, Int, Bool) (Int, Int)\n\n go (pos, rem, dir) | pos == n = if even rem then (0, 0) else nonInterval\n go (pos, rem, dir) = movesF `addInterval` movesT\n where\n pdir = (moves ! pos) == 'F'\n\n movesF | dir = (minv + 1, maxv + 1)\n | otherwise = (minv - 1, maxv - 1)\n where\n (minv, maxv) = turtle (pos + 1, rem - (if pdir then 0 else 1), dir) \n \n movesT = turtle (pos + 1, rem - (if pdir then 1 else 0), not dir)\n\n----------------------------------------------------------------------\n----------------------------------------------------------------------\n----------------------------------------------------------------------\n\nclass (Monad m) => MonadState s m | m -> s where\n\tget :: m s\n\tput :: s -> m ()\n\nmodify :: (MonadState s m) => (s -> s) -> m ()\nmodify f = do\n\ts <- get\n\tput (f s)\n\ngets :: (MonadState s m) => (s -> a) -> m a\ngets f = do\n\ts <- get\n\treturn (f s)\n\nnewtype State s a = State { runState :: s -> (a, s) }\n\ninstance Functor (State s) where\n\tfmap f m = State $ \\s -> let\n\t\t(a, s') = runState m s\n\t\tin (f a, s')\n\ninstance Applicative (State s) where\n pure = return\n (<*>) = ap\n\ninstance Monad (State s) where\n\treturn a = State $ \\s -> (a, s)\n\tm >>= k = State $ \\s -> let\n\t\t(a, s') = runState m s\n\t\tin runState (k a) s'\n\ninstance MonadState s (State s) where\n\tget = State $ \\s -> (s, s)\n\tput s = State $ \\_ -> ((), s)\n\nevalState :: State s a -> s -> a\nevalState m s = fst (runState m s)\n\nexecState :: State s a -> s -> s\nexecState m s = snd (runState m s)\n\nmapState :: ((a, s) -> (b, s)) -> State s a -> State s b\nmapState f m = State $ f . runState m\n\nwithState :: (s -> s) -> State s a -> State s a\nwithState f m = State $ runState m . f\n\nstate = State\n", "positive_code": [{"source_code": "module Main where\n\nimport Data.Array\n\nmain = interact (solve . lines)\n\nsolve :: [String] -> String\n--solve [prog, n'] = unlines [show [dyn ! (k, l) | l <- [0..len]] | k <- [0..n]] where\nsolve [prog, n'] = show result where\n result = max (abs $ fst bestTuple) (abs $ snd bestTuple)\n bestTuple = foldl1 best [dyn ! (k, 0) | k <- [0, 2..n]]\n dyn = array cells [(x, distance x) | x <- range cells]\n cells = ((0, 0), (n, len))\n n = read n'\n len = length prog\n\n distance (k, l)\n | l == len = if k == n then (0, 0) else (10000, -10000)\n | k == n = effect (prog !! l) (dyn ! (k, l + 1))\n | otherwise = best\n (effect (prog !! l) (dyn ! (k, l + 1)))\n (effect (rev $ prog !! l) (dyn ! (k + 1, l + 1)))\n\neffect 'T' (a, b) = (-b, -a)\neffect 'F' (a, b) = (a + 1, b + 1)\n\nrev 'F' = 'T'\nrev 'T' = 'F'\n\nbest :: (Int, Int) -> (Int, Int) -> (Int, Int)\nbest (a, b) (c, d) = (min a c, max b d)\n\n-- distance :: (Int, Int) -> (Int, Int)\n"}], "negative_code": [], "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d"} {"source_code": "\nmain :: IO ()\nmain = do\n ln <- getLine\n let (a:b:c:_) = scanall ln in putStrLn (show (ans a b c))\n\nans :: Integral i => i -> i -> i -> i\nans a b c\n | a + b <= c = p c a b\n | a + c <= b = p b a c\n | b + c <= a = p a b c\n | otherwise = 0\n where p x y z = 1 + (x - (y + z))\n\nscanall :: Read a => String -> [a]\nscanall s = [read x | x <- split ' ' s]\n\nsplit :: Char -> String -> [String]\nsplit c \"\" = []\nsplit c s = a : split c b where (a, b) = splitfirst c s\n\nsplitfirst :: Char -> String -> (String, String)\nsplitfirst c \"\" = (\"\", \"\")\nsplitfirst c (x:xs)\n | c == x = (\"\", xs)\n | otherwise = (x : a, b)\n where (a, b) = splitfirst c xs\n", "positive_code": [{"source_code": "import Control.Applicative\nimport Data.List\n\nmain = do\n [a,b,c] <- map read . words <$> getLine :: IO [Int]\n\n let t = [(i,j,k) | i<-[1..200], j<-[1..200], k<-[1..200], i+j>k, i+k>j, j+k>i]\n\n print $ minimum [(abs $ i-a) + (abs $ j-b) + (abs $ k-c) | (i,j,k) <- t]\n \n"}, {"source_code": "--Codeforces 10640\n\nisTriangle :: Int -> Int -> Int -> Bool\nisTriangle a b c = (a + b) > c && abs(a - b) < c\n\nmakeTriangle :: Int -> Int -> Int -> Int\nmakeTriangle a b c\n | isTriangle a b c = 0\n | otherwise = 2 * maximum [a, b, c] + 1 - sum [a, b, c]\n\nmain :: IO ()\nmain = do\n input <- getLine\n let [a, b, c] = map (read :: String -> Int) (words input)\n print (makeTriangle a b c)\n"}, {"source_code": "import Data.List\n \nmain =do\n e<-getLine\n let (a:b:c:[])=sort $ map read (words e)::[Int]\n print $ if c-b>= print . solve . sort . map read . words\n\nsolve (a:b:c:_) = max 0 (c - b - a + 1)\n"}, {"source_code": "import Control.Applicative\nimport Control.Monad\nimport Data.List\nimport Data.Maybe\nimport Data.Array\n\nprocess n | x>0 = 0\n | otherwise = 1-x\n\twhere x =( sum n)- 2*maximum n\n\n\nmain = do\n\tn <- map read <$> words <$> getLine ::IO [Int]\n\tprint $ process n\n"}, {"source_code": "--ghc 7.10\n\nmakeTriangle :: Int -> Int -> Int -> Int\nmakeTriangle a b c\n | d < 0 = 0\n | otherwise = d+1\n where\n maxSide = max a (max b c)\n d = 2 * maxSide - (a + b + c)\n\nmain = do\n abcStr <- getLine\n let [a,b,c] = map read . words $ abcStr\n print $ makeTriangle a b c"}], "negative_code": [], "src_uid": "3dc56bc08606a39dd9ca40a43c452f09"} {"source_code": "\nimport Control.Monad\nimport Control.Applicative\nimport Data.List\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Data.Array\n\nreadInt :: IO Integer\nreadInt = read <$> getLine\nreadIntList :: IO [Integer]\nreadIntList = fmap read . words <$> getLine\nreadIntArray :: Integer -> IO (Array Integer Integer)\nreadIntArray n = listArray (0, n-1) <$> readIntList\nreadSortedIntArray :: Integer -> IO (Array Integer Integer)\nreadSortedIntArray n = listArray (0, n-1) . sort <$> readIntList\n\nmain :: IO ()\nmain = do\n [c, d] <- readIntList\n [n, m] <- readIntList\n [k] <- readIntList\n putStrLn . show $ minimum $ flip fmap [0..1000] $ \\i -> i * c + (max 0 $ n * m - i * n - k) * d", "positive_code": [{"source_code": "import Control.Applicative\n\nreadInts :: IO [Int]\nreadInts = map read . words <$> getLine\n\nmain = do\n [c, d] <- readInts\n [n, m] <- readInts\n k <- readLn\n let\n f x y = c * x + d * y\n c1 = f ((n*m-k+n-1) `div` n) 0\n c2 = f ((n*m-k) `div` n) (((-k) `mod` n + n) `mod` n)\n c3 = f 0 (n*m-k)\n in putStrLn . show $ max (minimum [c1, c2, c3]) 0\n"}, {"source_code": "main = interact $ show . max 0 . f . map read . words\nf [c, d, n, m, k] = minimum [let (x, y) = divMod (n * m - k) n in x * c + y * d, d * (n * m - k), div (n * m - k + n - 1) n * c]"}, {"source_code": "import Data.List\n\nsolve c d n m k =\n case nums of\n [] -> 0\n _ -> minimum nums\n where f (a,b) = a*c+b*d\n end = m + ((n-1-k) `div` n)\n nums = map f [ (a,b) | a <- [0..end], let b = max 0 (n*m-k-n*a) ]\n\nmain = do\n (c:d:_) <- fmap (map read . words) getLine\n (n:m:_) <- fmap (map read . words) getLine\n k <- fmap read getLine\n print $ solve c d n m k \n \n"}], "negative_code": [{"source_code": "main = interact $ show . f . map read . words\nf [c, d, n, m, k] = minimum [let (x, y) = divMod (n * m - k) n in x * c + y * d, d * (n * m - k), div (n * m - k + n - 1) n * c]"}, {"source_code": "import Control.Applicative\n\nreadInts :: IO [Int]\nreadInts = map read . words <$> getLine\n\nmain = do\n [c, d] <- readInts\n [n, m] <- readInts\n k <- readLn\n let\n f x y = c * x + d * y\n c1 = f ((n*m-k+n-1) `div` n) 0\n c2 = f ((n*m-k) `div` n) (((-k) `mod` n + n) `mod` n)\n c3 = f 0 (n*m-k)\n in putStrLn . show $ minimum [c1, c2, c3]\n"}, {"source_code": "import Control.Applicative\n\nreadInts :: IO [Int]\nreadInts = map read . words <$> getLine\n\nmain = do\n [c, d] <- readInts\n [n, m] <- readInts\n k <- readLn\n let\n binarySearch lb ub\n | ub-lb > 1 = if can mid then binarySearch lb mid else binarySearch mid ub\n | otherwise = ub\n where mid = (lb+ub) `div` 2\n value z = if n*d > c then n*d*z+k*c*d else c*z+k*c*d\n can z = value z >= n * m * c * d\n in putStrLn . show $ binarySearch (-1) 1000000\n"}], "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb"} {"source_code": "solve :: (Integer, Integer, Integer) -> Integer\nsolve (both, top, bottom)\n | ((both `mod` 2) == 0) = case (top `mod` 2, bottom `mod` 2) of\n (0, 0) -> 0\n (1, 1) -> 1\n (0, 1) -> -1\n (1, 0) -> -1\n | otherwise = case (top `mod` 2, bottom `mod` 2) of\n (1, 1) -> 0\n (0, 1) -> -1\n (1, 0) -> -1\n (0, 0) -> if (top + bottom) > 0 then 1 else -1\n\ncalc :: [String] -> (Integer, Integer, Integer)\ncalc [] = (0, 0, 0)\ncalc (x:xs) = case (top `mod` 2, bottom `mod` 2) of\n (0, 0) -> (pboth, ptop, pbottom)\n (0, 1) -> (pboth, ptop, pbottom+1)\n (1, 0) -> (pboth, ptop+1, pbottom)\n (1, 1) -> (pboth+1, ptop, pbottom)\n where\n (pboth, ptop, pbottom) = calc xs\n [top, bottom] = map read $ words x\n\nget :: Integer -> IO [String]\nget 0 = return []\nget n = do\n s <- getLine\n ls <- get (n-1)\n return $ s : ls\n\nmain = do\n n <- getLine\n a <- get (read n)\n print $ solve (calc a)\n", "positive_code": [{"source_code": "import Control.Applicative\nimport Control.Monad\nimport Control.Arrow\nimport Data.List\nimport Data.Char\nimport Text.Printf\n\nmain = do\n\tn <- readLn\n\tps <- replicateM n $ do\n\t\t[ a, b ] <- map read . words <$> getLine\n\t\treturn ( a, b )\n\tprint $ solve ps\n\nsolve ps\n\t| sum1 `mod` 2 == 0 && sum2 `mod` 2 == 0 = 0\n\t| sum1 `mod` 2 == 1 && sum2 `mod` 2 == 1 =\n\t\tif any ( uncurry (&&) . ( even *** odd ) ) ps || any ( uncurry (&&) . ( odd *** even ) ) ps\n\t\t\tthen 1\n\t\t\telse -1\n\t| otherwise = -1\n\t\twhere\n\t\t\tsum1 = sum . map fst $ ps\n\t\t\tsum2 = sum . map snd $ ps\n"}, {"source_code": "import Data.Functor\nimport Control.Monad\n\nmain = do\n n <- read <$> getLine :: IO Int\n ls <- replicateM n ((map read) <$> (words <$> getLine)) :: IO [[Int]]\n putStrLn (show (solve n ls))\n return ()\n\nsolve n ds \n | even (sum (map fst ds')) && even (sum (map snd ds')) = 0\n | odd (sum (map fst ds')) && odd (sum (map snd ds')) && any (\\(x,y) -> odd (x+y)) ds' = 1\n | otherwise = -1\n where \n ds' = map (\\(x:y:_) -> (x,y)) ds\n"}, {"source_code": "{-# LANGUAGE MultiParamTypeClasses,FlexibleContexts,FlexibleInstances,TypeSynonymInstances,BangPatterns,RankNTypes #-}\n\nimport Control.Monad\nimport Control.Monad.ST\nimport Control.Applicative\nimport Control.Arrow\nimport Debug.Trace\n\nimport Data.List\nimport Data.Int\nimport Data.Maybe\nimport Data.Array.Unboxed\nimport Data.Array.ST\nimport qualified Data.Map as M\nimport qualified Data.Set as S\nimport qualified Data.ByteString.Char8 as B\n\nreadInt = B.readInt >>> fmap fst >>> fromMaybe 0\nreadsInt = map readInt . B.words <$> B.getLine\nreadLine :: Read a => IO a\nreadLine = read <$> getLine \nreadsLine :: Read a => IO [a]\nreadsLine = map read . words <$> getLine\n\ncmpFst (a,_) (b,_) = compare a b\ncmpSnd (_,a) (_,b) = compare a b\ncmpLen a b = length a `compare` length b\n\nswap (a,b) = (b,a)\nrect a b = rect2 0 0 a b\nrect2 i j a b = ((i,j),(a,b))\n\nitof :: Int -> Double\nitof = fromIntegral\ncasti = fromIntegral\n\nmaximize f l = snd $ maximumBy cmpFst [(f x,x) | x <- l]\nminimize f l = snd $ minimumBy cmpFst [(f x,x) | x <- l]\n\ninfixr 2 <||> \ninfixr 3 <&&>\np1 <||> p2 = (p1 &&& p2) >>> uncurry (||)\np1 <&&> p2 = (p1 &&& p2) >>> uncurry (&&)\n\nxor True True = False\nxor a b = a || b\n\nmain = do\n n <- readLn\n l <- replicateM n ((\\[x,y] -> (odd x,odd y)) <$> readsLine)\n let (lu,ll) = unzip l\n case (foldl1 xor lu,foldl1 xor ll) of\n (False,False) -> print 0\n (True,False) -> print (-1)\n (False,True) -> print (-1)\n (True,True) -> case find (uncurry xor) l of\n Just _ -> print 1\n Nothing -> print (-1)\n"}, {"source_code": "\nimport Control.Monad (liftM, replicateM)\nimport Data.Char (ord)\nimport Prelude hiding (reads)\n\nreads :: Num a => IO [a]\nreads = liftM (Prelude.map read . words) getLine\n where\n read ('-':s) = (-1) * read s\n read s = read' 0 s\n read' a \"\" = a\n read' a (c:s) = read' (10 * a + fromIntegral (ord c - ord '0')) s\n\nreadTuple :: Num a => IO (a, a)\nreadTuple = do\n [a, b] <- reads\n return (a, b)\n\nsolve :: [(Int, Int)] -> Int\nsolve [(a, b)]\n | even a && even b = 0\n | otherwise = -1\nsolve ds\n | even up && even down = 0\n | odd up && odd down && findOddSum = 1\n | otherwise = -1\n where\n up = sum $ map fst ds\n down = sum $ map snd ds\n findOddSum = any (odd . uncurry (+)) ds\n\nmain :: IO ()\nmain = do\n n <- readLn\n ds <- replicateM n readTuple\n print $ solve ds"}, {"source_code": "import Data.List (group, transpose)\n\nmain :: IO ()\nmain = getContents >>= print . solve . map (map read . words) . tail . lines\n\nsolve :: [[Int]] -> Int\nsolve xys = case (map (even . sum) (transpose xys), length (filter ((>1) . length . group . map even) xys ) > 1) of\n ([ True, True ], _) -> 0\n ([ False, False ], True) -> 1\n _ -> -1\n"}, {"source_code": "import Data.List (group, transpose)\n\nmain :: IO ()\nmain = getContents >>= print . solve . map (map read . words) . tail . lines\n\nsolve :: [[Int]] -> Int\nsolve xys | all even (map sum (transpose xys)) = 0\n | length (group (map (even . sum) (transpose xys))) == 1 && length (filter ((>1) . length . group . map even) xys ) > 1 = 1\n | otherwise = -1\n"}, {"source_code": "main=interact$show.f.parse.map read.tail.words\nparse (x:y:xys) = (x,y):parse xys\nparse _ = []\n\nf xys\n | p xys = 0\n | any (p.swap xys) [1..100] = 1\n | otherwise = -1\n\nswap xys i\n | (xys0,(x,y):xys1) <- splitAt (i-1) xys = xys0 ++ (y,x) : xys1\n | otherwise = xys\n\np xys = even (sum xs) && even (sum ys)\n where\n (xs,ys) = unzip xys\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \n\n \n\n\nmain= do\n\ts<- getLine \n\t[a1,a2]<- transpose. map (map read). map words.lines <$> getContents::IO [[Int]]\n\tlet s1 = sum a1\n\tlet s2 = sum a2\n\tprint $ if even s1 && even s2 then 0 \n else if odd (s1+s2) then -1 \n else if length (take 1 (filter odd (zipWith (+) a1 a2))) ==1 then 1 \n\t\t\t\t\t\t\t\t\t\t\t\t\t\telse -1\n\t"}, {"source_code": "module Main where\n---------------------Import--------------------------- {{{\nimport Data.List\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Data.Char\nimport System.IO\nimport Data.Ratio -- x = 5%6\nimport Data.Bits -- (.&.), (.|.), shiftL...\nimport Text.Printf -- printf \"%0.6f\" (1.0)\nimport qualified Data.ByteString.Char8 as BS-- }}}\n\n---------------------Input---------------------------- {{{\ngetInteger = (\\(Just (x,_)) -> x). BS.readInteger\ngetInt = (\\(Just (x,_)) -> x). BS.readInt\n\ngetIntArray = readIntArray\ngetIntegerArray = readIntegerArray\n\nreadIntArray input = \n case x of\n Just (a, xs) -> a : readIntArray xs\n Nothing -> []\n where\n x = BS.readInt. BS.dropWhile isSpace $ input \n\nreadIntegerArray input = \n case x of\n Nothing -> []\n Just (y, ys) -> y : readIntegerArray ys\n where\n x = BS.readInteger. BS.dropWhile isSpace $ input\n------------------------------------------------------ }}}\n\nparse [] = []\nparse (x:y:xxs) = (x, y): parse xxs\n\nmain :: IO ()\nmain = BS.getContents >>= print. solve. parse. tail. readIntArray\n\n--solve :: [(Int, Int)] -> Bool\nsolve arr = \n let\n oddPair = not. null. filter (\\(x, y) -> odd x && odd y) $ arr\n (xs, ys) = foldl' (\\(acx, acy) (x, y) -> (acx+x, acy+y)) (0, 0) arr\n p1 = not. null. filter (\\(x, y) -> even (xs - x + y) && even (ys - y+x) ) $ arr\n in\n if even xs && even ys\n then 0\n else if p1\n then 1\n else (-1)\n"}, {"source_code": "module Main where\n\nmain = do\n n <- getLine\n x <- fmap (map ((\\[a,b] ->(a,b)) . take 2 . map read . words) . lines) getContents\n print $ rush x\n\nrush :: [(Int,Int)] -> Int\nrush xs\n | odd (ls + rs) = -1\n | even rs = 0\n | otherwise = if exists xs then 1 else -1\n where (l, r) = unzip xs\n ls = sum l\n rs = sum r\n exists [] = False\n exists ((x,y):r)\n | (even x && odd y) || (odd x && even y) = True\n | otherwise = exists r\n \n"}], "negative_code": [{"source_code": "import Data.Functor\nimport Control.Monad\n\nmain = do\n n <- read <$> getLine :: IO Int\n ls <- replicateM n ((map read) <$> (words <$> getLine)) :: IO [[Int]]\n putStrLn (show (solve n ls))\n return ()\n\nsolve n ds \n | c1 = 0\n | c2 = 1\n | otherwise = -1\n where c1 = (even (sum (map fst ds'))) && (even (sum (map snd ds')))\n c2 = any (\\(x,y) -> odd (x+y)) ds' && 1 (x,y)) ds\n"}, {"source_code": "import Data.Functor\nimport Control.Monad\n\nmain = do\n n <- read <$> getLine :: IO Int\n ls <- replicateM n ((map read) <$> (words <$> getLine)) :: IO [[Int]]\n putStrLn (show (solve ls))\n return ()\n\nsolve ds \n | c1 = 0\n | c2 = 1\n | otherwise = -1\n where c1 = (even (sum (map fst ds'))) && (even (sum (map snd ds')))\n c2 = any (\\(x,y) -> odd (x+y)) ds'\n ds' = map (\\(x:y:_) -> (x,y)) ds\n"}, {"source_code": "import Data.List (group, transpose)\n\nmain :: IO ()\nmain = getContents >>= print . solve . map (map read . words) . tail . lines\n\nsolve :: [[Int]] -> Int\nsolve xys | all even (map sum (transpose xys)) = 0\n | length (filter ((>1) . length . group . map even) xys ) > 1 = 1\n | otherwise = -1\n"}, {"source_code": "main=interact$show.f.parse.map read.tail.words\nparse (x:y:xys) = (x,y):parse xys\nparse _ = []\nf xys\n | even (sum xs) && even (sum ys) = 0\n | (_:_:_)<-filter (\\(x,y)->odd(x+y)) xys = 1\n | otherwise = -1\n where\n (xs,ys) = unzip xys\n"}], "src_uid": "f9bc04aed2b84c7dd288749ac264bb43"} {"source_code": "main = do\n [n, k] <- fmap (map read . words) getLine\n\n print $ if k <= (n+1) `div` 2 then 2*(k-1)+1 else 2*(k - (n+1)`div`2)\n", "positive_code": [{"source_code": "import Data.List\nimport Data.Maybe\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ show.solve.map read.words.head . lines\nsolve :: [Integer]->Integer\nsolve [x,y] = let z= ceiling (fromIntegral x/ 2) in if y <=z then 2*y-1 else 2*(y - z)"}, {"source_code": "import Control.Applicative\n\nmain = do\n [n,i] <- map read.words <$> getLine :: IO [Integer]\n putStrLn.show $ index n i\n\nindex n i\n | i <= div (n+1) 2 = 2*i-1\n | otherwise = (i- div (n+1) 2) * 2"}, {"source_code": "import Control.Applicative\n\nmain = do\n [n,k] <- map read . words <$> getLine :: IO [Integer]\n let d = n `div` 2 + fromIntegral (fromEnum (rem n 2 == 1))\n print $ if k > d then 2*(k-d) else 2*(k-1)+1"}, {"source_code": "{-# LANGUAGE PatternGuards #-}\n\nimport Control.Concurrent\nimport Control.Monad\nimport System.IO\nimport Text.Printf\nimport System.Environment\n\n \nmain = subMain\n \nsolve n k = if (k > midn) then 2*(k - midn) else 2*k-1 where\n\t\tmidn = if (nm2 == 0) then n2 else n2 + 1\n\t\tnm2 = mod n 2\n\t\tn2 = div n 2\n\nsubMain = do\n numsStr <- getLine\n let [n, k] = map (read :: String -> Integer) $ words numsStr\n print $ solve n k\n \n\n---------------\n-----------------------------------------------------------------------------\n"}, {"source_code": "import Control.Monad\nimport Data.Array\nimport Data.Char\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\n-- import qualified Data.Text as T\nimport qualified Data.ByteString.Char8 as B\ngetList :: Read a => IO [a]\ngetList = fmap (map (read . B.unpack) . B.words) B.getLine\ngetIntList :: IO [Int]\ngetIntList = fmap (unfoldr (B.readInt . B.dropWhile isSpace)) B.getLine\n\nsolve :: Int64 -> Int64 -> Int64\nsolve n k = if k <= m then 2 * k - 1 else 2 * (k - m)\n where m = (n + 1) `div` 2\n\nmain :: IO ()\nmain = do\n [n,k] <- getList\n print $ solve n k\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.List.Split\n\n\n\ncalc n k | even n && k<=n2 = 2*k-1\n | even n = (k-n2)*2\n | odd n && k<=(n2+1) = 2*k-1\n | otherwise = (k-n2-1)*2\n where n2 = div n 2\n\n\n\nmain=do\n [n,k]<- map read <$>words <$> getLine ::IO [Integer]\n print $ calc n k\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Integer] -> Integer\nsolve [n, k] | k <= (n + 1) `div` 2 = 2 * k - 1\n | otherwise = 2 * (k - (n + 1) `div` 2)\n"}, {"source_code": "main = interact $ show . solve . map read . words\nsolve [n,k] = r + 1 + (1 - n `mod` 2) * q\n where (q,r) = (2 * (k-1)) `divMod` n\n"}, {"source_code": "import System.IO\nimport Control.Monad\nimport Data.List\n\nglwr = fmap (map read . words) getLine\n\nmain = do\n hSetBuffering stdout NoBuffering\n solve\n\nsolve :: IO ()\nsolve = do\n n:k:_ <- glwr\n\n print $ evenOrOdd n k\n\nevenOrOdd :: Integer -> Integer -> Integer\nevenOrOdd n k\n | k <= odds = k*2 - 1\n | 0 < 1 = (k - odds) * 2\n where\n odds = div n 2 + sum [ 1 | odd n ]\n evens = n - odds\n"}, {"source_code": "nthNumber n k\n | oddsCount >= k = 2 * k - 1\n | otherwise = (k - oddsCount) * 2\n where\n oddsCount = (n + 1) `div` 2\n\nmain = do\n input <- getLine\n let [n, k] = map (read :: String -> Integer) (words input) in print (nthNumber n k)\n"}, {"source_code": "import Control.Applicative\nmain = map read . words <$> getLine >>= print . solve\nsolve :: [Integer] -> Integer\nsolve [n, k] | even n = solveEven n k\n | odd n = solveOdd n k\nsolveEven :: Integer -> Integer -> Integer\nsolveEven n k | k <= n `div` 2 = k * 2 - 1\n | k > n `div` 2 = (k - n `div` 2) * 2\nsolveOdd :: Integer -> Integer -> Integer\nsolveOdd n k | k <= n `div` 2 + 1 = k * 2 - 1\n | k > n `div` 2 + 1 = (k - (n`div` 2 + 1)) * 2\n "}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/318/A\n\nimport Data.Int\n\nsolve :: [Int64] -> Int64\nsolve [n,k] = if k <= m then 2*k-1 else 2*(k-m)\n where m = (n+1) `div` 2\n\nmain :: IO ()\nmain = getLine >>= print . solve . map read . words\n"}, {"source_code": "solve [a,b] | b <= div (a+1) 2 = 2 * b - 1\n | 0 < 1 = 2 * (b - div (a + 1) 2)\nmain = interact $ show . solve . map read . words\n"}, {"source_code": "main=interact$show.f.map read.words\nf :: [Integer] -> Integer\nf[n,k]|k<=div(n+1)2=2*k-1|0<1=2*(k-div(n+1)2)"}, {"source_code": "main = interact (show . answer . readInput)\n\nreadInput :: String -> [Integer]\nreadInput line = (map read) . words $ line\n\nanswer :: [Integer] -> Integer\nanswer [n, k] = if (k <= (n + 1) `div` 2) then k * 2 - 1 else (k - (n + 1) `div` 2) * 2\n\n"}, {"source_code": "import Control.Monad\nimport Control.Applicative\n\ngenAns n k\n | k <= ceiling (fromIntegral n / 2) = k * 2 - 1\n | otherwise = (k - (ceiling (fromIntegral n / 2) )) * 2\n\nmain = do\n [n,k] <- map read . words <$> getLine :: IO [Integer]\n print $ genAns n k\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \nmain= do\n\t[n,k]<- map read. words <$> getLine ::IO [Integer]\n\tprint $ if even n then if k*2 <=n then k*2-1 else (2*(k- (div n 2)) )else if k*2-1<=n then k*2-1 else (2*(k-(div (n+1) 2)))\n\t "}, {"source_code": "module Main (main)\n where\n\n\nmain :: IO ()\nmain = print . find . take 2 . map read . words =<< getLine\n where find [n,k]\n | k > lastOdd = 2*(k - lastOdd)\n | otherwise = 2*k - 1\n where lastOdd = (n + n `mod` 2) `div` 2"}, {"source_code": "\nmain = do\n\ts<-getLine\n\tlet [n,k]=map read $words s\n\tputStrLn $ show $ solve n k\n\nsolve n k | even n && k> div n 2 = 2*(k-div n 2 )\n | even n && k<= div n 2 = 1+2*(k-1)\n | odd n && k>div (n+1) 2=2*(k- div (n+1) 2)\n | odd n && k<=div (n+1) 2=1+2*(k-1)"}, {"source_code": "\n\nfindnum f s = \n if (odd f)\n then if (s > ((div f 2)+1))\n then (2*(s-((div f 2)+1)))\n else (2*s - 1)\n else if (s > (div f 2))\n then (2*(s-(div f 2)))\n else (2*s - 1)\n\n\nmain = do\n aa <- getLine\n let ff = (read (head (words aa)))::Integer\n ss = (read (last (words aa)))::Integer\n\n let ans = findnum ff ss\n putStrLn (show ans)\n"}, {"source_code": "-- Snippet: readItems\nreadItems = do\n line <- getLine\n return $ map read $ words line\n\nmain = do\n [n, k] <- readItems\n let numOdd = div (n + 1) 2\n putStrLn $ show $ if k <= numOdd then k + k - 1 else (k - numOdd) * 2\n"}, {"source_code": "main = do\n m <- getLine\n let [m1, m2] = (map read . words) m\n print $ makn m1 m2\nmakn :: Integer -> Integer -> Integer\n--makn x y = head $ drop (y-1) (filter odd [1..x] ++ filter even [1..x])\nmakn x y\n | 2*y-1 <= x = 2*y-1\n | otherwise = 2*(y-(quot (x+1) 2))"}, {"source_code": "solve [n, k] =\n (+ div (2*(k - 1)) n).(+1).(*2).mod (k - 1) $ div (n + 1) 2\nmain = getLine >>= print. solve. map read. words\n"}, {"source_code": "main=interact$ (++\"\\n\").show.(\\[n,k] ->\n let numOdds=(n+1)`div`2 in if k<= numOdds then 2*k-1 else 2*(k- numOdds) \n ).map read.words\n"}, {"source_code": "main :: IO ()\nmain = interact $ show . solve . map read . words\n\nsolve :: [Integer] -> Integer\nsolve [n, k]\n | k <= m = 2 * k - 1\n | otherwise = 2 * (k - m)\n where\n m = n `div` 2 + n `mod` 2\n"}, {"source_code": "main :: IO ()\nmain = do\n [n, k] <- map (read :: String -> Integer) . words <$> getLine\n print $ if 2 * k <= (n + 1)\n then 2 * (k - 1) + 1\n else 2 * (k - ((n + 1) `div` 2))"}, {"source_code": "main :: IO()\nmain = interact mainFunction\n\nmainFunction :: String -> String\nmainFunction input = let [n, k] = map parseInteger . words $ input\n in show $ solve n k \n\nparseInteger :: String -> Integer\nparseInteger = read\n\nsolve :: Integer -> Integer -> Integer\nsolve n k = let oddCount = (n + 1) `div` 2\n in if k <= oddCount\n then 2 * k - 1\n else 2 * (k - oddCount)\n"}, {"source_code": "main :: IO ()\nmain = do\n line <- getLine \n putStrLn $ show $ solve line\n\nlineToInts :: String -> [Integer]\nlineToInts s = map (read :: String -> Integer) (words s)\n\nsolve :: String -> Integer\nsolve line = \n let nums = lineToInts line\n amount = head nums \n index = (last nums) - 1 in\n -- ([1,3..amount] ++ [2,4..amount]) !! (fromIntegral index)\n solve' amount index\n\nsolve' :: Integer -> Integer -> Integer\nsolve' amount index\n | index < odds = index * 2 + 1\n | otherwise = (index - odds + 1) * 2 \n where odds = ceiling $ (fromIntegral amount) / 2 "}, {"source_code": "{-# LANGUAGE BlockArguments #-}\n\nimport Control.Arrow\nimport Data.List\n\nmain = do { nk <- getLine\n ; let [n,k] = words >>> map read $ nk\n ; putStrLn $ show (solve n k)\n }\n\nsolve :: Integer -> Integer -> Integer\nsolve n k = let m = (div n 2) + (mod n 2)\n in if k <= m \n then 2*k - 1\n else 2*(k-m)"}, {"source_code": "main = getLine >>= return . map read . words\n >>= putStrLn . show . solve\n\nsolve (a:b:_)\n | bound < b = (b - bound) * 2\n | otherwise = b * 2 - 1\n where dm = a `divMod` 2\n bound = fst dm + snd dm\n"}, {"source_code": "main = do\n str <- getLine\n let xs = map read $ words str :: [Integer]\n let n = xs !! 0\n let k = xs !! 1\n let m = if (mod n 2 == 0) then (div n 2) else (div n 2 + 1)\n let ans = if (k > m) then ((k - m) * 2) else (k * 2 - 1)\n print ans\n"}, {"source_code": "main = do\n input <- getLine\n let inp = (split ' ' input)\n let n = read (inp !! 0) :: Integer\n let k = read (inp !! 1) :: Integer\n let v = (n+1) `div` 2\n putStrLn (show (if k <= v then (k * 2 - 1) else ((k - v) * 2)))\n\nsplit' :: (Eq a) => a -> [a] -> [a] -> [[a]]\nsplit' _ [] l = [l]\nsplit' v (x:xs) l\n | x /= v = split' v xs (l ++ [x])\n | otherwise = [l] ++ split' v xs []\n\nsplit :: (Eq a) => a -> [a] -> [[a]]\nsplit v xs = split' v xs []\n"}, {"source_code": "process :: Integral a => a -> a -> a\nprocess n k\n | k <= m = 2*k-1\n | otherwise = 2*(k-m)\n where m = n - n `div` 2\n\nreadInt :: String -> Integer\nreadInt = read\n\nmain = do\n [n, k] <- fmap (map readInt.words) getLine\n print $ process n k"}, {"source_code": "import Control.Monad\nimport qualified Data.Map.Lazy as Map\nimport qualified Data.ByteString.Lazy as BS\nimport Data.List\n\nmain :: IO ()\nmain = do\n n:m:_ <- fmap (map read . words) getLine\n print $ rush n m\n\nrush :: Integer -> Integer -> Integer\nrush n m\n | n `mod` 2 == 0 && m * 2 <= n = 2 * m - 1\n | n `mod` 2 == 0 = (m - n `div` 2) * 2\n | n `mod` 2 == 1 && m * 2 - 1 <= n = 2 * m - 1\n | otherwise = (m - n `div` 2 - 1) * 2\n\n"}, {"source_code": "import Control.Monad\n\nmain = do\n [n,k] <- liftM (map (\\x -> read x::Integer) . words) getLine\n let midn = n`div`2 + (if odd n then 1 else 0)\n result = if k > midn then 2*(k-midn) else 2*(k-1)+1\n print result\n\n"}, {"source_code": "\nimport Control.Monad (liftM, replicateM)\nimport Prelude hiding (reads)\n\nreads :: Read a => IO [a]\nreads = liftM (map read . words) getLine\n\nsolve :: [Integer] -> Integer\nsolve [n, k]\n | k <= n `div` 2 + n `mod` 2 = 2 * k - 1\n | otherwise = 2 * (k - n `div` 2 - n `mod` 2)\n\nmain :: IO ()\nmain = reads >>= print . solve"}, {"source_code": "import Control.Applicative\n\nmain = do\n [a,b] <- map read.words <$> getLine :: IO [Integer]\n putStrLn.show $ if odd a then oddA a b else evenA a b\n\noddA a b = if b <= div (a+1) 2 then 2*b-1 else (b-div (a+1) 2)*2\nevenA a b = if b <= div a 2 then 2*b-1 else (b-div a 2)*2"}, {"source_code": "-- Even and Odds\nmain :: IO ()\nmain = do\n [n, k] <- fmap (map read . words) getLine\n print $ sol n k\n\nsol :: Integer -> Integer -> Integer\nsol n k\n | k <= ceil = pred (k * 2)\n | otherwise = (* 2) (k - ceil)\n where\n ceil = div (succ n) 2\n"}, {"source_code": "main = interact solve\nsolve str = let [n, k] = map (read::String -> Integer) . words $ str\n in findk n k\n\nfindk n k\n | k <= oddCounts = show $ 2*k - 1\n | otherwise = show $ (k-oddCounts) * 2\n where oddCounts = (n+1) `div` 2"}], "negative_code": [{"source_code": "import Control.Applicative\n\nmain = do\n [a,b] <- map read.words <$> getLine :: IO [Int]\n putStrLn.show $ if odd a then oddA a b else evenA a b\n\noddA a b = if b <= div (a+1) 2 then [1,3..a] !! (b-1) else (b-div (a+1) 2)*2\nevenA a b = if b <= div a 2 then 2*b-1 else (b-div a 2)*2"}, {"source_code": "import Control.Applicative\n\nmain = do\n [n,k] <- map read . words <$> getLine :: IO [Int]\n let d = n `div` 2 + fromEnum (rem n 2 == 1)\n print $ if k > d then 2*(k-d) else 2*(k-1)+1"}, {"source_code": "{-# LANGUAGE PatternGuards #-}\n\nimport Control.Concurrent\nimport Control.Monad\nimport System.IO\nimport Text.Printf\nimport System.Environment\n\n \nmain = subMain\n \nsolve n k = if (k > midn) then 2*(k - midn) else 2*k-1 where\n\t\tmidn = div n 2 + 1\n\nsubMain = do\n numsStr <- getLine\n let [n, k] = map (read :: String -> Integer) $ words numsStr\n print $ solve n k\n \n\n---------------\n-----------------------------------------------------------------------------\n"}, {"source_code": "{-# LANGUAGE PatternGuards #-}\n\nimport Control.Concurrent\nimport Control.Monad\nimport System.IO\nimport Text.Printf\nimport System.Environment\n\n \nmain = subMain\n \nsolve n k = if (k >= midn) then 2*(k - midn) else 2*k-1 where\n\t\tmidn = if (nm2 == 0) then n2 else n2 + 1\n\t\tnm2 = mod n 2\n\t\tn2 = div n 2\n\nsubMain = do\n numsStr <- getLine\n let [n, k] = map (read :: String -> Integer) $ words numsStr\n print $ solve n k\n \n\n---------------\n-----------------------------------------------------------------------------\n"}, {"source_code": "{-# LANGUAGE PatternGuards #-}\n\nimport Control.Concurrent\nimport Control.Monad\nimport System.IO\nimport Text.Printf\nimport System.Environment\n\n \nmain = subMain\n \nsolve n k = if (k > midn) then 2*(k - midn) else 2*k-1 where\n\t\tmidn = div n 2 + 1\n\nsubMain = do\n numsStr <- getLine\n let [n, k] = map (read :: String -> Int) $ words numsStr\n print $ solve n k\n \n\n---------------\n-----------------------------------------------------------------------------\n"}, {"source_code": "import Control.Applicative\nimport Data.List\nimport Data.List.Split\n\n\n\ncalc n k | even n && k<=n2 = 2*k-1\n | even n = (k-n2)*2\n | odd n && k<=(n2+1) = 2*k-1\n | otherwise = (k-n2-1)*2\n where n2 = div n 2\n\n\n\nmain=do\n [n,k]<- map read <$>words <$> getLine ::IO [Int]\n print $ calc n k\n"}, {"source_code": "import System.IO\nimport Control.Monad\nimport Data.List\n\nglwr = fmap (map read . words) getLine\n\nmain = do\n hSetBuffering stdout NoBuffering\n solve\n\nsolve :: IO ()\nsolve = do\n n:k:_ <- glwr\n\n print $ evenOrOdd n k\n\nevenOrOdd :: Int -> Int -> Int\nevenOrOdd n k\n | k <= odds = k*2 - 1\n | 0 < 1 = (k - odds) * 2\n where\n odds = div n 2 + sum [ 1 | odd n ]\n evens = n - odds\n"}, {"source_code": "nthNumber n k\n | oddsCount >= k = 2 * k - 1\n | otherwise = (k - oddsCount) * 2\n where\n oddsCount = (n + 1) `div` 2\n\nmain = do\n input <- getLine\n let [n, k] = map (read :: String -> Int) (words input) in print (nthNumber n k)\n"}, {"source_code": "-- Vicfred\n-- https://codeforces.com/problemset/problem/318/A\n\nsolve :: [Int] -> Int\nsolve [n,k] = if k <= m then 2*k-1 else 2*(k-m)\n where m = (n+1) `div` 2\n\nmain :: IO ()\nmain = getLine >>= print . solve . map read . words\n"}, {"source_code": "solve [a,b] | a `div` 2 > b = 2*b - 1\n | a `div` 2 < b = 2 * (b - (a `div` 2) - 1)\nmain = interact $ show . solve . map read . words\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n \nmain= do\n\t[n,k]<- map read. words <$> getLine ::IO [Int]\n\tprint $ if even n then if k*2 <=n then k*2-1 else (2*(k- (div n 2)) )else if k*2-1<=n then k*2-1 else (2*(k-(div (n+1) 2)))\n\t "}, {"source_code": "main = do\n m <- getLine\n let [m1, m2] = (map read . words) m\n print $ makn m1 m2\nmakn :: Integer -> Integer -> Integer\n--makn x y = head $ drop (y-1) (filter odd [1..x] ++ filter even [1..x])\nmakn x y\n | 2*y Integer -> Integer\n--makn x y = head $ drop (y-1) (filter odd [1..x] ++ filter even [1..x])\nmakn x y\n | 2*y Integer -> Integer\n--makn x y = head $ drop (y-1) (filter odd [1..x] ++ filter even [1..x])\nmakn x y\n | 2*y Integer) . words <$> getLine\n print $ if 2 * k < n\n then 2 * (k - 1) + 1\n else 2 * (k - ((n + 1) `div` 2))"}, {"source_code": "main :: IO()\nmain = interact mainFunction\n\nmainFunction :: String -> String\nmainFunction input = let [n, k] = map parseInt . words $ input\n in show $ solve n k \n\nparseInt :: String -> Int\nparseInt = read\n\nsolve :: Int -> Int -> Int\nsolve n k = let oddCount = (n + 1) `div` 2\n in if k <= oddCount\n then 2 * k - 1\n else 2 * (k - oddCount)\n"}, {"source_code": "main = do\n input <- getLine\n let inp = (split ' ' input)\n let n = read (inp !! 0) :: Int\n let k = read (inp !! 1) :: Int\n let v = (n+1) `div` 2\n putStrLn (show (if k <= v then (k * 2 - 1) else ((k - v) * 2)))\n\nsplit' :: (Eq a) => a -> [a] -> [a] -> [[a]]\nsplit' _ [] l = [l]\nsplit' v (x:xs) l\n | x /= v = split' v xs (l ++ [x])\n | otherwise = [l] ++ split' v xs []\n\nsplit :: (Eq a) => a -> [a] -> [[a]]\nsplit v xs = split' v xs []\n"}, {"source_code": "-- Even and Odds\n\nmain :: IO ()\nmain = do\n [n, k] <- fmap (map read . words) getLine\n print $ sol n k\n\nsol :: Int -> Int -> Int\nsol n k \n | 2 * k <= n = last . take k $ [1,3..]\n | otherwise = last . take (k `div` 2) $ [2,4..]\n"}, {"source_code": "-- Even and Odds\nmain :: IO ()\nmain = do\n [n, k] <- fmap (map read . words) getLine\n print $ sol n k\n\nsol :: Int -> Int -> Int\nsol n k\n | k <= ceil = pred (k * 2)\n | otherwise = (* 2) (k - ceil)\n where\n ceil = div (succ n) 2\n"}, {"source_code": "main = interact solve\nsolve str = let [n, k] = map (read::String -> Int) . words $ str\n in findk n k\n\nfindk n k\n | k <= oddCounts = show $ 2*k - 1\n | otherwise = show $ (k-oddCounts) * 2\n where oddCounts = (n+1) `div` 2"}, {"source_code": "\n\nfindnum f s = \n if (odd f)\n then if (s > ((div f 2)+1))\n then (2*(s-((div f 2)+1)))\n else (2*s - 1)\n else if (s > (div f 2))\n then (2*(s-(div f 2)))\n else (2*s - 1)\n\n\nmain = do\n aa <- getLine\n let ff = (read (head (words aa)))::Int\n ss = (read (last (words aa)))::Int\n\n let ans = findnum ff ss\n putStrLn (show ans)\n"}, {"source_code": "{-# LANGUAGE BlockArguments #-}\n\nimport Control.Arrow\nimport Data.List\n\nmain = do { nk <- getLine\n ; let [n,k] = words >>> map read $ nk\n ; putStrLn $ show (solve n k)\n }\n\nsolve :: Int -> Int -> Int\nsolve n k = let m = (div n 2) + (mod n 2)\n in if k <= m \n then 2*k - 1\n else 2*(k-m)"}, {"source_code": "import Data.List\nimport Data.Maybe\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = interact $ show.solve.map read.words.head . lines\nsolve :: [Int]->Int\nsolve [x,y] = let z= ceiling (fromIntegral x/ 2) in if y <=z then 2*y-1 else 2*(y - z)"}, {"source_code": "import Control.Monad\n\nmain = do\n [n,k] <- liftM (map (\\x -> read x::Int) . words) getLine\n let midn = n`div`2\n print $ if k > midn then 2*(k-midn-1) else 2*(k-1)+1\n"}, {"source_code": "import Control.Monad\n\nmain = do\n [n,k] <- liftM (map (\\x -> read x::Int) . words) getLine\n let midn = n`div`2\n print $ if k > midn then 2*(k-midn-(if odd n then 1 else 0)) else 2*(k-1)+1\n"}, {"source_code": "import Control.Applicative\n\nmain = do\n [n,i] <- map read.words <$> getLine :: IO [Int]\n putStrLn.show $ index n i\n\nindex n i\n | i < div (n+1) 2 = 2*i-1\n | otherwise = (i- div (n+1) 2) * 2"}, {"source_code": "import Control.Applicative\n\nmain = do\n [a,b] <- map read.words <$> getLine :: IO [Int]\n putStrLn.show $ if odd a then oddA a b else evenA a b\n\noddA a b = if b <= div (a+1) 2 then 2*b-1 else (b-div (a+1) 2)*2\nevenA a b = if b <= div a 2 then 2*b-1 else (b-div a 2)*2"}, {"source_code": "import Control.Applicative\n\nmain = do\n [n,i] <- map read.words <$> getLine :: IO [Int]\n putStrLn.show $ index n i\n\nindex n i\n | i <= div (n+1) 2 = 2*i-1\n | otherwise = (i- div (n+1) 2) * 2"}], "src_uid": "1f8056884db00ad8294a7cc0be75fe97"} {"source_code": "\nm :: Int -> Int -> Int -> Int\nm y n x = y*n - x*100\n\nans :: Int -> Int\nans m | m > 0 = (m + 99) `div` 100\n | otherwise = 0\n\n\nmain = do\n [n, x, y] <- fmap ((map read).words) getLine\n print $ ans $ m y n x\n\n", "positive_code": [{"source_code": "\ngetWords :: IO [String]\ngetWords = getLine >>= return . words\n\nreads :: Read a => IO [a]\nreads = getWords >>= return . (map read)\n\nsolve :: Int -> Int -> Int -> Int\nsolve n x y = max 0 ((n*y - 1) `div` 100 + 1 - x)\n\nmain :: IO ()\nmain = do\n [n, x, y] <- Main.reads\n print $ solve n x y"}, {"source_code": "main=interact$show.f.map read.words\nf[n,x,y]=max 0$ -(-n*y)`div`100-x\n"}, {"source_code": "main :: IO ()\nmain = getContents >>= print . solve . map read . words\n\nsolve :: [Integer] -> Integer\nsolve [ n, x, y ] = max 0 $ (n * y + 99) `div` 100 - x\nsolve _ = undefined\n"}, {"source_code": "main = print . solve . map read . words =<< getLine\nsolve [n,x,y] = max 0 $ (y*n + 99) `div` 100 - x\n"}, {"source_code": "main=interact$show.s.map read.words\ns[n,x,y]=max 0$(-100*x+y*n+99)`div`100"}, {"source_code": "import Control.Applicative\nimport Data.List\n \n \n \n\n\n\nmain= do\n\t[n,a,b]<- map read. words <$> getLine::IO [Double]\n\tprint $ max 0 $ ceiling $ b*n/100.0 - a "}], "negative_code": [{"source_code": "import Control.Applicative\nimport Data.List\n \n \n \n\n\n\nmain= do\n\t[n,a,b]<- map read. words <$> getLine::IO [Double]\n\tprint $ ceiling $ b*n/100.0 - a "}], "src_uid": "7038d7b31e1900588da8b61b325e4299"} {"source_code": "import Data.List\nimport qualified Data.Map.Strict as Map\n\ntoint s = (read s) :: Integer\n\n\nsolve::String -> String\nsolve ss =\n\tlet n:s:_ = map toint $ words ss in\n\tshow(div (s+n-1) n)++\"\\n\"\n\nmain = do\n interact $ solve", "positive_code": [{"source_code": "import System.IO\n\nparseInt :: IO [Int]\nparseInt = fmap (map read . words) getLine\n\nmain :: IO()\nmain = do\n [n, s] <- parseInt\n \n let sol = ceiling $ fromIntegral s / fromIntegral n\n print sol"}, {"source_code": "import Control.Applicative\nimport Control.Monad\n\t\t\n\nmain= do\n\t\t[n,m]<- map read <$> words <$> getLine ::IO [Int]\n\t\tprint $ (div m n) + if (mod m n)>0 then 1 else 0\n"}, {"source_code": "import Data.List (nub)\n\nprocess :: Int -> Int -> Int\nprocess n s = (s - 1) `div` n + 1\n\nreadInt :: String -> Int\nreadInt = read\n\nmain :: IO ()\nmain = do\n [n,s] <- fmap (map readInt.words) getLine\n print $ process n s"}, {"source_code": "import Data.List\n\nmain = do\n e<-getLine\n let (n:s:[])=map read (words e)::[Integer]\n print $ s `div` n + if s `mod` n==0 then 0 else 1 "}, {"source_code": "import Prelude\nimport Control.Monad\n\nstr2Ints str = [read x::Int | x <- words str]\ngetLineN n = replicateM n getLine\n\nmain = do\n s <- getLine;\n let l = str2Ints(s);\n (putStrLn.show)(l!!1 `quot` l!!0 + (if l!!1 `mod` l!!0/=0 then 1 else 0));"}, {"source_code": "main = interact $ show . solve . map read . words\nsolve [n,s] = s `div` n + signum (s `mod` n)\n"}, {"source_code": "main = do\n contents <- getContents\n process (parse contents)\n\nparse :: String -> Maybe (Integer, Integer)\nparse s = two_first(words s)\n\nprocess :: Maybe (Integer, Integer) -> IO ()\nprocess (Just (n, s)) = print (solve n s)\nprocess Nothing = putStrLn \"Invalid input\"\n\ntwo_first (a:b:x) = Just (read a, read b)\ntwo_first x = Nothing\n\nsolve :: Integer -> Integer -> Integer\nsolve n s = (quot (s - 1) n) + 1\n"}, {"source_code": "main = do\n contents <- getContents\n print (solve (parse contents))\n\nparse :: String -> (Integer, Integer)\nparse s = two_first(words s)\n\ntwo_first (a:b:x) = (read a, read b)\ntwo_first x = (10, 100000)\n\nsolve (n, s) = (quot (s - 1) n) + 1\n"}, {"source_code": "import Control.Monad\n\nsolve :: Int -> Int -> Int\nsolve n s = let (q, r) = s `quotRem` n in\n q + (if r /= 0 then 1 else 0)\n\nmain = do\n [n, s] <- fmap read <$> words <$> getLine :: IO [Int]\n print $ solve n s\n"}], "negative_code": [{"source_code": "import Prelude\nimport Control.Monad\n\nstr2Ints str = [read x::Int | x <- words str]\ngetLineN n = replicateM n getLine\n\nmain = do\n s <- getLine;\n let l = str2Ints(s);\n (putStrLn.show)(l!!1 `quot` l!!0 + (if l!!1 `mod` l!!0==1 then 1 else 0));"}, {"source_code": "import Control.Applicative\nimport Control.Monad\n\t\t\n\nmain= do\n\t\t[n,m]<- map read <$> words <$> getLine ::IO [Int]\n\t\tprint $ (div m n) + if (mod m n)==1 then 1 else 0\n"}], "src_uid": "04c067326ec897091c3dbcf4d134df96"} {"source_code": "main :: IO()\nmain = print . solve . map read . words =<< getContents\n\nsolve :: [Int] -> Int\nsolve [0, m] = 0\nsolve [n, m] | n < m = -1\n | otherwise = (div ((div (n + 1) 2) + (m - 1)) m) * m\n", "positive_code": [{"source_code": "getAnswer :: Integer -> Integer -> Integer\ngetAnswer n m = quantify n 1 m\n\nquantify :: Integer -> Integer -> Integer -> Integer\nquantify limit current divisor = if current > limit\n then -1\n else if satisfy limit current divisor\n then current\n else quantify limit (current + 1) divisor\n\nsatisfy :: Integer -> Integer -> Integer -> Bool\nsatisfy limit steps divisor = if steps `mod` divisor == 0 && steps >= allowed\n then True\n else False\n where allowed = (limit+1) `div` 2\n\nmain :: IO ()\nmain = do\n numbers <- getLine\n let [n, m] = map read (words numbers)\n print (getAnswer n m)"}, {"source_code": "import Data.List\nmain = interact $show.solve.map read.words\n\nsolve::[Int]->Int\nsolve (n:m:[]) = getRes $ find (comp m) [leftBound n..n]\n where leftBound n | even n = div n 2\n | otherwise = div n 2 +1\n\n\ncomp m n | mod n m == 0 = True\n | otherwise = False\n\ngetRes::Maybe Int->Int\ngetRes (Just n) = n\ngetRes Nothing = -1"}, {"source_code": "default ( Integer, Rational)\n\nfib = 0:1:zipWith (+) fib fib'\nfib' = tail fib\nsol n m = ((n+1) `div` 2 - 1) `div` m * m + m\nsolve [n,m] = if sol n m <= n then sol n m else -1\n\nmain = interact $ show . solve . map read . words\n"}, {"source_code": "main = do\n [n, m] <- fmap (map read . words) getLine\n\n let ix = [i | i <- [1..10000], i `mod` m == 0, i <= n && n <= 2*i]\n\n print $ if null ix then -1 else head ix\n"}, {"source_code": "module Main where\n\nimport Control.Applicative\nimport Control.Monad\nimport Data.Char (toLower)\nimport Data.List (intersperse)\nimport System.IO\n\nsolve :: Integral t => t -> t -> t\nsolve n m =\n if min_result > max_steps\n then -1\n else min_result\n where\n min_result = min_steps `cdiv` m * m\n max_steps = n\n min_steps = n `cdiv` 2\n cdiv a b = a `div` b + if a `mod` b > 0 then 1 else 0\n\nmain :: IO ()\nmain = do\n hSetBuffering stdin $ BlockBuffering Nothing\n hSetBuffering stdout $ BlockBuffering Nothing\n [n, m] <- map read . words <$> getLine\n print $ solve n m\n"}, {"source_code": "import Data.List\nimport Data.Tree\nimport Data.Int\nimport Data.Maybe\nimport Data.Char\nimport Data.Functor\nimport Control.Monad\nimport Control.Monad.ST.Safe\nimport Control.Arrow\nimport Data.Array\nimport Data.Array.ST.Safe\nimport Data.STRef\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport qualified Data.ByteString.Char8 as C\nmain= readsolveprint\nreadsolveprint::IO()\nreadsolveprint = solve =<< (map (fst.fromJust.C.readInt).C.words<$>C.getLine)\n--solve::Int->IO()\nsolve [x,y] = let m =x `div` 2+ x `mod` 2; b= snd $ break (\\a-> a `mod` y ==0) [m..x] in print $ if b== [] then (-1) else head b"}, {"source_code": "import Data.Char\n\nh :: Int -> Int -> Int -> Int\nh n m x \n | n-2*m >= 2*m = h (n-2*m) m (x+m)\n | n > 2*m = x + 2*m\n | n >= m = x+m\n | otherwise = -1\n \n\n--main = do\n-- line <- getLine\n-- print (h line [])\n\n\n\nmain = do\n line <- getLine\n let a = (read (takeWhile (/= ' ') line) :: Int)\n let b = (read (drop 1 (dropWhile (/= ' ') line)) :: Int)\n print (h a b 0)\n\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\nprocess n m | mod nos m ==0 = nos\n | nos < m && n words <$> getLine ::IO [Int]\n print $ process n m\n"}, {"source_code": "main :: IO ()\nmain = getLine >>= print . solve . map read . words\n\nsolve :: [Int] -> Int\nsolve [n, m] | n < m = -1\n | otherwise = m * ((n `div'` 2) `div'` m)\n where div' a b = - (-a) `div` b\n"}, {"source_code": "main = interact $ show . solve . map read . words\nsolve [n,m]\n | r > n = -1\n | otherwise = r\n where b = (n+1) `div` 2 + m - 1\n r = b - b `mod` m\n"}, {"source_code": "{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}\n{-# LANGUAGE BangPatterns, TupleSections, OverloadedStrings #-}\nimport Control.Applicative\nimport Control.Exception\nimport Control.Monad\nimport Control.Monad.ST\nimport Data.Array.Base\nimport Data.Array.ST (runSTUArray, STArray, runSTArray)\nimport Data.Bits\nimport qualified Data.ByteString.Char8 as B\nimport Data.Char\nimport Data.Function\nimport Data.Int\nimport Data.List\nimport qualified Data.Map as M\nimport qualified Data.Set as S\nimport Data.STRef\nimport GHC.Arr (Array, Ix, range, unsafeIndex)\nbool :: a -> a -> Bool -> a\nbool t f b=if b then t else f\nreadInt :: B.ByteString -> Int\nreadInt bs=case B.readInt bs of{Just(n,_)->n;_->error$\"readInt error : bs = \"++show bs;}\nrep, rev :: Monad m => Int -> (Int -> m ()) -> m ()\nrep !n f=go 0 where go !i=when(i>go(i+1)\nrev !n f=go(n-1)where go !i=when(i>=0)$f i>>go(i-1)\n{-# INLINE rep #-}\n{-# INLINE rev #-}\nfor :: Monad m => Int -> (Int -> Bool) -> (Int -> Int) -> (Int -> m ()) -> m ()\nfor !i0 p next f=go i0 where go !i=when(p i)$f i>>go(next i)\n{-# INLINE for #-} \nmodifyArray :: (MArray a e m, Ix i) => a i e -> i -> (e -> e) -> m ()\nmodifyArray a i f=readArray a i>>=writeArray a i.f\n{-# INLINE modifyArray #-}\nunsafeModify :: (MArray a e m, Ix i) => a i e -> Int -> (e -> e) -> m ()\nunsafeModify a i f=unsafeRead a i>>=unsafeWrite a i.f\n{-# INLINE unsafeModify #-}\n\nmain :: IO ()\nmain = do\n [n,m] <- map read.words <$> getLine :: IO [Int]\n case [k|k<-[m,m+m..n],let a=2*k-n, let b=n-k, a>=0, b>=0] of\n [] -> print (-1)\n xs -> print $ head xs\n"}, {"source_code": "#!/usr/bin/env runghc\nmain = getContents >>= mapM_ print . solve . lines\nsolve = map (f . map read . words)\nf [n,m]\n | n==0 = 0\n | n getLine::IO [Int]\n\tlet ans = ( div n 2 )+ ( if odd n then 1 else 0)\n\tprint $ if (m>n) then (-1) else (((div ans m)+(if mod ans m >0 then 1 else 0))*m)\n\t "}, {"source_code": "main = do\n [n, m] <- getLine >>= return. map read. words :: IO [Int]\n let idx = [i | i <- [div (n + 1) 2 .. n], mod i m == 0]\n print $ if (not.null $ idx) then head idx else -1\n"}, {"source_code": "main = interact $ show . f . map (read :: String -> Int) . words where\n f [n, m] = _f (div n 2) n m\n _f (-1) _ _ = -1\n _f x n m\n | mod (n - x) m == 0 = n - x\n | otherwise = _f (x - 1) n m"}, {"source_code": "import Data.List\n\ncal ls = if length res == 0 then \"-1\" else show $ minimum res\n where xs = map read $ words $ head $ lines ls\n n = head xs\n m = head $ tail xs\n dm = divMod n 2\n min = (uncurry (+)) dm\n res = [i | i <- [min .. n], i `mod` m == 0]\n\nmain = interact cal\n"}, {"source_code": "main :: IO ()\nmain = interact solve\n\n\nminMoves :: Int -> Int -> Int\nminMoves n m \n | moves <= n && n <= 2 * moves = moves\n | otherwise = -1\n where moves = m * (n `divUp` (2 * m))\n\ndivUp :: (Integral a) => a -> a -> a\ndivUp a b = (a + b - 1) `div` b\n\nsolve :: String -> String\nsolve s = show $ minMoves n m\n where (n:m:_) = fmap read . words $ s\n"}, {"source_code": "climb :: Int -> Int -> Int -> Int\nclimb _ 0 _ = -1\nclimb moves stairs m\n | even stairs && ((steps + moves) `mod` m == 0) = moves + steps\n | odd stairs && ((steps + moves + 1) `mod` m == 0) = moves + steps + 1\n | otherwise = climb (moves + 1) (stairs - 1) m\n where steps = quot stairs 2\n \n\nmain = do\n [stairs, m] <- fmap (map read . words) getLine\n print $ climb 0 stairs m\n"}], "negative_code": [{"source_code": "getAnswer :: Integer -> Integer -> Integer\ngetAnswer n m = quantify n 1 m\n\nquantify :: Integer -> Integer -> Integer -> Integer\nquantify limit current divisor = if current > limit\n then -1\n else if satisfy limit current divisor\n then current\n else quantify limit (current + 1) divisor\n\nsatisfy :: Integer -> Integer -> Integer -> Bool\nsatisfy limit steps divisor = if steps `mod` divisor == 0 && steps >= allowed\n then True\n else False\n where allowed = limit `div` 2\n\nmain :: IO ()\nmain = do\n numbers <- getLine\n let [n, m] = map read (words numbers)\n print (getAnswer n m)"}, {"source_code": "import Data.List\nmain = interact $show.solve.map read.words\n\nsolve::[Int]->Int\nsolve (n:m:[]) = getRes $ find (comp m) [div n 2..n]\n\ncomp m n | mod n m == 0 = True\n | otherwise = False\n\ngetRes::Maybe Int->Int\ngetRes (Just n) = n\ngetRes Nothing = -1"}, {"source_code": "import Data.Char\n\nh :: Int -> Int -> Int -> Int\nh n m x \n | n-2*m >= 2*m = h (n-2*m) m (x+m)\n | n >= 2*m = x + 2*m\n | n >= m = x+m\n | otherwise = -1\n \n\n--main = do\n-- line <- getLine\n-- print (h line [])\n\n\n\nmain = do\n line <- getLine\n let a = (read (takeWhile (/= ' ') line) :: Int)\n let b = (read (drop 1 (dropWhile (/= ' ') line)) :: Int)\n print (h a b 0)\n\n"}, {"source_code": "import Data.Char\n\nh :: Int -> Int -> Int -> Int\nh n m x \n | n-2*m >= m = h (n-2*m) m (x+m)\n | n >= m = x+m\n | otherwise = -1\n \n\n--main = do\n-- line <- getLine\n-- print (h line [])\n\n\n\nmain = do\n line <- getLine\n let a = (read (takeWhile (/= ' ') line) :: Int)\n let b = (read (drop 1 (dropWhile (/= ' ') line)) :: Int)\n print (h a b 0)\n\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\nprocess n m | mod nos m ==0 = nos\n | nos < m = -1\n | otherwise = nos +m -(mod nos m)\n where nos = div (n+1) 2\n\n\nmain = do\n [n,m]<- map read <$> words <$> getLine ::IO [Int]\n print $ process n m\n"}, {"source_code": "#!/usr/bin/env runghc\nmain = getContents >>= mapM_ print . solve . lines\nsolve = map (f . map read . words)\nf [n,m]\n | n>= mapM_ print . solve . lines\nsolve = map (f . map read . words)\nf [n,m]\n | n==0 = 0\n | n getLine::IO [Int]\n\tlet ans = ( div n 2 )+ ( if odd n then 1 else 0)\n\tprint $ if (m>n) then (-1) else ((div ans m)+(if mod ans m >0 then 1 else 0)*m)\n\t "}, {"source_code": "import Control.Applicative\n \n\nmain=do\n\t[n,m]<-map read.words <$> getLine::IO [Int]\n\tlet ans = ( div n 2 )+ ( if odd n then 1 else 0)\n\tprint $ if (m>n) then (-1) else (((div ans m)+1)*m)\n\t "}, {"source_code": "main :: IO ()\nmain = interact solve\n\n\nminMoves :: Int -> Int -> Int\nminMoves n m \n | moves <= n && n < 2 * moves = moves\n | otherwise = -1\n where moves = m * (n `divUp` (2 * m))\n\ndivUp :: (Integral a) => a -> a -> a\ndivUp a b = (a + b - 1) `div` b\n\nsolve :: String -> String\nsolve s = show $ minMoves n m\n where (n:m:_) = fmap read . words $ s\n"}, {"source_code": "climb :: Int -> Int -> Int -> Int\nclimb _ 0 _ = -1\nclimb moves stairs m\n | even stairs && ((steps + moves) `mod` m == 0) = moves + steps\n | odd stairs && ((steps + moves) + 1 `mod` m == 0) = moves + steps + 1\n | otherwise = climb (moves + 1) (stairs - 1) m\n where steps = quot stairs 2\n \n\nmain = do\n [stairs, m] <- fmap (map read . words) getLine\n print $ climb 0 stairs m\n"}], "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f"} {"source_code": "canBuy :: Int -> Bool\ncanBuy x | x < 0 = False\n | x == 0 = True\n | x `mod` 3 == 0 = True\n | x `mod` 7 == 0 = True\n | x < 7 = canBuy (x - 3)\n | otherwise = canBuy (x - 7)\n\nshowResult :: Bool -> String\nshowResult True = \"YES\"\nshowResult False = \"NO\"\n\nmain :: IO ()\nmain = do\n cases <- fmap (read :: String -> Int) getLine\n results <- sequence $ replicate cases getLine\n mapM_ putStrLn (map (showResult . canBuy . (read :: String -> Int)) results)\n return ()\n", "positive_code": [{"source_code": "module Main where\nimport qualified Data.ByteString.Char8 as B\nimport Control.Monad\nimport Control.Monad.Trans.State.Lazy\nimport Data.Bool\n\nmain = B.interact exec\nexec = B.pack . evalState app . B.words\napp = (unlines . map (bool \"NO\" \"YES\" . solve)) `fmap` (flip replicateM poi =<< poi)\n where\n pop = state $ \\(x:xs) -> (x, xs)\n poi = fmap int pop\n int = maybe undefined fst . B.readInt\n\nsolve x = or [3*a + 7*b == x| a <- [0..100], b <- [0..100]]"}, {"source_code": "main :: IO ()\nmain =\n interact\n $ unlines\n . map\n (([\"NO\", \"YES\"] !!)\n . fromEnum\n . (`elem` [3 * a + 7 * b | a <- [0 .. 100], b <- [0 .. 100]])\n . read\n )\n . tail\n . words\n"}, {"source_code": "main = getLine >> interact (unlines . solve . map read . lines)\n\nsolve [] = []\nsolve (n:ns)\n | filter (\\t -> (n - 3*t) `mod` 7 == 0) [0 .. (n `div` 3)] == [] = \"NO\":(solve ns)\n | otherwise = \"YES\":(solve ns)\n"}, {"source_code": "g=1000000007::Integer\n\nf :: Int->String\nf n\n |n<0=\"NO\"\n |n `mod` 7==0=\"YES\"\n |otherwise=f (n-3)\n\nmain = do\n a<-getLine\n b<-getContents\n let xs=map read (lines b)::[Int]\n mapM_ putStrLn $ map f xs"}, {"source_code": "main = interact $ unlines . map (solve . read) . tail . words\nsolve n | null [ () | i <- [0..33], j <- [0..14], 3*i+7*j == n ] = \"NO\"\n | otherwise = \"YES\"\n"}, {"source_code": "groupOn :: Int -> [a] -> [[a]]\ngroupOn _ [] = []\ngroupOn n xs = let (sts, nds) = splitAt n xs in sts : groupOn n nds\n-------------------------------------------------------------------------------\n\nmain = interact $ unlines . parse . lines\n\nparse (_:ops') = map sol ops\n where\n ops = map (fn . words) ops'\n fn :: [String] -> Int\n fn [b] = read b\n\nsol a = res \n where\n res = sol' a\n sol' a\n | a < 0 = \"NO\"\n | a `mod` 3 == 0 = \"YES\"\n | otherwise = sol' (a-7)\n"}], "negative_code": [{"source_code": "canBuy :: Int -> Bool\ncanBuy x = x `mod` 3 == 0 || x `mod` 7 == 0\n\nshowResult :: Bool -> String\nshowResult True = \"YES\"\nshowResult False = \"NO\"\n\nmain :: IO ()\nmain = do\n cases <- fmap (read :: String -> Int) getLine\n results <- sequence $ replicate cases getLine\n mapM_ putStrLn (map (showResult . canBuy . (read :: String -> Int)) results)\n return ()\n"}, {"source_code": "canBuy :: Int -> Bool\ncanBuy x | x < 0 = False\n | x == 0 = True\n | x < 7 = canBuy (x - 3)\n | otherwise = canBuy (x - 7)\n\nshowResult :: Bool -> String\nshowResult True = \"YES\"\nshowResult False = \"NO\"\n\nmain :: IO ()\nmain = do\n cases <- fmap (read :: String -> Int) getLine\n results <- sequence $ replicate cases getLine\n mapM_ putStrLn (map (showResult . canBuy . (read :: String -> Int)) results)\n return ()\n"}, {"source_code": "main = interact $ unlines . map (show . solve . read) . tail . words\nsolve n | null [ () | i <- [0..33], j <- [0..14], 3*i+7*j == n ] = \"NO\"\n | otherwise = \"YES\"\n\n"}], "src_uid": "cfd1182be98fb5f0c426f8b68e48d452"} {"source_code": "import Data.Bits\nmain=interact$show.f.map read.words\nf :: [Integer] -> Integer\nf[l,r]=last.(0:).takeWhile(<2*(l`xor`r)).map pred$iterate(2*)1", "positive_code": [{"source_code": "import Control.Applicative\nimport Data.Bits\n\ngao :: Int -> (Integer, Integer) -> (Integer, Integer) -> Integer\ngao p r1 r2\n | r1 == (0, mm) = mm\n | r2 == (0, mm) = mm\n | otherwise = maximum $ [u1 `xor` u2 `xor` gao (p - 1) w1 w2 |\n (u1, v1) <- f r1, (u2, v2) <- f r2, let w1 = g v1, let w2 = g v2]\n where\n mm = bit (p + 1) - 1\n b = bit p\n m = b - 1\n f (x, y) = filter (uncurry (<=) . snd) [\n (0, (x, min y m)), (b, (max x b, y))]\n g (x, y) = (x .&. m, y .&. m)\n\nmain :: IO ()\nmain = do\n [l, r] <- map read <$> words <$> getLine\n print $ gao 100 (l, r) (l, r)\n"}, {"source_code": "import Data.Bits\nimport Data.Int\nmain :: IO()\nmain = do\n [b,a] <- fmap ((map read) . words) getLine :: IO [Int64]\n let l = reverse $ zip (bits a []) (bits b [0,0..])\n l' = dropWhile (\\(x1,x2) -> x1==x2) l\n ans = bit $ length l' :: Int64\n print (ans-1)\n\nbits 0 t = t\nbits n t = n `rem` 2 : bits (n `quot` 2) t"}, {"source_code": "import Control.Monad\nimport Data.Bits\n\nreadi :: [Char] -> Integer\nreadi x = read x :: Integer\n\nfunc1 l r = foldl (max) 0 $ (foldl (++) []) $ [map (xor x) [l..r] | x <- [l..r]]\n\nmaxdig = 70\n\nfunc2 l r = (foldl (max) 0 $ filter (\\x -> (m .&. x) /= 0) (map (2^) [0..maxdig]))*2 - 1\n\twhere m = xor l r\n\nmain = do\n\t[l, r] <- ((map readi) . words) `liftM` getLine\n\tputStr $ show $ max (func2 l r) 0\n"}], "negative_code": [{"source_code": "import Control.Monad\nimport Data.Bits\n\nreadi :: [Char] -> Integer\nreadi x = read x :: Integer\n\nfunc1 l r = foldl (max) 0 $ (foldl (++) []) $ [map (xor x) [l..r] | x <- [l..r]]\n\nmaxdig = 70\n\nfunc2 l r = (foldl (max) 0 $ filter (\\x -> (m .&. x) /= 0) (map (2^) [0..maxdig]))*2 - 1\n\twhere m = xor l r\n\nmain = do\n\t[l, r] <- ((map readi) . words) `liftM` getLine\n\tputStr $ show $ func2 l r\n"}], "src_uid": "d90e99d539b16590c17328d79a5921e0"} {"source_code": "ri :: String -> Integer\nri = read\n\nmyDiv :: Integer -> Integer -> Integer\nmyDiv x y | rem x y /= 0 = (div x y) + 1\n | otherwise = div x y\n\ncalc :: [Integer] -> Integer\ncalc [n,m,a] = (myDiv n a) * (myDiv m a)\n\nmain = do\n line <- getLine\n\n print $ calc (map ri (words line))", "positive_code": [{"source_code": "import Control.Applicative\n\nmain = do\n [n, m, a] <- (map read . words) <$> getLine\n print $ (div (n+a-1) a)*(div (m+a-1) a)\n"}, {"source_code": "\nans :: Integer -> Integer -> Integer -> Integer \nans n m a = x * y\n where x = if n `mod` a == 0 then n `div` a else (n `div` a) + 1\n y = if m `mod` a == 0 then m `div` a else (m `div` a) + 1\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\nmain = do \n\tinp <- getLine \n\tlet (n : m : a : []) = map read (words inp) :: [Integer]\n\tputStrLn $ show $ ans n m a "}, {"source_code": "import Data.Word\n\nsolve:: (Integral a) => a -> a -> a -> a\nsolve n m a = (ceilDiv n a) * (ceilDiv m a)\n where\n ceilDiv = \\x y -> (div x y) + (if (mod x y) > 0 then 1 else 0)\n\nmain :: IO ()\nmain = do\n --let input = \"1000000000 1000000000 192\"\n input <- getLine :: IO String\n let [n, m, a] = map (read :: String -> Word64) $ words input\n print $ solve n m a"}, {"source_code": "import Control.Applicative\n\nmain = do\n [n, m, a] <- (map read . words) <$> getLine\n print $ (div (n+a-1) a) *(div (m+a-1) a)\n"}, {"source_code": "main= readsoveprint\nreadsoveprint::IO()\nreadsoveprint=getLine >>= print . solve .isdata\nsolve :: [Int]->Integer\nsolve [x,y,z]=(ceiling $ fromIntegral x/ fromIntegral z) * (ceiling $ fromIntegral y/ fromIntegral z)\nisdata :: String->[Int]\nisdata x= map read $ words x"}, {"source_code": "-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n-- File Name : 0001A.hs\n-- Creation Date : 17-10-2012\n-- Last Modified : Fri 19 Oct 2012 01:44:16 PM EEST\n-- Created By : Greg Liras \n--_._._._._._._._._._._._._._._._._._._._._.\n\n{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\ncalcTiles len side = \n let\n x = ceiling $ fromIntegral len / fromIntegral side\n in\n case x of\n 0 -> 1\n _ -> x\n\n\nmain :: IO ()\nmain = \n do\n all <- BS.getContents\n let Just (n, r1) = readInt all\n let Just (m, r2) = readInt r1\n let Just (a, _) = readInt r2\n let x = fromIntegral $ (calcTiles n a) * (calcTiles m a)\n print $ x\n where \n readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let \n (xs, t) = readMany readf r\n in \n (x : xs, t)\n Nothing -> ([], s)\n"}, {"source_code": "\nstr2int_list :: String -> [Int]\nstr2int_list = map read . words\n\nstonesNeeded x a = \n let quotient = div x a \n has_remainder = fromEnum (mod x a /= 0)\n in quotient + has_remainder\n\nmain = do\n input <- getLine :: IO String\n let [n, m, a] = str2int_list input\n stonesNeededBy x = stonesNeeded x a\n answer = (toInteger $ stonesNeededBy n) * (toInteger $ stonesNeededBy m)\n print answer\n"}, {"source_code": "{-# LANGUAGE CPP, TemplateHaskell #-}\n-----------------------------------------------------------------------------\n--\n-- Module : Main\n-- Copyright :\n-- License : AllRightsReserved\n--\n-- Maintainer :\n-- Stability :\n-- Portability :\n--\n-- |\n--\n-----------------------------------------------------------------------------\n\nmodule Main (\n main\n) where\n\nimport Control.Monad (unless)\nimport Data.List (stripPrefix)\nimport System.Exit (exitFailure)\n--import Test.QuickCheck.All (quickCheckAll)\n\n-- Simple function to create a hello message.\nhello s = \"Hello \" ++ s\n\nfun n a = ((div n a) + if mod n a >0 then 1 else 0)\n\ncount n m a = (fun n a )* (fun m a)\n\n-- Hello World\nmain = do\n [n, m, a] <- (map read . words) `fmap` getLine\n print ( count n m a)\n\n-- Entry point for unit tests.\n--testMain = do\n-- allPass <- $quickCheckAll -- Run QuickCheck on all prop_ functions\n-- unless allPass exitFailure\n\n-- This is a clunky, but portable, way to use the same Main module file\n-- for both an application and for unit tests.\n-- MAIN_FUNCTION is preprocessor macro set to exeMain or testMain.\n-- That way we can use the same file for both an application and for tests.\n#ifndef MAIN_FUNCTION\n#define MAIN_FUNCTION exeMain\n#endif\n--main = MAIN_FUNCTION\n\n"}, {"source_code": "squares n m a\n | n < a = 1 * divma\n | mod n a == 0 = (div n a ) * divma\n | mod n a /= 0 = (div n a + 1) * divma\n where\n divma\n | m < a = 1\n | m >= a = if mod m a == 0 then div m a else div m a + 1\n \nmain = do\n numbers <- getLine\n let n = read ((words numbers) !! 0) :: Integer\n let m = read ((words numbers) !! 1) :: Integer\n let a = read ((words numbers) !! 2) :: Integer\n print (squares n m a)\n"}, {"source_code": "main = do\n [a, b, c] <- (read <$>) <$> words <$> getLine\n print $ div (a + c - 1) c * div (b + c - 1) c\n"}, {"source_code": "main=interact$show.(\\[a,b,c]->div(-a)c*div(-b)c).map read.words"}, {"source_code": "main = do\n line <- getLine\n let [m, n, a] = map read (words line) :: [Integer]\n print $ div (m+a-1) a * div (n+a-1) a\n"}, {"source_code": "\nceildiv m n = m `div` n + if m `mod` n == 0 then 0 else 1\n\nmain = do\n line <- getLine\n let [m, n, a] = map read (words line) :: [Integer]\n putStrLn . show $ ceildiv m a * ceildiv n a\n"}, {"source_code": "module Main where\n\nparseInts :: String -> [Integer]\nparseInts = map (read :: String -> Integer) . words\n\ndivUp n a = (div n a) +\n if (mod n a) > 0\n then 1\n else 0\n\nmain = do\n answer <- getLine\n let [n, m, a] = parseInts answer\n print $ (divUp n a) * (divUp m a)\n return ()\n"}, {"source_code": "calcStones :: [Integer] -> Integer\ncalcStones [x, y, z] = row * column\n where\n row = ceiling $ (fromInteger x) / (fromInteger z)\n column = ceiling $ (fromInteger y) / (fromInteger z)\n\nmain = do\n inputList <- getLine >>= return . words\n print $ calcStones $ map (\\x -> read x :: Integer) inputList\n"}, {"source_code": "import Control.Monad\n\nmain :: IO ()\nmain = do\n line <- getLine\n let n:m:a:xs = fmap (\\x -> read x :: Int) $ words line\n print (toInteger (coveringStones n a) * toInteger (coveringStones m a))\n\ncoveringStones :: Int -> Int -> Int\ncoveringStones l a =(div l a) + if (mod l a == 0) then 0 else 1"}, {"source_code": "main=interact(unlines.map f.lines)\nf s=do show$ceiling(n/a)*ceiling(m/a)\n where [n,m,a]=map read(words s)"}, {"source_code": "main=interact(unlines.map f.lines)\nf s=do show(ceiling(n/a)*ceiling(m/a))\n where [n, m, a]=(map read (words s))\n"}, {"source_code": "main = do\n\tcontents <- getContents\n\tlet\n\t numbers = map (\\str -> read str :: Int) $ words contents\n\t n = numbers !! 0\n\t m = numbers !! 1\n\t k = numbers !! 2\n\tprint $ (toInteger $ f n k) * (toInteger $ f m k)\n\nf :: Int -> Int -> Int\nf n k = if n `mod` k == 0\n\tthen n `div` k\n\telse (n `div` k) + 1\n\n"}, {"source_code": "import Data.Int\n\nparseString :: String -> [Int64]\nparseString str = map (\\x -> read x::Int64) $ words str\n\nsolution :: Int64 -> Int64 -> Int64 -> Int64\nsolution n m a = (fst x1 + y x1) * (fst x2 + y x2)\n where \n x1 = divMod n a\n x2 = divMod m a\n y x = if snd x == 0 then 0 else 1\n\nmain :: IO()\nmain = do\n a <- getLine\n print $ solution ((ps a)!!0) ((ps a)!!1) ((ps a)!!2)\n where ps = parseString"}, {"source_code": "module Main where\n\nimport Control.Monad (sequence)\nimport qualified Data.ByteString.Char8 as BS\n\nmain :: IO ()\nmain = do\n result <- (fmap (map fst)\n . sequence\n . map BS.readInteger\n . BS.words) `fmap` BS.getLine\n case result of\n Just (n : m : a : _)\n | flagstoneArea == 1 -> print area\n | flagstoneArea > area -> print 1\n | otherwise ->\n print ((ceiling ((fromIntegral n) / (fromIntegral a))) *\n (ceiling ((fromIntegral m) / (fromIntegral a))))\n where\n area = n * m\n flagstoneArea = a * a\n Nothing -> error (\"err: invalid input \" ++ show result)\n"}, {"source_code": "main :: IO ()\nmain = interact func\n\nfunc :: String -> String\nfunc s = show . func' . map read $ words s\n\nfunc' :: [Integer] -> Integer\nfunc' (n:m:a:[]) = (m `div` a + (m `dived` a)) * (n `div` a + (n `dived` a))\n where dived x y = if x `mod` y == 0 then 0 else 1\nfunc' _ = error \"\"\n"}, {"source_code": "main :: IO ()\nmain = interact func\n\nfunc :: String -> String\nfunc s = show . func' . map read $ words s\n\nfunc' :: [Integer] -> Integer\nfunc' (n:m:a:[]) = (m `div` a + (m `dived` a)) * (n `div` a + (n `dived` a))\n where dived x y = if x `mod` y == 0 then 0 else 1\n"}, {"source_code": "s[n,m,a]=div(-n)a*div(-m)a\nmain=interact$show.s.map read.words"}, {"source_code": "main :: IO ()\nmain = do\n s <- getLine\n putStrLn $ (coverSquare' . (map read) . words) s\n return ()\n\ncoverSquare' :: (Show a, Integral a) => [a] -> String\ncoverSquare' [n,m,a] = show $ coverSquare n m a\ncoverSquare' _ = \"coverSquare': Invalid number of arguments.\"\n\ncoverSquare :: Integral a => a -> a -> a -> a\ncoverSquare n m a = (n `quot'` a) * (m `quot'` a)\n where\n c `quot'` d = (c `quot` d) + (if c `rem` d > 0 then 1 else 0)\n"}, {"source_code": "main = do\n (n:m:[a]) <- map read <$> words <$> getLine\n print $ (n `divUp` a) * (m `divUp` a) where\n divUp a b = ceiling (fromIntegral a / fromIntegral b)\n"}, {"source_code": "module Main (main) where\n\nimport System\nimport Data.Char\nimport Data.List\nimport Control.Monad\nimport Control.Applicative\n\nsolve n m a = ((n-1) `div` a + 1)*((m-1) `div` a + 1)\n\nmain = do line <- getLine\n let arr = words line\n let [n,m,a] = map read arr :: [Integer]\n print $ solve n m a\n return ()\n"}, {"source_code": "module Main where\n\nrequiredCount :: Integer -> Integer -> Integer\nrequiredCount size tileSize = (size - 1) `div` tileSize + 1\n\nsolution :: Integer -> Integer -> Integer -> String\nsolution n m a = show $ (requiredCount n a) * (requiredCount m a)\n\nmain::IO()\nmain = do\n line <- getLine\n let [nString, mString, aString] = words line\n let n = read nString :: Integer\n let m = read mString :: Integer\n let a = read aString :: Integer\n putStr $ solution n m a"}, {"source_code": "main :: IO ()\nmain = interact func\n\nfunc :: String -> String\nfunc s = show . func' . map read $ words s\n\nfunc' :: [Integer] -> Integer \nfunc' (n:m:a:[]) = (m `div` a + (m `dived` a)) * (n `div` a + (n `dived` a))\n where dived x y = if x `mod` y == 0 then 0 else 1\nfunc' _ = error \"\"\n"}, {"source_code": "import Control.Applicative\nmain= do\n\t[n,m,a]<- map read. words <$> getLine:: IO [Integer]\n\tlet x = ( div n a) + if ( mod n a ==0) then 0 else 1\n\tlet y = ( div m a) + if ( mod m a ==0) then 0 else 1\n\tprint $ x*y\n"}, {"source_code": "main :: IO ()\nmain = do\n\t--nmpStr <- readFile \"input.txt\"\n\tnmpStr <- getLine\n\tlet n : m : p : [] = map (read :: String -> Integer) $ words nmpStr\n\tprint ((if ((mod n p) /= 0) then (div n p + 1) else div n p) * (if ((mod m p) /= 0) then (div m p + 1) else div m p))\n\treturn ()"}, {"source_code": "module Main where\n\nmain :: IO ()\nmain = do\n line <- getLine\n let i = map (read :: String->Int) $ words line\n let n = fromIntegral $ i !! 0\n let m = fromIntegral $ i !! 1\n let a = fromIntegral $ i !! 2\n print $ (ceiling $ m / a) * (ceiling $ n / a)\n\n"}, {"source_code": "--ghc 7.10\n\nimport Control.Applicative\nimport Control.Monad\nimport System.IO\n\nreadNumbers :: String -> [Integer]\nreadNumbers = map read . words\n\nres n a = if (mod n a == 0) then div n a else 1 + div n a\n\n-- IO Monad\nmain :: IO ()\nmain = do\n l1 <- getLine\n let aye = readNumbers l1\n n = aye!!0\n m = aye!!1\n a = aye!!2\n print(res n a * res m a)"}, {"source_code": "module Main where\n\nimport Control.Applicative ((<$>), pure)\nimport Data.Word (Word64)\n\n\ninput :: IO (Word64, Word64, Word64)\ninput = do\n [n, m, a] <- fmap read . words <$> getLine\n pure (n, m, a)\n\n\ncount :: Word64 -> Word64 -> Word64\ncount x y =\n let n = x `div` y\n in if x `mod` y /= 0\n then n + 1\n else n\n\n\nmain :: IO ()\nmain = do\n (n, m, a) <- input\n print $ count n a * count m a\n"}, {"source_code": "\na meiapal resto\n | null resto = (meiapal, resto)\n | otherwise = (\\(r:rs)->if r==' ' then (meiapal, rs) else a (meiapal++[r]) rs) resto\n\npri resu rest\n | null rest = (resu, rest)\n | otherwise = (\\(pal, resto)->pri (resu++[pal]) resto) (a [] rest)\n\nsepara str = fst (pri [] str)\n\nsq n m a\n | a==1 = m*n\n | (mod n a) == 0 = sq (n-1) m a\n | (mod m a) == 0 = sq n (m-1) a\n | otherwise = ((div m a)+1)*((div n a)+1)\n\nsqn l = let a:b:c:_=l in sq a b c\n\n\nmain = do\n s <- getLine\n putStrLn (show(sqn (let readInt a = read a::Integer in map readInt (separa s))))\n"}, {"source_code": "ans :: [Integer] -> Integer\nans (x : (y : (z : xs))) = ((x + z - 1) `div` z) * ((y + z - 1) `div` z)\n\nmain = do\n d <- getLine\n putStr (show (ans (map read (words d))))\n"}, {"source_code": "module Main where\n\nimport Control.Applicative\n\nf :: Double -> Double -> Double -> Integer\nf n m a = g n * g m\n where\n g x = ceiling $ (/) x a\n\nmain :: IO ()\nmain = do\n (n:m:a:_) <- words <$> getLine\n putStrLn $ show $ f (read n) (read m) (read a)\n"}, {"source_code": "(|>) a b = b a\n\nf n m a =\n ceiling ((fromIntegral n) / (fromIntegral a))\n * ceiling ((fromIntegral m) / (fromIntegral a))\n\nmain = do\n s <- getLine \n let a = s |> words |> map (read :: String -> Int) \n f (a !! 0) (a !! 1) (a !! 2) |> print"}, {"source_code": "module Main where\n\nimport Control.Monad\nimport Data.List\n\ngetUpperBound :: Integer -> Integer -> Integer\ngetUpperBound x y\n | mod x y == 0 = quot x y\n | otherwise = (quot x y) + 1\n\ntheaterSquare :: [Integer] -> Integer\ntheaterSquare (x:y:z:_) = (getUpperBound x z) * (getUpperBound y z)\n\nmain :: IO()\nmain = do\n input <- getLine\n let arr = Data.List.map (read :: String -> Integer) . words $ input\n print . theaterSquare $ arr"}, {"source_code": "getDiv :: Integer -> Integer -> Integer\ngetDiv x a = x `div` a\n\ngetMul :: Integer -> Integer -> Integer\ngetMul x a \n | x `mod` a == 0 = getDiv x a \n | otherwise = getDiv x a + 1\n\nmain :: IO ()\nmain = do\n num <- fmap (map read.words) getLine\n let a = last num\n print $ getMul (num !! 0) a * getMul (num !! 1) a\n"}, {"source_code": "import Data.Int\nimport Control.Applicative\n\nfindFlagstoneNumber :: Int64 -> Int64 -> Int64 -> Int64\nfindFlagstoneNumber n m a\n = solve1d n * solve1d m\n where solve1d x = div (x + a - 1) a\n\nsolve :: String -> String\nsolve str\n | [n, m, a] <- read <$> words str\n = show $ findFlagstoneNumber n m a\n\nmain :: IO ()\nmain = interact solve\n"}, {"source_code": "import Data.List\n\nsolve :: [Integer] -> Integer\nsolve [n, m, a] = (div (n + a - 1) a) * (div (m + a - 1) a)\n\n--splitTokens :: String -> [String]\n--splitTokens \"\" = []\n--splitTokens (x:xs) = getTokens (x:xs) \"\"\n-- where getTokens \"\" s = [s]\n-- getTokens (y:ys) s = if y == ' ' the\nmain = do\n z <- getLine\n putStrLn $ show $ solve $ map read (words z)\n"}, {"source_code": "import Data.Int\nfindFlagstoneNumber :: [Int64] -> Int64\nfindFlagstoneNumber args\n | [n, m, a] <- args\n = div (n + a - 1) a\n * div (m + a - 1) a\n\nsolve :: String -> String\nsolve str \n = (show $ findFlagstoneNumber $ map (\\x -> read x) $ words str)\n ++ \"\\n\"\n\nmain :: IO ()\nmain = interact solve\n"}, {"source_code": "import Data.Int\nimport Control.Applicative\n\nfindFlagstoneNumber :: Int64 -> Int64 -> Int64 -> Int64\nfindFlagstoneNumber n m a\n = foldl1 (*) $ solve1D <$> [n, m]\n where solve1D = (`div` a) . (+) (a - 1)\n\nmain :: IO ()\nmain = do\n [n, m, a] <- map read <$> words <$> getLine\n print $ findFlagstoneNumber n m a\n"}, {"source_code": "module Main where\nmain = interact $ match . fmap read . words\n\nmatch [n, m, a] = show $ solve n m a\nmatch _ = error \"Input mismatch\"\n\n--solve :: Integer -> Integer -> Integer -> Integer\nsolve :: (Integral a) => a -> a -> a -> a\nsolve n m a = divUp n a * divUp m a\n\ndivUp :: (Integral a) => a -> a -> a\ndivUp a b = (a + b - 1) `div` b"}, {"source_code": "module Main where\n\nimport Data.Int (Int64)\n\n\nmain :: IO ()\nmain = mapM_ (print . (\\[m, n, a] -> f m n a) . map read . words) . lines =<< getContents\n\n\nf :: Int64 -> Int64 -> Int64 -> Int64\nf n m a = ceiling (fromIntegral n / fromIntegral a) * ceiling (fromIntegral m / fromIntegral a)\n"}, {"source_code": "import Data.Int\nimport Control.Applicative\n\nfindFlagstoneNumber :: Int64 -> Int64 -> Int64 -> Int64\nfindFlagstoneNumber n m a\n = solve1d n * solve1d m\n where solve1d x = div (x + a - 1) a\n\nsolve :: String -> String\nsolve str\n | [n, m , a] <- read <$> words str\n = show $ findFlagstoneNumber n m a\n\nmain :: IO ()\nmain = interact solve\n"}, {"source_code": "import Data.Int\nfindFlagstoneNumber :: Int64 -> Int64 -> Int64 -> Int64\nfindFlagstoneNumber n m a\n = div (n + a - 1) a * div (m + a - 1) a\n\nsolve :: String -> String\nsolve str\n | [n, m, a] <- map (\\x -> read x) $ words str\n = show $ findFlagstoneNumber n m a\n\nmain :: IO ()\nmain = interact solve\n"}, {"source_code": "import Data.Int\nfindFlagstoneNumber :: Int64 -> Int64 -> Int64 -> Int64\nfindFlagstoneNumber n m a\n = div (n + a - 1) a\n * div (m + a - 1) a\n\nsolve :: String -> String\nsolve str \n = ( show\n $ findFlagstoneNumber\n (read $ args !! 0)\n (read $ args !! 1)\n (read $ args !! 2)\n ) ++ \"\\n\"\n where args = words str\n\nmain :: IO ()\nmain = interact solve\n"}, {"source_code": "solve' :: [Integer] -> Integer\nsolve' [n, m, a] = ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)\n\nsolve :: IO String -> IO Integer\nsolve x = fmap (solve'.(map read.words)) x\n\nmain :: IO()\nmain = solve getLine >>= print"}, {"source_code": "main = do\n input <- fmap words getLine\n let ints = (map read input :: [Integer])\n let a = ints !! 0\n let b = ints !! 1\n let c = ints !! 2\n print (calc a b c)\n\ncalc a b c = (if mod a c == 0 then div a c else div a c + 1)*(if mod b c == 0 then div b c else div b c + 1)"}, {"source_code": "f :: [String] -> [Integer]\nf = map read \n\n--tileCount:: (Integral a) => a -> a-> a\ntileCount length side\n | modulus == 0 = quotient\n | otherwise = quotient + 1\n where \n modulus = length `mod` side\n quotient = length `div` side\n\nmain = do\n z <- getLine\n let [m, n, a] = f (words z) \n print ((tileCount m a) * (tileCount n a))"}, {"source_code": "main :: IO ()\nmain = interact $ show . solve . (map read . words) . head . lines\n\nsolve :: [Integer] -> Integer\nsolve [n, m, a] = ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)\nsolve _ = 0\n"}, {"source_code": "w[n,m,a]=div(-n)a*div(-m)a;main=getLine>>=print.w.map read.words\n"}, {"source_code": "divUp a b = (a - 1) `div` b + 1\nsolve [n, m, a] = (n `divUp` a) * (m `divUp` a)\nmain = interact $ show . solve . map read . words\n"}, {"source_code": "s[n,m,a]=div (-n) a * div (-m) a\nmain=getLine>>=print.s.map read.words\n"}, {"source_code": "main :: IO ()\nmain = do\n [n, m, a] <- fmap (map read . words) getLine :: IO [Integer]\n let rp = if mod n a /= 0 then 1 else 0\n rq = if mod m a /= 0 then 1 else 0\n p = (div n a) + rp\n q = (div m a) + rq \n print (p * q)\n \n\n"}, {"source_code": "{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, BangPatterns, PatternGuards, ViewPatterns, RecordWildCards, ForeignFunctionInterface, CPP, TypeSynonymInstances, FlexibleInstances, FlexibleContexts, ImplicitParams #-}\n{-# OPTIONS_GHC -O2 -Wall -fno-warn-unused-do-bind -fno-warn-type-defaults -fno-warn-unused-imports #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Foreign\nimport Foreign.C\nimport Data.List\nimport qualified Data.ByteString.Char8 as BS\n-- import qualified Data.Map as Map\n-- import qualified Data.Set as Set\n\nmain :: IO ()\nmain = do\n n :: Integer <- input\n m :: Integer <- input\n a :: Integer <- input\n output' $ ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n--------------------------------------------------\n-- Imported C functions\n--------------------------------------------------\n#define BUFMAX (100005)\n\ntype BString = BS.ByteString\n\nforeign import ccall unsafe \"stdio.h scanf\"\n c_scanf_i :: CString -> Ptr Int -> IO ()\nforeign import ccall unsafe \"stdio.h scanf\"\n c_scanf_i64 :: CString -> Ptr Int64 -> IO ()\nforeign import ccall unsafe \"stdio.h scanf\"\n c_scanf_f :: CString -> Ptr Float -> IO ()\nforeign import ccall unsafe \"stdio.h scanf\"\n c_scanf_s :: CString -> CString -> IO ()\nforeign import ccall unsafe \"stdio.h printf\"\n c_printf_i :: CString -> Int -> IO ()\nforeign import ccall unsafe \"stdio.h printf\"\n c_printf_i64 :: CString -> Int64 -> IO ()\nforeign import ccall unsafe \"stdio.h printf\"\n c_printf_d :: CString -> Double -> IO ()\nforeign import ccall unsafe \"stdio.h printf\"\n c_printf_s :: CString -> CString -> IO ()\n\nfmt_i, fmt_i64, fmt_f, fmt_d, fmt_s :: CString\nfmt_i = unsafePerformIO $ newCString \"%d\"\nfmt_i64 = unsafePerformIO $ newCString \"%I64d\"\nfmt_f = unsafePerformIO $ newCString \"%f\"\nfmt_d = unsafePerformIO $ newCString \"%.16f\"\nfmt_s = unsafePerformIO $ newCString \"%s\"\n{-# NOINLINE fmt_i #-}\n{-# NOINLINE fmt_i64 #-}\n{-# NOINLINE fmt_f #-}\n{-# NOINLINE fmt_d #-}\n{-# NOINLINE fmt_s #-}\n\nptr_i :: Ptr Int\nptr_i = unsafePerformIO malloc\nptr_i64 :: Ptr Int64\nptr_i64 = unsafePerformIO malloc\nptr_f :: Ptr Float\nptr_f = unsafePerformIO malloc\nptr_d :: Ptr Double\nptr_d = unsafePerformIO malloc\nptr_s :: CString\nptr_s = unsafePerformIO $ mallocArray BUFMAX\n{-# NOINLINE ptr_i #-}\n{-# NOINLINE ptr_i64 #-}\n{-# NOINLINE ptr_f #-}\n{-# NOINLINE ptr_d #-}\n{-# NOINLINE ptr_s #-}\n\nclass Input a where\n input :: IO a\n\ninstance Input Int where\n input = c_scanf_i fmt_i ptr_i >> peek ptr_i\ninstance Input Int64 where\n input = c_scanf_i64 fmt_i64 ptr_i64 >> peek ptr_i64\ninstance Input Integer where\n input = toInteger <$> (input :: IO Int64)\ninstance Input Double where\n input = c_scanf_f fmt_f ptr_f >> realToFrac <$> peek ptr_f\ninstance Input String where\n input = c_scanf_s fmt_s ptr_s >> peekCString ptr_s\ninstance Input BString where\n input = c_scanf_s fmt_s ptr_s >> BS.packCString ptr_s\n\nclass Output a where\n output_ :: a -> IO ()\n output :: a -> IO ()\n output = (>> space ) . output_\n output' :: a -> IO ()\n output' = (>> newline) . output_\n\ninstance Output Int where\n output_ = c_printf_i fmt_i\ninstance Output Int64 where\n output_ = c_printf_i64 fmt_i64\ninstance Output Integer where\n output_ = output_ . show\ninstance Output Double where\n output_ = c_printf_d fmt_d\ninstance Output String where\n output_ = flip withCString (c_printf_s fmt_s)\ninstance Output BString where\n output_ = flip BS.useAsCString (c_printf_s fmt_s)\n\nspace :: IO ()\nspace = output_ (\" \" :: String)\n\nnewline :: IO ()\nnewline = output_ (\"\\n\" :: String)\n"}, {"source_code": "--import System.Environment\nimport Data.Int\n\nsolve n m a =\n hline * vline\n where\n hadd = if n `mod` a > 0 then 1 else 0\n vadd = if m `mod` a > 0 then 1 else 0\n hline = n `div` a + hadd\n vline = m `div` a + vadd\n\nreadInts :: IO [Int64]\nreadInts = fmap (map read.words) getLine\n\nmain = do\n (n:m:a:rest) <- readInts\n putStrLn (show $ solve n m a)\n"}, {"source_code": "{-# OPTIONS_GHC -O2 #-}\n\nmain :: IO ()\nmain = do\n n : m : a : _ <- fmap (map read . words) getLine :: IO [Integer]\n print $ ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)\n\n"}, {"source_code": "плиты :: [Integer] -> Integer\nплиты (ш:д:пл:[]) = (ceiling (fromInteger ш / fromInteger пл)) * (ceiling (fromInteger д / fromInteger пл))\nmain = interact $ show . плиты . map read . words\n"}, {"source_code": "import qualified Data.ByteString.Char8 as B\nimport Data.Maybe\n\ngetThreeIntsM = map (fst . fromJust . B.readInt) . B.words <$> B.getLine\n\ncover x a = toInteger $ x `div` a + (if x `rem` a == 0 then 0 else 1)\n\nmain = do\n [n, m, a] <- getThreeIntsM\n putStrLn . show $ (cover n a) * (cover m a)"}, {"source_code": "readInts :: IO [Integer]\nreadInts = fmap (map read.words) getLine\n\nmain = do\n [n, m, a] <- readInts\n putStrLn $ (show (((n + a - 1) `div` a) * ((m + a - 1) `div` a)))"}, {"source_code": "main = fmap (fmap read . words) getLine >>= \\[n,m,a] -> print $ (n^/a)*(m^/a) where x^/y = quot (x + y - 1) y\n"}, {"source_code": "--flagStones :: Fractional a => a -> a -> a -> a\nflagStones n m a = (ceiling $ n / a) * (ceiling $ m / a)\n\nmain = do\n str <- getLine\n let [n, m, a] = map read . words $ str :: [Double]\n print $ flagStones n m a"}, {"source_code": "#! /usr/bin/runhaskell\nmodule Main where\nimport System.IO\nmain = do\n s <- getLine\n let rs = (map read (words s)) :: [Integer]\n let n = head rs\n m = head (tail rs)\n a = last rs\n in putStrLn $ show (ff n a * ff m a)\n\n\nff :: Integer -> Integer -> Integer\nff n a = if n `mod` a == 0 then n `div` a\n else n `div` a + 1 \n"}, {"source_code": "module Main (\n main\n) where\n\nimport Data.Int\n\nsolve :: Int64 -> Int64 -> Int64 -> Int64\nsolve n m a = (n `div1` a) * (m `div1` a)\n where\n div1 x y = (x + y - 1) `quot` y\n\nmain :: IO ()\nmain = do\n [n, m, a] <- getInts\n print $ solve n m a\n\ngetInts :: IO [Int64]\ngetInts = (map read . words) `fmap` getLine :: IO [Int64]"}, {"source_code": "main = do\n [n,m,a] <- fmap (map read . words) $ getLine :: IO [Integer]\n print $ (floor n a) * (floor m a)\n where floor x y = (x + y - 1) `div` y"}, {"source_code": "import GHC.Int\n\nconvert :: Read a => String -> [a]\nconvert = map read . words\n\nmain :: IO ()\nmain = do\n line <- getLine\n let [n, m, a] = convert line :: [GHC.Int.Int64]\n let x = (n - 1) `div` a + 1\n let y = (m - 1) `div` a + 1\n print (x * y) "}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n\nimport Data.List.Split\n \nmain :: IO()\nmain = do \n line :: String <- getLine\n let x = map read $ splitOn \" \" line :: [Integer]\n let f = \\[a,b,c] -> ((-a) `div` c) * ((-b) `div` c)\n print (f x)\n"}], "negative_code": [{"source_code": "squares n m a\n | mod n a == 0 = (div n a ) * divma\n | mod n a /= 0 = (div n a + 1) * divma\n where\n divma = if div m a <= 0 then 1 else div m a + 1\n \nmain = do\n numbers <- getLine\n let n = read ((words numbers) !! 0) :: Int\n let m = read ((words numbers) !! 1) :: Int\n let a = read ((words numbers) !! 2) :: Int\n print (squares n m a)\n"}, {"source_code": "main :: IO ()\nmain = do\n\t--nmpStr <- readFile \"input.txt\"\n\tnmpStr <- getLine\n\tlet n : m : p : [] = map (read :: String -> Int) $ words nmpStr\n\tprint ((if ((mod n p) /= 0) then (div n p + 1) else div n p) * (if ((mod m p) /= 0) then (div m p + 1) else div m p))\n\treturn ()"}, {"source_code": "import System.Environment(getArgs)\n\np1a :: Double -> Double -> Double -> Int\np1a n m a = ceiling (n / a) * ceiling (m / a)\n\nmain :: IO ()\nmain = do cons <- getContents\n let [n, m, a] = fmap read $ words cons\n print $ p1a n m a"}, {"source_code": "module Main where\n\n\n\nimport IO\nimport GHC.Base\n\n\nmain = do \n\n s <- getLine\n (m:n:a) <- return $ map readint $ split s ' '\n --m1 <- getLine\n --n1 <- getLine\n --a1 <- getLine\n \n \n print $ ( (m `roundInt` head a) * (n `roundInt` head a))\nroundInt :: Int -> Int -> Int\nroundInt a b | a `modInt` b == 0 = a `divInt` b\n | otherwise = a`divInt`b + 1\n--readseq :: String -> [Int]\n--readseq = read\nsplit :: String -> Char -> [String]\nsplit [] delim = [\"\"]\nsplit (c:cs) delim\n | c == delim = \"\" : rest\n | otherwise = (c : head rest) : tail rest\n where\n rest = split cs delim\nreadint :: String -> Int\nreadint = read"}, {"source_code": "main = do\n [n,m,a] <- fmap (map read . words) $ getLine :: IO [Int]\n print $ (floor n a) * (floor m a)\n where floor x y = (x + y - 1) `div` y"}, {"source_code": "import Control.Applicative\n\ntileCount:: (Integral a) => a -> a-> a\ntileCount length side\n | modulus == 0 = quotient\n | otherwise = quotient + 1\n where \n modulus = length `mod` side\n quotient = length `div` side\n\nreadInt :: String -> Int\nreadInt = read\n\nmain = do\n [m, n, a] <- (map readInt . words) <$> getLine\n print ((tileCount m a) * (tileCount n a))\n"}, {"source_code": "--import Helpers\n--import Data.String.Utils\n\n{-\nindicate :: String -> String\nindicate address = \n if address == \"127.0.0.1\" then \"localhost\" else address\n-}\n{-\nindicate :: String -> String\nindicate \"127.0.0.1\" = \"localhost\"\nindicate address = address\n-}\nparseInt :: String -> Int\nparseInt x = read x :: Int\n\nsolve:: Int -> Int -> Int -> Int\nsolve n m a = (ceilDiv n a) * (ceilDiv m a)\n\nceilDiv :: Int -> Int -> Int\nceilDiv x y = (div x y) + (if (mod x y) > 0 then 1 else 0)\n\nmain :: IO ()\nmain = do\n --let input = \"6 6 4\"\n input <- getLine :: IO String\n let parsed = map parseInt $ words input\n --print parsed\n print $ solve (head parsed) (head $ tail parsed) (head $ tail $ tail parsed)"}, {"source_code": "main = print \"foobarba\"\n"}, {"source_code": "f :: [String] -> [Int]\nf = map read \n\ntileCount:: (Integral a) => a -> a-> a\ntileCount length side\n | modulus == 0 = quotient\n | otherwise = quotient + 1\n where \n modulus = length `mod` side\n quotient = length `div` side\n \nmain = do\n z <- getLine\n let [m, n, a] = f (words z) \n print ((tileCount m a) * (tileCount n a))"}, {"source_code": "import System.Environment\n\nsolve n m a =\n hline * vline\n where\n hadd = if n `mod` a > 0 then 1 else 0\n vadd = if m `mod` a > 0 then 1 else 0\n hline = n `div` a + hadd\n vline = m `div` a + vadd\n\nreadInts :: IO [Int]\nreadInts = fmap (map read.words) getLine\n\nmain = do\n (n:m:a:rest) <- readInts\n putStrLn (show $ solve n m a)\n"}, {"source_code": "solve :: Int -> Int -> Int\nsolve x y = (x + y - 1) `div` y\n\nmain = do\n line <- getLine\n let [n, m, a] = map read $ words line\n print $ ((solve n a) * (solve m a))\n \n"}, {"source_code": "module Main (\n main\n) where\n\nimport Data.Maybe\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BS8\n\nsolve :: Int -> Int -> Int -> Int\nsolve n m a = (n `div1` a) * (m `div1` a)\n where\n div1 x y = (x `div` y) + if (x `mod` y) == 0 then 0 else 1\n\nmain :: IO ()\nmain = do\n [n, m, a] <- getInts\n print $ solve n m a\n\ngetInts :: IO [Int]\ngetInts = fmap (map readInt . BS8.words) BS.getLine\n where\n readInt = fst . fromJust . BS8.readInt"}, {"source_code": "import Control.Monad\n\nmain :: IO ()\nmain = do\n line <- getLine\n let n:m:a:xs = fmap (\\x -> read x :: Int) $ words line\n print ((coveringStones n a) * (coveringStones m a))\n\ncoveringStones :: Int -> Int -> Int\ncoveringStones l a = (div l a) + if (mod l a == 0) then 0 else 1"}, {"source_code": "main = print \"foo\"\n"}, {"source_code": "(|>) a b = b a\n\nf n m a =\n ceiling ((fromIntegral n) / (fromIntegral a))\n + ceiling ((fromIntegral m) / (fromIntegral a))\n\nmain = do\n s <- getLine \n let a = s |> words |> map (read :: String -> Int) \n f (a !! 0) (a !! 1) (a !! 2) |> print"}, {"source_code": "--import Helpers\n--import Data.String.Utils\n\n{-\nindicate :: String -> String\nindicate address = \n if address == \"127.0.0.1\" then \"localhost\" else address\n-}\n{-\nindicate :: String -> String\nindicate \"127.0.0.1\" = \"localhost\"\nindicate address = address\n-}\nparseInt :: String -> Int\nparseInt x = read x :: Int\n\nsolve:: Int -> Int -> Int -> Int\nsolve n m a = (ceilDiv n a) * (ceilDiv m a)\n\nceilDiv :: Int -> Int -> Int\nceilDiv x y = (div x y) + (if (mod x y) > 0 then 1 else 0)\n\nmain :: IO ()\nmain = do\n --let input = \"6 6 4\"\n input <- getLine :: IO String\n let parsed = map parseInt $ words input\n --print parsed\n print $ solve (head parsed) (head $ tail parsed) (head $ tail $ tail parsed)"}, {"source_code": "main = do\n\tinput <- getLine\n\tlet n = read $ [input !! 0]\n\tlet m = read $ [input !! 2]\n\tlet a = read $ [input !! 4]\n\tputStrLn $ show $ (ceiling(n / a)) * (ceiling(m / a))"}, {"source_code": "module Main where\n\nmain :: IO ()\nmain = do\n input <- getLine\n print $ (solve.words) input\n\nsolve :: [String] -> Int\nsolve input = let\n ints = map read input :: [Int]\n [n, m, a] = ints\n nAdd = if div n a == 0 then 0 else 1\n mAdd = if div m a == 0 then 0 else 1\n nPlit = div n a \n mPlit = div m a\n in\n (nPlit + nAdd) * (mPlit + mAdd)\n"}, {"source_code": "solve :: Int -> Int -> Int -> Int\nsolve n m a = squares n a * squares m a\nsquares :: Int -> Int -> Int\nsquares x a\n | x `mod` a == 0 = x `div` a\n | otherwise = x `div` a + 1\nmain = do\n numsStr <- getLine\n let [n, m, a] = map read $ words numsStr\n print $ solve n m a\n"}, {"source_code": "solve :: [Int] -> Int\nsolve [x, y, a] = (x' + x `quot` a)*(y' + y `quot` a)\n where x' = if x `rem` a == 0 then 0 else 1\n y' = if y `rem` a == 0 then 0 else 1\n \nmain = interact (show . solve . map read . words)"}, {"source_code": "{-# LANGUAGE BangPatterns, ViewPatterns, PatternGuards, ScopedTypeVariables #-}\n{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeSynonymInstances #-}\n{-# LANGUAGE ForeignFunctionInterface #-}\n\nimport Control.Applicative\nimport Control.Monad\nimport Data.Int\nimport Foreign\nimport Foreign.C\nimport qualified System.IO.Unsafe as U\n\nmain :: IO ()\nmain = do\n [n, m, a] :: [Int] <- replicateM 3 input\n print $ ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n--------------------------------------------------\n-- Helper functions\n--------------------------------------------------\nfor_ :: Int -> Int -> (Int -> IO ()) -> IO ()\nfor_ begin end k = loop begin\n where\n loop !i = when (i < end) $ k i >> loop (i + 1)\n\nc_bufsize :: Int\nc_bufsize = 2 ^ 16\n\n{-# NOINLINE g_buffer #-}\ng_buffer :: Ptr ()\ng_buffer = U.unsafePerformIO $ mallocBytes c_bufsize\n\nclass Input a where\n input :: IO a\n\ninstance Input Int where\n input = do\n scan_i c_format_i g_buffer'\n peek g_buffer'\n where\n g_buffer' = castPtr g_buffer :: Ptr Int\n\nforeign import ccall unsafe \"stdio.h scanf\" scan_i :: CString -> Ptr Int -> IO ()\n\n{-# NOINLINE c_format_i #-}\nc_format_i :: CString\nc_format_i = U.unsafePerformIO $ newCString \"%d\"\n\ninstance Input Int64 where\n input = do\n scan_i64 c_format_i64 g_buffer'\n peek g_buffer'\n where\n g_buffer' = castPtr g_buffer :: Ptr Int64\n\nforeign import ccall unsafe \"stdio.h scanf\" scan_i64 :: CString -> Ptr Int64 -> IO ()\n\n{-# NOINLINE c_format_i64 #-}\nc_format_i64 :: CString\nc_format_i64 = U.unsafePerformIO $ newCString \"%I64d\"\n\ninstance Input String where\n input = do\n scan_s c_format_s g_buffer'\n peekCString g_buffer'\n where\n g_buffer' = castPtr g_buffer :: CString\n\nforeign import ccall unsafe \"stdio.h scanf\" scan_s :: CString -> CString -> IO ()\n\n{-# NOINLINE c_format_s #-}\nc_format_s :: CString\nc_format_s = U.unsafePerformIO $ newCString \"%s\"\n\n"}, {"source_code": "module Main where\nmain = do\n inpStr <- getLine\n let [n, m, a] = readIntList inpStr\n print $ solve n m a\n\n\nreadIntList :: String -> [Int]\nreadIntList = fmap read . words\n\nsolve :: Int -> Int -> Int -> Int\nsolve n m a = (divUp n a) * (divUp m a)\n\ndivUp :: (Integral i) => i -> i -> i\ndivUp a b = (a + b - 1) `div` b"}, {"source_code": "main = putStrLn . show . (\\[a,b,c]->((a+c-1) `div` c) * ((b+c - 1 :: Int) `div` c)) . map read . words =<< getLine"}, {"source_code": "module Main where\n\ncompute :: Int -> Int -> Int -> Int\ncompute n m a = ceiling (toRational n / toRational a) * ceiling (toRational m / toRational a)\n\nmain :: IO ()\nmain = do\n\tinput <- getLine\n\tlet tokens = words input;\n\t\tn = read (tokens !! 0);\n\t\tm = read (tokens !! 1);\n\t\ta = read (tokens !! 2) in\n\t\tputStrLn (show (compute n m a))\n"}, {"source_code": "--BEGIN--\nmod' :: Int -> Int -> Int\nmod' x y | (y > x) = x\n | otherwise = mod' (x - y) y\n\n_div' :: Int -> Int -> Int -> Int\n_div' x y k | (y > x) = k\n | otherwise = _div' (x - y) y (k + 1)\n\ndiv' :: Int -> Int -> Int\ndiv' x y = _div' x y 0\n\nmain :: IO ()\nmain = do\n-- nmaStr <- readFile \"input.txt\"\n nmaStr <- getLine\n let n : m : a : [] = map (read :: String -> Int) $ words nmaStr\n\n let x = div' n a\n let y = div' m a\n\n let x' = if ((mod' n a) /= 0) then (x + 1) else x\n let y' = if ((mod' m a) /= 0) then (y + 1) else y\n\n print (x' * y')\n\n return ()\n--END--"}, {"source_code": "module Main where\n\nimport Control.Monad (sequence)\nimport qualified Data.ByteString.Char8 as BS\n\nmain :: IO ()\nmain = do\n result <- (fmap (map fst)\n . sequence\n . map BS.readInt\n . BS.words) `fmap` BS.getLine\n case result of\n Just (n : m : a : _)\n | flagstoneArea == 1 -> print area\n | flagstoneArea > area -> print 1\n | otherwise -> print ((area `div` flagstoneArea) ^ 2)\n where\n area = n * m\n flagstoneArea = a * a\n Nothing -> error (\"err: invalid input \" ++ show result)\n"}, {"source_code": "f[n,m,a] = (-n `div` a) * (-m `div` a)\nmain = interact $ show.f.map read.words"}, {"source_code": "import Control.Monad\n\nfn a x n\n | a * x > n = a\n | otherwise = fn (a+1) x n\n\nmain = do\n l <- liftM words getLine\n let [n,m,a] = map read l :: [Int]\n -- print (n,m,a)\n\n let w = fn 1 4 n\n let h = fn 1 4 m\n -- print (w,h)\n print (w*h)\n\n"}, {"source_code": "solve :: [Int] -> Int\nsolve [x, y, a] = (x' + x `quot` a)*(y' + y `quot` a)\n where x' = if x `rem` a == 0 then 0 else 1\n y' = if y `rem` a == 0 then 0 else 1\n \nmain = interact (show . solve . map read . words)"}, {"source_code": "squares n m a\n | mod n a == 0 = (div n a ) * divma\n | mod m a /= 0 = (div n a + 1) * divma\n where\n divma = if div m a == 0 then 1 else div m a + 1\n \nmain = do\n numbers <- getLine\n let n = read ((words numbers) !! 0) :: Int\n let m = read ((words numbers) !! 1) :: Int\n let a = read ((words numbers) !! 2) :: Int\n print (squares n m a)\n"}, {"source_code": "module Main (\n main\n) where\n\nimport Data.Maybe\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BS8\n\nsolve :: Int -> Int -> Int -> Int\nsolve n m a = (n `div1` a) * (m `div1` a)\n where\n div1 x y = (x + y - 1) `quot` y\n\nmain :: IO ()\nmain = do\n [n, m, a] <- getInts\n print $ solve n m a\n\ngetInts :: IO [Int]\ngetInts = fmap (map readInt . BS8.words) BS.getLine\n where\n readInt = fst . fromJust . BS8.readInt"}, {"source_code": "\na meiapal resto\n | null resto = (meiapal, resto)\n | otherwise = (\\(r:rs)->if r==' ' then (meiapal, rs) else a (meiapal++[r]) rs) resto\n\npri resu rest\n | null rest = (resu, rest)\n | otherwise = (\\(pal, resto)->pri (resu++[pal]) resto) (a [] rest)\n\nsepara str = fst (pri [] str)\n\nsq n m a\n | a==1 = m*n\n | (mod n a) == 0 = sq (n-1) m a\n | (mod m a) == 0 = sq n (m-1) a\n | otherwise = ((div m a)+1)*((div n a)+1)\n\nsqn l = let a:b:c:_=l in sq a b c\n\n\nmain = do\n s <- getLine\n putStrLn (show(sqn (let readInt a = read a::Int in map readInt (separa s))))\n"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n\nimport Data.List.Split\n \nmain :: IO()\nmain = do \n line :: String <- getLine\n let x = map read $ splitOn \" \" line :: [Int]\n print $ (((x !! 0) + (x !! 2) - 1) `quot` (x !! 2) *\n ((x !! 1) + (x !! 2) - 1) `quot` (x !! 2))\n"}, {"source_code": "import Control.Applicative\nmain= do\n\t[n,m,a]<- map read. words <$> getLine:: IO [Int]\n\tlet x = ( div n a) + if ( mod n a ==0) then 0 else 1\n\tlet y = ( div m a) + if ( mod m a ==0) then 0 else 1\n\tprint $ x*y\n"}, {"source_code": "solve [ n, m, a ] = ( n `div` a ) * ( m `div` a )\nmain = interact $ show . solve . map read . words"}, {"source_code": "module Main where\n\nreadParams :: String -> [Int]\nreadParams line = map (\\part -> read part) (split line)\n\nsplit :: String -> [[Char]]\nsplit [] = [\"\"]\nsplit (c:cs)\n\t| c == ' ' = \"\" : rest\n\t| otherwise = (c : head rest) : tail rest\n\twhere\n rest = split cs\n\nsol :: Int -> Int -> Int -> Int\nsol n m a = h * w\n\twhere\n\t\tceil c d = (c+d-1) `div` d\n\t\th = ceil m a\n\t\tw = ceil n a\n\nmain::IO()\nmain = do\n\tinputStr <- getLine\n\tlet params = readParams inputStr in putStrLn $ show $ sol (params !! 0) (params !! 1) (params !! 2)\n"}, {"source_code": "--import Helpers\n--import Data.String.Utils\n\n{-\nindicate :: String -> String\nindicate address = \n if address == \"127.0.0.1\" then \"localhost\" else address\n-}\n{-\nindicate :: String -> String\nindicate \"127.0.0.1\" = \"localhost\"\nindicate address = address\n-}\nparseInt :: String -> Int\nparseInt x = read x :: Int\n\nsolve:: Int -> Int -> Int -> Int\nsolve n m a = (ceilDiv n a) * (ceilDiv m a)\n\nceilDiv :: Int -> Int -> Int\nceilDiv x y = (div x y) + (if (mod x y) > 0 then 1 else 0)\n\nmain :: IO ()\nmain = do\n --let input = \"6 6 4\"\n input <- getLine :: IO String\n let parsed = map parseInt $ words input\n --print parsed\n print $ solve (head parsed) (head $ tail parsed) (head $ tail $ tail parsed)"}, {"source_code": "solve :: Int -> Int -> Int\nsolve x y = (x + y - 1) `div` y\n\nmain = do\n line <- getLine\n let [n, m, a] = map read $ words line\n print $ ((solve n a) * (solve m a))\n \n"}, {"source_code": "import Control.Applicative\nmain= do\n\t[n,m,a]<- map read. words <$> getLine:: IO [Int]\n\tlet x = ( div n a) + if ( mod n a ==0) then 0 else 1\n\tlet y = ( div m a) + if ( mod m a ==0) then 0 else 1\n\tprint $ x*y\n"}, {"source_code": "module Main where\n\nimport Data.Int (Int64)\n\n\nmain :: IO ()\nmain = mapM_ (print . (\\[m, n, a] -> f m n a) . map read . words) . lines =<< getContents\n\n\nf :: Int64 -> Int64 -> Int64 -> Int64\nf n m a = round (fromIntegral n / fromIntegral a) * round (fromIntegral m / fromIntegral a)\n"}, {"source_code": "\nmain :: IO ()\nmain = do\n cnt <- getLine\n let [n, m , a] = map read $ words cnt\n print $ bla n m a \n\n\nbla :: Int -> Int -> Int -> Int\nbla n m a = div n a + div m a + tmp + tmp2\n where\n tmp = if mod n a /= 0 then 1 else 0\n tmp2 = if mod m a /= 0 then 1 else 0\n"}, {"source_code": "ans :: [Integer] -> Integer\nans (x : (y : (z : xs))) = ((x + z - 1) `div` z) * ((y + z - 1) `div` z)\n\nmain = do\n d <- getLine\n print (show (ans (map read (words d))))\n"}, {"source_code": "module Main where\n\nimport Control.Monad (sequence)\nimport qualified Data.ByteString.Char8 as BS\n\nmain :: IO ()\nmain = do\n result <- (fmap (map fst)\n . sequence\n . map BS.readInt\n . BS.words) `fmap` BS.getLine\n case result of\n Just (n : m : a : _)\n | flagstoneArea == 1 -> print area\n | flagstoneArea > area -> print 1\n | otherwise ->\n print ((ceiling ((fromIntegral n) / (fromIntegral a))) *\n (ceiling ((fromIntegral m) / (fromIntegral a))))\n where\n area = n * m\n flagstoneArea = a * a\n Nothing -> error (\"err: invalid input \" ++ show result)\n"}, {"source_code": "module Main where\n\nf :: [Int] -> Int\nf [n,m,a] = (div (n+a-1) a) + (div (m+a-1) a)\n\n\nmain = do\n a <- getLine\n print $ f $ map read $ words a\n \n"}, {"source_code": "import Data.Char\n--flagStones :: Fractional a => a -> a -> a -> a\nflagStones n m a = (ceiling $ n / a) * (ceiling $ m / a)\n\nmain = do\n str <- getLine\n let n = fromIntegral . digitToInt . head $ str\n m = fromIntegral . digitToInt $ str !! 2\n a = fromIntegral . digitToInt . last $ str\n print $ flagStones n m a\n"}, {"source_code": "import Data.List\n\nsolve :: [Int] -> Int\nsolve [n, m, a] = (div (n + a - 1) a) * (div (m + a - 1) a)\n\n--splitTokens :: String -> [String]\n--splitTokens \"\" = []\n--splitTokens (x:xs) = getTokens (x:xs) \"\"\n-- where getTokens \"\" s = [s]\n-- getTokens (y:ys) s = if y == ' ' the\nmain = do\n z <- getLine\n putStrLn $ show $ solve $ map read (words z)\n"}, {"source_code": "to_int_array :: String -> [Int]\nto_int_array str = (map read) (words str)\n\nget_count :: Int -> Int -> Int\nget_count n a = if mod n a == 0 then div n a else div n a + 1\n\nget_all_counts :: [Int] -> Int\nget_all_counts a = get_count (a!!0) (a!!2) * get_count (a!!0) (a!!2)\n\nget_count_string :: String -> String\nget_count_string s = show(get_all_counts(to_int_array s))\n\nmain = interact(get_count_string)"}, {"source_code": "module Main (\n main\n) where\n\nimport Data.Maybe\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BS8\n\nsolve :: Int -> Int -> Int -> Int\nsolve n m a = (n `div1` a) * (m `div1` a)\n where\n div1 x y = (x `div` y) + if (x `mod` y) == 0 then 0 else 1\n\nmain :: IO ()\nmain = do\n [n, m, a] <- getInts\n print $ solve n m a\n\ngetInts :: IO [Int]\ngetInts = fmap (map readInt . BS8.words) BS.getLine\n where\n readInt = fst . fromJust . BS8.readInt"}, {"source_code": "import Control.Monad\n\nfn a x n\n | a * x > n = a\n | otherwise = fn (a+1) x n\n\nmain = do\n l <- liftM words getLine\n let [n,m,a] = map read l :: [Int]\n -- print (n,m,a)\n\n let w = fn 1 a n\n let h = fn 1 a m\n -- print (w,h)\n print (w*h)\n\n"}, {"source_code": "module Main where\n\nreadParams :: String -> [Int]\nreadParams line = map (\\part -> read part) (split line)\n\nsplit :: String -> [[Char]]\nsplit [] = [\"\"]\nsplit (c:cs)\n\t| c == ' ' = \"\" : rest\n\t| otherwise = (c : head rest) : tail rest\n\twhere\n rest = split cs\n\nsol :: Int -> Int -> Int -> Int\nsol n m a = h * w\n\twhere\n\t\tceil c d = (c+d-1) `div` d\n\t\th = ceil m a\n\t\tw = ceil n a\n\nmain::IO()\nmain = do\n\tinputStr <- getLine\n\tlet params = readParams inputStr in putStrLn $ show $ sol (params !! 0) (params !! 1) (params !! 2)\n"}, {"source_code": "main = print \"foobarbaaaaacaaaaaaaaaaaaaa\"\n"}, {"source_code": "import Control.Monad\nsplitBy :: Char -> [Char] -> [[Char]]\nsplitBy del = foldr f [[]]\n where f c l@(x:xs) | c == del = []:l\n | otherwise = (c:x):xs\nstrToInts :: [Char] -> [Int]\nstrToInts = (map read).(splitBy ' ')\ngetIntLine :: IO [Int]\ngetIntLine = liftM strToInts getLine\n\nudiv :: Int -> Int -> Int\nudiv a b = quot (a + b - 1) b\n\nsolve (a:b:c:xs) = udiv a c * (udiv b c)\n\nmain = do\n x <- getIntLine\n ans <- return $ solve x\n print ans"}, {"source_code": "\nmain = interact $ solve . toInts . head . lines\n where\n toInts :: String -> [Int]\n toInts = map read . words\n solve [n, m, a] = show $ ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)"}, {"source_code": "solve :: [Int] -> Int\nsolve [x, y, a] = x'*y'\n where x' = ceiling $ (fromIntegral x) / (fromIntegral a)\n y' = ceiling $ (fromIntegral y) / (fromIntegral a)\n \nmain = interact (show . solve . map read . words) "}, {"source_code": "squares n m a\n | mod n a == 0 = (div n a ) * divma\n | mod n a /= 0 = (div n a + 1) * divma\n where\n divma = if div m a <= 1 then 1 else div m a + 1\n \nmain = do\n numbers <- getLine\n let n = read ((words numbers) !! 0) :: Int\n let m = read ((words numbers) !! 1) :: Int\n let a = read ((words numbers) !! 2) :: Int\n print (squares n m a)\n"}, {"source_code": "import System.Environment(getArgs)\n\np1a :: Double -> Double -> Double -> Int\np1a n m a = ceiling (n / a) * ceiling (m / a)\n\nmain :: IO ()\nmain = do cons <- getContents\n let [n, m, a] = fmap read $ words cons\n print $ p1a n m a"}, {"source_code": "main = print \"\"\n"}, {"source_code": "module Main where\n\nimport Control.Applicative\n\nf :: Integer -> Integer -> Integer -> Integer\nf n m a = g n a * g m a\n where\n g x y = x `div` y + 1\n\nmain :: IO ()\nmain = do\n (n:m:a:_) <- words <$> getLine\n putStrLn $ show $ f (read n) (read m) (read a)\n"}, {"source_code": "f [n, m, a] = (-n / a) * (-m / a)\n\nmain = interact $ show.f.map read.words"}, {"source_code": "findFlagstoneNumber :: Int -> Int -> Int -> Int\nfindFlagstoneNumber n m a\n = div (n + a - 1) a\n * div (m + a - 1) a\n\nsolve :: String -> String\nsolve str \n = ( show\n $ findFlagstoneNumber\n (read $ args !! 0)\n (read $ args !! 1)\n (read $ args !! 2)\n ) ++ \"\\n\"\n where args = words str\n\nmain :: IO ()\nmain = interact solve\n"}, {"source_code": "main = print \"\"\n"}, {"source_code": "module Main where\n\ncalcSquaresNeeded :: Integer -> Integer -> Integer -> Integer\ncalcSquaresNeeded n m a = maximum [1, n `div` a + (rest n a)] * maximum [1, m `div` a + (rest m a)]\n\nrest :: Integer -> Integer -> Integer\nrest n a \n | n `mod` a > 0 = 1\n | otherwise = 0\n\nmain = do\n s <- getLine\n let input = words s\n print $ show (calcSquaresNeeded (read (input !! 0) :: Integer) (read (input !! 1) :: Integer) (read (input !! 2) :: Integer))"}, {"source_code": "main = do\n [n, a, b] <- fmap (map read . words) getLine\n print $ ((div (a + n - 1) n) * (div (b + n - 1) n))"}, {"source_code": "solve :: Int -> Int -> Int\nsolve x y = (x + y - 1) `div` y\n\nmain = do\n line <- getLine\n let [n, m, a] = map read $ words line\n print $ ((solve n a) * (solve m a))\n \n"}, {"source_code": "module Main where\n\ncalcSquaresNeeded n m a = maximum [1, n `div` a + (rest n a)] * maximum [1, m `div` a + (rest m a)]\n\nrest n a \n | n `mod` a > 0 = 1\n | otherwise = 0\n\nmain = do\n s <- getLine\n let input = words s\n print $ show (calcSquaresNeeded (read (input !! 0) :: Integer) (read (input !! 1) :: Integer) (read (input !! 2) :: Integer))"}, {"source_code": "module Main where\n\nmain :: IO ()\nmain = do\n input <- getLine\n print $ (solve.words) input\n\nsolve :: [String] -> Int\nsolve input = let\n ints = map read input :: [Int]\n [n, m, a] = ints\n nAdd = if mod n a == 0 then 0 else 1\n mAdd = if mod m a == 0 then 0 else 1\n nPlit = div n a \n mPlit = div m a\n in\n (nPlit + nAdd) * (mPlit + mAdd)\n"}, {"source_code": "main :: IO ()\nmain = interact func\n\nfunc :: String -> String\nfunc s = show . func' . map read $ words s\n\nfunc' :: [Int] -> Int\nfunc' (n:m:a:[]) = (m `div` a + (m `dived` a)) * (n `div` a + (n `dived` a))\n where dived x y = if x `mod` y == 0 then 0 else 1\nfunc' _ = error \"\"\n"}, {"source_code": "main = do\n\tcontents <- getContents\n\tlet\n\t numbers = map (\\str -> read str :: Int) $ words contents\n\t n = numbers !! 0\n\t m = numbers !! 1\n\t k = numbers !! 2\n\tprint $ toInteger $ f n k * f m k\n\nf :: Int -> Int -> Int\nf n k = if n `mod` k == 0\n\tthen n `div` k\n\telse (n `div` k) + 1\n\n"}, {"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n\nimport Data.List.Split\n \nmain :: IO()\nmain = do \n line :: String <- getLine\n let x = map read $ splitOn \" \" line :: [Int]\n print $ (((x !! 0) + (x !! 2) - 1) `quot` (x !! 2) *\n ((x !! 1) + (x !! 2) - 1) `quot` (x !! 2))\n"}, {"source_code": "import Control.Applicative\n\ntileCount:: (Integral a) => a -> a-> a\ntileCount length side\n | modulus == 0 = quotient\n | otherwise = quotient + 1\n where \n modulus = length `mod` side\n quotient = length `div` side\n\nreadInt :: String -> Int\nreadInt = read\n\nmain = do\n [m, n, a] <- (map readInt . words) <$> getLine\n print ((tileCount m a) * (tileCount n a))\n"}, {"source_code": "parseString :: String -> [Int]\nparseString str = map (\\x -> read x::Int) $ words str\n\nsolution :: Int -> Int -> Int -> Int\nsolution n m a = (fst x1 + y x1) * (fst x2 + y x2)\n where \n x1 = divMod n a \n x2 = divMod m a\n y x = if snd x == 0 then 0 else 1\n\nmain :: IO()\nmain = do\n a <- getLine\n print $ solution ((ps a)!!0) ((ps a)!!1) ((ps a)!!2)\n where ps = parseString"}, {"source_code": "main :: IO ()\nmain = do\n [n, m, a] <- fmap (map read . words) getLine :: IO [Int]\n let r = if (n * m) /= 0 then 1 else 0\n p = (div n a) + r \n q = (div m a) + r \n print (p * q)\n \n\n"}, {"source_code": "calc :: Int -> Int -> Int\ncalc a c = ceiling $ (fromIntegral $ a)/(fromIntegral $ c)\n\nsolve :: String -> String\nsolve s = show $ (calc a c) * (calc b c)\n where [a, b, c] = map read (words s)\n\nmain = do\n --input <- getContents\n interact $ solve\n --putStrLn $ a\n --let [a, b, c] = map read (splitOn \" \" input)\n --let n = calc a c\n --putStrLn $ show $ (calc a c) * (calc b c)\n"}, {"source_code": "import System.Environment(getArgs)\n\np1a :: Double -> Double -> Double -> Int\np1a n m a = ceiling (n / a) * ceiling (m / a)\n\nmain :: IO ()\nmain = do cons <- getContents\n let [n, m, a] = fmap read $ words cons\n print $ p1a n m a"}, {"source_code": "solve :: [Float] -> Int\nsolve (n:m:a:_) = ceiling (n / a) * ceiling (m / a)\n\n\nmain = do\n xs <- fmap (map read . words) getLine\n print $ solve xs\n"}, {"source_code": "import qualified Data.ByteString.Char8 as B\nimport Data.Maybe\n\ngetThreeIntsM = map (fst . fromJust . B.readInt) . B.words <$> B.getLine\n\ncover x a = x `div` a + (if x `rem` a == 0 then 0 else 1)\n\nmain = \n do\n [n, m, a] <- getThreeIntsM\n putStrLn . show $ (cover n a) * (cover m a)\n "}, {"source_code": "main = print \"foobar\"\n"}, {"source_code": "main = do\n [n,m,a] <- fmap (map read . words) $ getLine :: IO [Int]\n print $ (floor n a) * (floor m a)\n where floor x y = (x + y - 1) `div` y"}, {"source_code": "\n\ncalcSquaresNeeded n m a = maximum [1, n `div` a + (rest n a)] * maximum [1, m `div` a + (rest m a)]\n\nrest n a \n | n `mod` a > 0 = 1\n | otherwise = 0\n\nmain = do\n s <- getLine\n let input = words s\n print $ show (calcSquaresNeeded (read (input !! 0) :: Integer) (read (input !! 1) :: Integer) (read (input !! 2) :: Integer))"}, {"source_code": "main = print \"foobarbaaa\"\n"}, {"source_code": "main = print \"foobarbaaaaacacsadahogea\"\n"}, {"source_code": "main = print \"foobarbaaaaacacsada\"\n"}, {"source_code": "squares n m a\n | mod n a == 0 = (div n a ) * divma\n | mod n a /= 0 = (div n a + 1) * divma\n where\n divma = if div m a <= 1 then 1 else div m a + 1\n \nmain = do\n numbers <- getLine\n let n = read ((words numbers) !! 0) :: Int\n let m = read ((words numbers) !! 1) :: Int\n let a = read ((words numbers) !! 2) :: Int\n print (squares n m a)\n"}, {"source_code": "main = print 1"}, {"source_code": "f :: [String] -> [Int]\nf = map read \n\n--tileCount:: (Integral a) => a -> a-> a\ntileCount length side\n | modulus == 0 = quotient\n | otherwise = quotient + 1\n where \n modulus = length `mod` side\n quotient = length `div` side\n\nmain = do\n z <- getLine\n let [m, n, a] = f (words z) \n print ((tileCount m a) * (tileCount n a))"}, {"source_code": "ans :: [Integer] -> Integer\nans (x : (y : (z : xs))) = (x `div` z) * (y `div` z)\n\nmain = do\n d <- getLine\n print (show (ans (map read (words d))))\n"}, {"source_code": "import Data.Char\n\nmain = do\n\tline <- getLine\n\tlet n:m:a:xs = getInts 3 line\n\tprint $ (ceil n a)*(ceil m a)\n\nceil :: Int -> Int -> Int\n\nceil x y = div (x - 1 + y) y\n\ngetInts :: Int -> String -> [Int]\n\ngetInts 0 _ = []\ngetInts _ [] = []\ngetInts x str = map stringToInt $ take x $ words str\n\nstringToInt :: String -> Int\n\nstringToInt [] = 0\nstringToInt str = 10*(stringToInt $ init str) + digitToInt (last str)\n"}, {"source_code": "main :: IO ()\nmain = do\n s <- getLine\n putStrLn $ (coverSquare' . (map read) . words) s\n return ()\n\ncoverSquare' :: [Int] -> String\ncoverSquare' [n,m,a] = show $ coverSquare n m a\ncoverSquare' _ = \"coverSquare': Invalid number of arguments.\"\n\ncoverSquare :: Int -> Int -> Int -> Int\ncoverSquare n m a = (n `quot'` a) * (m `quot'` a)\n where\n c `quot'` d = (c `quot` d) + (if c `rem` d > 0 then 1 else 0)\n"}, {"source_code": "--BEGIN--\nmod' :: Int -> Int -> Int\nmod' x y | (y > x) = x\n | otherwise = mod' (x - y) y\n\n_div' :: Int -> Int -> Int -> Int\n_div' x y k | (y > x) = k\n | otherwise = _div' (x - y) y (k + 1)\n\ndiv' :: Int -> Int -> Int\ndiv' x y = _div' x y 0\n\nmain :: IO ()\nmain = do\n-- nmaStr <- readFile \"input.txt\"\n nmaStr <- getLine\n let n : m : a : [] = map (read :: String -> Int) $ words nmaStr\n\n let x = div' n a\n let y = div' m a\n\n let x' = if ((mod' n a) /= 0) then (x + 1) else x\n let y' = if ((mod' m a) /= 0) then (y + 1) else y\n\n print (x' * y')\n\n return ()\n--END--"}, {"source_code": "solve :: Int -> Int -> Int\nsolve x y = (x + y - 1) `div` y\n\nmain = do\n line <- getLine\n let [n, m, a] = map read $ words line\n print $ ((solve n a) * (solve m a))\n \n"}, {"source_code": "import Control.Applicative\nmain= do\n\t[n,m,a]<- map read. words <$> getLine:: IO [Int]\n\tlet x= 1+ ( div n a)\n\tlet y = 1+ (div m a)\n\tprint $ x*y\n"}, {"source_code": "-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n-- File Name : 0001A.hs\n-- Creation Date : 17-10-2012\n-- Last Modified : Fri 19 Oct 2012 01:33:40 PM EEST\n-- Created By : Greg Liras \n--_._._._._._._._._._._._._._._._._._._._._.\n\n{-# OPTIONS_GHC -O2 -optc-O2 #-}\n\nimport Data.Char (isSpace)\nimport qualified Data.ByteString as BS\nimport qualified Data.ByteString.Char8 as BSC\n\n\nmain :: IO ()\nmain = \n do\n all <- BS.getContents\n let Just (n, r1) = readInt all\n let Just (m, r2) = readInt r1\n let Just (a, _) = readInt r2\n let x = fromIntegral $ floor $ (fromIntegral n / fromIntegral a) * (fromIntegral m / fromIntegral a)\n print $ x*x\n where \n readInt s = BSC.readInt (BSC.dropWhile isSpace s)\n readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)\n readMany readf s = case readf s of\n Just (x, r) -> let \n (xs, t) = readMany readf r\n in \n (x : xs, t)\n Nothing -> ([], s)\n"}, {"source_code": "main=interact$show.(\\[a,b,c]->div(-c)a*div(-c)b).map read.words"}, {"source_code": "\nf :: Int -> Int -> Int -> Int\nf a b c = (*) (div (a + c - 1) c) (div (b + c - 1) c)\n\nmain = do\n str <- getLine\n {-print $ show $ words str-}\n let [a, b, c] = map (read::String->Int) $ words str\n print $ f a b c\n {-print a-}\n"}, {"source_code": "main = print \"foobarbaaaaacacsadahogebala\"\n"}, {"source_code": "findSquare :: Integer -> Integer -> Integer\nfindSquare squareArea a = findSquare' 1\n where\n findSquare' n = if (n * n) * (a * a) > squareArea then (n*n) else findSquare' (n + 1)\n\nmain = do\n line <- getLine\n let [n, m, a] = map (read :: String -> Integer) . words $ line\n\n print $ findSquare (n * m) a\n"}, {"source_code": "import Control.Applicative\n\npave :: [Double] -> Int\npave [m, n, a] = ceiling (m / a) * ceiling (n / a)\n\nmain = do\n\tpave <$> map read <$> fmap words getLine >>= print"}, {"source_code": "import Control.Monad\n\nfn a x n\n | a * x > n = a\n | otherwise = fn (a+1) x n\n\nmain = do\n l <- liftM words getLine\n let [n,m,a] = map read l :: [Int]\n -- print (n,m,a)\n\n let w = fn 1 4 n\n let h = fn 1 4 m\n -- print (w,h)\n print (w*h)\n\n"}, {"source_code": "import Control.Monad\n\nmain = do\n l <- liftM words getLine\n let [n,m,a] = map read l :: [Int]\n -- print (n,m,a)\n\n let as = map (*a) [1..]\n let w = (\\x -> div x a) $ head $ dropWhile (<= m) as\n let h = (\\x -> div x a) $ head $ dropWhile (<= n) as\n print (w*h)\n"}, {"source_code": "\n\nmodule Main where\n\nmain :: IO ()\nmain = do\n args <- getLine\n let (m:n:a:xs) = map read (splitOn args)\n print (func m n a)\n\nsplitOn :: String -> [String]\nsplitOn list = lines (map (\\x -> if x == ' ' then '\\n' else x) list)\n\n\n\nintRead :: String -> Int\nintRead = read \n\nfunc :: Int -> Int -> Int -> Int\nfunc n m a =\n nPlates + mPlates\n where\n nPlates = n `div` a + nRemainder\n mPlates = m `div` a + mRemainder\n nRemainder = if n `mod` a > 0\n then 1\n else 0\n mRemainder = if m `mod` a > 0\n then 1\n else 0\n"}], "src_uid": "ef971874d8c4da37581336284b688517"} {"source_code": "main :: IO ()\nmain = putStrLn . unwords . map show . solve . map read . words =<< getContents\n\nsolve :: [Int] -> [Int]\nsolve [n, _, b, c, d, e, _] = [x, y, z]\n where x = min b (n - c - e); y = min d (n - x - e); z = n - x - y\nsolve _ = undefined\n", "positive_code": [{"source_code": "{-# LANGUAGE ScopedTypeVariables #-}\n\nimport Control.Applicative\n\nsolve n0 n1 n2 x0 x1 x2 k =\n let\n k0 = min x0 (k - n1 - n2) \n k1 = min x1 (k - k0 - n2)\n k2 = k - k0 - k1\n in \n [k0, k1, k2]\n\nmain = do\n [k, n0, x0, n1, x1, n2, x2]::[Int] <- map read . words <$> getContents\n putStrLn . unwords . map show $ solve n0 n1 n2 x0 x1 x2 k\n"}, {"source_code": "import Control.Applicative\n\nsolve :: Int -> [Int] -> [Int] -> [Int] -> [Int]\nsolve n [min1,max1] [min2,max2] [min3,max3] =\n [min1 + min rest1 (max1 - min1), min2 + min rest2 (max2 - min2), min3 + min rest3 (max3 - min3)]\n where\n rest1 = n - min1 - min2 - min3\n rest2 = rest1 - min (max1 - min1) rest1\n rest3 = rest2 - min (max2 - min2) rest2\n\nmain :: IO ()\nmain = do\n n <- readLn\n fst <- map read . words <$> getLine\n snd <- map read . words <$> getLine\n trd <- map read . words <$> getLine\n putStrLn . unwords . map show $ solve n fst snd trd\n"}, {"source_code": "main :: IO()\nmain = mapM_ print . solve . map read . words =<< getContents\n\nsolve :: [Int] -> [Int]\nsolve (n:a1:a2:b1:b2:c1:c2) = \n let a = min (n - b1 - c1) a2\n b = min (n - a - c1) b2\n c = n - a - b\n in [a, b, c]\n"}, {"source_code": "-- http://codeforces.com/problemset/problem/557/A\nimport Data.List\n\ngetLines :: Int -> IO [String]\ngetLines 0 = return []\ngetLines n = do\n\tl <- getLine\n\tls <- getLines (n-1)\n\treturn (l:ls)\n\n------------------\n\nmain = do\n\tn <- fmap read $ getLine :: IO Int\n\t((m1:mx1:_):(m2:mx2:_):(m3:mx3:_):_) <-\n\t\tfmap (map (map read))\n\t\t$ fmap (map words)\n\t\t$ getLines 3 :: IO [[Int]]\n\n\tlet\n\t\tfd = min (n-m2-m3) mx1 -- First distribution\n\t\tsd = min (n-fd-m3) mx2 -- Second distribution\n\t\ttd = min (n - fd - sd) mx3 -- Third distribution\n\n\tputStrLn $ intercalate \" \" $ map show $ [fd,sd,td]\n"}, {"source_code": "{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}\n{-# OPTIONS_GHC -O2 #-}\n\nimport Control.Applicative\nimport Control.Monad hiding ((<$!>))\nimport Control.Monad.ST.Safe\nimport Control.Monad.State hiding ((<$!>))\n-- import Data.Array\nimport Data.Array.IArray\nimport Data.Array.IO.Safe\nimport Data.Array.MArray.Safe\nimport Data.Array.ST.Safe\nimport Data.Array.Unboxed\nimport qualified Data.ByteString.Char8 as B\nimport qualified Data.ByteString.Lazy.Builder as BB\nimport Data.Char\nimport qualified Data.Foldable as F\nimport Data.Function\nimport Data.Graph\nimport Data.Int\nimport Data.List\nimport Data.List.Split\nimport Data.Maybe\nimport Data.Monoid\nimport Data.Ord\nimport Data.Ratio\nimport qualified Data.Sequence as Seq\nimport Data.Sequence (Seq)\nimport Data.Set (Set)\nimport qualified Data.Set as Set\nimport Data.IntSet (IntSet)\nimport qualified Data.IntSet as IntSet\n-- import Data.Tree\nimport Data.Tuple\nimport Data.Map.Strict (Map)\nimport qualified Data.Map.Strict as Map\nimport Data.HashMap.Strict (HashMap)\nimport qualified Data.HashMap.Strict as HashMap\nimport Data.IntMap (IntMap)\nimport qualified Data.IntMap as IntMap\n-- import Debug.Trace\nimport System.IO\n\n-- getInts = fmap (map read . words) getLine\ngetInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine\n\nmain = do\n n <- readLn\n [min1, max1] <- getInts\n [min2, max2] <- getInts\n [min3, max3] <- getInts\n\n let\n a = min max1 (n - min2 - min3)\n n' = n-a\n b = min max2 (n' - min3)\n c = n' - b\n\n putStrLn $ show a ++ \" \" ++ show b ++ \" \" ++ show c\n\n"}, {"source_code": "\nparse :: String -> (Int, Int, Int, Int, Int, Int, Int)\nparse contents = (s, a, b, c, d, e, f) where [s, a, b, c, d, e, f] = map read . words $ contents\n\nmain :: IO ()\nmain = putStrLn . unwords . map show . solve . parse =<< getContents\n\nsolve :: (Int, Int, Int, Int, Int, Int, Int) -> [Int]\nsolve (s, a, b, c, d, e, f)\n | s-c-e <= b = [s-c-e, c, e]\n | s-b-e <= d = [b, s-b-e, e]\n | otherwise = [b, d, s-b-d]\n"}, {"source_code": "import Data.Char (ord)\nimport Data.List\n\nreadInt :: String -> Int\nreadInt = foldl' (\\s d -> s * 10 + ord d - 48) 0\n\nparse :: String -> (Int, Int, Int, Int, Int, Int, Int)\nparse contents = (s, a, b, c, d, e, f) where [s, a, b, c, d, e, f] = map readInt . words $ contents\n\nmain :: IO ()\nmain = putStrLn . nopa . solve . parse =<< getContents\n\nnopa :: (Int, Int, Int) -> String\nnopa (a, b, c) = show a ++ \" \" ++ show b ++ \" \" ++ show c\n\nsolve ::(Int, Int, Int, Int, Int, Int, Int) -> (Int, Int, Int)\nsolve (s, a, b, c, d, e, f)\n | s-c-e <= b = (s-c-e, c, e)\n | s-b-e <= d = (b, s-b-e, e)\n | otherwise = (b, d, s-b-d)\n"}, {"source_code": "import Data.List\nanswer::Int -> Int -> Int -> Int -> Int -> Int -> Int -> [Int]\nanswer n mn0 mx0 mn1 mx1 mn2 mx2 | mn0+mn1+mn2 == n = [mn0,mn1,mn2]\n | mx0+mn1+mn2 >= n = [n-mn1-mn2,mn1,mn2]\n | mx0+mx1+mn2 >= n = [mx0,n-mx0-mn2,mn2]\n | mx0+mx1+mx2 >= n = [mx0,mx1,n-mx0-mx1]\n | otherwise = [mx0,mx1,mx2]\nmain = do\n w0 <- getLine\n let n = read w0::Int\n w1 <- getLine\n let ww1 = words w1\n let mn0 = read (ww1 !! 0)::Int\n let mx0 = read (ww1 !! 1)::Int\n w2 <- getLine\n let ww2 = words w2\n let mn1 = read (ww2 !! 0)::Int\n let mx1 = read (ww2 !! 1)::Int\n w3 <- getLine\n let ww3 = words w3\n let mn2 = read (ww3 !! 0)::Int\n let mx2 = read (ww3 !! 1)::Int\n putStrLn $ intercalate \" \" (map show (answer n mn0 mx0 mn1 mx1 mn2 mx2))\n\n\n \n"}, {"source_code": "-- Codeforces 557A\n\nimport Data.List (intercalate)\n\nmain :: IO ()\nmain = getContents >>= putStrLn . intercalate \" \" . map show . solve . map read . words\n\nsolve :: [Int] -> [Int]\nsolve [n, min1, max1, min2, max2, min3, max3]\n | max1+min2+min3 >= n = [n-min2-min3, min2, min3]\n | max1+max2+min3 >= n = [max1, n-max1-min3, min3]\n | otherwise = [max1, max2, n-max1-max2]\n"}, {"source_code": "import Data.List\n\ngetList = fmap (map read . words) getLine\ngetValue = fmap read getLine\n\nmain = do\n n <- getValue\n [a, b] <- getList\n [c, d] <- getList\n [e, f] <- getList\n let k1 = min b (n-c-e); n2 = n - k1; k2 = min d (n2-e); n3 = n2 - k2; k3 = min f n3\n let ks = [k1, k2, k3]\n putStrLn . intercalate \" \" . map show $ ks\n"}, {"source_code": "import Control.Applicative\nimport Data.List\n\n \n\nmain= do\n\t n<- read <$> getLine::IO Int\n\t [a1,a2]<-map read. words <$> getLine::IO [Int]\n\t [b1,b2]<-map read. words <$> getLine::IO [Int] \n\t [c1,c2]<-map read. words <$> getLine::IO [Int]\n\t let nn = n-a1-b1-c1\n\t let a3= min nn (a2-a1)\n\t let b3 =max 0 (min (nn-a3) (b2-b1))\n let c3= max 0 (min (nn-a3-b3) (c2-c1))\n\t putStrLn $ intercalate \" \" $ map show [a1+a3,b1+b3,c1+c3]\n\t "}, {"source_code": "type Input = (Int, [(Int, Int)])\n\nparse :: String -> Input\nparse contents = (n, [(min1, max1), (min2, max2), (min3, max3)])\n where [n, min1, max1, min2, max2, min3, max3] = map read . words $ contents\n\nsolve :: Input -> [Int]\nsolve (_, []) = []\nsolve (n, (_, ma) : cs) = a : solve (n - a, cs)\n where a = min ma (n - sum (map fst cs))\n\npprint :: [Int] -> IO ()\npprint = putStrLn . unwords . map show\n\nmain :: IO ()\nmain = pprint . solve . parse =<< getContents\n"}], "negative_code": [{"source_code": "-- http://codeforces.com/problemset/problem/557/A\nimport Data.List\n\ngetLines :: Int -> IO [String]\ngetLines 0 = return []\ngetLines n = do\n\tl <- getLine\n\tls <- getLines (n-1)\n\treturn (l:ls)\n\n------------------\n\nmain = do\n\tn <- fmap read $ getLine :: IO Int\n\t((m1:mx1:_):(m2:mx2:_):(m3:mx3:_):_) <-\n\t\tfmap (map (map read))\n\t\t$ fmap (map words)\n\t\t$ getLines 3 :: IO [[Int]]\n\n\tlet\n\t\tfd = min (n-m2-m3) mx1 -- First distribution\n\t\tsd = min (fd+m3) mx2 -- Second distribution\n\t\ttd = n - fd - sd -- Third distribution\n\n\tputStrLn $ intercalate \" \" $ map show $ [fd,sd,td]\n"}], "src_uid": "3cd092b6507079518cf206deab21cf97"}