完整代码

s = input()

def calc(s):
  l = []
  for e in s:
    if e =='(' or e == '[':
      l.append(e)
    elif e == ']':
      if len(l) > 0:
        t = l[len(l) - 1]
        if t != '[':
          return False
        l = l[0: len(l) - 1]
      else:
        return False
    elif e == ')':
      if len(l) > 0:
        t = l[len(l) - 1]
        if t != '(':
          return False
        l = l[0: len(l) - 1]
      else:
        return False
  return True
if calc(s):
  print('true')
else:
  print('false')