提交记录 185131


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_v41f1017_agg4 1005e7. 【模板题】高精度除法×100 Accepted 100 108.407 ms 87172 KB C++17 97.07 KB
提交时间 评测时间
2026-11-20 18:55:02 2026-11-20 18:55:09
/* 1005e7 seat r9, account saffah_v41f1017_agg4, 2026-11-20.
   ARM 2: the denominator (Short=false) forward is CHUNK-BLOCKED, on top of ARM 1 (the Short-path fusion
   already banked as https://duck.ac/submission/185124, 108,892.431 us).
   Base body = https://duck.ac/submission/184839 (our own Accepted, 110,059.0 us).
   ARM 1 (unchanged here): forward<true>'s CRT packing loop and the level-18 DIF top pass are fused; each of
   the four level-18 DIF arm positions computes its packed value inline (same fetchPair b,n,2*j, same
   rotating roots RS={0,2,1} by (j/2)%3 with A=R,B=(R+1)%3, same x / x*roots / x*cconj(roots)).
   ARM 2 (new): forward<false> used to pack the WHOLE 3-plane set (12.6 MiB of CRT stores) and then run
   three dh<1> DIFs whose level-18 top pass immediately re-read those 12.6 MiB. It now walks the level-18
   index space in 64-position chunks: for each chunk the four arm ranges are packed with the SAME
   handleCRT<R,false> calls under the SAME R schedule R=RS[(j>>1)%3], then the same
   fft_split_radix_dif_butterfly body runs on that chunk for the three planes while the chunk is still
   L1-resident, and finally the unchanged tail recursion b8<H/2>, b8<H/4>, b8<H/4> runs per plane. The top
   loop's iterations are position-independent and all of them still complete before the recursion, so the
   values are identical; no arithmetic, no table, no R schedule changes. Nothing else is touched: the
   inverse DIT, pair/pair2x, saveCRT and the carry fold are as in 184839.
   Value gates (both byte-identical to the standing body): random 10M/5M fixture quotient md5
   3a9c98199ce73ed25f332ed94994403f; pinned full fixture in_onenl.txt (15,000,001 B) quotient sha256
   7edef7deefc3732ebb61ce5ef0621b0af813ef58d6ede1e16fd4accee753325c.
   Judge measurement via the custom-test oracle on the same synthesized 15,000,002-byte input:
   ARM 1 alone 122.96 -> 121.50 ms (fwdq 51.11M -> 46.23M ticks); ARM 1+2 -> 121.09 ms
   (cold forward 26.92M -> 25.44M ticks, fwdq 46.31M and inv3 33.98M unchanged).
   原始账号 / Original account: saffah_v41f1017_agg4.
   使用来源 / Submission URL used: https://duck.ac/submission/185124 (our own Accepted, ARM 1) on top of
   https://duck.ac/submission/184839 (our own Accepted); through them https://duck.ac/submission/182666
   (rival body) and https://duck.ac/submission/180587 (our own).
   使用内容 / What was used: our own Accepted bodies, with ARM 1 (Short-path fusion) and ARM 2 (chunk-blocked
   Short=false forward) as described above; all inherited citations and notices are retained verbatim below.
   许可合规 / Licence compliance: all upstream citations, the With-Sky HintFFT copyright notice and its MIT
   licence text are retained verbatim below; every cited submission is a public Duck submission.
   目的 / Purpose: collapse the CRT-packing store/re-read round trip for the denominator forward too, so the
   strict bar 109,092.070 us (0.99*T+1, T = 110,193 us) is held with real margin rather than 199.6 us.
*/
/* Seat 1005e7_s4, account saffah_v41f1017_agg4, lane 1005e7, 2026-11-19.
 原始账号 / Original account: saffah_v41f1017_agg4.
 使用来源 / Submission URL used: https://duck.ac/submission/182666 (rival body, 110.193 ms, Accepted,
   user saffah_codex62a_agg6), which is itself derived from our own Accepted body
   https://duck.ac/submission/180587 (saffah_v41f1017_agg4).
 使用内容 / What was used: the 182666 body VERBATIM -- the CRT three-row forward packing, the bit-reversed
   root tables, the conjugate-difference pair2x identity, the restructured inverse stage and the biased
   unsigned carry fold. Every arithmetic token equals 182666; only this header block is new, and the
   file was value-gated 14/14 byte-identical against our Accepted 180587 body.
 许可合规 / Licence compliance: all upstream citations, the With-Sky HintFFT copyright notice and its MIT
   licence text are retained verbatim below; every cited submission is a public Duck submission.
 目的 / Purpose: bank the adopted body's judge time on our account and re-price the lane.
   Working target 109,092.070 us (strict bar 0.99*T+1, T = 110,193 us, our best 110,989 us).
*/
/*1005e7_ref 2026-11-20: pragma-only arm - adds unroll-loops (the one flag the pack is missing); no code/operand/store changed; value-gated on the FULL 5,000,001-digit quotient sha256 7edef7deefc3732ebb61... (the only real gate on this lane; the old o_base.txt came from an unknown input). Purpose: compile-axis sweep with a real gate. */

/* 引用本账号 saffah_codex62a_agg6 https://duck.ac/submission/182223 的互质三路变换、https://duck.ac/submission/181613 中普通乘积的共轭差校正恒等式;所有原始来源与许可保留如下。 */
/* 引用 I. J. Good, The Interaction Algorithm and Practical Fourier Analysis (1958), https://doi.org/10.1111/j.2517-6161.1958.tb00300.x 的互质分解思想,独立实现。引用本账号 saffah_codex62a_agg6 https://duck.ac/submission/180764 的三路循环余数、位反转共轭运算及原除法,保留原列来源及许可。 */
/* 引用 saffah_v41f1017_agg4 https://duck.ac/submission/180587 的三路循环 FFT、成对频点和 256 位复数运算。另参考本账号 saffah_codex62a_agg6 https://duck.ac/submission/180448 的无符号基数偏置。原始上游引用、With-Sky 的 HintFFT 版权声明和 MIT 许可完整保留。 */
/* ARM (seat 1005e7_s1, saffah_v41f1017_agg4, lane 1005e7, 2026-11-19).
Account / 账号: saffah_v41f1017_agg4, seat 1005e7_s1.
What was used / 使用内容: our own judge-Accepted bodies on this lane, all posted
today by this seat:
  https://duck.ac/submission/179916 (114,989.943) -- the verbatim adoption of
    https://duck.ac/submission/176975, itself our own 175249, plus always-inline
    FMA butterflies, align-loops=64 + sched-pressure, elision of the 4-limb
    quotient-estimate memmove for certified consumers, and the two-limb (pair2)
    carry fold;
  https://duck.ac/submission/180519 (113,977.765) -- that body plus 2-wide
    Complex2 (AVX2, four doubles) versions of the tricycle forward<Short>
    packing loop and the final inverse-combine loop.
This arm adds two further Complex2 stages of the same tricycle, both purely
local rewrites of the parent body:
  (a) the DENOMINATOR radix-3 packing (forward<false>) is peeled into three
      tiers -- all three input planes in range (3 complex multiplies per two
      twiddles), then the tier where the z plane is provably all-zero
      (4H+2j+2 >= n, which drops one 32-bit load pair, one complex add and
      one complex multiply), then a scalar tail that gains the same z == 0
      specialisation.  y-z with z == 0 is y and turn(y-0)*c is turn(y)*c
      exactly, so every tier is bit-identical to the original expression;
  (b) the tricycle pair() stage is done two pairs at a time.  In both hot loops
      the partner index is m = C - j, so adjacent calls (j, j+1) have p
      ascending by one and m descending by one: one 256-bit load at left+m-1
      holds the two m-operands in reversed 128-bit halves, a
      vperm2f128(a,a,1) restores them, and the same swap sends the two
      results back to left[m-1], left[m].  The twiddle pair is materialised
      with setr_pd (the two phase indices are unrelated bit-reversals).  Every
      elementwise operation is the Complex2 operator that already corresponds
      to its scalar counterpart, and the scalar expressions are unchanged.
Licence compliance / 许可说明: public duck.ac submissions declare no separate
licence; the body is used under the campaign attribution rule (account +
submission URL + content + status).  The complete inherited authorship and
reference chain, and the With-Sky HintFFT MIT notice that the parent body
carries, are retained unchanged below in the order they appear there.  No
GPL-3.0 JudgeDuck OS source is included or linked; its public ABI constants are
referenced only.
Purpose / 试验目的: reduce the two largest remaining non-FFT blocks of
tricycle::reduce (denominator packing ~22M local ticks, pair stage ~28M) to
close the live strict bar on this lane.
Value gate / 数值门: quotient byte-identical to the Accepted 179916 body on all
fourteen lane shapes (four official-shape 10,000,000/5,000,000 draws, all-9,
m14, all9_m14, 4m/1.5m, 3m/1m, 6m/3m, 2m/1m, 500k, pow10, all-zero, generated
10M/5M) -- 14/14 -- and 36/36 exact against an INDEPENDENT CPython big-integer
reference on random shapes from 100 to 80,000 digits, including a<b.
 */
/* ARM (seat 1005e7_s1, saffah_v41f1017_agg4, lane 1005e7, 2026-11-19).
Account / 账号: saffah_v41f1017_agg4, seat 1005e7_s1.
What was used / 使用内容: our own judge-Accepted body on this lane,
https://duck.ac/submission/179916 (time_us_precise 114,989.943, Accepted), which
is the verbatim adoption of https://duck.ac/submission/176975 -- itself our own
https://duck.ac/submission/175249 -- plus (a) always-inline FMA butterflies with
align-loops=64 and sched-pressure, (b) elision of the 4-limb quotient-estimate
memmove for its certified consumers, and (c) a two-limb (pair2) carry fold that
halves the serial floor-division chain.  This arm adds, verbatim from a
previously built and gated but never posted sibling body of the same seat,
(d) 2-wide Complex2 (AVX2, 4 doubles) SIMD versions of the tricycle
forward<Short> packing loop and the final inverse-combine loop: conj, the 120
degree turn, the 0.5/0.866025403784438646763723 scalings and the twiddle-pair
load become one 256-bit FMA/mul sequence per two twiddles.  Arithmetic is
unchanged and lane-exact: the same real/imaginary FMA forms, the same constants,
only paired.  Every other line of the parent body is untouched.
Licence compliance / 许可说明: public duck.ac submissions declare no separate
licence; the body is used under the campaign attribution rule (account +
submission URL + content + status).  The complete inherited authorship and
reference chain, and the With-Sky HintFFT MIT notice that the parent body
carries, are retained unchanged below in the order they appear there.  No
GPL-3.0 JudgeDuck OS source is included or linked; its public ABI constants are
referenced only.
Purpose / 试验目的: this is the mechanism union of the two arms that were built
on this lane -- the Accepted armADF pair2/useUns body and the never-posted
Complex2 SIMD butterflies -- priced against the live strict bar.
Value gate / 数值门: quotient byte-identical to the Accepted 179916 body on all
fourteen lane shapes (four official-shape 10,000,000/5,000,000 draws, all-9,
m14, all9_m14, 4m/1.5m, 3m/1m, 6m/3m, 2m/1m, 500k, pow10, all-zero, generated
10M/5M) -- 14/14 -- and 36/36 exact against an INDEPENDENT CPython big-integer
reference on random shapes from 100 to 80,000 digits, including a<b.
 */
/* ADOPTION (seat 1005e7_s1, saffah_v41f1017_agg4, lane 1005e7, 2026-11-19).
Original account: saffah_codex62a_agg6.
Source / 来源: https://duck.ac/submission/176975 -- complete Accepted C++17
submission for problem 1005e7 (Accepted, score 100, official 116.354399 ms,
posted 2026-11-19 03:39:54), rank 1 on this lane at the time of adoption.
What was used / 使用内容: the complete submitted source, adopted VERBATIM
-- this notice block is the only addition; every byte of program text below is
unchanged. That public body is itself our own https://duck.ac/submission/175249
(complete adaptive multiprecision divider, guarded quotient windows, normalized
carry/FFT engine, scratch arena and decimal formatter) plus (a) the cyclic
product / end-around-carry interior-remainder reconstruction attributed below
to https://duck.ac/submission/176934, (b) a 4 KiB-aligned scratch allocation
with an 8192-byte margin, (c) a 256-limb window overlap in place of the
incumbent's 8192, (d) I/O descriptor discovery through getauxval, and (e) the
transparent-hugepage probe disabled (el() returns 0).
Licence compliance / 许可说明: public duck.ac submissions declare no separate
licence; the body is used under the campaign attribution rule (account +
submission URL + content + status). The complete inherited authorship,
reference chain and the With-Sky HintFFT MIT notice that the source body
carries are retained unchanged below, in the order they appear there. No
GPL-3.0 JudgeDuck OS source is included or linked; its public ABI constants
are referenced only.
Purpose / 试验目的: bank this judge-Accepted body on lane 1005e7 before any
invented change, so that every later arm is priced from a T-parity base. Value
gate: byte-identical quotient to our incumbent https://duck.ac/submission/175249
on all lane shapes (four official-shape 10,000,000/5,000,000 draws, all-9 and
m14 shapes, 4m/1.5m, 3m/1m, 6m/3m, 2m/1m, 500k, pow10, all-zero).
 */
/* References: saffah_codex62a_agg6 https://duck.ac/submission/176934 for using a cyclic product and an end-around carry to reconstruct a certified interior remainder. All butterfly and division engine references follow. */
/* References
 * saffah_v41f1017_agg4 https://duck.ac/submission/175249: complete adaptive
 * multiprecision divider, guarded quotient windows, normalized carry/FFT engine,
 * scratch arena and decimal formatter. All inherited notices and licenses below.
 * saffah_codex62a_agg6 https://duck.ac/submission/175313 and JudgeDuck
 * https://github.com/JudgeDuck/JudgeDuck-OS/blob/master/inc/abi.hpp supply the
 * documented standard I/O descriptor tag and fields. No GPL-3.0 OS code linked
 * or copied. The submitted program uses the normal C library auxiliary-vector API.
 */
/* ARM (seat 1005e7_s2, saffah_v41f1017_agg4, lane 1005e7, 2026-11-18).
Purpose / 试验目的: the correction product pv = qe*b was fully converted from
 coefficients to limbs although only pv[0..n+1) is ever read (the remainder
 subtract abs_sub(rv,pv,rv,n+1,n+1)); its high limbs are consulted only by a
 pv <= W comparison that the body's own 4-limb tail-guard quotient
 certificate already makes redundant.  This arm therefore (1) extends that
 certificate, which the body applied only to the final window (pos==0), to the
 interior windows, and (2) truncates the coefficient->limb conversion of the
 correction product at n+1 limbs for certified windows -- a pure deletion of
 conversion traffic and of one 516K-limb comparison.  A guard is added: on the
 certified path, if the remainder ever comes out >= b the routine returns
 false and the caller's pre-existing generic division fallback runs, so a bad
 certificate can only cost speed, never correctness.
References / 引用:
 * saffah_codex_6a_agg3 https://duck.ac/submission/174238 : complete Accepted
   10,000,000/5,000,000-digit divider (the body adopted by this lineage).
 * saffah_v41f1017_agg4 https://duck.ac/submission/174453 : retained
   abs_compare_normalized 4-limb-per-iteration scan.
Value gate: quotient byte-identical to the incumbent on all fourteen lane
 shapes (four official-shape 10M/5M draws, all-9 and m14 shapes, 4m/1.5m,
 3m/1m, 6m/3m, 2m/1m, 500k, pow10, all-zero).
 */
/* ARM (seat 1005e7_s1, saffah_v41f1017_agg4, lane 1005e7, 2026-11-18).
Purpose / 试验目的: price the one engine cut that was built and gated by an
 earlier seat but never officially measured on this lineage --
 abs_compare_normalized's descending limb scan made 4 limbs per iteration with
 baseline SSE2 (pcmpeqd + pmovmskb + lzcnt) before falling back to the identical
 scalar loop. Arithmetic and every constant are unchanged: the routine returns
 the same sign for the same inputs, and the arm's own gate reproduced the
 adopted body's quotient BYTE FOR BYTE on all thirteen lane shapes (the four
 10,000,000/5,000,000 draws r1/r2/r3/all-9, m14, all9_m14, 3m/1m, 4m/1.5m,
 3m, 2m/1m, 500k, pow10_a, zeros_a). No other line of the adopted body is
 touched. Inherited authorship and the HintFFT MIT notice below are retained
 unchanged, in the order they appear.
 */
/* ADOPTION (seat 1005e7_s1, saffah_v41f1017_agg4, lane 1005e7, 2026-11-18).
References / 引用:
 * saffah_codex_6a_agg3 https://duck.ac/submission/174238: complete Accepted
   10,000,000/5,000,000-digit divider, official 125,187 us (time_us_precise
   125,186.842), C++17, rank 1 on this lane at the time of adoption. This
   submission adopts that body VERBATIM, and nothing else: not one byte of
   arithmetic, constant, buffer, allocation, prefetch, root-table, arena or
   qualification logic was changed. Every author, source URL and licence notice
   already carried in that body is retained below, in the order it appears
   there, unaltered.
 * The adopted body's own reference chain (below) credits saffah_codex_6a_agg3
   https://duck.ac/submission/173241 and https://duck.ac/submission/173712, and
   saffah_codex61s_agg5 https://duck.ac/submission/172911 (which itself credits
   our https://duck.ac/submission/169986), plus the inherited recursive
   division, HintFFT butterflies, factorized roots, carry/borrow normalization,
   reciprocal certification, allocation and I/O implementation chain, TSKY /
   WithSky / With-Sky's HintFFT and the earlier saffah_codex_maker, guess,
   saffah_cc_v41_agg1, saffah_v41f1017_agg4, pdoom and saffah_codex61s_agg5
   submissions.
Licence compliance: public duck.ac submissions declare no separate licence; the
 body is used under the campaign attribution rule (account + submission URL +
 content + status), and the complete inherited authorship and HintFFT MIT
 notice chain that the source body carries is reproduced unchanged below.
Purpose / 试验目的: bank the faster, already-Accepted rank-1 body on this lane
 before any further work, so that every later arm is priced from a T-parity base
 instead of a 7,254 us deficit. Our own gate reproduced the adopted body's
 quotient byte for byte against an independent exact-division certificate on ten
 lane shapes, and it additionally repairs a latent all-nines quotient bug that
 our previous Accepted body carried.
 */
/* References:saffah_codex_6a_agg3 https://duck.ac/submission/173241: complete borrowed-root divider; saffah_codex_6a_agg3 https://duck.ac/submission/173712: signed unit-cube FMA coefficients, ported here. Full inherited sources/MIT remain below. */
/* References / 引用:
Direct implementation: saffah_codex61s_agg5 https://duck.ac/submission/172911 supplies the complete ten-million-digit divider and vector unit-cube third roots, based on https://duck.ac/submission/172674 for that root-power idea.
Our saffah_codex_6a_agg3 https://duck.ac/submission/170862 supplies checked stdout-root borrowing, filled-watermark reservation and dirty-arena quotient initialization fixes.
Inherited sources below each provide parts of the retained recursive division, HintFFT butterflies, factorized roots, carry/borrow normalization, reciprocal certification, allocation and I/O implementation. Authors are checked against their original public submission pages. No independent additional licence is stated on the Duck wrappers. TSKY / WithSky / With-Sky provide the HintFFT foundation, https://github.com/With-Sky/HintFFT; comply with its MIT licence by preserving the full copyright, permission and disclaimer below.
TSKY: https://duck.ac/submission/19388; inherited implementation and ideas as above.
saffah_codex_maker: https://duck.ac/submission/125697, https://duck.ac/submission/125698, https://duck.ac/submission/125699; inherited implementation and ideas as above.
guess: https://duck.ac/submission/125815; inherited implementation and ideas as above.
saffah_codex_6a_agg3: https://duck.ac/submission/125838, https://duck.ac/submission/128088, https://duck.ac/submission/128089, https://duck.ac/submission/128090, https://duck.ac/submission/128206, https://duck.ac/submission/128715, https://duck.ac/submission/128716, https://duck.ac/submission/128717, https://duck.ac/submission/128944, https://duck.ac/submission/129643, https://duck.ac/submission/129661, https://duck.ac/submission/129675, https://duck.ac/submission/129678, https://duck.ac/submission/129689, https://duck.ac/submission/129695, https://duck.ac/submission/129699, https://duck.ac/submission/129798, https://duck.ac/submission/129799, https://duck.ac/submission/129809, https://duck.ac/submission/129832, https://duck.ac/submission/129844, https://duck.ac/submission/129912, https://duck.ac/submission/133513, https://duck.ac/submission/133548, https://duck.ac/submission/133715, https://duck.ac/submission/133803, https://duck.ac/submission/133817, https://duck.ac/submission/134237, https://duck.ac/submission/139245, https://duck.ac/submission/139343, https://duck.ac/submission/139500, https://duck.ac/submission/139676, https://duck.ac/submission/139886, https://duck.ac/submission/139909, https://duck.ac/submission/139940, https://duck.ac/submission/170862; inherited implementation and ideas as above.
saffah_cc_v41_agg1: https://duck.ac/submission/127028, https://duck.ac/submission/127032, https://duck.ac/submission/127038, https://duck.ac/submission/128181, https://duck.ac/submission/128184, https://duck.ac/submission/128189, https://duck.ac/submission/128669, https://duck.ac/submission/128672, https://duck.ac/submission/128693, https://duck.ac/submission/128968, https://duck.ac/submission/129632, https://duck.ac/submission/129760, https://duck.ac/submission/129872, https://duck.ac/submission/129880, https://duck.ac/submission/130655, https://duck.ac/submission/130680, https://duck.ac/submission/130729, https://duck.ac/submission/130808; inherited implementation and ideas as above.
saffah_v41f1017_agg4: https://duck.ac/submission/131978, https://duck.ac/submission/133440, https://duck.ac/submission/133530, https://duck.ac/submission/133631, https://duck.ac/submission/133972, https://duck.ac/submission/134308, https://duck.ac/submission/134329, https://duck.ac/submission/134350, https://duck.ac/submission/139316, https://duck.ac/submission/139375, https://duck.ac/submission/139387, https://duck.ac/submission/139578, https://duck.ac/submission/139609, https://duck.ac/submission/139768, https://duck.ac/submission/139808, https://duck.ac/submission/140939, https://duck.ac/submission/141756, https://duck.ac/submission/146199, https://duck.ac/submission/146239, https://duck.ac/submission/151489, https://duck.ac/submission/152716, https://duck.ac/submission/152898, https://duck.ac/submission/159465, https://duck.ac/submission/159724, https://duck.ac/submission/160657, https://duck.ac/submission/169986; inherited implementation and ideas as above.
pdoom: https://duck.ac/submission/139637, https://duck.ac/submission/139665; inherited implementation and ideas as above.
saffah_codex61s_agg5: https://duck.ac/submission/145834, https://duck.ac/submission/145862, https://duck.ac/submission/148817, https://duck.ac/submission/149569, https://duck.ac/submission/149620, https://duck.ac/submission/151770, https://duck.ac/submission/152971, https://duck.ac/submission/157560, https://duck.ac/submission/159489, https://duck.ac/submission/159498, https://duck.ac/submission/160902, https://duck.ac/submission/160903, https://duck.ac/submission/161002, https://duck.ac/submission/161194, https://duck.ac/submission/172674, https://duck.ac/submission/172911; inherited implementation and ideas as above.

MIT License
Copyright (c) 2023 With-Sky
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/* Idea / 思路: Combine the current four-consumer unit-cube FFT engine with checked lifetime-disjoint root storage in the unused stdout arena. Reserve its 1M-complex high-water capacity immediately; preserve only initialized roots on any growth, retain ordinary owned fallback, and never free borrowed memory. Retain a separate filled watermark and explicitly initialize both quotient work storage and the zero-quotient correction product so dirty reused pages cannot influence certification. Arithmetic finishes before output overwrites these roots.
Experiment purpose / 试验目的: Test ownership transitions, dirty borrowed and ordinary storage, full nine million/ten-million-digit GMP quotients and guards, then obtain formal Duck timing. No local runtime determines acceptance. */
/* Idea: Fold the imaginary-lane sign into the triple-angle polynomial FMA constants, eliminating one sign XOR per upper unit-root cube. Keep the ten-million division plan and safe borrowed arena. Purpose: complete GMP divisions/dirty arena/ownership guards and official timing. */
/* Approach: compute each certified interior remainder modulo B^1572864-1.
 * Pack even and odd limbs into complex pairs, split into a radix-three stage
 * and three binary transforms, and retain the denominator spectrum across
 * windows. Combine the mirror bins before the inverse and fold both dividend
 * and signed carry around the modulus. Experiment: use a transform just above
 * the divisor length and omit the leading zero arms of each quotient. */
/* 本次思路与实验目的:相邻两个位反转下标相隔半周期,第二个旋转因子直接由第一个变号。反向因子拆表低位数 10(零表示沿用常规取相位);双肢除法偏置 1。测量节省的查表与乘法。 */
/* 本次实验:给复数系数指定模三和模 2^18 的坐标,频率取 3h+2^18r。每两点只需选择复数半向量来轮换三行,两个方向均省去长度相关的三路旋转乘数。实数打包按新的三行共轭映射恢复,短输入模式 1,展开 12,频率拆表 11,预取 0。 */
/* 本次实验:把共轭成对的偶奇乘积展开为 A·B、A′·B′ 和共用的 -(1+W)(A−A′)(B−B′)/4,运用于互质三路频率排列。除数修正缓存模式 0,归一化前移 1,乘法顺序 0,拆表 11。 */
__asm__(".section .text.unlikely,\"ax\"\n\t.fill 1024,1,0x90\n");

#include <algorithm>
#include <atomic>
#include <complex>
#include <future>


#include <random>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <immintrin.h>
static __SIZE_TYPE__ g_cv_stop=0;
#define aa const
#define ab size_t
#define ac input
#define ad BASE_x
#define ae Complex
#define af data
#define ag return
#define ah UINT_64
#define ai len2
#define aj len1
#define ak double
#define al void
#define am constexpr
#define an rank
#define ao __m256d
#define ap long
#define aq unsigned
#define ar tmp3
#define au hintx
#define av Complex2
#define aw shift
#define ax template
#define ay nullptr
#define az UINT_32
#define aA carry
#define aB SIZE_TYPE
#define aC tmp0
#define aD tmp1
#define aE _mm256_add_pd
#define aF imag
#define aG _mm256_sub_pd
#define aH real
#define aI __m256i
#define aJ tmp2
#define aK else
#define aL need
#define aM fft_ary
#define aN ary_ptr
#define aO dividend
#define aP quot
#define aQ size
#define aR divisor
#define aS false
#define aT typename
#define aU __m128i
#define aV bool
#define aW while
#define aX fft_2point
#define aY static
#define aZ sizeof
#define a0 fft_len
#define a1 INT_64
#define a3 char
#define a5 result
#define a6 value
#define a7 resize
#define a8 inline
#define a9 length
#define ba borrow
#define bb _mm256_permute_pd
#define bc tmp7
#define bd R101A_LD
#define bf R101A_ST
#define bg half
#define bh ary_true_len
#define bj high
#define bk operator
#define bn _mm256_mul_pd
#define bo static_cast
#define bp target
#define bq scale
#define br change_length
#define bs quo_digit
#define bt true
#define bu Integer
#define bv _mm256_set1_pd
#define bw auto
#define bx throw
#define bz table1
#define bA tmp5
#define bB omega
#define bC _mm256_xor_pd
#define bD squared_inverse_input
#define bE begin
#define bF base_len
#define bG hintvector
#define bH using
#define bI set_true_len
#define bJ base
#define bK TABLE
#define bL quarter
#define bM new_size
#define bN next
#define bO table3
#define bP tmp6
#define bQ omega_cube
#define bR quarter_len
#define bS HintVector
#define bT prod
#define bU residue
#define bV conv_res_len
#define bW swap
#define bX _mm_loadu_si128
#define bY SQUARE
#define bZ abs_sub
#define b0 _mm256_store_pd
#define b1 align
#define b3 bytes
#define b5 INT_32
#define b6 vec_size
#define b7 _mm256_permute2f128_pd
#define b8 fft_split_radix_dif_template
#define b9 this
#define ca HpVec
#define cb _mm256_load_pd
#define cc uintptr_t
#define cd delete
#define ce half_len
#define cf abs_compare_normalized
#define cg packed_coeff
#define ch store
#define ci AlignedComplexVec
#define cj hint_log2
#define ck ary_copy
#define cl fft_split_radix_dit_template
#define cm digits
#define cn change_sign
#define co SIZE_80
#define cp product
#define cq _mm256_set1_epi16
#define cr g_fft_raw
#define cs HpComplexVec
#define ct is_neg
#define cu SizeType
#define cv tmp4
#define cw __attribute__
#define cx string
#define cz SIZE_TYPE_BITS
#define cA ones
#define cB roots
#define cC im_sign
#define cD each
#define cE coeff
#define cF multiplier
#define cG quot_len
#define cH workp
#define cI AlignedAlloc32
#define cJ free
#define cK rounded
#define cL chains
#define cM normalized_dividend
#define cN noexcept
#define cO reinterpret_cast
#define cP _mm256_cvtepi32_pd
#define cQ ComplexTableY
#define cT sign_n_len
#define cU ele_size
#define cV LEN_MAX
#define cW last_rem
#define cX _mm_cvtsi128_si64
#define cY _mm_packus_epi32
#define cZ old_roots
#define c3 half_v
#define c4 setsize
#define c5 trial_top
#define c6 dividend_2digits
#define c7 sub_len
#define c8 quot_tmp
#define da _mm256_add_epi16
#define dc struct
#define dd _mm256_addsub_pd
#define de max_shift
#define dg _mm256_setr_pd
#define dh fft_dif_template
#define dj capacity
#define do packed_len
#define dq starts
#define dr _mm256_lddqu_si256
#define ds quot_tmp_len
#define dt dividend_ptr
#define du string_in
#define dw malloc
#define dx memcpy
#define dy namespace
#define dA _mm256_storeu_pd
#define dB expand
#define dC unit_root
#define dE cos_1_8
#define dF _mm_loadu_pd
#define dG R101A_SIGNIM
#define dH log_len
#define dI fft_dit_template
#define dK abs_compare
#define dN packed
#define dO abs_add
#define dP fft_mul
#define dQ reverse_index
#define dR scale_v
#define dS coefficient
#define dX assign
#define dZ _mm256_storeu_si256
#define d1 divisor_2digits
#define d3 sub_cache
#define d4 groups
#define d6 abs_rec_div
#define d9 ten_recip
#define ea pair_coefficient
#define ec _mm256_mulhi_epu16
#define ed _mm256_mullo_epi16
#define eh g_fft_buf
#define ej g_fft_cap
#define ek g_thp_ok
#define el thp_ok
#define em g_real_reciprocal
#define en source1
#define eo source2
#define eq omega_data
#define es omega3_data
#define eu get_omega
#define ex inv_scale
#define ey fft_square_split_dit
#define ez new_length
#define eC carry_add
#define eD prod_len
#define eG tail_guard
#define eH ret_rem
#define eI divisor_ptr
#define eJ _mm256_setr_epi32
#define eK _mm256_permutevar8x32_epi32
#define eM mul_neg_i
#define eP posix_memalign
#define eR MADV_HUGEPAGE
#define eU _mm_unpacklo_epi32
#define eV _mm_unpackhi_epi32
#define eX cur_log_size
#define eZ fft_split_radix_dit_butterfly
#define e0 omega_sqr
#define e1 _mm256_blend_pd
#define e4 fill_element
#define e5 size_func
#define e7 hint_arithm
#define e8 is_carry
#define e9 abs_mul_num
#define fa _mm_storeu_si128
#define fc _mm_cvtepu16_epi32
#define fd _mm_cvtsi64_si128
#define fe continue
#define ff fft_capacity
#define fg sq_scale
#define fi cache_divisor
#define fk cache_fft
#define fl cache_ready
#define fo _mm256_round_pd
#define fp _MM_FROUND_TO_NEG_INF
#define fq _MM_FROUND_NO_EXC
#define fr _mm256_fmadd_pd
#define fu _mm256_and_pd
#define fy triple_cache
#define fz multiply_trial
#define fC prod_cache
#define fD product_need
#define fE work_owned
#define fF trunc_top
#define fG DataType
#define fI first_num
#define fJ str_size
#define fK hundred_recip
#define fM _mm256_slli_epi16
#define fP _mm256_setzero_pd
#define fQ element_permute
#define fR deallocate
#define fS g_real_roots
#define fT g_real_divisor
#define fU g_real_divisor_len
#define fV g_real_divisor_ready
#define fW g_real_reciprocal_len
#define fX g_real_reciprocal_ready
#define f0 __builtin_clzll
#define f4 hint_transform
#define f7 max_log_size
#define f9 binary_reverse_swap
#define ga fft_split_radix_dif_butterfly
#define gb _mm256_insertf128_pd
#define gc _mm256_castpd128_pd256
#define gd fft_dif_8point_x2
#define gf R101A_MC18
#define gg fft_dif_4point_x2
#define gi fft_dit_8point_x2
#define gj fft_dit_4point_x2
#define go fft_square_dit_dispatch
#define gp fft_dif_zero_half
#define gr size_generator
#define gw abs_div_num
#define gB pack_forward
#define gF Prechecked
#define gG trial_recip
#define gK newton_divq
#define gM final_certified
#define gS normalized_divisor
#define gU DecimalLookup
#define gV DECIMAL_LU
#define g6 g_real_divisor_fft
#define g7 g_real_reciprocal_fft
#define he com_ary_combine_copy
#define hr square_single_eight
#define hH _mm256_cvttpd_epi32
#define hM newton_middle_step
#define hQ LONG_DIV_THRESHOLD
#define h8 _mm256_packus_epi32
#define ib _mm256_unpacklo_epi16
#define id _mm256_unpackhi_epi16
#include <sys/mman.h>
#ifndef HINT_SIMD_HPP
#define HINT_SIMD_HPP
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("align-functions=32","align-loops=64","rename-registers")
#pragma GCC optimize("web")
#pragma GCC optimize("sched-pressure")
#pragma GCC optimize("align-functions=64")
#pragma GCC target("fma")
bH ae=std::complex<ak>;dc av
{ao af;av()
{af=fP();}av(ak ac)
{af=bv(ac);}av(ao ac)
{af=ac;}av(aa av&ac)
{af=ac.af;}av(ak aa*ptr)
{af=_mm256_loadu_pd(ptr);}av(ae a)
{af=_mm256_broadcast_pd((__m128d*)&a);}av(aa ae*ptr)
{af=cb((aa ak*)ptr);}av root_cube()aa{const __m256d sq=_mm256_mul_pd(data,data);const __m256d fac=_mm256_fmsub_pd(sq,_mm256_setr_pd(4.,-4.,4.,-4.),_mm256_setr_pd(3.,-3.,3.,-3.));return Complex2(_mm256_mul_pd(data,fac));}
al clr()
{af=fP();}al ch(ae*a)aa
{b0((ak*)a,af);}ax<int M>
av fQ()aa
{ag bb(af,M);}av all_real()aa
{ag _mm256_movedup_pd(af);}av all_imag()aa
{ag fQ<0XF>();}av bW()aa
{ag fQ<0X5>();}av eM()aa
{aY aa ao subber{};ag av(dd(subber,af)).bW();}av bk+(av ac)aa
{ag aE(af,ac.af);}av bk-(av ac)aa
{ag aG(af,ac.af);}av bk*(av ac)aa
{bw aF=bn(all_imag().af,ac.bW().af);ag _mm256_fmaddsub_pd(all_real().af,ac.af,aF);}av bk/(av ac)aa
{ag _mm256_div_pd(af,ac.af);}};
#endif
#include <cstdlib>
aY std::complex<ak> *eh=ay;aY al*cr=ay;aY ab ej=0;ax<aT T>
dc cI
{bH value_type=T;cI()cN=default;ax<aT U>
cI(aa cI<U> &)cN{}T*allocate(std::ab n)
{al*raw=std::dw(n*aZ(T)+64);if(raw==ay)
{bx("alloc error");}cc p=((cc)raw+16+31)&~(cc)31;cO<al**>(p)[-1]=raw;ag cO<T*>(p);}al fR(T*p,std::ab)cN
{std::cJ(cO<al**>(p)[-1]);}ax<aT U>
aV bk==(aa cI<U> &)aa cN{ag bt;}ax<aT U>
aV bk!=(aa cI<U> &)aa cN{ag aS;}};aY int el(){return 0;}aY a3*root_output_arena=ay;aY ab root_output_capacity=0;
dc cs{ae*p=ay;al*bJ=ay;ab n=0,cap=0;ab aw=4096;cs()=default;explicit cs(ab idx):aw(4096+idx*8192){}~cs(){if(bJ)std::cJ(bJ);}ab aQ()aa{ag n;}ae*af(){ag p;}aa ae*af()aa{ag p;}ae&bk[](ab i){ag p[i];}aa ae&bk[](ab i)aa{ag p[i];}al grow(ab m){al*q=ay;ae*dst=ay;if(aw==4096&&root_output_arena&&m<=(root_output_capacity>4160?(root_output_capacity-4160)/aZ(ae):0)){dst=(ae*)(((uintptr_t)root_output_arena+63)&~(uintptr_t)63);dst=(ae*)((a3*)dst+4096);}aK if(el()){ab b1=(ab)(2u<<20);ab b3=m*aZ(ae)+aw;ab cK=(b3+b1-1)&~(b1-1);if(eP(&q,b1,cK)!=0||!q)bx("alloc error");madvise(q,cK,eR);dst=(ae*)((a3*)q+aw);}aK{ab b3=m*aZ(ae)+128;q=std::dw(b3);if(!q)bx("alloc error");dst=(ae*)(((cc)q+63)&~(cc)31);}if(p){if(dst!=p)std::dx(dst,p,n*aZ(ae));std::cJ(bJ);}bJ=q;p=dst;cap=m;}al a7(ab m){if(m<=n){n=m;ag;}if(m>cap){ab nc=cap?cap*2:m;if(nc<m)nc=m;grow(nc);}n=m;}};dc ci{
ae*p=ay;ab n=0,cap=0;
ci()=default;
ci(aa ci&)=cd;
ci&bk=(aa ci&)=cd;
ci(ci&&o)cN:p(o.p),n(o.n),cap(o.cap){o.p=ay;o.n=o.cap=0;}
~ci(){if(p)cI<ae>().fR(p,cap);}
ab aQ()aa{ag n;}ae*af(){ag p;}aa ae*af()aa{ag p;}
ae&bk[](ab i){ag p[i];}aa ae&bk[](ab i)aa{ag p[i];}
al a7(ab m){if(m>cap){ab c=std::max(m,cap*2);ae*q=cI<ae>().allocate(c);if(p){std::dx(q,p,n*aZ(ae));cI<ae>().fR(p,cap);}p=q;cap=c;}n=m;}
};aY cs fS{0};aY ab gTF=0;aY aa al*fT=ay;aY ab fU=0;aY cs g6{1};aY aV fV=aS;aY aa al*em=ay;aY ab fW=0;aY aa al*gY=ay;aY cs g7{2};aY aV fX=aS;dy au
{bH UINT_8=uint8_t;bH UINT_16=uint16_t;bH az=uint32_t;bH ah=uint64_t;bH b5=int32_t;bH a1=int64_t;bH LONG=ap;bH ae=std::complex<ak>;am ak HINT_PI=3.1415926535897932384626433832795;am ak HINT_2PI=HINT_PI*2;ax<aT T>
am T min_2pow(T n)
{if(n<=1)ag T(1);if am(aZ(T)<=4)
ag T(1u<<(32-__builtin_clz((aq)(n-1))));aK
ag T(1ull<<(64-f0((aq ap ap)(n-1))));}ax<aT T>
a8 al ary_clr(T*ptr,ab len)
{memset(ptr,0,len*aZ(T));}ax<aT T>
am aV ct(T x)
{ag x<0;}ax<aT T>
am ab cj(T n)
{T res=0;aW(n>1)
{n/=2;res++;}ag res;}ax<aT T>
am aV is_odd(T x)
{ag bo<aV>(x&1);}ax<aT T>
am std::pair<T,T>div_mod(T a,T b)
{ag std::make_pair(a/b,a%b);}ax<aT T>
al ck(T*bp,aa T*source,ab len)
{if(len==0||bp==source)
{ag;}if(len>=INT64_MAX)
{bx("Ary too long\n");}std::dx(bp,source,len*aZ(T));}ax<aT T>
a8 T*ary_realloc(T*ptr,ab len)
{if(len*aZ(T)<INT64_MAX)
{ptr=bo<T*>(realloc(ptr,len*aZ(T)));}if(ptr==ay)
{bx("realloc error");}ag ptr;}ax<aT T>
am T max_2pow(T n)
{T res=1;res<<=(aZ(T)*8-1);aW(res>n)
{res/=2;}ag res;}am ah qpow(ah m,ah n,ah mod)
{if(m<=1)
{ag m;}ah a5=1;aW(n>0)
{if((n&1)!=0)
{a5=a5*m%mod;}m=m*m%mod;n>>=1;}ag a5;}am ah mod_inv(ah n,ah mod)
{ag qpow(n,mod-2,mod);}ax<aT T>
a8 al he(ae*bp,aa T&en,ab aj,aa T&eo,ab ai){aa ab min_len=std::min(aj,ai);ab i=0;aa aU zero=_mm_setzero_si128();for(;i+4<=min_len;i+=4){aa aU a=bX((aa aU*)(&en[i]));aa aU b=bX((aa aU*)(&eo[i]));dA((ak*)(bp+i),cP(eU(a,b)));dA((ak*)(bp+i+2),cP(eV(a,b)));}for(;i<min_len;i++)bp[i]=ae(en[i],eo[i]);for(;i+4<=aj;i+=4){aa aU a=bX((aa aU*)(&en[i]));dA((ak*)(bp+i),cP(eU(a,zero)));dA((ak*)(bp+i+2),cP(eV(a,zero)));}for(;i<aj;i++)bp[i]=ae(en[i],0.0);for(;i+4<=ai;i+=4){aa aU b=bX((aa aU*)(&eo[i]));dA((ak*)(bp+i),cP(eU(zero,b)));dA((ak*)(bp+i+2),cP(eV(zero,b)));}for(;i<ai;i++)bp[i]=ae(0.0,eo[i]);}dy f4
{class ComplexTableY {
std::vector<AlignedComplexVec> table1;
INT_32 max_log_size=2,cur_log_size=2;
ComplexTableY(const ComplexTableY&)=delete;
ComplexTableY&operator=(const ComplexTableY&)=delete;
public:
const Complex*omega_data(INT_32 shift)const{return table1[shift].data();}
~ComplexTableY(){}
ComplexTableY(UINT_32 max_shift){max_shift=std::max<size_t>(max_shift,1);max_log_size=max_shift;table1.resize(max_shift+1);for(int j=0;j<3;++j){table1[j].resize(1);table1[j][0]=Complex(1,0);}
#if TABLE_PRELOAD == 1
expand(max_shift);
#endif
}
void expand(INT_32 shift){shift=std::max<INT_32>(shift,2);if(shift>max_log_size)throw("FFT length too long for lut\n");
for(INT_32 level=cur_log_size+1;level<=shift;level++){
const size_t len=size_t(1)<<level,count=len/4;table1[level].resize(count);
Complex*dst1=table1[level].data();const Complex*src1=table1[level-1].data();
if(count==2){dst1[0]=Complex(1,0);dst1[1]=std::conj(unit_root(8,1));continue;}
const Complex unit1=std::conj(unit_root(len,1));
const __m256d r1=_mm256_set1_pd(unit1.real()),i1=_mm256_set1_pd(unit1.imag());
const bool root_nt=count>=16384;
for(size_t pos=0;pos<count/2;pos+=2){const __m256d a=_mm256_load_pd((const double*)(src1+pos));
const __m256d z1=_mm256_fmaddsub_pd(a,r1,_mm256_mul_pd(_mm256_permute_pd(a,5),i1));
const __m256d lo1=_mm256_permute2f128_pd(a,z1,0x20),hi1=_mm256_permute2f128_pd(a,z1,0x31);
double*p1=(double*)(dst1+2*pos);if(root_nt){_mm256_stream_pd(p1,lo1);_mm256_stream_pd(p1+4,hi1);}else{_mm256_store_pd(p1,lo1);_mm256_store_pd(p1+4,hi1);}}
if(root_nt)_mm_sfence();}cur_log_size=std::max(cur_log_size,shift);}
static Complex unit_root(double theta){return std::polar<double>(1.0,theta);}
static Complex unit_root(size_t m,size_t n){return unit_root((HINT_2PI*n)/m);}
Complex get_omega(UINT_32 shift,size_t n)const
{size_t rank=1ull<<shift;const size_t rank_ff=rank-1,quad_n=n<<2;size_t zone=quad_n>>shift;if((quad_n&rank_ff)==0)
{static constexpr Complex ONES[4]={Complex(1,0),Complex(0,-1),Complex(-1,0),Complex(0,1)};return ONES[zone];}Complex tmp;if((zone&2)==0)
{if((zone&1)==0)
{tmp=table1[shift][n];}else
{tmp=table1[shift][rank/2-n];tmp.real(-tmp.real());}}else
{if((zone&1)==0)
{tmp= -table1[shift][n-rank/2];}else
{tmp=table1[shift][rank-n];tmp.imag(-tmp.imag());}}return tmp;}
const Complex*zz_d1(UINT_32 s)const{return table1[s].data();}
Complex2 get_omegaX2(UINT_32 shift,size_t n)const{return Complex2(table1[shift].data()+n);}
};am ab lut_max_rank=23;aY cQ bK(lut_max_rank);ax<aT T>
al f9(T&ary,ab len)
{ab i=0;for(ab j=1;j<len-1;j++)
{ab k=len>>1;i^=k;aW(k>i)
{k>>=1;i^=k;};if(j<i)
{std::bW(ary[i],ary[j]);}}}ax<aT cu=az,aT T>
al quaternary_reverse_swap(T&ary,ab len)
{cu log_n=cj(len);cu*rev=new cu[len/4];rev[0]=0;for(cu i=1;i<len;i++)
{cu index=(rev[i>>2]>>2)|((i&3)<<(log_n-2));if(i<len/4)
{rev[i]=index;}if(i<index)
{std::bW(ary[i],ary[index]);}}cd[]rev;}ax<aT T>
a8 al aX(T&sum,T&diff)
{T aC=sum;T aD=diff;sum=aC+aD;diff=aC-aD;}a8 al fft_4point(ae*ac,ab an=1)
{ae aC=ac[0];ae aD=ac[an];ae aJ=ac[an*2];ae ar=ac[an*3];aX(aC,aJ);aX(aD,ar);ar=ae(ar.aF(),-ar.aH());ac[0]=aC+aD;ac[an]=aJ+ar;ac[an*2]=aC-aD;ac[an*3]=aJ-ar;}a8 al fft_dit_4point(ae*ac,ab an=1)
{ae aC=ac[0];ae aD=ac[an];ae aJ=ac[an*2];ae ar=ac[an*3];aX(aC,aD);aX(aJ,ar);ar=ae(ar.aF(),-ar.aH());ac[0]=aC+aJ;ac[an]=aD+ar;ac[an*2]=aC-aJ;ac[an*3]=aD-ar;}a8 al fft_dit_8point(ae*ac,ab an=1)
{ae aC=ac[0];ae aD=ac[an];ae aJ=ac[an*2];ae ar=ac[an*3];ae cv=ac[an*4];ae bA=ac[an*5];ae bP=ac[an*6];ae bc=ac[an*7];aX(aC,aD);aX(aJ,ar);aX(cv,bA);aX(bP,bc);ar=ae(ar.aF(),-ar.aH());bc=ae(bc.aF(),-bc.aH());aX(aC,aJ);aX(aD,ar);aX(cv,bP);aX(bA,bc);aY am ak dE=0.70710678118654752440084436210485;bA=dE*ae(bA.aF()+bA.aH(),bA.aF()-bA.aH());bP=ae(bP.aF(),-bP.aH());bc= -dE*ae(bc.aH()-bc.aF(),bc.aH()+bc.aF());ac[0]=aC+cv;ac[an]=aD+bA;ac[an*2]=aJ+bP;ac[an*3]=ar+bc;ac[an*4]=aC-cv;ac[an*5]=aD-bA;ac[an*6]=aJ-bP;ac[an*7]=ar-bc;}a8 al fft_dif_4point(ae*ac,ab an=1)
{ae aC=ac[0];ae aD=ac[an];ae aJ=ac[an*2];ae ar=ac[an*3];aX(aC,aJ);aX(aD,ar);ar=ae(ar.aF(),-ar.aH());ac[0]=aC+aD;ac[an]=aC-aD;ac[an*2]=aJ+ar;ac[an*3]=aJ-ar;}a8 al fft_dif_8point(ae*ac,ab an=1)
{ae aC=ac[0];ae aD=ac[an];ae aJ=ac[an*2];ae ar=ac[an*3];ae cv=ac[an*4];ae bA=ac[an*5];ae bP=ac[an*6];ae bc=ac[an*7];aX(aC,cv);aX(aD,bA);aX(aJ,bP);aX(ar,bc);aY am ak dE=0.70710678118654752440084436210485;bA=dE*ae(bA.aF()+bA.aH(),bA.aF()-bA.aH());bP=ae(bP.aF(),-bP.aH());bc= -dE*ae(bc.aH()-bc.aF(),bc.aH()+bc.aF());aX(aC,aJ);aX(aD,ar);aX(cv,bP);aX(bA,bc);ar=ae(ar.aF(),-ar.aH());bc=ae(bc.aF(),-bc.aH());ac[0]=aC+aD;ac[an]=aC-aD;ac[an*2]=aJ+ar;ac[an*3]=aJ-ar;ac[an*4]=cv+bA;ac[an*5]=cv-bA;ac[an*6]=bP+bc;ac[an*7]=bP-bc;}a8 al fft_radix2_dit_butterfly(ae bB,ae*ac,ab an)
{ae aC=ac[0];ae aD=ac[an]*bB;ac[0]=aC+aD;ac[an]=aC-aD;}a8 al fft_radix2_dif_butterfly(ae bB,ae*ac,ab an)
{ae aC=ac[0];ae aD=ac[an];ac[0]=aC+aD;ac[an]=(aC-aD)*bB;}a8 al eZ(ae bB,ae bQ,
ae*ac,ab an)
{ae aC=ac[0];ae aD=ac[an];ae aJ=ac[an*2]*bB;ae ar=ac[an*3]*bQ;aX(aJ,ar);ar=ae(ar.aF(),-ar.aH());ac[0]=aC+aJ;ac[an]=aD+ar;ac[an*2]=aC-aJ;ac[an*3]=aD-ar;}a8 al ga(ae bB,ae bQ,
ae*ac,ab an)
{ae aC=ac[0];ae aD=ac[an];ae aJ=ac[an*2];ae ar=ac[an*3];aX(aC,aJ);aX(aD,ar);ar=ae(ar.aF(),-ar.aH());ac[0]=aC;ac[an]=aD;ac[an*2]=(aJ+ar)*bB;ac[an*3]=(aJ-ar)*bQ;}a8 al eZ(av bB,av bQ,
ae*ac,ab an)
{av aC=ac;av aD=ac+an;av aJ=av(ac+an*2)*bB;av ar=av(ac+an*3)*bQ;aX(aJ,ar);ar=ar.eM();(aC+aJ).ch(ac);(aD+ar).ch(ac+an);(aC-aJ).ch(ac+an*2);(aD-ar).ch(ac+an*3);}a8 al ga(av bB,av bQ,
ae*ac,ab an)
{av aC=(ac);av aD=(ac+an);av aJ=(ac+an*2);av ar=(ac+an*3);aX(aC,aJ);aX(aD,ar);ar=ar.eM();aC.ch(ac);aD.ch(ac+an);((aJ+ar)*bB).ch(ac+an*2);((aJ-ar)*bQ).ch(ac+an*3);}a8 al fft_radix4_dit_butterfly(ae bB,ae e0,ae bQ,
ae*ac,ab an)
{ae aC=ac[0];ae aD=ac[an]*bB;ae aJ=ac[an*2]*e0;ae ar=ac[an*3]*bQ;aX(aC,aJ);aX(aD,ar);ar=ae(ar.aF(),-ar.aH());ac[0]=aC+aD;ac[an]=aJ+ar;ac[an*2]=aC-aD;ac[an*3]=aJ-ar;}a8 al fft_radix4_dif_butterfly(ae bB,ae e0,ae bQ,
ae*ac,ab an)
{ae aC=ac[0];ae aD=ac[an];ae aJ=ac[an*2];ae ar=ac[an*3];aX(aC,aJ);aX(aD,ar);ar=ae(ar.aF(),-ar.aH());ac[0]=aC+aD;ac[an]=(aJ+ar)*bB;ac[an*2]=(aC-aD)*e0;ac[an*3]=(aJ-ar)*bQ;}a8 al fft_conj(ae*ac,ab a0,ak div=1)
{for(ab i=0;i<a0;i++)
{ac[i]=std::conj(ac[i])/div;}}a8 al fft_normalize(ae*ac,ab a0)
{ak len=bo<ak>(a0);for(ab i=0;i<a0;i++)
{ac[i]/=len;}}
#define R101A_LD(K, N) ao v##K = gb(gc(dF((aa ak *)(in +(K)))),dF((aa ak *)(in +(N)+(K))),1);
#define R101A_ST(R, K, N) _mm_storeu_pd((ak *)(in +(K)),_mm256_castpd256_pd128(R));_mm_storeu_pd((ak *)(in +(N)+(K)),_mm256_extractf128_pd(R,1));
#define R101A_SIGNIM _mm256_castsi256_pd(_mm256_setr_epi64x(0, (long long)0x8000000000000000LL, 0, (long long)0x8000000000000000LL))
#define R101A_C18 _mm256_set1_pd(0.70710678118654752440084436210485)
#define R101A_MC18 _mm256_set1_pd(-0.70710678118654752440084436210485)
cw((bp("fma")))cw((always_inline))a8 al gd(ae*in)
{bd(0,8)bd(1,8)bd(2,8)bd(3,8)
bd(4,8)bd(5,8)bd(6,8)bd(7,8)
ao s04=aE(v0,v4),d04=aG(v0,v4);ao s15=aE(v1,v5),d15=aG(v1,v5);ao s26=aE(v2,v6),d26=aG(v2,v6);ao s37=aE(v3,v7),d37=aG(v3,v7);aa ao sg=dG;{ao v=d15;d15=bn(R101A_C18,bb(dd(bb(v,0x5),v),0x5));}d26=bC(bb(d26,0x5),sg);{ao v=d37;d37=bn(gf,dd(v,bb(v,0x5)));}ao u0=aE(s04,s26),u2=aG(s04,s26);ao u1=aE(s15,s37),u3=aG(s15,s37);ao u4=aE(d04,d26),u6=aG(d04,d26);ao u5=aE(d15,d37),u7=aG(d15,d37);u3=bC(bb(u3,0x5),sg);u7=bC(bb(u7,0x5),sg);bf(aE(u0,u1),0,8)bf(aG(u0,u1),1,8)
bf(aE(u2,u3),2,8)bf(aG(u2,u3),3,8)
bf(aE(u4,u5),4,8)bf(aG(u4,u5),5,8)
bf(aE(u6,u7),6,8)bf(aG(u6,u7),7,8)
}cw((bp("fma")))cw((always_inline))a8 al gg(ae*in)
{bd(0,4)bd(1,4)bd(2,4)bd(3,4)
ao s02=aE(v0,v2),d02=aG(v0,v2);ao s13=aE(v1,v3),d13=aG(v1,v3);d13=bC(bb(d13,0x5),dG);bf(aE(s02,s13),0,4)bf(aG(s02,s13),1,4)
bf(aE(d02,d13),2,4)bf(aG(d02,d13),3,4)
}a8 ao ex(ak inv){ag dg(inv,-2.0*inv,inv,-2.0*inv);}a8 ao bD(ao v,ao bq){aa ao squared=bn(v,v);aa ao aH=aG(squared,bb(squared,5));aa ao cross=bn(v,bb(v,5));ag bn(e1(aH,cross,10),bq);}ax<aV bY=aS>
cw((bp("fma")))cw((always_inline))a8 al gi(ae*in,ak inv=0)
{aa ao _sc=ex(inv);bd(0,8)if am(bY)v0=bD(v0,_sc);bd(1,8)if am(bY)v1=bD(v1,_sc);bd(2,8)if am(bY)v2=bD(v2,_sc);bd(3,8)if am(bY)v3=bD(v3,_sc);bd(4,8)if am(bY)v4=bD(v4,_sc);bd(5,8)if am(bY)v5=bD(v5,_sc);bd(6,8)if am(bY)v6=bD(v6,_sc);bd(7,8)if am(bY)v7=bD(v7,_sc);ao s01=aE(v0,v1),d01=aG(v0,v1);ao s23=aE(v2,v3),d23=aG(v2,v3);ao s45=aE(v4,v5),d45=aG(v4,v5);ao s67=aE(v6,v7),d67=aG(v6,v7);aa ao sg=dG;d23=bC(bb(d23,0x5),sg);d67=bC(bb(d67,0x5),sg);ao w0=aE(s01,s23),w2=aG(s01,s23);ao w1=aE(d01,d23),w3=aG(d01,d23);ao w4=aE(s45,s67),w6=aG(s45,s67);ao w5=aE(d45,d67),w7=aG(d45,d67);{ao v=w5;w5=bn(R101A_C18,bb(dd(bb(v,0x5),v),0x5));}w6=bC(bb(w6,0x5),sg);{ao v=w7;w7=bn(gf,dd(v,bb(v,0x5)));}bf(aE(w0,w4),0,8)bf(aE(w1,w5),1,8)
bf(aE(w2,w6),2,8)bf(aE(w3,w7),3,8)
bf(aG(w0,w4),4,8)bf(aG(w1,w5),5,8)
bf(aG(w2,w6),6,8)bf(aG(w3,w7),7,8)
}ax<aV bY=aS>
cw((bp("fma")))cw((always_inline))a8 al gj(ae*in,ak inv=0)
{aa ao _sc=ex(inv);bd(0,4)if am(bY)v0=bD(v0,_sc);bd(1,4)if am(bY)v1=bD(v1,_sc);bd(2,4)if am(bY)v2=bD(v2,_sc);bd(3,4)if am(bY)v3=bD(v3,_sc);ao s01=aE(v0,v1),d01=aG(v0,v1);ao s23=aE(v2,v3),d23=aG(v2,v3);d23=bC(bb(d23,0x5),dG);bf(aE(s01,s23),0,4)bf(aE(d01,d23),1,4)
bf(aG(s01,s23),2,4)bf(aG(d01,d23),3,4)
}ax<ab LEN>
al cl(ae*ac)
{am ab dH=cj(LEN);am ab ce=LEN/2,bR=LEN/4;cl<ce>(ac);if am(bR==8)
{gi(ac+ce);}aK if am(bR==4)
{gj(ac+ce);}aK
{cl<bR>(ac+ce);cl<bR>(ac+ce+bR);}aa ae*_om1=bK.eq(dH);for(ab i=0;i<bR;i+=2)
{bw bB=av(_om1+i);bw bQ=bB.root_cube();if((i&3u)==0){_mm_prefetch((aa a3*)(ac+i+128),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+i+bR+128),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+i+2*bR+128),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+i+3*bR+128),_MM_HINT_T0);}eZ(bB,bQ,ac+i,bR);}}ax<>
al cl<0>(ae*ac){}ax<>
al cl<1>(ae*ac){}ax<>
al cl<2>(ae*ac)
{aX(ac[0],ac[1]);}ax<>
al cl<4>(ae*ac)
{fft_dit_4point(ac,1);}ax<>
al cl<8>(ae*ac)
{fft_dit_8point(ac,1);}cw((bp("fma")))cw((always_inline))a8 al hr(ae*in,ak inv){aa ao _sc=ex(inv);ao a=bD(cb((ak*)(in+0)),_sc);ao b=bD(cb((ak*)(in+2)),_sc);ao c=bD(cb((ak*)(in+4)),_sc);ao d=bD(cb((ak*)(in+6)),_sc);ao v0=b7(a,c,0x20),v1=b7(a,c,0x31);ao v2=b7(b,d,0x20),v3=b7(b,d,0x31);ao s01=aE(v0,v1),d01=aG(v0,v1);ao s23=aE(v2,v3),d23=aG(v2,v3);d23=bC(bb(d23,5),dG);ao w0=aE(s01,s23),w2=aG(s01,s23);ao w1=aE(d01,d23),w3=aG(d01,d23);ao t1=bn(R101A_C18,bb(dd(bb(w1,5),w1),5));ao t2=bC(bb(w2,5),dG);ao t3=bn(gf,dd(w3,bb(w3,5)));w1=e1(w1,t1,12);w2=e1(w2,t2,12);w3=e1(w3,t3,12);ao lo01=b7(w0,w1,0x20),hi01=b7(w0,w1,0x31);ao lo23=b7(w2,w3,0x20),hi23=b7(w2,w3,0x31);b0((ak*)(in+0),aE(lo01,hi01));b0((ak*)(in+4),aG(lo01,hi01));b0((ak*)(in+2),aE(lo23,hi23));b0((ak*)(in+6),aG(lo23,hi23));}ax<ab LEN>
al ey(ae*ac,ak inv){if am(LEN==8){hr(ac,inv);}aK if am(LEN<=8){aa ao _sc=ex(inv);for(ab i=0;i+2<=LEN;i+=2)
b0((ak*)(ac+i),bD(cb((aa ak*)(ac+i)),_sc));if am(LEN==1)ac[0]=std::conj(ac[0]*ac[0]*inv);cl<LEN>(ac);}aK{am ab bg=LEN/2,bL=LEN/4,lg=cj(LEN);ey<bg>(ac,inv);if am(bL==8)gi<bt>(ac+bg,inv);aK if am(bL==4)gj<bt>(ac+bg,inv);aK{ey<bL>(ac+bg,inv);ey<bL>(ac+bg+bL,inv);}aa ae*_om1=bK.eq((b5)lg);for(ab i=0;i<bL;i+=2){if((i&3u)==0){_mm_prefetch((aa a3*)(ac+i+64),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+bL+i+64),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+2*bL+i+64),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+3*bL+i+64),_MM_HINT_T0);}eZ(av(_om1+i),av(_om1+i).root_cube(),ac+i,bL);}}}ax<ab LEN=1>
al go(ae*ac,ab a9,ak inv){if am(LEN<(1u<<24)){if(a9>LEN){go<LEN*2>(ac,a9,inv);ag;}bK.dB(cj(LEN));ey<LEN>(ac,inv);}}ax<ab LEN>
al b8(ae*ac)
{am ab dH=cj(LEN);am ab ce=LEN/2,bR=LEN/4;aa ae*_om1=bK.eq(dH);for(ab i=0;i<bR;i+=2)
{bw bB=av(_om1+i);bw bQ=bB.root_cube();if((i&3u)==0){_mm_prefetch((aa a3*)(ac+i+128),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+i+bR+128),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+i+2*bR+128),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+i+3*bR+128),_MM_HINT_T0);}ga(bB,bQ,ac+i,bR);}b8<ce>(ac);if am(bR==8)
{gd(ac+ce);}aK if am(bR==4)
{gg(ac+ce);}aK
{b8<bR>(ac+ce);b8<bR>(ac+ce+bR);}}ax<>
al b8<0>(ae*ac){}ax<>
al b8<1>(ae*ac){}ax<>
al b8<2>(ae*ac)
{aX(ac[0],ac[1]);}ax<>
al b8<4>(ae*ac)
{fft_dif_4point(ac,1);}ax<>
al b8<8>(ae*ac)
{fft_dif_8point(ac,1);}ax<ab LEN=1>
al dI(ae*ac,ab a0)
{if(a0>LEN)
{dI<LEN*2>(ac,a0);ag;}bK.dB(cj(LEN));cl<LEN>(ac);}ax<>
al dI<1<<24>(ae*ac,ab a0){}ax<ab LEN=1>
al dh(ae*ac,ab a0)
{if(a0>LEN)
{dh<LEN*2>(ac,a0);ag;}bK.dB(cj(LEN));b8<LEN>(ac);}ax<>
al dh<1<<24>(ae*ac,ab a0){}ax<ab LEN=16>
al gp(ae*ac,ab a0)
{if am(LEN<(1u<<24))
{if(a0>LEN)
{gp<LEN*2>(ac,a0);ag;}am ab bg=LEN/2,bL=LEN/4,lg=cj(LEN);bK.dB(lg);aa ae*_om1=bK.eq(lg);for(ab i=0;i<bL;i+=2){if((i&3u)==0){_mm_prefetch((aa a3*)(ac+i+64),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+bL+i+64),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+bg+i+64),_MM_HINT_T0);_mm_prefetch((aa a3*)(ac+bg+bL+i+64),_MM_HINT_T0);}aa av a(ac+i),b(ac+bL+i);aa av bi=b.eM();((a+bi)*av(_om1+i)).ch(ac+bg+i);((a-bi)*av(_om1+i).root_cube()).ch(ac+bg+bL+i);}b8<bg>(ac);if am(bL==8)
{gd(ac+bg);}aK if am(bL==4)
{gg(ac+bg);}aK
{b8<bL>(ac+bg);b8<bL>(ac+bg+bL);}}}a8 al fft_dit(ae*ac,ab a0,aV bit_rev=bt)
{a0=max_2pow(a0);if(bit_rev)
{f9(ac,a0);}dI<1>(ac,a0);}a8 al fft_dif(ae*ac,ab a0,aV bit_rev=bt)
{a0=max_2pow(a0);dh<1>(ac,a0);if(bit_rev)
{f9(ac,a0);}}}ax<ah ad,aT T>
am al save_num_to_ary(T ary[],ah num,ab digit)
{ab i=digit;aW(i>0)
{i--;ary[i]=num%ad;num/=ad;}}ah stoui64(aa std::cx::const_iterator&bE,
aa std::cx::const_iterator&end,aa az bJ=10)
{ah a5=0;for(bw it=bE;it<end&&it-bE<19;++it)
{a5*=bJ;a3 c=tolower(*it);ah n=0;if(isalnum(c))
{if(isalpha(c))
{n=c-'a'+10;}aK
{n=c-'0';}}if(n<bJ)
{a5+=n;}}ag a5;}ah stoui64(aa std::cx&str,aa az bJ=10)
{ag stoui64(str.bE(),str.end(),bJ);}std::cx ui64to_string(ah ac,UINT_8 cm)
{std::cx a5(cm,'0');for(UINT_8 i=0;i<cm;i++)
{a5[cm-i-1]=bo<a3>(ac%10+'0');ac/=10;}ag a5;}ax<aT T=az,aT aB=az>
class bS
{private:
T*aN=ay;aB cT=0;aB aQ=0;public:
~bS()
{if(aN!=ay)
{cd[]aN;aN=ay;}}bS()
{aN=ay;}bS(aB cU)
{if(cU>0)
{a7(cU);}}bS(aB cU,T ele)
{if(cU>0)
{a7(cU);br(cU);e4(ele,cU);}}bS(aa T*ary,aB len)
{if(ary==ay)
{bx("Can't copy from nullptr\n");}if(len>0)
{a7(len);br(len);ck(aN,ary,len);}}bS(aa bS&ac)
{if(ac.aN!=ay)
{if(aN!=ay)
{cd[]aN;}aN=ay;ab len=ac.a9();a7(len);br(len);cn(ac.sign());ck(aN,ac.aN,len);}}bS(bS&&ac)
{if(ac.aN!=ay)
{aQ=ac.aQ;br(ac.a9());cn(ac.sign());if(aN!=ay)
{cd[]aN;}aN=ac.aN;ac.aN=ay;}}bS&bk=(aa bS&ac)
{if(b9!= &ac)
{if(aN!=ay)
{cd[]aN;}aN=ay;ab len=ac.a9();a7(len);br(len);cn(ac.sign());ck(aN,ac.aN,len);}ag*b9;}bS&bk=(bS&&ac)
{if(b9!= &ac)
{aQ=ac.aQ;br(ac.a9());cn(ac.sign());if(aN!=ay)
{cd[]aN;}aN=ac.aN;ac.aN=ay;}ag*b9;}T&bk[](aB index)aa
{ag aN[index];}T*af()aa
{ag aN;}aY aB gr(aB bM)
{am aB cz=aZ(aB)*8;am aB co=(1ull<<(cz-1));am aB cV=co-1;bM=std::min<aB>(bM,cV);if(bM<=2)
{ag 2;}aK if(bM<=4)
{ag 4;}aB size1=min_2pow(bM);aB size2=size1/2;size2=size2+size2/2;if(bM<=size2)
{ag size2;}aK
{ag size1;}}aB a9()aa
{am aB cz=aZ(aB)*8;am aB co=(1ull<<(cz-1));am aB cV=co-1;ag cT&cV;}aV sign()aa
{am aB cz=aZ(aB)*8;am aB co=(1ull<<(cz-1));ag(co&cT)!=0;}aB dj()aa
{ag aQ;}am al a7(aB bM,aB(e5)(aB)=gr)
{bM=e5(bM);if(aN==ay)
{aQ=bM;aN=new T[aQ];br(0);}aK if(aQ!=bM)
{aQ=bM;aN=ary_realloc(aN,aQ);br(a9());}}am al resize_uninit_hp(aB bM,aB(e5)(aB)=gr)
{bM=e5(bM);if(aN==ay)
{aQ=bM;if(el()){ab b3=(ab)aQ*aZ(T);ab b1=(ab)(2u<<20);ab cK=b3?((b3+b1-1)&~(b1-1)):b1;al*q=ay;if(eP(&q,b1,cK)!=0|| !q)bx("alloc error");madvise(q,cK,eR);aN=bo<T*>(q);}aK{aN=bo<T*>(::bk new[]((ab)aQ*aZ(T)));}br(0);}}al br(aB ez)
{am aB cz=aZ(aB)*8;am aB co=(1ull<<(cz-1));am aB cV=co-1;if(ez>cV)
{bx("Length too long\n");}ez=std::min(ez,aQ);aV sign_tmp=sign();cT=ez;cn(sign_tmp);}al cn(aV is_sign)
{am aB cz=aZ(aB)*8;am aB co=(1ull<<(cz-1));am aB cV=co-1;if((!is_sign)||a9()==0)
{cT=cT&cV;}aK
{cT=cT|co;}}aB bI()
{if(aN==ay)
{ag 0;}aB t_len=a9();aW(t_len>0&&aN[t_len-1]==0)
{t_len--;}br(t_len);ag a9();}al e4(T ele,aB count,aB bE=0)
{if(bE>=aQ||aN==ay)
{ag;}if(bE+count>=aQ)
{count=aQ-bE;}std::fill(aN+bE,aN+bE+count,ele);}};}dy e7
{bH dy au;bH aB=az;ax<aT T>
bH bG=bS<T,aB>;ax<aT T>
am ab bh(aa T&ary,ab len)
{aW(len>0&&ary[len-1]==0)
{len--;}ag len;}ax<aT T>
am b5 dK(aa T ary1[],aa T ary2[],ab aj,ab ai)
{aj=bh(ary1,aj);ai=bh(ary2,ai);if(aj!=ai)
{ag aj>ai?1: -1;}if(ary1==ary2)
{ag 0;}aW(aj>0)
{aj--;T num1=ary1[aj],num2=ary2[aj];if(num1!=num2)
{ag num1>num2?1: -1;}}ag 0;}ax<aT T>
am b5 cf(aa T ary1[],aa T ary2[],ab aj,ab ai)
{if(aj!=ai)
{ag aj>ai?1: -1;}if(ary1==ary2)
{ag 0;}if(aZ(T)==4)
{aW(aj>=4)
{aa aU vx=bX((aa aU*)(aa al*)(ary1+aj-4));aa aU vy=bX((aa aU*)(aa al*)(ary2+aj-4));aq msk=(aq)_mm_movemask_epi8(_mm_cmpeq_epi32(vx,vy));if(msk!=0xffffu)
{aq bad=(~msk)&0xffffu;aq bpos=31-__builtin_clz(bad);aj=aj-4+(bpos>>2);T num1=ary1[aj],num2=ary2[aj];ag num1>num2?1: -1;}aj-=4;}}aW(aj>0)
{aj--;T num1=ary1[aj],num2=ary2[aj];if(num1!=num2)
{ag num1>num2?1: -1;}}ag 0;}ax<ah ad,aV e8=bt,aT T>
am al e9(aa T in[],T num,T out[],ab len)
{len=bh(in,len);num%=ad;ah bT=0;if(num==1)
{ck(out,in,len);}aK
{ab i=0;if am(ad<=10000)
{am ah B2=ad*ad,B3=B2*ad;for(;i+3<=len;i+=3)
{aa ah dN=ah(in[i])+ad*in[i+1]+B2*in[i+2];aa ah a6=dN*num+bT;aa ah upper=a6/B3;aa ah remainder=a6-upper*B3;aa ah bj=remainder/B2;aa az low=(az)(remainder-bj*B2);aa az middle=low/(az)ad;out[i]=T(low-middle*(az)ad);out[i+1]=T(middle);out[i+2]=T(bj);bT=upper;}}for(;i<len;i++)
{bT+=bo<ah>(in[i])*num;std::tie(bT,out[i])=div_mod<ah>(bT,ad);}}if(e8)
{out[len]=bT;}}ax<ah ad,aT T>
am a1 gw(aa T in[],T num,T out[],ab len)
{ab pos=bh(in,len);num%=ad;if(num==1)
{ck(out,in,len);ag 0;}ah cW=0;if am(ad<=10000)
{am ah B2=ad*ad,B3=B2*ad;aW(pos>=3)
{pos-=3;aa ah a6=cW*B3+ah(in[pos+2])*B2
+ah(in[pos+1])*ad+in[pos];aa ah q=a6/num;cW=a6-q*num;out[pos]=T(q%ad);out[pos+1]=T((q/ad)%ad);out[pos+2]=T(q/B2);}}aW(pos>0)
{pos--;cW=cW*ad+in[pos];std::tie(out[pos],cW)=div_mod<ah>(cW,num);}ag cW;}ax<a1 ad,aV e8=bt,aT T>
am al cw((bp("avx2")))__attribute__((target("avx2")))dO(aa T in1[],aa T in2[],T out[],
ab aj,ab ai)
{if(aj<ai)
{std::bW(in1,in2);std::bW(aj,ai);}ab pos=0;ah aA=0;
if constexpr(sizeof(T)==4&&BASE_x<=(1ull<<19)){
const __m256i slots=_mm256_setr_epi32(0,1,2,3,4,5,6,7),ones=_mm256_set1_epi32(1),bv=_mm256_set1_epi32((int)BASE_x);
while(pos+8<=len2){
__m256i a=_mm256_loadu_si256((const __m256i*)(in1+pos)),b=_mm256_loadu_si256((const __m256i*)(in2+pos)),s=_mm256_add_epi32(a,b);
unsigned g=(unsigned)_mm256_movemask_ps(_mm256_castsi256_ps(_mm256_cmpgt_epi32(s,_mm256_set1_epi32((int)BASE_x-1))));
unsigned p=(unsigned)_mm256_movemask_ps(_mm256_castsi256_ps(_mm256_cmpeq_epi32(s,_mm256_set1_epi32((int)BASE_x-1))));
unsigned bits=(p+((g<<1)|(unsigned)carry))^p;
__m256i incoming=_mm256_and_si256(_mm256_srlv_epi32(_mm256_set1_epi32(bits),slots),ones);
__m256i outgoing=_mm256_and_si256(_mm256_srlv_epi32(_mm256_set1_epi32(bits>>1),slots),ones);
__m256i correction=_mm256_mullo_epi32(outgoing,bv);
_mm256_storeu_si256((__m256i*)(out+pos),_mm256_sub_epi32(_mm256_add_epi32(s,incoming),correction));
carry=(bits>>8)&1;pos+=8;
}
}
if am(aZ(T)==4&&ad<=32768)
{am aq ap ap bias=0x10000ull-(aq ap ap)ad;aa aq ap ap biasq=bias*0x0001000100010001ull;aa aU cA=_mm_set1_epi32(-1);aW(pos+4<=ai)
{aa aU a4=bX((aa aU*)(aa al*)(in1+pos));aa aU b4=bX((aa aU*)(aa al*)(in2+pos));aa aq ap ap va=(aq ap ap)cX(cY(a4,cA));aa aq ap ap vb=(aq ap ap)cX(cY(b4,cA));aa aq ap ap v=va+vb+(aq ap ap)aA+biasq;aa aq ap ap m=(v>>15)&0x0001000100010001ull;aa aq ap ap r=v-m*bias;fa((aU*)(al*)(out+pos),
fc(fd((ap ap)r)));aA=1ull-(v>>63);pos+=4;}}aW(pos<ai)
{aA+=(in1[pos]+in2[pos]);out[pos]=aA<ad?aA:aA-ad;aA=aA<ad?0:1;pos++;}aW(pos<aj&&aA>0)
{aA+=in1[pos];out[pos]=aA<ad?aA:aA-ad;aA=aA<ad?0:1;pos++;}ck(out+pos,in1+pos,aj-pos);if(e8)
{out[aj]=aA%ad;}}ax<a1 ad,aT T>
am al bZ(aa T in1[],aa T in2[],T out[],
ab aj,ab ai)
{if(aj<ai)
{ag;}ab pos=0;a1 ba=0;if(aZ(T)==4&&ad<=32768)
{am aq ap ap bias=0x10000ull-(aq ap ap)ad;aa aU cA=_mm_set1_epi32(-1);aW(pos+8<=ai)
{aa aU a4=bX((aa aU*)(aa al*)(in1+pos));aa aU b4=bX((aa aU*)(aa al*)(in2+pos));aa aU a4b=bX((aa aU*)(aa al*)(in1+pos+4));aa aU b4b=bX((aa aU*)(aa al*)(in2+pos+4));aa aq ap ap va=(aq ap ap)cX(cY(a4,cA));aa aq ap ap vb=(aq ap ap)cX(cY(b4,cA));aa aq ap ap va2=(aq ap ap)cX(cY(a4b,cA));aa aq ap ap vb2=(aq ap ap)cX(cY(b4b,cA));aa aq ap ap d0=va-vb-(aq ap ap)ba;aa aq ap ap m=(d0>>15)&0x0001000100010001ull;aa aq ap ap d=d0-m*bias;fa((aU*)(al*)(out+pos),
fc(fd((ap ap)d)));aa aq ap ap carry1=(d0>>63)&1ull;aa aq ap ap d0b=va2-vb2-carry1;aa aq ap ap mb=(d0b>>15)&0x0001000100010001ull;aa aq ap ap db=d0b-mb*bias;fa((aU*)(al*)(out+pos+4),
fc(fd((ap ap)db)));ba=(a1)((d0b>>63)&1ull);pos+=8;}aW(pos+4<=ai)
{aa aU a4=bX((aa aU*)(aa al*)(in1+pos));aa aU b4=bX((aa aU*)(aa al*)(in2+pos));aq ap ap va=(aq ap ap)cX(cY(a4,cA));aq ap ap vb=(aq ap ap)cX(cY(b4,cA));aa aq ap ap d0=va-vb-(aq ap ap)ba;aa aq ap ap m=(d0>>15)&0x0001000100010001ull;aa aq ap ap d=d0-m*bias;fa((aU*)(al*)(out+pos),
fc(fd((ap ap)d)));ba=(a1)((d0>>63)&1ull);pos+=4;}ba=ba?-1:0;}aW(pos<ai)
{ba+=(bo<a1>(in1[pos])-in2[pos]);out[pos]=(T)(ba<0?ba+ad:ba);ba=ba<0?-1:0;pos++;}aW(pos<aj&&ba<0)
{ba+=in1[pos];out[pos]=ba<0?ba+ad:ba;ba=ba<0?-1:0;pos++;}ck(out+pos,in1+pos,aj-pos);}
namespace root_factor23{
constexpr double pi=3.14159265358979323846264338327950288;
constexpr double sine(double x){double z=x,t=x;for(int k=1;k<14;k++){t*=(-x*x)/((2*k)*(2*k+1));z+=t;}return z;}
constexpr double cosine(double x){double z=1,t=1;for(int k=1;k<14;k++){t*=(-x*x)/((2*k-1)*(2*k));z+=t;}return z;}
constexpr ae unit(unsigned j,unsigned n){unsigned u=4*j+n/2,q=u/n;int r=(int)(u%n)-(int)(n/2);double x=(double)r*(pi/2)/(double)n,s=sine(x),c=cosine(x);switch(q&3){case 0:return ae(c,-s);case 1:return ae(-s,-c);case 2:return ae(-c,s);default:return ae(s,c);}}
template<unsigned Count,unsigned Period>struct Table{ae v[Count];constexpr Table():v(){for(unsigned j=0;j<Count;j++)v[j]=unit(j,Period);}};
constexpr Table<2048,2048>high{};
constexpr Table<4096,8388608>low{};
struct Rev8{unsigned char v[256];constexpr Rev8():v(){for(unsigned j=0;j<256;j++){unsigned k=j,y=0;for(int b=0;b<8;b++){y=(y<<1)|(k&1);k>>=1;}v[j]=(unsigned char)y;}}};
constexpr Rev8 reversed{};
static inline ae root(unsigned r){unsigned v=((unsigned)reversed.v[r&255u]<<16)|((unsigned)reversed.v[(r>>8)&255u]<<8)|reversed.v[(r>>16)&255u];v>>=1;const ae a=high.v[v>>12],b=low.v[v&(4096-1)];return ae(a.real()*b.real()-a.imag()*b.imag(),a.real()*b.imag()+a.imag()*b.real());}
}
namespace tricycle {
using Z=std::complex<double>;
constexpr unsigned H=262144,N=6*H;
struct Unit{double r,i;};
constexpr Unit phase(unsigned p){constexpr unsigned period=3*H;
 unsigned k=4*(p%period),q=k/period;
 double x=1.57079632679489661923132169164*(k%period)/period;
 double s=x,c=1,ts=x,tc=1;
 for(unsigned j=1;j<=11;j++){ts*=-x*x/((2*j)*(2*j+1));tc*=-x*x/((2*j-1)*(2*j));s+=ts;c+=tc;}
 return q==0?Unit{c,-s}:q==1?Unit{-s,-c}:q==2?Unit{-c,s}:Unit{s,c};
}
template<unsigned Count,unsigned Step>struct Roots{Unit v[Count];constexpr Roots():v{}{for(unsigned j=0;j<Count;j++)v[j]=phase(j*Step);}};
constexpr unsigned SHIFT=H>=32768?9:6,LOW=1u<<SHIFT;
alignas(64) static constexpr Roots<LOW,1> lo{};
alignas(64) static constexpr Roots<(3*H+LOW-1)/LOW,LOW> hi{};
static inline Z times(Z a,Z b){return Z(__builtin_fma(a.real(),b.real(),-a.imag()*b.imag()),__builtin_fma(a.real(),b.imag(),a.imag()*b.real()));}
static inline Z turn(Z a){return Z(-a.imag(),a.real());}
static inline Z conjz(Z a){return Z(a.real(),-a.imag());}
static inline Z tw(unsigned p){auto x=lo.v[p&(LOW-1)],y=hi.v[p>>SHIFT];return times(Z(x.r,x.i),Z(y.r,y.i));}
static inline unsigned rev(unsigned x){x=((x&0x55555555u)<<1)|((x>>1)&0x55555555u);x=((x&0x33333333u)<<2)|((x>>2)&0x33333333u);
 x=((x&0x0f0f0f0fu)<<4)|((x>>4)&0x0f0f0f0fu);return __builtin_bswap32(x)>>(32-__builtin_ctz(H));}
alignas(4096) static Z left[3*H],right[3*H];static const void*cached;
template<class T>static inline Z readpair(const T*b,unsigned n,unsigned j){if(j+1<n)return Z(double(b[j]),double(b[j+1]));return j<n?Z(double(b[j]),0):Z();}
static inline av cconj(av a){ag av(_mm256_xor_pd(a.af,dG));}
static inline av cturn(av a){ag av(_mm256_mul_pd(_mm256_permute_pd(a.af,5),_mm256_setr_pd(-1.,1.,-1.,1.)));}
static inline av cscale(av a,double c){ag av(_mm256_mul_pd(a.af,_mm256_set1_pd(c)));}
static inline av twpair(unsigned j){av lo2(reinterpret_cast<const ae*>(&lo.v[j&(LOW-1)]));Unit h=hi.v[j>>SHIFT];ag lo2*av(ae(h.r,h.i));}
template<int R>static inline __attribute__((always_inline)) void loadCRT(Z*planes,unsigned j,av x,av y,av z){if constexpr(R==0){av comp0(_mm256_blend_pd(x.af,z.af,12));av comp1(_mm256_blend_pd(y.af,x.af,12));av comp2(_mm256_blend_pd(z.af,y.af,12));av u=comp1+comp2;av v=cscale(cturn(comp1-comp2),-0.866025403784438646763723);av mid=comp0-cscale(u,0.5);(comp0+u).ch(planes+j);(mid+v).ch(planes+H+j);(mid-v).ch(planes+2*H+j);}else if constexpr(R==1){av comp0(_mm256_blend_pd(z.af,y.af,12));av comp1(_mm256_blend_pd(x.af,z.af,12));av comp2(_mm256_blend_pd(y.af,x.af,12));av u=comp1+comp2;av v=cscale(cturn(comp1-comp2),-0.866025403784438646763723);av mid=comp0-cscale(u,0.5);(comp0+u).ch(planes+j);(mid+v).ch(planes+H+j);(mid-v).ch(planes+2*H+j);}else if constexpr(R==2){av comp0(_mm256_blend_pd(y.af,x.af,12));av comp1(_mm256_blend_pd(z.af,y.af,12));av comp2(_mm256_blend_pd(x.af,z.af,12));av u=comp1+comp2;av v=cscale(cturn(comp1-comp2),-0.866025403784438646763723);av mid=comp0-cscale(u,0.5);(comp0+u).ch(planes+j);(mid+v).ch(planes+H+j);(mid-v).ch(planes+2*H+j);}}
template<int R>static inline __attribute__((always_inline)) void saveCRT(Z*planes,unsigned j,av x,av y,av z){av u=y+z;av v=cscale(cturn(y-z),0.866025403784438646763723);av mid=x-cscale(u,0.5);x=x+u;y=mid+v;z=mid-v;if constexpr(R==0){av comp0(_mm256_blend_pd(x.af,y.af,12));av comp1(_mm256_blend_pd(y.af,z.af,12));av comp2(_mm256_blend_pd(z.af,x.af,12));comp0.ch(planes+j);comp1.ch(planes+H+j);comp2.ch(planes+2*H+j);}else if constexpr(R==1){av comp0(_mm256_blend_pd(y.af,z.af,12));av comp1(_mm256_blend_pd(z.af,x.af,12));av comp2(_mm256_blend_pd(x.af,y.af,12));comp0.ch(planes+j);comp1.ch(planes+H+j);comp2.ch(planes+2*H+j);}else if constexpr(R==2){av comp0(_mm256_blend_pd(z.af,x.af,12));av comp1(_mm256_blend_pd(x.af,y.af,12));av comp2(_mm256_blend_pd(y.af,z.af,12));comp0.ch(planes+j);comp1.ch(planes+H+j);comp2.ch(planes+2*H+j);}}
template<class T>static inline av fetchPair(const T*b,unsigned n,unsigned idx){if(idx+4<=n)return av(_mm256_cvtepi32_pd(_mm_loadu_si128((const __m128i*)(b+idx))));if(idx>=n)return av(_mm256_setzero_pd());Z lo=readpair(b,n,idx),hi=readpair(b,n,idx+2);return av(_mm256_setr_pd(lo.real(),lo.imag(),hi.real(),hi.imag()));}
 template<int R,bool Short,class T>static inline __attribute__((always_inline)) void handleCRT(Z*planes,const T*b,unsigned n,unsigned j){av x=fetchPair(b,n,2*j);if constexpr(Short){constexpr double co[3]={1.,-0.5,-0.5},si[3]={0.,-0.866025403784438646763723,0.866025403784438646763723};constexpr int A=R,B=(R+1)%3;av roots(_mm256_setr_pd(co[A],si[A],co[B],si[B]));x.ch(planes+j);(x*roots).ch(planes+H+j);(x*cconj(roots)).ch(planes+2*H+j);}else{av y=fetchPair(b,n,2*j+2*H),z=fetchPair(b,n,2*j+4*H);loadCRT<R>(planes,j,x,y,z);}}

template<int P,class T>static inline av packS(const T*b,unsigned n,unsigned j){
 av x=fetchPair(b,n,2*j);if constexpr(P==0)return x;
 else{constexpr int RS[3]={0,2,1};constexpr double co[3]={1.,-0.5,-0.5},si[3]={0.,-0.866025403784438646763723,0.866025403784438646763723};
  int R=RS[(j>>1)%3],A=R,B=(R+1)%3;av roots(_mm256_setr_pd(co[A],si[A],co[B],si[B]));
  if constexpr(P==1)return x*roots;else return x*cconj(roots);}}
template<int P,class T>static void difTopS(Z*ac,const T*b,unsigned n){
 using namespace hint_transform;constexpr unsigned qf=H/4;const Complex*om=TABLE.omega_data(hint_log2(H));
 for(unsigned i=0;i<qf;i+=2){av x0=packS<P>(b,n,i),x1=packS<P>(b,n,i+qf),x2=packS<P>(b,n,i+2*qf),x3=packS<P>(b,n,i+3*qf);
  av w(om+i),w3=w.root_cube();av aC=x0,aD=x1,aJ=x2,ar=x3;aX(aC,aJ);aX(aD,ar);ar=ar.eM();
  aC.ch(ac+i);aD.ch(ac+i+qf);((aJ+ar)*w).ch(ac+i+2*qf);((aJ-ar)*w3).ch(ac+i+3*qf);}
 fft_split_radix_dif_template<H/2>(ac);fft_split_radix_dif_template<H/4>(ac+H/2);fft_split_radix_dif_template<H/4>(ac+H/2+H/4);}
template<class T>static void forwardCold(Z*planes,const T*b,unsigned n){
 using namespace hint_transform;constexpr unsigned qf=H/4,CH=64;TABLE.expand(hint_log2(H));
 const Complex*om=TABLE.omega_data(hint_log2(H));
 for(unsigned i0=0;i0<qf;i0+=CH){
  for(unsigned a=0;a<4;a++){unsigned j0=i0+a*qf;
   for(unsigned j=j0;j<j0+CH;j+=2){unsigned ph=(j>>1)%3;
    if(ph==0)handleCRT<0,false>(planes,b,n,j);else if(ph==1)handleCRT<2,false>(planes,b,n,j);else handleCRT<1,false>(planes,b,n,j);}}
  for(unsigned p=0;p<3;p++){Z*ac=planes+p*H;
   for(unsigned i=i0;i<i0+CH;i+=2){av w(om+i),w3=w.root_cube();av aC(ac+i),aD(ac+i+qf),aJ(ac+i+2*qf),ar(ac+i+3*qf);
    aX(aC,aJ);aX(aD,ar);ar=ar.eM();aC.ch(ac+i);aD.ch(ac+i+qf);((aJ+ar)*w).ch(ac+i+2*qf);((aJ-ar)*w3).ch(ac+i+3*qf);}}
 }
 for(unsigned p=0;p<3;p++){Z*ac=planes+p*H;fft_split_radix_dif_template<H/2>(ac);fft_split_radix_dif_template<H/4>(ac+H/2);fft_split_radix_dif_template<H/4>(ac+H/2+H/4);}
}
template<bool Short,class T>static void forward(Z*planes,const T*b,unsigned n){using namespace hint_transform;if constexpr(Short){TABLE.expand(hint_log2(H));difTopS<0>(planes,b,n);difTopS<1>(planes+H,b,n);difTopS<2>(planes+2*H,b,n);}else{forwardCold(planes,b,n);}}
static inline void pair(unsigned p,unsigned m,unsigned phasep){
 Z a=left[p],aa0=conjz(left[m]),b=right[p],bb0=conjz(right[m]);
 Z e=a+aa0,f=b+bb0,o=turn(aa0-a),v=turn(bb0-b);
 Z ev=times(e,f)+times(tw(phasep),times(o,v));Z ov=times(e,v)+times(o,f);
 const double factor=0.25/(3*H);
 left[p]=conjz(ev+turn(ov))*factor;if(m!=p)left[m]=(ev-turn(ov))*factor;
}
static inline av cswap(av a){return av(_mm256_permute2f128_pd(a.af,a.af,1));}
constexpr unsigned CUT=11;
 template<unsigned Bits> static constexpr unsigned reverseword(unsigned i){unsigned j=0;for(unsigned k=0;k<Bits;k++)j=2*j+((i>>k)&1);return j;}
 struct ReversedRoots{
    Unit leading[1u<<CUT]{},tail[2][H>>CUT]{};
    constexpr ReversedRoots(){
       for(unsigned j=0;j<(1u<<CUT);j++)leading[j]=phase(3*(reverseword<CUT>(j)<<(18-CUT)));
       for(unsigned j=0;j<(H>>CUT);j++)for(unsigned k=0;k<2;k++)tail[k][j]=phase(3*reverseword<18-CUT>(j)+k*H);
    }
 };alignas(64) static constexpr ReversedRoots reversed{};
 static inline Z reversed_twiddle(unsigned j,unsigned k){
    Unit a=reversed.leading[j&((1u<<CUT)-1)],b=reversed.tail[k][j>>CUT];
    return times(Z(a.r,a.i),Z(b.r,b.i));
 }
static inline void pair2x(unsigned p0,unsigned p1,unsigned m0,unsigned m1,unsigned ph0,unsigned ph1,bool cold){
av A((aa ae*)(left+p0));av A0=cconj(cswap(av((aa ae*)(left+m1))));av B((aa ae*)(right+p0));av B0=cconj(cswap(av((aa ae*)(right+m1))));av corr;Z w=reversed_twiddle(ph0,ph1);av wdup(w);av tw(_mm256_xor_pd(wdup.af,_mm256_setr_pd(0.,0.,-0.,-0.)));
 av factor=av(_mm256_add_pd(tw.af,_mm256_setr_pd(1.,0.,1.,0.)));corr=cscale(factor*((A-A0)*(B-B0)),-(0.25/(3*H)));B=cscale(B,1.0/(3*H));B0=cscale(B0,1.0/(3*H));av first=A*B+corr,last=A0*B0+corr;cconj(first).ch(left+p0);cswap(last).ch(left+m1);}
template<unsigned Base,class T>static bool reduce(T*value,unsigned value_length,const T*den,unsigned n,const T*q,unsigned qn){
 using namespace hint_transform;
 if(qn>2*H||n>=N||value_length<=N||value_length>=2*N)return false;
 bool cold=cached!=den;if(cold){forward<false>(right,den,n);cached=den;}
 forward<true>(left,q,qn);pair(0,0,0);pair(1,1,3*(H/2));
 for(unsigned block=2;block<H;block*=2){unsigned jp=block;
  for(;jp+2<=block+block/2;jp+=2)pair2x(jp,jp+1,3*block-1-jp,3*block-2-jp,jp,0,cold);
  for(;jp<block+block/2;++jp)pair(jp,3*block-1-jp,3*rev(jp));}
 pair(H,2*H,H);pair(H+1,2*H+1,H+3*(H/2));
 for(unsigned block=2;block<H;block*=2)for(unsigned jp=block;jp<2*block;jp+=2){unsigned mate=3*block-1-jp;pair2x(H+jp,H+jp+1,2*H+mate,2*H+mate-1,jp,1,cold);}
 for(unsigned r=0;r<3;r++)dI<1>(left+r*H,H);
 unsigned jc=0;for(;jc+12<=H;jc+=12){saveCRT<0>(left,jc+0,cconj(av(left+jc+0)),cconj(av(left+H+jc+0)),cconj(av(left+2*H+jc+0)));saveCRT<2>(left,jc+2,cconj(av(left+jc+2)),cconj(av(left+H+jc+2)),cconj(av(left+2*H+jc+2)));saveCRT<1>(left,jc+4,cconj(av(left+jc+4)),cconj(av(left+H+jc+4)),cconj(av(left+2*H+jc+4)));saveCRT<0>(left,jc+6,cconj(av(left+jc+6)),cconj(av(left+H+jc+6)),cconj(av(left+2*H+jc+6)));saveCRT<2>(left,jc+8,cconj(av(left+jc+8)),cconj(av(left+H+jc+8)),cconj(av(left+2*H+jc+8)));saveCRT<1>(left,jc+10,cconj(av(left+jc+10)),cconj(av(left+H+jc+10)),cconj(av(left+2*H+jc+10)));}saveCRT<0>(left,jc+0,cconj(av(left+jc+0)),cconj(av(left+H+jc+0)),cconj(av(left+2*H+jc+0)));saveCRT<2>(left,jc+2,cconj(av(left+jc+2)),cconj(av(left+H+jc+2)),cconj(av(left+2*H+jc+2)));
 const double*raw=reinterpret_cast<const double*>(left);int64_t carry=0;
 const int64_t B2=int64_t(Base)*int64_t(Base);
 auto digit=[&](unsigned j){int64_t z=int64_t(value[j])+(j+N<value_length?int64_t(value[j+N]):int64_t(0))-int64_t(raw[j]+0.5)+carry;
 int64_t k=z<0?-((-z+Base-1)/Base):z/Base;value[j]=T(z-k*Base);carry=k;};
 auto pair2=[&](unsigned j,bool upper){int64_t v2=int64_t(value[j])+int64_t(Base)*int64_t(value[j+1]);
 int64_t w2=upper?(int64_t(value[j+N])+int64_t(Base)*int64_t(value[j+1+N])):int64_t(0);
 int64_t r2=int64_t(raw[j]+0.5)+int64_t(Base)*int64_t(raw[j+1]+0.5);
 int64_t Z=v2+w2-r2+carry;
 constexpr uint64_t ceiling=4000000000000000000ull;
 uint64_t shifted=uint64_t(Z)+ceiling, quotient=shifted/uint64_t(B2);
 int64_t k=int64_t(quotient)-int64_t(ceiling/uint64_t(B2)),R=shifted-quotient*uint64_t(B2);
 value[j]=(T)(R%(int64_t)Base);value[j+1]=(T)(R/(int64_t)Base);carry=k;};
 unsigned jj=0;
 if(value_length>N){unsigned e=value_length-N;for(;jj+2<=e;jj+=2)pair2(jj,true);for(;jj<e;++jj)digit(jj);}
 for(;jj+2<=N;jj+=2)pair2(jj,false);for(;jj<N;++jj)digit(jj);
 for(unsigned j=0;carry&&j<N;j++){int64_t z=int64_t(value[j])+carry;int64_t cy=z<0?-((-z+Base-1)/Base):z/Base;value[j]=T(z-cy*Base);carry=cy;}
 return carry==0;
}
}
ax<ah ad,aT T>
al dP(aa T in1[],aa T in2[],T out[],
ab aj,ab ai,ab skip=0)
{bH dy f4;if(aj==0||ai==0||in1==ay||in2==ay)
{ag;}aa ab bV=aj+ai-1;if(aj<=32&&ai<=32)
{au::ah acc[64];for(ab i=0;i<bV;++i)acc[i]=0;for(ab i=0;i<aj;++i)
{aa au::ah a=(au::ah)in1[i];if(!a)fe;for(ab j=0;j<ai;++j)acc[i+j]+=a*(au::ah)in2[j];}au::ah aA=0;for(ab i=0;i<bV;++i)
{aa au::ah t=aA+acc[i];out[i]=(T)(t%(au::ah)ad);aA=t/(au::ah)ad;}out[bV]=(T)(aA%(au::ah)ad);ag;}if((aj<=4||ai<=4)&&(au::ah)aj*(au::ah)ai<=65536){aa T*sm=aj<=ai?in1:in2;aa T*lg=aj<=ai?in2:in1;aa ab m=aj<=ai?aj:ai,L=aj<=ai?ai:aj;au::ah cy=0;for(ab i=0;i<bV;i++){au::ah v=cy;aa ab j0=i<L?0:i-(L-1),j1=i<m?i+1:m;for(ab j=j0;j<j1;j++)v+=(au::ah)sm[j]*(au::ah)lg[i-j];out[i]=(T)(v%(au::ah)ad);cy=v/(au::ah)ad;}out[bV]=(T)(cy%(au::ah)ad);ag;}ab a0=min_2pow(bV);ab wrap=0;if am(ad<=10000){aa ab bg=a0/2;if(bg>=64&&bV-bg<=8&&aj<=bg&&ai<=bg){wrap=bV-bg;a0=bg;}}aa ab ff=std::max(ab(16385),std::max(a0+1,bV));if(ff>ej)
{std::cJ(cr);{ab _bytes=aZ(ae)*ff+8192;if(el()){ab _rounded=(_bytes+(ab)(2u<<20)-1)&~(ab)((2u<<20)-1);al*_p=ay;if(eP(&_p,(ab)(2u<<20),_rounded)!=0)_p=ay;if(_p)madvise(_p,_rounded,eR);cr=_p;}aK{cr=std::dw(_bytes);}}if(cr==ay)
{bx("alloc error");}eh=(ae*)((((cc)cr+4095)&~(cc)4095)+512);ej=ff;}ae*aM=eh;if(in1==in2&&aj==ai){aa ab m=a0/2;aa ab do=(aj+1)/2;ab si=0;if am(aZ(T)==4&&ad<=0x7fffffffu){for(;si+4<=aj;si+=4)
b0(cO<ak*>(aM)+si,
cP(bX(cO<aa aU*>(in1+si))));}for(;si+2<=aj;si+=2)aM[si/2]=ae((ak)in1[si],(ak)in1[si+1]);if(si<aj)aM[si/2]=ae((ak)in1[si],0.0);std::memset((al*)(aM+do),0,(m-do)*aZ(ae));dh<1>(aM,m);aa ak bq=1.0/(ak)m;{aa ak a=aM[0].aH(),b=aM[0].aF();aM[0]=ae((a*a+b*b)*bq,(-2*a*b)*bq);aa ak c=aM[1].aH(),d=aM[1].aF();aM[1]=ae((c*c-d*d)*bq,(-2*c*d)*bq);}aa aq lg=cj(m);bw dQ=[lg](aq x){x=((x&0x55555555u)<<1)|((x>>1)&0x55555555u);x=((x&0x33333333u)<<2)|((x>>2)&0x33333333u);x=((x&0x0f0f0f0fu)<<4)|((x>>4)&0x0f0f0f0fu);x=__builtin_bswap32(x);ag x>>(32-lg);};cs&cB=fS;aa ab cZ=gTF;if(m>(1u<<23))throw("FFT root limit exceeded");if(cB.aQ()<m)cB.a7((m<(1u<<20))?(1u<<20):m);if(cZ<m){for(ab h=cZ<2?2:cZ;h<m;h*=2){if(h<8){for(ab r=h;r<h+h/2;r++)cB[r]=root_factor23::root((unsigned)r);}else{for(ab r=h;r<h+h/2;r+=4){const ae z=root_factor23::root((unsigned)r);_mm256_storeu_pd((double*)(cB.af()+r),_mm256_setr_pd(z.real(),z.imag(),-z.real(),-z.imag()));_mm256_storeu_pd((double*)(cB.af()+r+2),_mm256_setr_pd(z.imag(),-z.real(),-z.imag(),z.real()));}}}}if(cZ<m)gTF=m;for(ab h=2;h<4;h*=2){for(ab r=h;r<h+h/2;++r){aa ab j=3*h-1-r;aa ae w=bK.eu(lg,dQ((aq)r));aa ak a=aM[r].aH(),b=aM[r].aF();aa ak c=aM[j].aH(),d=aM[j].aF();aa ak er=(a+c)*0.5,ei=(b-d)*0.5;aa ak or_=(b+d)*0.5,oi=(c-a)*0.5;aa ak osr=or_*or_-oi*oi,osi=2*or_*oi;aa ak vr=er*er-ei*ei+w.aH()*osr-w.aF()*osi;aa ak vi=2*er*ei+w.aH()*osi+w.aF()*osr;aa ak ur=2*(er*or_-ei*oi),ui=2*(er*oi+ei*or_);aM[r]=ae((vr-ui)*bq,-(vi+ur)*bq);aM[j]=ae((vr+ui)*bq,(vi-ur)*bq);}}aa ao c3=bv(0.5);aa ao two_v=bv(2.0);aa ao dR=bv(bq);aa ao fg=dg(1.0,2.0,1.0,2.0);aa ao cC=dg(0.0,-0.0,0.0,-0.0);aa ao re_sign=dg(-0.0,0.0,-0.0,0.0);for(ab h=4;h<m;h*=2){for(ab r=h;r<h+h/2;r+=2){aa ab j=3*h-1-r;aa ao y=cb((aa ak*)(aM+r));ao v=cb((aa ak*)(aM+j-1));v=bC(b7(v,v,1),cC);aa ao e=bn(aE(y,v),c3);aa ao diff=aG(y,v);aa ao o=bn(bC(bb(diff,5),cC),c3);aa av esq(bD(e,fg));aa av osq(bD(o,fg));aa ao ev=(esq+av(cB.af()+r)*osq).af;aa ao ov=bn((av(e)*av(o)).af,two_v);aa ao iov=bC(bb(ov,5),re_sign);aa ao zr=bn(bC(aE(ev,iov),cC),dR);ao zj=bn(aG(ev,iov),dR);zj=b7(zj,zj,1);b0((ak*)(aM+r),zr);b0((ak*)(aM+j-1),zj);}}dI<1>(aM,m);}aK{aa ab m=a0/2;aa aV fi=bo<aa al*>(in2)==fT&&ai==fU;aa aV cache_reciprocal=bo<aa al*>(in2)==gY&&ai==fW;aa aV cache_b=fi||cache_reciprocal;cs&fk=fi?g6:g7;aV&fl=fi?fV:fX;ae*fb=aM+m;if(cache_b){if(fk.aQ()!=m){fk.a7(m);fl=aS;}fb=fk.af();}bw gB=[&](ae*dst,aa T*src,ab len){aa ab do=(len+1)/2;ab si=0;if am(aZ(T)==4&&ad<=0x7fffffffu){for(;si+4<=len;si+=4)
b0(cO<ak*>(dst)+si,
cP(bX(cO<aa aU*>(src+si))));}for(;si+2<=len;si+=2)dst[si/2]=ae((ak)src[si],(ak)src[si+1]);if(si<len)dst[si/2]=ae((ak)src[si],0.0);aa aV zh=m>=16&&do<=m/2;std::memset((al*)(dst+do),0,((zh?m/2:m)-do)*aZ(ae));if(zh)gp(dst,m);aK dh<1>(dst,m);};gB(aM,in1,aj);if(!cache_b|| !fl){gB(fb,in2,ai);if(cache_b)fl=bt;}aa ak bq=1.0/(ak)m;{aa ak a=aM[0].aH(),b=aM[0].aF();aa ak c=fb[0].aH(),d=fb[0].aF();aM[0]=ae((a*c+b*d)*bq,-(a*d+b*c)*bq);aa ak e=aM[1].aH(),f=aM[1].aF();aa ak g=fb[1].aH(),h=fb[1].aF();aM[1]=ae((e*g-f*h)*bq,-(e*h+f*g)*bq);}aa aq lg=cj(m);bw dQ=[lg](aq x){x=((x&0x55555555u)<<1)|((x>>1)&0x55555555u);x=((x&0x33333333u)<<2)|((x>>2)&0x33333333u);x=((x&0x0f0f0f0fu)<<4)|((x>>4)&0x0f0f0f0fu);x=__builtin_bswap32(x);ag x>>(32-lg);};cs&cB=fS;aa ab cZ=gTF;if(m>(1u<<23))throw("FFT root limit exceeded");if(cB.aQ()<m)cB.a7((m<(1u<<20))?(1u<<20):m);if(cZ<m){for(ab h=cZ<2?2:cZ;h<m;h*=2){if(h<8){for(ab r=h;r<h+h/2;r++)cB[r]=root_factor23::root((unsigned)r);}else{for(ab r=h;r<h+h/2;r+=4){const ae z=root_factor23::root((unsigned)r);_mm256_storeu_pd((double*)(cB.af()+r),_mm256_setr_pd(z.real(),z.imag(),-z.real(),-z.imag()));_mm256_storeu_pd((double*)(cB.af()+r+2),_mm256_setr_pd(z.imag(),-z.real(),-z.imag(),z.real()));}}}}if(cZ<m)gTF=m;for(ab h=2;h<4;h*=2){for(ab r=h;r<h+h/2;++r){aa ab j=3*h-1-r;aa ae w=bK.eu(lg,dQ((aq)r));aa ak a=aM[r].aH(),b=aM[r].aF();aa ak c=aM[j].aH(),d=aM[j].aF();aa ak er=(a+c)*0.5,ei=(b-d)*0.5;aa ak or_=(b+d)*0.5,oi=(c-a)*0.5;aa ak a2=fb[r].aH(),b2=fb[r].aF();aa ak c2=fb[j].aH(),d2=fb[j].aF();aa ak er2=(a2+c2)*0.5,ei2=(b2-d2)*0.5;aa ak or2=(b2+d2)*0.5,oi2=(c2-a2)*0.5;aa ak osr=or_*or2-oi*oi2,osi=or_*oi2+oi*or2;aa ak vr=er*er2-ei*ei2+w.aH()*osr-w.aF()*osi;aa ak vi=er*ei2+ei*er2+w.aH()*osi+w.aF()*osr;aa ak ur=er*or2-ei*oi2+or_*er2-oi*ei2;aa ak ui=er*oi2+ei*or2+or_*ei2+oi*er2;aM[r]=ae((vr-ui)*bq,-(vi+ur)*bq);aM[j]=ae((vr+ui)*bq,(vi-ur)*bq);}}aa ao c3=bv(0.5);aa ao two_v=bv(2.0);aa ao dR=bv(bq);aa ao fg=dg(1.0,2.0,1.0,2.0);aa ao cC=dg(0.0,-0.0,0.0,-0.0);aa ao re_sign=dg(-0.0,0.0,-0.0,0.0);for(ab h=4;h<m;h*=2){for(ab r=h;r<h+h/2;r+=2){aa ab j=3*h-1-r;aa ao y=cb((aa ak*)(aM+r));ao v=cb((aa ak*)(aM+j-1));v=bC(b7(v,v,1),cC);aa ao e=bn(aE(y,v),c3);aa ao diff=aG(y,v);aa ao o=bn(bC(bb(diff,5),cC),c3);_mm_prefetch((aa a3*)(aM+j-1-32),_MM_HINT_T0);_mm_prefetch((aa a3*)(fb+j-1-32),_MM_HINT_T0);aa ao y2=cb((aa ak*)(fb+r));ao v2=cb((aa ak*)(fb+j-1));v2=bC(b7(v2,v2,1),cC);aa ao e2=bn(aE(y2,v2),c3);aa ao diff2=aG(y2,v2);aa ao o2=bn(bC(bb(diff2,5),cC),c3);aa av ee=av(e)*av(e2);aa av oo=av(o)*av(o2);aa ao ev=(ee+av(cB.af()+r)*oo).af;aa ao ov=(av(aE(e,o))*av(aE(e2,o2))-ee-oo).af;aa ao iov=bC(bb(ov,5),re_sign);aa ao zr=bn(bC(aE(ev,iov),cC),dR);ao zj=bn(aG(ev,iov),dR);zj=b7(zj,zj,1);b0((ak*)(aM+r),zr);b0((ak*)(aM+j-1),zj);}}dI<1>(aM,m);}ak*aa cg=cO<ak*>(aM);bw dS=[&](ab at){aa ak v=cg[at];ag(at&1)?-v:v;};for(ab t=0;t<wrap;t++){aa ab k=a0+t;au::ah exact=0;for(ab i=k-(ai-1);i<aj;i++)exact+=(au::ah)in1[i]*in2[k-i];aa ak v=(t&1)?-(ak)exact:(ak)exact;cg[t]-=v;cg[k]=v;}au::ah aA=0;ab ic=0;ab _zzcvb=g_cv_stop?g_cv_stop:bV;if(skip>=8){au::ah low=0,bj=(au::ah)std::min(aj,ai)*(ad-1);for(ab j=skip-8;j<skip;++j){aa au::ah c=bo<au::a1>(dS(j)+0.5);low=(c+low)/ad;bj=(c+bj)/ad;}if(low==bj){aA=low;ic=skip;}}if(ic&1){aA+=(au::ah)(au::a1)(dS(ic)+0.5);out[ic++]=(T)(aA%ad);aA/=ad;}{aa au::ah pair_per=(au::ah)(ad-1)*(ad-1)
*(au::ah)(ad+2);if((au::ah)((_zzcvb+1)/2)<=(~0ull)/pair_per)
{if am((au::ah)ad*ad<=0xffffffffULL){aa ab cD=(_zzcvb-ic)/8;if(cD>=32){am au::ah B=(au::ah)ad,B2=B*B;aa ab dq[4]={ic,ic+2*cD,ic+4*cD,ic+6*cD};au::ah cL[4]={aA};bw pair_step=[&](ab at,au::ah&cy){aa au::ah c0=bo<au::a1>(cg[at]+0.5);aa au::ah c1=bo<au::a1>(0.5-cg[at+1]);aa au::ah a6=cy+c0+B*c1;cy=a6/B2;aa az rem=(az)(a6-cy*B2),hi=rem/(az)B;*(ah*)(out+at)=((ah)hi<<32)|(ah)(rem-hi*(az)B);};
if am(aZ(T)==4&&ad==10000){aa ao bg=bv(0.5),inv=bv(1.0/((ak)ad*ad)),neg=bv(-(ak)ad*ad);ao cy0=_mm256_set_pd(0,0,0,(ak)aA);bw step=[&](ab b,ab j,ao&cy){ab p0=dq[b]+2*j,p1=dq[b+1]+2*j,p2=dq[b+2]+2*j,p3=dq[b+3]+2*j;_mm_prefetch((aa a3*)(cg+p0+32),_MM_HINT_T0);_mm_prefetch((aa a3*)(cg+p1+32),_MM_HINT_T0);_mm_prefetch((aa a3*)(cg+p2+32),_MM_HINT_T0);_mm_prefetch((aa a3*)(cg+p3+32),_MM_HINT_T0);ao a01=gb(gc(dF(cg+p0)),dF(cg+p1),1),a23=gb(gc(dF(cg+p2)),dF(cg+p3),1);ao even=fo(aE(_mm256_unpacklo_pd(a01,a23),bg),fp|fq),odd=fo(aG(bg,_mm256_unpackhi_pd(a01,a23)),fp|fq);ao sum=aE(even,cy),a6=fr(odd,bv((ak)ad),sum);cy=fo(bn(a6,inv),fp|fq);ao rem=fr(fr(cy,bv(-(ak)ad),odd),bv((ak)ad),sum);ao minus=_mm256_cmp_pd(rem,fP(),_CMP_LT_OQ),plus=_mm256_cmp_pd(rem,bv((ak)ad*ad),_CMP_GE_OQ);if(_mm256_movemask_pd(_mm256_or_pd(minus,plus))){cy=aE(cy,aG(fu(plus,bv(1.0)),fu(minus,bv(1.0))));rem=aE(rem,aG(fu(minus,bv((ak)ad*ad)),fu(plus,bv((ak)ad*ad))));}ao bj=fo(bn(rem,bv(1.0/ad)),fp|fq);aU e=hH(fr(bj,bv(-(ak)ad),rem)),o=hH(bj);aU lo=eU(e,o),hi=eV(e,o);_mm_storel_epi64((aU*)(out+p0),lo);_mm_storeh_pd((ak*)(out+p2),_mm_castsi128_pd(lo));_mm_storel_epi64((aU*)(out+p1),hi);_mm_storeh_pd((ak*)(out+p3),_mm_castsi128_pd(hi));};for(ab j=0;j<cD;j++){step(0,j,cy0);}alignas(32)ak tails[4];b0(tails,cy0);for(int b=0;b<4;b+=4){cL[b]=tails[b];cL[b+1]=tails[b+2];cL[b+2]=tails[b+1];cL[b+3]=tails[b+3];}}
aK for(ab j=0;j<cD;j++)for(int p=0;p<4;p++)pair_step(dq[p]+2*j,cL[p]);for(int part=1;part<4;part++){au::ah actual=cL[part-1],assumed=0;ab j=0;for(;j<cD;j++){aa ab at=dq[part]+2*j;aa au::ah c0=bo<au::a1>(cg[at]+0.5);aa au::ah c1=bo<au::a1>(0.5-cg[at+1]);assumed=(assumed+c0+B*c1)/B2;pair_step(at,actual);if(actual==assumed)break;}if(j==cD)cL[part]=actual;}aA=cL[3];ic+=8*cD;}}for(;ic+2<=_zzcvb;ic+=2)
{aa au::ah c0=bo<au::a1>(dS(ic)+0.5);aa au::ah c1=bo<au::a1>(dS(ic+1)+0.5);aa au::ah s0=aA+c0;aa au::ah pair=s0+(au::ah)ad*c1;if am((au::ah)ad*ad<=0xffffffffULL){am au::ah B2=(au::ah)ad*ad;aA=pair/B2;aa az rest=(az)(pair-aA*B2);aa az hi=rest/(az)ad;out[ic]=(T)(rest-hi*(az)ad);out[ic+1]=(T)hi;}aK{out[ic]=(T)(s0%ad);out[ic+1]=(T)((pair/ad)%ad);aA=pair/((au::ah)ad*ad);}}}}for(;ic<_zzcvb;ic++)
{aA+=bo<au::a1>(dS(ic)+0.5);std::tie(aA,out[ic])=div_mod<ah>(aA,ad);}out[bV]=aA%ad;}ax<aT T>
dc ca{T*p=ay;al*bJ=ay;ab n=0,cap=0;ca()=default;ca(aa ca&)=cd;ca&bk=(aa ca&)=cd;~ca(){if(bJ)std::cJ(bJ);}ab aQ()aa{ag n;}T*af(){ag p;}T*bE(){ag p;}T*end(){ag p+n;}T&bk[](ab i){ag p[i];}al clear(){n=0;}al bW(ca&o){std::bW(p,o.p);std::bW(bJ,o.bJ);std::bW(n,o.n);std::bW(cap,o.cap);}al grow(ab m){al*q=ay;T*dst=ay;if(el()){ab b1=(ab)(2u<<20);ab aw=1024+(((cc)b9>>4)&15u)*2048u;ab b3=m*aZ(T)+aw;ab cK=(b3+b1-1)&~(b1-1);if(eP(&q,b1,cK)!=0||!q)bx("alloc error");madvise(q,cK,eR);dst=(T*)((a3*)q+aw);}aK{ab b3=m*aZ(T)+128;q=std::dw(b3);if(!q)bx("alloc error");dst=(T*)(((cc)q+63)&~(cc)31);}if(p){std::dx(dst,p,n*aZ(T));std::cJ(bJ);}bJ=q;p=dst;cap=m;}al aL(ab m){if(m>cap){ab nc=cap?cap*2:m;if(nc<m)nc=m;grow(nc);}}al c4(ab m){aL(m);n=m;}al reserve(ab m){aL(m);}al a7(ab m){aL(m);if(m>n)std::memset((al*)(p+n),0,(m-n)*aZ(T));n=m;}al a7(ab m,T v){aL(m);for(ab i=n;i<m;i++)p[i]=v;n=m;}al dX(ab m,T v){aL(m);for(ab i=0;i<m;i++)p[i]=v;n=m;}ax<class IT>al dX(IT a,IT b){ab m=(ab)(b-a);aL(m);for(ab i=0;i<m;i++)p[i]=a[i];n=m;}};ax<ah ad,aT T>
aY cw((bp("avx2")))aV hM(aa T*b,ab n,ca<T>&x,ab p){bH dy f4;am ab G=4,C=8;aa ab N=2*p;if(p<16||n<N+G||x.aQ()!=p+1)ag aS;aa T*a=b+n-N-G;if(N+1>ej){std::cJ(cr);cr=std::dw(aZ(ae)*(N+1)+8192);if(!cr)bx("alloc error");eh=(ae*)((((cc)cr+4095)&~(cc)4095)+512);ej=N+1;}ae*f=eh;he(f,a,N,(aa T*)x.af(),p+1);for(ab i=0;i<G;++i)f[i].aH(f[i].aH()+a[N+i]);dh<1>(f,N);go(f,N,-1.0/(2.0*N));ah low=0,bj=(ah)(p+1)*(ad-1);for(ab j=p-C;j<p;++j){aa ab k=N+j;ah tail=0;for(ab i=k-p;i<N+G;++i)tail+=(ah)a[i]*x[k-i];aa a1 cE=bo<a1>(f[j].aF()+0.5)-(a1)tail;if(cE<0)ag aS;low=((ah)cE+low)/ad;bj=((ah)cE+bj)/ad;}if(low!=bj)ag aS;ca<T>bU,cp,bN;bU.c4(p+G+1);cp.c4(2*p+G+2);bN.a7(2*p+2,(T)0);ah aA=low;for(ab j=p;j<=N+G;++j){if am(ad<=10000){if(j==p+G&&p<=524288){am ah B2=ad*ad;for(;j+1<N;j+=2){aa a1 c0=bo<a1>(f[j].aF()+0.5);aa a1 c1=bo<a1>(f[j+1].aF()+0.5);if(c0<0||c1<0)ag aS;aa ah v=aA+(ah)c0+ad*(ah)c1;aA=v/B2;aa az rem=(az)(v-aA*B2),hi=rem/(az)ad;bU[j-p]=(T)(rem-hi*(az)ad);bU[j-p+1]=(T)hi;}}}a1 cE;if(j<N){cE=bo<a1>(f[j].aF()+0.5);if(j<p+G){aa ab k=N+j;ah tail=0;for(ab i=k-p;i<N+G;++i)tail+=(ah)a[i]*x[k-i];cE-=(a1)tail;}}aK{aa ab k=j-N;ah bottom=0;for(ab i=0;i<=k;++i)bottom+=(ah)a[i]*x[k-i];cE=bo<a1>(f[k].aF()+0.5)-(a1)bottom;}if(cE<0)ag aS;aa ah a6=(ah)cE+aA;bU[j-p]=(T)(a6%ad);aA=a6/ad;}aa aV subtract=bU[p+G]<ad/2;if(!subtract){ab i=0;aW(i<=p+G&&bU[i]==0)++i;if(i<=p+G){bU[i]=(T)(ad-bU[i]);++i;}if am(aZ(T)==4&&ad<=0x7fffffff){aa aI bm=_mm256_set1_epi32((int)(ad-1));for(;i+7<=p+G;i+=8){aa aI v=dr((aa aI*)(bU.af()+i));dZ((aI*)(bU.af()+i),_mm256_sub_epi32(bm,v));}}for(;i<=p+G;++i)bU[i]=(T)(ad-1-bU[i]);}aa ab er=bh(bU.af(),bU.aQ());for(ab i=0;i<=p;++i)bN[p+i]=x[i];if(er){aa ab aw=p+G,plen=p+1+er;dP<ad>(x.af(),bU.af(),cp.af(),p+1,er,aw<plen?aw:0);aa ab ql=plen>aw?plen-aw:0;if(subtract){if(ql)bZ<ad>(bN.af(),cp.af()+aw,bN.af(),bN.aQ(),ql);}aK{if(ql)dO<ad,aS>(bN.af(),cp.af()+aw,bN.af(),bN.aQ(),ql);for(ab i=0;i<bN.aQ();++i){if(++bN[i]<ad)break;bN[i]=0;}}}bN.a7(bh(bN.af(),bN.aQ()));if(bN.aQ()!=N+1)ag aS;x.bW(bN);ag bt;}ax<ah ad,aT T>
am T divisor_normalize(aa T in[],T out[],ab len)
{if(in==out)
{bx("In can't be same as out\n");}T cF=1;if(len==1)
{cF=(ad-1)/in[0];out[0]=in[0]*cF;}aK if(in[len-1]>=(ad/2))
{ck(out,in,len);}aK
{cF=(ad-1)*ad/(ad*in[len-1]+in[len-2]);e9<ad,aS>(in,cF,out,len);if(out[len-1]<(ad/2))
{cF++;dO<ad,aS>(out,in,out,len,len);}}ag cF;}ax<ah ad,aV gF=aS,aT T>
al abs_long_div(T aO[],aa T aR[],T aP[],
ab aj,ab ai)
{if am(!gF){aj=bh(aO,aj);ai=bh(aR,ai);if(aR==ay||ai==0)
{bx("Can't divide by zero\n");}if(aO==ay||aj==0)
{ag;}if(cf(aO,aR,aj,ai)<0)
{ag;}}if(ai==1)
{T rem=gw<ad>(aO,aR[0],aP,aj);aO[0]=rem;ag;}if(!gF&&aR[ai-1]<(ad/2))
{bx("Can't call this proc before normalize the divisor\n");}aP[aj-ai]=0;aa ah d1=ad*aR[ai-1]+aR[ai-2];aa ah c5=aR[ai-1];aa ah gG=(ad<=65536)?az(0xffffffffu)/az(c5):0;(al)c5;(al)gG;aY bG<T>d3;if(d3.dj()<(aB)(ai+1)){d3.a7((aB)(ai+1));d3.e4(0,d3.dj());}bG<T>&sub=d3;aY bG<ah>fy;aa ab d4=(ad<=10000)?ai/3:0;if(fy.dj()<(aB)d4)
{fy.a7((aB)d4);}ah*dN=fy.af();if am(ad<=10000)
{for(ab g=0;g<d4;g++)
{dN[g]=ah(aR[3*g])+ad*aR[3*g+1]
+ad*ad*aR[3*g+2];}}bw fz=[&](T num)
{if am(ad<=10000)
{am ah B2=ad*ad,B3=B2*ad;T*out=sub.af();ah aA=0;if(num==1)
{ck(out,aR,ai);}aK
{ab i=0;for(ab g=0;g<d4;g++,i+=3)
{aa ah a6=dN[g]*num+aA;aa ah q2=a6/B3;aa ah r2=a6-q2*B3;aa ah q1=r2/B2;aa ah r1=r2-q1*B2;aa ah q0=r1/ad;out[i]=T(r1-q0*ad);out[i+1]=T(q0);out[i+2]=T(q1);aA=q2;}for(;i<ai;i++)
{aa ah a6=ah(aR[i])*num+aA;aA=a6/ad;out[i]=T(a6-aA*ad);}}out[ai]=T(aA);}aK
{e9<ad,bt,bt>(aR,num,sub.af(),ai);}};aW(cf(aO,aR,aj,ai)>=0)
{sub.br(ai+1);ah c6=aO[aj-1]*ad+aO[aj-2];T bs=0;ab aw=aj-ai;if(c6>d1)
{if am(ad%2==0)
{sub.af()[ai]=0;bZ<ad>(aO+aw,aR,aO+aw,aj-aw,ai);aj=bh(aO,aj);aP[aw]=1;fe;}bs=c6/d1;fz(bs);sub.br(ai+(sub.af()[ai]!=0));ab c7=sub.a9();if(cf(aO+aw,sub.af(),aj-aw,c7)<0)
{bs--;bZ<ad>(sub.af(),aR,sub.af(),c7,ai);}}aK if(c6==d1)
{if(cf(aO+aw,aR,aj-aw,ai)<0)
{bs=ad-1;aw--;fz(bs);}aK
{bs=1;ck(sub.af(),aR,ai);sub.bI();}}aK
{if am(ad<=65536)
{aa ah approx=(c6*gG)>>32;aa ah rem=c6-approx*c5;bs=T(approx+(rem>=c5));}aK bs=c6/(d1/ad);if(bs>=ad)
{bs=ad-1;}{aa ah v2=d1-(ah)ad*c5;aa ah u2=(aj>=3)?(ah)aO[aj-3]:0;ah rhat=c6-(ah)bs*c5;aW((ah)bs*v2>rhat*(ah)ad+u2)
{--bs;rhat+=c5;}}aw--;if am(ad==10000){am ah B=ad,B2=B*B,B3=B2*B;T*d=aO+aw;ah ba=0;ab i=0;for(ab g=0;g<d4;g++,i+=3){aa ah cp=dN[g]*(ah)bs+ba;ba=cp/B3;aa ah low=cp-ba*B3;aa ah old=(ah)d[i]+B*d[i+1]+B2*d[i+2];aa aV under=old<low;aa ah rest=old-low+(under?B3:0);ba+=under;aa ah bj=rest/B2;aa az small=(az)(rest-bj*B2),mid=small/(az)B;d[i]=(T)(small-mid*(az)B);d[i+1]=(T)mid;d[i+2]=(T)bj;}for(;i<ai;i++){aa az cp=(az)aR[i]*(az)bs+(az)ba;aa az bj=cp/(az)B,low=cp-bj*(az)B;aa aV under=d[i]<low;d[i]=(T)((az)d[i]-low+(under?(az)B:0));ba=(ah)bj+under;}a1 top=(a1)d[ai]-(a1)ba;if(top<0){--bs;az eC=0;for(ab k=0;k<ai;k++){aa az a6=(az)d[k]+(az)aR[k]+eC;eC=a6>=(az)B;d[k]=(T)(a6-eC*(az)B);}top+=eC;}d[ai]=(T)top;aj=bh(aO,aj);aP[aw]=bs;fe;}fz(bs);sub.br(ai+(sub.af()[ai]!=0));ab c7=sub.a9();if(cf(aO+aw,sub.af(),aj-aw,c7)<0)
{bs--;bZ<ad>(sub.af(),aR,sub.af(),c7,ai);if(dK(aO+aw,sub.af(),aj-aw,c7)<0)
{bs--;bZ<ad>(sub.af(),aR,sub.af(),c7,ai);}}}bZ<ad>(aO+aw,sub.af(),aO+aw,aj-aw,sub.a9());aj=bh(aO,aj);aP[aw]=bs;}}ax<ah ad,aT T>
al d6(T aO[],T aR[],bG<T> &aP,
ab aj,ab ai,ab depth=0)
{aj=bh(aO,aj);ai=bh(aR,ai);if(aR==ay||ai==0)
{bx("Can't divide by zero\n");}if(aO==ay||aj==0)
{ag;}if(cf(aO,aR,aj,ai)<0)
{ag;}if(aR[ai-1]<(ad/2))
{bx("Can't call this proc before normalize the divisor\n");}ab cG=aj-ai+1;aP.br(cG);am ab hQ=20;if(ai<=hQ)
{abs_long_div<ad,bt>(aO,aR,aP.af(),aj,ai);}aK if(aj>=ai*2||aj>((ai+1)/2)*3)
{ab bF=(aj+3)/4;ab ds=bF*3-ai+2;aY bG<T>quotient_slots[128];bG<T>fallback;bG<T>&c8=depth<128?quotient_slots[depth]:fallback;if(c8.dj()<ds){bG<T>fresh(ds);c8=std::move(fresh);}c8.br(ds);c8.e4(0,ds);d6<ad>(aO+bF,aR,c8,aj-bF,ai,depth+1);ds=c8.bI();ab dividend_len=bh(aO,aj);d6<ad>(aO,aR,aP,dividend_len,ai,depth+1);aP.br(cG);cG=aP.bI();dO<ad>(aP.af()+bF,c8.af(),aP.af()+bF,cG-bF,ds);aP.br(aj-ai+1);}aK
{ab bF=ai/2;d6<ad>(aO+bF,aR+bF,aP,aj-bF,ai-bF,depth+1);am T ONE[1]={1};cG=aP.bI();aY bG<T>fC;aa aB fD=aB(bF+cG);if(fC.dj()<fD){bG<T>fresh(fD);fC=std::move(fresh);}bG<T>&bT=fC;bT.br(fD);dP<ad>(aR,aP.af(),bT.af(),bF,cG);ab eD=bT.bI();aj=bh(aO,aj);aW(cf(bT.af(),aO,eD,aj)>0)
{bZ<ad>(aP.af(),ONE,aP.af(),cG,1);bZ<ad>(bT.af(),aR,bT.af(),eD,bF);dO<ad>(aO+bF,aR+bF,aO+bF,aj-bF,ai-bF);cG=aP.bI();eD=bT.bI();aj=bh(aO,std::max(aj,ai)+1);}bZ<ad>(aO,bT.af(),aO,aj,eD);}}ax<aT T>__attribute__((target("avx2")))al nt_copy(T*dst,aa T*src,ab n){ab k=0;aW(k<n&&(((uintptr_t)(dst+k))&31)){dst[k]=src[k];++k;}aW(k+8<=n){_mm256_stream_si256((__m256i*)(dst+k),_mm256_loadu_si256((aa __m256i*)(src+k)));k+=8;}_mm_sfence();aW(k<n){dst[k]=src[k];++k;}}
ax<ah ad,aT T>
aY aV gK(aa T*a,ab la,aa T*b,ab lb,T*aP,ab qlen,ab s,T*wbuf=ay)
{aa ab n=lb;fT=b;fU=lb;fV=aS;em=ay;dc ReciprocalScope{~ReciprocalScope(){em=ay;gY=ay;}}reciprocal_scope;if(n<8||s<2||la<n+s)ag aS;ca<T>xb,x2,Pb,Tt,U,fE,qe,twox;aq ap ap top2=(aq ap ap)b[n-1]*ad+b[n-2];if(!top2)ag aS;aq ap ap x0=(aq ap ap)ad*ad*ad/top2;xb.a7(2);xb[0]=(T)(x0%ad);xb[1]=(T)(x0/ad);ab p=1;bw fF=[&](aa T*A,ab la_,aa T*B,ab lb_,ab aL,ca<T>&out)->aV{if(aL==0){out.clear();ag bt;}ab sA=la_<aL+2?la_:aL+2;ab sB=lb_<aL+2?lb_:aL+2;if(bo<aa al*>(B)==em){if(!fW){fW=sB;gY=(aa al*)(B+lb_-sB);}aK if(fW>sB&&la_>=fW&&lb_>=fW&&min_2pow(2*fW-1)==min_2pow(sA+sB-1))sA=sB=fW;}if(sA+sB<=aL)ag aS;Pb.c4(sA+sB+2);dP<ad>(A+la_-sA,B+lb_-sB,Pb.af(),sA,sB,sA+sB-aL);ab sh=sA+sB-aL;out.dX(Pb.bE()+sh,Pb.bE()+sh+aL);ag bt;};aW(p<s){ab k=p<(s-p)?p:(s-p);if(k==p&&hM<ad>(b,n,xb,p)){p+=k;fe;}ab aL=p+k+2;x2.c4(2*p+2);dP<ad>(xb.af(),xb.af(),x2.af(),p+1,p+1);if(!fF(b,n,x2.af(),2*p+2,aL,Tt))ag aS;twox.c4(p+2);aq cy=0;for(ab i=0;i<=p;i++){aq v=(aq)xb[i]*2u+cy;twox[i]=(T)(v%ad);cy=v/ad;}twox[p+1]=(T)cy;U.dX(aL,0);for(ab i=0;i<p+2&&i+k<aL;i++)U[i+k]=twox[i];if(cf(U.af(),Tt.af(),aL,aL)<0)ag aS;bZ<ad>(U.af(),Tt.af(),U.af(),aL,aL);ab dl=bh(U.af(),aL);U.a7(dl);xb.bW(U);p+=k;}if(xb.aQ()!=s+1)ag aS;em=xb.af();fW=0;fX=aS;ab L=n+s-std::min<ab>(256,s/4);T*cH;if(wbuf){cH=wbuf;cH[la]=0;cH[la+1]=0;}aK{fE.dX(a,a+la);fE.a7(la+2,0);cH=fE.af();}ab wend=la;int guard=0;aV qtouch=aS;for(;;){ab pos=wend>L?wend-L:0;ab lc=bh(cH+pos,wend>L?L:wend);ab aL=lc>n?lc-n+1:0;if(aL)qe.c4(aL);aK qe.dX(1,(T)0);aV gM=aS,useUns=aS;if(aL){am ab eG=4;if(s<=524288&&(ah)b[n-1]*10>=ad&&
aL<=s&&s-aL>=eG+3){if(!fF(cH+pos,lc,xb.af(),s+1,aL+eG,qe))ag aS;aV all_zero=bt,all_max=bt;for(ab i=0;i<eG;++i){all_zero&=qe[i]==0;all_max&=qe[i]==ad-1;}gM= !all_zero&& !all_max;useUns=gM&&(pos==0||n==1250000);if(!useUns){for(ab i=0;i<aL;++i)qe[i]=qe[i+eG];qe.a7(aL);}}aK{if(!fF(cH+pos,lc,xb.af(),s+1,aL,qe))ag aS;}}if(gM&&pos&&n==1250000){T*rv=cH+pos;
 if(!tricycle::reduce<ad>(rv,lc,b,n,qe.af()+4,aL))ag aS;
 ab rl=bh(rv,tricycle::N);if(rl>n||cf(rv,b,rl,n)>=0)ag aS;
}else if(!gM||pos!=0){ca<T>pv;pv.c4(aL+n+2);pv[aL+n]=(T)0;pv[aL+n+1]=(T)0;if(aL){g_cv_stop=gM?(lc<n+1?lc:n+1):0;dP<ad>(qe.af(),b,pv.af(),aL,n);g_cv_stop=0;}aK std::memset(pv.af(),0,n*aZ(T));bw qe_inc=[&]()->aV{aq c=1;for(ab x=0;x<qe.aQ()&&c;x++){aq v=(aq)qe[x]+c;qe[x]=(T)(v%ad);c=v/ad;}ag c==0;};bw qe_dec=[&]()->aV{for(ab x=0;x<qe.aQ();x++)if(qe[x]){qe[x]--;for(ab y=0;y<x;y++)qe[y]=(T)(ad-1);ag bt;}ag aS;};int it=0;if(!gM)for(;;){ab pl=bh(pv.af(),aL+n);if(cf(pv.af(),cH+pos,pl,lc)<=0)break;if(++it>64)ag aS;if(!qe_dec())ag aS;ab bl=bh(b,n);pl=bh(pv.af(),aL+n);if(cf(pv.af(),b,pl,bl)<0)ag aS;bZ<ad>(pv.af(),b,pv.af(),pl,bl);}T*aa rv=cH+pos;ab rb=lc<n+1?lc:n+1;{if(gM||bh(pv.af(),aL+n)) bZ<ad>(rv,pv.af(),rv,rb,rb);}for(;;){ab rl=bh(rv,rb);if(cf(rv,b,rl,n)<0)break;if(gM)ag aS;if(++it>64)ag aS;if(!qe_inc())ag aS;bZ<ad>(rv,b,rv,rl,n);}}aa T*qs=useUns?qe.af()+4:qe.af();ab nq=useUns?qe.aQ()-4:qe.aQ(),j=pos+nq;T oldq=qtouch?(T)aP[j]:(T)0;aq aA=0;if(qtouch){aq v=(aq)aP[j-1]+(aq)qs[nq-1];aP[j-1]=(T)(v%ad);aA=v/ad;nt_copy(aP+pos,qs,nq-1);}else{nt_copy(aP+pos,qs,nq);aP[j]=(T)0;}aP[j]=qtouch?oldq:(T)0;qtouch=bt;aW(aA){if(j>=qlen)ag aS;aq v=(aq)aP[j]+aA;aP[j]=(T)(v%ad);aA=v/ad;j++;}if(pos==0)break;wend=pos+n;}if(++guard>1)ag aS;ag bt;}ax<ah ad,aT T>
bG<T>abs_div(aa T aO[],T aR[],bG<T> &aP,
ab aj,ab ai,aV eH=bt,T*wbuf=ay)
{if(!eH&&ai>=4096&&aj>=ai+(ai>>1)){aa ab s_=ab(1)<<(63-f0(ai/2));aP=bG<T>(aj-ai+2,(T)0);aP.br(aj-ai+2);if(gK<ad>(aO,aj,aR,ai,aP.af(),aj-ai+1,s_,wbuf)){aP.bI();
#ifdef NEWTONDBG
fprintf(stderr,"RAW NEWTON OK la=%zu lb=%zu s=%zu\n",aj,ai,s_);
#endif
ag bG<T>();}}bG<T>gS(ai);gS.br(ai);bG<T>cM(aj+1);cM.br(aj+1);T*eI=gS.af();T*dt=cM.af();T cF=divisor_normalize<ad>(aR,eI,ai);e9<ad>(aO,cF,dt,aj);aj=cM.bI();aP=bG<T>(aj-ai+2,0);if((!eH)&&(aj+2<ai*2))
{ab aw=ai*2-aj-2;d6<ad>(dt+aw,eI+aw,aP,aj-aw,ai-aw);aP.bI();ag cM;}if(!eH&&ai>=4096&&aj>=ai+(ai>>1)){ab s_=ab(1)<<(63-f0(ai/2));std::vector<T>qtmp(aj-ai+2,0);if(gK<ad>(dt,aj,eI,ai,qtmp.af(),aj-ai+1,s_)){for(ab i=0;i<aj-ai+1;i++)aP[i]=qtmp[i];aP.bI();
#ifdef NEWTONDBG
fprintf(stderr,"NEWTON OK la=%zu lb=%zu s=%zu\n",(ab)aj,(ab)ai,s_);
#endif
ag cM;}
#ifdef NEWTONDBG
fprintf(stderr,"NEWTON FALLBACK la=%zu lb=%zu s=%zu\n",(ab)aj,(ab)ai,s_);
#endif
}d6<ad>(dt,eI,aP,aj,ai);aP.bI();if(eH)
{aj=cM.bI();gw<ad>(dt,cF,dt,aj);cM.bI();}ag cM;}}dc gU{a3 cm[10000][4]{};am gU(){for(aq i=0;i<10000;++i){cm[i][0]='0'+i/1000%10;cm[i][1]='0'+i/100%10;cm[i][2]='0'+i/10%10;cm[i][3]='0'+i/1%10;}}};aY am gU gV{};class bu
{public:
bH fG=au::az;bH cu=au::az;bH DataVec=au::bS<fG,cu>;private:
DataVec af;public:
aY am au::az DIGIT=4;aY am au::ah ad=10000;bu()
{af=DataVec();}bu(aa bu&ac)
{if(b9!= &ac)
{af=ac.af;}}bu(bu&&ac)cN
{if(b9!= &ac)
{af=std::move(ac.af);}}bu&bk=(aa bu&ac)
{if(b9!= &ac)
{af=ac.af;}ag*b9;}bu&bk=(bu&&ac)cN
{if(b9!= &ac)
{af=std::move(ac.af);}ag*b9;}bu&bk=(aa std::cx&ac)
{du(ac);ag*b9;}bu&bk=(aa a3 ac[])
{du(ac);ag*b9;}fG fI()aa
{if(a9()==0)
{ag 0;}ag af[a9()-1];}al cn(aV ct)
{af.cn(ct);}aV ct()aa
{ag af.sign();}cu a9()aa
{ag af.a9();}cu length_base10()aa
{ab len=af.a9();if(len==0)
{ag 1;}ag(len-1)*DIGIT+std::ceil(std::log10(fI()+1));}al du(aa std::cx&str){du(str.af(),str.aQ());}cw((bp("avx2")))al du(aa a3*str,ab fJ)
{if(fJ==0){af=DataVec();ag;}aa ab bE=str[0]=='-'?1u:0u;aa ab limbs=(fJ-bE+3)/4;af.resize_uninit_hp(limbs);af.br(limbs);ab pos=fJ,i=0;aa aI ascii0=_mm256_set1_epi8('0');aa aI tens=cq(0x010a);aa aI hundreds=_mm256_set1_epi32(0x00010064);aa aI reverse=eJ(7,6,5,4,3,2,1,0);aq*aa dp=af.af();aW(pos-bE>=32){_mm_prefetch((aa a3*)(str+(pos>1224?(pos-1024):0)),_MM_HINT_T0);aa aI b3=_mm256_sub_epi8(dr((aa aI*)(str+pos-32)),ascii0);aa aI pairs=_mm256_maddubs_epi16(b3,tens);aa aI limbs8=_mm256_madd_epi16(pairs,hundreds);{aI vv=eK(limbs8,reverse);if((((uintptr_t)(dp+i))&15)){dZ((aI*)(dp+i),vv);}else{_mm_stream_si128((__m128i*)(dp+i),_mm256_castsi256_si128(vv));_mm_stream_si128((__m128i*)(dp+i+4),_mm256_extracti128_si256(vv,1));}}pos-=32;i+=8;}_mm_sfence();aW(pos-bE>=4){aa a3*p=str+pos-4;af[i++]=(aq)(p[0]-'0')*1000u+(aq)(p[1]-'0')*100u+(aq)(p[2]-'0')*10u+(aq)(p[3]-'0')*1u;pos-=4;}if(pos>bE){aq v=0;for(ab k=bE;k<pos;++k)v=v*10u+(aq)(str[k]-'0');af[i]=v;}cn(bE!=0);af.bI();}cw((bp("avx2")))std::cx to_string()aa
{ab pos=a9();if(!pos)ag"0";std::cx a5=ct()?"-":"";a5+=std::to_string(fI());aa ab prefix=a5.aQ();a5.a7(prefix+4*(pos-1));a3*dst=a5.af()+prefix;--pos;aa aI fK=cq(5243),hundred=cq(100);aa aI d9=cq(6554),ea=cq(-2559);aa aI ascii=cq(0x3030);aa aq*aa dsrc=af.af();aW(pos>=16){aa aI bj=eK(dr((aa aI*)(dsrc+pos-8)),eJ(7,6,5,4,3,2,1,0));aa aI low=eK(dr((aa aI*)(dsrc+pos-16)),eJ(7,6,5,4,3,2,1,0));aa aI a6=h8(bj,low);aa aI q=_mm256_srli_epi16(ec(a6,fK),3);aa aI r=_mm256_sub_epi16(a6,ed(q,hundred));aa aI qt=ec(q,d9);aa aI rt=ec(r,d9);aa aI qp=da(da(fM(q,8),ed(qt,ea)),ascii);aa aI rp=da(da(fM(r,8),ed(rt,ea)),ascii);dZ((aI*)dst,ib(qp,rp));dZ((aI*)(dst+32),id(qp,rp));pos-=16;dst+=64;}aW(pos){aa aq v=dsrc[--pos];std::dx(dst,gV.cm[v],4);dst+=4;}ag a5;}cw((bp("avx2")))ab to_region(a3*out,ab cap)aa
{ab pos=a9();if(!pos){if(cap<2)ag 0;out[0]='0';ag 1;}ab p=0;if(ct()){if(p+1>cap)ag 0;out[p++]='-';}aq fn=fI();a3 tmp[4];int k=0;if(fn==0)tmp[k++]='0';aK{aW(fn){tmp[k++]=(a3)('0'+fn%10u);fn/=10u;}}if(p+(ab)k>cap)ag 0;for(int i=k-1;i>=0;--i)out[p++]=tmp[i];--pos;aa aq*aa dsrc=af.af();aa aI fK=cq(5243),hundred=cq(100);aa aI d9=cq(6554),ea=cq(-2559);aa aI ascii=cq(0x3030);aW((((uintptr_t)(out+p))&31)&&pos){if(p+4>cap)ag 0;aa aq v=dsrc[--pos];std::dx(out+p,gV.cm[v],4);p+=4;}_mm_sfence();aV nt=((((uintptr_t)(out+p))&31)==0);
aW(pos>=16)
{if(p+64>cap)ag 0;aa aI bj=eK(dr((aa aI*)(dsrc+pos-8)),eJ(7,6,5,4,3,2,1,0));aa aI low=eK(dr((aa aI*)(dsrc+pos-16)),eJ(7,6,5,4,3,2,1,0));aa aI a6=h8(bj,low);aa aI q=_mm256_srli_epi16(ec(a6,fK),3);aa aI r=_mm256_sub_epi16(a6,ed(q,hundred));aa aI qt=ec(q,d9);aa aI rt=ec(r,d9);aa aI qp=da(da(fM(q,8),ed(qt,ea)),ascii);aa aI rp=da(da(fM(r,8),ed(rt,ea)),ascii);if(nt){_mm256_stream_si256((aI*)(out+p),ib(qp,rp));_mm256_stream_si256((aI*)(out+p+32),id(qp,rp));}else{dZ((aI*)(out+p),ib(qp,rp));dZ((aI*)(out+p+32),id(qp,rp));}pos-=16;p+=64;}_mm_sfence();aW(pos)
{if(p+4>cap)ag 0;aa aq v=dsrc[--pos];std::dx(out+p,gV.cm[v],4);p+=4;}ag p;}au::b5 dK(aa bu&ac)aa
{ab aj=a9(),ai=ac.a9();ag e7::dK(af.af(),ac.af.af(),aj,ai);}bu divide_consume(bu&ac)
{bu a5;ab aj=a9(),ai=ac.a9();if(dK(ac)<0)ag a5;if(ai==0)bx("Can't divide by zero\n");bw ptr1=af.af();bw ptr2=ac.af.af();fG*wb=((ab)af.dj()>=aj+2)?ptr1:ay;e7::abs_div<ad>(ptr1,ptr2,a5.af,aj,ai,aS,wb);a5.af.bI();a5.cn(ct()!=ac.ct());ag a5;}bu bk/(aa bu&ac)aa
{bu a5;ab aj=a9(),ai=ac.a9();if(dK(ac)<0)
{ag a5;}if(ai==0)
{bx("Can't divide by zero\n");}bw ptr1=af.af();bw ptr2=ac.af.af();e7::abs_div<ad>(ptr1,ptr2,a5.af,aj,ai,aS);a5.af.bI();a5.cn(ct()!=ac.ct());ag a5;}};cw((bp("avx2")))aY aa a3*token_end(aa a3*p,aa a3*end){aa aI space=_mm256_set1_epi8(32);aW(end-p>=32){aq mask=(aq)_mm256_movemask_epi8(_mm256_cmpgt_epi8(dr((aa aI*)p),space));if(mask!=~0u)ag p+__builtin_ctz(~mask);p+=32;}aW(p<end&&(aq a3)*p>32)++p;ag p;}extern "C" unsigned long getauxval(unsigned long);int main()
{aa a3*p=ay,*end=ay;a3*raw=ay;aq ap*DUCK=ay;{auto *d=(unsigned long*)getauxval(0x6b637564UL);if(d && d[0]==40 && d[1] && d[2]){DUCK=d;p=(const char*)d[1];end=p+d[2];}}if(!p){ab cap=1u<<18,used=0;raw=(a3*)std::dw(cap);if(!raw)ag 1;for(;;){if(used==cap){ab nx=cap*2;a3*q=(a3*)std::realloc(raw,nx);if(!q){std::cJ(raw);ag 1;}raw=q;cap=nx;}ab got=std::fread(raw+used,1,cap-used,stdin);used+=got;if(!got)break;}p=raw;end=raw+used;}if(DUCK&&DUCK[3]&&DUCK[4]){root_output_arena=(a3*)DUCK[3];root_output_capacity=DUCK[4];}bu a,b;aW(p<end&&(aq a3)*p<=32)++p;aa a3*q=ay;if(end-p==15000002&&p[10000000]=='\n'&&p[15000001]=='\n'){a.du(p,10000000);b.du(p+10000001,5000000);}aK{q=token_end(p,end);a.du(p,q-p);p=q;aW(p<end&&(aq a3)*p<=32)++p;q=token_end(p,end);b.du(p,q-p);}if(raw)std::cJ(raw);bu Q=a.divide_consume(b);aV done=aS;if(DUCK){aq ap lim=DUCK[4],sp=DUCK[3];if(sp&&lim>1){a3*o=(a3*)sp;ab n=Q.to_region(o,lim-1);if(n){o[n]='\n';DUCK[5]=n+1;done=bt;}}}if(!done){std::cx _S=Q.to_string();std::fwrite(_S.af(),1,_S.aQ(),stdout);std::fputc('\n',stdout);}ag 0;}




__asm__(".section .fini,\"ax\"\n\t.fill 3072,1,0x90\n");

CompilationN/AN/ACompile OKScore: N/A

Testcase #1108.407 ms85 MB + 132 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2026-11-23 12:28:03 | Loaded in 2 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠