hyb
2025-12-23 10f3a1daddfbc7fa3dd2069197d83e8b6ef19176
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
Ë
Añúh¯oãó—dZddlZddlZddlmZddlmZddlmZm    Z    ddl
m Z m Z m Z mZmZmZmZmZmZmZmZmZddlmZmZmZddlmZgd    ¢Ze«Z    e d
¬ «ee d
¬ «Z!e#ed d „«Z$d„Z%dGd„Z&d„Z'dHd„Z(dHd„Z)dHd„Z*e+fd„Z,d„Z-e-Z.d„Z/d„Z0d„Z1dHd„Z2d„Z3    ddl
m4Z5d„Z4e3je4_Gd„de7«Z8d„Z9d „Z:dId!„Z;d"„Z<d#„Z=d$„Z>dHd%„Z?dHd&„Z@dJd(„ZAdHd)„ZBdKd*„ZCd+d,œd-„ZDdHd.„ZEd/„ZFd0„ZGd1„ZHd2„ZId3„ZJd4„ZKd5„ZLd6„ZMd7„ZNd8„ZOdLd9„ZPd:„ZQd'd œd;„ZRed<k\r dd=l
mSZTd'd œd>„ZSneRZSeRjeS_d?„ZUd@„ZVdA„ZWdB„ZXdC„ZYdD„ZZdE„Z[dF„Z\y#e"$re Z!YŒwxYw#e6$re3Z4YŒ¼wxYw)MaImported from the recipes section of the itertools documentation.
 
All functions taken from the recipes section of the itertools library docs
[1]_.
Some backward-compatible usability improvements have been made.
 
.. [1] http://docs.python.org/library/itertools.html#recipes
 
éN)Údeque)ÚSized)ÚpartialÚreduce) ÚchainÚ combinationsÚcompressÚcountÚcycleÚgroupbyÚisliceÚproductÚrepeatÚstarmapÚteeÚ zip_longest)Ú    randrangeÚsampleÚchoice)Ú
hexversion).Ú    all_equalÚbatchedÚbefore_and_afterÚconsumeÚconvolveÚ
dotproductÚ
first_trueÚfactorÚflattenÚgrouperÚ iter_exceptÚ
iter_indexÚmatmulÚncyclesÚnthÚnth_combinationÚpadnoneÚpad_noneÚpairwiseÚ    partitionÚpolynomial_evalÚpolynomial_from_rootsÚpolynomial_derivativeÚpowersetÚprependÚquantifyÚreshapeÚ#random_combination_with_replacementÚrandom_combinationÚrandom_permutationÚrandom_productÚ
repeatfuncÚ
roundrobinÚsieveÚsliding_windowÚ    subslicesÚsum_of_squaresÚtabulateÚtailÚtakeÚtotientÚ    transposeÚ
triplewiseÚuniqueÚunique_everseenÚunique_justseenT©ÚstrictÚsumprodcó—t||«S©N)r)ÚxÚys  ú\H:\Change_password\venv_build\Lib\site-packages\setuptools/_vendor/more_itertools/recipes.pyú<lambda>rM_s €´¸A¸qÓ1A€ócó,—tt||««S)zñReturn first *n* items of the iterable as a list.
 
        >>> take(3, range(10))
        [0, 1, 2]
 
    If there are fewer than *n* items in the iterable, all of them are
    returned.
 
        >>> take(10, range(3))
        [0, 1, 2]
 
    )Úlistr ©ÚnÚiterables  rLr>r>bs€ô ”x Ó#Ó $Ð$rNcó,—t|t|««S)a©Return an iterator over the results of ``func(start)``,
    ``func(start + 1)``, ``func(start + 2)``...
 
    *func* should be a function that accepts one integer argument.
 
    If *start* is not specified it defaults to 0. It will be incremented each
    time the iterator is advanced.
 
        >>> square = lambda x: x ** 2
        >>> iterator = tabulate(square, -3)
        >>> take(4, iterator)
        [9, 4, 1, 0]
 
    )Úmapr
)ÚfunctionÚstarts  rLr<r<rs€ô ˆxœ˜u›Ó &Ð&rNc    #óÈK—t|t«r,t|tdt    |«|z
«d«Ed{–—†yt t ||¬««Ed{–—†y7Œ$7Œ­w)zƒReturn an iterator over the last *n* items of *iterable*.
 
    >>> t = tail(3, 'ABCDEFG')
    >>> list(t)
    ['E', 'F', 'G']
 
    rN©Úmaxlen)Ú
isinstancerr ÚmaxÚlenÚiterrrQs  rLr=r=„sSèø€ô(œEÔ"ܘ(¤C¨¬3¨x«=¸1Ñ+<Ó$=¸tÓD×DÑD䜘h¨qÔ1Ó2×2Ñ2ð    Eøà2ús!‚7A"¹AºA"ÁA ÁA"Á A"cóR—|€t|d¬«ytt|||«d«y)aXAdvance *iterable* by *n* steps. If *n* is ``None``, consume it
    entirely.
 
    Efficiently exhausts an iterator without returning values. Defaults to
    consuming the whole iterator, but an optional second argument may be
    provided to limit consumption.
 
        >>> i = (x for x in range(10))
        >>> next(i)
        0
        >>> consume(i, 3)
        >>> next(i)
        4
        >>> consume(i)
        >>> next(i)
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        StopIteration
 
    If the iterator has fewer items remaining than the provided limit, the
    whole iterator will be consumed.
 
        >>> i = (x for x in range(3))
        >>> consume(i, 5)
        >>> next(i)
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        StopIteration
 
    NrrY)rÚnextr )ÚiteratorrRs  rLrr–s)€ð@    €yä ˆh˜qÖ!ô     ŒVH˜a Ó # TÕ*rNcó0—tt||d«|«S)z…Returns the nth item or a default value.
 
    >>> l = range(10)
    >>> nth(l, 3)
    3
    >>> nth(l, 20, "zebra")
    'zebra'
 
    N)r`r )rSrRÚdefaults   rLr%r%¾s€ô ”x  DÓ)¨7Ó 3Ð3rNc
óX—tttt||«d«««dkS)a§
    Returns ``True`` if all the elements are equal to each other.
 
        >>> all_equal('aaaa')
        True
        >>> all_equal('aaab')
        False
 
    A function that accepts a single argument and returns a transformed version
    of each input item can be specified with *key*:
 
        >>> all_equal('AaaA', key=str.casefold)
        True
        >>> all_equal([1, 2, 3], key=lambda x: x < 10)
        True
 
    éé)r]rPr r ©rSÚkeys  rLrrËs'€ô$ Œt”Fœ7 8¨SÓ1°1Ó5Ó6Ó 7¸1Ñ <Ð<rNcó,—tt||««S)zcReturn the how many times the predicate is true.
 
    >>> quantify([True, False, True])
    2
 
    )ÚsumrU)rSÚpreds  rLr0r0às€ô Œs4˜Ó"Ó #Ð#rNcó,—t|td««S)aReturns the sequence of elements and then returns ``None`` indefinitely.
 
        >>> take(5, pad_none(range(3)))
        [0, 1, 2, None, None]
 
    Useful for emulating the behavior of the built-in :func:`map` function.
 
    See also :func:`padded`.
 
    N)rr©rSs rLr(r(ês€ô œ6 $›<Ó (Ð(rNcóR—tjtt|«|««S)zvReturns the sequence elements *n* times
 
    >>> list(ncycles(["a", "b"], 3))
    ['a', 'b', 'a', 'b', 'a', 'b']
 
    )rÚ from_iterablerÚtuple)rSrRs  rLr$r$ûs €ô × Ñ œv¤e¨H£o°qÓ9Ó :Ð:rNcóJ—tttj||««S)zcReturns the dot product of the two iterables.
 
    >>> dotproduct([10, 10], [20, 20])
    400
 
    )rjrUÚoperatorÚmul)Úvec1Úvec2s  rLrrs€ô Œs”8—<‘<  tÓ,Ó -Ð-rNcó,—tj|«S)zÜReturn an iterator flattening one level of nesting in a list of lists.
 
        >>> list(flatten([[0, 1], [2, 3]]))
        [0, 1, 2, 3]
 
    See also :func:`collapse`, which can flatten multiple levels of nesting.
 
    )rro)Ú listOfListss rLrrs€ô × Ñ ˜{Ó +Ð+rNcó\—|€t|t|««St|t||««S)aGCall *func* with *args* repeatedly, returning an iterable over the
    results.
 
    If *times* is specified, the iterable will terminate after that many
    repetitions:
 
        >>> from operator import add
        >>> times = 4
        >>> args = 3, 5
        >>> list(repeatfunc(add, times, *args))
        [8, 8, 8, 8]
 
    If *times* is ``None`` the iterable will not terminate:
 
        >>> from random import randrange
        >>> times = None
        >>> args = 1, 11
        >>> take(6, repeatfunc(randrange, times, *args))  # doctest:+SKIP
        [2, 4, 8, 1, 8, 4]
 
    )rr)ÚfuncÚtimesÚargss   rLr6r6s.€ð, €}ܐtœV D›\Ó*Ð*Ü 4œ  eÓ,Ó -Ð-rNcóN—t|«\}}t|d«t||«S)zâReturns an iterator of paired items, overlapping, from the original
 
    >>> take(4, pairwise(count()))
    [(0, 1), (1, 2), (2, 3), (3, 4)]
 
    On Python 3.10 and above, this is an alias for :func:`itertools.pairwise`.
 
    N)rr`Úzip)rSÚaÚbs   rLÚ    _pairwiser€6s&€ô ˆx‹=D€A€q܈ˆD„MÜ ˆq!‹9ÐrN©r)có—t|«SrI)Úitertools_pairwiserms rLr)r)Js €Ü! (Ó+Ð+rNc󠇗eZdZdˆfd„    ZˆxZS)ÚUnequalIterablesErrorcóP•—d}||dj|Žz }t‰|    |«y)Nz Iterables have different lengthsz/: index 0 has length {}; index {} has length {})ÚformatÚsuperÚ__init__)ÚselfÚdetailsÚmsgÚ    __class__s   €rLr‰zUnequalIterablesError.__init__Qs;ø€Ø0ˆØ Ð Ø ÐMÐE×MÑMØðñ ˆCô    ‰Ñ˜ÕrNrI)Ú__name__Ú
__module__Ú __qualname__r‰Ú __classcell__)rs@rLr…r…Ps ø„÷ñrNr…c#ónK—t|dtiŽD]}|D]}|tusŒ t«‚|–—Œ!y­w)NÚ    fillvalue)rÚ_markerr…)Ú    iterablesÚcomboÚvals   rLÚ_zip_equal_generatorr˜[sEèø€Ü˜iÐ;´7Ñ;òˆØò    .ˆCØ”gŠ~Ü+Ó-Ð-ð    .ð‹ ñ    ùs‚ 5£5cóЗ    t|d«}t|ddd«D]$\}}t|«}||k7sŒt|||f¬«‚t|ŽS#t$rt |«cYSwxYw)Nrrf)r‹)r]Ú    enumerater…r}Ú    TypeErrorr˜)r•Ú
first_sizeÚiÚitÚsizes     rLÚ
_zip_equalr cs‚€ð /ܘ 1™Ó&ˆ
ܘy¨¨˜}¨aÓ0ò    K‰EˆAˆrܐr“7ˆDؐzÓ!Ü+°ZÀÀDÐ4IÔJÐJð    Kô
IˆÐøô ò/Ü# IÓ.Ò.ð/ús‚3A¶AÁA%Á$A%cóŠ—t|«g|z}|dk(r t|d|iŽS|dk(rt|ŽS|dk(rt|ŽSt    d«‚)a½Group elements from *iterable* into fixed-length groups of length *n*.
 
    >>> list(grouper('ABCDEF', 3))
    [('A', 'B', 'C'), ('D', 'E', 'F')]
 
    The keyword arguments *incomplete* and *fillvalue* control what happens for
    iterables whose length is not a multiple of *n*.
 
    When *incomplete* is `'fill'`, the last group will contain instances of
    *fillvalue*.
 
    >>> list(grouper('ABCDEFG', 3, incomplete='fill', fillvalue='x'))
    [('A', 'B', 'C'), ('D', 'E', 'F'), ('G', 'x', 'x')]
 
    When *incomplete* is `'ignore'`, the last group will not be emitted.
 
    >>> list(grouper('ABCDEFG', 3, incomplete='ignore', fillvalue='x'))
    [('A', 'B', 'C'), ('D', 'E', 'F')]
 
    When *incomplete* is `'strict'`, a subclass of `ValueError` will be raised.
 
    >>> it = grouper('ABCDEFG', 3, incomplete='strict')
    >>> list(it)  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    UnequalIterablesError
 
    Úfillr“rFÚignorez Expected fill, strict, or ignore)r^rr r}Ú
ValueError)rSrRÚ
incompleter“r{s     rLr r ss^€ô: ‹NÐ ˜aÑ €DؐVÒܘDÐ6¨IÑ6Ð6ؐXÒܘ4РРؐXÒܐDˆzÐäÐ;Ó<Ð<rNc'óÀK—tt|«}tt|«dd«D]/}t    t ||««}tt |«Ed{–—†Œ1y7Œ­w)aJYields an item from each iterable, alternating between them.
 
        >>> list(roundrobin('ABC', 'D', 'EF'))
        ['A', 'D', 'E', 'B', 'F', 'C']
 
    This function produces the same output as :func:`interleave_longest`, but
    may perform better for some inputs (in particular when the number of
    iterables is small).
 
    réÿÿÿÿN)rUr^Úranger]r r r`)r•Ú    iteratorsÚ
num_actives   rLr7r7›sTèø€ô”D˜)Ó$€IÜœC     ›N¨A¨rÓ2ò(ˆ
Üœ& ¨JÓ7Ó8ˆ    Ü”t˜YÓ'×'Ñ'ñ(à'ús‚AAÁAÁAcó—|€t}t|d«\}}}tt||««\}}t|ttj
|««t||«fS)a¯
    Returns a 2-tuple of iterables derived from the input iterable.
    The first yields the items that have ``pred(item) == False``.
    The second yields the items that have ``pred(item) == True``.
 
        >>> is_odd = lambda x: x % 2 != 0
        >>> iterable = range(10)
        >>> even_items, odd_items = partition(is_odd, iterable)
        >>> list(even_items), list(odd_items)
        ([0, 2, 4, 6, 8], [1, 3, 5, 7, 9])
 
    If *pred* is None, :func:`bool` is used.
 
        >>> iterable = [0, 1, False, True, '', ' ']
        >>> false_items, true_items = partition(None, iterable)
        >>> list(false_items), list(true_items)
        ([0, False, ''], [1, True, ' '])
 
    é)ÚboolrrUr    rrÚnot_)rkrSÚt1Út2ÚpÚp1Úp2s       rLr*r*­sX€ð( €|܈äH˜aÓ I€BˆˆAÜ ”T˜1“Ó F€BˆÜ RœœXŸ]™]¨BÓ/Ó 0´(¸2¸rÓ2BÐ CÐCrNc󀇗t|«Štjˆfd„tt    ‰«dz«D««S)a1Yields all possible subsets of the iterable.
 
        >>> list(powerset([1, 2, 3]))
        [(), (1,), (2,), (3,), (1, 2), (1, 3), (2, 3), (1, 2, 3)]
 
    :func:`powerset` will operate on iterables that aren't :class:`set`
    instances, so repeated elements in the input will produce repeated elements
    in the output.
 
        >>> seq = [1, 1, 0]
        >>> list(powerset(seq))
        [(), (1,), (1,), (0,), (1, 1), (1, 0), (1, 0), (1, 1, 0)]
 
    For a variant that efficiently yields actual :class:`set` instances, see
    :func:`powerset_of_sets`.
    c3ó6•K—|]}t‰|«–—Œy­wrI)r)Ú.0ÚrÚss  €rLú    <genexpr>zpowerset.<locals>.<genexpr>Ûsøèø€ÒM°aœ|¨A¨q×1ÑMùsƒrf)rPrror¨r])rSr¸s @rLr.r.És2ø€ô"     ˆX‹€AÜ × Ñ ÓM¼5ÄÀQÃÈ!ÁÓ;LÔMÓ MÐMrNc#óâK—t«}|j}g}|j}|du}|D]}|r||«n|}    ||vr ||«|–—Œ!y#t$r||vr ||«|–—YŒ>wxYw­w)a–
    Yield unique elements, preserving order.
 
        >>> list(unique_everseen('AAAABBBCCDAABBB'))
        ['A', 'B', 'C', 'D']
        >>> list(unique_everseen('ABBCcAD', str.lower))
        ['A', 'B', 'C', 'D']
 
    Sequences with a mix of hashable and unhashable items can be used.
    The function will be slower (i.e., `O(n^2)`) for unhashable items.
 
    Remember that ``list`` objects are unhashable - you can use the *key*
    parameter to transform the list to a tuple (which is hashable) to
    avoid a slowdown.
 
        >>> iterable = ([1, 2], [2, 3], [1, 2])
        >>> list(unique_everseen(iterable))  # Slow
        [[1, 2], [2, 3]]
        >>> list(unique_everseen(iterable, key=tuple))  # Faster
        [[1, 2], [2, 3]]
 
    Similarly, you may want to convert unhashable ``set`` objects with
    ``key=frozenset``. For ``dict`` objects,
    ``key=lambda x: frozenset(x.items())`` can be used.
 
    N)ÚsetÚaddÚappendr›)    rSrhÚseensetÚ seenset_addÚseenlistÚ seenlist_addÚuse_keyÚelementÚks             rLrCrCÞsŠèø€ô6‹e€GØ—+‘+€KØ€HØ—?‘?€Lؘˆo€Gàò    ˆÙ#‰CŒL¨ˆð    Ø˜ÑÙ˜A”Ø’ øñ     øô ò    Ø˜Ñ Ù˜Q”Ø’ ùð    üs(‚:A/½AÁ A/ÁA,Á)A/Á+A,Á,A/c
óė|€(ttjd«t|««Sttttjd«t||«««S)záYields elements in order, ignoring serial duplicates
 
    >>> list(unique_justseen('AAAABBBCCDAABBB'))
    ['A', 'B', 'C', 'D', 'A', 'B']
    >>> list(unique_justseen('ABBCcAD', str.lower))
    ['A', 'B', 'C', 'A', 'D']
 
    rrf)rUrrÚ
itemgetterr r`rgs  rLrDrD sL€ð €{Ü”8×&Ñ& qÓ)¬7°8Ó+<Ó=Ð=ä Œt”Sœ×,Ñ,¨QÓ/´¸À3Ó1GÓHÓ IÐIrNFcó4—tt|||¬«|¬«S)a°Yields unique elements in sorted order.
 
    >>> list(unique([[1, 2], [3, 4], [1, 2]]))
    [[1, 2], [3, 4]]
 
    *key* and *reverse* are passed to :func:`sorted`.
 
    >>> list(unique('ABBcCAD', str.casefold))
    ['A', 'B', 'c', 'D']
    >>> list(unique('ABBcCAD', str.casefold, reverse=True))
    ['D', 'c', 'B', 'A']
 
    The elements in *iterable* need not be hashable, but they must be
    comparable for sorting to work.
    )rhÚreverse)rh)rDÚsorted)rSrhrÈs   rLrBrBs€ô  œ6 (°¸WÔEÈ3Ô OÐOrNc#óNK—    |    |«–—    |«–—Œ
#|$rYywxYw­w)aÙYields results from a function repeatedly until an exception is raised.
 
    Converts a call-until-exception interface to an iterator interface.
    Like ``iter(func, sentinel)``, but uses an exception instead of a sentinel
    to end the loop.
 
        >>> l = [0, 1, 2]
        >>> list(iter_except(l.pop, IndexError))
        [2, 1, 0]
 
    Multiple exceptions can be specified as a stopping condition:
 
        >>> l = [1, 2, 3, '...', 4, 5, 6]
        >>> list(iter_except(lambda: 1 + l.pop(), (IndexError, TypeError)))
        [7, 6, 5]
        >>> list(iter_except(lambda: 1 + l.pop(), (IndexError, TypeError)))
        [4, 3, 2]
        >>> list(iter_except(lambda: 1 + l.pop(), (IndexError, TypeError)))
        []
 
    N©)ryÚ    exceptionÚfirsts   rLr!r!-s8èø€ð, Ø Ð Ù“'ŠMØÙ“&ŠLðøà ò Ù ð üs‚%„š"Ÿ%¡"¢%có.—tt||«|«S)a
    Returns the first true value in the iterable.
 
    If no true value is found, returns *default*
 
    If *pred* is not None, returns the first item for which
    ``pred(item) == True`` .
 
        >>> first_true(range(10))
        1
        >>> first_true(range(10), pred=lambda x: x > 5)
        6
        >>> first_true(range(10), default='missing', pred=lambda x: x > 9)
        'missing'
 
    )r`Úfilter)rSrcrks   rLrrLs€ô" ”t˜XÓ&¨Ó 0Ð0rNrf)rcóh—|Dcgc] }t|«‘Œc}|z}td„|D««Scc}w)aÇDraw an item at random from each of the input iterables.
 
        >>> random_product('abc', range(4), 'XYZ')  # doctest:+SKIP
        ('c', 3, 'Z')
 
    If *repeat* is provided as a keyword argument, that many items will be
    drawn from each iterable.
 
        >>> random_product('abcd', range(4), repeat=2)  # doctest:+SKIP
        ('a', 2, 'd', 3)
 
    This equivalent to taking a random selection from
    ``itertools.product(*args, **kwarg)``.
 
    c3ó2K—|]}t|«–—Œy­wrI)r)r¶Úpools  rLr¹z!random_product.<locals>.<genexpr>qsèø€Ò0 $”˜—Ñ0ùs‚)rp)rr{rÒÚpoolss    rLr5r5`s3€ð &*Ö *˜TŒU4[Ò *¨VÑ 3€EÜ Ñ0¨%Ô0Ó 0Ð0ùò +s…/có`—t|«}|€ t|«n|}tt||««S)abReturn a random *r* length permutation of the elements in *iterable*.
 
    If *r* is not specified or is ``None``, then *r* defaults to the length of
    *iterable*.
 
        >>> random_permutation(range(5))  # doctest:+SKIP
        (3, 4, 0, 1, 2)
 
    This equivalent to taking a random selection from
    ``itertools.permutations(iterable, r)``.
 
    )rpr]r)rSr·rÒs   rLr4r4ts-€ô ‹?€DؐYŒˆDŒ     A€AÜ ”˜˜a“Ó !Ð!rNc󔇗t|«Št‰«}ttt    |«|««}tˆfd„|D««S)zÿReturn a random *r* length subsequence of the elements in *iterable*.
 
        >>> random_combination(range(5), 3)  # doctest:+SKIP
        (2, 3, 4)
 
    This equivalent to taking a random selection from
    ``itertools.combinations(iterable, r)``.
 
    c3ó(•K—|]    }‰|–—Œ y­wrIrË©r¶rrÒs  €rLr¹z%random_combination.<locals>.<genexpr>“óøèø€Ò*˜Qa•Ñ*ùóƒ)rpr]rÉrr¨)rSr·rRÚindicesrÒs    @rLr3r3†s=ø€ô ‹?€DÜ ˆD‹    €AÜ”VœE !›H aÓ(Ó)€GÜ Ó* 'Ô*Ó *Ð*rNc󔇇—t|«Št‰«Štˆfd„t|«D««}tˆfd„|D««S)aSReturn a random *r* length subsequence of elements in *iterable*,
    allowing individual elements to be repeated.
 
        >>> random_combination_with_replacement(range(3), 5) # doctest:+SKIP
        (0, 0, 1, 2, 2)
 
    This equivalent to taking a random selection from
    ``itertools.combinations_with_replacement(iterable, r)``.
 
    c3ó4•K—|]}t‰«–—Œy­wrI)r)r¶rrRs  €rLr¹z6random_combination_with_replacement.<locals>.<genexpr>£søèø€Ò4 a”Y˜q—\Ñ4ùsƒc3ó(•K—|]    }‰|–—Œ y­wrIrËr×s  €rLr¹z6random_combination_with_replacement.<locals>.<genexpr>¤rØrÙ)rpr]rÉr¨)rSr·rÚrRrÒs   @@rLr2r2–s<ù€ô ‹?€DÜ ˆD‹    €AÜÓ4¬5°«8Ô4Ó4€GÜ Ó* 'Ô*Ó *Ð*rNcóž—t|«}t|«}|dks||kDrt‚d}t|||z
«}t    d|dz«D]}|||z
|zz|z}Œ|dkr||z }|dks||k\rt
‚g}|rL||z|z|dz
|dz
}}}||k\r||z}|||z
z|z|dz
}}||k\rŒ|j |d|z
«|rŒLt|«S)aEquivalent to ``list(combinations(iterable, r))[index]``.
 
    The subsequences of *iterable* that are of length *r* can be ordered
    lexicographically. :func:`nth_combination` computes the subsequence at
    sort position *index* directly, without computing the previous
    subsequences.
 
        >>> nth_combination(range(5), 3, 5)
        (0, 3, 4)
 
    ``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.
    rrfr§)rpr]r¤Úminr¨Ú
IndexErrorr½)    rSr·ÚindexrÒrRÚcrÄrÚresults             rLr&r&§s€ô ‹?€DÜ ˆD‹    €AØ    ˆAА1q’5ÜÐà    €AÜ ˆAˆq1‰u‹ €AÜ 1a˜!‘e‹_ò!ˆØ Q‘˜‘‰O˜qÑ  ‰ð!ð ˆq‚yØ ‰
ˆà Š    u ’zÜÐà €FÙ
ؐa‘%˜1‘*˜a !™e Q¨¡Uˆaˆ1ˆØqŠjØ Q‰JˆEؘ˜A™‘; !Ñ# Q¨¡UˆqˆAðq‹jð     ‰ d˜2 ™6‘lÔ#ò ô ‹=ÐrNcó—t|g|«S)aYield *value*, followed by the elements in *iterator*.
 
        >>> value = '0'
        >>> iterator = ['1', '2', '3']
        >>> list(prepend(value, iterator))
        ['0', '1', '2', '3']
 
    To prepend multiple values, see :func:`itertools.chain`
    or :func:`value_chain`.
 
    )r)Úvalueras  rLr/r/Ñs€ô %˜(Ó #Ð#rNc#óàK—t|«ddd…}t|«}tdg|¬«|z}t|t    d|dz
««D]!}|j |«t ||«–—Œ#y­w)aBConvolve the iterable *signal* with the iterable *kernel*.
 
        >>> signal = (1, 2, 3, 4, 5)
        >>> kernel = [3, 2, 1]
        >>> list(convolve(signal, kernel))
        [3, 8, 14, 20, 26, 14, 5]
 
    Note: the input arguments are not interchangeable, as the *kernel*
    is immediately consumed and stored.
 
    Nr§rrYrf)rpr]rrrr½Ú_sumprod)ÚsignalÚkernelrRÚwindowrJs     rLrràspèø€ô6‹]™4˜R˜4Ñ  €FÜ ˆF‹ €AÜ A3˜qÔ ! AÑ %€FÜ 6œ6 ! Q¨¡UÓ+Ó ,ò'ˆØ ‰ aÔܐv˜vÓ&Ó&ñ'ùs‚A,A.cóZ‡‡‡—t‰«ŠgŠˆˆˆfd„}t‰‰«}|«|fS)aÆA variant of :func:`takewhile` that allows complete access to the
    remainder of the iterator.
 
         >>> it = iter('ABCdEfGhI')
         >>> all_upper, remainder = before_and_after(str.isupper, it)
         >>> ''.join(all_upper)
         'ABC'
         >>> ''.join(remainder) # takewhile() would lose the 'd'
         'dEfGhI'
 
    Note that the first iterator must be fully consumed before the second
    iterator can generate valid results.
    c3óZ•K—‰D]!}‰|«r|–—Œ‰j|«yy­wrI)r½)ÚelemržÚ    predicateÚ
transitions €€€rLÚ true_iteratorz'before_and_after.<locals>.true_iterators3øèø€Øò    ˆDÙ˜ŒØ“
à×!Ñ! $Ô'Ùñ     ùsƒ(+)r^r)rîržrðÚremainder_iteratorrïs``  @rLrrös5ú€ô
ˆb‹€BØ€Jöô˜z¨2Ó.Ðá ‹?Ð.Ð .Ð.rNc#ó^K—tt|««D]\\}}\}}|||f–—Œy­w)zReturn overlapping triplets from *iterable*.
 
    >>> list(triplewise('ABCDE'))
    [('A', 'B', 'C'), ('B', 'C', 'D'), ('C', 'D', 'E')]
 
    Nr)rSr~Ú_rrâs     rLrArAs8èø€ô#¤8¨HÓ#5Ó6ò‰‰ˆˆA‘AؐAˆg‹ ñùs‚+-c#ó K—t|«}tt||dz
«|¬«}|D] }|j|«t    |«–—Œ"y­w)aYReturn a sliding window of width *n* over *iterable*.
 
        >>> list(sliding_window(range(6), 4))
        [(0, 1, 2, 3), (1, 2, 3, 4), (2, 3, 4, 5)]
 
    If *iterable* has fewer than *n* items, then nothing is yielded:
 
        >>> list(sliding_window(range(3), 4))
        []
 
    For a variant with more features, see :func:`windowed`.
    rfrYN)r^rr r½rp)rSrRržrêrJs     rLr9r9"sMèø€ô
ˆh‹€BÜ ”6˜"˜a !™eÓ$¨QÔ /€FØ òˆØ ‰ aÔܐF‹mÓñùs‚A Ac
ó¾—t|«}tttt    t |«dz«d««}t tjt|«|«S)zþReturn all contiguous non-empty subslices of *iterable*.
 
        >>> list(subslices('ABC'))
        [['A'], ['A', 'B'], ['A', 'B', 'C'], ['B'], ['B', 'C'], ['C']]
 
    This is similar to :func:`substrings`, but emits items in a different
    order.
    rfre)
rPrÚslicerr¨r]rUrrÚgetitemr)rSÚseqÚslicess   rLr:r:6sF€ô ˆx‹.€CÜ ”UœL¬¬s°3«x¸!©|Ó)<¸aÓ@Ó A€FÜ Œx×Ѥ¨£¨fÓ 5Ð5rNcó’—ttd«ttj|««}t t t|dg««S)zÌCompute a polynomial's coefficients from its roots.
 
    >>> roots = [5, -4, 3]  # (x - 5) * (x + 4) * (x - 3)
    >>> polynomial_from_roots(roots)  # x^3 - 4 * x^2 - 17 * x + 60
    [1, -4, -17, 60]
    rf)r}rrUrrÚnegrPrr)ÚrootsÚfactorss  rLr,r,Ds5€ô”&˜“)œS¤§¡¨uÓ5Ó6€GÜ ””x ¨1¨#Ó.Ó /Ð/rNc#óöK—t|dd«}|€0t|||«}t||«D]\}}||us||k(sŒ|–—Œy|€ t|«n|}|dz
}        |||dz|«x}–—Œ#t$rYywxYw­w)aûYield the index of each place in *iterable* that *value* occurs,
    beginning with index *start* and ending before index *stop*.
 
 
    >>> list(iter_index('AABCADEAF', 'A'))
    [0, 1, 4, 7]
    >>> list(iter_index('AABCADEAF', 'A', 1))  # start index is inclusive
    [1, 4, 7]
    >>> list(iter_index('AABCADEAF', 'A', 1, 7))  # stop index is not inclusive
    [1, 4]
 
    The behavior for non-scalar *values* matches the built-in Python types.
 
    >>> list(iter_index('ABCDABCD', 'AB'))
    [0, 4]
    >>> list(iter_index([0, 1, 2, 3, 0, 1, 2, 3], [0, 1]))
    []
    >>> list(iter_index([[0, 1], [2, 3], [0, 1], [2, 3]], [0, 1]))
    [0, 2]
 
    See :func:`locate` for a more general means of finding the indexes
    associated with particular values.
 
    ráNrf)Úgetattrr ršr]r¤)rSrårWÚstopÚ    seq_indexržrrÃs        rLr"r"Os¨èø€ô2˜ '¨4Ó0€IØÐä H˜e TÓ *ˆÜ# B¨Ó.ò    ‰JˆAˆwؘ%Ñ 7¨eÓ#3Ø“ñ    ð
!%  Œs8Œ}°$ˆØ A‰Iˆð    ØÙ% e¨Q°©U°DÓ9Ð9qÒ:ðøäò    Ù ð    üs(‚8A9»A9ÁA*Á*    A6Á3A9Á5A6Á6A9c #ójK—|dkDrd–—d}td«|dzz}tj|«dz}t|d||«D]Q}t|d|||z«Ed{–—†t    t t ||z|||z«««|||z|||z…<||z}ŒSt|d|«Ed{–—†y7ŒR7Œ­w)zdYield the primes less than n.
 
    >>> list(sieve(30))
    [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
    rer¬)rrfrfN)Ú    bytearrayÚmathÚisqrtr"Úbytesr]r¨)rRrWÚdataÚlimitr±s     rLr8r8zsÌèø€ð     ˆ1‚uØŠØ €EÜ VÓ   Q¡Ñ '€DÜ J‰Jq‹M˜AÑ €EÜ ˜˜a ¨Ó .òˆÜ˜d A u¨a°!©eÓ4×4Ð4Ü"'¬¬E°!°a±%¸¸AÀ¹EÓ,BÓ(CÓ"DˆˆQ‰UQ˜˜Q™Ð ÑØA‘‰ðô˜$  5Ó)×)Ñ)ð    5øð*ús%‚AB3ÁB/ÁA B3Â)B1Â*B3Â1B3c#óàK—|dkr td«‚t|«}tt||««x}r8|rt    |«|k7r td«‚|–—tt||««x}rŒ7yy­w)aŽBatch data into tuples of length *n*. If the number of items in
    *iterable* is not divisible by *n*:
    * The last batch will be shorter if *strict* is ``False``.
    * :exc:`ValueError` will be raised if *strict* is ``True``.
 
    >>> list(batched('ABCDEFG', 3))
    [('A', 'B', 'C'), ('D', 'E', 'F'), ('G',)]
 
    On Python 3.13 and above, this is an alias for :func:`itertools.batched`.
    rfzn must be at least onezbatched(): incomplete batchN)r¤r^rpr r])rSrRrFržÚbatchs     rLÚ_batchedr Œspèø€ð    ˆ1‚uÜÐ1Ó2Ð2Ü     ˆh‹€BÜœ  A›Ó'Ð
'ˆ%Ð
'Ù ”c˜%“j A’oÜÐ:Ó;Ð ;ØŠ ôœ  A›Ó'Ð
'ˆ%Ó
'ùs ‚A)A.Á,A.i¢ )rcó—t|||¬«S)NrE)Úitertools_batched)rSrRrFs   rLrr£s€Ü  ¨1°VÔ<Ð<rNcó—t|ŽS)a Swap the rows and columns of the input matrix.
 
    >>> list(transpose([(1, 2, 3), (11, 22, 33)]))
    [(1, 11), (2, 22), (3, 33)]
 
    The caller should ensure that the dimensions of the input are compatible.
    If the input is empty, no output will be produced.
    )Ú _zip_strict©ržs rLr@r@¬s€ô ˜Ð ÐrNcó@—ttj|«|«S)zÆReshape the 2-D input *matrix* to have a column count given by *cols*.
 
    >>> matrix = [(0, 1), (2, 3), (4, 5)]
    >>> cols = 3
    >>> list(reshape(matrix, cols))
    [(0, 1, 2), (3, 4, 5)]
    )rrro)ÚmatrixÚcolss  rLr1r1¸s€ô ”5×&Ñ& vÓ.°Ó 5Ð5rNc óx—t|d«}tttt    |t |«««|«S)zÚMultiply two matrices.
 
    >>> list(matmul([(7, 5), (3, 5)], [(2, 5), (7, 9)]))
    [(49, 80), (41, 60)]
 
    The caller should ensure that the dimensions of the input matrices are
    compatible with each other.
    r)r]rrrçrr@)Úm1Úm2rRs   rLr#r#Ãs0€ô     ˆBˆq‰E‹
€AÜ ”7œ8¤W¨R´¸2³Ó%?Ó@À!Ó DÐDrNc#ó¤K—ttj|«dz«D]}||zrŒ    |–—||z}|dk(ry||zsŒŒ |dkDr|–—yy­w)zTYield the prime factors of n.
 
    >>> list(factor(360))
    [2, 2, 2, 3, 3, 5]
    rfN)r8rr)rRÚprimes  rLrrÐsdèø€ô ”t—z‘z !“} qÑ(Ó)òˆØe“)ØŠKØ %‰KˆAؐAŠvÙð    e”)ðð     ˆ1‚uØ‹ð ùs‚*A­AÁ Ac    óœ—t|«}|dk(r|dzSttt|«t    t |«««}t ||«S)zÜEvaluate a polynomial at a specific value.
 
    Example: evaluating x^3 - 4 * x^2 - 17 * x + 60 at x = 2.5:
 
    >>> coefficients = [1, -4, -17, 60]
    >>> x = 2.5
    >>> polynomial_eval(coefficients, x)
    8.125
    r)r]rUÚpowrÚreversedr¨rç)Ú coefficientsrJrRÚpowerss    rLr+r+àsF€ô     ˆLÓ€A؈A‚vؐ1‰uˆ Ü ””f˜Q“i¤¬%°«(Ó!3Ó 4€FÜ L &Ó )Ð)rNcó$—tt|«ŽS)zfReturn the sum of the squares of the input values.
 
    >>> sum_of_squares([10, 20, 30])
    1400
    )rçrrs rLr;r;ñs€ô ”S˜“WÐ ÐrNcóŠ—t|«}ttd|««}tt    t
j ||««S)aCompute the first derivative of a polynomial.
 
    Example: evaluating the derivative of x^3 - 4 * x^2 - 17 * x + 60
 
    >>> coefficients = [1, -4, -17, 60]
    >>> derivative_coefficients = polynomial_derivative(coefficients)
    >>> derivative_coefficients
    [3, -8, -17]
    rf)r]rr¨rPrUrrrs)rrRrs   rLr-r-ús6€ô     ˆLÓ€AÜ ”e˜A˜q“kÓ "€FÜ ””H—L‘L ,°Ó7Ó 8Ð8rNcóN—tt|««D] }||z|dz
z}Œ|S)zReturn the count of natural numbers up to *n* that are coprime with *n*.
 
    >>> totient(9)
    6
    >>> totient(12)
    4
    rf)r»r)rRr±s  rLr?r?    s4€ô”˜“‹^òˆØ ‰Fa˜!‘eÑ ‰ðð €HrN)rrI)r¢N)NF)NN)rN)]Ú__doc__rrrÚ collectionsrÚcollections.abcrÚ    functoolsrrÚ    itertoolsrrr    r
r r r rrrrrÚrandomrrrÚsysrÚ__all__Úobjectr”r}rr›rÿrçr>r<r=rr%rr­r0r(r'r$rrr6r€r)rƒÚ ImportErrorr¤r…r˜r r r7r*r.rCrDrBr!rr5r4r3r2r&r/rrrAr9r:r,r"r8r rr r@r1r#rr+r;r-r?rËrNrLú<module>r+sðñó ÛåÝ!ß%÷ ÷ ÷ ó ÷-Ñ,Ýò/ €ñb ‹(€ð,ÙˆtÕñ˜# dÔ+€Kñ 4˜Ñ$AÓ B€ò %ó 'ò$3ó$%+óP
4ó=ð*!ó$ò )ð €ò;ò.ò    ,ó.ò6 ð    )Ý8ò
,ð!×(Ñ(€HÔô˜Jôòò /ó %=òP(ò$Dò8Nó**óZ JóPó& ó>1ð("#ô1ó("ò$ +ò +ò"'òT $ò'ò,/òBòò( 6ò0ó(òV*ð$%*ôð(ÒÝ6à',õ=ð€Gà×&Ñ&€G„Oò    ò6ò
Eò ò *ò"ò 9ó  øðaò؃KðûðZòØ‚Hðús$Á    E%Â&E3Å%E0Å/E0Å3E=Å<E=