P1739是不是有毒啊 #3 RE
lengthS :: String -> Int -> Bool
lengthS "" n = n == 0
lengthS s n
| n < 0 = False
| head s == '(' = lengthS (tail s) (n + 1)
| head s == ')' = lengthS (tail s) (n - 1)
| otherwise = lengthS (tail s) n
main :: IO()
main = do
src <- getLine
putStrLn $ if lengthS src 0 then "YES" else "NO"