problem
solution
codes
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main(){
stack<char>s;
string str; cin>>str;
bool flag = 1;
for(int i = 0; i < str.size(); i++){
if(str[i] == '(')s.push('(');
else if(str[i] == ')' && !s.empty())s.pop();
else if(str[i] == ')' && s.empty()){ flag = 0; break; }
}
if(s.empty() && flag)cout<<"YES
";//md答案写反了
else cout<<"NO
";
return 0;
}