program z1; {$APPTYPE CONSOLE} uses SysUtils; var a:array[1..250] of char; p:byte;c:char; procedure Add(C:Char); begin dec(p); a[p]:=c end; function Get:Char; begin Result:=a[p]; inc(p) end; function Send(C:Char):boolean; var G:Char; begin if C in ['(','['] then begin Add(C); Result:=True end else begin G:=Get; Result:=((G='(')and(C=')'))or((G='[')and(C=']')) end; end; begin { TODO -oUser -cConsole Main : Insert code here } p:=251; repeat Read(C); if not(c in ['(',')','[',']']) then Break; if not Send(C) then begin Write('NO');Exit end; until not(c in ['(',')','[',']']); Write('YES'); end.