#include <iostream>
#include <string>
#include <stack>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
while(1) {
string s;
getline(cin,s);
if(s==".") break;
stack<char> sta;
int is_vps=1;
for(auto c : s) {
if(c=='[' || c=='(') sta.push(c);
else if(c==']') {
if(sta.empty() || sta.top()=='(') {
is_vps=0;
break;
}
sta.pop();
} else if(c==')') {
if(sta.empty() || sta.top()=='[') {
is_vps=0;
break;
}
sta.pop();
}
}
if(is_vps && sta.empty()) cout << "yes\n";
else cout << "no\n";
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: