asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T PKfe[wwabc.pynu[from _collections_abc import * from _collections_abc import __all__ from _collections_abc import _CallableGenericAlias PKfe[PF#__pycache__/__init__.cpython-36.pycnu[3 \$@sdZddddddddd g Zd d lTd d lZeej7Zd d lmZmZd dlm Z d d l Z d d l Zd dlmZd dlmZmZmZd dlmZyd dlmZWnek rYn Xej eyd dlm!Z!Wnek rYnXGddde"Z#Gddde$Z%Gddde&Z'Gddde(Z)Gddde*Z+yd dlm+Z+Wnek rXYnXdZ,dZ-d Z.d!d!d d"d#dZ/d$d%Z0yd d&lm0Z0Wnek rYnXGd'dde*Z1Gd(d d e2Z3Gd)dde2Z4Gd*ddeZ5Gd+dde6Z7d S),a?This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, dict, list, set, and tuple. * namedtuple factory function for creating tuple subclasses with named fields * deque list-like container with fast appends and pops on either end * ChainMap dict-like class for creating a single view of multiple mappings * Counter dict subclass for counting hashable objects * OrderedDict dict subclass that remembers the order entries were added * defaultdict dict subclass that calls a factory function to supply missing values * UserDict wrapper around dictionary objects for easier dict subclassing * UserList wrapper around list objects for easier list subclassing * UserString wrapper around string objects for easier string subclassing deque defaultdict namedtupleUserDictUserList UserStringCounter OrderedDictChainMap)*N) itemgettereq) iskeyword)proxy)repeatchainstarmap)recursive_repr)r)rc@seZdZddZdS)_OrderedDictKeysViewccst|jEdHdS)N)reversed_mapping)selfr,/usr/lib64/python3.6/collections/__init__.py __reversed__5sz!_OrderedDictKeysView.__reversed__N)__name__ __module__ __qualname__rrrrrr3src@seZdZddZdS)_OrderedDictItemsViewccs(x"t|jD]}||j|fVq WdS)N)rr)rkeyrrrr:sz"_OrderedDictItemsView.__reversed__N)rrrrrrrrr8src@seZdZddZdS)_OrderedDictValuesViewccs$xt|jD]}|j|Vq WdS)N)rr)rrrrrr@sz#_OrderedDictValuesView.__reversed__N)rrrrrrrrr >sr c@seZdZdZdS)_Linkprevnextr __weakref__N)r"r#rr$)rrr __slots__rrrrr!Dsr!c@seZdZdZddZejeefddZej fddZ dd Z d d Z d d Z d*ddZ d+ddZddZejZZddZddZddZejZeZefddZd,ddZed d!Zd"d#Zd$d%Zed-d&d'Z d(d)Z!dS).rz)Dictionary that remembers insertion orderc Os|s td|^}}t|dkr0tdt|y |jWn>tk rxt|_t|j|_}||_|_i|_ YnX|j ||dS)zInitialize an ordered dictionary. The signature is the same as regular dictionaries. Keyword argument order is preserved. z?descriptor '__init__' of 'OrderedDict' object needs an argumentz$expected at most 1 arguments, got %dN) TypeErrorlen_OrderedDict__rootAttributeErrorr!_OrderedDict__hardroot_proxyr"r#_OrderedDict__map_OrderedDict__update)argskwdsrrootrrr__init__Vs    zOrderedDict.__init__c CsZ||krJ||j|<}|j}|j}||||_|_|_||_|||_||||dS)z!od.__setitem__(i, y) <==> od[i]=yN)r-r)r"r#r) rrvalueZ dict_setitemrZLinklinkr1lastrrr __setitem__is zOrderedDict.__setitem__cCs>||||jj|}|j}|j}||_||_d|_d|_dS)z od.__delitem__(y) <==> del od[y]N)r-popr"r#)rrZ dict_delitemr4 link_prev link_nextrrr __delitem__ws  zOrderedDict.__delitem__ccs,|j}|j}x||k r&|jV|j}qWdS)zod.__iter__() <==> iter(od)N)r)r#r)rr1currrrr__iter__s  zOrderedDict.__iter__ccs,|j}|j}x||k r&|jV|j}qWdS)z#od.__reversed__() <==> reversed(od)N)r)r"r)rr1r;rrrrs  zOrderedDict.__reversed__cCs*|j}||_|_|jjtj|dS)z.od.clear() -> None. Remove all items from od.N)r)r"r#r-cleardict)rr1rrrr=s  zOrderedDict.clearTcCsj|s td|j}|r0|j}|j}||_||_n|j}|j}||_||_|j}|j|=tj||}||fS)zRemove and return a (key, value) pair from the dictionary. Pairs are returned in LIFO order if last is true or FIFO order if false. zdictionary is empty)KeyErrorr)r"r#rr-r>r7)rr5r1r4r8r9rr3rrrpopitems  zOrderedDict.popitemc Cst|j|}|j}|j}|j}||_||_|j}|rR|j}||_||_||_||_n|j}||_||_||_||_dS)zMove an existing element to the end (or beginning if last==False). Raises KeyError if the element does not exist. When last=True, acts like a fast version of self[key]=self.pop(key). N)r-r"r#r)) rrr5r4r8r9Z soft_linkr1firstrrr move_to_ends$ zOrderedDict.move_to_endcCsVtj}t|d}||j}|||jd7}|||j|7}|||j|7}|S)Nr&)_sys getsizeofr(__dict__r-r+r))rZsizeofnsizerrr __sizeof__s  zOrderedDict.__sizeof__cCst|S)z:D.keys() -> a set-like object providing a view on D's keys)r)rrrrkeysszOrderedDict.keyscCst|S)z a set-like object providing a view on D's items)r)rrrritemsszOrderedDict.itemscCst|S)z6D.values() -> an object providing a view on D's values)r )rrrrvaluesszOrderedDict.valuescCs0||kr||}||=|S||jkr,t||S)zod.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. )_OrderedDict__markerr?)rrdefaultresultrrrr7s zOrderedDict.popNcCs||kr||S|||<|S)zDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in odr)rrrNrrr setdefaultszOrderedDict.setdefaultcCs*|sd|jjfSd|jjt|jfS)zod.__repr__() <==> repr(od)z%s()z%s(%r)) __class__rlistrK)rrrr__repr__szOrderedDict.__repr__cCsHt|j}xttD]}|j|dqW|jf|p8ddt|jfS)z%Return state information for picklingN)varscopyrr7rQiterrK)rZ inst_dictkrrr __reduce__s zOrderedDict.__reduce__cCs |j|S)z!od.copy() -> a shallow copy of od)rQ)rrrrrU szOrderedDict.copycCs |}x|D] }|||<q W|S)zOD.fromkeys(S[, v]) -> New ordered dictionary with keys from S. If not specified, the value defaults to None. r)clsiterabler3rrrrrfromkeyss  zOrderedDict.fromkeyscCs2t|tr&tj||o$ttt||Stj||S)zod.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. ) isinstancerr>__eq__allmap_eq)rotherrrrr]s zOrderedDict.__eq__)T)T)N)N)"rrr__doc__r2r>r6r,r!r:r<rr=r@rBrIMutableMappingupdater.rJrKrL__ne__objectrMr7rP_recursive_reprrSrXrU classmethodr[r]rrrrrGs0          )rafrom builtins import property as _property, tuple as _tuple from operator import itemgetter as _itemgetter from collections import OrderedDict class {typename}(tuple): '{typename}({arg_list})' __slots__ = () _fields = {field_names!r} def __new__(_cls, {arg_list}): 'Create new instance of {typename}({arg_list})' return _tuple.__new__(_cls, ({arg_list})) @classmethod def _make(cls, iterable, new=tuple.__new__, len=len): 'Make a new {typename} object from a sequence or iterable' result = new(cls, iterable) if len(result) != {num_fields:d}: raise TypeError('Expected {num_fields:d} arguments, got %d' % len(result)) return result def _replace(_self, **kwds): 'Return a new {typename} object replacing specified fields with new values' result = _self._make(map(kwds.pop, {field_names!r}, _self)) if kwds: raise ValueError('Got unexpected field names: %r' % list(kwds)) return result def __repr__(self): 'Return a nicely formatted representation string' return self.__class__.__name__ + '({repr_fmt})' % self def _asdict(self): 'Return a new OrderedDict which maps field names to their values.' return OrderedDict(zip(self._fields, self)) def __getnewargs__(self): 'Return self as a plain tuple. Used by copy and pickle.' return tuple(self) {field_defs} z {name}=%rzW {name} = _property(_itemgetter({index:d}), doc='Alias for field number {index:d}') F)verboserenamemodulec Cst|tr|jddj}ttt|}t|}|rt}xNt|D]B\}}|j spt |sp|j dsp||kr|d|||<|j |qDWxN|g|D]@}t |tk rt d|jstd|t |rtd|qWt}xJ|D]B}|j do| rtd|||krtd ||j |qWtj|t|t|tt|jd d d dd jdd|Ddjddt|Dd}td|d} t|| | |} || _|rt| j|dkrytjd jjdd}Wnttfk rYnX|dk r || _| S)aCReturns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22) , _z_%dz*Type names and field names must be stringsz8Type names and field names must be valid identifiers: %rz2Type names and field names cannot be a keyword: %rz/Field names cannot start with an underscore: %rz$Encountered duplicate field name: %r'r&z, css|]}tj|dVqdS))nameN)_repr_templateformat).0rqrrr sznamedtuple.. css |]\}}tj||dVqdS))indexrqN)_field_templaters)rtrwrqrrrrus)typename field_names num_fieldsarg_listrepr_fmt field_defsz namedtuple_%s)rNr__main__)r\strreplacesplitrRr_set enumerate isidentifier _iskeyword startswithaddtyper' ValueError_class_templaterstupler(reprjoinr>exec_sourceprintrD _getframe f_globalsgetr*r) ryrzrirjrkseenrwrqclass_definition namespacerOrrrresj               cCs*|j}x|D]}||dd||<q WdS)z!Tally elements from the iterable.r r&N)r)mappingrZZ mapping_getelemrrr_count_elementss r)rcseZdZdZfddZddZd/ddZd d Zed0d d Z fd dZ ddZ ddZ ddZ fddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.ZZS)1raDict subclass for counting hashable items. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values. >>> c = Counter('abcdeabcdabcaba') # count elements from a string >>> c.most_common(3) # three most common elements [('a', 5), ('b', 4), ('c', 3)] >>> sorted(c) # list all unique elements ['a', 'b', 'c', 'd', 'e'] >>> ''.join(sorted(c.elements())) # list elements with repetitions 'aaaaabbbbcccdde' >>> sum(c.values()) # total of all counts 15 >>> c['a'] # count of letter 'a' 5 >>> for elem in 'shazam': # update counts from an iterable ... c[elem] += 1 # by adding 1 to each element's count >>> c['a'] # now there are seven 'a' 7 >>> del c['b'] # remove all 'b' >>> c['b'] # now there are zero 'b' 0 >>> d = Counter('simsalabim') # make another counter >>> c.update(d) # add in the second counter >>> c['a'] # now there are nine 'a' 9 >>> c.clear() # empty the counter >>> c Counter() Note: If a count is set to zero or reduced to zero, it will remain in the counter until the entry is deleted or the counter is cleared: >>> c = Counter('aaabbc') >>> c['b'] -= 2 # reduce the count of 'b' by two >>> c.most_common() # 'b' is still in, but its count is zero [('a', 3), ('c', 1), ('b', 0)] csN|s td|^}}t|dkr0tdt|tt|j|j||dS)a Create a new, empty Counter object. And if given, count elements from an input iterable. Or, initialize the count from another mapping of elements to their counts. >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping >>> c = Counter(a=4, b=2) # a new counter from keyword args z;descriptor '__init__' of 'Counter' object needs an argumentr&z$expected at most 1 arguments, got %dN)r'r(superrr2rd)r/r0r)rQrrr2s  zCounter.__init__cCsdS)z1The count of elements not in the Counter is zero.r r)rrrrr __missing__szCounter.__missing__NcCs6|dkrt|jtdddStj||jtddS)zList the n most common elements and their counts from the most common to the least. If n is None, then list all element counts. >>> Counter('abcdeabcdabcaba').most_common(3) [('a', 5), ('b', 4), ('c', 3)] Nr&T)rreverse)r)sortedrK _itemgetter_heapqnlargest)rrGrrr most_commons zCounter.most_commoncCstjtt|jS)aIterator over elements repeating each as many times as its count. >>> c = Counter('ABCABC') >>> sorted(c.elements()) ['A', 'A', 'B', 'B', 'C', 'C'] # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1 >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) >>> product = 1 >>> for factor in prime_factors.elements(): # loop over factors ... product *= factor # and multiply them >>> product 1836 Note, if an element's count has been set to zero or is a negative number, elements() will ignore it. )_chain from_iterable_starmap_repeatrK)rrrrelements+szCounter.elementscCs tddS)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)rYrZvrrrr[CszCounter.fromkeyscs|s td|^}}t|dkr0tdt||r<|dnd}|dk rt|tr|r|j}x8|jD]\}}|||d||<qfWqtt|j|n t |||r|j|dS)aLike dict.update() but add counts instead of replacing them. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.update('witch') # add elements from another iterable >>> d = Counter('watch') >>> c.update(d) # add elements from another counter >>> c['h'] # four 'h' in which, witch, and watch 4 z9descriptor 'update' of 'Counter' object needs an argumentr&z$expected at most 1 arguments, got %dr N) r'r(r\MappingrrKrrrdr)r/r0rrZself_getrcount)rQrrrdJs    zCounter.updatecOs|s td|^}}t|dkr0tdt||r<|dnd}|dk r|j}t|trxH|jD]\}}||d|||<qbWn x|D]}||dd||<qW|r|j|dS)aLike dict.update() but subtracts counts instead of replacing them. Counts can be reduced below zero. Both the inputs and outputs are allowed to contain zero and negative counts. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.subtract('witch') # subtract elements from another iterable >>> c.subtract(Counter('watch')) # subtract elements from another counter >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch 0 >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch -1 z;descriptor 'subtract' of 'Counter' object needs an argumentr&z$expected at most 1 arguments, got %dr N)r'r(rr\rrKsubtract)r/r0rrZrrrrrrrrs   zCounter.subtractcCs |j|S)zReturn a shallow copy.)rQ)rrrrrUsz Counter.copycCs|jt|ffS)N)rQr>)rrrrrXszCounter.__reduce__cs||krtj|dS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rr:)rr)rQrrr:szCounter.__delitem__c Cs`|sd|jjSy&djtdj|j}d|jj|fStk rZdj|jjt|SXdS)Nz%s()z, z%r: %rz%s({%s})z {0}({1!r})) rQrrr___mod__rr'rsr>)rrKrrrrSs zCounter.__repr__cCsxt|tstSt}x0|jD]$\}}|||}|dkr|||<qWx,|jD] \}}||krP|dkrP|||<qPW|S)zAdd counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) r )r\rNotImplementedrK)rrarOrrnewcountrrr__add__s    zCounter.__add__cCs|t|tstSt}x0|jD]$\}}|||}|dkr|||<qWx0|jD]$\}}||krP|dkrPd|||<qPW|S)z Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) r )r\rrrK)rrarOrrrrrr__sub__s   zCounter.__sub__cCst|tstSt}x<|jD]0\}}||}||kr:|n|}|dkr|||<qWx,|jD] \}}||kr\|dkr\|||<q\W|S)zUnion is the maximum of value in either of the input counters. >>> Counter('abbb') | Counter('bcc') Counter({'b': 3, 'c': 2, 'a': 1}) r )r\rrrK)rrarOrr other_countrrrr__or__s   zCounter.__or__cCsVt|tstSt}x<|jD]0\}}||}||kr:|n|}|dkr|||<qW|S)z Intersection is the minimum of corresponding counts. >>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) r )r\rrrK)rrarOrrrrrrr__and__s  zCounter.__and__cCs0t}x$|jD]\}}|dkr|||<qW|S)zEAdds an empty counter, effectively stripping negative and zero countsr )rrK)rrOrrrrr__pos__s  zCounter.__pos__cCs4t}x(|jD]\}}|dkrd|||<qW|S)z{Subtracts from an empty counter. Strips positive and zero counts, and flips the sign on negative counts. r )rrK)rrOrrrrr__neg__s zCounter.__neg__cCs*dd|jD}x|D] }||=qW|S)z?Internal method to strip elements with a negative or zero countcSsg|]\}}|dks|qS)r r)rtrrrrr sz*Counter._keep_positive..)rK)r nonpositiverrrr_keep_positives  zCounter._keep_positivecCs.x$|jD]\}}|||7<q W|jS)zInplace add from another counter, keeping only positive counts. >>> c = Counter('abbb') >>> c += Counter('bcc') >>> c Counter({'b': 4, 'c': 2, 'a': 1}) )rKr)rrarrrrr__iadd__s zCounter.__iadd__cCs.x$|jD]\}}|||8<q W|jS)zInplace subtract counter, but keep only results with positive counts. >>> c = Counter('abbbc') >>> c -= Counter('bccd') >>> c Counter({'b': 2, 'a': 1}) )rKr)rrarrrrr__isub__%s zCounter.__isub__cCs6x,|jD] \}}||}||kr |||<q W|jS)zInplace union is the maximum of value from either counter. >>> c = Counter('abbb') >>> c |= Counter('bcc') >>> c Counter({'b': 3, 'c': 2, 'a': 1}) )rKr)rrarrrrrr__ior__2s  zCounter.__ior__cCs6x,|jD] \}}||}||kr |||<q W|jS)zInplace intersection is the minimum of corresponding counts. >>> c = Counter('abbb') >>> c &= Counter('bcc') >>> c Counter({'b': 1}) )rKr)rrarrrrrr__iand__As  zCounter.__iand__)N)N)rrrrbr2rrrrhr[rdrrUrXr:rSrrrrrrrrrrr __classcell__rr)rQrrs0+    ("    c@seZdZdZddZddZddZd'd d Zd d Zd dZ ddZ ddZ e ddZ eddZddZeZd(ddZeddZddZdd Zd!d"Zd#d$Zd%d&ZdS))r a A ChainMap groups multiple dicts (or other mappings) together to create a single, updateable view. The underlying mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state. Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping. cGst|p ig|_dS)zInitialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used. N)rRmaps)rrrrrr2cszChainMap.__init__cCs t|dS)N)r?)rrrrrrjszChainMap.__missing__c Cs8x,|jD]"}y||Stk r(YqXqW|j|S)N)rr?r)rrrrrr __getitem__ms   zChainMap.__getitem__NcCs||kr||S|S)Nr)rrrNrrrrusz ChainMap.getcCsttj|jS)N)r(runionr)rrrr__len__xszChainMap.__len__cCsttj|jS)N)rVrrr)rrrrr<{szChainMap.__iter__cstfdd|jDS)Nc3s|]}|kVqdS)Nr)rtm)rrrrusz(ChainMap.__contains__..)anyr)rrr)rr __contains__~szChainMap.__contains__cCs t|jS)N)rr)rrrr__bool__szChainMap.__bool__cCsdj|djtt|jS)Nz{0.__class__.__name__}({1})z, )rsrr_rr)rrrrrSszChainMap.__repr__cGs|tj|f|S)z?Create a ChainMap with a single dict created from the iterable.)r>r[)rYrZr/rrrr[szChainMap.fromkeyscCs$|j|jdjf|jddS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r r&N)rQrrU)rrrrrUsz ChainMap.copycCs|dkr i}|j|f|jS)zyNew ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. N)rQr)rrrrr new_childszChainMap.new_childcCs|j|jddS)zNew ChainMap from maps[1:].r&N)rQr)rrrrparentsszChainMap.parentscCs||jd|<dS)Nr )r)rrr3rrrr6szChainMap.__setitem__c Cs8y|jd|=Wn"tk r2tdj|YnXdS)Nr z(Key not found in the first mapping: {!r})rr?rs)rrrrrr:szChainMap.__delitem__c Cs0y|jdjStk r*tdYnXdS)zPRemove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.r z#No keys found in the first mapping.N)rr@r?)rrrrr@szChainMap.popitemc Gs>y|jdj|f|Stk r8tdj|YnXdS)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r z(Key not found in the first mapping: {!r}N)rr7r?rs)rrr/rrrr7sz ChainMap.popcCs|jdjdS)z'Clear maps[0], leaving maps[1:] intact.r N)rr=)rrrrr=szChainMap.clear)N)N)rrrrbr2rrrrr<rrrgrSrhr[rU__copy__rpropertyrr6r:r@r7r=rrrrr Us(     c@sbeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ e dddZ dS)rcOs|s td|^}}t|dkr0tdt||r>|d}n0d|krj|jd}ddl}|jdtddnd}i|_|dk r|j|t|r|j|dS) Nzz0Passing 'dict' as keyword argument is deprecatedrC) stacklevel)r'r(r7warningswarnDeprecationWarningdatard)r/kwargsrr>rrrrr2s$     zUserDict.__init__cCs t|jS)N)r(r)rrrrrszUserDict.__len__cCs:||jkr|j|St|jdr.|jj||St|dS)Nr)rhasattrrQrr?)rrrrrrs    zUserDict.__getitem__cCs||j|<dS)N)r)rritemrrrr6szUserDict.__setitem__cCs |j|=dS)N)r)rrrrrr:szUserDict.__delitem__cCs t|jS)N)rVr)rrrrr<szUserDict.__iter__cCs ||jkS)N)r)rrrrrrszUserDict.__contains__cCs t|jS)N)rr)rrrrrSszUserDict.__repr__c CsR|jtkrt|jjSddl}|j}zi|_|j|}Wd||_X|j||S)Nr )rQrrrUrd)rrUrcrrrrUs  z UserDict.copyNcCs |}x|D] }|||<q W|S)Nr)rYrZr3drrrrr[s  zUserDict.fromkeys)N)rrrr2rrr6r:r<rrSrUrhr[rrrrrs c@seZdZdZd>ddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$ZeZd%d&Zd'd(Zd)d*Zd@d,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dszUserList.indexcCs|jjdS)N)rr)rrrrr?szUserList.reversecOs|jj||dS)N)rsort)rr/r0rrrr@sz UserList.sortcCs*t|tr|jj|jn |jj|dS)N)r\rrextend)rrarrrrAs zUserList.extend)Nr)r)"rrrrbr2rSrrr]rrrrrrr6r:rrrr__rmul__rrrr7rr=rUrrwrrrrrrrrs>  c@s`eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&ZeZd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1ejfd2d3Zdd5d6Zd1ejfd7d8Z dd:d;Z!d1ejfdd?Z#d@dAZ$d1ejfdBdCZ%dDdEZ&dFdGZ'dHdIZ(dJdKZ)dLdMZ*dNdOZ+dPdQZ,dRdSZ-dTdUZ.dVdWZ/dXdYZ0dZd[Z1d\d]Z2d^d_Z3dd`daZ4e5j6Z6dbdcZ7ddedfZ8d1ejfdgdhZ9d1ejfdidjZ:dkdlZ;dmdnZddsdtZ?ddvdwZ@d1ejfdxdyZAddzd{ZBd|d}ZCd~dZDddZEddZFddZGd4S)rcCs<t|tr||_n&t|tr.|jdd|_n t||_dS)N)r\rrr)rseqrrrr2Ns   zUserString.__init__cCs t|jS)N)rr)rrrr__str__UszUserString.__str__cCs t|jS)N)rr)rrrrrSVszUserString.__repr__cCs t|jS)N)intr)rrrr__int__WszUserString.__int__cCs t|jS)N)floatr)rrrr __float__XszUserString.__float__cCs t|jS)N)complexr)rrrr __complex__YszUserString.__complex__cCs t|jS)N)hashr)rrrr__hash__ZszUserString.__hash__cCs|jddfS)N)r)rrrr__getnewargs__[szUserString.__getnewargs__cCs t|tr|j|jkS|j|kS)N)r\rr)rstringrrrr]^s  zUserString.__eq__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrbs  zUserString.__lt__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrfs  zUserString.__le__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrjs  zUserString.__gt__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrns  zUserString.__ge__cCst|tr|j}||jkS)N)r\rr)rcharrrrrss zUserString.__contains__cCs t|jS)N)r(r)rrrrrxszUserString.__len__cCs|j|j|S)N)rQr)rrwrrrryszUserString.__getitem__cCsJt|tr|j|j|jSt|tr6|j|j|S|j|jt|S)N)r\rrQrr)rrarrrrzs   zUserString.__add__cCs.t|tr|j||jS|jt||jS)N)r\rrQr)rrarrrrs zUserString.__radd__cCs|j|j|S)N)rQr)rrGrrrrszUserString.__mul__cCs|j|j|S)N)rQr)rr/rrrrszUserString.__mod__cCs|j|tS)N)rQr/)rrsrrr__rmod__szUserString.__rmod__cCs|j|jjS)N)rQr capitalize)rrrrrszUserString.capitalizecCs|j|jjS)N)rQrcasefold)rrrrrszUserString.casefoldcGs|j|jj|f|S)N)rQrcenter)rwidthr/rrrrszUserString.centerr cCs t|tr|j}|jj|||S)N)r\rrr)rsubstartendrrrrs zUserString.countNcCs>|r.|r|j|jj||S|j|jj|S|j|jjS)N)rQrencode)rencodingerrorsrrrrs zUserString.encodecCs|jj|||S)N)rendswith)rsuffixrrrrrrszUserString.endswithcCs|j|jj|S)N)rQr expandtabs)rtabsizerrrrszUserString.expandtabscCs t|tr|j}|jj|||S)N)r\rrfind)rrrrrrrrs zUserString.findcOs|jj||S)N)rrs)rr/r0rrrrsszUserString.formatcCs |jj|S)N)r format_map)rrrrrrszUserString.format_mapcCs|jj|||S)N)rrw)rrrrrrrrwszUserString.indexcCs |jjS)N)risalpha)rrrrrszUserString.isalphacCs |jjS)N)risalnum)rrrrrszUserString.isalnumcCs |jjS)N)r isdecimal)rrrrr szUserString.isdecimalcCs |jjS)N)risdigit)rrrrr szUserString.isdigitcCs |jjS)N)rr)rrrrrszUserString.isidentifiercCs |jjS)N)rislower)rrrrr szUserString.islowercCs |jjS)N)r isnumeric)rrrrr szUserString.isnumericcCs |jjS)N)r isprintable)rrrrr szUserString.isprintablecCs |jjS)N)risspace)rrrrrszUserString.isspacecCs |jjS)N)ristitle)rrrrrszUserString.istitlecCs |jjS)N)risupper)rrrrrszUserString.isuppercCs |jj|S)N)rr)rrrrrrszUserString.joincGs|j|jj|f|S)N)rQrljust)rrr/rrrrszUserString.ljustcCs|j|jjS)N)rQrlower)rrrrrszUserString.lowercCs|j|jj|S)N)rQrlstrip)rcharsrrrrszUserString.lstripcCs |jj|S)N)r partition)rseprrrrszUserString.partitionr&cCs6t|tr|j}t|tr |j}|j|jj|||S)N)r\rrrQr)roldnewmaxsplitrrrrs   zUserString.replacecCs t|tr|j}|jj|||S)N)r\rrrfind)rrrrrrrrs zUserString.rfindcCs|jj|||S)N)rrindex)rrrrrrrrszUserString.rindexcGs|j|jj|f|S)N)rQrrjust)rrr/rrrrszUserString.rjustcCs |jj|S)N)r rpartition)rrrrrrszUserString.rpartitioncCs|j|jj|S)N)rQrrstrip)rrrrrrszUserString.rstripcCs|jj||S)N)rr)rrrrrrrszUserString.splitcCs|jj||S)N)rrsplit)rrrrrrrszUserString.rsplitFcCs |jj|S)N)r splitlines)rkeependsrrrr szUserString.splitlinescCs|jj|||S)N)rr)rprefixrrrrrrszUserString.startswithcCs|j|jj|S)N)rQrstrip)rrrrrr#szUserString.stripcCs|j|jjS)N)rQrswapcase)rrrrr$szUserString.swapcasecCs|j|jjS)N)rQrtitle)rrrrr%szUserString.titlecGs|j|jj|S)N)rQr translate)rr/rrrr&szUserString.translatecCs|j|jjS)N)rQrupper)rrrrr'szUserString.uppercCs|j|jj|S)N)rQrzfill)rrrrrr(szUserString.zfill)NN)r)Nr)r)Nr)Nrr)Nr)F)N)Hrrrr2rrSrrrrrr]rrrrrrrrrrrrrrrrrDmaxsizerrrrrrsrrwrrr r rr r r rrrrrrrr maketransrrrrrrrrrr rr#r$r%r&r'r(rrrrrMs         )8rb__all___collections_abcoperatorr rr r`keywordrrsysrDheapqr_weakrefrr, itertoolsrrrrrrreprlibrrg _collectionsr ImportErrorMutableSequenceregisterrKeysViewr ItemsViewr ValuesViewr rfr!r>rrrrrxrrrrcr rrSequencerrrrrs`       `3blCIPKfe[\Q3$__pycache__/abc.cpython-36.opt-1.pycnu[3 \D@sddlTddlmZdS))*)__all__N)_collections_abcrrr'/usr/lib64/python3.6/collections/abc.pysPKfe[PF)__pycache__/__init__.cpython-36.opt-1.pycnu[3 \$@sdZddddddddd g Zd d lTd d lZeej7Zd d lmZmZd dlm Z d d l Z d d l Zd dlmZd dlmZmZmZd dlmZyd dlmZWnek rYn Xej eyd dlm!Z!Wnek rYnXGddde"Z#Gddde$Z%Gddde&Z'Gddde(Z)Gddde*Z+yd dlm+Z+Wnek rXYnXdZ,dZ-d Z.d!d!d d"d#dZ/d$d%Z0yd d&lm0Z0Wnek rYnXGd'dde*Z1Gd(d d e2Z3Gd)dde2Z4Gd*ddeZ5Gd+dde6Z7d S),a?This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, dict, list, set, and tuple. * namedtuple factory function for creating tuple subclasses with named fields * deque list-like container with fast appends and pops on either end * ChainMap dict-like class for creating a single view of multiple mappings * Counter dict subclass for counting hashable objects * OrderedDict dict subclass that remembers the order entries were added * defaultdict dict subclass that calls a factory function to supply missing values * UserDict wrapper around dictionary objects for easier dict subclassing * UserList wrapper around list objects for easier list subclassing * UserString wrapper around string objects for easier string subclassing deque defaultdict namedtupleUserDictUserList UserStringCounter OrderedDictChainMap)*N) itemgettereq) iskeyword)proxy)repeatchainstarmap)recursive_repr)r)rc@seZdZddZdS)_OrderedDictKeysViewccst|jEdHdS)N)reversed_mapping)selfr,/usr/lib64/python3.6/collections/__init__.py __reversed__5sz!_OrderedDictKeysView.__reversed__N)__name__ __module__ __qualname__rrrrrr3src@seZdZddZdS)_OrderedDictItemsViewccs(x"t|jD]}||j|fVq WdS)N)rr)rkeyrrrr:sz"_OrderedDictItemsView.__reversed__N)rrrrrrrrr8src@seZdZddZdS)_OrderedDictValuesViewccs$xt|jD]}|j|Vq WdS)N)rr)rrrrrr@sz#_OrderedDictValuesView.__reversed__N)rrrrrrrrr >sr c@seZdZdZdS)_Linkprevnextr __weakref__N)r"r#rr$)rrr __slots__rrrrr!Dsr!c@seZdZdZddZejeefddZej fddZ dd Z d d Z d d Z d*ddZ d+ddZddZejZZddZddZddZejZeZefddZd,ddZed d!Zd"d#Zd$d%Zed-d&d'Z d(d)Z!dS).rz)Dictionary that remembers insertion orderc Os|s td|^}}t|dkr0tdt|y |jWn>tk rxt|_t|j|_}||_|_i|_ YnX|j ||dS)zInitialize an ordered dictionary. The signature is the same as regular dictionaries. Keyword argument order is preserved. z?descriptor '__init__' of 'OrderedDict' object needs an argumentz$expected at most 1 arguments, got %dN) TypeErrorlen_OrderedDict__rootAttributeErrorr!_OrderedDict__hardroot_proxyr"r#_OrderedDict__map_OrderedDict__update)argskwdsrrootrrr__init__Vs    zOrderedDict.__init__c CsZ||krJ||j|<}|j}|j}||||_|_|_||_|||_||||dS)z!od.__setitem__(i, y) <==> od[i]=yN)r-r)r"r#r) rrvalueZ dict_setitemrZLinklinkr1lastrrr __setitem__is zOrderedDict.__setitem__cCs>||||jj|}|j}|j}||_||_d|_d|_dS)z od.__delitem__(y) <==> del od[y]N)r-popr"r#)rrZ dict_delitemr4 link_prev link_nextrrr __delitem__ws  zOrderedDict.__delitem__ccs,|j}|j}x||k r&|jV|j}qWdS)zod.__iter__() <==> iter(od)N)r)r#r)rr1currrrr__iter__s  zOrderedDict.__iter__ccs,|j}|j}x||k r&|jV|j}qWdS)z#od.__reversed__() <==> reversed(od)N)r)r"r)rr1r;rrrrs  zOrderedDict.__reversed__cCs*|j}||_|_|jjtj|dS)z.od.clear() -> None. Remove all items from od.N)r)r"r#r-cleardict)rr1rrrr=s  zOrderedDict.clearTcCsj|s td|j}|r0|j}|j}||_||_n|j}|j}||_||_|j}|j|=tj||}||fS)zRemove and return a (key, value) pair from the dictionary. Pairs are returned in LIFO order if last is true or FIFO order if false. zdictionary is empty)KeyErrorr)r"r#rr-r>r7)rr5r1r4r8r9rr3rrrpopitems  zOrderedDict.popitemc Cst|j|}|j}|j}|j}||_||_|j}|rR|j}||_||_||_||_n|j}||_||_||_||_dS)zMove an existing element to the end (or beginning if last==False). Raises KeyError if the element does not exist. When last=True, acts like a fast version of self[key]=self.pop(key). N)r-r"r#r)) rrr5r4r8r9Z soft_linkr1firstrrr move_to_ends$ zOrderedDict.move_to_endcCsVtj}t|d}||j}|||jd7}|||j|7}|||j|7}|S)Nr&)_sys getsizeofr(__dict__r-r+r))rZsizeofnsizerrr __sizeof__s  zOrderedDict.__sizeof__cCst|S)z:D.keys() -> a set-like object providing a view on D's keys)r)rrrrkeysszOrderedDict.keyscCst|S)z a set-like object providing a view on D's items)r)rrrritemsszOrderedDict.itemscCst|S)z6D.values() -> an object providing a view on D's values)r )rrrrvaluesszOrderedDict.valuescCs0||kr||}||=|S||jkr,t||S)zod.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. )_OrderedDict__markerr?)rrdefaultresultrrrr7s zOrderedDict.popNcCs||kr||S|||<|S)zDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in odr)rrrNrrr setdefaultszOrderedDict.setdefaultcCs*|sd|jjfSd|jjt|jfS)zod.__repr__() <==> repr(od)z%s()z%s(%r)) __class__rlistrK)rrrr__repr__szOrderedDict.__repr__cCsHt|j}xttD]}|j|dqW|jf|p8ddt|jfS)z%Return state information for picklingN)varscopyrr7rQiterrK)rZ inst_dictkrrr __reduce__s zOrderedDict.__reduce__cCs |j|S)z!od.copy() -> a shallow copy of od)rQ)rrrrrU szOrderedDict.copycCs |}x|D] }|||<q W|S)zOD.fromkeys(S[, v]) -> New ordered dictionary with keys from S. If not specified, the value defaults to None. r)clsiterabler3rrrrrfromkeyss  zOrderedDict.fromkeyscCs2t|tr&tj||o$ttt||Stj||S)zod.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. ) isinstancerr>__eq__allmap_eq)rotherrrrr]s zOrderedDict.__eq__)T)T)N)N)"rrr__doc__r2r>r6r,r!r:r<rr=r@rBrIMutableMappingupdater.rJrKrL__ne__objectrMr7rP_recursive_reprrSrXrU classmethodr[r]rrrrrGs0          )rafrom builtins import property as _property, tuple as _tuple from operator import itemgetter as _itemgetter from collections import OrderedDict class {typename}(tuple): '{typename}({arg_list})' __slots__ = () _fields = {field_names!r} def __new__(_cls, {arg_list}): 'Create new instance of {typename}({arg_list})' return _tuple.__new__(_cls, ({arg_list})) @classmethod def _make(cls, iterable, new=tuple.__new__, len=len): 'Make a new {typename} object from a sequence or iterable' result = new(cls, iterable) if len(result) != {num_fields:d}: raise TypeError('Expected {num_fields:d} arguments, got %d' % len(result)) return result def _replace(_self, **kwds): 'Return a new {typename} object replacing specified fields with new values' result = _self._make(map(kwds.pop, {field_names!r}, _self)) if kwds: raise ValueError('Got unexpected field names: %r' % list(kwds)) return result def __repr__(self): 'Return a nicely formatted representation string' return self.__class__.__name__ + '({repr_fmt})' % self def _asdict(self): 'Return a new OrderedDict which maps field names to their values.' return OrderedDict(zip(self._fields, self)) def __getnewargs__(self): 'Return self as a plain tuple. Used by copy and pickle.' return tuple(self) {field_defs} z {name}=%rzW {name} = _property(_itemgetter({index:d}), doc='Alias for field number {index:d}') F)verboserenamemodulec Cst|tr|jddj}ttt|}t|}|rt}xNt|D]B\}}|j spt |sp|j dsp||kr|d|||<|j |qDWxN|g|D]@}t |tk rt d|jstd|t |rtd|qWt}xJ|D]B}|j do| rtd|||krtd ||j |qWtj|t|t|tt|jd d d dd jdd|Ddjddt|Dd}td|d} t|| | |} || _|rt| j|dkrytjd jjdd}Wnttfk rYnX|dk r || _| S)aCReturns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22) , _z_%dz*Type names and field names must be stringsz8Type names and field names must be valid identifiers: %rz2Type names and field names cannot be a keyword: %rz/Field names cannot start with an underscore: %rz$Encountered duplicate field name: %r'r&z, css|]}tj|dVqdS))nameN)_repr_templateformat).0rqrrr sznamedtuple.. css |]\}}tj||dVqdS))indexrqN)_field_templaters)rtrwrqrrrrus)typename field_names num_fieldsarg_listrepr_fmt field_defsz namedtuple_%s)rNr__main__)r\strreplacesplitrRr_set enumerate isidentifier _iskeyword startswithaddtyper' ValueError_class_templaterstupler(reprjoinr>exec_sourceprintrD _getframe f_globalsgetr*r) ryrzrirjrkseenrwrqclass_definition namespacerOrrrresj               cCs*|j}x|D]}||dd||<q WdS)z!Tally elements from the iterable.r r&N)r)mappingrZZ mapping_getelemrrr_count_elementss r)rcseZdZdZfddZddZd/ddZd d Zed0d d Z fd dZ ddZ ddZ ddZ fddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.ZZS)1raDict subclass for counting hashable items. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values. >>> c = Counter('abcdeabcdabcaba') # count elements from a string >>> c.most_common(3) # three most common elements [('a', 5), ('b', 4), ('c', 3)] >>> sorted(c) # list all unique elements ['a', 'b', 'c', 'd', 'e'] >>> ''.join(sorted(c.elements())) # list elements with repetitions 'aaaaabbbbcccdde' >>> sum(c.values()) # total of all counts 15 >>> c['a'] # count of letter 'a' 5 >>> for elem in 'shazam': # update counts from an iterable ... c[elem] += 1 # by adding 1 to each element's count >>> c['a'] # now there are seven 'a' 7 >>> del c['b'] # remove all 'b' >>> c['b'] # now there are zero 'b' 0 >>> d = Counter('simsalabim') # make another counter >>> c.update(d) # add in the second counter >>> c['a'] # now there are nine 'a' 9 >>> c.clear() # empty the counter >>> c Counter() Note: If a count is set to zero or reduced to zero, it will remain in the counter until the entry is deleted or the counter is cleared: >>> c = Counter('aaabbc') >>> c['b'] -= 2 # reduce the count of 'b' by two >>> c.most_common() # 'b' is still in, but its count is zero [('a', 3), ('c', 1), ('b', 0)] csN|s td|^}}t|dkr0tdt|tt|j|j||dS)a Create a new, empty Counter object. And if given, count elements from an input iterable. Or, initialize the count from another mapping of elements to their counts. >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping >>> c = Counter(a=4, b=2) # a new counter from keyword args z;descriptor '__init__' of 'Counter' object needs an argumentr&z$expected at most 1 arguments, got %dN)r'r(superrr2rd)r/r0r)rQrrr2s  zCounter.__init__cCsdS)z1The count of elements not in the Counter is zero.r r)rrrrr __missing__szCounter.__missing__NcCs6|dkrt|jtdddStj||jtddS)zList the n most common elements and their counts from the most common to the least. If n is None, then list all element counts. >>> Counter('abcdeabcdabcaba').most_common(3) [('a', 5), ('b', 4), ('c', 3)] Nr&T)rreverse)r)sortedrK _itemgetter_heapqnlargest)rrGrrr most_commons zCounter.most_commoncCstjtt|jS)aIterator over elements repeating each as many times as its count. >>> c = Counter('ABCABC') >>> sorted(c.elements()) ['A', 'A', 'B', 'B', 'C', 'C'] # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1 >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) >>> product = 1 >>> for factor in prime_factors.elements(): # loop over factors ... product *= factor # and multiply them >>> product 1836 Note, if an element's count has been set to zero or is a negative number, elements() will ignore it. )_chain from_iterable_starmap_repeatrK)rrrrelements+szCounter.elementscCs tddS)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)rYrZvrrrr[CszCounter.fromkeyscs|s td|^}}t|dkr0tdt||r<|dnd}|dk rt|tr|r|j}x8|jD]\}}|||d||<qfWqtt|j|n t |||r|j|dS)aLike dict.update() but add counts instead of replacing them. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.update('witch') # add elements from another iterable >>> d = Counter('watch') >>> c.update(d) # add elements from another counter >>> c['h'] # four 'h' in which, witch, and watch 4 z9descriptor 'update' of 'Counter' object needs an argumentr&z$expected at most 1 arguments, got %dr N) r'r(r\MappingrrKrrrdr)r/r0rrZself_getrcount)rQrrrdJs    zCounter.updatecOs|s td|^}}t|dkr0tdt||r<|dnd}|dk r|j}t|trxH|jD]\}}||d|||<qbWn x|D]}||dd||<qW|r|j|dS)aLike dict.update() but subtracts counts instead of replacing them. Counts can be reduced below zero. Both the inputs and outputs are allowed to contain zero and negative counts. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.subtract('witch') # subtract elements from another iterable >>> c.subtract(Counter('watch')) # subtract elements from another counter >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch 0 >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch -1 z;descriptor 'subtract' of 'Counter' object needs an argumentr&z$expected at most 1 arguments, got %dr N)r'r(rr\rrKsubtract)r/r0rrZrrrrrrrrs   zCounter.subtractcCs |j|S)zReturn a shallow copy.)rQ)rrrrrUsz Counter.copycCs|jt|ffS)N)rQr>)rrrrrXszCounter.__reduce__cs||krtj|dS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rr:)rr)rQrrr:szCounter.__delitem__c Cs`|sd|jjSy&djtdj|j}d|jj|fStk rZdj|jjt|SXdS)Nz%s()z, z%r: %rz%s({%s})z {0}({1!r})) rQrrr___mod__rr'rsr>)rrKrrrrSs zCounter.__repr__cCsxt|tstSt}x0|jD]$\}}|||}|dkr|||<qWx,|jD] \}}||krP|dkrP|||<qPW|S)zAdd counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) r )r\rNotImplementedrK)rrarOrrnewcountrrr__add__s    zCounter.__add__cCs|t|tstSt}x0|jD]$\}}|||}|dkr|||<qWx0|jD]$\}}||krP|dkrPd|||<qPW|S)z Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) r )r\rrrK)rrarOrrrrrr__sub__s   zCounter.__sub__cCst|tstSt}x<|jD]0\}}||}||kr:|n|}|dkr|||<qWx,|jD] \}}||kr\|dkr\|||<q\W|S)zUnion is the maximum of value in either of the input counters. >>> Counter('abbb') | Counter('bcc') Counter({'b': 3, 'c': 2, 'a': 1}) r )r\rrrK)rrarOrr other_countrrrr__or__s   zCounter.__or__cCsVt|tstSt}x<|jD]0\}}||}||kr:|n|}|dkr|||<qW|S)z Intersection is the minimum of corresponding counts. >>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) r )r\rrrK)rrarOrrrrrrr__and__s  zCounter.__and__cCs0t}x$|jD]\}}|dkr|||<qW|S)zEAdds an empty counter, effectively stripping negative and zero countsr )rrK)rrOrrrrr__pos__s  zCounter.__pos__cCs4t}x(|jD]\}}|dkrd|||<qW|S)z{Subtracts from an empty counter. Strips positive and zero counts, and flips the sign on negative counts. r )rrK)rrOrrrrr__neg__s zCounter.__neg__cCs*dd|jD}x|D] }||=qW|S)z?Internal method to strip elements with a negative or zero countcSsg|]\}}|dks|qS)r r)rtrrrrr sz*Counter._keep_positive..)rK)r nonpositiverrrr_keep_positives  zCounter._keep_positivecCs.x$|jD]\}}|||7<q W|jS)zInplace add from another counter, keeping only positive counts. >>> c = Counter('abbb') >>> c += Counter('bcc') >>> c Counter({'b': 4, 'c': 2, 'a': 1}) )rKr)rrarrrrr__iadd__s zCounter.__iadd__cCs.x$|jD]\}}|||8<q W|jS)zInplace subtract counter, but keep only results with positive counts. >>> c = Counter('abbbc') >>> c -= Counter('bccd') >>> c Counter({'b': 2, 'a': 1}) )rKr)rrarrrrr__isub__%s zCounter.__isub__cCs6x,|jD] \}}||}||kr |||<q W|jS)zInplace union is the maximum of value from either counter. >>> c = Counter('abbb') >>> c |= Counter('bcc') >>> c Counter({'b': 3, 'c': 2, 'a': 1}) )rKr)rrarrrrrr__ior__2s  zCounter.__ior__cCs6x,|jD] \}}||}||kr |||<q W|jS)zInplace intersection is the minimum of corresponding counts. >>> c = Counter('abbb') >>> c &= Counter('bcc') >>> c Counter({'b': 1}) )rKr)rrarrrrrr__iand__As  zCounter.__iand__)N)N)rrrrbr2rrrrhr[rdrrUrXr:rSrrrrrrrrrrr __classcell__rr)rQrrs0+    ("    c@seZdZdZddZddZddZd'd d Zd d Zd dZ ddZ ddZ e ddZ eddZddZeZd(ddZeddZddZdd Zd!d"Zd#d$Zd%d&ZdS))r a A ChainMap groups multiple dicts (or other mappings) together to create a single, updateable view. The underlying mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state. Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping. cGst|p ig|_dS)zInitialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used. N)rRmaps)rrrrrr2cszChainMap.__init__cCs t|dS)N)r?)rrrrrrjszChainMap.__missing__c Cs8x,|jD]"}y||Stk r(YqXqW|j|S)N)rr?r)rrrrrr __getitem__ms   zChainMap.__getitem__NcCs||kr||S|S)Nr)rrrNrrrrusz ChainMap.getcCsttj|jS)N)r(runionr)rrrr__len__xszChainMap.__len__cCsttj|jS)N)rVrrr)rrrrr<{szChainMap.__iter__cstfdd|jDS)Nc3s|]}|kVqdS)Nr)rtm)rrrrusz(ChainMap.__contains__..)anyr)rrr)rr __contains__~szChainMap.__contains__cCs t|jS)N)rr)rrrr__bool__szChainMap.__bool__cCsdj|djtt|jS)Nz{0.__class__.__name__}({1})z, )rsrr_rr)rrrrrSszChainMap.__repr__cGs|tj|f|S)z?Create a ChainMap with a single dict created from the iterable.)r>r[)rYrZr/rrrr[szChainMap.fromkeyscCs$|j|jdjf|jddS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r r&N)rQrrU)rrrrrUsz ChainMap.copycCs|dkr i}|j|f|jS)zyNew ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. N)rQr)rrrrr new_childszChainMap.new_childcCs|j|jddS)zNew ChainMap from maps[1:].r&N)rQr)rrrrparentsszChainMap.parentscCs||jd|<dS)Nr )r)rrr3rrrr6szChainMap.__setitem__c Cs8y|jd|=Wn"tk r2tdj|YnXdS)Nr z(Key not found in the first mapping: {!r})rr?rs)rrrrrr:szChainMap.__delitem__c Cs0y|jdjStk r*tdYnXdS)zPRemove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.r z#No keys found in the first mapping.N)rr@r?)rrrrr@szChainMap.popitemc Gs>y|jdj|f|Stk r8tdj|YnXdS)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r z(Key not found in the first mapping: {!r}N)rr7r?rs)rrr/rrrr7sz ChainMap.popcCs|jdjdS)z'Clear maps[0], leaving maps[1:] intact.r N)rr=)rrrrr=szChainMap.clear)N)N)rrrrbr2rrrrr<rrrgrSrhr[rU__copy__rpropertyrr6r:r@r7r=rrrrr Us(     c@sbeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ e dddZ dS)rcOs|s td|^}}t|dkr0tdt||r>|d}n0d|krj|jd}ddl}|jdtddnd}i|_|dk r|j|t|r|j|dS) Nzz0Passing 'dict' as keyword argument is deprecatedrC) stacklevel)r'r(r7warningswarnDeprecationWarningdatard)r/kwargsrr>rrrrr2s$     zUserDict.__init__cCs t|jS)N)r(r)rrrrrszUserDict.__len__cCs:||jkr|j|St|jdr.|jj||St|dS)Nr)rhasattrrQrr?)rrrrrrs    zUserDict.__getitem__cCs||j|<dS)N)r)rritemrrrr6szUserDict.__setitem__cCs |j|=dS)N)r)rrrrrr:szUserDict.__delitem__cCs t|jS)N)rVr)rrrrr<szUserDict.__iter__cCs ||jkS)N)r)rrrrrrszUserDict.__contains__cCs t|jS)N)rr)rrrrrSszUserDict.__repr__c CsR|jtkrt|jjSddl}|j}zi|_|j|}Wd||_X|j||S)Nr )rQrrrUrd)rrUrcrrrrUs  z UserDict.copyNcCs |}x|D] }|||<q W|S)Nr)rYrZr3drrrrr[s  zUserDict.fromkeys)N)rrrr2rrr6r:r<rrSrUrhr[rrrrrs c@seZdZdZd>ddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$ZeZd%d&Zd'd(Zd)d*Zd@d,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dszUserList.indexcCs|jjdS)N)rr)rrrrr?szUserList.reversecOs|jj||dS)N)rsort)rr/r0rrrr@sz UserList.sortcCs*t|tr|jj|jn |jj|dS)N)r\rrextend)rrarrrrAs zUserList.extend)Nr)r)"rrrrbr2rSrrr]rrrrrrr6r:rrrr__rmul__rrrr7rr=rUrrwrrrrrrrrs>  c@s`eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&ZeZd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1ejfd2d3Zdd5d6Zd1ejfd7d8Z dd:d;Z!d1ejfdd?Z#d@dAZ$d1ejfdBdCZ%dDdEZ&dFdGZ'dHdIZ(dJdKZ)dLdMZ*dNdOZ+dPdQZ,dRdSZ-dTdUZ.dVdWZ/dXdYZ0dZd[Z1d\d]Z2d^d_Z3dd`daZ4e5j6Z6dbdcZ7ddedfZ8d1ejfdgdhZ9d1ejfdidjZ:dkdlZ;dmdnZddsdtZ?ddvdwZ@d1ejfdxdyZAddzd{ZBd|d}ZCd~dZDddZEddZFddZGd4S)rcCs<t|tr||_n&t|tr.|jdd|_n t||_dS)N)r\rrr)rseqrrrr2Ns   zUserString.__init__cCs t|jS)N)rr)rrrr__str__UszUserString.__str__cCs t|jS)N)rr)rrrrrSVszUserString.__repr__cCs t|jS)N)intr)rrrr__int__WszUserString.__int__cCs t|jS)N)floatr)rrrr __float__XszUserString.__float__cCs t|jS)N)complexr)rrrr __complex__YszUserString.__complex__cCs t|jS)N)hashr)rrrr__hash__ZszUserString.__hash__cCs|jddfS)N)r)rrrr__getnewargs__[szUserString.__getnewargs__cCs t|tr|j|jkS|j|kS)N)r\rr)rstringrrrr]^s  zUserString.__eq__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrbs  zUserString.__lt__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrfs  zUserString.__le__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrjs  zUserString.__gt__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrns  zUserString.__ge__cCst|tr|j}||jkS)N)r\rr)rcharrrrrss zUserString.__contains__cCs t|jS)N)r(r)rrrrrxszUserString.__len__cCs|j|j|S)N)rQr)rrwrrrryszUserString.__getitem__cCsJt|tr|j|j|jSt|tr6|j|j|S|j|jt|S)N)r\rrQrr)rrarrrrzs   zUserString.__add__cCs.t|tr|j||jS|jt||jS)N)r\rrQr)rrarrrrs zUserString.__radd__cCs|j|j|S)N)rQr)rrGrrrrszUserString.__mul__cCs|j|j|S)N)rQr)rr/rrrrszUserString.__mod__cCs|j|tS)N)rQr/)rrsrrr__rmod__szUserString.__rmod__cCs|j|jjS)N)rQr capitalize)rrrrrszUserString.capitalizecCs|j|jjS)N)rQrcasefold)rrrrrszUserString.casefoldcGs|j|jj|f|S)N)rQrcenter)rwidthr/rrrrszUserString.centerr cCs t|tr|j}|jj|||S)N)r\rrr)rsubstartendrrrrs zUserString.countNcCs>|r.|r|j|jj||S|j|jj|S|j|jjS)N)rQrencode)rencodingerrorsrrrrs zUserString.encodecCs|jj|||S)N)rendswith)rsuffixrrrrrrszUserString.endswithcCs|j|jj|S)N)rQr expandtabs)rtabsizerrrrszUserString.expandtabscCs t|tr|j}|jj|||S)N)r\rrfind)rrrrrrrrs zUserString.findcOs|jj||S)N)rrs)rr/r0rrrrsszUserString.formatcCs |jj|S)N)r format_map)rrrrrrszUserString.format_mapcCs|jj|||S)N)rrw)rrrrrrrrwszUserString.indexcCs |jjS)N)risalpha)rrrrrszUserString.isalphacCs |jjS)N)risalnum)rrrrrszUserString.isalnumcCs |jjS)N)r isdecimal)rrrrr szUserString.isdecimalcCs |jjS)N)risdigit)rrrrr szUserString.isdigitcCs |jjS)N)rr)rrrrrszUserString.isidentifiercCs |jjS)N)rislower)rrrrr szUserString.islowercCs |jjS)N)r isnumeric)rrrrr szUserString.isnumericcCs |jjS)N)r isprintable)rrrrr szUserString.isprintablecCs |jjS)N)risspace)rrrrrszUserString.isspacecCs |jjS)N)ristitle)rrrrrszUserString.istitlecCs |jjS)N)risupper)rrrrrszUserString.isuppercCs |jj|S)N)rr)rrrrrrszUserString.joincGs|j|jj|f|S)N)rQrljust)rrr/rrrrszUserString.ljustcCs|j|jjS)N)rQrlower)rrrrrszUserString.lowercCs|j|jj|S)N)rQrlstrip)rcharsrrrrszUserString.lstripcCs |jj|S)N)r partition)rseprrrrszUserString.partitionr&cCs6t|tr|j}t|tr |j}|j|jj|||S)N)r\rrrQr)roldnewmaxsplitrrrrs   zUserString.replacecCs t|tr|j}|jj|||S)N)r\rrrfind)rrrrrrrrs zUserString.rfindcCs|jj|||S)N)rrindex)rrrrrrrrszUserString.rindexcGs|j|jj|f|S)N)rQrrjust)rrr/rrrrszUserString.rjustcCs |jj|S)N)r rpartition)rrrrrrszUserString.rpartitioncCs|j|jj|S)N)rQrrstrip)rrrrrrszUserString.rstripcCs|jj||S)N)rr)rrrrrrrszUserString.splitcCs|jj||S)N)rrsplit)rrrrrrrszUserString.rsplitFcCs |jj|S)N)r splitlines)rkeependsrrrr szUserString.splitlinescCs|jj|||S)N)rr)rprefixrrrrrrszUserString.startswithcCs|j|jj|S)N)rQrstrip)rrrrrr#szUserString.stripcCs|j|jjS)N)rQrswapcase)rrrrr$szUserString.swapcasecCs|j|jjS)N)rQrtitle)rrrrr%szUserString.titlecGs|j|jj|S)N)rQr translate)rr/rrrr&szUserString.translatecCs|j|jjS)N)rQrupper)rrrrr'szUserString.uppercCs|j|jj|S)N)rQrzfill)rrrrrr(szUserString.zfill)NN)r)Nr)r)Nr)Nrr)Nr)F)N)Hrrrr2rrSrrrrrr]rrrrrrrrrrrrrrrrrDmaxsizerrrrrrsrrwrrr r rr r r rrrrrrrr maketransrrrrrrrrrr rr#r$r%r&r'r(rrrrrMs         )8rb__all___collections_abcoperatorr rr r`keywordrrsysrDheapqr_weakrefrr, itertoolsrrrrrrreprlibrrg _collectionsr ImportErrorMutableSequenceregisterrKeysViewr ItemsViewr ValuesViewr rfr!r>rrrrrxrrrrcr rrSequencerrrrrs`       `3blCIPKfe[\Q3__pycache__/abc.cpython-36.pycnu[3 \D@sddlTddlmZdS))*)__all__N)_collections_abcrrr'/usr/lib64/python3.6/collections/abc.pysPKfe[\Q3$__pycache__/abc.cpython-36.opt-2.pycnu[3 \D@sddlTddlmZdS))*)__all__N)_collections_abcrrr'/usr/lib64/python3.6/collections/abc.pysPKfe[$)__pycache__/__init__.cpython-36.opt-2.pycnu[3 \$@sdddddddddg Zd d lTd d lZeej7Zd d lmZmZd d lmZ d d l Z d d l Z d dlmZd dlmZmZmZd dlmZyd dlmZWnek rYn Xejeyd dlm Z Wnek rYnXGddde!Z"Gddde#Z$Gddde%Z&Gddde'Z(Gddde)Z*yd dlm*Z*Wnek rTYnXdZ+dZ,dZ-d d d d!d"dZ.d#d$Z/yd d%lm/Z/Wnek rYnXGd&dde)Z0Gd'dde1Z2Gd(dde1Z3Gd)ddeZ4Gd*dde5Z6d S)+deque defaultdict namedtupleUserDictUserList UserStringCounter OrderedDictChainMap)*N) itemgettereq) iskeyword)proxy)repeatchainstarmap)recursive_repr)r)rc@seZdZddZdS)_OrderedDictKeysViewccst|jEdHdS)N)reversed_mapping)selfr,/usr/lib64/python3.6/collections/__init__.py __reversed__5sz!_OrderedDictKeysView.__reversed__N)__name__ __module__ __qualname__rrrrrr3src@seZdZddZdS)_OrderedDictItemsViewccs(x"t|jD]}||j|fVq WdS)N)rr)rkeyrrrr:sz"_OrderedDictItemsView.__reversed__N)rrrrrrrrr8src@seZdZddZdS)_OrderedDictValuesViewccs$xt|jD]}|j|Vq WdS)N)rr)rrrrrr@sz#_OrderedDictValuesView.__reversed__N)rrrrrrrrr >sr c@seZdZdZdS)_Linkprevnextr __weakref__N)r"r#rr$)rrr __slots__rrrrr!Dsr!c@seZdZddZejeefddZejfddZddZ d d Z d d Z d)ddZ d*ddZ ddZejZZddZddZddZejZeZefddZd+ddZedd Zd!d"Zd#d$Zed,d%d&Zd'd(Z dS)-rc Os|s td|^}}t|dkr0tdt|y |jWn>tk rxt|_t|j|_}||_|_i|_ YnX|j ||dS)Nz?descriptor '__init__' of 'OrderedDict' object needs an argumentz$expected at most 1 arguments, got %d) TypeErrorlen_OrderedDict__rootAttributeErrorr!_OrderedDict__hardroot_proxyr"r#_OrderedDict__map_OrderedDict__update)argskwdsrrootrrr__init__Vs    zOrderedDict.__init__c CsZ||krJ||j|<}|j}|j}||||_|_|_||_|||_||||dS)N)r-r)r"r#r) rrvalueZ dict_setitemrZLinklinkr1lastrrr __setitem__is zOrderedDict.__setitem__cCs>||||jj|}|j}|j}||_||_d|_d|_dS)N)r-popr"r#)rrZ dict_delitemr4 link_prev link_nextrrr __delitem__ws  zOrderedDict.__delitem__ccs,|j}|j}x||k r&|jV|j}qWdS)N)r)r#r)rr1currrrr__iter__s  zOrderedDict.__iter__ccs,|j}|j}x||k r&|jV|j}qWdS)N)r)r"r)rr1r;rrrrs  zOrderedDict.__reversed__cCs*|j}||_|_|jjtj|dS)N)r)r"r#r-cleardict)rr1rrrr=s  zOrderedDict.clearTcCsj|s td|j}|r0|j}|j}||_||_n|j}|j}||_||_|j}|j|=tj||}||fS)Nzdictionary is empty)KeyErrorr)r"r#rr-r>r7)rr5r1r4r8r9rr3rrrpopitems  zOrderedDict.popitemc Cst|j|}|j}|j}|j}||_||_|j}|rR|j}||_||_||_||_n|j}||_||_||_||_dS)N)r-r"r#r)) rrr5r4r8r9Z soft_linkr1firstrrr move_to_ends$ zOrderedDict.move_to_endcCsVtj}t|d}||j}|||jd7}|||j|7}|||j|7}|S)Nr&)_sys getsizeofr(__dict__r-r+r))rZsizeofnsizerrr __sizeof__s  zOrderedDict.__sizeof__cCst|S)N)r)rrrrkeysszOrderedDict.keyscCst|S)N)r)rrrritemsszOrderedDict.itemscCst|S)N)r )rrrrvaluesszOrderedDict.valuescCs0||kr||}||=|S||jkr,t||S)N)_OrderedDict__markerr?)rrdefaultresultrrrr7s zOrderedDict.popNcCs||kr||S|||<|S)Nr)rrrNrrr setdefaultszOrderedDict.setdefaultcCs*|sd|jjfSd|jjt|jfS)Nz%s()z%s(%r)) __class__rlistrK)rrrr__repr__szOrderedDict.__repr__cCsHt|j}xttD]}|j|dqW|jf|p8ddt|jfS)N)varscopyrr7rQiterrK)rZ inst_dictkrrr __reduce__s zOrderedDict.__reduce__cCs |j|S)N)rQ)rrrrrU szOrderedDict.copycCs |}x|D] }|||<q W|S)Nr)clsiterabler3rrrrrfromkeyss  zOrderedDict.fromkeyscCs2t|tr&tj||o$ttt||Stj||S)N) isinstancerr>__eq__allmap_eq)rotherrrrr]s zOrderedDict.__eq__)T)T)N)N)!rrrr2r>r6r,r!r:r<rr=r@rBrIMutableMappingupdater.rJrKrL__ne__objectrMr7rP_recursive_reprrSrXrU classmethodr[r]rrrrrGs.          )rafrom builtins import property as _property, tuple as _tuple from operator import itemgetter as _itemgetter from collections import OrderedDict class {typename}(tuple): '{typename}({arg_list})' __slots__ = () _fields = {field_names!r} def __new__(_cls, {arg_list}): 'Create new instance of {typename}({arg_list})' return _tuple.__new__(_cls, ({arg_list})) @classmethod def _make(cls, iterable, new=tuple.__new__, len=len): 'Make a new {typename} object from a sequence or iterable' result = new(cls, iterable) if len(result) != {num_fields:d}: raise TypeError('Expected {num_fields:d} arguments, got %d' % len(result)) return result def _replace(_self, **kwds): 'Return a new {typename} object replacing specified fields with new values' result = _self._make(map(kwds.pop, {field_names!r}, _self)) if kwds: raise ValueError('Got unexpected field names: %r' % list(kwds)) return result def __repr__(self): 'Return a nicely formatted representation string' return self.__class__.__name__ + '({repr_fmt})' % self def _asdict(self): 'Return a new OrderedDict which maps field names to their values.' return OrderedDict(zip(self._fields, self)) def __getnewargs__(self): 'Return self as a plain tuple. Used by copy and pickle.' return tuple(self) {field_defs} z {name}=%rzW {name} = _property(_itemgetter({index:d}), doc='Alias for field number {index:d}') F)verboserenamemodulec Cst|tr|jddj}ttt|}t|}|rt}xNt|D]B\}}|j spt |sp|j dsp||kr|d|||<|j |qDWxN|g|D]@}t |tk rt d|jstd|t |rtd|qWt}xJ|D]B}|j do| rtd|||krtd ||j |qWtj|t|t|tt|jd d d dd jdd|Ddjddt|Dd}td|d} t|| | |} || _|rt| j|dkrytjd jjdd}Wnttfk rYnX|dk r || _| S)N, _z_%dz*Type names and field names must be stringsz8Type names and field names must be valid identifiers: %rz2Type names and field names cannot be a keyword: %rz/Field names cannot start with an underscore: %rz$Encountered duplicate field name: %r'r&z, css|]}tj|dVqdS))nameN)_repr_templateformat).0rprrr sznamedtuple.. css |]\}}tj||dVqdS))indexrpN)_field_templaterr)rsrvrprrrrts)typename field_names num_fieldsarg_listrepr_fmt field_defsz namedtuple_%s)rr__main__)r\strreplacesplitrRr_set enumerate isidentifier _iskeyword startswithaddtyper' ValueError_class_templaterrtupler(reprjoinr>exec_sourceprintrD _getframe f_globalsgetr*r) rxryrhrirjseenrvrpclass_definition namespacerOrrrresj               cCs*|j}x|D]}||dd||<q WdS)Nr r&)r)mappingrZZ mapping_getelemrrr_count_elementss r)rcseZdZfddZddZd.ddZdd Zed/d d Zfd d Z ddZ ddZ ddZ fddZ ddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-ZZS)0rcsN|s td|^}}t|dkr0tdt|tt|j|j||dS)Nz;descriptor '__init__' of 'Counter' object needs an argumentr&z$expected at most 1 arguments, got %d)r'r(superrr2rc)r/r0r)rQrrr2s  zCounter.__init__cCsdS)Nr r)rrrrr __missing__szCounter.__missing__NcCs6|dkrt|jtdddStj||jtddS)Nr&T)rreverse)r)sortedrK _itemgetter_heapqnlargest)rrGrrr most_commons zCounter.most_commoncCstjtt|jS)N)_chain from_iterable_starmap_repeatrK)rrrrelements+szCounter.elementscCs tddS)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)rYrZvrrrr[CszCounter.fromkeyscs|s td|^}}t|dkr0tdt||r<|dnd}|dk rt|tr|r|j}x8|jD]\}}|||d||<qfWqtt|j|n t |||r|j|dS)Nz9descriptor 'update' of 'Counter' object needs an argumentr&z$expected at most 1 arguments, got %dr ) r'r(r\MappingrrKrrrcr)r/r0rrZself_getrcount)rQrrrcJs    zCounter.updatecOs|s td|^}}t|dkr0tdt||r<|dnd}|dk r|j}t|trxH|jD]\}}||d|||<qbWn x|D]}||dd||<qW|r|j|dS)Nz;descriptor 'subtract' of 'Counter' object needs an argumentr&z$expected at most 1 arguments, got %dr )r'r(rr\rrKsubtract)r/r0rrZrrrrrrrrs   zCounter.subtractcCs |j|S)N)rQ)rrrrrUsz Counter.copycCs|jt|ffS)N)rQr>)rrrrrXszCounter.__reduce__cs||krtj|dS)N)rr:)rr)rQrrr:szCounter.__delitem__c Cs`|sd|jjSy&djtdj|j}d|jj|fStk rZdj|jjt|SXdS)Nz%s()z, z%r: %rz%s({%s})z {0}({1!r})) rQrrr___mod__rr'rrr>)rrKrrrrSs zCounter.__repr__cCsxt|tstSt}x0|jD]$\}}|||}|dkr|||<qWx,|jD] \}}||krP|dkrP|||<qPW|S)Nr )r\rNotImplementedrK)rrarOrrnewcountrrr__add__s    zCounter.__add__cCs|t|tstSt}x0|jD]$\}}|||}|dkr|||<qWx0|jD]$\}}||krP|dkrPd|||<qPW|S)Nr )r\rrrK)rrarOrrrrrr__sub__s   zCounter.__sub__cCst|tstSt}x<|jD]0\}}||}||kr:|n|}|dkr|||<qWx,|jD] \}}||kr\|dkr\|||<q\W|S)Nr )r\rrrK)rrarOrr other_countrrrr__or__s   zCounter.__or__cCsVt|tstSt}x<|jD]0\}}||}||kr:|n|}|dkr|||<qW|S)Nr )r\rrrK)rrarOrrrrrrr__and__s  zCounter.__and__cCs0t}x$|jD]\}}|dkr|||<qW|S)Nr )rrK)rrOrrrrr__pos__s  zCounter.__pos__cCs4t}x(|jD]\}}|dkrd|||<qW|S)Nr )rrK)rrOrrrrr__neg__s zCounter.__neg__cCs*dd|jD}x|D] }||=qW|S)NcSsg|]\}}|dks|qS)r r)rsrrrrr sz*Counter._keep_positive..)rK)r nonpositiverrrr_keep_positives  zCounter._keep_positivecCs.x$|jD]\}}|||7<q W|jS)N)rKr)rrarrrrr__iadd__s zCounter.__iadd__cCs.x$|jD]\}}|||8<q W|jS)N)rKr)rrarrrrr__isub__%s zCounter.__isub__cCs6x,|jD] \}}||}||kr |||<q W|jS)N)rKr)rrarrrrrr__ior__2s  zCounter.__ior__cCs6x,|jD] \}}||}||kr |||<q W|jS)N)rKr)rrarrrrrr__iand__As  zCounter.__iand__)N)N)rrrr2rrrrgr[rcrrUrXr:rSrrrrrrrrrrr __classcell__rr)rQrrs.3    ("    c@seZdZddZddZddZd&dd Zd d Zd d ZddZ ddZ e ddZ e ddZddZeZd'ddZeddZddZddZd d!Zd"d#Zd$d%ZdS)(r cGst|p ig|_dS)N)rRmaps)rrrrrr2cszChainMap.__init__cCs t|dS)N)r?)rrrrrrjszChainMap.__missing__c Cs8x,|jD]"}y||Stk r(YqXqW|j|S)N)rr?r)rrrrrr __getitem__ms   zChainMap.__getitem__NcCs||kr||S|S)Nr)rrrNrrrrusz ChainMap.getcCsttj|jS)N)r(runionr)rrrr__len__xszChainMap.__len__cCsttj|jS)N)rVrrr)rrrrr<{szChainMap.__iter__cstfdd|jDS)Nc3s|]}|kVqdS)Nr)rsm)rrrrtsz(ChainMap.__contains__..)anyr)rrr)rr __contains__~szChainMap.__contains__cCs t|jS)N)rr)rrrr__bool__szChainMap.__bool__cCsdj|djtt|jS)Nz{0.__class__.__name__}({1})z, )rrrr_rr)rrrrrSszChainMap.__repr__cGs|tj|f|S)N)r>r[)rYrZr/rrrr[szChainMap.fromkeyscCs$|j|jdjf|jddS)Nr r&)rQrrU)rrrrrUsz ChainMap.copycCs|dkr i}|j|f|jS)N)rQr)rrrrr new_childszChainMap.new_childcCs|j|jddS)Nr&)rQr)rrrrparentsszChainMap.parentscCs||jd|<dS)Nr )r)rrr3rrrr6szChainMap.__setitem__c Cs8y|jd|=Wn"tk r2tdj|YnXdS)Nr z(Key not found in the first mapping: {!r})rr?rr)rrrrrr:szChainMap.__delitem__c Cs0y|jdjStk r*tdYnXdS)Nr z#No keys found in the first mapping.)rr@r?)rrrrr@szChainMap.popitemc Gs>y|jdj|f|Stk r8tdj|YnXdS)Nr z(Key not found in the first mapping: {!r})rr7r?rr)rrr/rrrr7sz ChainMap.popcCs|jdjdS)Nr )rr=)rrrrr=szChainMap.clear)N)N)rrrr2rrrrr<rrrfrSrgr[rU__copy__rpropertyrr6r:r@r7r=rrrrr Us&    c@sbeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ e dddZ dS)rcOs|s td|^}}t|dkr0tdt||r>|d}n0d|krj|jd}ddl}|jdtddnd}i|_|dk r|j|t|r|j|dS) Nzz0Passing 'dict' as keyword argument is deprecatedrC) stacklevel)r'r(r7warningswarnDeprecationWarningdatarc)r/kwargsrr>rrrrr2s$     zUserDict.__init__cCs t|jS)N)r(r)rrrrrszUserDict.__len__cCs:||jkr|j|St|jdr.|jj||St|dS)Nr)rhasattrrQrr?)rrrrrrs    zUserDict.__getitem__cCs||j|<dS)N)r)rritemrrrr6szUserDict.__setitem__cCs |j|=dS)N)r)rrrrrr:szUserDict.__delitem__cCs t|jS)N)rVr)rrrrr<szUserDict.__iter__cCs ||jkS)N)r)rrrrrrszUserDict.__contains__cCs t|jS)N)rr)rrrrrSszUserDict.__repr__c CsR|jtkrt|jjSddl}|j}zi|_|j|}Wd||_X|j||S)Nr )rQrrrUrc)rrUrcrrrrUs  z UserDict.copyNcCs |}x|D] }|||<q W|S)Nr)rYrZr3drrrrr[s  zUserDict.fromkeys)N)rrrr2rrr6r:r<rrSrUrgr[rrrrrs c@seZdZd=ddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#ZeZd$d%Zd&d'Zd(d)Zd?d+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z dS)@rNcCsbg|_|dk r^t|t|jkr0||jdd<n.t|trT|jdd|jdd<n t||_dS)N)rrr\rrR)rinitlistrrrr2s zUserList.__init__cCs t|jS)N)rr)rrrrrSszUserList.__repr__cCs|j|j|kS)N)r_UserList__cast)rrarrr__lt__szUserList.__lt__cCs|j|j|kS)N)rr)rrarrr__le__szUserList.__le__cCs|j|j|kS)N)rr)rrarrrr]szUserList.__eq__cCs|j|j|kS)N)rr)rrarrr__gt__szUserList.__gt__cCs|j|j|kS)N)rr)rrarrr__ge__szUserList.__ge__cCst|tr|jS|S)N)r\rr)rrarrr__castszUserList.__castcCs ||jkS)N)r)rrrrrrszUserList.__contains__cCs t|jS)N)r(r)rrrrrszUserList.__len__cCs |j|S)N)r)rirrrrszUserList.__getitem__cCs||j|<dS)N)r)rrrrrrr6szUserList.__setitem__cCs |j|=dS)N)r)rrrrrr:szUserList.__delitem__cCsPt|tr|j|j|jSt|t|jr<|j|j|S|j|jt|S)N)r\rrQrrrR)rrarrrrs  zUserList.__add__cCsPt|tr|j|j|jSt|t|jr<|j||jS|jt||jS)N)r\rrQrrrR)rrarrr__radd__#s  zUserList.__radd__cCsRt|tr|j|j7_n2t|t|jr<|j|7_n|jt|7_|S)N)r\rrrrR)rrarrrr)s  zUserList.__iadd__cCs|j|j|S)N)rQr)rrGrrr__mul__1szUserList.__mul__cCs|j|9_|S)N)r)rrGrrr__imul__4szUserList.__imul__cCs|jj|dS)N)rappend)rrrrrr7szUserList.appendcCs|jj||dS)N)rinsert)rrrrrrr8szUserList.insertr&cCs |jj|S)N)rr7)rrrrrr79sz UserList.popcCs|jj|dS)N)rremove)rrrrrr:szUserList.removecCs|jjdS)N)rr=)rrrrr=;szUserList.clearcCs |j|S)N)rQ)rrrrrU<sz UserList.copycCs |jj|S)N)rr)rrrrrr=szUserList.countcGs|jj|f|S)N)rrv)rrr/rrrrv>szUserList.indexcCs|jjdS)N)rr)rrrrr?szUserList.reversecOs|jj||dS)N)rsort)rr/r0rrrr@sz UserList.sortcCs*t|tr|jj|jn |jj|dS)N)r\rrextend)rrarrrrAs zUserList.extend)Nr)r)!rrrr2rSrrr]rrrrrrr6r:rrrr__rmul__rrrr7rr=rUrrvrrrrrrrrs<  c@s`eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&ZeZd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1ejfd2d3Zdd5d6Zd1ejfd7d8Z dd:d;Z!d1ejfdd?Z#d@dAZ$d1ejfdBdCZ%dDdEZ&dFdGZ'dHdIZ(dJdKZ)dLdMZ*dNdOZ+dPdQZ,dRdSZ-dTdUZ.dVdWZ/dXdYZ0dZd[Z1d\d]Z2d^d_Z3dd`daZ4e5j6Z6dbdcZ7ddedfZ8d1ejfdgdhZ9d1ejfdidjZ:dkdlZ;dmdnZddsdtZ?ddvdwZ@d1ejfdxdyZAddzd{ZBd|d}ZCd~dZDddZEddZFddZGd4S)rcCs<t|tr||_n&t|tr.|jdd|_n t||_dS)N)r\rrr)rseqrrrr2Ns   zUserString.__init__cCs t|jS)N)rr)rrrr__str__UszUserString.__str__cCs t|jS)N)rr)rrrrrSVszUserString.__repr__cCs t|jS)N)intr)rrrr__int__WszUserString.__int__cCs t|jS)N)floatr)rrrr __float__XszUserString.__float__cCs t|jS)N)complexr)rrrr __complex__YszUserString.__complex__cCs t|jS)N)hashr)rrrr__hash__ZszUserString.__hash__cCs|jddfS)N)r)rrrr__getnewargs__[szUserString.__getnewargs__cCs t|tr|j|jkS|j|kS)N)r\rr)rstringrrrr]^s  zUserString.__eq__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrbs  zUserString.__lt__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrfs  zUserString.__le__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrjs  zUserString.__gt__cCs t|tr|j|jkS|j|kS)N)r\rr)rrrrrrns  zUserString.__ge__cCst|tr|j}||jkS)N)r\rr)rcharrrrrss zUserString.__contains__cCs t|jS)N)r(r)rrrrrxszUserString.__len__cCs|j|j|S)N)rQr)rrvrrrryszUserString.__getitem__cCsJt|tr|j|j|jSt|tr6|j|j|S|j|jt|S)N)r\rrQrr)rrarrrrzs   zUserString.__add__cCs.t|tr|j||jS|jt||jS)N)r\rrQr)rrarrrrs zUserString.__radd__cCs|j|j|S)N)rQr)rrGrrrrszUserString.__mul__cCs|j|j|S)N)rQr)rr/rrrrszUserString.__mod__cCs|j|tS)N)rQr/)rrrrrr__rmod__szUserString.__rmod__cCs|j|jjS)N)rQr capitalize)rrrrrszUserString.capitalizecCs|j|jjS)N)rQrcasefold)rrrrrszUserString.casefoldcGs|j|jj|f|S)N)rQrcenter)rwidthr/rrrrszUserString.centerr cCs t|tr|j}|jj|||S)N)r\rrr)rsubstartendrrrrs zUserString.countNcCs>|r.|r|j|jj||S|j|jj|S|j|jjS)N)rQrencode)rencodingerrorsrrrrs zUserString.encodecCs|jj|||S)N)rendswith)rsuffixrrrrrrszUserString.endswithcCs|j|jj|S)N)rQr expandtabs)rtabsizerrrrszUserString.expandtabscCs t|tr|j}|jj|||S)N)r\rrfind)rrrrrrrrs zUserString.findcOs|jj||S)N)rrr)rr/r0rrrrrszUserString.formatcCs |jj|S)N)r format_map)rrrrrrszUserString.format_mapcCs|jj|||S)N)rrv)rrrrrrrrvszUserString.indexcCs |jjS)N)risalpha)rrrrrszUserString.isalphacCs |jjS)N)risalnum)rrrrrszUserString.isalnumcCs |jjS)N)r isdecimal)rrrrrszUserString.isdecimalcCs |jjS)N)risdigit)rrrrr szUserString.isdigitcCs |jjS)N)rr)rrrrrszUserString.isidentifiercCs |jjS)N)rislower)rrrrr szUserString.islowercCs |jjS)N)r isnumeric)rrrrr szUserString.isnumericcCs |jjS)N)r isprintable)rrrrr szUserString.isprintablecCs |jjS)N)risspace)rrrrr szUserString.isspacecCs |jjS)N)ristitle)rrrrrszUserString.istitlecCs |jjS)N)risupper)rrrrrszUserString.isuppercCs |jj|S)N)rr)rrrrrrszUserString.joincGs|j|jj|f|S)N)rQrljust)rrr/rrrrszUserString.ljustcCs|j|jjS)N)rQrlower)rrrrrszUserString.lowercCs|j|jj|S)N)rQrlstrip)rcharsrrrrszUserString.lstripcCs |jj|S)N)r partition)rseprrrrszUserString.partitionr&cCs6t|tr|j}t|tr |j}|j|jj|||S)N)r\rrrQr)roldnewmaxsplitrrrrs   zUserString.replacecCs t|tr|j}|jj|||S)N)r\rrrfind)rrrrrrrrs zUserString.rfindcCs|jj|||S)N)rrindex)rrrrrrrrszUserString.rindexcGs|j|jj|f|S)N)rQrrjust)rrr/rrrrszUserString.rjustcCs |jj|S)N)r rpartition)rrrrrrszUserString.rpartitioncCs|j|jj|S)N)rQrrstrip)rrrrrrszUserString.rstripcCs|jj||S)N)rr)rrrrrrrszUserString.splitcCs|jj||S)N)rrsplit)rrrrrrrszUserString.rsplitFcCs |jj|S)N)r splitlines)rkeependsrrrrszUserString.splitlinescCs|jj|||S)N)rr)rprefixrrrrrrszUserString.startswithcCs|j|jj|S)N)rQrstrip)rrrrrr"szUserString.stripcCs|j|jjS)N)rQrswapcase)rrrrr#szUserString.swapcasecCs|j|jjS)N)rQrtitle)rrrrr$szUserString.titlecGs|j|jj|S)N)rQr translate)rr/rrrr%szUserString.translatecCs|j|jjS)N)rQrupper)rrrrr&szUserString.uppercCs|j|jj|S)N)rQrzfill)rrrrrr'szUserString.zfill)NN)r)Nr)r)Nr)Nrr)Nr)F)N)Hrrrr2rrSrrrrrr]rrrrrrrrrrrrrrrrrDmaxsizerrrrrrrrrvrrrr rr r r r rrrrrrr maketransrrrrrrrrrrrr"r#r$r%r&r'rrrrrMs         )7__all___collections_abcoperatorr rr r`keywordrrsysrDheapqr_weakrefrr, itertoolsrrrrrrreprlibrrf _collectionsr ImportErrorMutableSequenceregisterrKeysViewr ItemsViewr ValuesViewr rer!r>rrrqrwrrrrbr rrSequencerrrrrs^       `3blCIPKfe["% ~22 __init__.pynu['''This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, dict, list, set, and tuple. * namedtuple factory function for creating tuple subclasses with named fields * deque list-like container with fast appends and pops on either end * ChainMap dict-like class for creating a single view of multiple mappings * Counter dict subclass for counting hashable objects * OrderedDict dict subclass that remembers the order entries were added * defaultdict dict subclass that calls a factory function to supply missing values * UserDict wrapper around dictionary objects for easier dict subclassing * UserList wrapper around list objects for easier list subclassing * UserString wrapper around string objects for easier string subclassing ''' __all__ = [ 'ChainMap', 'Counter', 'OrderedDict', 'UserDict', 'UserList', 'UserString', 'defaultdict', 'deque', 'namedtuple', ] import _collections_abc import sys as _sys from itertools import chain as _chain from itertools import repeat as _repeat from itertools import starmap as _starmap from keyword import iskeyword as _iskeyword from operator import eq as _eq from operator import itemgetter as _itemgetter from reprlib import recursive_repr as _recursive_repr from _weakref import proxy as _proxy try: from _collections import deque except ImportError: pass else: _collections_abc.MutableSequence.register(deque) try: from _collections import defaultdict except ImportError: pass ################################################################################ ### OrderedDict ################################################################################ class _OrderedDictKeysView(_collections_abc.KeysView): def __reversed__(self): yield from reversed(self._mapping) class _OrderedDictItemsView(_collections_abc.ItemsView): def __reversed__(self): for key in reversed(self._mapping): yield (key, self._mapping[key]) class _OrderedDictValuesView(_collections_abc.ValuesView): def __reversed__(self): for key in reversed(self._mapping): yield self._mapping[key] class _Link(object): __slots__ = 'prev', 'next', 'key', '__weakref__' class OrderedDict(dict): 'Dictionary that remembers insertion order' # An inherited dict maps keys to values. # The inherited dict provides __getitem__, __len__, __contains__, and get. # The remaining methods are order-aware. # Big-O running times for all methods are the same as regular dictionaries. # The internal self.__map dict maps keys to links in a doubly linked list. # The circular doubly linked list starts and ends with a sentinel element. # The sentinel element never gets deleted (this simplifies the algorithm). # The sentinel is in self.__hardroot with a weakref proxy in self.__root. # The prev links are weakref proxies (to prevent circular references). # Individual links are kept alive by the hard reference in self.__map. # Those hard references disappear when a key is deleted from an OrderedDict. def __new__(cls, /, *args, **kwds): "Create the ordered dict object and set up the underlying structures." self = dict.__new__(cls) self.__hardroot = _Link() self.__root = root = _proxy(self.__hardroot) root.prev = root.next = root self.__map = {} return self def __init__(self, other=(), /, **kwds): '''Initialize an ordered dictionary. The signature is the same as regular dictionaries. Keyword argument order is preserved. ''' self.__update(other, **kwds) def __setitem__(self, key, value, dict_setitem=dict.__setitem__, proxy=_proxy, Link=_Link): 'od.__setitem__(i, y) <==> od[i]=y' # Setting a new item creates a new link at the end of the linked list, # and the inherited dictionary is updated with the new key/value pair. if key not in self: self.__map[key] = link = Link() root = self.__root last = root.prev link.prev, link.next, link.key = last, root, key last.next = link root.prev = proxy(link) dict_setitem(self, key, value) def __delitem__(self, key, dict_delitem=dict.__delitem__): 'od.__delitem__(y) <==> del od[y]' # Deleting an existing item uses self.__map to find the link which gets # removed by updating the links in the predecessor and successor nodes. dict_delitem(self, key) link = self.__map.pop(key) link_prev = link.prev link_next = link.next link_prev.next = link_next link_next.prev = link_prev link.prev = None link.next = None def __iter__(self): 'od.__iter__() <==> iter(od)' # Traverse the linked list in order. root = self.__root curr = root.next while curr is not root: yield curr.key curr = curr.next def __reversed__(self): 'od.__reversed__() <==> reversed(od)' # Traverse the linked list in reverse order. root = self.__root curr = root.prev while curr is not root: yield curr.key curr = curr.prev def clear(self): 'od.clear() -> None. Remove all items from od.' root = self.__root root.prev = root.next = root self.__map.clear() dict.clear(self) def popitem(self, last=True): '''Remove and return a (key, value) pair from the dictionary. Pairs are returned in LIFO order if last is true or FIFO order if false. ''' if not self: raise KeyError('dictionary is empty') root = self.__root if last: link = root.prev link_prev = link.prev link_prev.next = root root.prev = link_prev else: link = root.next link_next = link.next root.next = link_next link_next.prev = root key = link.key del self.__map[key] value = dict.pop(self, key) return key, value def move_to_end(self, key, last=True): '''Move an existing element to the end (or beginning if last is false). Raise KeyError if the element does not exist. ''' link = self.__map[key] link_prev = link.prev link_next = link.next soft_link = link_next.prev link_prev.next = link_next link_next.prev = link_prev root = self.__root if last: last = root.prev link.prev = last link.next = root root.prev = soft_link last.next = link else: first = root.next link.prev = root link.next = first first.prev = soft_link root.next = link def __sizeof__(self): sizeof = _sys.getsizeof n = len(self) + 1 # number of links including root size = sizeof(self.__dict__) # instance dictionary size += sizeof(self.__map) * 2 # internal dict and inherited dict size += sizeof(self.__hardroot) * n # link objects size += sizeof(self.__root) * n # proxy objects return size update = __update = _collections_abc.MutableMapping.update def keys(self): "D.keys() -> a set-like object providing a view on D's keys" return _OrderedDictKeysView(self) def items(self): "D.items() -> a set-like object providing a view on D's items" return _OrderedDictItemsView(self) def values(self): "D.values() -> an object providing a view on D's values" return _OrderedDictValuesView(self) __ne__ = _collections_abc.MutableMapping.__ne__ __marker = object() def pop(self, key, default=__marker): '''od.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. ''' marker = self.__marker result = dict.pop(self, key, marker) if result is not marker: # The same as in __delitem__(). link = self.__map.pop(key) link_prev = link.prev link_next = link.next link_prev.next = link_next link_next.prev = link_prev link.prev = None link.next = None return result if default is marker: raise KeyError(key) return default def setdefault(self, key, default=None): '''Insert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default. ''' if key in self: return self[key] self[key] = default return default @_recursive_repr() def __repr__(self): 'od.__repr__() <==> repr(od)' if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def __reduce__(self): 'Return state information for pickling' state = self.__getstate__() if state: if isinstance(state, tuple): state, slots = state else: slots = {} state = state.copy() slots = slots.copy() for k in vars(OrderedDict()): state.pop(k, None) slots.pop(k, None) if slots: state = state, slots else: state = state or None return self.__class__, (), state, None, iter(self.items()) def copy(self): 'od.copy() -> a shallow copy of od' return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): '''Create a new ordered dictionary with keys from iterable and values set to value. ''' self = cls() for key in iterable: self[key] = value return self def __eq__(self, other): '''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. ''' if isinstance(other, OrderedDict): return dict.__eq__(self, other) and all(map(_eq, self, other)) return dict.__eq__(self, other) def __ior__(self, other): self.update(other) return self def __or__(self, other): if not isinstance(other, dict): return NotImplemented new = self.__class__(self) new.update(other) return new def __ror__(self, other): if not isinstance(other, dict): return NotImplemented new = self.__class__(other) new.update(self) return new try: from _collections import OrderedDict except ImportError: # Leave the pure Python version in place. pass ################################################################################ ### namedtuple ################################################################################ try: from _collections import _tuplegetter except ImportError: _tuplegetter = lambda index, doc: property(_itemgetter(index), doc=doc) def namedtuple(typename, field_names, *, rename=False, defaults=None, module=None): """Returns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22) """ # Validate the field names. At the user's option, either generate an error # message or automatically replace the field name with a valid name. if isinstance(field_names, str): field_names = field_names.replace(',', ' ').split() field_names = list(map(str, field_names)) typename = _sys.intern(str(typename)) if rename: seen = set() for index, name in enumerate(field_names): if (not name.isidentifier() or _iskeyword(name) or name.startswith('_') or name in seen): field_names[index] = f'_{index}' seen.add(name) for name in [typename] + field_names: if type(name) is not str: raise TypeError('Type names and field names must be strings') if not name.isidentifier(): raise ValueError('Type names and field names must be valid ' f'identifiers: {name!r}') if _iskeyword(name): raise ValueError('Type names and field names cannot be a ' f'keyword: {name!r}') seen = set() for name in field_names: if name.startswith('_') and not rename: raise ValueError('Field names cannot start with an underscore: ' f'{name!r}') if name in seen: raise ValueError(f'Encountered duplicate field name: {name!r}') seen.add(name) field_defaults = {} if defaults is not None: defaults = tuple(defaults) if len(defaults) > len(field_names): raise TypeError('Got more default values than field names') field_defaults = dict(reversed(list(zip(reversed(field_names), reversed(defaults))))) # Variables used in the methods and docstrings field_names = tuple(map(_sys.intern, field_names)) num_fields = len(field_names) arg_list = ', '.join(field_names) if num_fields == 1: arg_list += ',' repr_fmt = '(' + ', '.join(f'{name}=%r' for name in field_names) + ')' tuple_new = tuple.__new__ _dict, _tuple, _len, _map, _zip = dict, tuple, len, map, zip # Create all the named tuple methods to be added to the class namespace namespace = { '_tuple_new': tuple_new, '__builtins__': {}, '__name__': f'namedtuple_{typename}', } code = f'lambda _cls, {arg_list}: _tuple_new(_cls, ({arg_list}))' __new__ = eval(code, namespace) __new__.__name__ = '__new__' __new__.__doc__ = f'Create new instance of {typename}({arg_list})' if defaults is not None: __new__.__defaults__ = defaults @classmethod def _make(cls, iterable): result = tuple_new(cls, iterable) if _len(result) != num_fields: raise TypeError(f'Expected {num_fields} arguments, got {len(result)}') return result _make.__func__.__doc__ = (f'Make a new {typename} object from a sequence ' 'or iterable') def _replace(self, /, **kwds): result = self._make(_map(kwds.pop, field_names, self)) if kwds: raise ValueError(f'Got unexpected field names: {list(kwds)!r}') return result _replace.__doc__ = (f'Return a new {typename} object replacing specified ' 'fields with new values') def __repr__(self): 'Return a nicely formatted representation string' return self.__class__.__name__ + repr_fmt % self def _asdict(self): 'Return a new dict which maps field names to their values.' return _dict(_zip(self._fields, self)) def __getnewargs__(self): 'Return self as a plain tuple. Used by copy and pickle.' return _tuple(self) # Modify function metadata to help with introspection and debugging for method in ( __new__, _make.__func__, _replace, __repr__, _asdict, __getnewargs__, ): method.__qualname__ = f'{typename}.{method.__name__}' # Build-up the class namespace dictionary # and use type() to build the result class class_namespace = { '__doc__': f'{typename}({arg_list})', '__slots__': (), '_fields': field_names, '_field_defaults': field_defaults, '__new__': __new__, '_make': _make, '_replace': _replace, '__repr__': __repr__, '_asdict': _asdict, '__getnewargs__': __getnewargs__, '__match_args__': field_names, } for index, name in enumerate(field_names): doc = _sys.intern(f'Alias for field number {index}') class_namespace[name] = _tuplegetter(index, doc) result = type(typename, (tuple,), class_namespace) # For pickling to work, the __module__ variable needs to be set to the frame # where the named tuple is created. Bypass this step in environments where # sys._getframe is not defined (Jython for example) or sys._getframe is not # defined for arguments greater than 0 (IronPython), or where the user has # specified a particular module. if module is None: try: module = _sys._getframe(1).f_globals.get('__name__', '__main__') except (AttributeError, ValueError): pass if module is not None: result.__module__ = module return result ######################################################################## ### Counter ######################################################################## def _count_elements(mapping, iterable): 'Tally elements from the iterable.' mapping_get = mapping.get for elem in iterable: mapping[elem] = mapping_get(elem, 0) + 1 try: # Load C helper function if available from _collections import _count_elements except ImportError: pass class Counter(dict): '''Dict subclass for counting hashable items. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values. >>> c = Counter('abcdeabcdabcaba') # count elements from a string >>> c.most_common(3) # three most common elements [('a', 5), ('b', 4), ('c', 3)] >>> sorted(c) # list all unique elements ['a', 'b', 'c', 'd', 'e'] >>> ''.join(sorted(c.elements())) # list elements with repetitions 'aaaaabbbbcccdde' >>> sum(c.values()) # total of all counts 15 >>> c['a'] # count of letter 'a' 5 >>> for elem in 'shazam': # update counts from an iterable ... c[elem] += 1 # by adding 1 to each element's count >>> c['a'] # now there are seven 'a' 7 >>> del c['b'] # remove all 'b' >>> c['b'] # now there are zero 'b' 0 >>> d = Counter('simsalabim') # make another counter >>> c.update(d) # add in the second counter >>> c['a'] # now there are nine 'a' 9 >>> c.clear() # empty the counter >>> c Counter() Note: If a count is set to zero or reduced to zero, it will remain in the counter until the entry is deleted or the counter is cleared: >>> c = Counter('aaabbc') >>> c['b'] -= 2 # reduce the count of 'b' by two >>> c.most_common() # 'b' is still in, but its count is zero [('a', 3), ('c', 1), ('b', 0)] ''' # References: # http://en.wikipedia.org/wiki/Multiset # http://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html # http://www.demo2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm # http://code.activestate.com/recipes/259174/ # Knuth, TAOCP Vol. II section 4.6.3 def __init__(self, iterable=None, /, **kwds): '''Create a new, empty Counter object. And if given, count elements from an input iterable. Or, initialize the count from another mapping of elements to their counts. >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping >>> c = Counter(a=4, b=2) # a new counter from keyword args ''' super().__init__() self.update(iterable, **kwds) def __missing__(self, key): 'The count of elements not in the Counter is zero.' # Needed so that self[missing_item] does not raise KeyError return 0 def total(self): 'Sum of the counts' return sum(self.values()) def most_common(self, n=None): '''List the n most common elements and their counts from the most common to the least. If n is None, then list all element counts. >>> Counter('abracadabra').most_common(3) [('a', 5), ('b', 2), ('r', 2)] ''' # Emulate Bag.sortedByCount from Smalltalk if n is None: return sorted(self.items(), key=_itemgetter(1), reverse=True) # Lazy import to speedup Python startup time import heapq return heapq.nlargest(n, self.items(), key=_itemgetter(1)) def elements(self): '''Iterator over elements repeating each as many times as its count. >>> c = Counter('ABCABC') >>> sorted(c.elements()) ['A', 'A', 'B', 'B', 'C', 'C'] # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1 >>> import math >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) >>> math.prod(prime_factors.elements()) 1836 Note, if an element's count has been set to zero or is a negative number, elements() will ignore it. ''' # Emulate Bag.do from Smalltalk and Multiset.begin from C++. return _chain.from_iterable(_starmap(_repeat, self.items())) # Override dict methods where necessary @classmethod def fromkeys(cls, iterable, v=None): # There is no equivalent method for counters because the semantics # would be ambiguous in cases such as Counter.fromkeys('aaabbc', v=2). # Initializing counters to zero values isn't necessary because zero # is already the default value for counter lookups. Initializing # to one is easily accomplished with Counter(set(iterable)). For # more exotic cases, create a dictionary first using a dictionary # comprehension or dict.fromkeys(). raise NotImplementedError( 'Counter.fromkeys() is undefined. Use Counter(iterable) instead.') def update(self, iterable=None, /, **kwds): '''Like dict.update() but add counts instead of replacing them. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.update('witch') # add elements from another iterable >>> d = Counter('watch') >>> c.update(d) # add elements from another counter >>> c['h'] # four 'h' in which, witch, and watch 4 ''' # The regular dict.update() operation makes no sense here because the # replace behavior results in some of the original untouched counts # being mixed-in with all of the other counts for a mismash that # doesn't have a straight-forward interpretation in most counting # contexts. Instead, we implement straight-addition. Both the inputs # and outputs are allowed to contain zero and negative counts. if iterable is not None: if isinstance(iterable, _collections_abc.Mapping): if self: self_get = self.get for elem, count in iterable.items(): self[elem] = count + self_get(elem, 0) else: # fast path when counter is empty super().update(iterable) else: _count_elements(self, iterable) if kwds: self.update(kwds) def subtract(self, iterable=None, /, **kwds): '''Like dict.update() but subtracts counts instead of replacing them. Counts can be reduced below zero. Both the inputs and outputs are allowed to contain zero and negative counts. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.subtract('witch') # subtract elements from another iterable >>> c.subtract(Counter('watch')) # subtract elements from another counter >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch 0 >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch -1 ''' if iterable is not None: self_get = self.get if isinstance(iterable, _collections_abc.Mapping): for elem, count in iterable.items(): self[elem] = self_get(elem, 0) - count else: for elem in iterable: self[elem] = self_get(elem, 0) - 1 if kwds: self.subtract(kwds) def copy(self): 'Return a shallow copy.' return self.__class__(self) def __reduce__(self): return self.__class__, (dict(self),) def __delitem__(self, elem): 'Like dict.__delitem__() but does not raise KeyError for missing values.' if elem in self: super().__delitem__(elem) def __repr__(self): if not self: return f'{self.__class__.__name__}()' try: # dict() preserves the ordering returned by most_common() d = dict(self.most_common()) except TypeError: # handle case where values are not orderable d = dict(self) return f'{self.__class__.__name__}({d!r})' # Multiset-style mathematical operations discussed in: # Knuth TAOCP Volume II section 4.6.3 exercise 19 # and at http://en.wikipedia.org/wiki/Multiset # # Outputs guaranteed to only include positive counts. # # To strip negative and zero counts, add-in an empty counter: # c += Counter() # # Results are ordered according to when an element is first # encountered in the left operand and then by the order # encountered in the right operand. # # When the multiplicities are all zero or one, multiset operations # are guaranteed to be equivalent to the corresponding operations # for regular sets. # Given counter multisets such as: # cp = Counter(a=1, b=0, c=1) # cq = Counter(c=1, d=0, e=1) # The corresponding regular sets would be: # sp = {'a', 'c'} # sq = {'c', 'e'} # All of the following relations would hold: # set(cp + cq) == sp | sq # set(cp - cq) == sp - sq # set(cp | cq) == sp | sq # set(cp & cq) == sp & sq # (cp == cq) == (sp == sq) # (cp != cq) == (sp != sq) # (cp <= cq) == (sp <= sq) # (cp < cq) == (sp < sq) # (cp >= cq) == (sp >= sq) # (cp > cq) == (sp > sq) def __eq__(self, other): 'True if all counts agree. Missing counts are treated as zero.' if not isinstance(other, Counter): return NotImplemented return all(self[e] == other[e] for c in (self, other) for e in c) def __ne__(self, other): 'True if any counts disagree. Missing counts are treated as zero.' if not isinstance(other, Counter): return NotImplemented return not self == other def __le__(self, other): 'True if all counts in self are a subset of those in other.' if not isinstance(other, Counter): return NotImplemented return all(self[e] <= other[e] for c in (self, other) for e in c) def __lt__(self, other): 'True if all counts in self are a proper subset of those in other.' if not isinstance(other, Counter): return NotImplemented return self <= other and self != other def __ge__(self, other): 'True if all counts in self are a superset of those in other.' if not isinstance(other, Counter): return NotImplemented return all(self[e] >= other[e] for c in (self, other) for e in c) def __gt__(self, other): 'True if all counts in self are a proper superset of those in other.' if not isinstance(other, Counter): return NotImplemented return self >= other and self != other def __add__(self, other): '''Add counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): newcount = count + other[elem] if newcount > 0: result[elem] = newcount for elem, count in other.items(): if elem not in self and count > 0: result[elem] = count return result def __sub__(self, other): ''' Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): newcount = count - other[elem] if newcount > 0: result[elem] = newcount for elem, count in other.items(): if elem not in self and count < 0: result[elem] = 0 - count return result def __or__(self, other): '''Union is the maximum of value in either of the input counters. >>> Counter('abbb') | Counter('bcc') Counter({'b': 3, 'c': 2, 'a': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): other_count = other[elem] newcount = other_count if count < other_count else count if newcount > 0: result[elem] = newcount for elem, count in other.items(): if elem not in self and count > 0: result[elem] = count return result def __and__(self, other): ''' Intersection is the minimum of corresponding counts. >>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): other_count = other[elem] newcount = count if count < other_count else other_count if newcount > 0: result[elem] = newcount return result def __pos__(self): 'Adds an empty counter, effectively stripping negative and zero counts' result = Counter() for elem, count in self.items(): if count > 0: result[elem] = count return result def __neg__(self): '''Subtracts from an empty counter. Strips positive and zero counts, and flips the sign on negative counts. ''' result = Counter() for elem, count in self.items(): if count < 0: result[elem] = 0 - count return result def _keep_positive(self): '''Internal method to strip elements with a negative or zero count''' nonpositive = [elem for elem, count in self.items() if not count > 0] for elem in nonpositive: del self[elem] return self def __iadd__(self, other): '''Inplace add from another counter, keeping only positive counts. >>> c = Counter('abbb') >>> c += Counter('bcc') >>> c Counter({'b': 4, 'c': 2, 'a': 1}) ''' for elem, count in other.items(): self[elem] += count return self._keep_positive() def __isub__(self, other): '''Inplace subtract counter, but keep only results with positive counts. >>> c = Counter('abbbc') >>> c -= Counter('bccd') >>> c Counter({'b': 2, 'a': 1}) ''' for elem, count in other.items(): self[elem] -= count return self._keep_positive() def __ior__(self, other): '''Inplace union is the maximum of value from either counter. >>> c = Counter('abbb') >>> c |= Counter('bcc') >>> c Counter({'b': 3, 'c': 2, 'a': 1}) ''' for elem, other_count in other.items(): count = self[elem] if other_count > count: self[elem] = other_count return self._keep_positive() def __iand__(self, other): '''Inplace intersection is the minimum of corresponding counts. >>> c = Counter('abbb') >>> c &= Counter('bcc') >>> c Counter({'b': 1}) ''' for elem, count in self.items(): other_count = other[elem] if other_count < count: self[elem] = other_count return self._keep_positive() ######################################################################## ### ChainMap ######################################################################## class ChainMap(_collections_abc.MutableMapping): ''' A ChainMap groups multiple dicts (or other mappings) together to create a single, updateable view. The underlying mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state. Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping. ''' def __init__(self, *maps): '''Initialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used. ''' self.maps = list(maps) or [{}] # always at least one map def __missing__(self, key): raise KeyError(key) def __getitem__(self, key): for mapping in self.maps: try: return mapping[key] # can't use 'key in mapping' with defaultdict except KeyError: pass return self.__missing__(key) # support subclasses that define __missing__ def get(self, key, default=None): return self[key] if key in self else default def __len__(self): return len(set().union(*self.maps)) # reuses stored hash values if possible def __iter__(self): d = {} for mapping in reversed(self.maps): d.update(dict.fromkeys(mapping)) # reuses stored hash values if possible return iter(d) def __contains__(self, key): return any(key in m for m in self.maps) def __bool__(self): return any(self.maps) @_recursive_repr() def __repr__(self): return f'{self.__class__.__name__}({", ".join(map(repr, self.maps))})' @classmethod def fromkeys(cls, iterable, *args): 'Create a ChainMap with a single dict created from the iterable.' return cls(dict.fromkeys(iterable, *args)) def copy(self): 'New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]' return self.__class__(self.maps[0].copy(), *self.maps[1:]) __copy__ = copy def new_child(self, m=None, **kwargs): # like Django's Context.push() '''New ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. Keyword arguments update the map or new empty dict. ''' if m is None: m = kwargs elif kwargs: m.update(kwargs) return self.__class__(m, *self.maps) @property def parents(self): # like Django's Context.pop() 'New ChainMap from maps[1:].' return self.__class__(*self.maps[1:]) def __setitem__(self, key, value): self.maps[0][key] = value def __delitem__(self, key): try: del self.maps[0][key] except KeyError: raise KeyError(f'Key not found in the first mapping: {key!r}') def popitem(self): 'Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.' try: return self.maps[0].popitem() except KeyError: raise KeyError('No keys found in the first mapping.') def pop(self, key, *args): 'Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].' try: return self.maps[0].pop(key, *args) except KeyError: raise KeyError(f'Key not found in the first mapping: {key!r}') def clear(self): 'Clear maps[0], leaving maps[1:] intact.' self.maps[0].clear() def __ior__(self, other): self.maps[0].update(other) return self def __or__(self, other): if not isinstance(other, _collections_abc.Mapping): return NotImplemented m = self.copy() m.maps[0].update(other) return m def __ror__(self, other): if not isinstance(other, _collections_abc.Mapping): return NotImplemented m = dict(other) for child in reversed(self.maps): m.update(child) return self.__class__(m) ################################################################################ ### UserDict ################################################################################ class UserDict(_collections_abc.MutableMapping): # Start by filling-out the abstract methods def __init__(self, dict=None, /, **kwargs): self.data = {} if dict is not None: self.update(dict) if kwargs: self.update(kwargs) def __len__(self): return len(self.data) def __getitem__(self, key): if key in self.data: return self.data[key] if hasattr(self.__class__, "__missing__"): return self.__class__.__missing__(self, key) raise KeyError(key) def __setitem__(self, key, item): self.data[key] = item def __delitem__(self, key): del self.data[key] def __iter__(self): return iter(self.data) # Modify __contains__ to work correctly when __missing__ is present def __contains__(self, key): return key in self.data # Now, add the methods in dicts but not in MutableMapping def __repr__(self): return repr(self.data) def __or__(self, other): if isinstance(other, UserDict): return self.__class__(self.data | other.data) if isinstance(other, dict): return self.__class__(self.data | other) return NotImplemented def __ror__(self, other): if isinstance(other, UserDict): return self.__class__(other.data | self.data) if isinstance(other, dict): return self.__class__(other | self.data) return NotImplemented def __ior__(self, other): if isinstance(other, UserDict): self.data |= other.data else: self.data |= other return self def __copy__(self): inst = self.__class__.__new__(self.__class__) inst.__dict__.update(self.__dict__) # Create a copy and avoid triggering descriptors inst.__dict__["data"] = self.__dict__["data"].copy() return inst def copy(self): if self.__class__ is UserDict: return UserDict(self.data.copy()) import copy data = self.data try: self.data = {} c = copy.copy(self) finally: self.data = data c.update(self) return c @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d ################################################################################ ### UserList ################################################################################ class UserList(_collections_abc.MutableSequence): """A more or less complete user-defined wrapper around list objects.""" def __init__(self, initlist=None): self.data = [] if initlist is not None: # XXX should this accept an arbitrary sequence? if type(initlist) == type(self.data): self.data[:] = initlist elif isinstance(initlist, UserList): self.data[:] = initlist.data[:] else: self.data = list(initlist) def __repr__(self): return repr(self.data) def __lt__(self, other): return self.data < self.__cast(other) def __le__(self, other): return self.data <= self.__cast(other) def __eq__(self, other): return self.data == self.__cast(other) def __gt__(self, other): return self.data > self.__cast(other) def __ge__(self, other): return self.data >= self.__cast(other) def __cast(self, other): return other.data if isinstance(other, UserList) else other def __contains__(self, item): return item in self.data def __len__(self): return len(self.data) def __getitem__(self, i): if isinstance(i, slice): return self.__class__(self.data[i]) else: return self.data[i] def __setitem__(self, i, item): self.data[i] = item def __delitem__(self, i): del self.data[i] def __add__(self, other): if isinstance(other, UserList): return self.__class__(self.data + other.data) elif isinstance(other, type(self.data)): return self.__class__(self.data + other) return self.__class__(self.data + list(other)) def __radd__(self, other): if isinstance(other, UserList): return self.__class__(other.data + self.data) elif isinstance(other, type(self.data)): return self.__class__(other + self.data) return self.__class__(list(other) + self.data) def __iadd__(self, other): if isinstance(other, UserList): self.data += other.data elif isinstance(other, type(self.data)): self.data += other else: self.data += list(other) return self def __mul__(self, n): return self.__class__(self.data * n) __rmul__ = __mul__ def __imul__(self, n): self.data *= n return self def __copy__(self): inst = self.__class__.__new__(self.__class__) inst.__dict__.update(self.__dict__) # Create a copy and avoid triggering descriptors inst.__dict__["data"] = self.__dict__["data"][:] return inst def append(self, item): self.data.append(item) def insert(self, i, item): self.data.insert(i, item) def pop(self, i=-1): return self.data.pop(i) def remove(self, item): self.data.remove(item) def clear(self): self.data.clear() def copy(self): return self.__class__(self) def count(self, item): return self.data.count(item) def index(self, item, *args): return self.data.index(item, *args) def reverse(self): self.data.reverse() def sort(self, /, *args, **kwds): self.data.sort(*args, **kwds) def extend(self, other): if isinstance(other, UserList): self.data.extend(other.data) else: self.data.extend(other) ################################################################################ ### UserString ################################################################################ class UserString(_collections_abc.Sequence): def __init__(self, seq): if isinstance(seq, str): self.data = seq elif isinstance(seq, UserString): self.data = seq.data[:] else: self.data = str(seq) def __str__(self): return str(self.data) def __repr__(self): return repr(self.data) def __int__(self): return int(self.data) def __float__(self): return float(self.data) def __complex__(self): return complex(self.data) def __hash__(self): return hash(self.data) def __getnewargs__(self): return (self.data[:],) def __eq__(self, string): if isinstance(string, UserString): return self.data == string.data return self.data == string def __lt__(self, string): if isinstance(string, UserString): return self.data < string.data return self.data < string def __le__(self, string): if isinstance(string, UserString): return self.data <= string.data return self.data <= string def __gt__(self, string): if isinstance(string, UserString): return self.data > string.data return self.data > string def __ge__(self, string): if isinstance(string, UserString): return self.data >= string.data return self.data >= string def __contains__(self, char): if isinstance(char, UserString): char = char.data return char in self.data def __len__(self): return len(self.data) def __getitem__(self, index): return self.__class__(self.data[index]) def __add__(self, other): if isinstance(other, UserString): return self.__class__(self.data + other.data) elif isinstance(other, str): return self.__class__(self.data + other) return self.__class__(self.data + str(other)) def __radd__(self, other): if isinstance(other, str): return self.__class__(other + self.data) return self.__class__(str(other) + self.data) def __mul__(self, n): return self.__class__(self.data * n) __rmul__ = __mul__ def __mod__(self, args): return self.__class__(self.data % args) def __rmod__(self, template): return self.__class__(str(template) % self) # the following methods are defined in alphabetical order: def capitalize(self): return self.__class__(self.data.capitalize()) def casefold(self): return self.__class__(self.data.casefold()) def center(self, width, *args): return self.__class__(self.data.center(width, *args)) def count(self, sub, start=0, end=_sys.maxsize): if isinstance(sub, UserString): sub = sub.data return self.data.count(sub, start, end) def removeprefix(self, prefix, /): if isinstance(prefix, UserString): prefix = prefix.data return self.__class__(self.data.removeprefix(prefix)) def removesuffix(self, suffix, /): if isinstance(suffix, UserString): suffix = suffix.data return self.__class__(self.data.removesuffix(suffix)) def encode(self, encoding='utf-8', errors='strict'): encoding = 'utf-8' if encoding is None else encoding errors = 'strict' if errors is None else errors return self.data.encode(encoding, errors) def endswith(self, suffix, start=0, end=_sys.maxsize): return self.data.endswith(suffix, start, end) def expandtabs(self, tabsize=8): return self.__class__(self.data.expandtabs(tabsize)) def find(self, sub, start=0, end=_sys.maxsize): if isinstance(sub, UserString): sub = sub.data return self.data.find(sub, start, end) def format(self, /, *args, **kwds): return self.data.format(*args, **kwds) def format_map(self, mapping): return self.data.format_map(mapping) def index(self, sub, start=0, end=_sys.maxsize): return self.data.index(sub, start, end) def isalpha(self): return self.data.isalpha() def isalnum(self): return self.data.isalnum() def isascii(self): return self.data.isascii() def isdecimal(self): return self.data.isdecimal() def isdigit(self): return self.data.isdigit() def isidentifier(self): return self.data.isidentifier() def islower(self): return self.data.islower() def isnumeric(self): return self.data.isnumeric() def isprintable(self): return self.data.isprintable() def isspace(self): return self.data.isspace() def istitle(self): return self.data.istitle() def isupper(self): return self.data.isupper() def join(self, seq): return self.data.join(seq) def ljust(self, width, *args): return self.__class__(self.data.ljust(width, *args)) def lower(self): return self.__class__(self.data.lower()) def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars)) maketrans = str.maketrans def partition(self, sep): return self.data.partition(sep) def replace(self, old, new, maxsplit=-1): if isinstance(old, UserString): old = old.data if isinstance(new, UserString): new = new.data return self.__class__(self.data.replace(old, new, maxsplit)) def rfind(self, sub, start=0, end=_sys.maxsize): if isinstance(sub, UserString): sub = sub.data return self.data.rfind(sub, start, end) def rindex(self, sub, start=0, end=_sys.maxsize): return self.data.rindex(sub, start, end) def rjust(self, width, *args): return self.__class__(self.data.rjust(width, *args)) def rpartition(self, sep): return self.data.rpartition(sep) def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars)) def split(self, sep=None, maxsplit=-1): return self.data.split(sep, maxsplit) def rsplit(self, sep=None, maxsplit=-1): return self.data.rsplit(sep, maxsplit) def splitlines(self, keepends=False): return self.data.splitlines(keepends) def startswith(self, prefix, start=0, end=_sys.maxsize): return self.data.startswith(prefix, start, end) def strip(self, chars=None): return self.__class__(self.data.strip(chars)) def swapcase(self): return self.__class__(self.data.swapcase()) def title(self): return self.__class__(self.data.title()) def translate(self, *args): return self.__class__(self.data.translate(*args)) def upper(self): return self.__class__(self.data.upper()) def zfill(self, width): return self.__class__(self.data.zfill(width)) PK ge[#((%__pycache__/abc.cpython-311.opt-1.pycnu[ !A?hw&ddlTddlmZddlmZdS))*)__all__)_CallableGenericAliasN)_collections_abcrr(/usr/lib64/python3.11/collections/abc.pyr s;$$$$$$22222222rPK ge[#((%__pycache__/abc.cpython-311.opt-2.pycnu[ !A?hw&ddlTddlmZddlmZdS))*)__all__)_CallableGenericAliasN)_collections_abcrr(/usr/lib64/python3.11/collections/abc.pyr s;$$$$$$22222222rPK ge[#((__pycache__/abc.cpython-311.pycnu[ !A?hw&ddlTddlmZddlmZdS))*)__all__)_CallableGenericAliasN)_collections_abcrr(/usr/lib64/python3.11/collections/abc.pyr s;$$$$$$22222222rPK ge[5€$11$__pycache__/__init__.cpython-311.pycnu[ !A?h2dZgdZddlZddlZddlmZddlmZ ddlm Z ddl m ZddlmZdd lmZdd lmZdd lmZ dd lmZejen #e$rYnwxYw dd lmZn #e$rYnwxYwGddej Z!Gddej"Z#Gddej$Z%Gdde&Z'Gdde(Z) ddlm)Z)n #e$rYnwxYw ddlm*Z*n#e$rdZ*YnwxYwdddddZ+dZ, ddlm,Z,n #e$rYnwxYwGd d!e(Z-Gd"d#ej.Z/Gd$d%ej.Z0Gd&d'ejZ1Gd(d)ej2Z3dS)*a?This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, dict, list, set, and tuple. * namedtuple factory function for creating tuple subclasses with named fields * deque list-like container with fast appends and pops on either end * ChainMap dict-like class for creating a single view of multiple mappings * Counter dict subclass for counting hashable objects * OrderedDict dict subclass that remembers the order entries were added * defaultdict dict subclass that calls a factory function to supply missing values * UserDict wrapper around dictionary objects for easier dict subclassing * UserList wrapper around list objects for easier list subclassing * UserString wrapper around string objects for easier string subclassing ) ChainMapCounter OrderedDictUserDictUserList UserString defaultdictdeque namedtupleN)chain)repeat)starmap) iskeyword)eq) itemgetter)recursive_repr)proxy)r )rceZdZdZdS)_OrderedDictKeysViewc#>Kt|jEd{VdSNreversed_mappingselfs -/usr/lib64/python3.11/collections/__init__.py __reversed__z!_OrderedDictKeysView.__reversed__<s.DM***********N__name__ __module__ __qualname__rrrrr:s#+++++rrceZdZdZdS)_OrderedDictItemsViewc#ZKt|jD]}||j|fVdSrrrkeys rrz"_OrderedDictItemsView.__reversed__AsDDM** , ,C c*+ + + + + , ,rNr r$rrr&r&?s#,,,,,rr&ceZdZdZdS)_OrderedDictValuesViewc#VKt|jD]}|j|VdSrrr(s rrz#_OrderedDictValuesView.__reversed__Gs?DM** % %C-$ $ $ $ $ % %rNr r$rrr+r+Es#%%%%%rr+ceZdZdZdS)_Link)prevnextr) __weakref__N)r!r"r# __slots__r$rrr.r.Ks4IIIrr.cBeZdZdZdZddZejee fdZej fdZ dZ dZ d Z dd Zdd Zd ZejjxZZdZdZdZejjZeZefdZddZedZdZdZ e!ddZ"dZ#dZ$dZ%dZ&dS)rz)Dictionary that remembers insertion orderct|}t|_t |jx|_}|x|_|_i|_|S)zDCreate the ordered dict object and set up the underlying structures.) dict__new__r._OrderedDict__hardroot_proxy_OrderedDict__rootr/r0_OrderedDict__map)clsargskwdsrroots rr6zOrderedDict.__new__]sN||C  ''#DO444 d $$ DI  rr$c "|j|fi|dS)zInitialize an ordered dictionary. The signature is the same as regular dictionaries. Keyword argument order is preserved. N)_OrderedDict__update)rotherr=s r__init__zOrderedDict.__init__fs$  e$$t$$$$$rc||vrO|x|j|<}|j}|j}|||c|_|_|_||_|||_||||dS)z!od.__setitem__(i, y) <==> od[i]=yN)r:r9r/r0r)) rr)value dict_setitemrLinklinkr>lasts r __setitem__zOrderedDict.__setitem__lsw d??%)TVV +DJsOd;D9D-14 *DIty$(DId DI T3&&&&&rc||||j|}|j}|j}||_||_d|_d|_dS)z od.__delitem__(y) <==> del od[y]N)r:popr/r0)rr) dict_delitemrG link_prev link_nexts r __delitem__zOrderedDict.__delitem__zsW  T3z~~c""I I " "   rc#ZK|j}|j}||ur|jV|j}||udSdS)zod.__iter__() <==> iter(od)N)r9r0r)rr>currs r__iter__zOrderedDict.__iter__L{y$(NNN9D$rc#ZK|j}|j}||ur|jV|j}||udSdS)z#od.__reversed__() <==> reversed(od)N)r9r/r)rQs rrzOrderedDict.__reversed__rTrc|j}|x|_|_|jt |dS)z.od.clear() -> None. Remove all items from od.N)r9r/r0r:clearr5)rr>s rrWzOrderedDict.clearsC{ $$ DI  4rTc|std|j}|r|j}|j}||_||_n|j}|j}||_||_|j}|j|=t ||}||fS)zRemove and return a (key, value) pair from the dictionary. Pairs are returned in LIFO order if last is true or FIFO order if false. zdictionary is empty)KeyErrorr9r/r0r)r:r5rK)rrHr>rGrMrNr)rDs rpopitemzOrderedDict.popitems  2011 1{  "9D I!IN!DII9D I!DI!INh JsOs##Ezrc|j|}|j}|j}|j}||_||_|j}|r%|j}||_||_||_||_dS|j}||_||_||_||_dS)zMove an existing element to the end (or beginning if last is false). Raise KeyError if the element does not exist. N)r:r/r0r9) rr)rHrGrMrN soft_linkr>firsts r move_to_endzOrderedDict.move_to_ends z#I I N " " {  9DDIDI!DIDIIIIEDIDI"EJDIIIrctj}t|dz}||j}|||jdzz }|||j|zz }|||j|zz }|S)N)_sys getsizeoflen__dict__r:r7r9)rsizeofnsizes r __sizeof__zOrderedDict.__sizeof__s IIMvdm$$ tz""Q&& t''!++ t{##a'' rc t|S)z:D.keys() -> a set-like object providing a view on D's keys)rrs rkeyszOrderedDict.keyss#D)))rc t|S)z a set-like object providing a view on D's items)r&rs ritemszOrderedDict.itemss$T***rc t|S)z6D.values() -> an object providing a view on D's values)r+rs rvalueszOrderedDict.valuess%d+++rc|j}t|||}||urF|j|}|j}|j}||_||_d|_d|_|S||urt ||S)zod.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. N)_OrderedDict__markerr5rKr:r/r0rY)rr)defaultmarkerresultrGrMrNs rrKzOrderedDict.pops $V,,   :>>#&&D I I&IN&INDIDIM f  3-- rNc(||vr||S|||<|S)zInsert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default. r$rr)rrs r setdefaultzOrderedDict.setdefaults% $;;9 S rc|s|jjdS|jjdt|dS)zod.__repr__() <==> repr(od)()()) __class__r!listrmrs r__repr__zOrderedDict.__repr__ sL 7!^4446 6>222D4F4F4F4FGGrc|}|rt|tr|\}}ni}|}|}t t D].}||d||d/|r||f}n|pd}|jd|dt| fS)z%Return state information for picklingNr$) __getstate__ isinstancetuplecopyvarsrrKr|iterrm)rstateslotsks r __reduce__zOrderedDict.__reduce__s!!##  &%'' $ uuJJLLEJJLLE+--(( # # !T""" !T"""" &u  ~r5$TZZ\\0B0BBBrc,||S)z!od.copy() -> a shallow copy of odr|rs rrzOrderedDict.copy%~~d###rc.|}|D]}|||<|S)zYCreate a new ordered dictionary with keys from iterable and values set to value. r$)r;iterablerDrr)s rfromkeyszOrderedDict.fromkeys)s.suu  CDII rct|tr>t||o"t t t ||St||S)zod.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. )rrr5__eq__allmap_eqrrAs rrzOrderedDict.__eq__2sX e[ ) ) K;;tU++JCT54I4I0J0J J{{4'''rc0|||Sr)updaters r__ior__zOrderedDict.__ior__;s E rct|tstS||}|||Srrr5NotImplementedr|rrrAnews r__or__zOrderedDict.__or__?sB%&& "! !nnT"" 5 rct|tstS||}|||Srrrs r__ror__zOrderedDict.__ror__FsB%&& "! !nnU## 4 r)r$)Tr)'r!r"r#__doc__r6rBr5rIr8r.rOrSrrWrZr^ri_collections_abcMutableMappingrr@rkrmro__ne__objectrqrKrw_recursive_reprr~rr classmethodrrrrrr$rrrrNs//%%%%"&!1e ' ' ' '-1,<    .2)7>>FX***+++,,, , 3FvxxH',_HHH CCC&$$$[(((rr)r) _tuplegetterc>tt||S)N)doc)property _itemgetter)indexrs rr\sh{5/A/As&K&K&KrF)renamedefaultsmodulec  ttr(ddt t tt jt|}|r|t}tD]^\}}| r(t|s| ds||vrd||<| |_|gzD]n}t|turtd| st!d|t|rt!d|ot}D]V}| dr|st!d|||vrt!d|| |Wi}|t#|}t%|t%krtd t't)t t+t)t)|}t#t t jt%d } d kr| dz } d d dDzdzt"jt&t"t$t t*f\id|d} d| d| d} t1| | } d| _d|d | d| _||| _t8fd} d|d| j_fd}d|d|_fd}fd}fd}| | j||||fD]}|d |j|_|d | dd!|| | ||||d" }tD]/\}}t jd#|}t?||||<0t|t"f|}|F t j d j!"d$d%}n#tFt f$rYnwxYw|||_$|S)&aCReturns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22) , _z*Type names and field names must be stringsz6Type names and field names must be valid identifiers: z0Type names and field names cannot be a keyword: z-Field names cannot start with an underscore: z"Encountered duplicate field name: Nz(Got more default values than field names, r`rzc3 K|] }|dV dS)z=%rNr$).0names r znamedtuple..s(DD$|||DDDDDDrr{ namedtuple_) _tuple_new __builtins__r!z lambda _cls, z: _tuple_new(_cls, (z))r6zCreate new instance of c||}|kr"tddt||S)Nz Expected z arguments, got ) TypeErrorrd)r;rrt_len num_fields tuple_news r_makeznamedtuple.._makesQ3)) 4<<: % %Q QQCKKQQRR R rz Make a new z# object from a sequence or iterablec||j|}|rtdt||S)NzGot unexpected field names: )rrK ValueErrorr})rr=rt_map field_namess r_replaceznamedtuple.._replacesODD;==>>  LJDJJJJKK K rz Return a new z2 object replacing specified fields with new valuesc(|jj|zzS)z/Return a nicely formatted representation string)r|r!)rrepr_fmts rr~znamedtuple..__repr__s~&D88rc8|j|S)z9Return a new dict which maps field names to their values.)_fields)r_dict_zips r_asdictznamedtuple.._asdicts!uTT$,--...rc|S)z7Return self as a plain tuple. Used by copy and pickle.r$)r_tuples r__getnewargs__z"namedtuple..__getnewargs__svd||r.r$) rr2r_field_defaultsr6rrr~rr__match_args__zAlias for field number r!__main__)%rstrreplacesplitr}rrbinternset enumerate isidentifier _iskeyword startswithaddtyperrrrdr5rzipjoinr6evalr!r __defaults__r__func__r#r _getframe f_globalsgetAttributeErrorr")typenamerrrrseenrrfield_defaultsarg_list namespacecoder6rrr~rrmethodclass_namespacerrtrrrrrrrrs ` @@@@@@@@rr r ^s4+s##<!))#s3399;; s3 ,,--K{3x==))H uu$[11  KE4%%'' 1d## 1??3'' 14<<%0[[ E" HHTNNNN [(33 ::S HII I  "" 76-16677 7 d   32)-2233 3 3 55D ??3   * *) $))** * 4<<J$JJKK K N?? x==3{++ + +FGG GhtC0E0E080B0B-D-D(E(EFFGGDK5566K[!!Jyy%%HQCTYYDD DDDDDDsJH I&*E3S&@#E64t  ,(,,I F8 E E E E ED4##G GFFF8FFFGO'[ ,H,,,EN 1111H99999//////   >>"*==FO== ,,,,,)(%  O!--99 tk;E;;<< ,UC 8 8 (UHo 6 6F~ ^A&&044ZLLFF +    D  " Ms7-Q%%Q98Q9cB|j}|D]}||ddz||<dS)z!Tally elements from the iterable.r r`N)r)mappingr mapping_getelems r_count_elementsr s>+K11# D!,,q0 11r)rceZdZdZd fd ZdZdZd dZdZe d dZ d fd Z d d Z d Z d Zfd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!xZ"S)!raDict subclass for counting hashable items. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values. >>> c = Counter('abcdeabcdabcaba') # count elements from a string >>> c.most_common(3) # three most common elements [('a', 5), ('b', 4), ('c', 3)] >>> sorted(c) # list all unique elements ['a', 'b', 'c', 'd', 'e'] >>> ''.join(sorted(c.elements())) # list elements with repetitions 'aaaaabbbbcccdde' >>> sum(c.values()) # total of all counts 15 >>> c['a'] # count of letter 'a' 5 >>> for elem in 'shazam': # update counts from an iterable ... c[elem] += 1 # by adding 1 to each element's count >>> c['a'] # now there are seven 'a' 7 >>> del c['b'] # remove all 'b' >>> c['b'] # now there are zero 'b' 0 >>> d = Counter('simsalabim') # make another counter >>> c.update(d) # add in the second counter >>> c['a'] # now there are nine 'a' 9 >>> c.clear() # empty the counter >>> c Counter() Note: If a count is set to zero or reduced to zero, it will remain in the counter until the entry is deleted or the counter is cleared: >>> c = Counter('aaabbc') >>> c['b'] -= 2 # reduce the count of 'b' by two >>> c.most_common() # 'b' is still in, but its count is zero [('a', 3), ('c', 1), ('b', 0)] Nc dt|j|fi|dS)a Create a new, empty Counter object. And if given, count elements from an input iterable. Or, initialize the count from another mapping of elements to their counts. >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping >>> c = Counter(a=4, b=2) # a new counter from keyword args N)superrBr)rrr=r|s rrBzCounter.__init__Ks;  H%%%%%%%rcdS)z1The count of elements not in the Counter is zero.r r$r(s r __missing__zCounter.__missing__Ys qrcDt|S)zSum of the counts)sumrors rtotalz Counter.total^s4;;==!!!rc|1t|tddSddl}|||tdS)zList the n most common elements and their counts from the most common to the least. If n is None, then list all element counts. >>> Counter('abracadabra').most_common(3) [('a', 5), ('b', 2), ('r', 2)] Nr`T)r)reverser )r))sortedrmrheapqnlargest)rrgrs r most_commonzCounter.most_commonbs] 9$**,,KNNDIII I  ~~a;q>>~BBBrcttjtt|S)aIterator over elements repeating each as many times as its count. >>> c = Counter('ABCABC') >>> sorted(c.elements()) ['A', 'A', 'B', 'B', 'C', 'C'] # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1 >>> import math >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) >>> math.prod(prime_factors.elements()) 1836 Note, if an element's count has been set to zero or is a negative number, elements() will ignore it. )_chain from_iterable_starmap_repeatrmrs relementszCounter.elementsrs'$#HWdjjll$C$CDDDrc td)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)r;rvs rrzCounter.fromkeyss" NPP Prc B|t|tjrX|r4|j}|D]\}}|||dz||<n2t |nt|||r||dSdS)aLike dict.update() but add counts instead of replacing them. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.update('witch') # add elements from another iterable >>> d = Counter('watch') >>> c.update(d) # add elements from another counter >>> c['h'] # four 'h' in which, witch, and watch 4 Nr )rrMappingrrmrrr)rrr=self_getrcountr|s rrzCounter.updates(  ($4$<== 0-#xH'/~~'7'7?? e%*XXdA->->%>T ?GGNN8,,,,h///   KK       rc |e|j}t|tjr-|D]\}}||d|z ||<n|D]}||ddz ||<|r||dSdS)aLike dict.update() but subtracts counts instead of replacing them. Counts can be reduced below zero. Both the inputs and outputs are allowed to contain zero and negative counts. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.subtract('witch') # subtract elements from another iterable >>> c.subtract(Counter('watch')) # subtract elements from another counter >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch 0 >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch -1 Nr r`)rrrrrmsubtract)rrr=rrrs rrzCounter.subtracts  xH($4$<== 7#+>>#3#3;;KD%!)$!2!2U!:DJJ;%77D!)$!2!2Q!6DJJ  MM$       rc,||S)zReturn a shallow copy.rrs rrz Counter.copyrrc0|jt|ffSr)r|r5rs rrzCounter.__reduce__s~T },,rcV||vr#t|dSdS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rrO)rrr|s rrOzCounter.__delitem__s1 4<< GG   % % % % % .=II1qII!47eAh&IIIIIIIrrrrrrs``rrzCounter.__eq__ F%)) "! !IIIIIu IIIIIIrcHt|tstS||k S)z@True if any counts disagree. Missing counts are treated as zero.rrrrs rrzCounter.__ne__s'%)) "! !5=  rczttstStfdfDS)z:True if all counts in self are a subset of those in other.c3FK|]}|D]}||kVdSrr$rs rrz!Counter.__le__..rrr rs``r__le__zCounter.__le__r!rcRt|tstS||ko||kS)zATrue if all counts in self are a proper subset of those in other.r#rs r__lt__zCounter.__lt__-%)) "! !u}..rczttstStfdfDS)z.&rrr rs``r__ge__zCounter.__ge__"r!rcRt|tstS||ko||kS)zCTrue if all counts in self are a proper superset of those in other.r#rs r__gt__zCounter.__gt__(r)rc t|tstSt}|D]\}}|||z}|dkr|||<|D]\}}||vr |dkr|||<|S)zAdd counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) r rrrrmrrArtrrnewcounts r__add__zCounter.__add__.s%)) "! !::<< ( (KD%uT{*H!||'t  ;;== % %KD%4EAII$t  rct|tstSt}|D]\}}|||z }|dkr|||<|D]\}}||vr|dkrd|z ||<|S)z Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) r r0r1s r__sub__zCounter.__sub__As%)) "! !::<< ( (KD%uT{*H!||'t  ;;== ) )KD%4EAII 5yt  rct|tstSt}|D]"\}}||}||kr|n|}|dkr|||<#|D]\}}||vr |dkr|||<|S)zUnion is the maximum of value in either of the input counters. >>> Counter('abbb') | Counter('bcc') Counter({'b': 3, 'c': 2, 'a': 1}) r r0rrArtrr other_countr2s rrzCounter.__or__Ts%)) "! !::<< ( (KD%+K&+k&9&9{{uH!||'t  ;;== % %KD%4EAII$t  rct|tstSt}|D]"\}}||}||kr|n|}|dkr|||<#|S)z Intersection is the minimum of corresponding counts. >>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) r r0r7s r__and__zCounter.__and__hst%)) "! !::<< ( (KD%+K % 3 3uuH!||'t  rclt}|D]\}}|dkr|||<|S)zEAdds an empty counter, effectively stripping negative and zero countsr rrmrrtrrs r__pos__zCounter.__pos__ys>::<< % %KD%qyy$t  rcrt}|D]\}}|dkrd|z ||<|S)z{Subtracts from an empty counter. Strips positive and zero counts, and flips the sign on negative counts. r r<r=s r__neg__zCounter.__neg__sD ::<< ) )KD%qyy 5yt  rcRd|D}|D]}||=|S)z?Internal method to strip elements with a negative or zero countc$g|] \}}|dk |S)r r$)rrrs r z*Counter._keep_positive..s!MMM e5199t999r)rm)r nonpositivers r_keep_positivezCounter._keep_positives:MMtzz||MMM   DT  rc~|D]\}}||xx|z cc<|S)zInplace add from another counter, keeping only positive counts. >>> c = Counter('abbb') >>> c += Counter('bcc') >>> c Counter({'b': 4, 'c': 2, 'a': 1}) rmrErrArrs r__iadd__zCounter.__iadd__I!;;==  KD% JJJ% JJJJ""$$$rc~|D]\}}||xx|zcc<|S)zInplace subtract counter, but keep only results with positive counts. >>> c = Counter('abbbc') >>> c -= Counter('bccd') >>> c Counter({'b': 2, 'a': 1}) rGrHs r__isub__zCounter.__isub__rJrc|D]\}}||}||kr|||<|S)zInplace union is the maximum of value from either counter. >>> c = Counter('abbb') >>> c |= Counter('bcc') >>> c Counter({'b': 3, 'c': 2, 'a': 1}) rG)rrArr8rs rrzCounter.__ior__sP"' ) ) D+JEU""(T ""$$$rc|D]\}}||}||kr|||<|S)zInplace intersection is the minimum of corresponding counts. >>> c = Counter('abbb') >>> c &= Counter('bcc') >>> c Counter({'b': 1}) rG)rrArrr8s r__iand__zCounter.__iand__sO ::<< ) )KD%+KU""(T ""$$$rr)#r!r"r#rrBrrrr rrrrrrrOr~rrr&r(r,r.r3r5rr:r>r@rErIrLrrO __classcell__rs@rrrs6**d & & & & & & """CCCC EEE, P P P[ P      D    6$$$---&&&&& 3 3 3ZJJJ !!! JJJ /// JJJ /// &&("    % % % % % % % % % % % % % % % %rrceZdZdZdZdZdZddZdZdZ d Z d Z e d Z ed Zd ZeZddZedZdZdZdZdZdZdZdZdZdS)ra A ChainMap groups multiple dicts (or other mappings) together to create a single, updateable view. The underlying mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state. Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping. c4t|pig|_dS)zInitialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used. N)r}maps)rrSs rrBzChainMap.__init__s JJ&2$ rc t|r)rYr(s rrzChainMap.__missing__ssmmrct|jD]} ||cS#t$rYwxYw||Sr)rSrYr)rr)rs r __getitem__zChainMap.__getitem__s\y  G s|###    $$$s  ""Nc||vr||n|Srr$rvs rrz ChainMap.gets4KKtCyyW4rcRttj|jSr)rdrunionrSrs r__len__zChainMap.__len__s;355; *+++rci}t|jD]/}|t|0t |Sr)rrSrr5rr)rrrs rrSzChainMap.__iter__sL  ** - -G HHT]]7++ , , , ,AwwrcDtfd|jDS)Nc3 K|]}|vV dSrr$)rmr)s rrz(ChainMap.__contains__..s'//3!8//////ranyrSr(s `r __contains__zChainMap.__contains__s(////TY//////rc*t|jSrr_rs r__bool__zChainMap.__bool__49~~rc||jjddtt|jdS)Nrzrr{)r|r!rrreprrSrs rr~zChainMap.__repr__s6.)NNDIIc$ 6J6J,K,KNNNNrc8|tj|g|RS)z?Create a ChainMap with a single dict created from the iterable.)r5r)r;rr<s rrzChainMap.fromkeyss&s4=1D111222rcr|j|jdg|jddRS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r r`N)r|rSrrs rrz ChainMap.copy s8t~dil//11BDIabbMBBBBrc `||}n|r|||j|g|jRS)zNew ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. Keyword arguments update the map or new empty dict. )rr|rS)rr^kwargss r new_childzChainMap.new_childsF 9AA   HHV   t~a,$),,,,rc0|j|jddS)zNew ChainMap from maps[1:].r`N)r|rSrs rparentszChainMap.parentsst~ty}--rc&||jd|<dSNr )rS)rr)rDs rrIzChainMap.__setitem__!s! ! Srcd |jd|=dS#t$rtd|wxYw)Nr $Key not found in the first mapping: )rSrYr(s rrOzChainMap.__delitem__$sR K ! S!!! K K KI#IIJJ J Ks/c| |jdS#t$rtdwxYw)zPRemove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.r z#No keys found in the first mapping.)rSrZrYrs rrZzChainMap.popitem*sN B9Q<'')) ) B B B@AA A Bs!;cv |jdj|g|RS#t$rtd|wxYw)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r rq)rSrKrY)rr)r<s rrKz ChainMap.pop1s_ K#49Q<#C/$/// / K K KI#IIJJ J Ks8cD|jddS)z'Clear maps[0], leaving maps[1:] intact.r N)rSrWrs rrWzChainMap.clear8s  ! rcF|jd||Sro)rSrrs rrzChainMap.__ior__<s! ! E""" rct|tjstS|}|jd||Sro)rrrrrrSr)rrAr^s rrzChainMap.__or__@sJ%!1!9:: "! ! IIKK q rct|tjstSt |}t |jD]}||||Sr) rrrrr5rrSrr|)rrAr^childs rrzChainMap.__ror__Gse%!1!9:: "! ! KKdi((  E HHUOOOO~~a   rr)r!r"r#rrBrrVrrZrSrarcrr~rrr__copy__rkrrmrIrOrZrKrWrrrr$rrrrs  '''%%%5555,,, 000_OOO33[3CCCH - - - -..X."""KKK BBBKKK!!!!!rrcveZdZddZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZeddZdS)rNc ti|_||||r||dSdSr)datar)rr5rjs rrBzUserDict.__init__WsK   KK     KK       rc*t|jSrrdr|rs rrZzUserDict.__len__^rdrc||jvr |j|St|jdr|j||St |)Nr)r|hasattrr|rrYr(s rrVzUserDict.__getitem__asS $)  9S> ! 4>= 1 1 9>--dC88 8smmrc||j|<dSrr|)rr)items rrIzUserDict.__setitem__hs #rc|j|=dSrrr(s rrOzUserDict.__delitem__ks IcNNNrc*t|jSr)rr|rs rrSzUserDict.__iter__nDIrc||jvSrrr(s rrazUserDict.__contains__rsdirc*t|jSrrfr|rs rr~zUserDict.__repr__vrrct|tr"||j|jzSt|tr||j|zSt Srrrr|r|r5rrs rrzUserDict.__or__ys` eX & & :>>$)ej"899 9 eT " " 5>>$)e"344 4rct|tr"||j|jzSt|tr|||jzSt Srrrs rrzUserDict.__ror__s` eX & & :>>%*ty"899 9 eT " " 5>>%$)"344 4rc|t|tr|xj|jzc_n|xj|zc_|Sr)rrr|rs rrzUserDict.__ior__s= eX & &  II #III II II rc|j|j}|j|j|jd|jd<|SNr|)r|r6rerrrinsts rryzUserDict.__copy__sU~%%dn55 T]+++ $ f 5 : : < < f rc|jtur&t|jSddl}|j} i|_||}||_n #||_wxYw|||Sro)r|rr|rr)rrr|rs rrz UserDict.copys >X % %DINN,,-- - y DI $ADIIDI     s A%% A.c.|}|D]}|||<|Srr$)r;rrDrr)s rrzUserDict.fromkeyss, CEE  CAcFFrr)r!r"r#rBrZrVrIrOrSrar~rrrryrrrr$rrrrTs          [rrceZdZdZd"dZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZeZdZdZdZdZd#dZdZdZdZdZdZdZ d Z!d!Z"dS)$rzAA more or less complete user-defined wrapper around list objects.Nc g|_|yt|t|jkr||jdd<dSt|tr|jdd|jdd<dSt ||_dSdSr)r|rrrr})rinitlists rrBzUserList.__init__s  H~~di00' !!! Hh// +'}QQQ/ !!!  NN  rc*t|jSrrrs rr~zUserList.__repr__rrc>|j||kSrr|_UserList__castrs rr(zUserList.__lt__y4;;u----rc>|j||kSrrrs rr&zUserList.__le__yDKK....rc>|j||kSrrrs rrzUserList.__eq__rrc>|j||kSrrrs rr.zUserList.__gt__rrc>|j||kSrrrs rr,zUserList.__ge__rrc>t|tr|jn|Sr)rrr|rs r__castzUserList.__casts'x88CuzzeCrc||jvSrrrrs rrazUserList.__contains__sty  rc*t|jSrr~rs rrZzUserList.__len__rdrct|tr ||j|S|j|Sr)rslicer|r|ris rrVzUserList.__getitem__s8 a   >>$)A,// /9Q< rc||j|<dSrrrrrs rrIzUserList.__setitem__s ! rc|j|=dSrrrs rrOzUserList.__delitem__s IaLLLrcBt|tr"||j|jzSt|t |jr||j|zS||jt |zSrrrr|r|rr}rs rr3zUserList.__add__s eX & & 5>>$)ej"899 9 tDI / / 5>>$)e"344 4~~di$u++5666rcBt|tr"||j|jzSt|t |jr|||jzS|t ||jzSrrrs r__radd__zUserList.__radd__s eX & & 5>>%*ty"899 9 tDI / / 5>>%$)"344 4~~d5kkDI5666rct|tr|xj|jz c_nPt|t|jr|xj|z c_n|xjt |z c_|Sr)rrr|rr}rs rrIzUserList.__iadd__so eX & & % II #III tDI / / % II III IIe $II rc<||j|zSrr|r|rrgs r__mul__zUserList.__mul__~~di!m,,,rc&|xj|zc_|Srrrs r__imul__zUserList.__imul__s Q  rc|j|j}|j|j|jddd|jd<|Sr)r|r6rerrs rryzUserList.__copy__sR~%%dn55 T]+++ $ f 5aaa 8 f rc:|j|dSr)r|appendrs rrzUserList.append  rc<|j||dSr)r|insertrs rrzUserList.insert s  D!!!!!rc6|j|Sr)r|rKrs rrKz UserList.popsy}}Qrc:|j|dSr)r|removers rrzUserList.removerrc8|jdSr)r|rWrs rrWzUserList.clears rc,||Srrrs rrz UserList.copys~~d###rc6|j|Sr)r|rrs rrzUserList.countsyt$$$rc(|jj|g|RSrr|r)rrr<s rrzUserList.indexstyt+d++++rc8|jdSr)r|rrs rrzUserList.reverse"s rc*|jj|i|dSr)r|sortrr<r=s rrz UserList.sort%s! %%%%%%rct|tr!|j|jdS|j|dSr)rrr|extendrs rrzUserList.extend(sN eX & & $ I  UZ ( ( ( ( ( I  U # # # # #rrr)#r!r"r#rrBr~r(r&rr.r,rrarZrVrIrOr3rrIr__rmul__rryrrrKrrWrrrrrrr$rrrrsKK + + + +...//////...///DDD!!!   777777---H"""    $$$%%%,,,&&&$$$$$rrc4eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZeZdZdZdZdZdZdejfdZdZdZ dKdZ!dejfd Z"dLd"Z#dejfd#Z$d$Z%d%Z&dejfd&Z'd'Z(d(Z)d)Z*d*Z+d+Z,d,Z-d-Z.d.Z/d/Z0d0Z1d1Z2d2Z3d3Z4d4Z5d5Z6dMd7Z7e8j9Z9d8Z:dNd:Z;dejfd;Zd>Z?dMd?Z@dOd@ZAdOdAZBdPdCZCdejfdDZDdMdEZEdFZFdGZGdHZHdIZIdJZJd6S)Qrct|tr ||_dSt|tr|jdd|_dSt||_dSr)rrr|rrseqs rrBzUserString.__init__5sW c3   !DIII Z ( ( ! DIIICDIIIrc*t|jSr)rr|rs r__str__zUserString.__str__=rdrc*t|jSrrrs rr~zUserString.__repr__@rrc*t|jSr)intr|rs r__int__zUserString.__int__Crdrc*t|jSr)floatr|rs r __float__zUserString.__float__FsTYrc*t|jSr)complexr|rs r __complex__zUserString.__complex__Isty!!!rc*t|jSr)hashr|rs r__hash__zUserString.__hash__Lrrc"|jddfSrrrs rrzUserString.__getnewargs__Os !!! rcbt|tr|j|jkS|j|kSrrrr|rstrings rrzUserString.__eq__R0 fj ) ) ,9 + +yF""rcbt|tr|j|jkS|j|kSrrrs rr(zUserString.__lt__W0 fj ) ) +9v{* *y6!!rcbt|tr|j|jkS|j|kSrrrs rr&zUserString.__le__\rrcbt|tr|j|jkS|j|kSrrrs rr.zUserString.__gt__arrcbt|tr|j|jkS|j|kSrrrs rr,zUserString.__ge__frrcLt|tr|j}||jvSrr)rchars rrazUserString.__contains__ks( dJ ' ' 9Dty  rc*t|jSrr~rs rrZzUserString.__len__prdrcB||j|Srr)rrs rrVzUserString.__getitem__ss~~di.///rc(t|tr"||j|jzSt|tr||j|zS||jt |zSr)rrr|r|rrs rr3zUserString.__add__vsy eZ ( ( 5>>$)ej"899 9 s # # 5>>$)e"344 4~~di#e**4555rct|tr|||jzS|t||jzSr)rrr|r|rs rrzUserString.__radd__}sL eS ! ! 5>>%$)"344 4~~c%jj494555rc<||j|zSrrrs rrzUserString.__mul__rrc<||j|zSrrrr<s r__mod__zUserString.__mod__s~~di$.///rcL|t||zSr)r|r)rtemplates r__rmod__zUserString.__rmod__s~~c(mmd2333rcZ||jSr)r|r| capitalizers rrzUserString.capitalizes"~~di2244555rcZ||jSr)r|r|casefoldrs rrzUserString.casefold"~~di0022333rcN||jj|g|RSr)r|r|centerrwidthr<s rrzUserString.centers,~~.di.u>> !dl0000 >>> >>> 2222 &'DL6666==== T\//// ///--- !dl0000#########%%%###(((###%%%'''############===1117777 I(((EEEE !dl0000 !"t|1111===)))7777....////....()dl88886666444111:::11166666rr)4r__all__rsysrb itertoolsr rr r rr keywordrroperatorrrrrreprlibrr_weakrefrr8 _collectionsr MutableSequenceregister ImportErrorrKeysViewr ItemsViewr& ValuesViewr+rr.r5rrr rrrrrrSequencerr$rrrsK   %%%%%%''''''))))))++++++......555555$$$$$$5""""""$--e4444   D  (((((((   D ++++++4+++ ,,,,,,6,,, %%%%%-8%%% 55555F555}}}}}$}}}@ (((((((   D L)))))))LLLKKLLLL16Thhhhh^111  ,,,,,,,   D q%q%q%q%q%dq%q%q%p }!}!}!}!}!.}!}!}!HSSSSS.SSSt~$~$~$~$~$/~$~$~$Ju6u6u6u6u6!*u6u6u6u6u6sZA!!A)(A)-A44A<;A<CC$#C$(C//C:9C: DDDPK ge[5€$11*__pycache__/__init__.cpython-311.opt-1.pycnu[ !A?h2dZgdZddlZddlZddlmZddlmZ ddlm Z ddl m ZddlmZdd lmZdd lmZdd lmZ dd lmZejen #e$rYnwxYw dd lmZn #e$rYnwxYwGddej Z!Gddej"Z#Gddej$Z%Gdde&Z'Gdde(Z) ddlm)Z)n #e$rYnwxYw ddlm*Z*n#e$rdZ*YnwxYwdddddZ+dZ, ddlm,Z,n #e$rYnwxYwGd d!e(Z-Gd"d#ej.Z/Gd$d%ej.Z0Gd&d'ejZ1Gd(d)ej2Z3dS)*a?This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, dict, list, set, and tuple. * namedtuple factory function for creating tuple subclasses with named fields * deque list-like container with fast appends and pops on either end * ChainMap dict-like class for creating a single view of multiple mappings * Counter dict subclass for counting hashable objects * OrderedDict dict subclass that remembers the order entries were added * defaultdict dict subclass that calls a factory function to supply missing values * UserDict wrapper around dictionary objects for easier dict subclassing * UserList wrapper around list objects for easier list subclassing * UserString wrapper around string objects for easier string subclassing ) ChainMapCounter OrderedDictUserDictUserList UserString defaultdictdeque namedtupleN)chain)repeat)starmap) iskeyword)eq) itemgetter)recursive_repr)proxy)r )rceZdZdZdS)_OrderedDictKeysViewc#>Kt|jEd{VdSNreversed_mappingselfs -/usr/lib64/python3.11/collections/__init__.py __reversed__z!_OrderedDictKeysView.__reversed__<s.DM***********N__name__ __module__ __qualname__rrrrr:s#+++++rrceZdZdZdS)_OrderedDictItemsViewc#ZKt|jD]}||j|fVdSrrrkeys rrz"_OrderedDictItemsView.__reversed__AsDDM** , ,C c*+ + + + + , ,rNr r$rrr&r&?s#,,,,,rr&ceZdZdZdS)_OrderedDictValuesViewc#VKt|jD]}|j|VdSrrr(s rrz#_OrderedDictValuesView.__reversed__Gs?DM** % %C-$ $ $ $ $ % %rNr r$rrr+r+Es#%%%%%rr+ceZdZdZdS)_Link)prevnextr) __weakref__N)r!r"r# __slots__r$rrr.r.Ks4IIIrr.cBeZdZdZdZddZejee fdZej fdZ dZ dZ d Z dd Zdd Zd ZejjxZZdZdZdZejjZeZefdZddZedZdZdZ e!ddZ"dZ#dZ$dZ%dZ&dS)rz)Dictionary that remembers insertion orderct|}t|_t |jx|_}|x|_|_i|_|S)zDCreate the ordered dict object and set up the underlying structures.) dict__new__r._OrderedDict__hardroot_proxy_OrderedDict__rootr/r0_OrderedDict__map)clsargskwdsrroots rr6zOrderedDict.__new__]sN||C  ''#DO444 d $$ DI  rr$c "|j|fi|dS)zInitialize an ordered dictionary. The signature is the same as regular dictionaries. Keyword argument order is preserved. N)_OrderedDict__update)rotherr=s r__init__zOrderedDict.__init__fs$  e$$t$$$$$rc||vrO|x|j|<}|j}|j}|||c|_|_|_||_|||_||||dS)z!od.__setitem__(i, y) <==> od[i]=yN)r:r9r/r0r)) rr)value dict_setitemrLinklinkr>lasts r __setitem__zOrderedDict.__setitem__lsw d??%)TVV +DJsOd;D9D-14 *DIty$(DId DI T3&&&&&rc||||j|}|j}|j}||_||_d|_d|_dS)z od.__delitem__(y) <==> del od[y]N)r:popr/r0)rr) dict_delitemrG link_prev link_nexts r __delitem__zOrderedDict.__delitem__zsW  T3z~~c""I I " "   rc#ZK|j}|j}||ur|jV|j}||udSdS)zod.__iter__() <==> iter(od)N)r9r0r)rr>currs r__iter__zOrderedDict.__iter__L{y$(NNN9D$rc#ZK|j}|j}||ur|jV|j}||udSdS)z#od.__reversed__() <==> reversed(od)N)r9r/r)rQs rrzOrderedDict.__reversed__rTrc|j}|x|_|_|jt |dS)z.od.clear() -> None. Remove all items from od.N)r9r/r0r:clearr5)rr>s rrWzOrderedDict.clearsC{ $$ DI  4rTc|std|j}|r|j}|j}||_||_n|j}|j}||_||_|j}|j|=t ||}||fS)zRemove and return a (key, value) pair from the dictionary. Pairs are returned in LIFO order if last is true or FIFO order if false. zdictionary is empty)KeyErrorr9r/r0r)r:r5rK)rrHr>rGrMrNr)rDs rpopitemzOrderedDict.popitems  2011 1{  "9D I!IN!DII9D I!DI!INh JsOs##Ezrc|j|}|j}|j}|j}||_||_|j}|r%|j}||_||_||_||_dS|j}||_||_||_||_dS)zMove an existing element to the end (or beginning if last is false). Raise KeyError if the element does not exist. N)r:r/r0r9) rr)rHrGrMrN soft_linkr>firsts r move_to_endzOrderedDict.move_to_ends z#I I N " " {  9DDIDI!DIDIIIIEDIDI"EJDIIIrctj}t|dz}||j}|||jdzz }|||j|zz }|||j|zz }|S)N)_sys getsizeoflen__dict__r:r7r9)rsizeofnsizes r __sizeof__zOrderedDict.__sizeof__s IIMvdm$$ tz""Q&& t''!++ t{##a'' rc t|S)z:D.keys() -> a set-like object providing a view on D's keys)rrs rkeyszOrderedDict.keyss#D)))rc t|S)z a set-like object providing a view on D's items)r&rs ritemszOrderedDict.itemss$T***rc t|S)z6D.values() -> an object providing a view on D's values)r+rs rvalueszOrderedDict.valuess%d+++rc|j}t|||}||urF|j|}|j}|j}||_||_d|_d|_|S||urt ||S)zod.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. N)_OrderedDict__markerr5rKr:r/r0rY)rr)defaultmarkerresultrGrMrNs rrKzOrderedDict.pops $V,,   :>>#&&D I I&IN&INDIDIM f  3-- rNc(||vr||S|||<|S)zInsert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default. r$rr)rrs r setdefaultzOrderedDict.setdefaults% $;;9 S rc|s|jjdS|jjdt|dS)zod.__repr__() <==> repr(od)()()) __class__r!listrmrs r__repr__zOrderedDict.__repr__ sL 7!^4446 6>222D4F4F4F4FGGrc|}|rt|tr|\}}ni}|}|}t t D].}||d||d/|r||f}n|pd}|jd|dt| fS)z%Return state information for picklingNr$) __getstate__ isinstancetuplecopyvarsrrKr|iterrm)rstateslotsks r __reduce__zOrderedDict.__reduce__s!!##  &%'' $ uuJJLLEJJLLE+--(( # # !T""" !T"""" &u  ~r5$TZZ\\0B0BBBrc,||S)z!od.copy() -> a shallow copy of odr|rs rrzOrderedDict.copy%~~d###rc.|}|D]}|||<|S)zYCreate a new ordered dictionary with keys from iterable and values set to value. r$)r;iterablerDrr)s rfromkeyszOrderedDict.fromkeys)s.suu  CDII rct|tr>t||o"t t t ||St||S)zod.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. )rrr5__eq__allmap_eqrrAs rrzOrderedDict.__eq__2sX e[ ) ) K;;tU++JCT54I4I0J0J J{{4'''rc0|||Sr)updaters r__ior__zOrderedDict.__ior__;s E rct|tstS||}|||Srrr5NotImplementedr|rrrAnews r__or__zOrderedDict.__or__?sB%&& "! !nnT"" 5 rct|tstS||}|||Srrrs r__ror__zOrderedDict.__ror__FsB%&& "! !nnU## 4 r)r$)Tr)'r!r"r#__doc__r6rBr5rIr8r.rOrSrrWrZr^ri_collections_abcMutableMappingrr@rkrmro__ne__objectrqrKrw_recursive_reprr~rr classmethodrrrrrr$rrrrNs//%%%%"&!1e ' ' ' '-1,<    .2)7>>FX***+++,,, , 3FvxxH',_HHH CCC&$$$[(((rr)r) _tuplegetterc>tt||S)N)doc)property _itemgetter)indexrs rr\sh{5/A/As&K&K&KrF)renamedefaultsmodulec  ttr(ddt t tt jt|}|r|t}tD]^\}}| r(t|s| ds||vrd||<| |_|gzD]n}t|turtd| st!d|t|rt!d|ot}D]V}| dr|st!d|||vrt!d|| |Wi}|t#|}t%|t%krtd t't)t t+t)t)|}t#t t jt%d } d kr| dz } d d dDzdzt"jt&t"t$t t*f\id|d} d| d| d} t1| | } d| _d|d | d| _||| _t8fd} d|d| j_fd}d|d|_fd}fd}fd}| | j||||fD]}|d |j|_|d | dd!|| | ||||d" }tD]/\}}t jd#|}t?||||<0t|t"f|}|F t j d j!"d$d%}n#tFt f$rYnwxYw|||_$|S)&aCReturns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22) , _z*Type names and field names must be stringsz6Type names and field names must be valid identifiers: z0Type names and field names cannot be a keyword: z-Field names cannot start with an underscore: z"Encountered duplicate field name: Nz(Got more default values than field names, r`rzc3 K|] }|dV dS)z=%rNr$).0names r znamedtuple..s(DD$|||DDDDDDrr{ namedtuple_) _tuple_new __builtins__r!z lambda _cls, z: _tuple_new(_cls, (z))r6zCreate new instance of c||}|kr"tddt||S)Nz Expected z arguments, got ) TypeErrorrd)r;rrt_len num_fields tuple_news r_makeznamedtuple.._makesQ3)) 4<<: % %Q QQCKKQQRR R rz Make a new z# object from a sequence or iterablec||j|}|rtdt||S)NzGot unexpected field names: )rrK ValueErrorr})rr=rt_map field_namess r_replaceznamedtuple.._replacesODD;==>>  LJDJJJJKK K rz Return a new z2 object replacing specified fields with new valuesc(|jj|zzS)z/Return a nicely formatted representation string)r|r!)rrepr_fmts rr~znamedtuple..__repr__s~&D88rc8|j|S)z9Return a new dict which maps field names to their values.)_fields)r_dict_zips r_asdictznamedtuple.._asdicts!uTT$,--...rc|S)z7Return self as a plain tuple. Used by copy and pickle.r$)r_tuples r__getnewargs__z"namedtuple..__getnewargs__svd||r.r$) rr2r_field_defaultsr6rrr~rr__match_args__zAlias for field number r!__main__)%rstrreplacesplitr}rrbinternset enumerate isidentifier _iskeyword startswithaddtyperrrrdr5rzipjoinr6evalr!r __defaults__r__func__r#r _getframe f_globalsgetAttributeErrorr")typenamerrrrseenrrfield_defaultsarg_list namespacecoder6rrr~rrmethodclass_namespacerrtrrrrrrrrs ` @@@@@@@@rr r ^s4+s##<!))#s3399;; s3 ,,--K{3x==))H uu$[11  KE4%%'' 1d## 1??3'' 14<<%0[[ E" HHTNNNN [(33 ::S HII I  "" 76-16677 7 d   32)-2233 3 3 55D ??3   * *) $))** * 4<<J$JJKK K N?? x==3{++ + +FGG GhtC0E0E080B0B-D-D(E(EFFGGDK5566K[!!Jyy%%HQCTYYDD DDDDDDsJH I&*E3S&@#E64t  ,(,,I F8 E E E E ED4##G GFFF8FFFGO'[ ,H,,,EN 1111H99999//////   >>"*==FO== ,,,,,)(%  O!--99 tk;E;;<< ,UC 8 8 (UHo 6 6F~ ^A&&044ZLLFF +    D  " Ms7-Q%%Q98Q9cB|j}|D]}||ddz||<dS)z!Tally elements from the iterable.r r`N)r)mappingr mapping_getelems r_count_elementsr s>+K11# D!,,q0 11r)rceZdZdZd fd ZdZdZd dZdZe d dZ d fd Z d d Z d Z d Zfd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!xZ"S)!raDict subclass for counting hashable items. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values. >>> c = Counter('abcdeabcdabcaba') # count elements from a string >>> c.most_common(3) # three most common elements [('a', 5), ('b', 4), ('c', 3)] >>> sorted(c) # list all unique elements ['a', 'b', 'c', 'd', 'e'] >>> ''.join(sorted(c.elements())) # list elements with repetitions 'aaaaabbbbcccdde' >>> sum(c.values()) # total of all counts 15 >>> c['a'] # count of letter 'a' 5 >>> for elem in 'shazam': # update counts from an iterable ... c[elem] += 1 # by adding 1 to each element's count >>> c['a'] # now there are seven 'a' 7 >>> del c['b'] # remove all 'b' >>> c['b'] # now there are zero 'b' 0 >>> d = Counter('simsalabim') # make another counter >>> c.update(d) # add in the second counter >>> c['a'] # now there are nine 'a' 9 >>> c.clear() # empty the counter >>> c Counter() Note: If a count is set to zero or reduced to zero, it will remain in the counter until the entry is deleted or the counter is cleared: >>> c = Counter('aaabbc') >>> c['b'] -= 2 # reduce the count of 'b' by two >>> c.most_common() # 'b' is still in, but its count is zero [('a', 3), ('c', 1), ('b', 0)] Nc dt|j|fi|dS)a Create a new, empty Counter object. And if given, count elements from an input iterable. Or, initialize the count from another mapping of elements to their counts. >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping >>> c = Counter(a=4, b=2) # a new counter from keyword args N)superrBr)rrr=r|s rrBzCounter.__init__Ks;  H%%%%%%%rcdS)z1The count of elements not in the Counter is zero.r r$r(s r __missing__zCounter.__missing__Ys qrcDt|S)zSum of the counts)sumrors rtotalz Counter.total^s4;;==!!!rc|1t|tddSddl}|||tdS)zList the n most common elements and their counts from the most common to the least. If n is None, then list all element counts. >>> Counter('abracadabra').most_common(3) [('a', 5), ('b', 2), ('r', 2)] Nr`T)r)reverser )r))sortedrmrheapqnlargest)rrgrs r most_commonzCounter.most_commonbs] 9$**,,KNNDIII I  ~~a;q>>~BBBrcttjtt|S)aIterator over elements repeating each as many times as its count. >>> c = Counter('ABCABC') >>> sorted(c.elements()) ['A', 'A', 'B', 'B', 'C', 'C'] # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1 >>> import math >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) >>> math.prod(prime_factors.elements()) 1836 Note, if an element's count has been set to zero or is a negative number, elements() will ignore it. )_chain from_iterable_starmap_repeatrmrs relementszCounter.elementsrs'$#HWdjjll$C$CDDDrc td)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)r;rvs rrzCounter.fromkeyss" NPP Prc B|t|tjrX|r4|j}|D]\}}|||dz||<n2t |nt|||r||dSdS)aLike dict.update() but add counts instead of replacing them. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.update('witch') # add elements from another iterable >>> d = Counter('watch') >>> c.update(d) # add elements from another counter >>> c['h'] # four 'h' in which, witch, and watch 4 Nr )rrMappingrrmrrr)rrr=self_getrcountr|s rrzCounter.updates(  ($4$<== 0-#xH'/~~'7'7?? e%*XXdA->->%>T ?GGNN8,,,,h///   KK       rc |e|j}t|tjr-|D]\}}||d|z ||<n|D]}||ddz ||<|r||dSdS)aLike dict.update() but subtracts counts instead of replacing them. Counts can be reduced below zero. Both the inputs and outputs are allowed to contain zero and negative counts. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.subtract('witch') # subtract elements from another iterable >>> c.subtract(Counter('watch')) # subtract elements from another counter >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch 0 >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch -1 Nr r`)rrrrrmsubtract)rrr=rrrs rrzCounter.subtracts  xH($4$<== 7#+>>#3#3;;KD%!)$!2!2U!:DJJ;%77D!)$!2!2Q!6DJJ  MM$       rc,||S)zReturn a shallow copy.rrs rrz Counter.copyrrc0|jt|ffSr)r|r5rs rrzCounter.__reduce__s~T },,rcV||vr#t|dSdS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rrO)rrr|s rrOzCounter.__delitem__s1 4<< GG   % % % % % .=II1qII!47eAh&IIIIIIIrrrrrrs``rrzCounter.__eq__ F%)) "! !IIIIIu IIIIIIrcHt|tstS||k S)z@True if any counts disagree. Missing counts are treated as zero.rrrrs rrzCounter.__ne__s'%)) "! !5=  rczttstStfdfDS)z:True if all counts in self are a subset of those in other.c3FK|]}|D]}||kVdSrr$rs rrz!Counter.__le__..rrr rs``r__le__zCounter.__le__r!rcRt|tstS||ko||kS)zATrue if all counts in self are a proper subset of those in other.r#rs r__lt__zCounter.__lt__-%)) "! !u}..rczttstStfdfDS)z.&rrr rs``r__ge__zCounter.__ge__"r!rcRt|tstS||ko||kS)zCTrue if all counts in self are a proper superset of those in other.r#rs r__gt__zCounter.__gt__(r)rc t|tstSt}|D]\}}|||z}|dkr|||<|D]\}}||vr |dkr|||<|S)zAdd counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) r rrrrmrrArtrrnewcounts r__add__zCounter.__add__.s%)) "! !::<< ( (KD%uT{*H!||'t  ;;== % %KD%4EAII$t  rct|tstSt}|D]\}}|||z }|dkr|||<|D]\}}||vr|dkrd|z ||<|S)z Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) r r0r1s r__sub__zCounter.__sub__As%)) "! !::<< ( (KD%uT{*H!||'t  ;;== ) )KD%4EAII 5yt  rct|tstSt}|D]"\}}||}||kr|n|}|dkr|||<#|D]\}}||vr |dkr|||<|S)zUnion is the maximum of value in either of the input counters. >>> Counter('abbb') | Counter('bcc') Counter({'b': 3, 'c': 2, 'a': 1}) r r0rrArtrr other_countr2s rrzCounter.__or__Ts%)) "! !::<< ( (KD%+K&+k&9&9{{uH!||'t  ;;== % %KD%4EAII$t  rct|tstSt}|D]"\}}||}||kr|n|}|dkr|||<#|S)z Intersection is the minimum of corresponding counts. >>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) r r0r7s r__and__zCounter.__and__hst%)) "! !::<< ( (KD%+K % 3 3uuH!||'t  rclt}|D]\}}|dkr|||<|S)zEAdds an empty counter, effectively stripping negative and zero countsr rrmrrtrrs r__pos__zCounter.__pos__ys>::<< % %KD%qyy$t  rcrt}|D]\}}|dkrd|z ||<|S)z{Subtracts from an empty counter. Strips positive and zero counts, and flips the sign on negative counts. r r<r=s r__neg__zCounter.__neg__sD ::<< ) )KD%qyy 5yt  rcRd|D}|D]}||=|S)z?Internal method to strip elements with a negative or zero countc$g|] \}}|dk |S)r r$)rrrs r z*Counter._keep_positive..s!MMM e5199t999r)rm)r nonpositivers r_keep_positivezCounter._keep_positives:MMtzz||MMM   DT  rc~|D]\}}||xx|z cc<|S)zInplace add from another counter, keeping only positive counts. >>> c = Counter('abbb') >>> c += Counter('bcc') >>> c Counter({'b': 4, 'c': 2, 'a': 1}) rmrErrArrs r__iadd__zCounter.__iadd__I!;;==  KD% JJJ% JJJJ""$$$rc~|D]\}}||xx|zcc<|S)zInplace subtract counter, but keep only results with positive counts. >>> c = Counter('abbbc') >>> c -= Counter('bccd') >>> c Counter({'b': 2, 'a': 1}) rGrHs r__isub__zCounter.__isub__rJrc|D]\}}||}||kr|||<|S)zInplace union is the maximum of value from either counter. >>> c = Counter('abbb') >>> c |= Counter('bcc') >>> c Counter({'b': 3, 'c': 2, 'a': 1}) rG)rrArr8rs rrzCounter.__ior__sP"' ) ) D+JEU""(T ""$$$rc|D]\}}||}||kr|||<|S)zInplace intersection is the minimum of corresponding counts. >>> c = Counter('abbb') >>> c &= Counter('bcc') >>> c Counter({'b': 1}) rG)rrArrr8s r__iand__zCounter.__iand__sO ::<< ) )KD%+KU""(T ""$$$rr)#r!r"r#rrBrrrr rrrrrrrOr~rrr&r(r,r.r3r5rr:r>r@rErIrLrrO __classcell__rs@rrrs6**d & & & & & & """CCCC EEE, P P P[ P      D    6$$$---&&&&& 3 3 3ZJJJ !!! JJJ /// JJJ /// &&("    % % % % % % % % % % % % % % % %rrceZdZdZdZdZdZddZdZdZ d Z d Z e d Z ed Zd ZeZddZedZdZdZdZdZdZdZdZdZdS)ra A ChainMap groups multiple dicts (or other mappings) together to create a single, updateable view. The underlying mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state. Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping. c4t|pig|_dS)zInitialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used. N)r}maps)rrSs rrBzChainMap.__init__s JJ&2$ rc t|r)rYr(s rrzChainMap.__missing__ssmmrct|jD]} ||cS#t$rYwxYw||Sr)rSrYr)rr)rs r __getitem__zChainMap.__getitem__s\y  G s|###    $$$s  ""Nc||vr||n|Srr$rvs rrz ChainMap.gets4KKtCyyW4rcRttj|jSr)rdrunionrSrs r__len__zChainMap.__len__s;355; *+++rci}t|jD]/}|t|0t |Sr)rrSrr5rr)rrrs rrSzChainMap.__iter__sL  ** - -G HHT]]7++ , , , ,AwwrcDtfd|jDS)Nc3 K|]}|vV dSrr$)rmr)s rrz(ChainMap.__contains__..s'//3!8//////ranyrSr(s `r __contains__zChainMap.__contains__s(////TY//////rc*t|jSrr_rs r__bool__zChainMap.__bool__49~~rc||jjddtt|jdS)Nrzrr{)r|r!rrreprrSrs rr~zChainMap.__repr__s6.)NNDIIc$ 6J6J,K,KNNNNrc8|tj|g|RS)z?Create a ChainMap with a single dict created from the iterable.)r5r)r;rr<s rrzChainMap.fromkeyss&s4=1D111222rcr|j|jdg|jddRS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r r`N)r|rSrrs rrz ChainMap.copy s8t~dil//11BDIabbMBBBBrc `||}n|r|||j|g|jRS)zNew ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. Keyword arguments update the map or new empty dict. )rr|rS)rr^kwargss r new_childzChainMap.new_childsF 9AA   HHV   t~a,$),,,,rc0|j|jddS)zNew ChainMap from maps[1:].r`N)r|rSrs rparentszChainMap.parentsst~ty}--rc&||jd|<dSNr )rS)rr)rDs rrIzChainMap.__setitem__!s! ! Srcd |jd|=dS#t$rtd|wxYw)Nr $Key not found in the first mapping: )rSrYr(s rrOzChainMap.__delitem__$sR K ! S!!! K K KI#IIJJ J Ks/c| |jdS#t$rtdwxYw)zPRemove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.r z#No keys found in the first mapping.)rSrZrYrs rrZzChainMap.popitem*sN B9Q<'')) ) B B B@AA A Bs!;cv |jdj|g|RS#t$rtd|wxYw)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r rq)rSrKrY)rr)r<s rrKz ChainMap.pop1s_ K#49Q<#C/$/// / K K KI#IIJJ J Ks8cD|jddS)z'Clear maps[0], leaving maps[1:] intact.r N)rSrWrs rrWzChainMap.clear8s  ! rcF|jd||Sro)rSrrs rrzChainMap.__ior__<s! ! E""" rct|tjstS|}|jd||Sro)rrrrrrSr)rrAr^s rrzChainMap.__or__@sJ%!1!9:: "! ! IIKK q rct|tjstSt |}t |jD]}||||Sr) rrrrr5rrSrr|)rrAr^childs rrzChainMap.__ror__Gse%!1!9:: "! ! KKdi((  E HHUOOOO~~a   rr)r!r"r#rrBrrVrrZrSrarcrr~rrr__copy__rkrrmrIrOrZrKrWrrrr$rrrrs  '''%%%5555,,, 000_OOO33[3CCCH - - - -..X."""KKK BBBKKK!!!!!rrcveZdZddZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZeddZdS)rNc ti|_||||r||dSdSr)datar)rr5rjs rrBzUserDict.__init__WsK   KK     KK       rc*t|jSrrdr|rs rrZzUserDict.__len__^rdrc||jvr |j|St|jdr|j||St |)Nr)r|hasattrr|rrYr(s rrVzUserDict.__getitem__asS $)  9S> ! 4>= 1 1 9>--dC88 8smmrc||j|<dSrr|)rr)items rrIzUserDict.__setitem__hs #rc|j|=dSrrr(s rrOzUserDict.__delitem__ks IcNNNrc*t|jSr)rr|rs rrSzUserDict.__iter__nDIrc||jvSrrr(s rrazUserDict.__contains__rsdirc*t|jSrrfr|rs rr~zUserDict.__repr__vrrct|tr"||j|jzSt|tr||j|zSt Srrrr|r|r5rrs rrzUserDict.__or__ys` eX & & :>>$)ej"899 9 eT " " 5>>$)e"344 4rct|tr"||j|jzSt|tr|||jzSt Srrrs rrzUserDict.__ror__s` eX & & :>>%*ty"899 9 eT " " 5>>%$)"344 4rc|t|tr|xj|jzc_n|xj|zc_|Sr)rrr|rs rrzUserDict.__ior__s= eX & &  II #III II II rc|j|j}|j|j|jd|jd<|SNr|)r|r6rerrrinsts rryzUserDict.__copy__sU~%%dn55 T]+++ $ f 5 : : < < f rc|jtur&t|jSddl}|j} i|_||}||_n #||_wxYw|||Sro)r|rr|rr)rrr|rs rrz UserDict.copys >X % %DINN,,-- - y DI $ADIIDI     s A%% A.c.|}|D]}|||<|Srr$)r;rrDrr)s rrzUserDict.fromkeyss, CEE  CAcFFrr)r!r"r#rBrZrVrIrOrSrar~rrrryrrrr$rrrrTs          [rrceZdZdZd"dZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZeZdZdZdZdZd#dZdZdZdZdZdZdZ d Z!d!Z"dS)$rzAA more or less complete user-defined wrapper around list objects.Nc g|_|yt|t|jkr||jdd<dSt|tr|jdd|jdd<dSt ||_dSdSr)r|rrrr})rinitlists rrBzUserList.__init__s  H~~di00' !!! Hh// +'}QQQ/ !!!  NN  rc*t|jSrrrs rr~zUserList.__repr__rrc>|j||kSrr|_UserList__castrs rr(zUserList.__lt__y4;;u----rc>|j||kSrrrs rr&zUserList.__le__yDKK....rc>|j||kSrrrs rrzUserList.__eq__rrc>|j||kSrrrs rr.zUserList.__gt__rrc>|j||kSrrrs rr,zUserList.__ge__rrc>t|tr|jn|Sr)rrr|rs r__castzUserList.__casts'x88CuzzeCrc||jvSrrrrs rrazUserList.__contains__sty  rc*t|jSrr~rs rrZzUserList.__len__rdrct|tr ||j|S|j|Sr)rslicer|r|ris rrVzUserList.__getitem__s8 a   >>$)A,// /9Q< rc||j|<dSrrrrrs rrIzUserList.__setitem__s ! rc|j|=dSrrrs rrOzUserList.__delitem__s IaLLLrcBt|tr"||j|jzSt|t |jr||j|zS||jt |zSrrrr|r|rr}rs rr3zUserList.__add__s eX & & 5>>$)ej"899 9 tDI / / 5>>$)e"344 4~~di$u++5666rcBt|tr"||j|jzSt|t |jr|||jzS|t ||jzSrrrs r__radd__zUserList.__radd__s eX & & 5>>%*ty"899 9 tDI / / 5>>%$)"344 4~~d5kkDI5666rct|tr|xj|jz c_nPt|t|jr|xj|z c_n|xjt |z c_|Sr)rrr|rr}rs rrIzUserList.__iadd__so eX & & % II #III tDI / / % II III IIe $II rc<||j|zSrr|r|rrgs r__mul__zUserList.__mul__~~di!m,,,rc&|xj|zc_|Srrrs r__imul__zUserList.__imul__s Q  rc|j|j}|j|j|jddd|jd<|Sr)r|r6rerrs rryzUserList.__copy__sR~%%dn55 T]+++ $ f 5aaa 8 f rc:|j|dSr)r|appendrs rrzUserList.append  rc<|j||dSr)r|insertrs rrzUserList.insert s  D!!!!!rc6|j|Sr)r|rKrs rrKz UserList.popsy}}Qrc:|j|dSr)r|removers rrzUserList.removerrc8|jdSr)r|rWrs rrWzUserList.clears rc,||Srrrs rrz UserList.copys~~d###rc6|j|Sr)r|rrs rrzUserList.countsyt$$$rc(|jj|g|RSrr|r)rrr<s rrzUserList.indexstyt+d++++rc8|jdSr)r|rrs rrzUserList.reverse"s rc*|jj|i|dSr)r|sortrr<r=s rrz UserList.sort%s! %%%%%%rct|tr!|j|jdS|j|dSr)rrr|extendrs rrzUserList.extend(sN eX & & $ I  UZ ( ( ( ( ( I  U # # # # #rrr)#r!r"r#rrBr~r(r&rr.r,rrarZrVrIrOr3rrIr__rmul__rryrrrKrrWrrrrrrr$rrrrsKK + + + +...//////...///DDD!!!   777777---H"""    $$$%%%,,,&&&$$$$$rrc4eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZeZdZdZdZdZdZdejfdZdZdZ dKdZ!dejfd Z"dLd"Z#dejfd#Z$d$Z%d%Z&dejfd&Z'd'Z(d(Z)d)Z*d*Z+d+Z,d,Z-d-Z.d.Z/d/Z0d0Z1d1Z2d2Z3d3Z4d4Z5d5Z6dMd7Z7e8j9Z9d8Z:dNd:Z;dejfd;Zd>Z?dMd?Z@dOd@ZAdOdAZBdPdCZCdejfdDZDdMdEZEdFZFdGZGdHZHdIZIdJZJd6S)Qrct|tr ||_dSt|tr|jdd|_dSt||_dSr)rrr|rrseqs rrBzUserString.__init__5sW c3   !DIII Z ( ( ! DIIICDIIIrc*t|jSr)rr|rs r__str__zUserString.__str__=rdrc*t|jSrrrs rr~zUserString.__repr__@rrc*t|jSr)intr|rs r__int__zUserString.__int__Crdrc*t|jSr)floatr|rs r __float__zUserString.__float__FsTYrc*t|jSr)complexr|rs r __complex__zUserString.__complex__Isty!!!rc*t|jSr)hashr|rs r__hash__zUserString.__hash__Lrrc"|jddfSrrrs rrzUserString.__getnewargs__Os !!! rcbt|tr|j|jkS|j|kSrrrr|rstrings rrzUserString.__eq__R0 fj ) ) ,9 + +yF""rcbt|tr|j|jkS|j|kSrrrs rr(zUserString.__lt__W0 fj ) ) +9v{* *y6!!rcbt|tr|j|jkS|j|kSrrrs rr&zUserString.__le__\rrcbt|tr|j|jkS|j|kSrrrs rr.zUserString.__gt__arrcbt|tr|j|jkS|j|kSrrrs rr,zUserString.__ge__frrcLt|tr|j}||jvSrr)rchars rrazUserString.__contains__ks( dJ ' ' 9Dty  rc*t|jSrr~rs rrZzUserString.__len__prdrcB||j|Srr)rrs rrVzUserString.__getitem__ss~~di.///rc(t|tr"||j|jzSt|tr||j|zS||jt |zSr)rrr|r|rrs rr3zUserString.__add__vsy eZ ( ( 5>>$)ej"899 9 s # # 5>>$)e"344 4~~di#e**4555rct|tr|||jzS|t||jzSr)rrr|r|rs rrzUserString.__radd__}sL eS ! ! 5>>%$)"344 4~~c%jj494555rc<||j|zSrrrs rrzUserString.__mul__rrc<||j|zSrrrr<s r__mod__zUserString.__mod__s~~di$.///rcL|t||zSr)r|r)rtemplates r__rmod__zUserString.__rmod__s~~c(mmd2333rcZ||jSr)r|r| capitalizers rrzUserString.capitalizes"~~di2244555rcZ||jSr)r|r|casefoldrs rrzUserString.casefold"~~di0022333rcN||jj|g|RSr)r|r|centerrwidthr<s rrzUserString.centers,~~.di.u>> !dl0000 >>> >>> 2222 &'DL6666==== T\//// ///--- !dl0000#########%%%###(((###%%%'''############===1117777 I(((EEEE !dl0000 !"t|1111===)))7777....////....()dl88886666444111:::11166666rr)4r__all__rsysrb itertoolsr rr r rr keywordrroperatorrrrrreprlibrr_weakrefrr8 _collectionsr MutableSequenceregister ImportErrorrKeysViewr ItemsViewr& ValuesViewr+rr.r5rrr rrrrrrSequencerr$rrrsK   %%%%%%''''''))))))++++++......555555$$$$$$5""""""$--e4444   D  (((((((   D ++++++4+++ ,,,,,,6,,, %%%%%-8%%% 55555F555}}}}}$}}}@ (((((((   D L)))))))LLLKKLLLL16Thhhhh^111  ,,,,,,,   D q%q%q%q%q%dq%q%q%p }!}!}!}!}!.}!}!}!HSSSSS.SSSt~$~$~$~$~$/~$~$~$Ju6u6u6u6u6!*u6u6u6u6u6sZA!!A)(A)-A44A<;A<CC$#C$(C//C:9C: DDDPK ge[X*__pycache__/__init__.cpython-311.opt-2.pycnu[ !A?h2 gdZddlZddlZddlmZddlmZddlm Z ddl m Z ddlmZddlmZdd lmZdd lmZ dd lmZejen #e$rYnwxYw dd lmZn #e$rYnwxYwGd dejZ Gddej!Z"Gddej#Z$Gdde%Z&Gdde'Z( ddlm(Z(n #e$rYnwxYw ddlm)Z)n#e$rdZ)YnwxYwdddddZ*dZ+ ddlm+Z+n #e$rYnwxYwGdd e'Z,Gd!d"ej-Z.Gd#d$ej-Z/Gd%d&ejZ0Gd'd(ej1Z2dS))) ChainMapCounter OrderedDictUserDictUserList UserString defaultdictdeque namedtupleN)chain)repeat)starmap) iskeyword)eq) itemgetter)recursive_repr)proxy)r )rceZdZdZdS)_OrderedDictKeysViewc#>Kt|jEd{VdSNreversed_mappingselfs -/usr/lib64/python3.11/collections/__init__.py __reversed__z!_OrderedDictKeysView.__reversed__<s.DM***********N__name__ __module__ __qualname__rrrrr:s#+++++rrceZdZdZdS)_OrderedDictItemsViewc#ZKt|jD]}||j|fVdSrrrkeys rrz"_OrderedDictItemsView.__reversed__AsDDM** , ,C c*+ + + + + , ,rNr r$rrr&r&?s#,,,,,rr&ceZdZdZdS)_OrderedDictValuesViewc#VKt|jD]}|j|VdSrrr(s rrz#_OrderedDictValuesView.__reversed__Gs?DM** % %C-$ $ $ $ $ % %rNr r$rrr+r+Es#%%%%%rr+ceZdZdZdS)_Link)prevnextr) __weakref__N)r!r"r# __slots__r$rrr.r.Ks4IIIrr.c@eZdZ dZddZejeefdZej fdZ dZ dZ dZ dd Z dd Zd ZejjxZZd ZdZdZejjZeZefdZddZedZdZdZe ddZ!dZ"dZ#dZ$dZ%dS)rc t|}t|_t |jx|_}|x|_|_i|_|Sr) dict__new__r._OrderedDict__hardroot_proxy_OrderedDict__rootr/r0_OrderedDict__map)clsargskwdsrroots rr6zOrderedDict.__new__]sQN||C  ''#DO444 d $$ DI  rr$c $ |j|fi|dSr)_OrderedDict__update)rotherr=s r__init__zOrderedDict.__init__fs)   e$$t$$$$$rc ||vrO|x|j|<}|j}|j}|||c|_|_|_||_|||_||||dSr)r:r9r/r0r)) rr)value dict_setitemrLinklinkr>lasts r __setitem__zOrderedDict.__setitem__lsz+ d??%)TVV +DJsOd;D9D-14 *DIty$(DId DI T3&&&&&rc ||||j|}|j}|j}||_||_d|_d|_dSr)r:popr/r0)rr) dict_delitemrG link_prev link_nexts r __delitem__zOrderedDict.__delitem__zsZ*  T3z~~c""I I " "   rc#\K |j}|j}||ur|jV|j}||udSdSr)r9r0r)rr>currs r__iter__zOrderedDict.__iter__sM%{y$(NNN9D$rc#\K |j}|j}||ur|jV|j}||udSdSr)r9r/r)rQs rrzOrderedDict.__reversed__sM-{y$(NNN9D$rc |j}|x|_|_|jt |dSr)r9r/r0r:clearr5)rr>s rrVzOrderedDict.clearsF8{ $$ DI  4rTc |std|j}|r|j}|j}||_||_n|j}|j}||_||_|j}|j|=t ||}||fS)Nzdictionary is empty)KeyErrorr9r/r0r)r:r5rK)rrHr>rGrMrNr)rDs rpopitemzOrderedDict.popitems  2011 1{  "9D I!IN!DII9D I!DI!INh JsOs##Ezrc  |j|}|j}|j}|j}||_||_|j}|r%|j}||_||_||_||_dS|j}||_||_||_||_dSr)r:r/r0r9) rr)rHrGrMrN soft_linkr>firsts r move_to_endzOrderedDict.move_to_ends z#I I N " " {  9DDIDI!DIDIIIIEDIDI"EJDIIIrctj}t|dz}||j}|||jdzz }|||j|zz }|||j|zz }|S)N)_sys getsizeoflen__dict__r:r7r9)rsizeofnsizes r __sizeof__zOrderedDict.__sizeof__s IIMvdm$$ tz""Q&& t''!++ t{##a'' rc" t|Sr)rrs rkeyszOrderedDict.keyssD#D)))rc" t|Sr)r&rs ritemszOrderedDict.itemssF$T***rc" t|Sr)r+rs rvalueszOrderedDict.valuess@%d+++rc |j}t|||}||urF|j|}|j}|j}||_||_d|_d|_|S||urt ||Sr)_OrderedDict__markerr5rKr:r/r0rX)rr)defaultmarkerresultrGrMrNs rrKzOrderedDict.pops $V,,   :>>#&&D I I&IN&INDIDIM f  3-- rNc* ||vr||S|||<|Srr$rr)rqs r setdefaultzOrderedDict.setdefaults*  $;;9 S rc |s|jjdS|jjdt|dSNz()()) __class__r!listrlrs r__repr__zOrderedDict.__repr__ sM% 7!^4446 6>222D4F4F4F4FGGrc |}|rt|tr|\}}ni}|}|}t t D].}||d||d/|r||f}n|pd}|jd|dt| fS)Nr$) __getstate__ isinstancetuplecopyvarsrrKr{iterrl)rstateslotsks r __reduce__zOrderedDict.__reduce__s/!!##  &%'' $ uuJJLLEJJLLE+--(( # # !T""" !T"""" &u  ~r5$TZZ\\0B0BBBrc. ||Srr{rs rrzOrderedDict.copy%s+~~d###rc0 |}|D]}|||<|Srr$)r;iterablerDrr)s rfromkeyszOrderedDict.fromkeys)s1 suu  CDII rc t|tr>t||o"t t t ||St||Sr)rrr5__eq__allmap_eqrrAs rrzOrderedDict.__eq__2s]  e[ ) ) K;;tU++JCT54I4I0J0J J{{4'''rc0|||Sr)updaters r__ior__zOrderedDict.__ior__;s E rct|tstS||}|||Srrr5NotImplementedr{rrrAnews r__or__zOrderedDict.__or__?sB%&& "! !nnT"" 5 rct|tstS||}|||Srrrs r__ror__zOrderedDict.__ror__FsB%&& "! !nnU## 4 r)r$)Tr)&r!r"r#r6rBr5rIr8r.rOrSrrVrYr]rh_collections_abcMutableMappingrr@rjrlrn__ne__objectrprKrv_recursive_reprr}rr classmethodrrrrrr$rrrrNs/%%%%"&!1e ' ' ' '-1,<    .2)7>>FX***+++,,, , 3FvxxH',_HHH CCC&$$$[(((rr)r) _tuplegetterc>tt||S)N)doc)property _itemgetter)indexrs rr\sh{5/A/As&K&K&KrF)renamedefaultsmodulec   ttr(ddt t tt jt|}|r|t}tD]^\}}| r(t|s| ds||vrd||<| |_|gzD]n}t|turtd| st!d|t|rt!d|ot}D]V}| dr|st!d|||vrt!d|| |Wi}|t#|}t%|t%krtd t't)t t+t)t)|}t#t t jt%d } d kr| dz } d d d Dzdzt"jt&t"t$t t*f\id|d} d| d| d} t1| | } d| _d|d | d| _||| _t8fd} d|d| j_fd}d|d|_fd}fd}fd}| | j||||fD]}|d|j|_|d | dd || | ||||d! }tD]/\}}t jd"|}t?||||<0t|t"f|}|F t j d j!"d#d$}n#tFt f$rYnwxYw|||_$|S)%N, _z*Type names and field names must be stringsz6Type names and field names must be valid identifiers: z0Type names and field names cannot be a keyword: z-Field names cannot start with an underscore: z"Encountered duplicate field name: z(Got more default values than field names, r_ryc3 K|] }|dV dS)z=%rNr$).0names r znamedtuple..s(DD$|||DDDDDDrrz namedtuple_) _tuple_new __builtins__r!z lambda _cls, z: _tuple_new(_cls, (z))r6zCreate new instance of c||}|kr"tddt||S)Nz Expected z arguments, got ) TypeErrorrc)r;rrs_len num_fields tuple_news r_makeznamedtuple.._makesQ3)) 4<<: % %Q QQCKKQQRR R rz Make a new z# object from a sequence or iterablec||j|}|rtdt||S)NzGot unexpected field names: )rrK ValueErrorr|)rr=rs_map field_namess r_replaceznamedtuple.._replacesODD;==>>  LJDJJJJKK K rz Return a new z2 object replacing specified fields with new valuesc* |jj|zzSr)r{r!)rrepr_fmts rr}znamedtuple..__repr__s9~&D88rc: |j|Sr)_fields)r_dict_zips r_asdictznamedtuple.._asdicts$CuTT$,--...rc |Srr$)r_tuples r__getnewargs__z"namedtuple..__getnewargs__sAvd||r.r$) __doc__r2r_field_defaultsr6rrr}rr__match_args__zAlias for field number r!__main__)%rstrreplacesplitr|rrainternset enumerate isidentifier _iskeyword startswithaddtyperrrrcr5rzipjoinr6evalr!r __defaults__r__func__r#r _getframe f_globalsgetAttributeErrorr")typenamerrrrseenrrfield_defaultsarg_list namespacecoder6rrr}rrmethodclass_namespacerrsrrrrrrrrs ` @@@@@@@@rr r ^s2+s##<!))#s3399;; s3 ,,--K{3x==))H uu$[11  KE4%%'' 1d## 1??3'' 14<<%0[[ E" HHTNNNN [(33 ::S HII I  "" 76-16677 7 d   32)-2233 3 3 55D ??3   * *) $))** * 4<<J$JJKK K N?? x==3{++ + +FGG GhtC0E0E080B0B-D-D(E(EFFGGDK5566K[!!Jyy%%HQCTYYDD DDDDDDsJH I&*E3S&@#E64t  ,(,,I F8 E E E E ED4##G GFFF8FFFGO'[ ,H,,,EN 1111H99999//////   >>"*==FO== ,,,,,)(%  O!--99 tk;E;;<< ,UC 8 8 (UHo 6 6F~ ^A&&044ZLLFF +    D  " Ms8-Q&&Q:9Q:cD |j}|D]}||ddz||<dSNr r_)r)mappingr mapping_getelems r_count_elementsr sA'+K11# D!,,q0 11r)rceZdZ dfd ZdZdZddZdZeddZ dfd Z dd Z d Z d Z fd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ xZ!S) rNc f t|j|fi|dSr)superrBr)rrr=r{s rrBzCounter.__init__Ks@   H%%%%%%%rc dSNr r$r(s r __missing__zCounter.__missing__Ys ;qrcF t|Sr)sumrnrs rtotalz Counter.total^s4;;==!!!rc |1t|tddSddl}|||tdS)Nr_T)r)reverser )r))sortedrlrheapqnlargest)rrfrs r most_commonzCounter.most_commonbsb  9$**,,KNNDIII I  ~~a;q>>~BBBrcv tjtt|Sr)_chain from_iterable_starmap_repeatrlrs relementszCounter.elementsrs, "#HWdjjll$C$CDDDrc td)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)r;rvs rrzCounter.fromkeyss" NPP Prc D |t|tjrX|r4|j}|D]\}}|||dz||<n2t |nt|||r||dSdSr)rrMappingrrlrrr)rrr=self_getrcountr{s rrzCounter.updates &  ($4$<== 0-#xH'/~~'7'7?? e%*XXdA->->%>T ?GGNN8,,,,h///   KK       rc  |e|j}t|tjr-|D]\}}||d|z ||<n|D]}||ddz ||<|r||dSdSr)rrrrrlsubtract)rrr=rrrs rrzCounter.subtracts   xH($4$<== 7#+>>#3#3;;KD%!)$!2!2U!:DJJ;%77D!)$!2!2Q!6DJJ  MM$       rc. ||Srrrs rrz Counter.copys ~~d###rc0|jt|ffSr)r{r5rs rrzCounter.__reduce__s~T },,rcX ||vr#t|dSdSr)rrO)rrr{s rrOzCounter.__delitem__s4Q 4<< GG   % % % % % .=II1qII!47eAh&IIIIIIIrrrrrrs``rrzCounter.__eq__ sIG%)) "! !IIIIIu IIIIIIrcJ t|tstS||k Srrrrrs rrzCounter.__ne__s*J%)) "! !5=  rc| ttstStfdfDS)Nc3FK|]}|D]}||kVdSrr$rs rrz!Counter.__le__..rrr rs``r__le__zCounter.__le__sID%)) "! !IIIIIu IIIIIIrcT t|tstS||ko||kSrr"rs r__lt__zCounter.__lt__s0K%)) "! !u}..rc| ttstStfdfDS)Nc3FK|]}|D]}||kVdSrr$rs rrz!Counter.__ge__..&rrr rs``r__ge__zCounter.__ge__"sIF%)) "! !IIIIIu IIIIIIrcT t|tstS||ko||kSrr"rs r__gt__zCounter.__gt__(s0M%)) "! !u}..rc t|tstSt}|D]\}}|||z}|dkr|||<|D]\}}||vr |dkr|||<|SrrrrrlrrArsrrnewcounts r__add__zCounter.__add__.s %)) "! !::<< ( (KD%uT{*H!||'t  ;;== % %KD%4EAII$t  rc t|tstSt}|D]\}}|||z }|dkr|||<|D]\}}||vr|dkrd|z ||<|Srr.r/s r__sub__zCounter.__sub__As %)) "! !::<< ( (KD%uT{*H!||'t  ;;== ) )KD%4EAII 5yt  rc t|tstSt}|D]"\}}||}||kr|n|}|dkr|||<#|D]\}}||vr |dkr|||<|Srr.rrArsrr other_countr0s rrzCounter.__or__Ts %)) "! !::<< ( (KD%+K&+k&9&9{{uH!||'t  ;;== % %KD%4EAII$t  rc t|tstSt}|D]"\}}||}||kr|n|}|dkr|||<#|Srr.r5s r__and__zCounter.__and__hsy %)) "! !::<< ( (KD%+K % 3 3uuH!||'t  rcn t}|D]\}}|dkr|||<|Srrrlrrsrrs r__pos__zCounter.__pos__ysAO::<< % %KD%qyy$t  rct t}|D]\}}|dkrd|z ||<|Srr:r;s r__neg__zCounter.__neg__sI ::<< ) )KD%qyy 5yt  rcT d|D}|D]}||=|S)Nc$g|] \}}|dk |S)r r$)rrrs r z*Counter._keep_positive..s!MMM e5199t999r)rl)r nonpositivers r_keep_positivezCounter._keep_positives=MMMtzz||MMM   DT  rc |D]\}}||xx|z cc<|SrrlrCrrArrs r__iadd__zCounter.__iadd__N !;;==  KD% JJJ% JJJJ""$$$rc |D]\}}||xx|zcc<|SrrErFs r__isub__zCounter.__isub__rHrc |D]\}}||}||kr|||<|SrrE)rrArr6rs rrzCounter.__ior__sU "' ) ) D+JEU""(T ""$$$rc |D]\}}||}||kr|||<|SrrE)rrArrr6s r__iand__zCounter.__iand__sT  ::<< ) )KD%+KU""(T ""$$$rr)"r!r"r#rBrrrr rrrrrrrOr}rrr%r'r*r,r1r3rr8r<r>rCrGrJrrM __classcell__rs@rrrs1*d & & & & & & """CCCC EEE, P P P[ P      D    6$$$---&&&&& 3 3 3ZJJJ !!! JJJ /// JJJ /// &&("    % % % % % % % % % % % % % % % %rrceZdZ dZdZdZddZdZdZdZ d Z e d Z e d Zd ZeZdd ZedZdZdZdZdZdZdZdZdZdS)rc6 t|pig|_dSr)r|maps)rrQs rrBzChainMap.__init__s! JJ&2$ rc t|r)rXr(s rrzChainMap.__missing__ssmmrct|jD]} ||cS#t$rYwxYw||Sr)rQrXr)rr)rs r __getitem__zChainMap.__getitem__s\y  G s|###    $$$s  ""Nc||vr||n|Srr$rus rrz ChainMap.gets4KKtCyyW4rcRttj|jSr)rcrunionrQrs r__len__zChainMap.__len__s;355; *+++rci}t|jD]/}|t|0t |Sr)rrQrr5rr)rrrs rrSzChainMap.__iter__sL  ** - -G HHT]]7++ , , , ,AwwrcDtfd|jDS)Nc3 K|]}|vV dSrr$)rmr)s rrz(ChainMap.__contains__..s'//3!8//////ranyrQr(s `r __contains__zChainMap.__contains__s(////TY//////rc*t|jSrr]rs r__bool__zChainMap.__bool__49~~rc||jjddtt|jdS)Nryrrz)r{r!rrreprrQrs rr}zChainMap.__repr__s6.)NNDIIc$ 6J6J,K,KNNNNrc: |tj|g|RSr)r5r)r;rr<s rrzChainMap.fromkeyss'Is4=1D111222rct |j|jdg|jddRSr)r{rQrrs rrz ChainMap.copy s;Rt~dil//11BDIabbMBBBBrc b ||}n|r|||j|g|jRSr)rr{rQ)rr\kwargss r new_childzChainMap.new_childsK  9AA   HHV   t~a,$),,,,rc2 |j|jddS)Nr_)r{rQrs rparentszChainMap.parentss%t~ty}--rc&||jd|<dSr)rQ)rr)rDs rrIzChainMap.__setitem__!s! ! Srcd |jd|=dS#t$rtd|wxYwNr z$Key not found in the first mapping: )rQrXr(s rrOzChainMap.__delitem__$sR K ! S!!! K K KI#IIJJ J Ks/c~ |jdS#t$rtdwxYw)Nr z#No keys found in the first mapping.)rQrYrXrs rrYzChainMap.popitem*sQZ B9Q<'')) ) B B B@AA A Bs"<cx |jdj|g|RS#t$rtd|wxYwrn)rQrKrX)rr)r<s rrKz ChainMap.pop1sba K#49Q<#C/$/// / K K KI#IIJJ J Ks9cF |jddSr)rQrVrs rrVzChainMap.clear8s#1 ! rcF|jd||Sr)rQrrs rrzChainMap.__ior__<s! ! E""" rct|tjstS|}|jd||Sr)rrrrrrQr)rrAr\s rrzChainMap.__or__@sJ%!1!9:: "! ! IIKK q rct|tjstSt |}t |jD]}||||Sr) rrrrr5rrQrr{)rrAr\childs rrzChainMap.__ror__Gse%!1!9:: "! ! KKdi((  E HHUOOOO~~a   rr)r!r"r#rBrrTrrXrSr_rarr}rrr__copy__rirrkrIrOrYrKrVrrrr$rrrrs '''%%%5555,,, 000_OOO33[3CCCH - - - -..X."""KKK BBBKKK!!!!!rrcveZdZddZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZeddZdS)rNc ti|_||||r||dSdSr)datar)rr5rhs rrBzUserDict.__init__WsK   KK     KK       rc*t|jSrrcryrs rrXzUserDict.__len__^rbrc||jvr |j|St|jdr|j||St |)Nr)ryhasattrr{rrXr(s rrTzUserDict.__getitem__asS $)  9S> ! 4>= 1 1 9>--dC88 8smmrc||j|<dSrry)rr)items rrIzUserDict.__setitem__hs #rc|j|=dSrrr(s rrOzUserDict.__delitem__ks IcNNNrc*t|jSr)rryrs rrSzUserDict.__iter__nDIrc||jvSrrr(s rr_zUserDict.__contains__rsdirc*t|jSrrdryrs rr}zUserDict.__repr__vrrct|tr"||j|jzSt|tr||j|zSt Srrrr{ryr5rrs rrzUserDict.__or__ys` eX & & :>>$)ej"899 9 eT " " 5>>$)e"344 4rct|tr"||j|jzSt|tr|||jzSt Srrrs rrzUserDict.__ror__s` eX & & :>>%*ty"899 9 eT " " 5>>%$)"344 4rc|t|tr|xj|jzc_n|xj|zc_|Sr)rrryrs rrzUserDict.__ior__s= eX & &  II #III II II rc|j|j}|j|j|jd|jd<|SNry)r{r6rdrrrinsts rrvzUserDict.__copy__sU~%%dn55 T]+++ $ f 5 : : < < f rc|jtur&t|jSddl}|j} i|_||}||_n #||_wxYw|||Sr)r{rryrr)rrryrs rrz UserDict.copys >X % %DINN,,-- - y DI $ADIIDI     s A%% A.c.|}|D]}|||<|Srr$)r;rrDrr)s rrzUserDict.fromkeyss, CEE  CAcFFrr)r!r"r#rBrXrTrIrOrSr_r}rrrrvrrrr$rrrrTs          [rrceZdZ d!dZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZeZdZdZdZdZd"dZdZdZdZdZdZdZdZ d Z!dS)#rNc g|_|yt|t|jkr||jdd<dSt|tr|jdd|jdd<dSt ||_dSdSr)ryrrrr|)rinitlists rrBzUserList.__init__s  H~~di00' !!! Hh// +'}QQQ/ !!!  NN  rc*t|jSrrrs rr}zUserList.__repr__rrc>|j||kSrry_UserList__castrs rr'zUserList.__lt__y4;;u----rc>|j||kSrrrs rr%zUserList.__le__yDKK....rc>|j||kSrrrs rrzUserList.__eq__rrc>|j||kSrrrs rr,zUserList.__gt__rrc>|j||kSrrrs rr*zUserList.__ge__rrc>t|tr|jn|Sr)rrryrs r__castzUserList.__casts'x88CuzzeCrc||jvSrrrrs rr_zUserList.__contains__sty  rc*t|jSrr{rs rrXzUserList.__len__rbrct|tr ||j|S|j|Sr)rslicer{ryris rrTzUserList.__getitem__s8 a   >>$)A,// /9Q< rc||j|<dSrrrrrs rrIzUserList.__setitem__s ! rc|j|=dSrrrs rrOzUserList.__delitem__s IaLLLrcBt|tr"||j|jzSt|t |jr||j|zS||jt |zSrrrr{ryrr|rs rr1zUserList.__add__s eX & & 5>>$)ej"899 9 tDI / / 5>>$)e"344 4~~di$u++5666rcBt|tr"||j|jzSt|t |jr|||jzS|t ||jzSrrrs r__radd__zUserList.__radd__s eX & & 5>>%*ty"899 9 tDI / / 5>>%$)"344 4~~d5kkDI5666rct|tr|xj|jz c_nPt|t|jr|xj|z c_n|xjt |z c_|Sr)rrryrr|rs rrGzUserList.__iadd__so eX & & % II #III tDI / / % II III IIe $II rc<||j|zSrr{ryrrfs r__mul__zUserList.__mul__~~di!m,,,rc&|xj|zc_|Srrrs r__imul__zUserList.__imul__s Q  rc|j|j}|j|j|jddd|jd<|Sr)r{r6rdrrs rrvzUserList.__copy__sR~%%dn55 T]+++ $ f 5aaa 8 f rc:|j|dSr)ryappendrs rrzUserList.append  rc<|j||dSr)ryinsertrs rrzUserList.insert s  D!!!!!rc6|j|Sr)ryrKrs rrKz UserList.popsy}}Qrc:|j|dSr)ryremovers rrzUserList.removerrc8|jdSr)ryrVrs rrVzUserList.clears rc,||Srrrs rrz UserList.copys~~d###rc6|j|Sr)ryrrs rrzUserList.countsyt$$$rc(|jj|g|RSrryr)rrr<s rrzUserList.indexstyt+d++++rc8|jdSr)ryrrs rrzUserList.reverse"s rc*|jj|i|dSr)rysortrr<r=s rrz UserList.sort%s! %%%%%%rct|tr!|j|jdS|j|dSr)rrryextendrs rrzUserList.extend(sN eX & & $ I  UZ ( ( ( ( ( I  U # # # # #rrr)"r!r"r#rBr}r'r%rr,r*rr_rXrTrIrOr1rrGr__rmul__rrvrrrKrrVrrrrrrr$rrrrsK + + + +...//////...///DDD!!!   777777---H"""    $$$%%%,,,&&&$$$$$rrc4eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZeZdZdZdZdZdZdejfdZdZdZ dKdZ!dejfd Z"dLd"Z#dejfd#Z$d$Z%d%Z&dejfd&Z'd'Z(d(Z)d)Z*d*Z+d+Z,d,Z-d-Z.d.Z/d/Z0d0Z1d1Z2d2Z3d3Z4d4Z5d5Z6dMd7Z7e8j9Z9d8Z:dNd:Z;dejfd;Zd>Z?dMd?Z@dOd@ZAdOdAZBdPdCZCdejfdDZDdMdEZEdFZFdGZGdHZHdIZIdJZJd6S)Qrct|tr ||_dSt|tr|jdd|_dSt||_dSr)rrryrrseqs rrBzUserString.__init__5sW c3   !DIII Z ( ( ! DIIICDIIIrc*t|jSr)rryrs r__str__zUserString.__str__=rbrc*t|jSrrrs rr}zUserString.__repr__@rrc*t|jSr)intryrs r__int__zUserString.__int__Crbrc*t|jSr)floatryrs r __float__zUserString.__float__FsTYrc*t|jSr)complexryrs r __complex__zUserString.__complex__Isty!!!rc*t|jSr)hashryrs r__hash__zUserString.__hash__Lrrc"|jddfSrrrs rrzUserString.__getnewargs__Os !!! rcbt|tr|j|jkS|j|kSrrrryrstrings rrzUserString.__eq__R0 fj ) ) ,9 + +yF""rcbt|tr|j|jkS|j|kSrrrs rr'zUserString.__lt__W0 fj ) ) +9v{* *y6!!rcbt|tr|j|jkS|j|kSrrrs rr%zUserString.__le__\rrcbt|tr|j|jkS|j|kSrrrs rr,zUserString.__gt__arrcbt|tr|j|jkS|j|kSrrrs rr*zUserString.__ge__frrcLt|tr|j}||jvSrr)rchars rr_zUserString.__contains__ks( dJ ' ' 9Dty  rc*t|jSrr{rs rrXzUserString.__len__prbrcB||j|Srr)rrs rrTzUserString.__getitem__ss~~di.///rc(t|tr"||j|jzSt|tr||j|zS||jt |zSr)rrr{ryrrs rr1zUserString.__add__vsy eZ ( ( 5>>$)ej"899 9 s # # 5>>$)e"344 4~~di#e**4555rct|tr|||jzS|t||jzSr)rrr{ryrs rrzUserString.__radd__}sL eS ! ! 5>>%$)"344 4~~c%jj494555rc<||j|zSrrrs rrzUserString.__mul__rrc<||j|zSrrrr<s r__mod__zUserString.__mod__s~~di$.///rcL|t||zSr)r{r)rtemplates r__rmod__zUserString.__rmod__s~~c(mmd2333rcZ||jSr)r{ry capitalizers rrzUserString.capitalizes"~~di2244555rcZ||jSr)r{rycasefoldrs rrzUserString.casefold"~~di0022333rcN||jj|g|RSr)r{rycenterrwidthr<s rrzUserString.centers,~~.di.u>> !dl0000 >>> >>> 2222 &'DL6666==== T\//// ///--- !dl0000#########%%%###(((###%%%'''############===1117777 I(((EEEE !dl0000 !"t|1111===)))7777....////....()dl88886666444111:::11166666rr)3__all__rsysra itertoolsr rr r rr keywordrroperatorrrrrreprlibrr_weakrefrr8 _collectionsr MutableSequenceregister ImportErrorrKeysViewr ItemsViewr& ValuesViewr+rr.r5rrr rrrrrrSequencerr$rrr}sF   %%%%%%''''''))))))++++++......555555$$$$$$5""""""$--e4444   D  (((((((   D ++++++4+++ ,,,,,,6,,, %%%%%-8%%% 55555F555}}}}}$}}}@ (((((((   D L)))))))LLLKKLLLL16Thhhhh^111  ,,,,,,,   D q%q%q%q%q%dq%q%q%p }!}!}!}!}!.}!}!}!HSSSSS.SSSt~$~$~$~$~$/~$~$~$Ju6u6u6u6u6!*u6u6u6u6u6sYA A('A(,A33A;:A;CC#"C#'C..C98C9DDDPKfe[wwabc.pynu[PKfe[PF#__pycache__/__init__.cpython-36.pycnu[PKfe[\Q3$__pycache__/abc.cpython-36.opt-1.pycnu[PKfe[PF)__pycache__/__init__.cpython-36.opt-1.pycnu[PKfe[\Q3Zh__pycache__/abc.cpython-36.pycnu[PKfe[\Q3$ai__pycache__/abc.cpython-36.opt-2.pycnu[PKfe[$)nj__pycache__/__init__.cpython-36.opt-2.pycnu[PKfe["% ~22 __init__.pynu[PK ge[#((%F__pycache__/abc.cpython-311.opt-1.pycnu[PK ge[#((%__pycache__/abc.cpython-311.opt-2.pycnu[PK ge[#((@__pycache__/abc.cpython-311.pycnu[PK ge[5€$11$__pycache__/__init__.cpython-311.pycnu[PK ge[5€$11*__pycache__/__init__.cpython-311.opt-1.pycnu[PK ge[X*w(__pycache__/__init__.cpython-311.opt-2.pycnu[PKM1