栈的操作
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#include <cctype>
#include <unordered_map>
using namespace std;
int main(){
string str;
getline(cin, str);
stack<char> st;
bool flag = true;
int left = 0, right = 0;
for(int i = 0; i < str.size(); i++){
if(str[i]=='(' || str[i]=='{'||str[i]=='[') left++, st.push(str[i]);
else if(str[i]==')'||str[i]=='}'||str[i]==']'){
right++;
if(st.size()){
if(str[i] == ')' && st.top()=='(') st.pop();
else if(str[i] == '}' && st.top() == '{') st.pop();
else if(str[i] == ']' && st.top() == '[') st.pop();
else flag = false;
}else flag = false;
}
}
cout<<left<<" "<<right<<endl;
if(flag && st.empty()) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}