import sys
lines = sys.stdin.readlines()
for line in lines :
if line == "." :
continue
stack = []
balanced = True
for i in line :
if i in "[(" :
stack.append(i)
elif i == "]" :
if not stack or stack[-1] != "[" :
balanced = False
break
stack.pop()
elif i == ")" :
if not stack or stack[-1] != "(" :
balanced = False
break
stack.pop()
stack.clear()
if balanced and not stack :
print("yes")
else :
print("no")
To embed this project on your website, copy the following code and paste it into your website's HTML: