+
    }ij                       ^ RI t ^ RIt^ RIHtHtHtHt ^ RIHt ^ RI	H
t
 ^ RIHtHtHtHt ^ RIHtHt ^ RIHtHtHtHtHtHtHtHtHtHtHtHtH t H!t!H"t" ^ RI H#t#H$t$H%t%H&t&H't'H(t(H)t)H*t*H+t+H,t, ^ R	I H-t- ^ R
I.H/t/H0t0 ^ RI1H1t1H2t2H3t3H4t4 ^ RI5H6t6H7t7H8t8H9t9H:t:H;t;H<t<H=t= ^ RI>H?t?H@t@ ^ RIAHBtB ^RICHDtDHEtEHFtFHGtGHHtHHItIHJtJHKtKHLtLHMtMHNtNHOtOHPtPHQtQ . RNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNR NR!NR"NR#NR$NR%NR&NR'NR(NR)NR*NR+NR,NR-NR.NR/NR0NR1NR2NR3NR4NR5NR6NR7NR8NR9NR:NR;NR<NR=NR>NR?NR@NRANRBNRCNRDNRENRFNRGNRHNRINRJNRKNRLNRMNRNNRONRPNRQNRRNRSNRTNRUNRVNRWNRXNRYNRZNR[NR\NR]NR^NR_NR`NRaNRbNRcNRdNReNRfNRgNRhNRiNRjNRkNRlNRmNRnNRoNRpNRqNRrNRsNRtNRuNRvNRwNRxNRyNRzNR{NR|NR}NR~NRNRNRNRNRNtR ^ RI HStT ERR ltX]D3R ltY]D3R ltZ]D3R lt[ ! R R\4      t\R t]R t^R t_R t`ERR ltaR tbERR ltcERR ltdERR lteERR ltfR tgERR lthR tiERR ltj ! R R4      tkERR ltlR tmR tnERR ltoR tpERR ltqERR ltrERR ltsERR lttERR ltuERR ltvERR ltwR txERR ltyERR ltzERR lt{R t|ERR lt}R t~RRRR/R ltERR ltR tR t]]33R ltERR ltERR lt ! R RU]P                  ]EP                  4      tERR ltR t]R3R ltR tR tR tR t ! R RB4      tR tR tERR lt]<3RR/R llt ! R R]4      t ! R Rh4      t ! R Rf4      t]3R ltERR ltERR ltERR lt]R3R ltERR ltR tERR lt ! R Ry4      tERR ltR tR tR tR tR tR tERR ltR tR tR tERRRRR/R lltERR lt ! R R]4      t ! R R4      tR tERR ltR tR tR tR tR tR tR tR t ! R R%4      tR tR]]3RR/R ltERR ltERR ltERR ltERR ltRRR]D/R ltR]R3R ltR tR tR tR tER  tER tER tER tER tER tER tER tER tER	R/ER
 ltRR/ER ltRR/ER ltER tR#   ]U d    R R ltVR tWR tT ELi ; i(      N)Counterdefaultdictdequeabc)Sequence)suppress)cached_propertypartialreducewraps)heapifyheapreplace)chaincombinationscompresscountcycle	dropwhilegroupbyislicepermutationsrepeatstarmap	takewhileteezip_longestproduct)
combeexp	factorialfloorfsumloglog1ppermtau)ceil)EmptyQueue)random	randrangeshuffleuniform)
attrgetteris_not
itemgetterltmulnegsubgt)
hexversionmaxsize)	monotonic)_marker
_zip_equalUnequalIterablesErrorconsume
first_trueflattenis_primenthpowersetsievetakeunique_everseen	all_equalbatchedAbortThreadSequenceViewr<   adjacent
all_uniquealways_iterablealways_reversibleargmaxargminbucketcallback_iterchunkedchunked_evencircular_shiftscollapsecombination_index"combination_with_replacement_indexconsecutive_groupsconstrained_batchesconsumercount_cycle	countablederangementsdft
differencedistinct_combinationsdistinct_permutations
distributedividedoublestarmapduplicates_everseenduplicates_justseenclassify_unique	exactly_nextractfilter_except
filter_mapfirstgray_productgroupby_transformichunkediequalsidftilen
interleaveinterleave_evenlyinterleave_longestinterleave_randomlyintersperse	is_sortedislice_extendediterateiter_suppressjoin_mappingslastlocatelongest_common_prefixlstripmake_decorator
map_exceptmap_if
map_reduce	mark_endsminmaxnth_or_lastnth_permutation	nth_primenth_product nth_combination_with_replacementnumeric_rangeoneonlyouter_productpaddedpartial_product
partitionspeekablepermutation_indexpowerset_of_setsproduct_indexraise_repeat_eachrepeat_lastreplacerlocaterstrip
run_lengthsampleseekableset_partitionsside_effectslicedsort_togethersplit_aftersplit_atsplit_before
split_into
split_whenspystaggerstrip
strictly_n
substringssubstrings_indexestakewhile_inclusivetime_limitedunique_in_windowunique_to_eachunzipvalue_chainwindowedwindowed_complete	with_iterzip_broadcast	zip_equal
zip_offset)sumprodc                $    V ^8  d   QhR\         /# )   x)float)formats   "e/Users/ahmad/.openclaw/workspace/my-crawler/.venv/lib/python3.14/site-packages/more_itertools/more.py__annotate__r      s      E     c                H    V R,          pWV ,
          ,
          pW,
          pW#3# )z1Split a float into two half-precision components.g     A )r   thilos   &   r   dl_splitr      s$    Oa%[Vvr   c                    \        V 4      w  r#\        V4      w  rEW$,          pW%,          W4,          ,           pWg,           pWh,
          V,           W5,          ,           p	W3# )zLossless multiplication.)r   )
r   yxx_hixx_loyy_hiyy_lopqzzzs
   &&        r   dl_mulr      sM    {{MMEM)EUQY&ur   c           	      \    \        \        P                  ! \        \        W4      4      4      # N)r#   r   from_iterablemapr   )r   r   s   &&r   	_fsumprodr      s    E''FA(9:;;r   Fc           	        aa \        \        \        S\        V 4      4      . 4      oV'       d   Sf   \        R4      hVV3R lpV! 4       # S# )a  Break *iterable* into lists of length *n*:

    >>> list(chunked([1, 2, 3, 4, 5, 6], 3))
    [[1, 2, 3], [4, 5, 6]]

By the default, the last yielded list will have fewer than *n* elements
if the length of *iterable* is not divisible by *n*:

    >>> list(chunked([1, 2, 3, 4, 5, 6, 7, 8], 3))
    [[1, 2, 3], [4, 5, 6], [7, 8]]

To use a fill-in value instead, see the :func:`grouper` recipe.

If the length of *iterable* is not divisible by *n* and *strict* is
``True``, then ``ValueError`` will be raised before the last
list is yielded.

z*n must not be None when using strict mode.c               3   `   <"   S F"  p \        V 4      S8w  d   \        R 4      hV x  K$  	  R# 5i)ziterable is not divisible by n.Nlen
ValueError)chunkiteratorns    r   retchunked.<locals>.ret   s,     !u:?$%FGG "   +.)iterr
   rD   r   )iterabler   strictr   r   s   &f& @r   rR   rR      sE    & GD!T(^4b9H9IJJ	 ur   c                F    V  F  pVu # 	  V\         J d   \        R4      hV# )a  Return the first item of *iterable*, or *default* if *iterable* is
empty.

    >>> first([0, 1, 2, 3])
    0
    >>> first([], 'some default')
    'some default'

If *default* is not provided and there are no items in the iterable,
raise ``ValueError``.

:func:`first` is useful when you have a generator of expensive-to-retrieve
values and want any arbitrary one. It is marginally shorter than
``next(iter(iterable), default)``.

zKfirst() was called on an empty iterable, and no default value was provided.)r:   r   )r   defaultitems   && r   rl   rl      s4    "  '1
 	
 Nr   c                    \        V \        4      '       d
   V R,          # \        V RR4      '       d   \        \	        V 4      4      # \        V ^R7      R,          #   \        \        \        3 d    T\        J d   \        R4      hTu # i ; i)zReturn the last item of *iterable*, or *default* if *iterable* is
empty.

    >>> last([0, 1, 2, 3])
    3
    >>> last([], 'some default')
    'some default'

If *default* is not provided and there are no items in the iterable,
raise ``ValueError``.
__reversed__NmaxlenzJlast() was called on an empty iterable, and no default value was provided.)
isinstancer   getattrnextreversedr   
IndexError	TypeErrorStopIterationr:   r   )r   r   s   &&r   r}   r}     s    h))B<8^T22*++Xa(,,	=1 g5  s   A &A A -BBc                <    \        \        W^,           4      VR7      # )a?  Return the nth or the last item of *iterable*,
or *default* if *iterable* is empty.

    >>> nth_or_last([0, 1, 2, 3], 2)
    2
    >>> nth_or_last([0, 1], 2)
    1
    >>> nth_or_last([], 0, 'some default')
    'some default'

If *default* is not provided and there are no items in the iterable,
raise ``ValueError``.
r   )r}   r   )r   r   r   s   &&&r   r   r   ,  s     xQ'99r   c                   Z   a  ] tR tRt o RtR tR tR t]3R lt	R t
R tR	 tR
 tRtV tR# )r   i=  aX  Wrap an iterator to allow lookahead and prepending elements.

Call :meth:`peek` on the result to get the value that will be returned
by :func:`next`. This won't advance the iterator:

    >>> p = peekable(['a', 'b'])
    >>> p.peek()
    'a'
    >>> next(p)
    'a'

Pass :meth:`peek` a default value to return that instead of raising
``StopIteration`` when the iterator is exhausted.

    >>> p = peekable([])
    >>> p.peek('hi')
    'hi'

peekables also offer a :meth:`prepend` method, which "inserts" items
at the head of the iterable:

    >>> p = peekable([1, 2, 3])
    >>> p.prepend(10, 11, 12)
    >>> next(p)
    10
    >>> p.peek()
    11
    >>> list(p)
    [11, 12, 1, 2, 3]

peekables can be indexed. Index 0 is the item that will be returned by
:func:`next`, index 1 is the item after that, and so on:
The values up to the given index will be cached.

    >>> p = peekable(['a', 'b', 'c', 'd'])
    >>> p[0]
    'a'
    >>> p[1]
    'b'
    >>> next(p)
    'a'

Negative indexes are supported, but be aware that they will cache the
remaining items in the source iterator, which may require significant
storage.

To check whether a peekable is exhausted, check its truth value:

    >>> p = peekable(['a', 'b'])
    >>> if p:  # peekable has items
    ...     list(p)
    ['a', 'b']
    >>> if not p:  # peekable is exhausted
    ...     list(p)
    []

c                D    \        V4      V n        \        4       V n        R # r   )r   _itr   _cacheselfr   s   &&r   __init__peekable.__init__x  s    >gr   c                    V # r   r   r   s   &r   __iter__peekable.__iter__|      r   c                L     V P                  4        R#   \         d     R # i ; iFTpeekr   r  s   &r   __bool__peekable.__bool__  )    	IIK   		    ##c                    V P                   '       g0    V P                   P                  \        V P                  4      4       V P                   ^ ,          #   \         d    T\
        J d   h Tu # i ; i)zReturn the item that will be next returned from ``next()``.

Return ``default`` if there are no items left. If ``default`` is not
provided, raise ``StopIteration``.

)r   appendr   r   r   r:   )r   r   s   &&r   r	  peekable.peek  s]     {{{""4>2
 {{1~	 ! g%s   .A A0/A0c                N    V P                   P                  \        V4      4       R# )a\  Stack up items to be the next ones returned from ``next()`` or
``self.peek()``. The items will be returned in
first in, first out order::

    >>> p = peekable([1, 2, 3])
    >>> p.prepend(10, 11, 12)
    >>> next(p)
    10
    >>> list(p)
    [11, 12, 1, 2, 3]

It is possible, by prepending items, to "resurrect" a peekable that
previously raised ``StopIteration``.

    >>> p = peekable([])
    >>> next(p)
    Traceback (most recent call last):
      ...
    StopIteration
    >>> p.prepend(1)
    >>> next(p)
    1
    >>> next(p)
    Traceback (most recent call last):
      ...
    StopIteration

N)r   
extendleftr   )r   itemss   &*r   prependpeekable.prepend  s    : 	x/r   c                    V P                   '       d   V P                   P                  4       # \        V P                  4      # r   )r   popleftr   r   r  s   &r   __next__peekable.__next__  s,    ;;;;;&&((DHH~r   c                   VP                   f   ^MVP                   pV^ 8  d>   VP                  f   ^ MVP                  pVP                  f   \        MVP                  pMWV^ 8  dF   VP                  f   RMVP                  pVP                  f   \        ) ^,
          MVP                  pM\	        R4      hV^ 8  g   V^ 8  d'   V P
                  P                  V P                  4       Mp\        \        W44      ^,           \        4      p\        V P
                  4      pWV8  d6   V P
                  P                  \        V P                  WV,
          4      4       \        V P
                  4      V,          # )Nzslice step cannot be zeror   )stepstartstopr8   r   r   extendr   minmaxr   r   list)r   indexr  r  r  r   	cache_lens   &&     r   
_get_slicepeekable._get_slice  s	   ZZ'qejj!8++-AEKKE$zz17

DAX ;;.BU[[E&+jj&8WHqLuzzD899 AI4!8KKtxx( C$q('2ADKK(I~""6$((AM#BCDKK ''r   c                   \        V\        4      '       d   V P                  V4      # \        V P                  4      pV^ 8  d'   V P                  P                  V P                  4       MCW8  d>   V P                  P                  \        V P                  V^,           V,
          4      4       V P                  V,          # r   )r   slicer$  r   r   r  r   r   )r   r"  r#  s   && r   __getitem__peekable.__getitem__  s    eU##??5))$	19KKtxx(KKvdhh	I0EFG{{5!!r   )r   r   N)__name__
__module____qualname____firstlineno____doc__r   r  r
  r:   r	  r  r  r$  r)  __static_attributes____classdictcell____classdict__s   @r   r   r   =  s=     8t #  0>(4
" 
"r   c                0   a  \        S 4      V 3R l4       pV# )a  Decorator that automatically advances a PEP-342-style "reverse iterator"
to its first yield point so you don't have to call ``next()`` on it
manually.

    >>> @consumer
    ... def tally():
    ...     i = 0
    ...     while True:
    ...         print('Thing number %s is %s.' % (i, (yield)))
    ...         i += 1
    ...
    >>> t = tally()
    >>> t.send('red')
    Thing number 0 is red.
    >>> t.send('fish')
    Thing number 1 is fish.

Without the decorator, you would have to call ``next(t)`` before
``t.send()`` could be used.

c                  .   < S! V / VB p\        V4       V# r   r   )argskwargsgenfuncs   *, r   wrapperconsumer.<locals>.wrapper  s    D#F#S	
r   )r   )r:  r;  s   f r   rZ   rZ     s"    . 4[ 
 Nr   c                P    \        \        \        ^4      \        V 4      4      4      # )aQ  Return the number of items in *iterable*.

For example, there are 168 prime numbers below 1,000:

    >>> ilen(sieve(1000))
    168

Equivalent to, but faster than::

    def ilen(iterable):
        count = 0
        for _ in iterable:
            count += 1
        return count

This fully consumes the iterable, so handle with care.

)sumr   r   zipr   s   &r   rr   rr     s    , xq	3x=122r   c              #     "   \        \        4      ;_uu_ 4         Vx  V ! V4      pK    + '       g   i     R# ; i5i)a  Return ``start``, ``func(start)``, ``func(func(start))``, ...

Produces an infinite iterator. To add a stopping condition,
use :func:`take`, ``takewhile``, or :func:`takewhile_inclusive`:.

>>> take(10, iterate(lambda x: 2*x, 1))
[1, 2, 4, 8, 16, 32, 64, 128, 256, 512]

>>> collatz = lambda x: 3*x + 1 if x%2==1 else x // 2
>>> list(takewhile_inclusive(lambda x: x!=1, iterate(collatz, 10)))
[10, 5, 16, 8, 4, 2, 1]

N)r   r   )r:  r  s   &&r   rz   rz     s.      
-	 	 KKE 
!	 	 s   >*;		>c              #  t   "   T ;_uu_ 4       pT Rj  xL
  RRR4       R#  L  + '       g   i     R# ; i5i)a&  Wrap an iterable in a ``with`` statement, so it closes once exhausted.

For example, this will close the file when the iterator is exhausted::

    upper_lines = (line.upper() for line in with_iter(open('foo')))

Any context manager which returns an iterable is a candidate for
``with_iter``.

Nr   )context_managerr   s   & r   r   r   /  s*      
H 
 
s    8$"$
8$5		8c                    \        V 4      pV F,  pV F!  pRV: RV: R2pT;'       g    \        V4      h	  Vu # 	  T;'       g    \        R4      h)a  Return the first item from *iterable*, which is expected to contain only
that item. Raise an exception if *iterable* is empty or has more than one
item.

:func:`one` is useful for ensuring that an iterable contains only one item.
For example, it can be used to retrieve the result of a database query
that is expected to return a single row.

If *iterable* is empty, ``ValueError`` will be raised. You may specify a
different exception with the *too_short* keyword:

    >>> it = []
    >>> one(it)  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    ValueError: too few items in iterable (expected 1)'
    >>> too_short = IndexError('too few items')
    >>> one(it, too_short=too_short)  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    IndexError: too few items

Similarly, if *iterable* contains more than one item, ``ValueError`` will
be raised. You may specify a different exception with the *too_long*
keyword:

    >>> it = ['too', 'many']
    >>> one(it)  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    ValueError: Expected exactly one item in iterable, but got 'too',
    'many', and perhaps more.
    >>> too_long = RuntimeError
    >>> one(it, too_long=too_long)  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    RuntimeError

Note that :func:`one` attempts to advance *iterable* twice to ensure there
is only one item. See :func:`spy` or :func:`peekable` to check iterable
contents less destructively.

/Expected exactly one item in iterable, but got , , and perhaps more.z&too few items in iterable (expected 1)r   r   )r   	too_shorttoo_longr   rl   secondmsgs   &&&    r   r   r   >  sn    X H~HFA%"*/1  --jo-    
K
Kz"JKKr   c                     V ! V!  hr   r   )	exceptionr7  s   &*r   r   r   v  s    
T
r   c              #     "   Vf   R pVf   R p\        V 4      p^ p\        WA4       F  pVx  V^,          pK  	  WQ8  d   V! V4       R# V F  pV! V^,           4        R# 	  R# 5i)a  Validate that *iterable* has exactly *n* items and return them if
it does. If it has fewer than *n* items, call function *too_short*
with the actual number of items. If it has more than *n* items, call function
*too_long* with the number ``n + 1``.

    >>> iterable = ['a', 'b', 'c', 'd']
    >>> n = 4
    >>> list(strictly_n(iterable, n))
    ['a', 'b', 'c', 'd']

Note that the returned iterable must be consumed in order for the check to
be made.

By default, *too_short* and *too_long* are functions that raise
``ValueError``.

    >>> list(strictly_n('ab', 3))  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    ValueError: too few items in iterable (got 2)

    >>> list(strictly_n('abc', 2))  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    ValueError: too many items in iterable (got at least 3)

You can instead supply functions that do something else.
*too_short* will be called with the number of items in *iterable*.
*too_long* will be called with `n + 1`.

    >>> def too_short(item_count):
    ...     raise RuntimeError
    >>> it = strictly_n('abcd', 6, too_short=too_short)
    >>> list(it)  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    RuntimeError

    >>> def too_long(item_count):
    ...     print('The boss is going to hear about this')
    >>> it = strictly_n('abcdef', 4, too_long=too_long)
    >>> list(it)
    The boss is going to hear about this
    ['a', 'b', 'c', 'd']

Nc                 *    \        \        R V  R24      # )zToo few items in iterable (got )r   r   
item_counts   &r   <lambda>strictly_n.<locals>.<lambda>  s    v-j\;(
r   c                 *    \        \        R V  R24      # )z)Too many items in iterable (got at least rQ  rR  rS  s   &r   rU  rV    s    f7
|1E'
r   )r   r   )r   r   rI  rJ  itsentr   s   &&&&   r   r   r   z  sy     ^ 
	
 

 
hBDr
	  x$Q s   A&A(c           	       aaa V3R lpR p\        V 4      p VP                  4        Rp\        V4      oVf   SpVS8X  d   TM\        W1R7      p^ Tu;8  d   S8:  d&   M M"V'       d	   V! V4      # V3R lV! X4       4       # \        V'       d   R4      # R	4      #   \         d    Rp\        \         4      pT F)  pYdP	                  T4      ,          P                  T4       K+  	  T Uu. uF  qtP	                  T4      NK  	  Mu upi ppTP                  4        TP                  4        U	U
u/ uF  w  rT	\        T
4      bK  	  Mu up
p	i up
p	oT3R lo EL1i ; i)
a  Yield successive distinct permutations of the elements in *iterable*.

    >>> sorted(distinct_permutations([1, 0, 1]))
    [(0, 1, 1), (1, 0, 1), (1, 1, 0)]

Equivalent to yielding from ``set(permutations(iterable))``, except
duplicates are not generated and thrown away. For larger input sequences
this is much more efficient.

Duplicate permutations arise when there are duplicated elements in the
input iterable. The number of items returned is
`n! / (x_1! * x_2! * ... * x_n!)`, where `n` is the total number of
items input, and each `x_i` is the count of a distinct item in the input
sequence. The function :func:`multinomial` computes this directly.

If *r* is given, only the *r*-length permutations are yielded.

    >>> sorted(distinct_permutations([1, 0, 1], r=2))
    [(0, 1), (1, 0), (1, 1)]
    >>> sorted(distinct_permutations(range(3), r=2))
    [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]

*iterable* need not be sortable, but note that using equal (``x == y``)
but non-identical (``id(x) != id(y)``) elements may produce surprising
behavior. For example, ``1`` and ``True`` are equal but non-identical:

    >>> list(distinct_permutations([1, True, '3']))  # doctest: +SKIP
    [
        (1, True, '3'),
        (1, '3', True),
        ('3', 1, True)
    ]
    >>> list(distinct_permutations([1, 2, '3']))  # doctest: +SKIP
    [
        (1, 2, '3'),
        (1, '3', 2),
        (2, 1, '3'),
        (2, '3', 1),
        ('3', 1, 2),
        ('3', 2, 1)
    ]
c              3   b  <"    \        V 4      x  \        S^,
          RR4       F  pW,          W^,           ,          8  g   K   M	  R# \        S^,
          VR4       F  pW,          W,          8  g   K   M	  V X,          W,          uW&   W&   V RVS,
          R1,          W^,           R% K  5i)TNr   )tuplerange)Aijsizes   &  r   _full$distinct_permutations.<locals>._full  s     (N 4!8R,4!E(? -
  4!8Q+4!$; , 1qtJAD!$?QX?+A!egJs   =B/-B/78B/c              3   &  "   V R V WR  r2\        V^,
          RR4      p\        \        V4      4      p \        V4      x  VR,          pV F  pW',          V8  d    MW',          pK  	  R # V F-  pW8,          W',          8  g   K  W8,          W',          uW'&   W8&    M5	  V F-  pW(,          W',          8  g   K  W(,          W',          uW'&   W(&    M	  W2R Wq,
          R1,          ,          pV^,          pVR W,
           W1V,
          R  uW'R % VR&   K  5i)N:NNNr   )r]  r   r\  )	r^  rheadtailright_head_indexesleft_tail_indexespivotr_  r`  s	   &&       r   _partial'distinct_permutations.<locals>._partial
  s    rUAbEd"1q5"b1!#d),+ HE'7U? (
  '7TW$'+w$DGTW ' ,Aw(+/7DG( , 152&&DFA $WqutEG}DHd1gs   A?D.D9ADTFc                 h   < \         ;QJ d    . V3R  lV  4       F  NK  	  5# ! V3R  lV  4       4      # )c              3   H   <"   T F  p\        SV,          4      x  K  	  R # 5ir   r6  ).0r"  equivalent_itemss   & r   	<genexpr>@distinct_permutations.<locals>.permuted_items.<locals>.<genexpr>D  s#      ;K%%e,--;Ks   "r\  )permuted_indicesrp  s   &r   permuted_items-distinct_permutations.<locals>.permuted_itemsC  s5    5 ;K5 5 ;K  r   re  c              3   4   <"   T F  pS! V4      x  K  	  R # 5ir   r   )ro  rt  ru  s   & r   rq  (distinct_permutations.<locals>.<genexpr>S  s"      (:$ /00(:s   r   )r   )r!  sortr   r   r"  r  r  r   r   r
   r   )r   re  rb  rk  r  sortableindices_dictr   indiceskv	algorithmrp  ru  ra  s   &&          @@@r   ra   ra     s?   Z,0%=N NE

& u:Dy t)'(*@I1}}U##(1'(: 
 a##U##E  "4(DT*+2248  277;;t$774@4F4F4HI4HDAAuQxK4HI	 	s*   B AE-D+E1E	EEc                    \        V 4      p\        \        \        V4      4      4      p\        \	        W!R7      \        \        \        \
        \        \        4      \        V4      \	        W1R7      4      4      4      # )ah  Yield successive derangements of the elements in *iterable*.

A derangement is a permutation in which no element appears at its original
index. In other words, a derangement is a permutation that has no fixed points.

Suppose Alice, Bob, Carol, and Dave are playing Secret Santa.
The code below outputs all of the different ways to assign gift recipients
such that nobody is assigned to himself or herself:

    >>> for d in derangements(['Alice', 'Bob', 'Carol', 'Dave']):
    ...    print(', '.join(d))
    Bob, Alice, Dave, Carol
    Bob, Carol, Dave, Alice
    Bob, Dave, Alice, Carol
    Carol, Alice, Dave, Bob
    Carol, Dave, Alice, Bob
    Carol, Dave, Bob, Alice
    Dave, Alice, Bob, Carol
    Dave, Carol, Alice, Bob
    Dave, Carol, Bob, Alice

If *r* is given, only the *r*-length derangements are yielded.

    >>> sorted(derangements(range(3), 2))
    [(1, 0), (1, 2), (2, 0)]
    >>> sorted(derangements([0, 2, 3], 2))
    [(2, 0), (2, 3), (3, 0)]

Elements are treated as unique based on their position, not on their value.

Consider the Secret Santa example with two *different* people who have
the *same* name. Then there are two valid gift assignments even though
it might appear that a person is assigned to themselves:

    >>> names = ['Alice', 'Bob', 'Bob']
    >>> list(derangements(names))
    [('Bob', 'Bob', 'Alice'), ('Bob', 'Alice', 'Bob')]

To avoid confusion, make the inputs distinct:

    >>> deduped = [f'{name}{index}' for index, name in enumerate(names)]
    >>> list(derangements(deduped))
    [('Bob1', 'Bob2', 'Alice0'), ('Bob2', 'Alice0', 'Bob1')]

The number of derangements of a set of size *n* is known as the
"subfactorial of n".  For n > 0, the subfactorial is:
``round(math.factorial(n) / math.e)``.

References:

* Article:  https://www.numberanalytics.com/blog/ultimate-guide-to-derangements-in-combinatorics
* Sizes:    https://oeis.org/A000166
rw  )	r\  r]  r   r   r   r   allr   r0   )r   re  xsyss   &&  r   r]   r]   [  sW    l 
xB	uSW~	BRCS&.&*l26KLM r   c                    V^ 8X  d   \        R4      hV^8X  d!   \        \        \        V 4      V4      ^R4      # \        V .4      p\	        W4      p\        \        \        W44      ^R4      4      # )a  Intersperse filler element *e* among the items in *iterable*, leaving
*n* items between each filler element.

    >>> list(intersperse('!', [1, 2, 3, 4, 5]))
    [1, '!', 2, '!', 3, '!', 4, '!', 5]

    >>> list(intersperse(None, [1, 2, 3, 4, 5], n=2))
    [1, 2, None, 3, 4, None, 5]

zn must be > 0N)r   r   rs   r   rR   r?   )r   r   r   fillerchunkss   &&&  r   rw   rw     si     	Av))	
a jH5q$??
 %vj8!TBCCr   c            	     L   V  Uu. uF  p\        V4      NK  	  pp\        \        P                  ! \	        \
        V4      4      4      pV Uu0 uF  qCV,          ^8X  g   K  VkK  	  ppV Uu. uF"  p\        \        VP                  V4      4      NK$  	  up# u upi u upi u upi )a{  Return the elements from each of the input iterables that aren't in the
other input iterables.

For example, suppose you have a set of packages, each with a set of
dependencies::

    {'pkg_1': {'A', 'B'}, 'pkg_2': {'B', 'C'}, 'pkg_3': {'B', 'D'}}

If you remove one package, which dependencies can also be removed?

If ``pkg_1`` is removed, then ``A`` is no longer necessary - it is not
associated with ``pkg_2`` or ``pkg_3``. Similarly, ``C`` is only needed for
``pkg_2``, and ``D`` is only needed for ``pkg_3``::

    >>> unique_to_each({'A', 'B'}, {'B', 'C'}, {'B', 'D'})
    [['A'], ['C'], ['D']]

If there are duplicates in one input iterable that aren't in the others
they will be duplicated in the output. Input order is preserved::

    >>> unique_to_each("mississippi", "missouri")
    [['p', 'p'], ['o', 'u', 'r']]

It is assumed that the elements of each iterable are hashable.

)r!  r   r   r   r   setfilter__contains__)	iterablesrX  poolcountselementuniquess   *     r   r   r     s    6  ))yDHyD)U((S$89F&,Ef7w10DwwfGE=ABTrD,,b12TBB *EBs   BB B,(B!c              #  *  "   V^ 8  d   \        R4      hV^ 8X  d   Rx  R# V^8  d   \        R4      h\        V 4      p\        \        WA4      VR7      pV'       g   R# \	        V4      V8  d/   \        V4      V3V\	        V4      ,
          ,          ,           x  R# \        V4      x  V3W18  d
   V^,
          MV^,
          ,          p\        VP                  \        WF4      4      p\        Ws^,
          RV4       F  p\        V4      x  K  	  R# 5i)a  Return a sliding window of width *n* over the given iterable.

    >>> all_windows = windowed([1, 2, 3, 4, 5], 3)
    >>> list(all_windows)
    [(1, 2, 3), (2, 3, 4), (3, 4, 5)]

When the window is larger than the iterable, *fillvalue* is used in place
of missing values:

    >>> list(windowed([1, 2, 3], 4))
    [(1, 2, 3, None)]

Each window will advance in increments of *step*:

    >>> list(windowed([1, 2, 3, 4, 5, 6], 3, fillvalue='!', step=2))
    [(1, 2, 3), (3, 4, 5), (5, 6, '!')]

To slide into the iterable's items, use :func:`chain` to add filler items
to the left:

    >>> iterable = [1, 2, 3, 4]
    >>> n = 3
    >>> padding = [None] * (n - 1)
    >>> list(windowed(chain(padding, iterable), 3))
    [(None, None, 1), (None, 1, 2), (1, 2, 3), (2, 3, 4)]
n must be >= 0Nzstep must be >= 1r   r   )	r   r   r   r   r   r\  r   r  r   )	seqr   	fillvaluer  r   windowpaddingr  _s	   &&&&     r   r   r     s     6 	1u)**Avax,--CyH 6(&q1F 
6{QFm	|q3v;?@@
- ltya!edQh?Gh 89F F1HdD1Fm 2s   DDc              #    "   . pV  F  pVP                  V4       V3x  K  	  \        V4      p\        V4      p\        ^V^,           4       F.  p\        W4,
          ^,           4       F  pWWT,            x  K  	  K0  	  R# 5i)a.  Yield all of the substrings of *iterable*.

    >>> [''.join(s) for s in substrings('more')]
    ['m', 'o', 'r', 'e', 'mo', 'or', 're', 'mor', 'ore', 'more']

Note that non-string iterables can also be subdivided.

    >>> list(substrings([0, 1, 2]))
    [(0,), (1,), (2,), (0, 1), (1, 2), (0, 1, 2)]

N)r  r\  r   r]  )r   r  r   rT  r   r_  s   &     r   r   r     sv      C

4g  *CSJ 1j1n%z~)*A!%.  + &s   A?Bc                z   a  \        ^\        S 4      ^,           4      pV'       d   \        V4      pV 3R lV 4       # )a  Yield all substrings and their positions in *seq*

The items yielded will be a tuple of the form ``(substr, i, j)``, where
``substr == seq[i:j]``.

This function only works for iterables that support slicing, such as
``str`` objects.

>>> for item in substrings_indexes('more'):
...    print(item)
('m', 0, 1)
('o', 1, 2)
('r', 2, 3)
('e', 3, 4)
('mo', 0, 2)
('or', 1, 3)
('re', 2, 4)
('mor', 0, 3)
('ore', 1, 4)
('more', 0, 4)

Set *reverse* to ``True`` to yield the same items in the opposite order.


c              3      <"   T FB  p\        \        S4      V,
          ^,           4       F  pSW"V,            W"V,           3x  K  	  KD  	  R# 5i   N)r]  r   )ro  Lr_  r  s   &  r   rq  %substrings_indexes.<locals>.<genexpr>E  sA      ,-quSX\A=M7N!QQE"7N"As   A
A)r]  r   r   )r  reversere  s   f& r   r   r   (  s7    4 	aSAAQK,- r   c                   F   a  ] tR tRt o RtR
R ltR tR tR tR t	R	t
V tR# )rP   iJ  ar  Wrap *iterable* and return an object that buckets the iterable into
child iterables based on a *key* function.

    >>> iterable = ['a1', 'b1', 'c1', 'a2', 'b2', 'c2', 'b3']
    >>> s = bucket(iterable, key=lambda x: x[0])  # Bucket by 1st character
    >>> sorted(list(s))  # Get the keys
    ['a', 'b', 'c']
    >>> a_iterable = s['a']
    >>> next(a_iterable)
    'a1'
    >>> next(a_iterable)
    'a2'
    >>> list(s['b'])
    ['b1', 'b2', 'b3']

The original iterable will be advanced and its items will be cached until
they are used by the child iterables. This may require significant storage.

By default, attempting to select a bucket to which no items belong  will
exhaust the iterable and cache all values.
If you specify a *validator* function, selected buckets will instead be
checked against it.

    >>> from itertools import count
    >>> it = count(1, 2)  # Infinite sequence of odd numbers
    >>> key = lambda x: x % 10  # Bucket by last digit
    >>> validator = lambda x: x in {1, 3, 5, 7, 9}  # Odd digits only
    >>> s = bucket(it, key=key, validator=validator)
    >>> 2 in s
    False
    >>> list(s[2])
    []

Nc                ~    \        V4      V n        W n        \        \        4      V n        T;'       g    R  V n        R# )c                     R # )Tr   r   s   &r   rU  !bucket.__init__.<locals>.<lambda>r  s    $r   N)r   r   _keyr   r   r   
_validator)r   r   key	validators   &&&&r   r   bucket.__init__n  s-    >	!%(#77r   c                    V P                  V4      '       g   R #  \        W,          4      pV P                  V,          P                  V4       R#   \         d     R # i ; ir  )r  r   r   
appendleftr   )r   valuer   s   && r   r  bucket.__contains__t  sU    u%%	0$D KK))$/  		s   A AAc              #    "    V P                   V,          '       d&   V P                   V,          P                  4       x  K?    \        V P                  4      pT P                  T4      pY18X  d   Tx  Ks  T P                  T4      '       g   KM  T P                   T,          P                  T4       Kq    \         d     R# i ; i5i)z
Helper to yield items from the parent iterator that match *value*.
Items that don't match are stored in the local cache as they
are encountered.
N)r   r  r   r   r   r  r  r  )r   r  r   
item_values   &&  r   _get_valuesbucket._get_values  s       {{5!!kk%(0022 #DHH~ "&4J!*"
44J/66t< ) s4   C&CB3 1C$C3C>CCCc                    V P                    FO  pV P                  V4      pV P                  V4      '       g   K-  V P                  V,          P	                  V4       KQ  	  \        V P                  4      # r   )r   r  r  r   r  r   )r   r   r  s   &  r   r  bucket.__iter__  sT    HHD4Jz**J'..t4 
 DKK  r   c                h    V P                  V4      '       g   \        R4      # V P                  V4      # )Nr   )r  r   r  r   r  s   &&r   r)  bucket.__getitem__  s+    u%%8O&&r   )r   r   r  r  r   )r+  r,  r-  r.  r/  r   r  r  r  r)  r0  r1  r2  s   @r   rP   rP   J  s)     !F8=4!' 'r   c                6    \        V 4      w  r#\        W4      V3# )al  Return a 2-tuple with a list containing the first *n* elements of
*iterable*, and an iterator with the same items as *iterable*.
This allows you to "look ahead" at the items in the iterable without
advancing it.

There is one item in the list by default:

    >>> iterable = 'abcdefg'
    >>> head, iterable = spy(iterable)
    >>> head
    ['a']
    >>> list(iterable)
    ['a', 'b', 'c', 'd', 'e', 'f', 'g']

You may use unpacking to retrieve items instead of lists:

    >>> (head,), iterable = spy('abcdefg')
    >>> head
    'a'
    >>> (first, second), iterable = spy('abcdefg', 2)
    >>> first
    'a'
    >>> second
    'b'

The number of items requested can be larger than the number of items in
the iterable:

    >>> iterable = [1, 2, 3, 4, 5]
    >>> head, iterable = spy(iterable, 10)
    >>> head
    [1, 2, 3, 4, 5]
    >>> list(iterable)
    [1, 2, 3, 4, 5]

)r   rD   )r   r   r   r   s   &&  r   r   r     s    J x=DA:q=r   c                 <    \         P                  ! \        V !  4      # )a  Return a new iterable yielding from each iterable in turn,
until the shortest is exhausted.

    >>> list(interleave([1, 2, 3], [4, 5], [6, 7, 8]))
    [1, 4, 6, 2, 5, 7]

For a version that doesn't terminate after the shortest iterable is
exhausted, see :func:`interleave_longest`.

)r   r   r?  r  s   *r   rs   rs     s     sI//r   c               '  l   "   \        V R\        /  F  pV F  pV\        Jg   K  Vx  K  	  K  	  R# 5i)aW  Return a new iterable yielding from each iterable in turn,
skipping any that are exhausted.

    >>> list(interleave_longest([1, 2, 3], [4, 5], [6, 7, 8]))
    [1, 4, 6, 2, 5, 7, 3, 8]

This function produces the same output as :func:`roundrobin`, but may
perform better for some inputs (in particular when the number of iterables
is large).

r  N)r   r:   )r  r  r   s   *  r   ru   ru     s2      988A  9s   44c              #  d  a"   Sf    V  Uu. uF  p\        V4      NK  	  upoM$\        V 4      \        S4      8w  d   \        R4      h\        S4      p\        \	        V4      V3R lRR7      pV Uu. uF  pSV,          NK  	  ppV Uu. uF  p\        W,          4      NK  	  ppV^ ,          VR,          rV^ ,          VR,          rW,          .\        V	4      ,          p\        S4      pV'       d   \        V
4      x  V^,          p\        W4       UUu. uF  w  rW,
          NK  	  ppp\        V4       F?  w  ppV^ 8  g   K  \        W,          4      x  V^,          pW;;,          V,          uu&   KA  	  K  R# u upi   \         d    \        R4      hi ; iu upi u upi u uppi 5i)a  
Interleave multiple iterables so that their elements are evenly distributed
throughout the output sequence.

>>> iterables = [1, 2, 3, 4, 5], ['a', 'b']
>>> list(interleave_evenly(iterables))
[1, 2, 'a', 3, 4, 'b', 5]

>>> iterables = [[1, 2, 3], [4, 5], [6, 7, 8]]
>>> list(interleave_evenly(iterables))
[1, 6, 4, 2, 7, 3, 8, 5]

This function requires iterables of known length. Iterables without
``__len__()`` can be used by manually specifying lengths with *lengths*:

>>> from itertools import combinations, repeat
>>> iterables = [combinations(range(4), 2), ['a', 'b', 'c']]
>>> lengths = [4 * (4 - 1) // 2, 3]
>>> list(interleave_evenly(iterables, lengths=lengths))
[(0, 1), (0, 2), 'a', (0, 3), (1, 2), 'b', (1, 3), (2, 3), 'c']

Based on Bresenham's algorithm.
Nz^Iterable lengths could not be determined automatically. Specify them with the lengths keyword.z,Mismatching number of iterables and lengths.c                    < SV ,          # r   r   )r_  lengthss   &r   rU  #interleave_evenly.<locals>.<lambda>  s	    71:r   Tr  r  :r  NN)
r   r   r   sortedr]  r   r>  r   r?  	enumerate)r  r  rX  dimslengths_permuter_  lengths_desc
iters_descdelta_primarydeltas_secondaryiter_primaryiters_secondaryerrorsto_yieldr   deltae_s   &f               r   rt   rt     s    0 	)232s2w3G 
Y3w<	'GHHw<D d-tO )881GAJJL8.=>o$y|$oJ> '31o|B7G#$.qM:b>/#$s+;'<<F7|H
<  A,/,IJ,I!)),IJ v&EArAv?-..A	]*		 ' 3 4 	9 	 9> Ks]   F0F FF AF03F F0F%%AF05$F0F*,F0	8F0F FF0c               '     "   V  Uu. uF  p\        V4      NK  	  ppV'       d+   \        \        V4      4      p \        W#,          4      x  K2  R# u upi   \         d    TR,          Y#&   TR  KU  i ; i5i)a  Repeatedly select one of the input *iterables* at random and yield the next
item from it.

    >>> iterables = [1, 2, 3], 'abc', (True, False, None)
    >>> list(interleave_randomly(*iterables))  # doctest: +SKIP
    ['a', 'b', 1, 'c', True, False, None, 2, 3]

The relative order of the items in each input iterable will preserved. Note the
sequences of items with this property are not equally likely to be generated.

Nr   )r   r,   r   r   r   )r  r   	iteratorsidxs   *   r   rv   rv   5  sn      #,,)Qa)I,
I'	y~&&  -
  	&r]IN"	s7   A6A	A6A6A 	A6A3/A62A33A6c              #    "   \        4       pVP                  ^ \        V ^4      34       V'       d   VP                  4       pVw  rVVe   WR8  d   T Rj  xL
  K2  V Fr  p\	        V\
        \        34      '       g   Ve   \	        Wq4      '       d   Vx  K:   \        V4      pVP                  V4       VP                  V^,           V34        K  	  K  R#  L  \         d	    Tx   K  i ; i5i)a  Flatten an iterable with multiple levels of nesting (e.g., a list of
lists of tuples) into non-iterable types.

    >>> iterable = [(1, 2), ([3, 4], [[5], [6]])]
    >>> list(collapse(iterable))
    [1, 2, 3, 4, 5, 6]

Binary and text strings are not considered iterable and
will not be collapsed.

To avoid collapsing other types, specify *base_type*:

    >>> iterable = ['ab', ('cd', 'ef'), ['gh', 'ij']]
    >>> list(collapse(iterable, base_type=tuple))
    ['ab', ('cd', 'ef'), 'gh', 'ij']

Specify *levels* to stop flattening after a certain level:

>>> iterable = [('a', ['b']), ('c', ['d'])]
>>> list(collapse(iterable))  # Fully flattened
['a', 'b', 'c', 'd']
>>> list(collapse(iterable, levels=1))  # Only one level flattened
['a', ['b'], 'c', ['d']]

N)	r   r  r   r  r   strbytesr   r   )	r   	base_typelevelsstack
node_grouplevelnodesnodetrees	   &&&      r   rU   rU   L  s     4 GE	a!,-.
]]_
! %.D$e--&Jt,G,G

:D
 $$Z0$$eai%67%    ! Js;   /C0#C0CAC0C$5C0C-)C0,C--C0c              #     "    Ve   V! 4        Vf   V F  pV ! V4       Vx  K  	  M$\        W4       F  pV ! V4       T Rj  xL
  K  	  Ve
   V! 4        R# R#  L  Te	   T! 4        i i ; i5i)a  Invoke *func* on each item in *iterable* (or on each *chunk_size* group
of items) before yielding the item.

`func` must be a function that takes a single argument. Its return value
will be discarded.

*before* and *after* are optional functions that take no arguments. They
will be executed before iteration starts and after it ends, respectively.

`side_effect` can be used for logging, updating progress bars, or anything
that is not functionally "pure."

Emitting a status message:

    >>> from more_itertools import consume
    >>> func = lambda item: print('Received {}'.format(item))
    >>> consume(side_effect(func, range(2)))
    Received 0
    Received 1

Operating on chunks of items:

    >>> pair_sums = []
    >>> func = lambda chunk: pair_sums.append(sum(chunk))
    >>> list(side_effect(func, [0, 1, 2, 3, 4, 5], 2))
    [0, 1, 2, 3, 4, 5]
    >>> list(pair_sums)
    [1, 5, 9]

Writing to a file-like object:

    >>> from io import StringIO
    >>> from more_itertools import consume
    >>> f = StringIO()
    >>> func = lambda x: print(x, file=f)
    >>> before = lambda: print(u'HEADER', file=f)
    >>> after = f.close
    >>> it = [u'a', u'b', u'c']
    >>> consume(side_effect(func, it, before=before, after=after))
    >>> f.closed
    True

N)rR   )r:  r   
chunk_sizebeforeafterr   r   s   &&&&&  r   r   r     s{     XH T

 ! !6U    7 G  !G s/   A/A A AA A/A A,,A/c                   a aa \        \        VV 3R l\        ^ S4       4       4      oV'       d   VV3R lpV! 4       # S# )a@  Yield slices of length *n* from the sequence *seq*.

>>> list(sliced((1, 2, 3, 4, 5, 6), 3))
[(1, 2, 3), (4, 5, 6)]

By the default, the last yielded slice will have fewer than *n* elements
if the length of *seq* is not divisible by *n*:

>>> list(sliced((1, 2, 3, 4, 5, 6, 7, 8), 3))
[(1, 2, 3), (4, 5, 6), (7, 8)]

If the length of *seq* is not divisible by *n* and *strict* is
``True``, then ``ValueError`` will be raised before the last
slice is yielded.

This function will only work for iterables that support slicing.
For non-sliceable iterables, see :func:`chunked`.

c              3   :   <"   T F  pSWS,            x  K  	  R # 5ir   r   )ro  r_  r   r  s   & r   rq  sliced.<locals>.<genexpr>  s     C{!s11u~{s   c               3   `   <"   S F"  p \        V 4      S8w  d   \        R 4      hV x  K$  	  R# 5i)zseq is not divisible by n.Nr   )_slicer   r   s    r   r   sliced.<locals>.ret  s-     "v;!#$%ABB #r   )r   r   r   )r  r   r   r   r   s   ff& @r   r   r     s3    ( CuQ{CDH	 ur   c              #    "   V^ 8X  d   \        V 4      x  R# . p\        V 4      pV FW  pV! V4      '       d6   Vx  V'       d   V.x  V^8X  d   \        V4      x   R# . pV^,          pKF  VP                  V4       KY  	  Vx  R# 5i)a  Yield lists of items from *iterable*, where each list is delimited by
an item where callable *pred* returns ``True``.

    >>> list(split_at('abcdcba', lambda x: x == 'b'))
    [['a'], ['c', 'd', 'c'], ['a']]

    >>> list(split_at(range(10), lambda n: n % 2 == 1))
    [[0], [2], [4], [6], [8], []]

At most *maxsplit* splits are done. If *maxsplit* is not specified or -1,
then there is no limit on the number of splits:

    >>> list(split_at(range(10), lambda n: n % 2 == 1, maxsplit=2))
    [[0], [2], [4, 5, 6, 7, 8, 9]]

By default, the delimiting items are not included in the output.
To include them, set *keep_separator* to ``True``.

    >>> list(split_at('abcdcba', lambda x: x == 'b', keep_separator=True))
    [['a'], ['b'], ['c', 'd', 'c'], ['b'], ['a']]

Nr!  r   r  )r   predmaxsplitkeep_separatorbufrX  r   s   &&&&   r   r   r     s     . 1}8n
C	hB::If1}2hCMHJJt  Is   AB	AB	c              #    "   V^ 8X  d   \        V 4      x  R# . p\        V 4      pV FJ  pV! V4      '       d)   V'       d!   Vx  V^8X  d   V.VOx   R# . pV^,          pVP                  V4       KL  	  V'       d   Vx  R# R# 5i)a4  Yield lists of items from *iterable*, where each list ends just before
an item for which callable *pred* returns ``True``:

    >>> list(split_before('OneTwo', lambda s: s.isupper()))
    [['O', 'n', 'e'], ['T', 'w', 'o']]

    >>> list(split_before(range(10), lambda n: n % 3 == 0))
    [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]

At most *maxsplit* splits are done. If *maxsplit* is not specified or -1,
then there is no limit on the number of splits:

    >>> list(split_before(range(10), lambda n: n % 3 == 0, maxsplit=2))
    [[0, 1, 2], [3, 4, 5], [6, 7, 8, 9]]
Nr  r   r  r  r  rX  r   s   &&&   r   r   r     s       1}8n
C	hB::#I1}kbk!CMH

4  	 s   >B<B>Bc              #  8  "   V^ 8X  d   \        V 4      x  R# . p\        V 4      pV F^  pVP                  V4       V! V4      '       g   K$  V'       g   K.  Vx  V^8X  d   \        V4      pV'       d   Vx   R# . pV^,          pK`  	  V'       d   Vx  R# R# 5i)a3  Yield lists of items from *iterable*, where each list ends with an
item where callable *pred* returns ``True``:

    >>> list(split_after('one1two2', lambda s: s.isdigit()))
    [['o', 'n', 'e', '1'], ['t', 'w', 'o', '2']]

    >>> list(split_after(range(10), lambda n: n % 3 == 0))
    [[0], [1, 2, 3], [4, 5, 6], [7, 8, 9]]

At most *maxsplit* splits are done. If *maxsplit* is not specified or -1,
then there is no limit on the number of splits:

    >>> list(split_after(range(10), lambda n: n % 3 == 0, maxsplit=2))
    [[0], [1, 2, 3], [4, 5, 6, 7, 8, 9]]

Nr  r  s   &&&   r   r   r   6  s     " 1}8n
C	hB

4::##I1}2hICMH  	 s   ABB;BBc              #  .  "   V^ 8X  d   \        V 4      x  R# \        V 4      p \        V4      pT.pT FD  pT! YF4      '       d!   Tx  T^8X  d   T.TOx   R# . pT^,          pTP	                  T4       TpKF  	  Tx  R#   \         d     R# i ; i5i)a  Split *iterable* into pieces based on the output of *pred*.
*pred* should be a function that takes successive pairs of items and
returns ``True`` if the iterable should be split in between them.

For example, to find runs of increasing numbers, split the iterable when
element ``i`` is larger than element ``i + 1``:

    >>> list(split_when([1, 2, 3, 3, 2, 5, 2, 4, 2], lambda x, y: x > y))
    [[1, 2, 3, 3], [2, 5], [2, 4], [2]]

At most *maxsplit* splits are done. If *maxsplit* is not specified or -1,
then there is no limit on the number of splits:

    >>> list(split_when([1, 2, 3, 3, 2, 5, 2, 4, 2],
    ...                 lambda x, y: x > y, maxsplit=2))
    [[1, 2, 3, 3], [2, 5], [2, 4, 2]]

N)r!  r   r   r   r  )r   r  r  rX  cur_itemr  	next_items   &&&    r   r   r   \  s     & 1}8n	hB8 *C	$$I1} &2&&CMH

9  I!  s(   "BB ABBBBBc              #     "   \        V 4      pV F-  pVf   \        V4      x   R# \        \        W#4      4      x  K/  	  R# 5i)a  Yield a list of sequential items from *iterable* of length 'n' for each
integer 'n' in *sizes*.

    >>> list(split_into([1,2,3,4,5,6], [1,2,3]))
    [[1], [2, 3], [4, 5, 6]]

If the sum of *sizes* is smaller than the length of *iterable*, then the
remaining items of *iterable* will not be returned.

    >>> list(split_into([1,2,3,4,5,6], [2,3]))
    [[1, 2], [3, 4, 5]]

If the sum of *sizes* is larger than the length of *iterable*, fewer items
will be returned in the iteration that overruns the *iterable* and further
lists will be empty:

    >>> list(split_into([1,2,3,4], [1,2,3,4]))
    [[1], [2, 3], [4], []]

When a ``None`` object is encountered in *sizes*, the returned list will
contain items up to the end of *iterable* the same way that
:func:`itertools.slice` does:

    >>> list(split_into([1,2,3,4,5,6,7,8,9,0], [2,3,None]))
    [[1, 2], [3, 4, 5], [6, 7, 8, 9, 0]]

:func:`split_into` can be useful for grouping a series of items where the
sizes of the groups are not uniform. An example would be where in a row
from a table, multiple columns represent elements of the same feature
(e.g. a point represented by x,y,z) but, the format is not the same for
all columns.
N)r   r!  r   )r   sizesrX  ra  s   &&  r   r   r     s<     F 
hB<r(Nvb'(( s   AAc                   aaa \        V 4      o\        S\        V4      4      oSf   S# S^8  d   \        R4      hV'       d$   VVV3R lp\        P                  ! V! 4       4      # \        \        SS4      S4      # )a  Yield the elements from *iterable*, followed by *fillvalue*, such that
at least *n* items are emitted.

    >>> list(padded([1, 2, 3], '?', 5))
    [1, 2, 3, '?', '?']

If *next_multiple* is ``True``, *fillvalue* will be emitted until the
number of items emitted is a multiple of *n*:

    >>> list(padded([1, 2, 3, 4], n=3, next_multiple=True))
    [1, 2, 3, 4, None, None]

If *n* is ``None``, *fillvalue* will be emitted indefinitely.

To create an *iterable* of exactly size *n*, you can truncate with
:func:`islice`.

    >>> list(islice(padded([1, 2, 3], '?'), 5))
    [1, 2, 3, '?', '?']
    >>> list(islice(padded([1, 2, 3, 4, 5, 6, 7, 8], '?'), 5))
    [1, 2, 3, 4, 5]

n must be at least 1c               3   V   <"   S F  p V 3x  \        SS^,
          4      x  K  	  R# 5ir  )r   )rl   r   iterator_with_repeatr   s    r   slice_generatorpadded.<locals>.slice_generator  s)     !h11q599 "s   &))r   r   r   r   r   r   )r   r  r   next_multipler  r   r  s   &&f& @@r   r   r     ss    0 H~H 6)+<=y##	
Q/00		: ""?#455 V0!4h??r   c           	     ^    \         P                  ! \        \        V \        V4      4      4      # )z|Repeat each element in *iterable* *n* times.

>>> list(repeat_each('ABC', 3))
['A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C']
)r   r   r   r   )r   r   s   &&r   r   r     s"     s68VAY?@@r   c              #  z   "   \         pV  F  pVx  K	  	  V\         J d   TMTp\        V4       Rj  xL
  R#  L5i)a
  After the *iterable* is exhausted, keep yielding its last element.

    >>> list(islice(repeat_last(range(3)), 5))
    [0, 1, 2, 2, 2]

If the iterable is empty, yield *default* forever::

    >>> list(islice(repeat_last(range(0), 42), 5))
    [42, 42, 42, 42, 42]

N)r:   r   )r   r   r   finals   &&  r   r   r     s5      D
 wGDEe}s   0;9;c           
         V ^8  d   \        R4      h\        W4      p\        V4       UUu. uF  w  r4\        WCRV 4      NK  	  upp# u uppi )aL  Distribute the items from *iterable* among *n* smaller iterables.

    >>> group_1, group_2 = distribute(2, [1, 2, 3, 4, 5, 6])
    >>> list(group_1)
    [1, 3, 5]
    >>> list(group_2)
    [2, 4, 6]

If the length of *iterable* is not evenly divisible by *n*, then the
length of the returned iterables will not be identical:

    >>> children = distribute(3, [1, 2, 3, 4, 5, 6, 7])
    >>> [list(c) for c in children]
    [[1, 4, 7], [2, 5], [3, 6]]

If the length of *iterable* is smaller than *n*, then the last returned
iterables will be empty:

    >>> children = distribute(5, [1, 2, 3])
    >>> [list(c) for c in children]
    [[1], [2], [3], [], []]

This function uses :func:`itertools.tee` and may require significant
storage.

If you need the order items in the smaller iterables to match the
original iterable, see :func:`divide`.

r  N)r   r   r  r   )r   r   childrenr"  rX  s   &&   r   rb   rb     sK    < 	1u/008H8A(8KL8K95F2dA&8KLLLs   Ac           	     J    \        V \        V4      4      p\        VRVRVRV/ # )a#  Yield tuples whose elements are offset from *iterable*.
The amount by which the `i`-th item in each tuple is offset is given by
the `i`-th item in *offsets*.

    >>> list(stagger([0, 1, 2, 3]))
    [(None, 0, 1), (0, 1, 2), (1, 2, 3)]
    >>> list(stagger(range(8), offsets=(0, 2, 4)))
    [(0, 2, 4), (1, 3, 5), (2, 4, 6), (3, 5, 7)]

By default, the sequence will end when the final element of a tuple is the
last item in the iterable. To continue until the first element of a tuple
is the last item in the iterable, set *longest* to ``True``::

    >>> list(stagger([0, 1, 2, 3], longest=True))
    [(None, 0, 1), (0, 1, 2), (1, 2, 3), (2, 3, None), (3, None, None)]

By default, ``None`` will be used to replace offsets beyond the end of the
sequence. Specify *fillvalue* to use some other value.

offsetslongestr  )r   r   r   )r   r  r  r  r  s   &&&& r   r   r   $  s<    * 8S\*H	",3?H r   c                 `    \         R8  d   \        P                  ! R\        4       \	        V !  # )a  ``zip`` the input *iterables* together but raise
``UnequalIterablesError`` if they aren't all the same length.

    >>> it_1 = range(3)
    >>> it_2 = iter('abc')
    >>> list(zip_equal(it_1, it_2))
    [(0, 'a'), (1, 'b'), (2, 'c')]

    >>> it_1 = range(3)
    >>> it_2 = iter('abcd')
    >>> list(zip_equal(it_1, it_2)) # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    more_itertools.more.UnequalIterablesError: Iterables have different
    lengths

i 
zwzip_equal will be removed in a future version of more-itertools. Use the builtin zip function with strict=True instead.)r7   warningswarnDeprecationWarningr;   r  s   *r   r   r   @  s/    $ Y' 	
 y!!r   r  r  c           	     t   \        V4      \        V 4      8w  d   \        R4      h. p\        W04       Fh  w  rVV^ 8  d(   VP                  \	        \        W&) 4      V4      4       K3  V^ 8  d   VP                  \        WVR4      4       KW  VP                  V4       Kj  	  V'       d   \        VRV/ # \        V!  # )a  ``zip`` the input *iterables* together, but offset the `i`-th iterable
by the `i`-th item in *offsets*.

    >>> list(zip_offset('0123', 'abcdef', offsets=(0, 1)))
    [('0', 'b'), ('1', 'c'), ('2', 'd'), ('3', 'e')]

This can be used as a lightweight alternative to SciPy or pandas to analyze
data sets in which some series have a lead or lag relationship.

By default, the sequence will end when the shortest iterable is exhausted.
To continue until the longest iterable is exhausted, set *longest* to
``True``.

    >>> list(zip_offset('0123', 'abcdef', offsets=(0, 1), longest=True))
    [('0', 'b'), ('1', 'c'), ('2', 'd'), ('3', 'e'), (None, 'f')]

By default, ``None`` will be used to replace offsets beyond the end of the
sequence. Specify *fillvalue* to use some other value.

z,Number of iterables and offsets didn't matchNr  )r   r   r?  r  r   r   r   r   )r  r  r  r  	staggeredrX  r   s   $$$*   r   r   r   _  s    * 9~W%GHHIY(q5U6)R#8"=>UVB401R  ) I;;;	?r   c           
        aaa Sf   \        V!  pM<\        V4      p\        V4      ^8X  d   V^ ,          oVV3R lpM\        V!  oVV3R lpV'       d   \        M\        p\        V! \        V! V !  WSR7      !  4      # )a  Return the input iterables sorted together, with *key_list* as the
priority for sorting. All iterables are trimmed to the length of the
shortest one.

This can be used like the sorting function in a spreadsheet. If each
iterable represents a column of data, the key list determines which
columns are used for sorting.

By default, all iterables are sorted using the ``0``-th iterable::

    >>> iterables = [(4, 3, 2, 1), ('a', 'b', 'c', 'd')]
    >>> sort_together(iterables)
    [(1, 2, 3, 4), ('d', 'c', 'b', 'a')]

Set a different key list to sort according to another iterable.
Specifying multiple keys dictates how ties are broken::

    >>> iterables = [(3, 1, 2), (0, 1, 0), ('c', 'b', 'a')]
    >>> sort_together(iterables, key_list=(1, 2))
    [(2, 3, 1), (0, 0, 1), ('a', 'c', 'b')]

To sort by a function of the elements of the iterable, pass a *key*
function. Its arguments are the elements of the iterables corresponding to
the key list::

    >>> names = ('a', 'b', 'c')
    >>> lengths = (1, 2, 3)
    >>> widths = (5, 2, 1)
    >>> def area(length, width):
    ...     return length * width
    >>> sort_together([names, lengths, widths], key_list=(1, 2), key=area)
    [('c', 'b', 'a'), (3, 2, 1), (1, 2, 5)]

Set *reverse* to ``True`` to sort in descending order.

    >>> sort_together([(1, 2, 3), ('c', 'b', 'a')], reverse=True)
    [(3, 2, 1), ('a', 'b', 'c')]

If the *strict* keyword argument is ``True``, then
``UnequalIterablesError`` will be raised if any of the iterables have
different lengths.

c                 "   < S! V S,          4      # r   r   )zipped_itemsr  
key_offsets   &r   rU  sort_together.<locals>.<lambda>  s    L4L0Mr   c                    < S! S! V 4      !  # r   r   )r  get_key_itemsr  s   &r   rU  r    s    |,1r   r  )r1   r!  r   r   r?  r  )	r  key_listr  r  r   key_argumentzipperr  r  s	   &&f&&  @@r   r   r     s}    \ { "8, >x=A "!JML '1ML !YcFvy)|MN r   c                    \        V 4      w  rV'       g   R# V^ ,          p\        V \        V4      4      p\        ;QJ d    . R \	        V4       4       F  NK  	  5# ! R \	        V4       4       4      # )a  The inverse of :func:`zip`, this function disaggregates the elements
of the zipped *iterable*.

The ``i``-th iterable contains the ``i``-th element from each element
of the zipped iterable. The first element is used to determine the
length of the remaining elements.

    >>> iterable = [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
    >>> letters, numbers = unzip(iterable)
    >>> list(letters)
    ['a', 'b', 'c', 'd']
    >>> list(numbers)
    [1, 2, 3, 4]

This is similar to using ``zip(*iterable)``, but it avoids reading
*iterable* into memory. Note, however, that this function uses
:func:`itertools.tee` and thus may require significant storage.

c              3   l   "   T F*  w  r\        \        \        V4      V4      \        4      x  K,  	  R # 5ir   )r{   r   r1   r   )ro  r_  rX  s   &  r   rq  unzip.<locals>.<genexpr>  s.      )EA 	c*Q-,j99)s   24r   )r   r   r   r\  r  )r   rf  r  s   &  r   r   r     sn    ( ]ND	7DHc$i(I 5 y)5 5 y)  r   c                P   V ^8  d   \        R4      h VR,           Tp\        \	        V4      V 4      w  r4. p^ p\        ^V ^,           4       F9  pTpYgV8:  d
   V^,           MT,          pVP                  \        W(V 4      4       K;  	  V#   \         d    \        T4      p Li ; i)a.  Divide the elements from *iterable* into *n* parts, maintaining
order.

    >>> group_1, group_2 = divide(2, [1, 2, 3, 4, 5, 6])
    >>> list(group_1)
    [1, 2, 3]
    >>> list(group_2)
    [4, 5, 6]

If the length of *iterable* is not evenly divisible by *n*, then the
length of the returned iterables will not be identical:

    >>> children = divide(3, [1, 2, 3, 4, 5, 6, 7])
    >>> [list(c) for c in children]
    [[1, 2, 3], [4, 5], [6, 7]]

If the length of the iterable is smaller than n, then the last returned
iterables will be empty:

    >>> children = divide(5, [1, 2, 3])
    >>> [list(c) for c in children]
    [[1], [2], [3], [], []]

This function will exhaust the iterable before returning.
If order is not important, see :func:`distribute`, which does not first
pull the iterable into memory.

r  :Nr   N)r   r   r\  divmodr   r]  r  r   )	r   r   r  r   re  r   r  r_  r  s	   &&       r   rc   rc     s    : 	1u/00 #c(ADA
CD1a!e_aAQ&

4$() 
 J  Hos   	B B%$B%c                    V f   \        R4      # Ve   \        W4      '       d   \        V 34      #  \        V 4      #   \         d    \        T 34      u # i ; i)a  If *obj* is iterable, return an iterator over its items::

    >>> obj = (1, 2, 3)
    >>> list(always_iterable(obj))
    [1, 2, 3]

If *obj* is not iterable, return a one-item iterable containing *obj*::

    >>> obj = 1
    >>> list(always_iterable(obj))
    [1]

If *obj* is ``None``, return an empty iterable:

    >>> obj = None
    >>> list(always_iterable(None))
    []

By default, binary and text strings are not considered iterable::

    >>> obj = 'foo'
    >>> list(always_iterable(obj))
    ['foo']

If *base_type* is set, objects for which ``isinstance(obj, base_type)``
returns ``True`` won't be considered iterable.

    >>> obj = {'a': 1}
    >>> list(always_iterable(obj))  # Iterate over the dict's keys
    ['a']
    >>> list(always_iterable(obj, base_type=dict))  # Treat dicts as a unit
    [{'a': 1}]

Set *base_type* to ``None`` to avoid any special handling and treat objects
Python considers iterable as iterable:

    >>> obj = 'foo'
    >>> list(always_iterable(obj, base_type=None))
    ['f', 'o', 'o']
r   )r   r   r   )objr  s   &&r   rL   rL   +  sY    R {Bx:c#=#=SF|Cy SF|s   
= AAc                    V^ 8  d   \        R4      h\        V4      w  r4R.V,          p\        V\        W4      V4      p\        \        \        V^V,          ^,           4      4      p\        Wt4      # )a+  Return an iterable over `(bool, item)` tuples where the `item` is
drawn from *iterable* and the `bool` indicates whether
that item satisfies the *predicate* or is adjacent to an item that does.

For example, to find whether items are adjacent to a ``3``::

    >>> list(adjacent(lambda x: x == 3, range(6)))
    [(False, 0), (False, 1), (True, 2), (True, 3), (True, 4), (False, 5)]

Set *distance* to change what counts as adjacent. For example, to find
whether items are two places away from a ``3``:

    >>> list(adjacent(lambda x: x == 3, range(6), distance=2))
    [(False, 0), (True, 1), (True, 2), (True, 3), (True, 4), (True, 5)]

This is useful for contextualizing the results of a search function.
For example, a code comparison tool might want to identify lines that
have changed, but also surrounding lines to give the viewer of the diff
context.

The predicate function will only be called once for each item in the
iterable.

See also :func:`groupby_transform`, which can be used with this function
to group ranges of items with the same `bool` value.

zdistance must be at least 0F)r   r   r   r   anyr   r?  )	predicater   distancei1i2r  selectedadjacent_to_selecteds   &&&     r   rJ   rJ   `  sj    : !|677]FBg GWc)0':HsHXq8|a7G$HI#((r   c                p   aa \        W4      pS'       d   V3R lV 4       pS'       d   V3R lV 4       pV# )a  An extension of :func:`itertools.groupby` that can apply transformations
to the grouped data.

* *keyfunc* is a function computing a key value for each item in *iterable*
* *valuefunc* is a function that transforms the individual items from
  *iterable* after grouping
* *reducefunc* is a function that transforms each group of items

>>> iterable = 'aAAbBBcCC'
>>> keyfunc = lambda k: k.upper()
>>> valuefunc = lambda v: v.lower()
>>> reducefunc = lambda g: ''.join(g)
>>> list(groupby_transform(iterable, keyfunc, valuefunc, reducefunc))
[('A', 'aaa'), ('B', 'bbb'), ('C', 'ccc')]

Each optional argument defaults to an identity function if not specified.

:func:`groupby_transform` is useful when grouping elements of an iterable
using a separate iterable as the key. To do this, :func:`zip` the iterables
and pass a *keyfunc* that extracts the first element and a *valuefunc*
that extracts the second element::

    >>> from operator import itemgetter
    >>> keys = [0, 0, 1, 1, 1, 2, 2, 2, 3]
    >>> values = 'abcdefghi'
    >>> iterable = zip(keys, values)
    >>> grouper = groupby_transform(iterable, itemgetter(0), itemgetter(1))
    >>> [(k, ''.join(g)) for k, g in grouper]
    [(0, 'ab'), (1, 'cde'), (2, 'fgh'), (3, 'i')]

Note that the order of items in the iterable is significant.
Only adjacent items are grouped together, so if you don't want any
duplicate groups, you should sort the iterable by the key function.

c              3   D   <"   T F  w  rV\        SV4      3x  K  	  R # 5ir   )r   )ro  r~  g	valuefuncs   &  r   rq  $groupby_transform.<locals>.<genexpr>  s     6#$!3y!$%#    c              3   <   <"   T F  w  rVS! V4      3x  K  	  R # 5ir   r   )ro  r~  r$  
reducefuncs   &  r   rq  r&    s     2cda:a=!cs   r   )r   keyfuncr%  r)  r   s   &&ff r   rn   rn     s/    H (
$C6#62c2Jr   c                      a  ] tR tRt o Rt]! ]! ^ ^ 4      4      tR tR t	R t
R tR tR tR	 tR
 t]R 4       tR tR tR tR tR tR tRtV tR# )r   i  a  An extension of the built-in ``range()`` function whose arguments can
be any orderable numeric type.

With only *stop* specified, *start* defaults to ``0`` and *step*
defaults to ``1``. The output items will match the type of *stop*:

    >>> list(numeric_range(3.5))
    [0.0, 1.0, 2.0, 3.0]

With only *start* and *stop* specified, *step* defaults to ``1``. The
output items will match the type of *start*:

    >>> from decimal import Decimal
    >>> start = Decimal('2.1')
    >>> stop = Decimal('5.1')
    >>> list(numeric_range(start, stop))
    [Decimal('2.1'), Decimal('3.1'), Decimal('4.1')]

With *start*, *stop*, and *step*  specified the output items will match
the type of ``start + step``:

    >>> from fractions import Fraction
    >>> start = Fraction(1, 2)  # Start at 1/2
    >>> stop = Fraction(5, 2)  # End at 5/2
    >>> step = Fraction(1, 2)  # Count by 1/2
    >>> list(numeric_range(start, stop, step))
    [Fraction(1, 2), Fraction(1, 1), Fraction(3, 2), Fraction(2, 1)]

If *step* is zero, ``ValueError`` is raised. Negative steps are supported:

    >>> list(numeric_range(3, -1, -1.0))
    [3.0, 2.0, 1.0, 0.0]

Be aware of the limitations of floating-point numbers; the representation
of the yielded numbers may be surprising.

``datetime.datetime`` objects can be used for *start* and *stop*, if *step*
is a ``datetime.timedelta`` object:

    >>> import datetime
    >>> start = datetime.datetime(2019, 1, 1)
    >>> stop = datetime.datetime(2019, 1, 3)
    >>> step = datetime.timedelta(days=1)
    >>> items = iter(numeric_range(start, stop, step))
    >>> next(items)
    datetime.datetime(2019, 1, 1, 0, 0)
    >>> next(items)
    datetime.datetime(2019, 1, 2, 0, 0)

c                   \        V4      pV^8X  d\   Vw  V n        \        V P                  4      ! ^ 4      V n        \        V P                  V P                  ,
          4      ! ^4      V n        MV^8X  dB   Vw  V n        V n        \        V P                  V P                  ,
          4      ! ^4      V n        M@V^8X  d   Vw  V n        V n        V n        M#V^ 8X  d   \        RV 24      h\        RV 24      h\        V P                  4      ! ^ 4      V n        V P                  V P                  8X  d   \        R4      hV P                  V P                  8  V n        R# )r  z0numeric_range expected at least 1 argument, got z0numeric_range expected at most 3 arguments, got z&numeric_range() arg 3 must not be zeroN)	r   _stoptype_start_stepr   _zeror   _growing)r   r7  argcs   &* r   r   numeric_range.__init__  s   4y19 MTZtzz*1-DKdjj4;;67:DJQY&*#DKdjj4;;67:DJQY26/DKTZQYB4&I  B4&I  $**%a(
::#EFF

TZZ/r   c                    V P                   '       d   V P                  V P                  8  # V P                  V P                  8  # r   )r3  r0  r.  r  s   &r   r
  numeric_range.__bool__	  s1    ===;;++;;++r   c                   V P                   '       d[   V P                  Tu;8:  d   V P                  8  d5   M R # WP                  ,
          V P                  ,          V P                  8H  #  R # V P                  Tu;8  d   V P                  8  d7   M R # V P                  V,
          V P                  ) ,          V P                  8H  # R # F)r3  r0  r.  r1  r2  )r   elems   &&r   r  numeric_range.__contains__		  s    ==={{d/TZZ/  {{*djj8DJJFF 0  {{d/TZZ/  d*

{;tzzIIr   c                t   \        V\        4      '       d   \        V 4      '       * p\        V4      '       * pV'       g	   V'       d   T;'       d    T# V P                  VP                  8H  ;'       dE    V P                  VP                  8H  ;'       d$    V P                  R4      VP                  R4      8H  # R# )r  Fr   )r   r   boolr0  r1  _get_by_index)r   other
empty_selfempty_others   &&  r   __eq__numeric_range.__eq__	  s    e]++!$ZJ"5k/K[!11k1 KK5<</ J J

ekk1J J**2.%2E2Eb2II r   c                .   \        V\        4      '       d   V P                  V4      # \        V\        4      '       Ed8   VP                  f   V P
                  MVP                  V P
                  ,          pVP                  e   VP                  V P                  ) 8:  d   V P                  pMCVP                  V P                  8  d   V P                  pMV P                  VP                  4      pVP                  e   VP                  V P                  8  d   V P                  pMDVP                  V P                  ) 8:  d   V P                  pMV P                  VP                  4      p\        W4V4      # \        R\        V4      P                   24      h)Nz6numeric range indices must be integers or slices, not )r   intr>  r(  r  r1  r  _lenr0  r.  r  r   r   r/  r+  )r   r  r  r  r  s   &&   r   r)  numeric_range.__getitem__"	  s%   c3%%c**U##!$!14::sxx$**7LDyy CII$))$;dii'

**3995xx388tyy#8zzdiiZ'{{))#((3 d33++/9+=+=*>@ r   c                    V '       d2   \        V P                  V P                  R4      V P                  34      # V P                  # r  r   )hashr0  r>  r1  _EMPTY_HASHr  s   &r   __hash__numeric_range.__hash__=	  s6    d&8&8&<djjIJJ###r   c                   a  V 3R  l\        4        4       pS P                  '       d%   \        \        \        S P
                  4      V4      # \        \        \        S P
                  4      V4      # )c              3   l   <"   T F)  pSP                   VSP                  ,          ,           x  K+  	  R # 5ir   )r0  r1  )ro  r   r   s   & r   rq  )numeric_range.__iter__.<locals>.<genexpr>D	  s%     B'Q$++TZZ00's   14)r   r3  r   r
   r6   r.  r2   )r   valuess   f r   r  numeric_range.__iter__C	  sH    B%'B===WR4f==WR4f==r   c                    V P                   # r   )rF  r  s   &r   __len__numeric_range.__len__J	  s    yyr   c                V   V P                   '       d&   V P                  pV P                  pV P                  pM%V P                  pV P                  pV P                  ) pW!,
          pW@P                  8:  d   ^ # \        WC4      w  rV\        V4      \        W`P                  8g  4      ,           # r'  )r3  r0  r.  r1  r2  r  rE  )r   r  r  r  r  r   re  s   &      r   rF  numeric_range._lenM	  s}    ===KKE::D::DJJE;;DJJ;D<zz!()DAq6CZZ000r   c                T    \         V P                  V P                  V P                  33# r   )r   r0  r.  r1  r  s   &r   
__reduce__numeric_range.__reduce__^	  s     t{{DJJ

CCCr   c                    V P                   ^8X  d    RV P                  : RV P                  : R2# RV P                  : RV P                  : RV P                   : R2# )r  znumeric_range(rF  rQ  )r1  r0  r.  r  s   &r   __repr__numeric_range.__repr__a	  sS    ::?#DKK?"TZZN!DDT[[O2djj^2djj^1M	
r   c                    \        \        V P                  R4      V P                  V P                  ,
          V P                  ) 4      4      # rI  )r   r   r>  r0  r1  r  s   &r   r   numeric_range.__reversed__h	  s<    ""2&djj(@4::+
 	
r   c                    \        W9   4      # r   )rE  r  s   &&r   r   numeric_range.counto	  s    5=!!r   c                   V P                   '       dk   V P                  Tu;8:  d   V P                  8  dG   M M\        WP                  ,
          V P                  4      w  r#W0P
                  8X  d   \        V4      # MkV P                  Tu;8  d   V P                  8  dI   M ME\        V P                  V,
          V P                  ) 4      w  r#W0P
                  8X  d   \        V4      # \        V R 24      h)z is not in numeric range)r3  r0  r.  r  r1  r2  rE  r   )r   r  r   re  s   &&  r   r"  numeric_range.indexr	  s    ==={{e0djj0ekk14::>

?q6M{{e0djj0dkkE1DJJ;?

?q6ME7":;<<r   c                    V^ 8  d   WP                   ,          pV^ 8  g   WP                   8  d   \        R4      hV P                  WP                  ,          ,           # )r   z'numeric range object index out of range)rF  r   r0  r1  )r   r_  s   &&r   r>  numeric_range._get_by_index	  sD    q5NAq5ANFGG{{Q^++r   )r3  r0  r1  r.  r2  N)r+  r,  r-  r.  r/  rJ  r]  rK  r   r
  r  rB  r)  rL  r  rT  r	   rF  rY  r\  r   r   r"  r>  r0  r1  r2  s   @r   r   r     s}     1f uQ{#K02,6$> 1 1 D

"=, ,r   c                    \        V 4      pV'       g   \        R4      # Vf   \        4       M
\        V4      p\	        \        V\        V4      4      \        V4      4      # )a	  Cycle through the items from *iterable* up to *n* times, yielding
the number of completed cycles along with each item. If *n* is omitted the
process repeats indefinitely.

>>> list(count_cycle('AB', 3))
[(0, 'A'), (0, 'B'), (1, 'A'), (1, 'B'), (2, 'A'), (2, 'B')]

r   )r\  r   r   r]  r?  r   r   r   )r   r   r  counters   &&  r   r[   r[   	  sF     /CBxegaG{7CH-uSz::r   c              #  p   "   \        V 4      pV F   pRpV F  pVRV3x  TpRpK  	  VRV3x  K"  	  R# 5i)a  Yield 3-tuples of the form ``(is_first, is_last, item)``.

>>> list(mark_ends('ABC'))
[(True, False, 'A'), (False, False, 'B'), (False, True, 'C')]

Use this when looping over an iterable to take special action on its first
and/or last items:

>>> iterable = ['Header', 100, 200, 'Footer']
>>> total = 0
>>> for is_first, is_last, item in mark_ends(iterable):
...     if is_first:
...         continue  # Skip the header
...     if is_last:
...         continue  # Skip the footer
...     total += item
>>> print(total)
300
TFN)r   )r   rX  arl   bs   &    r   r   r   	  sM     ( 
hBA/!AE  T1n s   46c                    Vf   \        \        4       \        W4      4      # V^8  d   \        R4      h\	        W\
        R7      p\        \        4       \        W4      4      # )a3  Yield the index of each item in *iterable* for which *pred* returns
``True``.

*pred* defaults to :func:`bool`, which will select truthy items:

    >>> list(locate([0, 1, 1, 0, 1, 0, 0]))
    [1, 2, 4]

Set *pred* to a custom function to, e.g., find the indexes for a particular
item.

    >>> list(locate(['a', 'b', 'c', 'b'], lambda x: x == 'b'))
    [1, 3]

If *window_size* is given, then the *pred* function will be called with
that many items. This enables searching for sub-sequences:

    >>> iterable = [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]
    >>> pred = lambda *args: args == (1, 2, 3)
    >>> list(locate(iterable, pred=pred, window_size=3))
    [1, 5, 9]

Use with :func:`seekable` to find indexes and then retrieve the associated
items:

    >>> from itertools import count
    >>> from more_itertools import seekable
    >>> source = (3 * n + 1 if (n % 2) else n // 2 for n in count())
    >>> it = seekable(source)
    >>> pred = lambda x: x > 100
    >>> indexes = locate(it, pred=pred)
    >>> i = next(indexes)
    >>> it.seek(i)
    >>> next(it)
    106

zwindow size must be at least 1r  )r   r   r   r   r   r:   r   )r   r  window_sizerX  s   &&& r   r~   r~   	  sR    L T!455Q9::	(7	;BEGWT.//r   c                >    R \        \        \        V !  4       4       # )zYield elements of the longest common prefix among given *iterables*.

>>> ''.join(longest_common_prefix(['abcd', 'abc', 'abf']))
'ab'

c              3   2   "   T F  q^ ,          x  K  	  R# 5ir   Nr   )ro  cs   & r   rq  (longest_common_prefix.<locals>.<genexpr>	  s     @?QaDD?s   )r   rF   r?  r  s   &r   r   r   	  s     A)IsI?@@r   c                    \        W4      # )a  Yield the items from *iterable*, but strip any from the beginning
for which *pred* returns ``True``.

For example, to remove a set of items from the start of an iterable:

    >>> iterable = (None, False, None, 1, 2, None, 3, False, None)
    >>> pred = lambda x: x in {None, False, ''}
    >>> list(lstrip(iterable, pred))
    [1, 2, None, 3, False, None]

This function is analogous to to :func:`str.lstrip`, and is essentially
an wrapper for :func:`itertools.dropwhile`.

)r   r   r  s   &&r   r   r   	  s     T$$r   c              #     "   . pVP                   pVP                  pV  F0  pV! V4      '       d   V! V4       K  T Rj  xL
  V! 4        Vx  K2  	  R#  L5i)a  Yield the items from *iterable*, but strip any from the end
for which *pred* returns ``True``.

For example, to remove a set of items from the end of an iterable:

    >>> iterable = (None, False, None, 1, 2, None, 3, False, None)
    >>> pred = lambda x: x in {None, False, ''}
    >>> list(rstrip(iterable, pred))
    [None, False, None, 1, 2, None, 3]

This function is analogous to :func:`str.rstrip`.

N)r  clear)r   r  cachecache_appendcache_clearr   s   &&    r   r   r   
  sP      E<<L++K77OMG  s   =AA Ac                ,    \        \        W4      V4      # )a  Yield the items from *iterable*, but strip any from the
beginning and end for which *pred* returns ``True``.

For example, to remove a set of items from both ends of an iterable:

    >>> iterable = (None, False, None, 1, 2, None, 3, False, None)
    >>> pred = lambda x: x in {None, False, ''}
    >>> list(strip(iterable, pred))
    [1, 2, None, 3]

This function is analogous to :func:`str.strip`.

)r   r   rt  s   &&r   r   r   
  s     &($//r   c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	ry   i-
  a  An extension of :func:`itertools.islice` that supports negative values
for *stop*, *start*, and *step*.

    >>> iterator = iter('abcdefgh')
    >>> list(islice_extended(iterator, -4, -1))
    ['e', 'f', 'g']

Slices with negative values require some caching of *iterable*, but this
function takes care to minimize the amount of memory required.

For example, you can use a negative step with an infinite iterator:

    >>> from itertools import count
    >>> list(islice_extended(count(), 110, 99, -2))
    [110, 108, 106, 104, 102, 100]

You can also use slice notation directly:

    >>> iterator = map(str, count())
    >>> it = islice_extended(iterator)[10:20:2]
    >>> list(it)
    ['10', '12', '14', '16', '18']

c                l    \        V4      pV'       d   \        V\        V!  4      V n        R # W0n        R # r   )r   _islice_helperr(  	_iterator)r   r   r7  rX  s   &&* r   r   islice_extended.__init__G
  s%    (^+Bt=DNNr   c                    V # r   r   r  s   &r   r  islice_extended.__iter__N
  r  r   c                ,    \        V P                  4      # r   r   r~  r  s   &r   r  islice_extended.__next__Q
      DNN##r   c                    \        V\        4      '       d    \        \        V P                  V4      4      # \        R 4      h)z4islice_extended.__getitem__ argument must be a slice)r   r(  ry   r}  r~  r   )r   r  s   &&r   r)  islice_extended.__getitem__T
  s1    c5!!">$..##FGGNOOr   )r~  N)r+  r,  r-  r.  r/  r   r  r  r)  r0  r1  r2  s   @r   ry   ry   -
  s%     2 $P Pr   c              #     "   VP                   pVP                  pVP                  ^ 8X  d   \        R4      hVP                  ;'       g    ^pV^ 8  Ed   Vf   ^ MTpV^ 8  d   \	        \        V ^4      V) R7      pV'       d   VR,          ^ ,          M^ p\        Wb,           ^ 4      pVf   TpM%V^ 8  d   \        W64      pM\        Wc,           ^ 4      pW,
          p	V	^ 8:  d   R# \        V	4       F;  p
W,          ^ 8X  d   VP                  4       ^,          x  K+  VP                  4        K=  	  R# Ve   V^ 8  d   \        \        WV4      R4       \	        \        W) 4      V) R7      p\        V 4       FF  w  rW,          ^ 8X  d   VP                  4       x  MVP                  4        VP                  V4       KH  	  R# \        WW44       Rj  xL
  R# Vf   RMTpVe   V^ 8  d|   V) ^,
          p	\	        \        V ^4      V	R7      pV'       d   VR,          ^ ,          M^ pV^ 8  d   Y#rM\        W&,
          R4      Rr\        V4      WxV1,           F	  w  rVx  K  	  R# Ve    V^,           p\        \        WV4      R4       V^ 8  d   TpRp	M#Vf   RpV^,           p	MRpW#,
          p	V	^ 8:  d   R# \        \        W	4      4      pWWRV1,           Rj  xL
  R#  EL L	5i)r   z1step argument must be a non-zero integer or None.Nr   r   )r  r  r  r   r   r  r   r  r]  r  r   r   r  r!  )rX  sr  r  r  rw  len_iterr_  r`  r   r"  r   ms   &&           r   r}  r}  [
  s    GGE66Dvv{LMM66;;QDaxm%19)B*E6:E',uRy|!H H$a(A |'+ AAvq<1$  --/!,, MMO " TAX5)40 &U+TE:E(}<1$  --/) MMOT"  - b444}54!8	A)B*15E',uRy|!H
 qy15+R0$1#E{1t844
  5 1HVB1%t, qy AI L6'EWW~%%[ 5Z &s,   AK%
FK%K DK%K#K%#K%c                d     \        V 4      #   \         d    \        \        T 4      4      u # i ; i)a  An extension of :func:`reversed` that supports all iterables, not
just those which implement the ``Reversible`` or ``Sequence`` protocols.

    >>> print(*always_reversible(x for x in range(3)))
    2 1 0

If the iterable is already reversible, this function returns the
result of :func:`reversed()`. If the iterable is not reversible,
this function will cache the remaining items in the iterable and
yield them in reverse order, which may require significant storage.
)r   r   r!  r@  s   &r   rM   rM   
  s0    (!! (X''(s   
 //c              #     a"   Sf   R pMV3R lp\        \        V 4      VR7       F  w  r4\        \        ^4      V4      x  K  	  R# 5i)a  Yield groups of consecutive items using :func:`itertools.groupby`.
The *ordering* function determines whether two items are adjacent by
returning their position.

By default, the ordering function is the identity function. This is
suitable for finding runs of numbers:

    >>> iterable = [1, 10, 11, 12, 20, 30, 31, 32, 33, 40]
    >>> for group in consecutive_groups(iterable):
    ...     print(list(group))
    [1]
    [10, 11, 12]
    [20]
    [30, 31, 32, 33]
    [40]

To find runs of adjacent letters, apply :func:`ord` function
to convert letters to ordinals.

    >>> iterable = 'abcdfgilmnop'
    >>> ordering = ord
    >>> for group in consecutive_groups(iterable, ordering):
    ...     print(list(group))
    ['a', 'b', 'c', 'd']
    ['f', 'g']
    ['i']
    ['l', 'm', 'n', 'o', 'p']

Each group of consecutive items is an iterator that shares it source with
*iterable*. When an an output group is advanced, the previous group is
no longer available unless its elements are copied (e.g., into a ``list``).

    >>> iterable = [1, 2, 11, 12, 21, 22]
    >>> saved_groups = []
    >>> for group in consecutive_groups(iterable):
    ...     saved_groups.append(list(group))  # Copy group elements
    >>> saved_groups
    [[1, 2], [11, 12], [21, 22]]

Nc                 0    V ^ ,          V ^,          ,
          # r'  r   r  s   &r   rU  $consecutive_groups.<locals>.<lambda>  s    !qtr   c                 >   < V ^ ,          S! V ^,          4      ,
          # r'  r   )r   orderings   &r   rU  r    s    !x!~-r   r  )r   r  r   r1   )r   r  r  r~  r$  s   &f   r   rX   rX   
  sB     R #-	(+5*Q-## 6s   AA
initialc                   \        V 4      w  r4 \        V4      .pTe   . p\	        T\        YT4      4      #   \         d    \        . 4      u # i ; i)a  This function is the inverse of :func:`itertools.accumulate`. By default
it will compute the first difference of *iterable* using
:func:`operator.sub`:

    >>> from itertools import accumulate
    >>> iterable = accumulate([0, 1, 2, 3, 4])  # produces 0, 1, 3, 6, 10
    >>> list(difference(iterable))
    [0, 1, 2, 3, 4]

*func* defaults to :func:`operator.sub`, but other functions can be
specified. They will be applied as follows::

    A, B, C, D, ... --> A, func(B, A), func(C, B), func(D, C), ...

For example, to do progressive division:

    >>> iterable = [1, 2, 6, 24, 120]
    >>> func = lambda x, y: x // y
    >>> list(difference(iterable, func))
    [1, 2, 3, 4, 5]

If the *initial* keyword is set, the first element will be skipped when
computing successive differences.

    >>> it = [10, 11, 13, 16]  # from accumulate([1, 2, 3], initial=10)
    >>> list(difference(it, initial=10))
    [1, 2, 3]

)r   r   r   r   r   r   )r   r:  r  ri  rj  rl   s   &&$   r   r_   r_     sY    < x=DAa	 DQ((  Bxs   7 AAc                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	rI   i5  a  Return a read-only view of the sequence object *target*.

:class:`SequenceView` objects are analogous to Python's built-in
"dictionary view" types. They provide a dynamic view of a sequence's items,
meaning that when the sequence updates, so does the view.

    >>> seq = ['0', '1', '2']
    >>> view = SequenceView(seq)
    >>> view
    SequenceView(['0', '1', '2'])
    >>> seq.append('3')
    >>> view
    SequenceView(['0', '1', '2', '3'])

Sequence views support indexing, slicing, and length queries. They act
like the underlying sequence, except they don't allow assignment:

    >>> view[1]
    '1'
    >>> view[1:-1]
    ['1', '2']
    >>> len(view)
    4

Sequence views are useful as an alternative to copying, as they don't
require (much) extra storage.

c                J    \        V\        4      '       g   \        hWn        R # r   )r   r   r   _target)r   targets   &&r   r   SequenceView.__init__S  s    &(++Or   c                (    V P                   V,          # r   r  )r   r"  s   &&r   r)  SequenceView.__getitem__X  s    ||E""r   c                ,    \        V P                  4      # r   )r   r  r  s   &r   rT  SequenceView.__len__[  s    4<<  r   c                P    V P                   P                   R V P                  : R2# )(rQ  )	__class__r+  r  r  s   &r   r\  SequenceView.__repr__^  s%    ..))*!DLL+;1==r   r  N)r+  r,  r-  r.  r/  r   r)  rT  r\  r0  r1  r2  s   @r   rI   rI   5  s#     :
#!> >r   c                   ^   a  ] tR tRt o RtRR ltR tR tR t]	3R lt
R	 tR
 tR tRtV tR# )r   ib  an
  Wrap an iterator to allow for seeking backward and forward. This
progressively caches the items in the source iterable so they can be
re-visited.

Call :meth:`seek` with an index to seek to that position in the source
iterable.

To "reset" an iterator, seek to ``0``:

    >>> from itertools import count
    >>> it = seekable((str(n) for n in count()))
    >>> next(it), next(it), next(it)
    ('0', '1', '2')
    >>> it.seek(0)
    >>> next(it), next(it), next(it)
    ('0', '1', '2')

You can also seek forward:

    >>> it = seekable((str(n) for n in range(20)))
    >>> it.seek(10)
    >>> next(it)
    '10'
    >>> it.seek(20)  # Seeking past the end of the source isn't a problem
    >>> list(it)
    []
    >>> it.seek(0)  # Resetting works even after hitting the end
    >>> next(it)
    '0'

Call :meth:`relative_seek` to seek relative to the source iterator's
current position.

    >>> it = seekable((str(n) for n in range(20)))
    >>> next(it), next(it), next(it)
    ('0', '1', '2')
    >>> it.relative_seek(2)
    >>> next(it)
    '5'
    >>> it.relative_seek(-3)  # Source is at '6', we move back to '3'
    >>> next(it)
    '3'
    >>> it.relative_seek(-3)  # Source is at '4', we move back to '1'
    >>> next(it)
    '1'


Call :meth:`peek` to look ahead one item without advancing the iterator:

    >>> it = seekable('1234')
    >>> it.peek()
    '1'
    >>> list(it)
    ['1', '2', '3', '4']
    >>> it.peek(default='empty')
    'empty'

Before the iterator is at its end, calling :func:`bool` on it will return
``True``. After it will return ``False``:

    >>> it = seekable('5678')
    >>> bool(it)
    True
    >>> list(it)
    ['5', '6', '7', '8']
    >>> bool(it)
    False

You may view the contents of the cache with the :meth:`elements` method.
That returns a :class:`SequenceView`, a view that updates automatically:

    >>> it = seekable((str(n) for n in range(10)))
    >>> next(it), next(it), next(it)
    ('0', '1', '2')
    >>> elements = it.elements()
    >>> elements
    SequenceView(['0', '1', '2'])
    >>> next(it)
    '3'
    >>> elements
    SequenceView(['0', '1', '2', '3'])

By default, the cache grows as the source iterable progresses, so beware of
wrapping very large or infinite iterables. Supply *maxlen* to limit the
size of the cache (this of course limits how far back you can seek).

    >>> from itertools import count
    >>> it = seekable((str(n) for n in count()), maxlen=2)
    >>> next(it), next(it), next(it), next(it)
    ('0', '1', '2', '3')
    >>> list(it.elements())
    ['2', '3']
    >>> it.seek(0)
    >>> next(it), next(it), next(it), next(it)
    ('2', '3', '4', '5')
    >>> next(it)
    '6'

Nc                n    \        V4      V n        Vf	   . V n        M\        . V4      V n        R V n        R # r   )r   _sourcer   r   _index)r   r   r   s   &&&r   r   seekable.__init__  s.    H~>DKF+DKr   c                    V # r   r   r  s   &r   r  seekable.__iter__  r  r   c                $   V P                   e:    V P                  V P                   ,          pV ;P                   ^,          un         V# \        V P                  4      pV P                  P                  V4       V#   \         d    R T n          LFi ; ir   )r  r   r   r   r  r  r   r   s   & r   r  seekable.__next__  su    ;;"{{4;;/ q DLL!4   #"#s   A: :BBc                L     V P                  4        R#   \         d     R # i ; ir  r  r  s   &r   r
  seekable.__bool__  r  r  c                     \        V 4      pT P                  f   \	        T P
                  4      T n        T ;P                  ^,          un        T#   \         d    T\        J d   h Tu # i ; ir   )r   r   r:   r  r   r   )r   r   peekeds   && r   r	  seekable.peek  s`    	$ZF
 ;;dkk*DKq  	'!N	s   A A+*A+c                ,    \        V P                  4      # r   )rI   r   r  s   &r   elementsseekable.elements  s    DKK((r   c                r    Wn         V\        V P                  4      ,
          pV^ 8  d   \        W4       R# R# rp  )r  r   r   r=   )r   r"  	remainders   && r   seekseekable.seek  s.    C,,	q=D$ r   c                    V P                   f   \        V P                  4      V n         V P                  \	        V P                   V,           ^ 4      4       R # r   )r  r   r   r  r   )r   r   s   &&r   relative_seekseekable.relative_seek  s8    ;;dkk*DK		#dkkE)1-.r   )r   r  r  r   )r+  r,  r-  r.  r/  r   r  r  r
  r:   r	  r  r  r  r0  r1  r2  s   @r   r   r   b  s>     bH # 
)%/ /r   c                   D   a  ] tR tRt o Rt]R 4       t]R 4       tRtV t	R# )r   i  af  
:func:`run_length.encode` compresses an iterable with run-length encoding.
It yields groups of repeated items with the count of how many times they
were repeated:

    >>> uncompressed = 'abbcccdddd'
    >>> list(run_length.encode(uncompressed))
    [('a', 1), ('b', 2), ('c', 3), ('d', 4)]

:func:`run_length.decode` decompresses an iterable that was previously
compressed with run-length encoding. It yields the items of the
decompressed iterable:

    >>> compressed = [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
    >>> list(run_length.decode(compressed))
    ['a', 'b', 'b', 'c', 'c', 'c', 'd', 'd', 'd', 'd']

c                &    R  \        V 4       4       # )c              3   @   "   T F  w  rV\        V4      3x  K  	  R # 5ir   )rr   )ro  r~  r$  s   &  r   rq  $run_length.encode.<locals>.<genexpr>  s     ;):DG):s   r*  r@  s   &r   encoderun_length.encode  s    ;):;;r   c                J    \         P                  ! \        \        V 4      4      # r   )r   r   r   r   r@  s   &r   decoderun_length.decode  s    ""768#<==r   r   N)
r+  r,  r-  r.  r/  staticmethodr  r  r0  r1  r2  s   @r   r   r     s2     & < < > >r   c                R    \        \        \        W 4      V^,           4      4      V8H  # )a  Return ``True`` if exactly ``n`` items in the iterable are ``True``
according to the *predicate* function.

    >>> exactly_n([True, True, False], 2)
    True
    >>> exactly_n([True, True, False], 1)
    False
    >>> exactly_n([0, 1, 2, 3, 4, 5], 3, lambda x: x < 3)
    True

The iterable will be advanced until ``n + 1`` truthy items are encountered,
so avoid calling it on infinite iterables.

)rr   r   r  )r   r   r  s   &&&r   rh   rh      s$     vi2AE:;q@@r   c              #  "  "   \        V 4      pV^ 8X  d   \        R4      hVP                  V4       V) p\        V4      pV\        P
                  ! W14      ,          p\        RV4       F!  pVP                  V4       \        V4      x  K#  	  R# 5i)a  Yield the circular shifts of *iterable*.

>>> list(circular_shifts(range(4)))
[(0, 1, 2, 3), (1, 2, 3, 0), (2, 3, 0, 1), (3, 0, 1, 2)]

Set *steps* to the number of places to rotate to the left
(or to the right if negative).  Defaults to 1.

>>> list(circular_shifts(range(4), 2))
[(0, 1, 2, 3), (2, 3, 0, 1)]

>>> list(circular_shifts(range(4), -1))
[(0, 1, 2, 3), (3, 0, 1, 2), (2, 3, 0, 1), (1, 2, 3, 0)]

z"Steps should be a non-zero integerN)r   r   rotater   mathgcdr   r\  )r   stepsbufferr   r  s   &&   r   rT   rT   2  sx       8_Fz=>>
MM%FEFA$((1
AD!_eFm s   BBc                   a a VV 3R lpV# )aZ  Return a decorator version of *wrapping_func*, which is a function that
modifies an iterable. *result_index* is the position in that function's
signature where the iterable goes.

This lets you use itertools on the "production end," i.e. at function
definition. This can augment what the function returns without changing the
function's code.

For example, to produce a decorator version of :func:`chunked`:

    >>> from more_itertools import chunked
    >>> chunker = make_decorator(chunked, result_index=0)
    >>> @chunker(3)
    ... def iter_range(n):
    ...     return iter(range(n))
    ...
    >>> list(iter_range(9))
    [[0, 1, 2], [3, 4, 5], [6, 7, 8]]

To only allow truthy items to be returned:

    >>> truth_serum = make_decorator(filter, result_index=1)
    >>> @truth_serum(bool)
    ... def boolean_test():
    ...     return [0, 1, '', ' ', False, True]
    ...
    >>> list(boolean_test())
    [1, ' ', True]

The :func:`peekable` and :func:`seekable` wrappers make for practical
decorators:

    >>> from more_itertools import peekable
    >>> peekable_function = make_decorator(peekable)
    >>> @peekable_function()
    ... def str_range(*args):
    ...     return (str(x) for x in range(*args))
    ...
    >>> it = str_range(1, 20, 2)
    >>> next(it), next(it), next(it)
    ('1', '3', '5')
    >>> it.peek()
    '7'
    >>> next(it)
    '7'

c                     <a a VV VV3R  lpV# )c                    <a  V VVVV3R  lpV# )c                  ^   < S! V / VB p\        S4      pVP                  SV4       S! V/ SB # r   )r!  insert)	r7  r8  resultwrapping_args_fresult_indexwrapping_argswrapping_funcwrapping_kwargss	   *,  r   inner_wrapperOmake_decorator.<locals>.decorator.<locals>.outer_wrapper.<locals>.inner_wrapper  s<    D+F+!%m!4%%lF;$nHHHr   r   )r  r  r  r  r  r  s   f r   outer_wrapper8make_decorator.<locals>.decorator.<locals>.outer_wrapper  s    I I ! r   r   )r  r  r  r  r  s   jl r   	decorator!make_decorator.<locals>.decorator  s    	! 	! r   r   )r  r  r  s   ff r   r   r   P  s    f
 r   c                :   \        \        4      pVf*   V  F"  pV! V4      pWF,          P                  V4       K$  	  M0V  F*  pV! V4      pV! V4      pWF,          P                  V4       K,  	  Ve$   VP                  4        F  w  rhV! V4      WF&   K  	  RVn        V# )aC  Return a dictionary that maps the items in *iterable* to categories
defined by *keyfunc*, transforms them with *valuefunc*, and
then summarizes them by category with *reducefunc*.

*valuefunc* defaults to the identity function if it is unspecified.
If *reducefunc* is unspecified, no summarization takes place:

    >>> keyfunc = lambda x: x.upper()
    >>> result = map_reduce('abbccc', keyfunc)
    >>> sorted(result.items())
    [('A', ['a']), ('B', ['b', 'b']), ('C', ['c', 'c', 'c'])]

Specifying *valuefunc* transforms the categorized items:

    >>> keyfunc = lambda x: x.upper()
    >>> valuefunc = lambda x: 1
    >>> result = map_reduce('abbccc', keyfunc, valuefunc)
    >>> sorted(result.items())
    [('A', [1]), ('B', [1, 1]), ('C', [1, 1, 1])]

Specifying *reducefunc* summarizes the categorized items:

    >>> keyfunc = lambda x: x.upper()
    >>> valuefunc = lambda x: 1
    >>> reducefunc = sum
    >>> result = map_reduce('abbccc', keyfunc, valuefunc, reducefunc)
    >>> sorted(result.items())
    [('A', 1), ('B', 2), ('C', 3)]

You may want to filter the input iterable before applying the map/reduce
procedure:

    >>> all_items = range(30)
    >>> items = [x for x in all_items if 10 <= x <= 20]  # Filter
    >>> keyfunc = lambda x: x % 2  # Evens map to 0; odds to 1
    >>> categories = map_reduce(items, keyfunc=keyfunc)
    >>> sorted(categories.items())
    [(0, [10, 12, 14, 16, 18, 20]), (1, [11, 13, 15, 17, 19])]
    >>> summaries = map_reduce(items, keyfunc=keyfunc, reducefunc=sum)
    >>> sorted(summaries.items())
    [(0, 90), (1, 75)]

Note that all items in the iterable are gathered into a list before the
summarization step, which may require significant storage.

The returned object is a :obj:`collections.defaultdict` with the
``default_factory`` set to ``None``, such that it behaves like a normal
dictionary.

N)r   r!  r  r  default_factory)	r   r+  r%  r)  r   r   r  r  
value_lists	   &&&&     r   r   r     s    h d
CD$-CHOOD! 
 D$-CdOEHOOE" 
 "yy{OC!*-CH  + CJr   c           	        a Vf,    \        V 4      oV3R l\        \        V 4      V4       4       # \        \	        \        WV4      4      4      #   \         d     L+i ; i)a+  Yield the index of each item in *iterable* for which *pred* returns
``True``, starting from the right and moving left.

*pred* defaults to :func:`bool`, which will select truthy items:

    >>> list(rlocate([0, 1, 1, 0, 1, 0, 0]))  # Truthy at 1, 2, and 4
    [4, 2, 1]

Set *pred* to a custom function to, e.g., find the indexes for a particular
item:

    >>> iterator = iter('abcb')
    >>> pred = lambda x: x == 'b'
    >>> list(rlocate(iterator, pred))
    [3, 1]

If *window_size* is given, then the *pred* function will be called with
that many items. This enables searching for sub-sequences:

    >>> iterable = [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]
    >>> pred = lambda *args: args == (1, 2, 3)
    >>> list(rlocate(iterable, pred=pred, window_size=3))
    [9, 5, 1]

Beware, this function won't return anything for infinite iterables.
If *iterable* is reversible, ``rlocate`` will reverse it and search from
the right. Otherwise, it will search from the left and return the results
in reverse order.

See :func:`locate` to for other example applications.

c              3   D   <"   T F  pSV,
          ^,
          x  K  	  R# 5ir  r   )ro  r_  r  s   & r   rq  rlocate.<locals>.<genexpr>  s     O.NHqL1$$.Nr'  )r   r~   r   r   r!  )r   r  rm  r  s   &&&@r   r   r     s^    B 	8}HOfXh5G.NOO D<=>>  		s   )A AAc              #    "   V^8  d   \        R4      h\        V4      p\        V \        \        V^,
          4      4      p\        WT4      p^ pV Fh  pV! V!  '       d2   Ve   Ws8  d(   V^,          pT Rj  xL
  \        Wd^,
          4       K@  V'       g   KJ  V^ ,          \        Jg   K]  V^ ,          x  Kj  	  R#  LF5i)a  Yield the items from *iterable*, replacing the items for which *pred*
returns ``True`` with the items from the iterable *substitutes*.

    >>> iterable = [1, 1, 0, 1, 1, 0, 1, 1]
    >>> pred = lambda x: x == 0
    >>> substitutes = (2, 3)
    >>> list(replace(iterable, pred, substitutes))
    [1, 1, 2, 3, 1, 1, 2, 3, 1, 1]

If *count* is given, the number of replacements will be limited:

    >>> iterable = [1, 1, 0, 1, 1, 0, 1, 1, 0]
    >>> pred = lambda x: x == 0
    >>> substitutes = [None]
    >>> list(replace(iterable, pred, substitutes, count=2))
    [1, 1, None, 1, 1, None, 1, 1, 0]

Use *window_size* to control the number of items passed as arguments to
*pred*. This allows for locating and replacing subsequences.

    >>> iterable = [0, 1, 2, 5, 0, 1, 2, 5]
    >>> window_size = 3
    >>> pred = lambda *args: args == (0, 1, 2)  # 3 items passed to pred
    >>> substitutes = [3, 4] # Splice in these items
    >>> list(replace(iterable, pred, substitutes, window_size=window_size))
    [3, 4, 5, 3, 4, 5]

zwindow_size must be at least 1N)r   r\  r   r   r:   r   r=   )	r   r  substitutesr   rm  rX  windowsr   ws	   &&&&&    r   r   r     s     : Q9:: $K 
xq9	:Br'G	A 8819Q&&&q1 1!A$g%A$J#  's   A5C 7B>8C C -C c              #     "   \        V 4      p\        V4      p\        \        ^V4      4       F5  p\	        RV,           W23,           4       UUu. uF	  w  r4WV NK  	  uppx  K7  	  R# u uppi 5i)zYield all possible order-preserving partitions of *iterable*.

>>> iterable = 'abc'
>>> for part in partitions(iterable):
...     print([''.join(p) for p in part])
['abc']
['a', 'bc']
['ab', 'c']
['a', 'b', 'c']

This is unrelated to :func:`partition`.

Nr'  )r!  r   rB   r]  r?  )r   sequencer   r_  r`  s   &    r   r   r   C  s]      H~HHAeAqk"),TAXq4x)@A)@x!})@AA #As   AA/A)A/c              #  ~  aaa"   \        V 4      p\        V4      pVe   V^8  d   \        R4      hW8  d   R# Se   SM^ oSe   SMToSS8  d   R# V3R loVf<   \        ^V^,           4       F"  p\	        VV3R lS! WA4      4       Rj  xL
  K$  	  R# \	        VV3R lS! WA4      4       Rj  xL
  R#  L+ L5i)aO  
Yield the set partitions of *iterable* into *k* parts. Set partitions are
not order-preserving.

>>> iterable = 'abc'
>>> for part in set_partitions(iterable, 2):
...     print([''.join(p) for p in part])
['a', 'bc']
['ab', 'c']
['b', 'ac']


If *k* is not given, every set partition is generated.

>>> iterable = 'abc'
>>> for part in set_partitions(iterable):
...     print([''.join(p) for p in part])
['abc']
['a', 'bc']
['ab', 'c']
['b', 'ac']
['a', 'b', 'c']

if *min_size* and/or *max_size* are given, the minimum and/or maximum size
per block in partition is set.

>>> iterable = 'abc'
>>> for part in set_partitions(iterable, min_size=2):
...     print([''.join(p) for p in part])
['abc']
>>> for part in set_partitions(iterable, max_size=2):
...     print([''.join(p) for p in part])
['a', 'bc']
['ab', 'c']
['b', 'ac']
['a', 'b', 'c']

Nz6Can't partition in a negative or zero number of groupsc              3   t  <"   \        V 4      pV^8X  d   V .x  R# W!8X  d   V  Uu. uF  q3.NK  	  upx  R# V vrES! WQ^,
          4       F  pV..VOx  K  	  S! WQ4       FK  p\        \        V4      4       F0  pVRV V.Wg,          ,           .,           Wg^,           R ,           x  K2  	  KM  	  R# u upi 5ir  )r   r]  )	r  r~  r   r  r   Mr   r_  set_partitions_helpers	   &&      r   r  -set_partitions.<locals>.set_partitions_helper  s     F6#IV !"13""EA*1!e4siQi 5*10s1vABQ%A3:,.q57;; ' 1 #s   $B8B3BB8c                 |   < \         ;QJ d     VV3R  lV  4       F  '       d   K   R# 	  R# ! VV3R  lV  4       4      # )c              3   b   <"   T F$  pS\        V4      u;8*  ;'       d    S8*  Mu x  K&  	  R # 5ir   r   ro  bkmax_sizemin_sizes   & r   rq  3set_partitions.<locals>.<lambda>.<locals>.<genexpr>  s%     J"h#b'==X==   ,/FTr  r   r  r  s   &r   rU   set_partitions.<locals>.<lambda>  s(    ##JJ##J#J#JJJr   c                 |   < \         ;QJ d     VV3R  lV  4       F  '       d   K   R# 	  R# ! VV3R  lV  4       4      # )c              3   b   <"   T F$  pS\        V4      u;8*  ;'       d    S8*  Mu x  K&  	  R # 5ir   r  r  s   & r   rq  r    s%     FAb(c"g9999Ar  FTr  r  s   &r   rU  r    s(    ccFAFccFcFcFAFFr   )r!  r   r   r]  r  )r   r~  r  r  r  r   r  s   &&ff  @r   r   r   W  s     N 	XAAA}q5H  U#/xQH#/xQH(< 	yq!a%AJ%a+   ! F!!'
 	
 	

	
s$   BB=B9$B=2B;3B=;B=c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )r   i  a	  
Yield items from *iterable* until *limit_seconds* have passed.
If the time limit expires before all items have been yielded, the
``timed_out`` parameter will be set to ``True``.

>>> from time import sleep
>>> def generator():
...     yield 1
...     yield 2
...     sleep(0.2)
...     yield 3
>>> iterable = time_limited(0.1, generator())
>>> list(iterable)
[1, 2]
>>> iterable.timed_out
True

Note that the time is checked before each item is yielded, and iteration
stops if  the time elapsed is greater than *limit_seconds*. If your time
limit is 1 second, but it takes 2 seconds to generate the first item from
the iterable, the function will run for 2 seconds and not yield anything.
As a special case, when *limit_seconds* is zero, the iterator never
returns anything.

c                    V^ 8  d   \        R4      hWn        \        V4      V n        \	        4       V n        RV n        R# )r   zlimit_seconds must be positiveFN)r   limit_secondsr   r~  r9   _start_time	timed_out)r   r   r   s   &&&r   r   time_limited.__init__  s8    1=>>*h$;r   c                    V # r   r   r  s   &r   r  time_limited.__iter__  r  r   c                    V P                   ^ 8X  d   RV n        \        h\        V P                  4      p\        4       V P                  ,
          V P                   8  d   RV n        \        hV# )r   T)r   r  r   r   r~  r9   r  r  s   & r   r  time_limited.__next__  sX    "!DNDNN#;)))D,>,>>!DNr   )r~  r  r   r  N
r+  r,  r-  r.  r/  r   r  r  r0  r1  r2  s   @r   r   r     s     4	 	r   c                    \        V 4      pV F,  pV F!  pRV: RV: R2pT;'       g    \        V4      h	  Vu # 	  V# )a  If *iterable* has only one item, return it.
If it has zero items, return *default*.
If it has more than one item, raise the exception given by *too_long*,
which is ``ValueError`` by default.

>>> only([], default='missing')
'missing'
>>> only([1])
1
>>> only([1, 2])  # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: Expected exactly one item in iterable, but got 1, 2,
 and perhaps more.'
>>> only([1, 2], too_long=TypeError)  # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
TypeError

Note that :func:`only` attempts to advance *iterable* twice to ensure there
is only one item.  See :func:`spy` or :func:`peekable` to check
iterable contents less destructively.

rE  rF  rG  rH  )r   r   rJ  r   rl   rK  rL  s   &&&    r   r   r     s^    2 H~HFA%"*/1  --jo-    Nr   c                 b   aa \        4       o\        W4      oVV3R  lpRVV3R llpV! 4       V3# )c               3      <"   \        \        4      ;_uu_ 4         S '       d   S P                  4       x  K  \        S4      x  K,    + '       g   i     R# ; i5iTN)r   r   r  r   )rw  r   s   r   	generator_ichunk.<locals>.generator  s8     m$$--/)u+% %$$s   A	A#AA		Ac                    < V f   SP                  S4       \        S4      # V \        S4      ,
          pV^ 8  d   SP                  \        SV4      4       \        V \        S4      4      # r   )r  r   r   r  )r   to_cacherw  r   s   & r   materialize_next!_ichunk.<locals>.materialize_next  sZ    9LLu:s5z> a<LLx01 1c%j!!r   r  )r   r   )r   r   r  r  rw  r   s   &&  @@r   _ichunkr    s3    GE8E&" " K)**r   c              #  v   "   \        V 4      p \        W!4      w  r4V! 4       '       g   R# Vx  V! R4       K+  5i)ag  Break *iterable* into sub-iterables with *n* elements each.
:func:`ichunked` is like :func:`chunked`, but it yields iterables
instead of lists.

If the sub-iterables are read in order, the elements of *iterable*
won't be stored in memory.
If they are read out of order, :func:`itertools.tee` is used to cache
elements as necessary.

>>> from itertools import count
>>> all_chunks = ichunked(count(), 4)
>>> c_1, c_2, c_3 = next(all_chunks), next(all_chunks), next(all_chunks)
>>> list(c_2)  # c_1's elements have been cached; c_3's haven't been
[4, 5, 6, 7]
>>> list(c_1)
[0, 1, 2, 3]
>>> list(c_3)
[8, 9, 10, 11]

N)r   r  )r   r   r   r   r  s   &&   r   ro   ro     s=     * H~H
")("6  !! 	s   79c                 V    \        \        \        \        V R\	        4       / 4      4      # )a  Return ``True`` if all given *iterables* are equal to each other,
which means that they contain the same elements in the same order.

The function is useful for comparing iterables of different data types
or iterables that do not support equality checks.

>>> iequals("abc", ['a', 'b', 'c'], ('a', 'b', 'c'), iter("abc"))
True

>>> iequals("abc", "acb")
False

Not to be confused with :func:`all_equal`, which checks whether all
elements of iterable are equal to each other.

r  )r  r   rF   r   objectr  s   *r   rp   rp   A  s"    " s9k9IIJKKr   c           	   #     "   V^ 8  d   \        R4      hV^ 8X  d   Rx  R# \        V 4      p\        \        V4      \	        ^4      R7      .pR.V,          p^ pV'       d    \        VR,          4      w  rgYtT&   T^,           T8X  d   \        T4      x  K>  TP                  \        \        Y&^,           R T^,           4      \	        ^4      R7      4       T^,          pK  R#   \         d    TP                  4        T^,          p K  i ; i5i)a*  Yield the distinct combinations of *r* items taken from *iterable*.

    >>> list(distinct_combinations([0, 0, 1], 2))
    [(0, 0), (0, 1)]

Equivalent to ``set(combinations(iterable))``, except duplicates are not
generated and thrown away. For larger input sequences this is much more
efficient.

zr must be non-negativeNr  r   r   )	r   r\  rE   r  r1   r   r   popr  )r   re  r  
generatorscurrent_combor  cur_idxr   s   &&      r   r`   r`   U  s      	1u122	
a?D!)D/z!}EFJFQJME
	jn-JG
  !e19>&&dQ;=17Q;?"1 QJE#   	NNQJE	s+   AD"C# 6A-D#$DD
DDc              '  V   "   V F  p V ! V4       Vx  K  	  R#   T d     K   i ; i5i)a  Yield the items from *iterable* for which the *validator* function does
not raise one of the specified *exceptions*.

*validator* is called for each item in *iterable*.
It should be a function that accepts one argument and raises an exception
if that item is not valid.

>>> iterable = ['1', '2', 'three', '4', None]
>>> list(filter_except(int, iterable, ValueError, TypeError))
['1', '2', '4']

If an exception other than one given by *exceptions* is raised by
*validator*, it is raised like normal.
Nr   )r  r   
exceptionsr   s   &&* r   rj   rj   }  s7      	dO J   		s   )
)&)&)c              '  R   "   V F  p V ! V4      x  K  	  R#   T d     K  i ; i5i)a  Transform each item from *iterable* with *function* and yield the
result, unless *function* raises one of the specified *exceptions*.

*function* is called to transform each item in *iterable*.
It should accept one argument.

>>> iterable = ['1', '2', 'three', '4', None]
>>> list(map_except(int, iterable, ValueError, TypeError))
[1, 2, 4]

If an exception other than one given by *exceptions* is raised by
*function*, it is raised like normal.
Nr   )functionr   r  r   s   &&* r   r   r     s3      	4.    		s   '
'$'$'c              #     "   Vf&   V  F  pV! V4      '       d	   V! V4      MTx  K  	  R# V  F#  pV! V4      '       d	   V! V4      MV! V4      x  K%  	  R# 5i)a  Evaluate each item from *iterable* using *pred*. If the result is
equivalent to ``True``, transform the item with *func* and yield it.
Otherwise, transform the item with *func_else* and yield it.

*pred*, *func*, and *func_else* should each be functions that accept
one argument. By default, *func_else* is the identity function.

>>> from math import sqrt
>>> iterable = list(range(-5, 5))
>>> iterable
[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]
>>> list(map_if(iterable, lambda x: x > 3, lambda x: 'toobig'))
[-5, -4, -3, -2, -1, 0, 1, 2, 3, 'toobig']
>>> list(map_if(iterable, lambda x: x >= 0,
... lambda x: f'{sqrt(x):.2f}', lambda x: None))
[None, None, None, None, None, '0.00', '1.00', '1.41', '1.73', '2.00']
Nr   )r   r  r:  	func_elser   s   &&&& r   r   r     sO     & D $T

$t*4  D $T

$t*	$? s   AAc           	         \        \        W4      4      pV'       d   \        V4      V8  d   \        R 4      hRp\	        \
        4      ;_uu_ 4         V\        4       ^V,          ,          ,          p\        \        \        4       4      \        V) 4      ,          4      p\        \        WR4      4      pWc\        V4      &   Kq    + '       g   i     M; i\        T4       T# )Sample larger than population      ?N)r!  r   r   r   r   r   r+   r"   r$   r%   r   r,   r-   )r   r~  r   	reservoirWskipr  s   &&&    r   _sample_unweightedr)    s     VH()I#i.1$899A	-	 	 a!e$$AVXr23D6($78G&-il# 
!	  Is   A2CC	c                 T   R  V 4       p\        V\        W@4      4      pV'       d   \        V4      V8  d   \        R4      h\	        V4       V^ ,          w  rg\        \        4       4      V,          p\        W 4       F  w  rW8  do   V^ ,          w  rg\        W,          4      p\        V^4      p\        V4      V	,          p\        W]V
34       V^ ,          w  rg\        \        4       4      V,          pKy  W,          pK  	  V UU
u. uF  w  rV
NK	  	  ppp
\        V4       V# u up
pi )c              3   V   "   T F  p\        \        4       4      V,          x  K!  	  R # 5ir   )r$   r+   )ro  weights   & r   rq  #_sample_weighted.<locals>.<genexpr>  s     @f3vx=6))s   ')r$  )rD   r?  r   r   r   r$   r+   r    r.   r   r-   )r   r~  weightsr   weight_keysr&  smallest_weight_keyr  weights_to_skipr,  r  t_wr_2
weight_keyr   s   &&&&           r   _sample_weightedr5    s   
 A@K QK23I#i.1$899I 'q\&(m&99Ow1$ &/q\"f23C#q/CSF*J	#89%.q\"!&(m.AAO%O 2 /8
8i*z7iC
8CLJ 9s   D$c                 d  a aa	a
 R o	^ o
VV	V V
3R lp\        \        4      ;_uu_ 4        . p\        V4       F  pVP                  V! ^ 4      4       K  	  R R R 4       V'       d   \	        X4      V8  d   \        R4      h\        \        4      ;_uu_ 4        Rp V\        4       ^V,          ,          ,          p\        \        \        4       4      \        V) 4      ,          4      pV! V4      o	S	X\        V4      &   Ke    + '       g   i     L; i  + '       g   i     M; i\        X4       T# )Nc                    < V ^,           S8  d"   V S,
          p \        S4      o\        S4      oK/  SV ^,           ,          oS# r  r6  )r_  r  r  
population	remainings   &r   feed_sample_counted.<locals>.feed  s@     !eiIA:&GVIQU	r   r$  r%  )r   r   r]  r  r   r   r+   r"   r$   r%   r,   r-   )r8  r~  r  r   r:  r&  r  r'  r(  r  r9  s   f&f&     @@r   _sample_countedr<    s    GI	 	 
-	 	 	qAT!W%  
!
 #i.1$899	-	 	 a!e$$AVXr23D4jG&-Iil# 
!	  
!	  Is   ,C?A(D?D	D"	r  r   c                   \        V 4      pV^ 8  d   \        R4      hV^ 8X  d   . # Ve   Ve   \        R4      hVe   \        V4      p\        WQW$4      # Ve   \        V4      p\	        WQW44      # \        WQV4      # )a  Return a *k*-length list of elements chosen (without replacement)
from the *iterable*.

Similar to :func:`random.sample`, but works on inputs that aren't
indexable (such as sets and dictionaries) and on inputs where the
size isn't known in advance (such as generators).

>>> iterable = range(100)
>>> sample(iterable, 5)  # doctest: +SKIP
[81, 60, 96, 16, 4]

For iterables with repeated elements, you may supply *counts* to
indicate the repeats.

>>> iterable = ['a', 'b']
>>> counts = [3, 4]  # Equivalent to 'a', 'a', 'a', 'b', 'b', 'b', 'b'
>>> sample(iterable, k=3, counts=counts)  # doctest: +SKIP
['a', 'a', 'b']

An iterable with *weights* may be given:

>>> iterable = range(100)
>>> weights = (i * i + 1 for i in range(100))
>>> sampled = sample(iterable, 5, weights=weights)  # doctest: +SKIP
[79, 67, 74, 66, 78]

Weighted selections are made without replacement.
After an element is selected, it is removed from the pool and the
relative weights of the other elements increase (this
does not match the behavior of :func:`random.sample`'s *counts*
parameter). Note that *weights* may not be used with *counts*.

If the length of *iterable* is less than *k*,
``ValueError`` is raised if *strict* is ``True`` and
all elements are returned (in shuffled order) if *strict* is ``False``.

By default, the `Algorithm L <https://w.wiki/ANrM>`__ reservoir sampling
technique is used. When *weights* are provided,
`Algorithm A-ExpJ <https://w.wiki/ANrS>`__ is used instead.

Notes on reproducibility:

* The algorithms rely on inexact floating-point functions provided
  by the underlying math library (e.g. ``log``, ``log1p``, and ``pow``).
  Those functions can `produce slightly different results
  <https://members.loria.fr/PZimmermann/papers/accuracy.pdf>`_ on
  different builds.  Accordingly, selections can vary across builds
  even for the same seed.

* The algorithms loop over the input and make selections based on
  ordinal position, so selections from unordered collections (such as
  sets) won't reproduce across sessions on the same platform using the
  same seed.  For example, this won't reproduce::

      >> seed(8675309)
      >> sample(set('abcdefghijklmnopqrstuvwxyz'), 10)
      ['c', 'p', 'e', 'w', 's', 'a', 'j', 'd', 'n', 't']

zk must be non-negativez)weights and counts are mutually exclusive)r   r   r   r5  r<  r)  )r   r~  r.  r  r   r   s   &&&$$ r   r   r   $  s    x H~H1u122Av	v1CDD		w-W==		fxF;; "(v66r   c                    Vf   T M
\        W4      p\        V4      w  rV\        VR4       V'       d   YVrVV'       d   \        \        \        WV4      4      # \        \        \        We4      4      '       * # )a  Returns ``True`` if the items of iterable are in sorted order, and
``False`` otherwise. *key* and *reverse* have the same meaning that they do
in the built-in :func:`sorted` function.

>>> is_sorted(['1', '2', '3', '4', '5'], key=int)
True
>>> is_sorted([5, 4, 3, 1, 2], reverse=True)
False

If *strict*, tests for strict sorting, that is, returns ``False`` if equal
elements are found:

>>> is_sorted([1, 2, 2])
True
>>> is_sorted([1, 2, 2], strict=True)
False

The function returns ``False`` after encountering the first out-of-order
item, which means it may produce results that differ from the built-in
:func:`sorted` function for objects with unusual comparison dynamics
(like ``math.nan``). If there are no out-of-order items, the iterable is
exhausted.
N)r   r   r   r  r2   r  )r   r  r  r   rX  ri  rj  s   &&&&   r   rx   rx   w  sV    0 kC(:Br7DADM1!'3s2q}CSQ]1C-CCr   c                       ] tR tRtRtR# )rH   i  r   N)r+  r,  r-  r.  r0  r   r   r   rH   rH     s    r   c                   l   a  ] tR tRt o RtRR ltR tR tR tR t	]
R 4       t]
R	 4       tR
 tRtV tR# )rQ   i  aU  Convert a function that uses callbacks to an iterator.

Let *func* be a function that takes a `callback` keyword argument.
For example:

>>> def func(callback=None):
...     for i, c in [(1, 'a'), (2, 'b'), (3, 'c')]:
...         if callback:
...             callback(i, c)
...     return 4


Use ``with callback_iter(func)`` to get an iterator over the parameters
that are delivered to the callback.

>>> with callback_iter(func) as it:
...     for args, kwargs in it:
...         print(args)
(1, 'a')
(2, 'b')
(3, 'c')

The function will be called in a background thread. The ``done`` property
indicates whether it has completed execution.

>>> it.done
True

If it completes successfully, its return value will be available
in the ``result`` property.

>>> it.result
4

Notes:

* If the function uses some keyword argument besides ``callback``, supply
  *callback_kwd*.
* If it finished executing, but raised an exception, accessing the
  ``result`` property will raise the same exception.
* If it hasn't finished executing, accessing the ``result``
  property from within the ``with`` block will raise ``RuntimeError``.
* If it hasn't finished executing, accessing the ``result`` property from
  outside the ``with`` block will raise a
  ``more_itertools.AbortThread`` exception.
* Provide *wait_seconds* to adjust how frequently the it is polled for
  output.

c                    Wn         W n        R V n        RV n        W0n        \        R4      P                  P                  ^R7      V n        V P                  4       V n
        R# )FNzconcurrent.futures)max_workers)_func_callback_kwd_aborted_future_wait_seconds
__import__futuresThreadPoolExecutor	_executor_readerr~  )r   r:  callback_kwdwait_secondss   &&&&r   r   callback_iter.__init__  sU    
))# 

'$$$3 	 r   c                    V # r   r   r  s   &r   	__enter__callback_iter.__enter__  r  r   c                H    R V n         V P                  P                  4        R# r  )rE  rK  shutdown)r   exc_type	exc_value	tracebacks   &&&&r   __exit__callback_iter.__exit__  s    !r   c                    V # r   r   r  s   &r   r  callback_iter.__iter__  r  r   c                ,    \        V P                  4      # r   r  r  s   &r   r  callback_iter.__next__  r  r   c                V    V P                   f   R# V P                   P                  4       # )NF)rF  doner  s   &r   r_  callback_iter.done  s"    <<||  ""r   c                p    V P                   '       g   \        R 4      hV P                  P                  4       # )zFunction has not yet completed)r_  RuntimeErrorrF  r  r  s   &r   r  callback_iter.result  s*    yyy?@@||""$$r   c              #  6  a a"   \        4       oVV 3R  lpS P                  P                  ! S P                  3/ S P                  V/B S n          SP                  S P                  R7      pSP                  4        Vx  S P
                  P                  4       '       g   KT   . p  SP                  4       pSP                  4        TP                  T4       K5    \         d     Lgi ; i  \         d     Mi ; iSP                  4        T Rj  xL 
  R# 5i)c                  f   < SP                   '       d   \        R 4      hSP                  W34       R# )zcanceled by userN)rE  rH   put)r7  r8  r   r   s   *,r   callback'callback_iter._reader.<locals>.callback  s&    }}}!"455EE4.!r   )timeoutN)r*   rK  submitrC  rD  rF  getrG  	task_doner)   r_  
get_nowaitr  join)r   rg  r   r9  r   s   f   @r   rL  callback_iter._reader  s     G	" ~~,,JJ
--x8
 uuT%7%7u8 
||  ""	'||~   &#    
 	
s`   ADC ,1D"D'C+ 7#DC(%D'C((D+C96D8C99DDD)rE  rD  rK  rC  rF  r~  rG  N)rg  g?)r+  r,  r-  r.  r/  r   rQ  rX  r  r  propertyr_  r  rL  r0  r1  r2  s   @r   rQ   rQ     sV     0d
("$ # #
 % %# #r   c              #     "   V^ 8  d   \        R4      h\        V 4      p\        V4      pW8  d   \        R4      h\        W1,
          ^,           4       F#  pVRV pW$WA,            pW$V,           R pWVV3x  K%  	  R# 5i)a  
Yield ``(beginning, middle, end)`` tuples, where:

* Each ``middle`` has *n* items from *iterable*
* Each ``beginning`` has the items before the ones in ``middle``
* Each ``end`` has the items after the ones in ``middle``

>>> iterable = range(7)
>>> n = 3
>>> for beginning, middle, end in windowed_complete(iterable, n):
...     print(beginning, middle, end)
() (0, 1, 2) (3, 4, 5, 6)
(0,) (1, 2, 3) (4, 5, 6)
(0, 1) (2, 3, 4) (5, 6)
(0, 1, 2) (3, 4, 5) (6,)
(0, 1, 2, 3) (4, 5, 6) ()

Note that *n* must be at least 0 and most equal to the length of
*iterable*.

This function will exhaust the iterable and may require significant
storage.
r  zn must be <= len(seq)N)r   r\  r   r]  )r   r   r  ra  r_  	beginningmiddleends   &&      r   r   r     s     0 	1u)**
/Cs8Dx01148a< G	a%'l$$	 !s   A;A=c                    \        4       pVP                  p. pVP                  pV'       d   \        W4      MT  F  p Wb9   d    R# V! V4       K  	  R#   \         d    Yd9   d     R# T! T4        K;  i ; i)a  
Returns ``True`` if all the elements of *iterable* are unique (no two
elements are equal).

    >>> all_unique('ABCB')
    False

If a *key* function is specified, it will be used to make comparisons.

    >>> all_unique('ABCb')
    True
    >>> all_unique('ABCb', str.lower)
    False

The function returns as soon as the first non-unique element is
encountered. Iterables with a mix of hashable and unhashable items can
be used, but the function will be slower for unhashable items.
FT)r  addr  r   r   )r   r  seensetseenset_addseenlistseenlist_addr  s   &&     r   rK   rK   B  su    & eG++KH??L),3s%(:	"! 	 ; 	  	""!	"s   AAA6*A65A6c                   \        \        \        \        V4      4      4      p\        \        \        V4      4      p\        \        V4      pV ^ 8  d	   W,          p ^ T u;8:  d   V8  g    \        h \        h. p\        W#4       F+  w  rgVP                  W`V,          ,          4       W,          p K-  	  \        \        V4      4      # )ae  Equivalent to ``list(product(*args))[index]``.

The products of *args* can be ordered lexicographically.
:func:`nth_product` computes the product at sort position *index* without
computing the previous products.

    >>> nth_product(8, range(2), range(2), range(2), range(2))
    (1, 0, 0, 0)

``IndexError`` will be raised if the given *index* is invalid.
)
r!  r   r\  r   r   r   r3   r   r?  r  )r"  r7  poolsnsrq  r  r  r   s   &*      r   r   r   e  s     UHTN+,E	c#uo	BsBAqy
>> Fu>d19o& " &!""r   c                N   \        V 4      p\        V4      pVe   W8X  d   T\        V4      rQM(^ Tu;8:  d   V8  g    \        h \        h\	        WA4      pV^ 8  g   Q hV^ 8  d	   W%,          p^ Tu;8:  d   V8  g    \
        h \
        h^ .V,          pW8  d   V\        V4      ,          V,          MTp\        ^V^,           4       F;  p\        Wx4      w  ry^ WH,
          u;8:  d   V8  d   M M
WWH,
          &   V^ 8X  g   K;   M	  \        \        VP                  V4      4      # )a  Equivalent to ``list(permutations(iterable, r))[index]```

The subsequences of *iterable* that are of length *r* where order is
important can be ordered lexicographically. :func:`nth_permutation`
computes the subsequence at sort position *index* directly, without
computing the previous subsequences.

    >>> nth_permutation('ghijk', 2, 5)
    ('h', 'i')

``ValueError`` will be raised If *r* is negative or greater than the length
of *iterable*.
``IndexError`` will be raised if the given *index* is invalid.
)r!  r   r!   r   r&   r   r]  r  r\  r   r  )
r   re  r"  r  r   rq  r  r   dr_  s
   &&&       r   r   r     s     >DD	AyAF)A,1!ZaZ Jq5L5qy
>> S1WF%&U	!!A1a!e_a|>>15M6  TXXv&''r   c                   \        V 4      p\        V4      pV^ 8  g   W8  d   \        h\        WA,           ^,
          V4      pV^ 8  d	   W%,          pV^ 8  g   W%8  d   \        h. p^ pV'       df   V^,          pV^ 8  d=   \        WA,           ^,
          V4      pW(8  d   MV^,          pV^,          pW(,          pKC  VP                  W7,          4       Km  \        V4      # )a;  Equivalent to
``list(combinations_with_replacement(iterable, r))[index]``.


The subsequences with repetition of *iterable* that are of length *r* can
be ordered lexicographically. :func:`nth_combination_with_replacement`
computes the subsequence at sort position *index* directly, without
computing the previous subsequences with replacement.

    >>> nth_combination_with_replacement(range(5), 3, 5)
    (0, 1, 1)

``ValueError`` will be raised If *r* is negative or greater than the length
of *iterable*.
``IndexError`` will be raised if the given *index* is invalid.
)r\  r   r   r   r   r  )	r   re  r"  r  r   rq  r  r_  	num_combss	   &&&      r   r   r     s    " ?DD	A	A15QUQYAqy
	uzF	A
	Q1fQUQY*I FAFAEdg=r   c               '     "   V  F0  p\        V\        \        34      '       d   Vx  K%   T Rj  xL
  K2  	  R#  L
  \         d	    Tx   KJ  i ; i5i)aj  Yield all arguments passed to the function in the same order in which
they were passed. If an argument itself is iterable then iterate over its
values.

    >>> list(value_chain(1, 2, 3, [4, 5, 6]))
    [1, 2, 3, 4, 5, 6]

Binary and text strings are not considered iterable and are emitted
as-is:

    >>> list(value_chain('12', '34', ['56', '78']))
    ['12', '34', '56', '78']

Pre- or postpend a single element to an iterable:

    >>> list(value_chain(1, [2, 3, 4, 5, 6]))
    [1, 2, 3, 4, 5, 6]
    >>> list(value_chain([1, 2, 3, 4, 5], 6))
    [1, 2, 3, 4, 5, 6]

Multiple levels of nesting are not flattened.

N)r   r  r  r   )r7  r  s   * r   r   r     sP     0 ec5\**K	 
  	K	s1   (A=;=A=AAAAc                    ^ p\        W\        R7       FW  w  r4V\        J g   V\        J d   \        R4      h\        V4      pV\	        V4      ,          VP                  V4      ,           pKY  	  V# )af  Equivalent to ``list(product(*args)).index(element)``

The products of *args* can be ordered lexicographically.
:func:`product_index` computes the first index of *element* without
computing the previous products.

    >>> product_index([8, 2], range(10), range(5))
    42

``ValueError`` will be raised if the given *element* isn't in the product
of *args*.
rl  z element is not a product of args)r   r:   r   r\  r   r"  )r  r7  r"  r   r  s   &*   r   r   r      sa     Ew@<47??@@T{D	!DJJqM1 A Lr   c                   \        V 4      p \        V R4      w  r#Vf   ^ # . p\        V4      pV F4  w  rgWs8X  g   K  VP                  V4       \        V R4      w  rVf    MTpK6  	  \        R4      h\	        WVR3R7      w  ri^p
\        \        V4      ^R7       F'  w  rWl,
          pW8:  g   K  V
\        W4      ,          p
K)  	  \        V^,           V^,           4      V
,
          # )a  Equivalent to ``list(combinations(iterable, r)).index(element)``

The subsequences of *iterable* that are of length *r* can be ordered
lexicographically. :func:`combination_index` computes the index of the
first *element*, without computing the previous combinations.

    >>> combination_index('adf', 'abcdefg')
    10

``ValueError`` will be raised if the given *element* isn't one of the
combinations of *iterable*.
Nz(element is not a combination of iterabler   )r  NN)r  r   r  r   r}   r   r   )r  r   r~  r   indexesr  r   r   tmpr  r"  r_  r`  s   &&           r   rV   rV     s      G&DAyGXD6NN1'<0FC{  CDD$i(DA E(7+15E6T!ZE 6
 Aq1u%%r   c                l   \        V 4      p \        V 4      p\        V 4      p \        V R4      w  r4Vf   ^ # . p\        V4      p\        V4       F9  w  rxW8X  d)   VP	                  V4       \        V R4      w  rV	f   MT	pK.  Ve   K9   M	  \        R4      h\        V4      p^ .V,          p
V F  pW;;,          ^,          uu&   K  	  ^ p^ p\        ^V4       FX  pWV^,
          ,          ,          pW',           ^,
          V,
          V,
          pWs,
          pW8:  g   KF  V\        W4      ,          pKZ  	  V# )a  Equivalent to
``list(combinations_with_replacement(iterable, r)).index(element)``

The subsequences with repetition of *iterable* that are of length *r* can
be ordered lexicographically. :func:`combination_with_replacement_index`
computes the index of the first *element*, without computing the previous
combinations with replacement.

    >>> combination_with_replacement_index('adf', 'abcdefg')
    20

``ValueError`` will be raised if the given *element* isn't one of the
combinations with replacement of *iterable*.
z9element is not a combination with replacement of iterabler  )r\  r   r  r   r  r   r]  r   )r  r   lr~  r   r  r  r   r   r  occupationsr   r"  cumulative_sumr`  r_  s   &&              r   rW   rW   D  s(    GnGGA G&DAyG?D$fNN1'<0FC{9   G
 	
 	D	A#'K!  EN1a[a!e,,EAIMN*E6T!ZE  Lr   c                    ^ p\        V4      p\        \        \        V4      RR4      V 4       F'  w  rEVP	                  V4      pW$,          V,           pW6 K)  	  V# )a  Equivalent to ``list(permutations(iterable, r)).index(element)```

The subsequences of *iterable* that are of length *r* where order is
important can be ordered lexicographically. :func:`permutation_index`
computes the index of the first *element* directly, without computing
the previous permutations.

    >>> permutation_index([1, 3, 2], range(5))
    19

``ValueError`` will be raised if the given *element* isn't one of the
permutations of *iterable*.
r   )r!  r?  r]  r   r"  )r  r   r"  r  r_  r   re  s   &&     r   r   r   }  sV     E>DE#d)R,g6JJqM	AG 7
 Lr   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )r\   i  a  Wrap *iterable* and keep a count of how many items have been consumed.

The ``items_seen`` attribute starts at ``0`` and increments as the iterable
is consumed:

    >>> iterable = map(str, range(10))
    >>> it = countable(iterable)
    >>> it.items_seen
    0
    >>> next(it), next(it)
    ('0', '1')
    >>> list(it)
    ['2', '3', '4', '5', '6', '7', '8', '9']
    >>> it.items_seen
    10
c                4    \        V4      V n        ^ V n        R# rp  )r   r~  
items_seenr   s   &&r   r   countable.__init__  s    hr   c                    V # r   r   r  s   &r   r  countable.__iter__  r  r   c                b    \        V P                  4      pV ;P                  ^,          un        V# r  )r   r~  r  r  s   & r   r  countable.__next__  s#    DNN#1r   )r~  r  Nr  r2  s   @r   r\   r\     s     " r   c              #  b  "   \        V 4      pV^,
          V^,
          ,          p\        \        W#4      4      p\        \        VP                  V4      VRV4       F  pVRV x  VRV1 K  	  V'       g   R# \        V4      p\        Wa4      w  rxYx^ 8  d   ^M^ ,           p	\        Wi4      w  rxYx^ 8  d   ^M^ ,           p
V
^,
          pWkV	,          ,
          pW,          pV
^ 8  d    \        ^ W4       F  pWNW,            x  K  	  V^ 8  d"   \        WV4       F  pWNW,            x  K  	  R# R# 5i)ae  Break *iterable* into lists of approximately length *n*.
Items are distributed such the lengths of the lists differ by at most
1 item.

>>> iterable = [1, 2, 3, 4, 5, 6, 7]
>>> n = 3
>>> list(chunked_even(iterable, n))  # List lengths: 3, 2, 2
[[1, 2, 3], [4, 5], [6, 7]]
>>> list(chunked(iterable, n))  # List lengths: 3, 3, 1
[[1, 2, 3], [4, 5, 6], [7]]

N)r   r!  r   r   r  r   r  r]  )r   r   r   
min_bufferr  r  lengthr   re  	num_lists	full_sizepartial_sizenum_fullpartial_start_idxr_  s   &&             r   rS   rS     s.     H~H a%AE"J&./F Cx0!T1=Raj2A2J >
 [F &DAa%QQ'I&$DAa%QQ'Iq=Ly00H !,1}q+7AQ]++ 8 a(,?AQ-.. @ s   A3D/6B9D/scalar_typesc              '    a "   V 3R lp\        V4      pV'       g   R# R.V,          p. . rv\        V4       FD  w  rV! V	4      '       d   WV&   K  VP                  \        V	4      4       VP                  V4       KF  	  V'       g   \	        V4      x  R# V'       d   \
        M\        p
V
! V!   F'  p\        W{4       F  w  qV&   K
  	  \	        V4      x  K)  	  R# 5i)a  A version of :func:`zip` that "broadcasts" any scalar
(i.e., non-iterable) items into output tuples.

>>> iterable_1 = [1, 2, 3]
>>> iterable_2 = ['a', 'b', 'c']
>>> scalar = '_'
>>> list(zip_broadcast(iterable_1, iterable_2, scalar))
[(1, 'a', '_'), (2, 'b', '_'), (3, 'c', '_')]

The *scalar_types* keyword argument determines what types are considered
scalar. It is set to ``(str, bytes)`` by default. Set it to ``None`` to
treat strings and byte strings as iterable:

>>> list(zip_broadcast('abc', 0, 'xyz', scalar_types=None))
[('a', 0, 'x'), ('b', 0, 'y'), ('c', 0, 'z')]

If the *strict* keyword argument is ``True``, then
``UnequalIterablesError`` will be raised if any of the iterables have
different lengths.
c                 |   < S'       d   \        V S4      '       d   R #  \        V 4       R#   \         d     R # i ; i)TF)r   r   r   )r  r  s   &r   	is_scalar zip_broadcast.<locals>.is_scalar  s:    JsL99	I   		s   , ;;N)r   r  r  r   r\  r;   r?  )r  r   objectsr  ra  new_itemr  iterable_positionsr_  r  r  r   s   d$*         r   r   r     s     , w<Dv}H$&!G$S>>QKT#Y'%%a( % Gn!ZsF	"!"4;NA{ <Ho #s   BCC?Cc              #  ~  "   V^ 8:  d   \        R4      h\        VR7      p\        \        4      pVRJpV  F  p\	        V4      V8X  d.   V^ ,          pWG,          ^8X  d   WG MWG;;,          ^,          uu&   V'       d	   V! V4      MTpW9  d   Vx  WH;;,          ^,          uu&   VP                  V4       K  	  R# 5i)a  Yield the items from *iterable* that haven't been seen recently.
*n* is the size of the lookback window.

    >>> iterable = [0, 1, 0, 2, 3, 0]
    >>> n = 3
    >>> list(unique_in_window(iterable, n))
    [0, 1, 2, 3, 0]

The *key* function, if provided, will be used to determine uniqueness:

    >>> list(unique_in_window('abAcda', 3, key=lambda x: x.lower()))
    ['a', 'b', 'c', 'd', 'a']

The items in *iterable* must be hashable.

zn must be greater than 0r   N)r   r   r   rE  r   r  )	r   r   r  r  r  use_keyr   
to_discardr~  s	   &&&      r   r   r     s     " 	Av344!_FFoGv;!J!Q&&"a'" CId?J	Q	a s   A;B=>?B=c              #     "   \        4       p. pVRJpV  F3  pV'       d	   V! V4      MTp Wb9  d   VP                  V4       K/  Vx  K5  	  R#   \         d#    Yc9  d   TP                  T4        K^  Tx   Ke  i ; i5i)a_  Yield duplicate elements after their first appearance.

>>> list(duplicates_everseen('mississippi'))
['s', 'i', 's', 's', 'i', 'p', 'i']
>>> list(duplicates_everseen('AaaBbbCccAaa', str.lower))
['a', 'a', 'b', 'b', 'c', 'c', 'A', 'a', 'a']

This function is analogous to :func:`unique_everseen` and is subject to
the same performance considerations.

N)r  rv  r   r  )r   r  seen_set	seen_listr  r  r~  s   &&     r   re   re   F  sw      uHIoG#CL		 Q   	!  #		s@   (A>AA>AA>"A;0A>3A;7A>:A;;A>c                8    \        R \        W4       4       4      # )a  Yields serially-duplicate elements after their first appearance.

>>> list(duplicates_justseen('mississippi'))
['s', 's', 'p']
>>> list(duplicates_justseen('AaaBbbCccAaa', str.lower))
['a', 'a', 'b', 'b', 'c', 'c', 'a', 'a']

This function is analogous to :func:`unique_justseen`.

c              3   :   "   T F  w  rV F  qx  K  	  K  	  R # 5ir   r   )ro  r  r$  s   &  r   rq  &duplicates_justseen.<locals>.<genexpr>o  s     C!7A11!7s   )r?   r   r   r  s   &&r   rf   rf   d  s     C!7CCCr   c              #  @  "   \        4       p. pVRJpRp\        V 4       FN  w  rgV'       d	   V! V4      MTpV'       * ;'       g    WX8g  p	TpRp
 W9  d   VP                  V4       Rp
YyT
3x  KP  	  R#   \         d    Y9  d   TP	                  T4       Rp
 L2i ; i5i)a  Classify each element in terms of its uniqueness.

For each element in the input iterable, return a 3-tuple consisting of:

1. The element itself
2. ``False`` if the element is equal to the one preceding it in the input,
   ``True`` otherwise (i.e. the equivalent of :func:`unique_justseen`)
3. ``False`` if this element has been seen anywhere in the input before,
   ``True`` otherwise (i.e. the equivalent of :func:`unique_everseen`)

>>> list(classify_unique('otto'))    # doctest: +NORMALIZE_WHITESPACE
[('o', True,  True),
 ('t', True,  True),
 ('t', False, False),
 ('o', True,  False)]

This function is analogous to :func:`unique_everseen` and is subject to
the same performance considerations.

NFT)r  r  rv  r   r  )r   r  r  r  r  previousr_  r  r~  is_unique_justseenis_unique_everseens   &&         r   rg   rg   r  s     * uHIoGH)
#CL!"U33hm"	* Q%)"
 +=== *  	*!  #%)"	*s0   AB	BA4(B4$BBBBr  r   c                  V'       d   V .VO5MT p\        V4      p \        V4      ;rgTf4   \        YUTR7       F  w  rY8  d   YrY8  d   T	pYz8  g   K  T
pK!  	  Yg3# T! T4      ;r\        YUTR7       F3  w  rT! T	4      T! T
4      rY8  d   YY3w  rrY8  d   YrY8  g   K1  YrK5  	  Yg3#   \         d#   pT\        J d   \	        R4      ThTu Rp?# Rp?ii ; i)a  Returns both the smallest and largest items from an iterable
or from two or more arguments.

    >>> minmax([3, 1, 5])
    (1, 5)

    >>> minmax(4, 2, 6)
    (2, 6)

If a *key* function is provided, it will be used to transform the input
items for comparison.

    >>> minmax([5, 30], key=str)  # '30' sorts before '5'
    (30, 5)

If a *default* value is provided, it will be returned if there are no
input items.

    >>> minmax([], default=(0, 0))
    (0, 0)

Otherwise ``ValueError`` is raised.

This function makes a single pass over the input elements and takes care to
minimize the number of comparisons made during processing.

Note that unlike the builtin ``max`` function, which always returns the first
item with the maximum value, this function may return another item when there are
ties.

This function is based on the
`recipe <https://code.activestate.com/recipes/577916-fast-minmax-function>`__ by
Raymond Hettinger.
z[`minmax()` argument is an empty iterable. Provide a `default` value to suppress this error.Nrl  )r   r   r   r:   r   r   )iterable_or_valuer  r   othersr   rX  r   r   excr   r   lo_keyhi_keyx_keyy_keys   &$$*           r   r   r     s   F 06!+F+;LH	hBr( {"5DAu1vv 6* 6M b'!"5DAq63q65}%&5%7"e~F~F 6 6MC  gD  s   B0 0C;CCCTc              #    "   V^ 8:  d   \        R4      h. p^ p^ pV  F  pV! V4      p	V'       d   W8  d   \        R4      hWr8H  p
W,           V8  pV'       d2   V'       g	   V
'       d"   \        V4      x  VP                  4        ^ p^ pVP                  V4       Wi,          pV^,          pK  	  V'       d   \        V4      x  R# R# 5i)a
  Yield batches of items from *iterable* with a combined size limited by
*max_size*.

>>> iterable = [b'12345', b'123', b'12345678', b'1', b'1', b'12', b'1']
>>> list(constrained_batches(iterable, 10))
[(b'12345', b'123'), (b'12345678', b'1', b'1'), (b'12', b'1')]

If a *max_count* is supplied, the number of items per batch is also
limited:

>>> iterable = [b'12345', b'123', b'12345678', b'1', b'1', b'12', b'1']
>>> list(constrained_batches(iterable, 10, max_count = 2))
[(b'12345', b'123'), (b'12345678', b'1'), (b'1', b'12'), (b'1',)]

If a *get_len* function is supplied, use that instead of :func:`len` to
determine item size.

If *strict* is ``True``, raise ``ValueError`` if any single item is bigger
than *max_size*. Otherwise, allow single items to exceed *max_size*.
z&maximum size must be greater than zerozitem size exceeds maximum sizeN)r   r\  rv  r  )r   r  	max_countget_lenr   batch
batch_sizebatch_countr   item_lenreached_countreached_sizes   &&&&&       r   rY   rY     s     . 1}ABBEJK4=h)=>>#0,x7LM,KKMJKT
q " El s   AC C(AC7Cc               '    aa"   \         ;QJ d    . R V  4       F  NK  	  5M! R V  4       4      o\        S4      pS F  p\        V4      ^8  g   K  \        R4      h	  ^ .V,          o\        \	        V^,           4      4      p^.V,          p \         ;QJ d!    . VV3R l\	        V4       4       F  NK  	  5M! VV3R l\	        V4       4       4      x  V^ ,          p^ V^ &   WQ8X  d   R# SV,          WE,          ,           SV&   SV,          ^ 8X  g(   SV,          \        SV,          4      ^,
          8X  g   K  WE,          ) WE&   W5^,           ,          W5&   V^,           W5^,           &   K  5i)a:  Like :func:`itertools.product`, but return tuples in an order such
that only one element in the generated tuple changes from one iteration
to the next.

    >>> list(gray_product('AB','CD'))
    [('A', 'C'), ('B', 'C'), ('B', 'D'), ('A', 'D')]

This function consumes all of the input iterables before producing output.
If any of the input iterables have fewer than two items, ``ValueError``
is raised.

For information on the algorithm, see
`this section <https://www-cs-faculty.stanford.edu/~knuth/fasc2a.ps.gz>`__
of Donald Knuth's *The Art of Computer Programming*.
c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   rs  )ro  r   s   & r   rq  gray_product.<locals>.<genexpr>+  s     6Iq%((Is   z)each iterable must have two or more itemsc              3   R   <"   T F  pSV,          SV,          ,          x  K  	  R # 5ir   r   )ro  r_  ri  all_iterabless   & r   rq  r  9  s$     J4IqM!$QqT**4Is   $'N)r\  r   r   r!  r]  )r  iterable_countr   r  or`  ri  r  s   *     @@r   rm   rm     s&      E6I6EE6I66M'N!x=1HII " 
nAU>A%&'A	
nA
eJE.4IJeeJE.4IJJJaD!tad{!Q419!M!$4 5 99D5ADU8AD1uA!eHs   A
E,AE,BE,<0E,c               '    "   \        \        \        V 4      4      p V Uu. uF  p\        V4      NK  	  pp\        T4      x  \        T4       F  w  rBT F  Y4&   \        T4      x  K  	  K  	  R# u upi   \         d     R# i ; i5i)a  Yields tuples containing one item from each iterator, with subsequent
tuples changing a single item at a time by advancing each iterator until it
is exhausted. This sequence guarantees every value in each iterable is
output at least once without generating all possible combinations.

This may be useful, for example, when testing an expensive function.

    >>> list(partial_product('AB', 'C', 'DEF'))
    [('A', 'C', 'D'), ('B', 'C', 'D'), ('B', 'C', 'E'), ('B', 'C', 'F')]
N)r!  r   r   r   r   r\  r  )r  r  rX  prodr_  s   *    r   r   r   E  s~      Sy)*I#,-9RR9- +9%DG+  & . s7   B	A7 A2A7 ;B	2A7 7BB	BB	c              #  J   "   V F  pVx  V ! V4      '       d   K   R# 	  R# 5i)zA variant of :func:`takewhile` that yields one additional element.

    >>> list(takewhile_inclusive(lambda x: x < 5, [1, 4, 6, 4, 1]))
    [1, 4, 6]

:func:`takewhile` would return ``[1, 4]``.
Nr   )r  r   r   s   && r   r   r   ^  s"      || s   ##c           	     |   a aa \        V4      p\        \        VV V3R l\        W4      4      \	        V4      R7      # )as  A generalized outer product that applies a binary function to all
pairs of items. Returns a 2D matrix with ``len(xs)`` rows and ``len(ys)``
columns.
Also accepts ``*args`` and ``**kwargs`` that are passed to ``func``.

Multiplication table:

>>> list(outer_product(mul, range(1, 4), range(1, 6)))
[(1, 2, 3, 4, 5), (2, 4, 6, 8, 10), (3, 6, 9, 12, 15)]

Cross tabulation:

>>> xs = ['A', 'B', 'A', 'A', 'B', 'B', 'A', 'A', 'B', 'B']
>>> ys = ['X', 'X', 'X', 'Y', 'Z', 'Z', 'Y', 'Y', 'Z', 'Z']
>>> pair_counts = Counter(zip(xs, ys))
>>> count_rows = lambda x, y: pair_counts[x, y]
>>> list(outer_product(count_rows, sorted(set(xs)), sorted(set(ys))))
[(2, 3, 0), (1, 0, 4)]

Usage with ``*args`` and ``**kwargs``:

>>> animals = ['cat', 'wolf', 'mouse']
>>> list(outer_product(min, animals, animals, key=len))
[('cat', 'cat', 'cat'), ('cat', 'wolf', 'wolf'), ('cat', 'wolf', 'mouse')]
c                    < S! W.SO5/ SB # r   r   )r   r   r7  r:  r8  s   &&r   rU  outer_product.<locals>.<lambda>  s    T!888r   )r   )r\  rG   r   r   r   )r:  r  r  r7  r8  s   f&&jlr   r   r   l  s1    4 
rB8'"/J
b' r   c              '  D   "    T  Rj  xL
  R#  L  T d     R# i ; i5i)a  Yield each of the items from *iterable*. If the iteration raises one of
the specified *exceptions*, that exception will be suppressed and iteration
will stop.

>>> from itertools import chain
>>> def breaks_at_five(x):
...     while True:
...         if x >= 5:
...             raise RuntimeError
...         yield x
...         x += 1
>>> it_1 = iter_suppress(breaks_at_five(1), RuntimeError)
>>> it_2 = iter_suppress(breaks_at_five(2), RuntimeError)
>>> list(chain(it_1, it_2))
[1, 2, 3, 4, 2, 3, 4]
Nr   )r   r  s   &*r   r{   r{     s$     " s(          c              #  D   "   V F  pV ! V4      pVf   K  Vx  K  	  R# 5i)zApply *func* to every element of *iterable*, yielding only those which
are not ``None``.

>>> elems = ['1', 'a', '2', 'b', '3']
>>> list(filter_map(lambda s: int(s) if s.isnumeric() else None, elems))
[1, 2, 3]
Nr   )r:  r   r   r   s   &&  r   rk   rk     s$      G=G s    
 c           
        a \        \        P                  \        \        \        V 4      4      4      4      o\        P                  ! V3R l\        \        S4      ^,           4       4       4      # )a\  Yields all possible subsets of the iterable.

    >>> list(powerset_of_sets([1, 2, 3]))  # doctest: +SKIP
    [set(), {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}]
    >>> list(powerset_of_sets([1, 1, 0]))  # doctest: +SKIP
    [set(), {1}, {0}, {0, 1}]

:func:`powerset_of_sets` takes care to minimize the number
of hash operations performed.
c              3   t   <"   T F-  p\        \        4       P                  \        SV4      4      x  K/  	  R # 5ir   )r   r  unionr   )ro  re  setss   & r   rq  #powerset_of_sets.<locals>.<genexpr>  s/      %A 	\$233%s   58)
r\  dictfromkeysr   	frozensetr?  r   r   r]  r   )r   r  s   &@r   r   r     sP     s9c(m<=>D s4y1}%  r   c                     \        \        4      pV P                  4        F)  w  r#VP                  4        F  w  rEWQV,          V&   K  	  K+  	  \        V4      # )a  
Joins multiple mappings together using their common keys.

>>> user_scores = {'elliot': 50, 'claris': 60}
>>> user_times = {'elliot': 30, 'claris': 40}
>>> join_mappings(score=user_scores, time=user_times)
{'elliot': {'score': 50, 'time': 30}, 'claris': {'score': 60, 'time': 40}}
)r   r  r  )field_to_mapr   
field_namemappingr  r  s   ,     r   r|   r|     sN     d
C+113
!--/JC#(HZ  *  4 9r   c           
     v   \        R4      p\        R4      p\        \        W 4      \        \        \        W04      4      4      p\        \        W!4      \        W14      4      p\        \        W 4      \        W04      4      p\        \        W14      \        W!4      4      p\	        \        WE4      \        Wg4      4      # )zTHigh precision sumprod() for complex numbers.
Used by :func:`dft` and :func:`idft`.
realimag)r/   r   r   r4   complexr   )v1v2r  r  r1r2r  r  s   &&      r   _complex_sumprodr    s    
 fDfD	s4}c#s4}5	6B	s4}c$m	,B	s4}c$m	,B	s4}c$m	,B9R$i&788r   c              #  J  "   \        V 4      p\        V4       Uu. uF(  p\        W!,          \        ,          R,          ,          NK*  	  pp\        V4       F=  p\        V4       Uu. uF  q#WB,          V,          ,          NK  	  pp\	        W4      x  K?  	  R# u upi u upi 5i)aI  Discrete Fourier Transform. *xarr* is a sequence of complex numbers.
Yields the components of the corresponding transformed output vector.

>>> import cmath
>>> xarr = [1, 2-1j, -1j, -1+2j]  # time domain
>>> Xarr = [2, -2-2j, -2j, 4+4j]  # frequency domain
>>> magnitudes, phases = zip(*map(cmath.polar, Xarr))
>>> all(map(cmath.isclose, dft(xarr), Xarr))
True

Inputs are restricted to numeric types that can add and multiply
with a complex number.  This includes int, float, complex, and
Fraction, but excludes Decimal.

See :func:`idft` for the inverse Discrete Fourier Transform.
Ny             r   r]  r   r'   r  )xarrNr   roots_of_unityr~  coeffss   &     r   r^   r^     s     " 	D	A8=aA1aAECK#-..NA1X5:1X>X++X>t,,  B>s   B#.B	B#&BB#c              #  X  "   \        V 4      p\        V4       Uu. uF(  p\        W!,          \        ,          R,          ,          NK*  	  pp\        V4       FD  p\        V4       Uu. uF  q#WB,          V,          ,          NK  	  pp\	        W4      V,          x  KF  	  R# u upi u upi 5i)a  Inverse Discrete Fourier Transform. *Xarr* is a sequence of
complex numbers. Yields the components of the corresponding
inverse-transformed output vector.

>>> import cmath
>>> xarr = [1, 2-1j, -1j, -1+2j]  # time domain
>>> Xarr = [2, -2-2j, -2j, 4+4j]  # frequency domain
>>> all(map(cmath.isclose, idft(Xarr), xarr))
True

Inputs are restricted to numeric types that can add and multiply
with a complex number.  This includes int, float, complex, and
Fraction, but excludes Decimal.

See :func:`dft` for the Discrete Fourier Transform.
y              ?Nr  )Xarrr  r   r  r~  r  s   &     r   rq   rq     s     " 	D	A7<Qx@x!aAECK",--xN@1X5:1X>X++X>t,q00  A>s   B*.B 	B*&B%&B*c              #  4   "   V F  pV ! R/ VB x  K  	  R# 5i)a  Apply *func* to every item of *iterable* by dictionary unpacking
the item into *func*.

The difference between :func:`itertools.starmap` and :func:`doublestarmap`
parallels the distinction between ``func(*a)`` and ``func(**a)``.

>>> iterable = [{'a': 1, 'b': 2}, {'a': 40, 'b': 60}]
>>> list(doublestarmap(lambda a, b: a + b, iterable))
[3, 100]

``TypeError`` will be raised if *func*'s signature doesn't match the
mapping contained in *iterable* or if *iterable* does not contain mappings.
Nr   r   )r:  r   r   s   && r   rd   rd     s      lTl s   c                &   V ^8  d   \         hV ^8  d   V RV ,          3# V \        V \        V 4      ,          4      ,          pW,
          pV R8  d@   WR\        \        V 4      4      R,
          \        V 4      ,          ,
          ,          ,          pW!3# )z:Bounds for the nth prime (counting from 1): lb < p_n < ub.g      @i
 r%  g       @)r   r$   )r   upper_boundlower_bounds   &  r   _nth_prime_boundsr  &  s}     	1u1u4!8} c!c!f*o%K/KG|C3s1v;#4A">>??##r   approximatec                   \        V ^,           4      w  r#V'       d   V R8:  d   \        \        \        V4      4      V 4      # \	        W#,           ^,          4      ^,          p\        \        V^R7      \        R7      # )a8  Return the nth prime (counting from 0).

>>> nth_prime(0)
2
>>> nth_prime(100)
547

If *approximate* is set to True, will return a prime close
to the nth prime.  The estimation is much faster than computing
an exact result.

>>> nth_prime(200_000_000, approximate=True)  # Exact result is 4222234763
4217820427

i@B )r  )r  )r  rA   rC   r(   r"   r>   r   r@   )r   r  lbubodds   &$   r   r   r   9  s]      q1u%FB!y.5b?A&& A

"CeCa(x88r   c               l    Ve   \        W4      p \        \        V 4      \        ^4      R7      ^ ,          # )a  
Index of the first occurrence of a minimum value in an iterable.

    >>> argmin('efghabcdijkl')
    4
    >>> argmin([3, 2, 1, 0, 4, 2, 1, 0])
    3

For example, look up a label corresponding to the position
of a value that minimizes a cost function::

    >>> def cost(x):
    ...     "Days for a wound to heal given a subject's age."
    ...     return x**2 - 20*x + 150
    ...
    >>> labels =  ['homer', 'marge', 'bart', 'lisa', 'maggie']
    >>> ages =    [  35,      30,      10,      9,      1    ]

    # Fastest healing family member
    >>> labels[argmin(ages, key=cost)]
    'bart'

    # Age with fastest healing
    >>> min(ages, key=cost)
    10

r  )r   r  r  r1   r  s   &$r   rO   rO   S  s.    8 s%y"
16q99r   c               l    Ve   \        W4      p \        \        V 4      \        ^4      R7      ^ ,          # )u  
Index of the first occurrence of a maximum value in an iterable.

    >>> argmax('abcdefghabcd')
    7
    >>> argmax([0, 1, 2, 3, 3, 2, 1, 0])
    3

For example, identify the best machine learning model::

    >>> models =   ['svm', 'random forest', 'knn', 'naïve bayes']
    >>> accuracy = [  68,        61,          84,       72      ]

    # Most accurate model
    >>> models[argmax(accuracy)]
    'knn'

    # Best accuracy
    >>> max(accuracy)
    84

r  )r   r   r  r1   r  s   &$r   rN   rN   t  s.    . s%y"
16q99r   c              #    "   \        V 4      p\        \        V\        4       4      4      pV'       d!   V^ ,          ^ ,          ^ 8  d   \	        R4      h/ pRp^ pV F\  w  rxWu,
          p	V	'       d     \        \        W)^,
          R4      4      p
TpX
WH&   Wd9   g   K@  VP                  V4      x  V^,          pK&  	  R#   \         d    \        T4      hi ; i5i)a  Yield values at the specified indices.

Example:

    >>> data = 'abcdefghijklmnopqrstuvwxyz'
    >>> list(extract(data, [7, 4, 11, 11, 14]))
    ['h', 'e', 'l', 'l', 'o']

The *iterable* is consumed lazily and can be infinite.
The *indices* are consumed immediately and must be finite.

Raises ``IndexError`` if an index lies beyond the iterable.
Raises ``ValueError`` for negative indices.
zIndices must be non-negativeNr   )
r   r  r?  r   r   r   r   r   r   r  )r   r}  r   index_and_positionr  iterator_positionnext_to_emitr"  orderadvancer  s   &&         r   ri   ri     s       H~HGUW 5603A6:788FL*+(VHk4@A !&$**\**AL +
 ! ( ''(s$   A.C1B=	C"C=CCr9  r  r   r  )Nr  )NNN)r   F)r   )NNF)r   ))r   r   r  FNr'  )r'  NFF)NFF)r  r  collectionsr   r   r   r   collections.abcr   
contextlibr   	functoolsr	   r
   r   r   heapqr   r   	itertoolsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   queuer)   r*   r+   r,   r-   r.   operatorr/   r0   r1   r2   r3   r4   r5   r6   sysr7   r8   timer9   recipesr:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   __all__r   r   ImportErrorr   r   rR   rl   r}   r   r   rZ   rr   rz   r   r   r   r   ra   r]   rw   r   r   r   r   rP   r   rs   ru   rt   rv   rU   r   r   r   r   r   r   r   r   r   r   rb   r   r   r   r   r   rc   r  r  rL   rJ   rn   Hashabler   r[   r   r=  r~   r   r   r   r   ry   r}  rM   rX   r_   rI   r   r   rh   rT   r   r   r   r   r   r   r   r   r  ro   rp   r`   rj   r   r   r)  r5  r<  r   rx   BaseExceptionrH   rQ   r   rK   r   r   r   r   r   rV   rW   r   r\   rS   r   r   re   rf   rg   r   r   rY   rm   r   r   r   r{   rk   r   r|   r  r^   rq   rd   r  r   rO   rN   ri   r   r   r   <module>r     s	     8 8 $  = = &    " M L L   6 6	 	 	 $    "uuu u 	u
 u u u u u u u u u u u  !u" )#u$ %u& 'u( )u* +u, -u. /u0 
1u2 3u4 5u6 7u8 9u: ;u< =u> ?u@ AuB CuD EuF GuH IuJ KuL MuN OuP QuR SuT UuV WuX YuZ [u\ ]u^ _u` aub cud euf guh iuj kul mun oup qur sut uuv wux yuz {u| }u~ u@ AuB CuD EuF GuH IuJ 'KuL MuN 
OuP QuR SuT UuV WuX YuZ [u\ ]u^ _u` aub cud euf guh iuj kul mun oup qur sut uuv wux yuz {u| }u~ u@ AuB CuD EuF 
GuH IuJ KuL MuN OuP QuR SuT UuV WuX YuZ [u\ ]u^ _u` aub cud euf guh iup<): F $ 6 # 8 &- :"b" b"J@32 (5LpHVS$l;|D4CB7t!4D]' ]'@&R0$?+D.9x:zD)X F#L*Z*)Z*@ZA&"MJ8">$E $T $NFR&R0f %(< 2j$)N*ZQ,CLL#,, Q,h; < D -0`A%$40"+P +P\i&X($/$d " ')d ')T*>8 *>Z^/ ^/B> >: &* A$<?DFR  T (?V:zB(N
b/ /d"J+<!HL(%P0*@8($N FP7 P7U P7fD@	- 	| |~%%P F#>)(X+\D2(&V6r0 @//d5#u 5e 5p$N<D'>TJ4 J J\ #'D/d'T2B.$$9-010$$&9 94:D :B:D :8's^  <</<s   6Q# #Q:9Q: