Balanced Brackets (single type)

HARD · C · 3000ms

A group of CS freshmen are experimenting with code snippets in the kiosk's text editor, and Rina needs the editor to flag whether their parentheses are properly balanced before they try to compile anything. Read a string made only of characters '(' and ')'. Print "YES" if the brackets are balanced (every open has a matching close, and never more closes than opens at any prefix), otherwise "NO".

Input

One string S of '(' and ')'.

Output

"YES" or "NO".

Constraints

1 ≤ |S| ≤ 10^5

Sample Input

(()())

Sample Output

YES
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Balanced Brackets (single type) · DIU ContestHub