#include <stdio.h>
#include <stdlib.h>
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef struct{
char *base;
char *top;
int stacksize;
}sqStack;
void initStack(sqStack *s)
{
s->base = (char *)malloc(STACK_INIT_SIZE*sizeof(char));
if(!s->base) exit(0);
s->top = s->base;
s->stacksize = STACK_INIT_SIZE;
}
void Push(sqStack *s,char e)
{
if(s->top - s->base >= s->stacksize)
{
s->base = (char*)realloc(s->base,(s->stacksize+STACKINCREMENT)*sizeof(char));
if(!s->base) exit(0);
s->top = s->base + s->stacksize;
s->stacksize+=STACKINCREMENT;
}
*(s->top) = e;
s->top++;
}
void Pop(sqStack *s)
{
if(s->top==s->base) return;
s->top--;
}
void checkStack(sqStack *s,char a[])
{
int i,flag=0;
for(i=0;a[i]!='\0';i++)
{
if(a[i]=='{'||a[i]=='['||a[i]=='(')
{
Push(s,a[i]);
flag=1;
}
else if(a[i]=='}')
{
if(*(s->top-1)=='{')
{
Pop(s);
flag=1;
}
else
{
flag=0;
break;
}
}
else if(a[i]==']')
{
if(*(s->top-1)=='[')
{
Pop(s);
flag=1;
}
else
{
flag=0;
break;
}
}
else if(a[i]==')')
{
if(*(s->top-1)=='(')
{
Pop(s);
flag=1;
}
else
{
flag=0;
break;
}
}
}
if(s->top!=s->base)
flag=0;
if(flag==1) printf("yes\n");
else printf("no\n");
}
int main()
{
sqStack s;
char a[51];
while(gets(a))
{
initStack(&s);//!!!
checkStack(&s,a);
}
return 0;
}