<s> import operator <EOL> def _thread_ident ( ) : <EOL> return - <NUM_LIT:1> <EOL> n = <NUM_LIT:30> <EOL> LFTLNK = n <EOL> RGTLNK = n + <NUM_LIT:1> <EOL> BLOCKSIZ = n + <NUM_LIT:2> <EOL> class deque : <EOL> def __new__ ( cls , iterable = ( ) , * args , ** kw ) : <EOL> self = object . __new__ ( cls , * args , ** kw ) <EOL> self . clear ( ) <EOL> return self <EOL> def __init__ ( self , iterable = ( ) , maxlen = None ) : <EOL> object . __init__ ( self ) <EOL> self . clear ( ) <EOL> if maxlen is not None : <EOL> if maxlen < <NUM_LIT:0> : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> self . _maxlen = maxlen <EOL> add = self . append <EOL> for elem in iterable : <EOL> add ( elem ) <EOL> @ property <EOL> def maxlen ( self ) : <EOL> return self . _maxlen <EOL> def clear ( self ) : <EOL> self . right = self . left = [ None ] * BLOCKSIZ <EOL> self . rightndx = n // <NUM_LIT:2> <EOL> self . leftndx = n // <NUM_LIT:2> + <NUM_LIT:1> <EOL> self . length = <NUM_LIT:0> <EOL> self . state = <NUM_LIT:0> <EOL> def append ( self , x ) : <EOL> self . state += <NUM_LIT:1> <EOL> self . rightndx += <NUM_LIT:1> <EOL> if self . rightndx == n : <EOL> newblock = [ None ] * BLOCKSIZ <EOL> self . right [ RGTLNK ] = newblock <EOL> newblock [ LFTLNK ] = self . right <EOL> self . right = newblock <EOL> self . rightndx = <NUM_LIT:0> <EOL> self . length += <NUM_LIT:1> <EOL> self . right [ self . rightndx ] = x <EOL> if self . maxlen is not None and self . length > self . maxlen : <EOL> self . popleft ( ) <EOL> def appendleft ( self , x ) : <EOL> self . state += <NUM_LIT:1> <EOL> self . leftndx -= <NUM_LIT:1> <EOL> if self . leftndx == - <NUM_LIT:1> : <EOL> newblock = [ None ] * BLOCKSIZ <EOL> self . left [ LFTLNK ] = newblock <EOL> newblock [ RGTLNK ] = self . left <EOL> self . left = newblock <EOL> self . leftndx = n - <NUM_LIT:1> <EOL> self . length += <NUM_LIT:1> <EOL> self . left [ self . leftndx ] = x <EOL> if self . maxlen is not None and self . length > self . maxlen : <EOL> self . pop ( ) <EOL> def extend ( self , iterable ) : <EOL> if iterable is self : <EOL> iterable = list ( iterable ) <EOL> for elem in iterable : <EOL> self . append ( elem ) <EOL> def extendleft ( self , iterable ) : <EOL> if iterable is self : <EOL> iterable = list ( iterable ) <EOL> for elem in iterable : <EOL> self . appendleft ( elem ) <EOL> def pop ( self ) : <EOL> if self . left is self . right and self . leftndx > self . rightndx : <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> x = self . right [ self . rightndx ] <EOL> self . right [ self . rightndx ] = None <EOL> self . length -= <NUM_LIT:1> <EOL> self . rightndx -= <NUM_LIT:1> <EOL> self . state += <NUM_LIT:1> <EOL> if self . rightndx == - <NUM_LIT:1> : <EOL> prevblock = self . right [ LFTLNK ] <EOL> if prevblock is None : <EOL> self . rightndx = n // <NUM_LIT:2> <EOL> self . leftndx = n // <NUM_LIT:2> + <NUM_LIT:1> <EOL> else : <EOL> prevblock [ RGTLNK ] = None <EOL> self . right [ LFTLNK ] = None <EOL> self . right = prevblock <EOL> self . rightndx = n - <NUM_LIT:1> <EOL> return x <EOL> def popleft ( self ) : <EOL> if self . left is self . right and self . leftndx > self . rightndx : <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> x = self . left [ self . leftndx ] <EOL> self . left [ self . leftndx ] = None <EOL> self . length -= <NUM_LIT:1> <EOL> self . leftndx += <NUM_LIT:1> <EOL> self . state += <NUM_LIT:1> <EOL> if self . leftndx == n : <EOL> prevblock = self . left [ RGTLNK ] <EOL> if prevblock is None : <EOL> self . rightndx = n // <NUM_LIT:2> <EOL> self . leftndx = n // <NUM_LIT:2> + <NUM_LIT:1> <EOL> else : <EOL> prevblock [ LFTLNK ] = None <EOL> self . left [ RGTLNK ] = None <EOL> self . left = prevblock <EOL> self . leftndx = <NUM_LIT:0> <EOL> return x <EOL> def count ( self , value ) : <EOL> c = <NUM_LIT:0> <EOL> for item in self : <EOL> if item == value : <EOL> c += <NUM_LIT:1> <EOL> return c <EOL> def remove ( self , value ) : <EOL> for i in range ( len ( self ) ) : <EOL> if self [ i ] == value : <EOL> del self [ i ] <EOL> return <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> def rotate ( self , n = <NUM_LIT:1> ) : <EOL> length = len ( self ) <EOL> if length == <NUM_LIT:0> : <EOL> return <EOL> halflen = ( length + <NUM_LIT:1> ) >> <NUM_LIT:1> <EOL> if n > halflen or n < - halflen : <EOL> n %= length <EOL> if n > halflen : <EOL> n -= length <EOL> elif n < - halflen : <EOL> n += length <EOL> while n > <NUM_LIT:0> : <EOL> self . appendleft ( self . pop ( ) ) <EOL> n -= <NUM_LIT:1> <EOL> while n < <NUM_LIT:0> : <EOL> self . append ( self . popleft ( ) ) <EOL> n += <NUM_LIT:1> <EOL> def reverse ( self ) : <EOL> "<STR_LIT>" <EOL> leftblock = self . left <EOL> rightblock = self . right <EOL> leftindex = self . leftndx <EOL> rightindex = self . rightndx <EOL> for i in range ( self . length // <NUM_LIT:2> ) : <EOL> assert leftblock != rightblock or leftindex < rightindex <EOL> ( rightblock [ rightindex ] , leftblock [ leftindex ] ) = ( <EOL> leftblock [ leftindex ] , rightblock [ rightindex ] ) <EOL> leftindex += <NUM_LIT:1> <EOL> if leftindex == n : <EOL> leftblock = leftblock [ RGTLNK ] <EOL> assert leftblock is not None <EOL> leftindex = <NUM_LIT:0> <EOL> rightindex -= <NUM_LIT:1> <EOL> if rightindex == - <NUM_LIT:1> : <EOL> rightblock = rightblock [ LFTLNK ] <EOL> assert rightblock is not None <EOL> rightindex = n - <NUM_LIT:1> <EOL> def __repr__ ( self ) : <EOL> threadlocalattr = '<STR_LIT>' + str ( _thread_ident ( ) ) <EOL> if threadlocalattr in self . __dict__ : <EOL> return '<STR_LIT>' <EOL> else : <EOL> self . __dict__ [ threadlocalattr ] = True <EOL> try : <EOL> if self . maxlen is not None : <EOL> return '<STR_LIT>' % ( list ( self ) , self . maxlen ) <EOL> else : <EOL> return '<STR_LIT>' % ( list ( self ) , ) <EOL> finally : <EOL> del self . __dict__ [ threadlocalattr ] <EOL> def __iter__ ( self ) : <EOL> return deque_iterator ( self , self . _iter_impl ) <EOL> def _iter_impl ( self , original_state , giveup ) : <EOL> if self . state != original_state : <EOL> giveup ( ) <EOL> block = self . left <EOL> while block : <EOL> l , r = <NUM_LIT:0> , n <EOL> if block is self . left : <EOL> l = self . leftndx <EOL> if block is self . right : <EOL> r = self . rightndx + <NUM_LIT:1> <EOL> for elem in block [ l : r ] : <EOL> yield elem <EOL> if self . state != original_state : <EOL> giveup ( ) <EOL> block = block [ RGTLNK ] <EOL> def __reversed__ ( self ) : <EOL> return deque_iterator ( self , self . _reversed_impl ) <EOL> def _reversed_impl ( self , original_state , giveup ) : <EOL> if self . state != original_state : <EOL> giveup ( ) <EOL> block = self . right <EOL> while block : <EOL> l , r = <NUM_LIT:0> , n <EOL> if block is self . left : <EOL> l = self . leftndx <EOL> if block is self . right : <EOL> r = self . rightndx + <NUM_LIT:1> <EOL> for elem in reversed ( block [ l : r ] ) : <EOL> yield elem <EOL> if self . state != original_state : <EOL> giveup ( ) <EOL> block = block [ LFTLNK ] <EOL> def __len__ ( self ) : <EOL> return self . length <EOL> def __getref ( self , index ) : <EOL> if index >= <NUM_LIT:0> : <EOL> block = self . left <EOL> while block : <EOL> l , r = <NUM_LIT:0> , n <EOL> if block is self . left : <EOL> l = self . leftndx <EOL> if block is self . right : <EOL> r = self . rightndx + <NUM_LIT:1> <EOL> span = r - l <EOL> if index < span : <EOL> return block , l + index <EOL> index -= span <EOL> block = block [ RGTLNK ] <EOL> else : <EOL> block = self . right <EOL> while block : <EOL> l , r = <NUM_LIT:0> , n <EOL> if block is self . left : <EOL> l = self . leftndx <EOL> if block is self . right : <EOL> r = self . rightndx + <NUM_LIT:1> <EOL> negative_span = l - r <EOL> if index >= negative_span : <EOL> return block , r + index <EOL> index -= negative_span <EOL> block = block [ LFTLNK ] <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> def __getitem__ ( self , index ) : <EOL> block , index = self . __getref ( index ) <EOL> return block [ index ] <EOL> def __setitem__ ( self , index , value ) : <EOL> block , index = self . __getref ( index ) <EOL> block [ index ] = value <EOL> def __delitem__ ( self , index ) : <EOL> length = len ( self ) <EOL> if index >= <NUM_LIT:0> : <EOL> if index >= length : <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> self . rotate ( - index ) <EOL> self . popleft ( ) <EOL> self . rotate ( index ) <EOL> else : <EOL> index = index ^ ( <NUM_LIT:2> ** <NUM_LIT> ) <EOL> if index >= length : <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> self . rotate ( index ) <EOL> self . pop ( ) <EOL> self . rotate ( - index ) <EOL> def __reduce_ex__ ( self , proto ) : <EOL> return type ( self ) , ( list ( self ) , self . maxlen ) <EOL> def __hash__ ( self ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> def __copy__ ( self ) : <EOL> return self . __class__ ( self , self . maxlen ) <EOL> def __eq__ ( self , other ) : <EOL> if isinstance ( other , deque ) : <EOL> return list ( self ) == list ( other ) <EOL> else : <EOL> return NotImplemented <EOL> def __ne__ ( self , other ) : <EOL> if isinstance ( other , deque ) : <EOL> return list ( self ) != list ( other ) <EOL> else : <EOL> return NotImplemented <EOL> def __lt__ ( self , other ) : <EOL> if isinstance ( other , deque ) : <EOL> return list ( self ) < list ( other ) <EOL> else : <EOL> return NotImplemented <EOL> def __le__ ( self , other ) : <EOL> if isinstance ( other , deque ) : <EOL> return list ( self ) <= list ( other ) <EOL> else : <EOL> return NotImplemented <EOL> def __gt__ ( self , other ) : <EOL> if isinstance ( other , deque ) : <EOL> return list ( self ) > list ( other ) <EOL> else : <EOL> return NotImplemented <EOL> def __ge__ ( self , other ) : <EOL> if isinstance ( other , deque ) : <EOL> return list ( self ) >= list ( other ) <EOL> else : <EOL> return NotImplemented <EOL> def __iadd__ ( self , other ) : <EOL> self . extend ( other ) <EOL> return self <EOL> class deque_iterator ( object ) : <EOL> def __init__ ( self , deq , itergen ) : <EOL> self . counter = len ( deq ) <EOL> def giveup ( ) : <EOL> self . counter = <NUM_LIT:0> <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> self . _gen = itergen ( deq . state , giveup ) <EOL> def next ( self ) : <EOL> res = self . _gen . next ( ) <EOL> self . counter -= <NUM_LIT:1> <EOL> return res <EOL> def __iter__ ( self ) : <EOL> return self <EOL> class defaultdict ( dict ) : <EOL> def __init__ ( self , * args , ** kwds ) : <EOL> if len ( args ) > <NUM_LIT:0> : <EOL> default_factory = args [ <NUM_LIT:0> ] <EOL> args = args [ <NUM_LIT:1> : ] <EOL> if not callable ( default_factory ) and default_factory is not None : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> else : <EOL> default_factory = None <EOL> dict . __init__ ( self , args , kwds ) <EOL> self . default_factory = default_factory <EOL> self . update ( args , kwds ) <EOL> super ( defaultdict , self ) . __init__ ( * args , ** kwds ) <EOL> def __missing__ ( self , key ) : <EOL> if self . default_factory is None : <EOL> raise KeyError ( key ) <EOL> self [ key ] = value = self . default_factory ( ) <EOL> return value <EOL> def __repr__ ( self , recurse = set ( ) ) : <EOL> if id ( self ) in recurse : <EOL> return "<STR_LIT>" <EOL> try : <EOL> recurse . add ( id ( self ) ) <EOL> return "<STR_LIT>" % ( repr ( self . default_factory ) , super ( defaultdict , self ) . __repr__ ( ) ) <EOL> finally : <EOL> recurse . remove ( id ( self ) ) <EOL> def copy ( self ) : <EOL> return type ( self ) ( self . default_factory , self ) <EOL> def __copy__ ( self ) : <EOL> return self . copy ( ) <EOL> def __reduce__ ( self ) : <EOL> return ( type ( self ) , ( self . default_factory , ) , None , None , self . items ( ) ) <EOL> from operator import itemgetter as _itemgetter <EOL> from keyword import iskeyword as _iskeyword <EOL> import sys as _sys <EOL> def namedtuple ( typename , field_names , verbose = False , rename = False ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( field_names , str ) : <EOL> field_names = field_names . replace ( '<STR_LIT:U+002C>' , '<STR_LIT:U+0020>' ) . split ( ) <EOL> field_names = tuple ( map ( str , field_names ) ) <EOL> if rename : <EOL> names = list ( field_names ) <EOL> seen = set ( ) <EOL> for i , name in enumerate ( names ) : <EOL> if ( not min ( c . isalnum ( ) or c == '<STR_LIT:_>' for c in name ) or _iskeyword ( name ) <EOL> or not name or name [ <NUM_LIT:0> ] . isdigit ( ) or name . startswith ( '<STR_LIT:_>' ) <EOL> or name in seen ) : <EOL> names [ i ] = '<STR_LIT>' % i <EOL> seen . add ( name ) <EOL> field_names = tuple ( names ) <EOL> for name in ( typename , ) + field_names : <EOL> if not min ( c . isalnum ( ) or c == '<STR_LIT:_>' for c in name ) : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> if _iskeyword ( name ) : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> if name [ <NUM_LIT:0> ] . isdigit ( ) : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> seen_names = set ( ) <EOL> for name in field_names : <EOL> if name . startswith ( '<STR_LIT:_>' ) and not rename : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> if name in seen_names : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> seen_names . add ( name ) <EOL> numfields = len ( field_names ) <EOL> argtxt = repr ( field_names ) . replace ( "<STR_LIT:'>" , "<STR_LIT>" ) [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> reprtxt = '<STR_LIT:U+002CU+0020>' . join ( '<STR_LIT>' % name for name in field_names ) <EOL> template = '''<STR_LIT>''' % locals ( ) <EOL> for i , name in enumerate ( field_names ) : <EOL> template += '<STR_LIT>' % ( name , i ) <EOL> if verbose : <EOL> print ( template ) <EOL> namespace = dict ( _itemgetter = _itemgetter , __name__ = '<STR_LIT>' % typename , <EOL> _property = property , _tuple = tuple ) <EOL> try : <EOL> exec ( template , namespace ) <EOL> except SyntaxError as e : <EOL> raise SyntaxError ( e . message + '<STR_LIT>' + template ) <EOL> result = namespace [ typename ] <EOL> try : <EOL> result . __module__ = _sys . _getframe ( <NUM_LIT:1> ) . f_globals . get ( '<STR_LIT>' , '<STR_LIT:__main__>' ) <EOL> except ( AttributeError , ValueError ) : <EOL> pass <EOL> return result <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> Point = namedtuple ( '<STR_LIT>' , [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> p = Point ( <NUM_LIT:11> , y = <NUM_LIT> ) <EOL> print ( p [ <NUM_LIT:0> ] + p [ <NUM_LIT:1> ] ) <EOL> x , y = p <EOL> print ( x , y ) <EOL> print ( p . x + p . y ) <EOL> print ( p ) </s>
