SHARE
TWEET

Untitled

a guest Jan 21st, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from collections import deque
  2.  
  3. if __name__ == "__main__":
  4.     symbols_deq = deque(input())
  5.     check = 'YES'
  6.     if len(symbols_deq) % 2 == 0 and symbols_deq:
  7.         while symbols_deq:
  8.             j = ord(symbols_deq.popleft())
  9.             k = ord(symbols_deq[0])
  10.             if (j == 40 and k == 41) or (j == 123 and k == 125) or (j == 91 and k == 93):
  11.                 symbols_deq.popleft()
  12.             else:
  13.                 i = ord(symbols_deq.pop())
  14.                 if (i == 125 and j != 123) or (i == 123 and j != 125):
  15.                     check = 'NO'
  16.                 if (i == 93 and j != 91) or (i == 91 and j != 93):
  17.                     check = 'NO'
  18.                 if (i == 41 and j != 40) or (i == 40 and j != 41):
  19.                     check = 'NO'
  20.     else:
  21.         check = 'NO'
  22.     print(check)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top