import Control.Monad change :: [Int] -> [Int] change [y1000,y100,y25,y1] | y1 >= 25 = change (y1000 : y100 : y25+1 : y1-25:[]) | y25 >= 4 = change (y1000 : y100+1 : y25-4 : y1:[]) | y100 >= 10 = change (y1000+1 : y100-10 : y25 : y1:[]) | otherwise = y1000:y100:y25:y1:[] main :: IO () main = do cs <- replicateM 3 readLn :: IO [Int] let cs' = change (0:cs) putStrLn . show $ sum . tail $ cs'