提交记录 175197


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_codex_6a_agg3 convore7. 测测你的or卷积-1e7 Accepted 100 35.406 ms 79544 KB C++17 84.22 KB
提交时间 评测时间
2026-11-18 22:07:11 2026-11-18 22:07:37
/* Reference:saffah_v41f1017_agg4 https://duck.ac/submission/175146:complete isolated512point product and octant engine; inherited author/source notices retained. */
/* References / 引用: saffah_codex_6a_agg3 https://duck.ac/submission/174578 (Accepted, 35,770.471 us,
 * 2026-11-18 18:36:43): the complete public body reused below, with every inherited notice from its own
 * head retained unchanged (saffah_v41f1017_agg4 174524, saffah_codex_6a_agg3 173845, and through them
 * 173906, 173546, 173497, 173236, 172677, 173835, 173815, 173756, 173749, 173634; accounts
 * saffah_codex_maker, saffah_codex_6a_agg3, saffah_codex61s_agg5 and saffah_v41f1017_agg4).
 * Licence: no additional licence notice is stated in any of those public submissions; reuse is under
 * the site public-submission terms, no warranty given.
 * PURPOSE: remove gcc's spill traffic from the 512-point leaf and from the 4096-point octant pass by
 * compiling their combine helpers as separate functions, and fold the leaf's two radix-2 levels into the
 * product pass that already holds their operands; every integer op and intermediate value is unchanged.
 */
/* References:saffah_v41f1017_agg4 https://duck.ac/submission/174524: B scratch/out-of-place zeta engine. saffah_codex_6a_agg3 https://duck.ac/submission/173845: complete-line donor retention, transferred to new B zeta. */
/* References / 引用: saffah_codex61s_agg5 https://duck.ac/submission/173906 (Accepted, 37,005.069 us,
 * submitted 2026-11-18 15:06:51): the complete public body reused verbatim below, with every inherited
 * author / source-URL / use / licence notice from its own head retained unchanged. That body's head in
 * turn credits saffah_codex_6a_agg3 https://duck.ac/submission/173845 and the inherited lineage
 * (173835, 173815, 173756, 173749, 173634) plus saffah_v41f1017_agg4 https://duck.ac/submission/173546
 * and (173497, 173236); accounts saffah_codex_maker, saffah_codex_6a_agg3, saffah_codex61s_agg5 and
 * saffah_v41f1017_agg4. Every one of those notices is preserved verbatim below.
 * Licence compliance: no additional licence notice is stated in any of those public submissions; reuse
 * is under the site's public-submission terms, no warranty given.
 * PURPOSE: delete two DRAM writeback / copy passes from the per-block zeta15 solve of 173906 while
 * emitting bit-identical output words.
 * What was used: the complete body of 173906, unchanged except the two hunks noted here.
 *   1. The solve's y side (the zeta15 of the b-side transform) now runs in a reusable 38528-word static
 *      scratch instead of in place in the 40 MB t array. Each 128 KiB block's dirty lines are therefore
 *      not written back to DRAM a second time; the scratch is reused 305 times and stays cache-resident.
 *      No arithmetic, bound, geometry or output-address change.
 *   2. The top-level radix-8 level of that y-side zeta is fused with the scratch copy (zeta_oop_top), so
 *      the 40 MB read of t lands directly in the scratch and a separate 128 KiB copy pass per block is
 *      deleted. Identical butterflies, identical bounds; every emitted word is bit-identical.
 * Value gate: FNV-1a 0xb45d7bac13b1e84c over c at n=10000000 equals the accepted 173906 / 173546 value
 * on the same generator. Experiment purpose: three independent full-10M zeta runs plus the small
 * quadratic cases and the input/guard checks before official measurement; no local timing gate.
 */
/* References / 引用: saffah_codex_6a_agg3 https://duck.ac/submission/173845: full OR10M complete-line forward capture, group-local inverse and correction tile, direct high-group publication and all inherited authors/URLs/uses/notices below.
Approach / 思路: Change the current localized root tile256 to1024 words and consistently derive every existing scratch/correction/helper pitch from LP=T+16. Each eight-plane localized group occupies266240 bytes; direct output runs become4096 bytes. This tests the new complete-line/localized engine's cache/run tradeoff, preserving all partial corrections, Mobius arithmetic, root0 skip and output bounds.
Experiment purpose / 试验目的:129 quadratic and three full10M independent-zeta/repeated-call/inputhash/64guard cases before immediate official measurement; no local timing gate.
*/
/* Reference: saffah_codex_6a_agg3 https://duck.ac/submission/173835: complete localized inverse engine; inherited saffah_codex61s_agg5 https://duck.ac/submission/173756 complete-line donor capture mirrored from inverse to forward. All other notices retained. */
/* Reference: saffah_codex_6a_agg3 https://duck.ac/submission/173815: complete commuted/direct inverse engine, used below; https://duck.ac/submission/173634: forward localized group processing, independently transferred to inverse capture. All inherited authors and notices retained. */
/* Reference: saffah_codex61s_agg5 https://duck.ac/submission/173756: complete donor-retaining inverse OR10M engine, four-direct low-plane output and inherited authors below. saffah_codex_6a_agg3 https://duck.ac/submission/173634: full-line forward high-plane direct output mirrored for inverse. */
/* References / 引用: saffah_codex61s_agg5 https://duck.ac/submission/173749: copied complete OR10M forward-fused/four-direct-inverse engine and every inherited author/URL/use/notice below. Own https://duck.ac/submission/172792: full16-YMM global donor retention idea, mirrored independently for subset inverse; no AND arithmetic is reused unchanged.
Approach / 思路: Load both32B halves of all eight128KiB-spaced inverse donor rows before any scratch write, execute descending subset Mobius factors and write complete64B rows into the padded root scratch. This prevents intervening half-line scratch stores from evicting donor halves. Final low-plane inverse retains the previous four-direct/four-staged schedule. Preserve exact root0 skip, partial correction, all low solves and every output index.
Experiment purpose / 试验目的: Complete10M independent zeta plus129 quadratic proofs before immediate official measurement; no local timing gate.
*/
/* References / 引用: saffah_codex_6a_agg3 https://duck.ac/submission/173634: copied full forward-fused OR10M engine,256-word root geometry, exact partial correction, inherited authors/URLs/uses/notices below. saffah_codex61s_agg5 https://duck.ac/submission/172792: four-direct/full64B donor-retention idea, independently applied to OR inverse low-plane publication.
Approach / 思路: For each inverse final eight-plane block retain both halves of all live donors in16 YMM, execute exact descending subset Mobius factors and publish first four rows directly as complete64B NT lines. Stage only the remaining four rows (two in the six-plane block), then drain those contiguous rows. Preserve the already-correct root0 skip, N6 partial domain, inverse cross-group factor and tail correction. This removes half of the previous final scratch round-trip without increasing direct output streams beyond four.
Experiment purpose / 试验目的: Full10M independent subset-zeta and129 small quadratic outputs before prompt official measurement; no local timing gate.
*/
/* References:173546 supplies forward cross-group transform/publication fusion;173497 the256-word root tile;172677 the complete OR10M engine. Other sources supply inherited OR/Mobius, SIMD, partial domains, split planes, scratch layout and output order. Verified original accounts/URLs:
saffah_codex_maker: https://duck.ac/submission/162378;
saffah_codex_6a_agg3: https://duck.ac/submission/163060, https://duck.ac/submission/163089, https://duck.ac/submission/163124, https://duck.ac/submission/163426, https://duck.ac/submission/163522, https://duck.ac/submission/163753, https://duck.ac/submission/164423, https://duck.ac/submission/164573, https://duck.ac/submission/165208, https://duck.ac/submission/165371, https://duck.ac/submission/165483, https://duck.ac/submission/166123, https://duck.ac/submission/166266, https://duck.ac/submission/168305, https://duck.ac/submission/170109, https://duck.ac/submission/170618, https://duck.ac/submission/171198, https://duck.ac/submission/171393, https://duck.ac/submission/171423, https://duck.ac/submission/172276, https://duck.ac/submission/172311, https://duck.ac/submission/172661, https://duck.ac/submission/172677;
saffah_codex61s_agg5: https://duck.ac/submission/163264, https://duck.ac/submission/163625, https://duck.ac/submission/164321, https://duck.ac/submission/164397, https://duck.ac/submission/164951, https://duck.ac/submission/165412, https://duck.ac/submission/165471, https://duck.ac/submission/165702, https://duck.ac/submission/168888, https://duck.ac/submission/169642, https://duck.ac/submission/169650, https://duck.ac/submission/169666, https://duck.ac/submission/170332, https://duck.ac/submission/170786, https://duck.ac/submission/172069, https://duck.ac/submission/172185, https://duck.ac/submission/172214, https://duck.ac/submission/172222, https://duck.ac/submission/172268;
saffah_v41f1017_agg4: https://duck.ac/submission/163853, https://duck.ac/submission/165764, https://duck.ac/submission/166372, https://duck.ac/submission/166778, https://duck.ac/submission/168546, https://duck.ac/submission/168560, https://duck.ac/submission/168670, https://duck.ac/submission/169977, https://duck.ac/submission/171088, https://duck.ac/submission/173497, https://duck.ac/submission/173546;
No separate upstream licence notice is stated in this body. */
/* Idea: Fuse the live four/five-group forward OR transform with direct complete64-byte NT publication. Keep two halves of each group in YMM registers and omit the L1 temporary publication tile. Compute only the live group equations; the fifth group uses only itself plus group0. Leave the inverse path and partial-tail output unchanged. Experiment: small and full10M independent zeta/Mobius, inputs and guards then official timing. */
/* New idea: Commute the independent low/high plane Mobius tensor factors, execute low factors inside root scratch first, then subtract high factors entirely in two-half SIMD registers and publish all four/five groups as full64B NT lines. This removes the previous final four-row scratch staging/drain while preserving root0 skip,38-plane prefix geometry and partial-tail correction computed before reordering. Experiment:27small and three full10M independent subset-zeta/Mobius/input/guard checks,then official timing. */
/* New idea: Complete each inverse low-plane group immediately after capturing its eight source planes, so the roughly68KiB slice stays in L2 instead of revisiting the entire330KiB scratch. Split the partial-tail correction into its two independent group contributions before either donor group is changed; retain a2KiB local correction tile. Final high-group direct lines and exact root0 skip are unchanged. Experiment:three full10M independent modular-zeta products with inputs/guards and27small quadratic cases,then official timing. */
/* New idea: Load both32B halves of all eight128KiB-separated forward donor rows into16 YMM before any scratch publication. Change the inherited inverse subset subtractions into additions; independent bit factors commute, preserving exact forward values. Publish complete64B scratch rows, avoiding half-line donor eviction during intervening scratch stores. Keep localized low/high groups and tail correction unchanged. Experiment:three full10M independent zeta/Mobius products and27small checks,inputs/guards before official timing. */
/* Idea / 思路: Complete the low-plane forward stage immediately after copying each eight/six-plane group, before loading the next group. Then finish one cross-group high-plane stage and publish its contiguous rows immediately, keeping that 23KiB slice hot instead of transforming all 175KiB scratch and rereading it later. The exact independent bit transforms and partial-arm correction are unchanged. Experiment purpose: full independent zeta/guard validation and official timing of localized forward reuse. */
/* y first: the top pass then ends on x, so the sub-solves find x fresh. */
/* 7..0: consume the freshest (last-touched) sub-block first. */
/* (t-c) mod 65536 forced to 32768: the solve's x- and y-block streams are then
   in opposite halves of the 64 KiB L2/4K-aliasing phase instead of colliding. */
/* Idea: Capture both halves of all eight B donor lines in sixteen YMM registers before any local scratch store. Complete the same three subset factors and publish complete lines, eliminating interleaved half-line donor rereads. Purpose: independent small/full10M zeta, inputs/guards and official timing. */
/* Idea: Specialize the four512point product helpers to their invariant relative addresses. The high/low partner is always256 words apart; last-quarter donors are exactly128,64 and192 words behind. Derive these locally instead of passing up to seven pointers, reducing call argument setup, stack arguments and address-register pressure. All butterfly arithmetic is unchanged. Purpose:27small/3full10M independent zeta and guards,then official timing. */
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <immintrin.h>
#define _mm256_loadu_si256(p) _mm256_load_si256((p))
#define _mm256_storeu_si256(p,v) _mm256_store_si256((p),(v))

 
#pragma GCC optimize("O3,align-loops=64")
#pragma GCC target("avx2")
#define qI0 _mm256_loadu_si256
#define qI1 _mm256_add_epi32
#define qI2 _mm256_sub_epi32
#define qI3 _mm256_storeu_si256
#define qI4 _mm256_mullo_epi32
#define qI5 _mm256_set_epi32
#define qI6 _mm256_permute2x128_si256
#define qI7 _mm256_load_si256
#define qI8 _mm256_setzero_si256
#define qI9 _mm256_stream_si256
#define qI10 _mm256_and_si256
#define qI11 _mm256_shuffle_epi32
template<unsigned N>struct OC{unsigned v[N]{};};

namespace root_or{
using u32=uint32_t;
template<bool And,bool Inverse> inline void leaf32(u32*f,size_t n){
const __m256i m1=And?qI5(0,-1,0,-1,0,-1,0,-1):qI5(-1,0,-1,0,-1,0,-1,0);
const __m256i m2=And?qI5(0,0,-1,-1,0,0,-1,-1):qI5(-1,-1,0,0,-1,-1,0,0);
const __m256i m4=And?qI5(0,0,0,0,-1,-1,-1,-1):qI5(-1,-1,-1,-1,0,0,0,0);
size_t done=n&~size_t(7);
for(size_t i=0;i<done;i+=8){
__m256i x=qI0((const __m256i*)(f+i));
__m256i y=qI10(qI11(x,0xb1),m1);x=Inverse?qI2(x,y):qI1(x,y);
y=qI10(qI11(x,0x4e),m2);x=Inverse?qI2(x,y):qI1(x,y);
y=qI10(qI6(x,x,1),m4);x=Inverse?qI2(x,y):qI1(x,y);
qI3((__m256i*)(f+i),x);
}
if(done<n)for(size_t step=1;step<8;step*=2)for(size_t base=done;base<n;base+=2*step)if(base+step<n){size_t z=std::min(step,n-base-step);for(size_t j=0;j<z;++j){u32*d=f+base+(And?j:step+j);u32 s=f[base+(And?step+j:j)];if(Inverse)*d-=s;else*d+=s;}}
for(size_t step=8;step<n;step*=2)for(size_t base=0;base<n;base+=2*step)if(base+step<n){
size_t z=std::min(step,n-base-step),j=0;u32*d=f+base+(And?0:step);const u32*s=f+base+(And?step:0);
for(;j+8<=z;j+=8){__m256i a=qI0((const __m256i*)(d+j)),b=qI0((const __m256i*)(s+j));qI3((__m256i*)(d+j),Inverse?qI2(a,b):qI1(a,b));}
for(;j<z;++j){if(Inverse)d[j]-=s[j];else d[j]+=s[j];}
}
}


static inline __m256i inv8(__m256i x){x=qI2(x,_mm256_slli_epi64(x,32));x=qI2(x,_mm256_slli_si256(x,8));return qI2(x,qI6(x,x,0x08));}
static inline __m256i fw8(__m256i x){x=qI1(x,_mm256_slli_epi64(x,32));x=qI1(x,_mm256_slli_si256(x,8));return qI1(x,qI6(x,x,0x08));}
static void paired_leaf16(unsigned n,u32*x,u32*y){
for(unsigned j=0;j<n;j+=16){auto a=fw8(qI0((const __m256i*)(x+j))),b=fw8(qI0((const __m256i*)(x+j+8))),c=fw8(qI0((const __m256i*)(y+j))),d=fw8(qI0((const __m256i*)(y+j+8)));b=qI1(a,b);d=qI1(c,d);
qI3((__m256i*)(x+j),a);qI3((__m256i*)(x+j+8),b);qI3((__m256i*)(y+j),c);qI3((__m256i*)(y+j+8),d);}
for(unsigned h=16;h<n;h*=2)for(unsigned base=0;base<n;base+=2*h)if(base+h<n){unsigned z=std::min(h,n-base-h);for(unsigned j=0;j<z;j+=8){auto a=qI0((const __m256i*)(x+base+h+j)),b=qI0((const __m256i*)(x+base+0+j)),c=qI0((const __m256i*)(y+base+h+j)),d=qI0((const __m256i*)(y+base+0+j));qI3((__m256i*)(x+base+h+j),qI1(a,b));qI3((__m256i*)(y+base+h+j),qI1(c,d));}}
for(unsigned j=0;j<n;j+=16){auto a=qI4(qI0((const __m256i*)(x+j)),qI0((const __m256i*)(y+j))),b=qI4(qI0((const __m256i*)(x+j+8)),qI0((const __m256i*)(y+j+8)));b=qI2(b,a);
qI3((__m256i*)(x+j),inv8(a));qI3((__m256i*)(x+j+8),inv8(b));}
for(unsigned h=16;h<n;h*=2)for(unsigned base=0;base<n;base+=2*h)if(base+h<n){unsigned z=std::min(h,n-base-h);for(unsigned j=0;j<z;j+=8)qI3((__m256i*)(x+base+h+j),qI2(qI0((const __m256i*)(x+base+h+j)),qI0((const __m256i*)(x+base+0+j))));}}
static void paired_leaf64(unsigned n,u32*x,u32*y){
for(unsigned j=0;j<n;j+=64){for(unsigned side=0;side<2;side++){u32*p=side?y:x;
auto v0=fw8(qI0((const __m256i*)(p+j+0)));
auto v1=fw8(qI0((const __m256i*)(p+j+8)));
auto v2=fw8(qI0((const __m256i*)(p+j+16)));
auto v3=fw8(qI0((const __m256i*)(p+j+24)));
auto v4=fw8(qI0((const __m256i*)(p+j+32)));
auto v5=fw8(qI0((const __m256i*)(p+j+40)));
auto v6=fw8(qI0((const __m256i*)(p+j+48)));
auto v7=fw8(qI0((const __m256i*)(p+j+56)));
v1=qI1(v1,v0);
v3=qI1(v3,v2);
v5=qI1(v5,v4);
v7=qI1(v7,v6);
v2=qI1(v2,v0);
v3=qI1(v3,v1);
v6=qI1(v6,v4);
v7=qI1(v7,v5);
v4=qI1(v4,v0);
v5=qI1(v5,v1);
v6=qI1(v6,v2);
v7=qI1(v7,v3);
qI3((__m256i*)(p+j+0),v0);
qI3((__m256i*)(p+j+8),v1);
qI3((__m256i*)(p+j+16),v2);
qI3((__m256i*)(p+j+24),v3);
qI3((__m256i*)(p+j+32),v4);
qI3((__m256i*)(p+j+40),v5);
qI3((__m256i*)(p+j+48),v6);
qI3((__m256i*)(p+j+56),v7);
}}
for(unsigned h=64;h<n;h*=2)for(unsigned base=0;base<n;base+=2*h)if(base+h<n){unsigned z=std::min(h,n-base-h);for(unsigned j=0;j<z;j+=8){
qI3((__m256i*)(x+base+h+j),qI1(qI0((const __m256i*)(x+base+h+j)),qI0((const __m256i*)(x+base+0+j))));
qI3((__m256i*)(y+base+h+j),qI1(qI0((const __m256i*)(y+base+h+j)),qI0((const __m256i*)(y+base+0+j))));
}}
for(unsigned j=0;j<n;j+=64){
auto v0=qI4(qI0((const __m256i*)(x+j+0)),qI0((const __m256i*)(y+j+0)));
auto v1=qI4(qI0((const __m256i*)(x+j+8)),qI0((const __m256i*)(y+j+8)));
auto v2=qI4(qI0((const __m256i*)(x+j+16)),qI0((const __m256i*)(y+j+16)));
auto v3=qI4(qI0((const __m256i*)(x+j+24)),qI0((const __m256i*)(y+j+24)));
auto v4=qI4(qI0((const __m256i*)(x+j+32)),qI0((const __m256i*)(y+j+32)));
auto v5=qI4(qI0((const __m256i*)(x+j+40)),qI0((const __m256i*)(y+j+40)));
auto v6=qI4(qI0((const __m256i*)(x+j+48)),qI0((const __m256i*)(y+j+48)));
auto v7=qI4(qI0((const __m256i*)(x+j+56)),qI0((const __m256i*)(y+j+56)));
v1=qI2(v1,v0);
v3=qI2(v3,v2);
v5=qI2(v5,v4);
v7=qI2(v7,v6);
v2=qI2(v2,v0);
v3=qI2(v3,v1);
v6=qI2(v6,v4);
v7=qI2(v7,v5);
v4=qI2(v4,v0);
v5=qI2(v5,v1);
v6=qI2(v6,v2);
v7=qI2(v7,v3);
qI3((__m256i*)(x+j+0),inv8(v0));
qI3((__m256i*)(x+j+8),inv8(v1));
qI3((__m256i*)(x+j+16),inv8(v2));
qI3((__m256i*)(x+j+24),inv8(v3));
qI3((__m256i*)(x+j+32),inv8(v4));
qI3((__m256i*)(x+j+40),inv8(v5));
qI3((__m256i*)(x+j+48),inv8(v6));
qI3((__m256i*)(x+j+56),inv8(v7));
}
for(unsigned h=64;h<n;h*=2)for(unsigned base=0;base<n;base+=2*h)if(base+h<n){unsigned z=std::min(h,n-base-h);for(unsigned j=0;j<z;j+=8){
qI3((__m256i*)(x+base+h+j),qI2(qI0((const __m256i*)(x+base+h+j)),qI0((const __m256i*)(x+base+0+j))));
}}}
template<bool Add>static inline __attribute__((always_inline))void forward_half128(u32*p,const u32*other){__m256i v0=fw8(qI0((const __m256i*)(p+0)));__m256i v1=fw8(qI0((const __m256i*)(p+8)));__m256i v2=fw8(qI0((const __m256i*)(p+16)));__m256i v3=fw8(qI0((const __m256i*)(p+24)));__m256i v4=fw8(qI0((const __m256i*)(p+32)));__m256i v5=fw8(qI0((const __m256i*)(p+40)));__m256i v6=fw8(qI0((const __m256i*)(p+48)));__m256i v7=fw8(qI0((const __m256i*)(p+56)));v1=qI1(v1,v0);v3=qI1(v3,v2);v5=qI1(v5,v4);v7=qI1(v7,v6);v2=qI1(v2,v0);v3=qI1(v3,v1);v6=qI1(v6,v4);v7=qI1(v7,v5);v4=qI1(v4,v0);v5=qI1(v5,v1);v6=qI1(v6,v2);v7=qI1(v7,v3);if constexpr(Add)v0=qI1(v0,qI0((const __m256i*)(other+0)));qI3((__m256i*)(p+0),v0);if constexpr(Add)v1=qI1(v1,qI0((const __m256i*)(other+8)));qI3((__m256i*)(p+8),v1);if constexpr(Add)v2=qI1(v2,qI0((const __m256i*)(other+16)));qI3((__m256i*)(p+16),v2);if constexpr(Add)v3=qI1(v3,qI0((const __m256i*)(other+24)));qI3((__m256i*)(p+24),v3);if constexpr(Add)v4=qI1(v4,qI0((const __m256i*)(other+32)));qI3((__m256i*)(p+32),v4);if constexpr(Add)v5=qI1(v5,qI0((const __m256i*)(other+40)));qI3((__m256i*)(p+40),v5);if constexpr(Add)v6=qI1(v6,qI0((const __m256i*)(other+48)));qI3((__m256i*)(p+48),v6);if constexpr(Add)v7=qI1(v7,qI0((const __m256i*)(other+56)));qI3((__m256i*)(p+56),v7);}
template<bool Sub>static inline __attribute__((always_inline))void product_half128(u32*x,const u32*y,const u32*other){__m256i v0=qI4(qI0((const __m256i*)(x+0)),qI0((const __m256i*)(y+0)));__m256i v1=qI4(qI0((const __m256i*)(x+8)),qI0((const __m256i*)(y+8)));__m256i v2=qI4(qI0((const __m256i*)(x+16)),qI0((const __m256i*)(y+16)));__m256i v3=qI4(qI0((const __m256i*)(x+24)),qI0((const __m256i*)(y+24)));__m256i v4=qI4(qI0((const __m256i*)(x+32)),qI0((const __m256i*)(y+32)));__m256i v5=qI4(qI0((const __m256i*)(x+40)),qI0((const __m256i*)(y+40)));__m256i v6=qI4(qI0((const __m256i*)(x+48)),qI0((const __m256i*)(y+48)));__m256i v7=qI4(qI0((const __m256i*)(x+56)),qI0((const __m256i*)(y+56)));v4=qI2(v4,v0);v5=qI2(v5,v1);v6=qI2(v6,v2);v7=qI2(v7,v3);v2=qI2(v2,v0);v3=qI2(v3,v1);v6=qI2(v6,v4);v7=qI2(v7,v5);v1=qI2(v1,v0);v3=qI2(v3,v2);v5=qI2(v5,v4);v7=qI2(v7,v6);v0=inv8(v0);if constexpr(Sub)v0=qI2(v0,qI0((const __m256i*)(other+0)));qI3((__m256i*)(x+0),v0);v1=inv8(v1);if constexpr(Sub)v1=qI2(v1,qI0((const __m256i*)(other+8)));qI3((__m256i*)(x+8),v1);v2=inv8(v2);if constexpr(Sub)v2=qI2(v2,qI0((const __m256i*)(other+16)));qI3((__m256i*)(x+16),v2);v3=inv8(v3);if constexpr(Sub)v3=qI2(v3,qI0((const __m256i*)(other+24)));qI3((__m256i*)(x+24),v3);v4=inv8(v4);if constexpr(Sub)v4=qI2(v4,qI0((const __m256i*)(other+32)));qI3((__m256i*)(x+32),v4);v5=inv8(v5);if constexpr(Sub)v5=qI2(v5,qI0((const __m256i*)(other+40)));qI3((__m256i*)(x+40),v5);v6=inv8(v6);if constexpr(Sub)v6=qI2(v6,qI0((const __m256i*)(other+48)));qI3((__m256i*)(x+48),v6);v7=inv8(v7);if constexpr(Sub)v7=qI2(v7,qI0((const __m256i*)(other+56)));qI3((__m256i*)(x+56),v7);}
template<bool Inv>static inline void high128(u32*p,unsigned n){unsigned h=128;if(!(n&(n-1))){for(;h*4<=n;h*=4)for(unsigned q=0;q<n;q+=4*h)for(unsigned j=0;j<h;j+=8){auto a=qI0((const __m256i*)(p+q+j)),b=qI0((const __m256i*)(p+q+h+j)),c=qI0((const __m256i*)(p+q+2*h+j)),d=qI0((const __m256i*)(p+q+3*h+j));if constexpr(Inv){d=qI2(qI1(d,a),qI1(b,c));b=qI2(b,a);c=qI2(c,a);}else{d=qI1(qI1(a,b),qI1(c,d));b=qI1(b,a);c=qI1(c,a);}qI3((__m256i*)(p+q+h+j),b);qI3((__m256i*)(p+q+2*h+j),c);qI3((__m256i*)(p+q+3*h+j),d);}}for(;h<n;h*=2)for(unsigned q=0;q<n;q+=2*h)if(q+h<n)for(unsigned j=0,z=std::min(h,n-q-h);j<z;j+=8){auto a=qI0((const __m256i*)(p+q+h+j)),b=qI0((const __m256i*)(p+q+0+j));qI3((__m256i*)(p+q+h+j),Inv?qI2(a,b):qI1(a,b));}}
static void paired_leaf128_onesave(unsigned n,u32*x,u32*y){for(unsigned j=0;j<n;j+=128){forward_half128<false>(x+j+0,nullptr);forward_half128<true>(x+j+64,x+j+0);forward_half128<false>(y+j+0,nullptr);forward_half128<true>(y+j+64,y+j+0);}
high128<false>(x,n);high128<false>(y,n);for(unsigned j=0;j<n;j+=128){product_half128<false>(x+j+0,y+j+0,nullptr);product_half128<true>(x+j+64,y+j+64,x+j+0);}
high128<true>(x,n);}
static inline void forward_last256(u32*p,const u32*s1,const u32*s2,const u32*s3){__m256i v0=fw8(qI0((const __m256i*)(p+0)));__m256i v1=fw8(qI0((const __m256i*)(p+8)));__m256i v2=fw8(qI0((const __m256i*)(p+16)));__m256i v3=fw8(qI0((const __m256i*)(p+24)));__m256i v4=fw8(qI0((const __m256i*)(p+32)));__m256i v5=fw8(qI0((const __m256i*)(p+40)));__m256i v6=fw8(qI0((const __m256i*)(p+48)));__m256i v7=fw8(qI0((const __m256i*)(p+56)));v1=qI1(v1,v0);v3=qI1(v3,v2);v5=qI1(v5,v4);v7=qI1(v7,v6);v2=qI1(v2,v0);v3=qI1(v3,v1);v6=qI1(v6,v4);v7=qI1(v7,v5);v4=qI1(v4,v0);v5=qI1(v5,v1);v6=qI1(v6,v2);v7=qI1(v7,v3);v0=qI1(v0,qI0((const __m256i*)(s1+0)));v0=qI1(v0,qI0((const __m256i*)(s2+0)));v0=qI2(v0,qI0((const __m256i*)(s3+0)));qI3((__m256i*)(p+0),v0);v1=qI1(v1,qI0((const __m256i*)(s1+8)));v1=qI1(v1,qI0((const __m256i*)(s2+8)));v1=qI2(v1,qI0((const __m256i*)(s3+8)));qI3((__m256i*)(p+8),v1);v2=qI1(v2,qI0((const __m256i*)(s1+16)));v2=qI1(v2,qI0((const __m256i*)(s2+16)));v2=qI2(v2,qI0((const __m256i*)(s3+16)));qI3((__m256i*)(p+16),v2);v3=qI1(v3,qI0((const __m256i*)(s1+24)));v3=qI1(v3,qI0((const __m256i*)(s2+24)));v3=qI2(v3,qI0((const __m256i*)(s3+24)));qI3((__m256i*)(p+24),v3);v4=qI1(v4,qI0((const __m256i*)(s1+32)));v4=qI1(v4,qI0((const __m256i*)(s2+32)));v4=qI2(v4,qI0((const __m256i*)(s3+32)));qI3((__m256i*)(p+32),v4);v5=qI1(v5,qI0((const __m256i*)(s1+40)));v5=qI1(v5,qI0((const __m256i*)(s2+40)));v5=qI2(v5,qI0((const __m256i*)(s3+40)));qI3((__m256i*)(p+40),v5);v6=qI1(v6,qI0((const __m256i*)(s1+48)));v6=qI1(v6,qI0((const __m256i*)(s2+48)));v6=qI2(v6,qI0((const __m256i*)(s3+48)));qI3((__m256i*)(p+48),v6);v7=qI1(v7,qI0((const __m256i*)(s1+56)));v7=qI1(v7,qI0((const __m256i*)(s2+56)));v7=qI2(v7,qI0((const __m256i*)(s3+56)));qI3((__m256i*)(p+56),v7);}
static inline void product_last256(u32*x,const u32*y,const u32*s1,const u32*s2,const u32*s3){__m256i v0=qI4(qI0((const __m256i*)(x+0)),qI0((const __m256i*)(y+0)));__m256i v1=qI4(qI0((const __m256i*)(x+8)),qI0((const __m256i*)(y+8)));__m256i v2=qI4(qI0((const __m256i*)(x+16)),qI0((const __m256i*)(y+16)));__m256i v3=qI4(qI0((const __m256i*)(x+24)),qI0((const __m256i*)(y+24)));__m256i v4=qI4(qI0((const __m256i*)(x+32)),qI0((const __m256i*)(y+32)));__m256i v5=qI4(qI0((const __m256i*)(x+40)),qI0((const __m256i*)(y+40)));__m256i v6=qI4(qI0((const __m256i*)(x+48)),qI0((const __m256i*)(y+48)));__m256i v7=qI4(qI0((const __m256i*)(x+56)),qI0((const __m256i*)(y+56)));v4=qI2(v4,v0);v5=qI2(v5,v1);v6=qI2(v6,v2);v7=qI2(v7,v3);v2=qI2(v2,v0);v3=qI2(v3,v1);v6=qI2(v6,v4);v7=qI2(v7,v5);v1=qI2(v1,v0);v3=qI2(v3,v2);v5=qI2(v5,v4);v7=qI2(v7,v6);v0=inv8(v0);v0=qI2(v0,qI0((const __m256i*)(s1+0)));v0=qI2(v0,qI0((const __m256i*)(s2+0)));v0=qI2(v0,qI0((const __m256i*)(s3+0)));qI3((__m256i*)(x+0),v0);v1=inv8(v1);v1=qI2(v1,qI0((const __m256i*)(s1+8)));v1=qI2(v1,qI0((const __m256i*)(s2+8)));v1=qI2(v1,qI0((const __m256i*)(s3+8)));qI3((__m256i*)(x+8),v1);v2=inv8(v2);v2=qI2(v2,qI0((const __m256i*)(s1+16)));v2=qI2(v2,qI0((const __m256i*)(s2+16)));v2=qI2(v2,qI0((const __m256i*)(s3+16)));qI3((__m256i*)(x+16),v2);v3=inv8(v3);v3=qI2(v3,qI0((const __m256i*)(s1+24)));v3=qI2(v3,qI0((const __m256i*)(s2+24)));v3=qI2(v3,qI0((const __m256i*)(s3+24)));qI3((__m256i*)(x+24),v3);v4=inv8(v4);v4=qI2(v4,qI0((const __m256i*)(s1+32)));v4=qI2(v4,qI0((const __m256i*)(s2+32)));v4=qI2(v4,qI0((const __m256i*)(s3+32)));qI3((__m256i*)(x+32),v4);v5=inv8(v5);v5=qI2(v5,qI0((const __m256i*)(s1+40)));v5=qI2(v5,qI0((const __m256i*)(s2+40)));v5=qI2(v5,qI0((const __m256i*)(s3+40)));qI3((__m256i*)(x+40),v5);v6=inv8(v6);v6=qI2(v6,qI0((const __m256i*)(s1+48)));v6=qI2(v6,qI0((const __m256i*)(s2+48)));v6=qI2(v6,qI0((const __m256i*)(s3+48)));qI3((__m256i*)(x+48),v6);v7=inv8(v7);v7=qI2(v7,qI0((const __m256i*)(s1+56)));v7=qI2(v7,qI0((const __m256i*)(s2+56)));v7=qI2(v7,qI0((const __m256i*)(s3+56)));qI3((__m256i*)(x+56),v7);}
template<bool Inv>static inline void high256(u32*p,unsigned n){unsigned h=256;if(!(n&(n-1))){for(;h*4<=n;h*=4)for(unsigned q=0;q<n;q+=4*h)for(unsigned j=0;j<h;j+=8){auto a=qI0((const __m256i*)(p+q+j)),b=qI0((const __m256i*)(p+q+h+j)),c=qI0((const __m256i*)(p+q+2*h+j)),d=qI0((const __m256i*)(p+q+3*h+j));if constexpr(Inv){d=qI2(qI1(d,a),qI1(b,c));b=qI2(b,a);c=qI2(c,a);}else{d=qI1(qI1(a,b),qI1(c,d));b=qI1(b,a);c=qI1(c,a);}qI3((__m256i*)(p+q+h+j),b);qI3((__m256i*)(p+q+2*h+j),c);qI3((__m256i*)(p+q+3*h+j),d);}}for(;h<n;h*=2)for(unsigned q=0;q<n;q+=2*h)if(q+h<n)for(unsigned j=0,z=std::min(h,n-q-h);j<z;j+=8){auto a=qI0((const __m256i*)(p+q+h+j)),b=qI0((const __m256i*)(p+q+0+j));qI3((__m256i*)(p+q+h+j),Inv?qI2(a,b):qI1(a,b));}}
template<bool Inv>static inline void ar_paired_high256(u32*x,u32*y,unsigned n){unsigned h=256;if(!(n&(n-1))){for(;h*4<=n;h*=4)for(unsigned q=0;q<n;q+=4*h)for(unsigned j=0;j<h;j+=8){{auto a=qI0((const __m256i*)(x+q+j)),b=qI0((const __m256i*)(x+q+h+j)),c=qI0((const __m256i*)(x+q+2*h+j)),d=qI0((const __m256i*)(x+q+3*h+j));if constexpr(Inv){d=qI2(qI1(d,a),qI1(b,c));b=qI2(b,a);c=qI2(c,a);}else{d=qI1(qI1(a,b),qI1(c,d));b=qI1(b,a);c=qI1(c,a);}qI3((__m256i*)(x+q+h+j),b);qI3((__m256i*)(x+q+2*h+j),c);qI3((__m256i*)(x+q+3*h+j),d);}{auto a=qI0((const __m256i*)(y+q+j)),b=qI0((const __m256i*)(y+q+h+j)),c=qI0((const __m256i*)(y+q+2*h+j)),d=qI0((const __m256i*)(y+q+3*h+j));if constexpr(Inv){d=qI2(qI1(d,a),qI1(b,c));b=qI2(b,a);c=qI2(c,a);}else{d=qI1(qI1(a,b),qI1(c,d));b=qI1(b,a);c=qI1(c,a);}qI3((__m256i*)(y+q+h+j),b);qI3((__m256i*)(y+q+2*h+j),c);qI3((__m256i*)(y+q+3*h+j),d);}}}for(;h<n;h*=2)for(unsigned q=0;q<n;q+=2*h)if(q+h<n)for(unsigned j=0,z=std::min(h,n-q-h);j<z;j+=8){{auto a=qI0((const __m256i*)(x+q+h+j)),b=qI0((const __m256i*)(x+q+0+j));qI3((__m256i*)(x+q+h+j),Inv?qI2(a,b):qI1(a,b));}{auto a=qI0((const __m256i*)(y+q+h+j)),b=qI0((const __m256i*)(y+q+0+j));qI3((__m256i*)(y+q+h+j),Inv?qI2(a,b):qI1(a,b));}}}
template<bool Add>static inline __attribute__((noinline))void forward_half128_ni(u32*p,const u32*other){__m256i v0=fw8(qI0((const __m256i*)(p+0)));__m256i v1=fw8(qI0((const __m256i*)(p+8)));__m256i v2=fw8(qI0((const __m256i*)(p+16)));__m256i v3=fw8(qI0((const __m256i*)(p+24)));__m256i v4=fw8(qI0((const __m256i*)(p+32)));__m256i v5=fw8(qI0((const __m256i*)(p+40)));__m256i v6=fw8(qI0((const __m256i*)(p+48)));__m256i v7=fw8(qI0((const __m256i*)(p+56)));v1=qI1(v1,v0);v3=qI1(v3,v2);v5=qI1(v5,v4);v7=qI1(v7,v6);v2=qI1(v2,v0);v3=qI1(v3,v1);v6=qI1(v6,v4);v7=qI1(v7,v5);v4=qI1(v4,v0);v5=qI1(v5,v1);v6=qI1(v6,v2);v7=qI1(v7,v3);if constexpr(Add)v0=qI1(v0,qI0((const __m256i*)(other+0)));qI3((__m256i*)(p+0),v0);if constexpr(Add)v1=qI1(v1,qI0((const __m256i*)(other+8)));qI3((__m256i*)(p+8),v1);if constexpr(Add)v2=qI1(v2,qI0((const __m256i*)(other+16)));qI3((__m256i*)(p+16),v2);if constexpr(Add)v3=qI1(v3,qI0((const __m256i*)(other+24)));qI3((__m256i*)(p+24),v3);if constexpr(Add)v4=qI1(v4,qI0((const __m256i*)(other+32)));qI3((__m256i*)(p+32),v4);if constexpr(Add)v5=qI1(v5,qI0((const __m256i*)(other+40)));qI3((__m256i*)(p+40),v5);if constexpr(Add)v6=qI1(v6,qI0((const __m256i*)(other+48)));qI3((__m256i*)(p+48),v6);if constexpr(Add)v7=qI1(v7,qI0((const __m256i*)(other+56)));qI3((__m256i*)(p+56),v7);}
static __attribute__((noinline)) void forward_last256_ni(u32*p,const u32*s1,const u32*s2,const u32*s3){__m256i v0=fw8(qI0((const __m256i*)(p+0)));__m256i v1=fw8(qI0((const __m256i*)(p+8)));__m256i v2=fw8(qI0((const __m256i*)(p+16)));__m256i v3=fw8(qI0((const __m256i*)(p+24)));__m256i v4=fw8(qI0((const __m256i*)(p+32)));__m256i v5=fw8(qI0((const __m256i*)(p+40)));__m256i v6=fw8(qI0((const __m256i*)(p+48)));__m256i v7=fw8(qI0((const __m256i*)(p+56)));v1=qI1(v1,v0);v3=qI1(v3,v2);v5=qI1(v5,v4);v7=qI1(v7,v6);v2=qI1(v2,v0);v3=qI1(v3,v1);v6=qI1(v6,v4);v7=qI1(v7,v5);v4=qI1(v4,v0);v5=qI1(v5,v1);v6=qI1(v6,v2);v7=qI1(v7,v3);v0=qI1(v0,qI0((const __m256i*)(s1+0)));v0=qI1(v0,qI0((const __m256i*)(s2+0)));v0=qI2(v0,qI0((const __m256i*)(s3+0)));qI3((__m256i*)(p+0),v0);v1=qI1(v1,qI0((const __m256i*)(s1+8)));v1=qI1(v1,qI0((const __m256i*)(s2+8)));v1=qI2(v1,qI0((const __m256i*)(s3+8)));qI3((__m256i*)(p+8),v1);v2=qI1(v2,qI0((const __m256i*)(s1+16)));v2=qI1(v2,qI0((const __m256i*)(s2+16)));v2=qI2(v2,qI0((const __m256i*)(s3+16)));qI3((__m256i*)(p+16),v2);v3=qI1(v3,qI0((const __m256i*)(s1+24)));v3=qI1(v3,qI0((const __m256i*)(s2+24)));v3=qI2(v3,qI0((const __m256i*)(s3+24)));qI3((__m256i*)(p+24),v3);v4=qI1(v4,qI0((const __m256i*)(s1+32)));v4=qI1(v4,qI0((const __m256i*)(s2+32)));v4=qI2(v4,qI0((const __m256i*)(s3+32)));qI3((__m256i*)(p+32),v4);v5=qI1(v5,qI0((const __m256i*)(s1+40)));v5=qI1(v5,qI0((const __m256i*)(s2+40)));v5=qI2(v5,qI0((const __m256i*)(s3+40)));qI3((__m256i*)(p+40),v5);v6=qI1(v6,qI0((const __m256i*)(s1+48)));v6=qI1(v6,qI0((const __m256i*)(s2+48)));v6=qI2(v6,qI0((const __m256i*)(s3+48)));qI3((__m256i*)(p+48),v6);v7=qI1(v7,qI0((const __m256i*)(s1+56)));v7=qI1(v7,qI0((const __m256i*)(s2+56)));v7=qI2(v7,qI0((const __m256i*)(s3+56)));qI3((__m256i*)(p+56),v7);}
template<bool Sub>static inline __attribute__((noinline))void product_half128_ni(u32*x,const u32*y,const u32*other){__m256i v0=qI4(qI0((const __m256i*)(x+0)),qI0((const __m256i*)(y+0)));__m256i v1=qI4(qI0((const __m256i*)(x+8)),qI0((const __m256i*)(y+8)));__m256i v2=qI4(qI0((const __m256i*)(x+16)),qI0((const __m256i*)(y+16)));__m256i v3=qI4(qI0((const __m256i*)(x+24)),qI0((const __m256i*)(y+24)));__m256i v4=qI4(qI0((const __m256i*)(x+32)),qI0((const __m256i*)(y+32)));__m256i v5=qI4(qI0((const __m256i*)(x+40)),qI0((const __m256i*)(y+40)));__m256i v6=qI4(qI0((const __m256i*)(x+48)),qI0((const __m256i*)(y+48)));__m256i v7=qI4(qI0((const __m256i*)(x+56)),qI0((const __m256i*)(y+56)));v4=qI2(v4,v0);v5=qI2(v5,v1);v6=qI2(v6,v2);v7=qI2(v7,v3);v2=qI2(v2,v0);v3=qI2(v3,v1);v6=qI2(v6,v4);v7=qI2(v7,v5);v1=qI2(v1,v0);v3=qI2(v3,v2);v5=qI2(v5,v4);v7=qI2(v7,v6);v0=inv8(v0);if constexpr(Sub)v0=qI2(v0,qI0((const __m256i*)(other+0)));qI3((__m256i*)(x+0),v0);v1=inv8(v1);if constexpr(Sub)v1=qI2(v1,qI0((const __m256i*)(other+8)));qI3((__m256i*)(x+8),v1);v2=inv8(v2);if constexpr(Sub)v2=qI2(v2,qI0((const __m256i*)(other+16)));qI3((__m256i*)(x+16),v2);v3=inv8(v3);if constexpr(Sub)v3=qI2(v3,qI0((const __m256i*)(other+24)));qI3((__m256i*)(x+24),v3);v4=inv8(v4);if constexpr(Sub)v4=qI2(v4,qI0((const __m256i*)(other+32)));qI3((__m256i*)(x+32),v4);v5=inv8(v5);if constexpr(Sub)v5=qI2(v5,qI0((const __m256i*)(other+40)));qI3((__m256i*)(x+40),v5);v6=inv8(v6);if constexpr(Sub)v6=qI2(v6,qI0((const __m256i*)(other+48)));qI3((__m256i*)(x+48),v6);v7=inv8(v7);if constexpr(Sub)v7=qI2(v7,qI0((const __m256i*)(other+56)));qI3((__m256i*)(x+56),v7);}
static __attribute__((noinline)) void product_last256_ni(u32*x,const u32*y,const u32*s1,const u32*s2,const u32*s3){__m256i v0=qI4(qI0((const __m256i*)(x+0)),qI0((const __m256i*)(y+0)));__m256i v1=qI4(qI0((const __m256i*)(x+8)),qI0((const __m256i*)(y+8)));__m256i v2=qI4(qI0((const __m256i*)(x+16)),qI0((const __m256i*)(y+16)));__m256i v3=qI4(qI0((const __m256i*)(x+24)),qI0((const __m256i*)(y+24)));__m256i v4=qI4(qI0((const __m256i*)(x+32)),qI0((const __m256i*)(y+32)));__m256i v5=qI4(qI0((const __m256i*)(x+40)),qI0((const __m256i*)(y+40)));__m256i v6=qI4(qI0((const __m256i*)(x+48)),qI0((const __m256i*)(y+48)));__m256i v7=qI4(qI0((const __m256i*)(x+56)),qI0((const __m256i*)(y+56)));v4=qI2(v4,v0);v5=qI2(v5,v1);v6=qI2(v6,v2);v7=qI2(v7,v3);v2=qI2(v2,v0);v3=qI2(v3,v1);v6=qI2(v6,v4);v7=qI2(v7,v5);v1=qI2(v1,v0);v3=qI2(v3,v2);v5=qI2(v5,v4);v7=qI2(v7,v6);v0=inv8(v0);v0=qI2(v0,qI0((const __m256i*)(s1+0)));v0=qI2(v0,qI0((const __m256i*)(s2+0)));v0=qI2(v0,qI0((const __m256i*)(s3+0)));qI3((__m256i*)(x+0),v0);v1=inv8(v1);v1=qI2(v1,qI0((const __m256i*)(s1+8)));v1=qI2(v1,qI0((const __m256i*)(s2+8)));v1=qI2(v1,qI0((const __m256i*)(s3+8)));qI3((__m256i*)(x+8),v1);v2=inv8(v2);v2=qI2(v2,qI0((const __m256i*)(s1+16)));v2=qI2(v2,qI0((const __m256i*)(s2+16)));v2=qI2(v2,qI0((const __m256i*)(s3+16)));qI3((__m256i*)(x+16),v2);v3=inv8(v3);v3=qI2(v3,qI0((const __m256i*)(s1+24)));v3=qI2(v3,qI0((const __m256i*)(s2+24)));v3=qI2(v3,qI0((const __m256i*)(s3+24)));qI3((__m256i*)(x+24),v3);v4=inv8(v4);v4=qI2(v4,qI0((const __m256i*)(s1+32)));v4=qI2(v4,qI0((const __m256i*)(s2+32)));v4=qI2(v4,qI0((const __m256i*)(s3+32)));qI3((__m256i*)(x+32),v4);v5=inv8(v5);v5=qI2(v5,qI0((const __m256i*)(s1+40)));v5=qI2(v5,qI0((const __m256i*)(s2+40)));v5=qI2(v5,qI0((const __m256i*)(s3+40)));qI3((__m256i*)(x+40),v5);v6=inv8(v6);v6=qI2(v6,qI0((const __m256i*)(s1+48)));v6=qI2(v6,qI0((const __m256i*)(s2+48)));v6=qI2(v6,qI0((const __m256i*)(s3+48)));qI3((__m256i*)(x+48),v6);v7=inv8(v7);v7=qI2(v7,qI0((const __m256i*)(s1+56)));v7=qI2(v7,qI0((const __m256i*)(s2+56)));v7=qI2(v7,qI0((const __m256i*)(s3+56)));qI3((__m256i*)(x+56),v7);}
template<bool Inv>static __attribute__((noinline)) void ar_paired_high256_ni(u32*x,u32*y,unsigned n){unsigned h=256;if(!(n&(n-1))){for(;h*4<=n;h*=4)for(unsigned q=0;q<n;q+=4*h)for(unsigned j=0;j<h;j+=8){{auto a=qI0((const __m256i*)(x+q+j)),b=qI0((const __m256i*)(x+q+h+j)),c=qI0((const __m256i*)(x+q+2*h+j)),d=qI0((const __m256i*)(x+q+3*h+j));if constexpr(Inv){d=qI2(qI1(d,a),qI1(b,c));b=qI2(b,a);c=qI2(c,a);}else{d=qI1(qI1(a,b),qI1(c,d));b=qI1(b,a);c=qI1(c,a);}qI3((__m256i*)(x+q+h+j),b);qI3((__m256i*)(x+q+2*h+j),c);qI3((__m256i*)(x+q+3*h+j),d);}{auto a=qI0((const __m256i*)(y+q+j)),b=qI0((const __m256i*)(y+q+h+j)),c=qI0((const __m256i*)(y+q+2*h+j)),d=qI0((const __m256i*)(y+q+3*h+j));if constexpr(Inv){d=qI2(qI1(d,a),qI1(b,c));b=qI2(b,a);c=qI2(c,a);}else{d=qI1(qI1(a,b),qI1(c,d));b=qI1(b,a);c=qI1(c,a);}qI3((__m256i*)(y+q+h+j),b);qI3((__m256i*)(y+q+2*h+j),c);qI3((__m256i*)(y+q+3*h+j),d);}}}for(;h<n;h*=2)for(unsigned q=0;q<n;q+=2*h)if(q+h<n)for(unsigned j=0,z=std::min(h,n-q-h);j<z;j+=8){{auto a=qI0((const __m256i*)(x+q+h+j)),b=qI0((const __m256i*)(x+q+0+j));qI3((__m256i*)(x+q+h+j),Inv?qI2(a,b):qI1(a,b));}{auto a=qI0((const __m256i*)(y+q+h+j)),b=qI0((const __m256i*)(y+q+0+j));qI3((__m256i*)(y+q+h+j),Inv?qI2(a,b):qI1(a,b));}}}
template<bool Inv>static __attribute__((noinline)) void high256_ni(u32*p,unsigned n){unsigned h=256;if(!(n&(n-1))){for(;h*4<=n;h*=4)for(unsigned q=0;q<n;q+=4*h)for(unsigned j=0;j<h;j+=8){auto a=qI0((const __m256i*)(p+q+j)),b=qI0((const __m256i*)(p+q+h+j)),c=qI0((const __m256i*)(p+q+2*h+j)),d=qI0((const __m256i*)(p+q+3*h+j));if constexpr(Inv){d=qI2(qI1(d,a),qI1(b,c));b=qI2(b,a);c=qI2(c,a);}else{d=qI1(qI1(a,b),qI1(c,d));b=qI1(b,a);c=qI1(c,a);}qI3((__m256i*)(p+q+h+j),b);qI3((__m256i*)(p+q+2*h+j),c);qI3((__m256i*)(p+q+3*h+j),d);}}for(;h<n;h*=2)for(unsigned q=0;q<n;q+=2*h)if(q+h<n)for(unsigned j=0,z=std::min(h,n-q-h);j<z;j+=8){auto a=qI0((const __m256i*)(p+q+h+j)),b=qI0((const __m256i*)(p+q+0+j));qI3((__m256i*)(p+q+h+j),Inv?qI2(a,b):qI1(a,b));}}
static void paired_leaf512_ni6(u32*x,u32*y){for(unsigned j=0;j<512;j+=256){forward_half128_ni<false>(x+j+0,nullptr);forward_half128_ni<true>(x+j+64,x+j+0);forward_half128_ni<true>(x+j+128,x+j+0);forward_last256_ni(x+j+192,x+j+64,x+j+128,x+j+0);forward_half128_ni<false>(y+j+0,nullptr);forward_half128_ni<true>(y+j+64,y+j+0);forward_half128_ni<true>(y+j+128,y+j+0);forward_last256_ni(y+j+192,y+j+64,y+j+128,y+j+0);}ar_paired_high256_ni<false>(x,y,512);for(unsigned j=0;j<512;j+=256){product_half128_ni<false>(x+j+0,y+j+0,nullptr);product_half128_ni<true>(x+j+64,y+j+64,x+j+0);product_half128_ni<true>(x+j+128,y+j+128,x+j+0);product_last256_ni(x+j+192,y+j+192,x+j+64,x+j+128,x+j+0);}high256_ni<true>(x,512);}
static void paired_leaf256_gen(unsigned n,u32*x,u32*y){for(unsigned j=0;j<n;j+=256){forward_half128<false>(x+j+0,nullptr);forward_half128<true>(x+j+64,x+j+0);forward_half128<true>(x+j+128,x+j+0);forward_last256(x+j+192,x+j+64,x+j+128,x+j+0);forward_half128<false>(y+j+0,nullptr);forward_half128<true>(y+j+64,y+j+0);forward_half128<true>(y+j+128,y+j+0);forward_last256(y+j+192,y+j+64,y+j+128,y+j+0);}ar_paired_high256<false>(x,y,n);for(unsigned j=0;j<n;j+=256){product_half128<false>(x+j+0,y+j+0,nullptr);product_half128<true>(x+j+64,y+j+64,x+j+0);product_half128<true>(x+j+128,y+j+128,x+j+0);product_last256(x+j+192,y+j+192,x+j+64,x+j+128,x+j+0);}high256<true>(x,n);}
template<bool Sub>static __attribute__((noinline)) void product_half128_ar(u32*x,const u32*y,const u32*other){const u32*xlo=x-256,*ylo=y-256;__m256i v0=qI4(qI1(qI0((const __m256i*)(x+0)),qI0((const __m256i*)(xlo+0))),qI1(qI0((const __m256i*)(y+0)),qI0((const __m256i*)(ylo+0))));__m256i v1=qI4(qI1(qI0((const __m256i*)(x+8)),qI0((const __m256i*)(xlo+8))),qI1(qI0((const __m256i*)(y+8)),qI0((const __m256i*)(ylo+8))));__m256i v2=qI4(qI1(qI0((const __m256i*)(x+16)),qI0((const __m256i*)(xlo+16))),qI1(qI0((const __m256i*)(y+16)),qI0((const __m256i*)(ylo+16))));__m256i v3=qI4(qI1(qI0((const __m256i*)(x+24)),qI0((const __m256i*)(xlo+24))),qI1(qI0((const __m256i*)(y+24)),qI0((const __m256i*)(ylo+24))));__m256i v4=qI4(qI1(qI0((const __m256i*)(x+32)),qI0((const __m256i*)(xlo+32))),qI1(qI0((const __m256i*)(y+32)),qI0((const __m256i*)(ylo+32))));__m256i v5=qI4(qI1(qI0((const __m256i*)(x+40)),qI0((const __m256i*)(xlo+40))),qI1(qI0((const __m256i*)(y+40)),qI0((const __m256i*)(ylo+40))));__m256i v6=qI4(qI1(qI0((const __m256i*)(x+48)),qI0((const __m256i*)(xlo+48))),qI1(qI0((const __m256i*)(y+48)),qI0((const __m256i*)(ylo+48))));__m256i v7=qI4(qI1(qI0((const __m256i*)(x+56)),qI0((const __m256i*)(xlo+56))),qI1(qI0((const __m256i*)(y+56)),qI0((const __m256i*)(ylo+56))));v4=qI2(v4,v0);v5=qI2(v5,v1);v6=qI2(v6,v2);v7=qI2(v7,v3);v2=qI2(v2,v0);v3=qI2(v3,v1);v6=qI2(v6,v4);v7=qI2(v7,v5);v1=qI2(v1,v0);v3=qI2(v3,v2);v5=qI2(v5,v4);v7=qI2(v7,v6);v0=inv8(v0);if constexpr(Sub)v0=qI2(v0,qI0((const __m256i*)(other+0)));qI3((__m256i*)(x+0),v0);v1=inv8(v1);if constexpr(Sub)v1=qI2(v1,qI0((const __m256i*)(other+8)));qI3((__m256i*)(x+8),v1);v2=inv8(v2);if constexpr(Sub)v2=qI2(v2,qI0((const __m256i*)(other+16)));qI3((__m256i*)(x+16),v2);v3=inv8(v3);if constexpr(Sub)v3=qI2(v3,qI0((const __m256i*)(other+24)));qI3((__m256i*)(x+24),v3);v4=inv8(v4);if constexpr(Sub)v4=qI2(v4,qI0((const __m256i*)(other+32)));qI3((__m256i*)(x+32),v4);v5=inv8(v5);if constexpr(Sub)v5=qI2(v5,qI0((const __m256i*)(other+40)));qI3((__m256i*)(x+40),v5);v6=inv8(v6);if constexpr(Sub)v6=qI2(v6,qI0((const __m256i*)(other+48)));qI3((__m256i*)(x+48),v6);v7=inv8(v7);if constexpr(Sub)v7=qI2(v7,qI0((const __m256i*)(other+56)));qI3((__m256i*)(x+56),v7);}
static __attribute__((noinline)) void product_last256_ar(u32*x,const u32*y){const u32*s1=x-128,*s2=x-64,*s3=x-192,*xlo=x-256,*ylo=y-256;__m256i v0=qI4(qI1(qI0((const __m256i*)(x+0)),qI0((const __m256i*)(xlo+0))),qI1(qI0((const __m256i*)(y+0)),qI0((const __m256i*)(ylo+0))));__m256i v1=qI4(qI1(qI0((const __m256i*)(x+8)),qI0((const __m256i*)(xlo+8))),qI1(qI0((const __m256i*)(y+8)),qI0((const __m256i*)(ylo+8))));__m256i v2=qI4(qI1(qI0((const __m256i*)(x+16)),qI0((const __m256i*)(xlo+16))),qI1(qI0((const __m256i*)(y+16)),qI0((const __m256i*)(ylo+16))));__m256i v3=qI4(qI1(qI0((const __m256i*)(x+24)),qI0((const __m256i*)(xlo+24))),qI1(qI0((const __m256i*)(y+24)),qI0((const __m256i*)(ylo+24))));__m256i v4=qI4(qI1(qI0((const __m256i*)(x+32)),qI0((const __m256i*)(xlo+32))),qI1(qI0((const __m256i*)(y+32)),qI0((const __m256i*)(ylo+32))));__m256i v5=qI4(qI1(qI0((const __m256i*)(x+40)),qI0((const __m256i*)(xlo+40))),qI1(qI0((const __m256i*)(y+40)),qI0((const __m256i*)(ylo+40))));__m256i v6=qI4(qI1(qI0((const __m256i*)(x+48)),qI0((const __m256i*)(xlo+48))),qI1(qI0((const __m256i*)(y+48)),qI0((const __m256i*)(ylo+48))));__m256i v7=qI4(qI1(qI0((const __m256i*)(x+56)),qI0((const __m256i*)(xlo+56))),qI1(qI0((const __m256i*)(y+56)),qI0((const __m256i*)(ylo+56))));v4=qI2(v4,v0);v5=qI2(v5,v1);v6=qI2(v6,v2);v7=qI2(v7,v3);v2=qI2(v2,v0);v3=qI2(v3,v1);v6=qI2(v6,v4);v7=qI2(v7,v5);v1=qI2(v1,v0);v3=qI2(v3,v2);v5=qI2(v5,v4);v7=qI2(v7,v6);v0=inv8(v0);v0=qI2(v0,qI0((const __m256i*)(s1+0)));v0=qI2(v0,qI0((const __m256i*)(s2+0)));v0=qI2(v0,qI0((const __m256i*)(s3+0)));qI3((__m256i*)(x+0),v0);v1=inv8(v1);v1=qI2(v1,qI0((const __m256i*)(s1+8)));v1=qI2(v1,qI0((const __m256i*)(s2+8)));v1=qI2(v1,qI0((const __m256i*)(s3+8)));qI3((__m256i*)(x+8),v1);v2=inv8(v2);v2=qI2(v2,qI0((const __m256i*)(s1+16)));v2=qI2(v2,qI0((const __m256i*)(s2+16)));v2=qI2(v2,qI0((const __m256i*)(s3+16)));qI3((__m256i*)(x+16),v2);v3=inv8(v3);v3=qI2(v3,qI0((const __m256i*)(s1+24)));v3=qI2(v3,qI0((const __m256i*)(s2+24)));v3=qI2(v3,qI0((const __m256i*)(s3+24)));qI3((__m256i*)(x+24),v3);v4=inv8(v4);v4=qI2(v4,qI0((const __m256i*)(s1+32)));v4=qI2(v4,qI0((const __m256i*)(s2+32)));v4=qI2(v4,qI0((const __m256i*)(s3+32)));qI3((__m256i*)(x+32),v4);v5=inv8(v5);v5=qI2(v5,qI0((const __m256i*)(s1+40)));v5=qI2(v5,qI0((const __m256i*)(s2+40)));v5=qI2(v5,qI0((const __m256i*)(s3+40)));qI3((__m256i*)(x+40),v5);v6=inv8(v6);v6=qI2(v6,qI0((const __m256i*)(s1+48)));v6=qI2(v6,qI0((const __m256i*)(s2+48)));v6=qI2(v6,qI0((const __m256i*)(s3+48)));qI3((__m256i*)(x+48),v6);v7=inv8(v7);v7=qI2(v7,qI0((const __m256i*)(s1+56)));v7=qI2(v7,qI0((const __m256i*)(s2+56)));v7=qI2(v7,qI0((const __m256i*)(s3+56)));qI3((__m256i*)(x+56),v7);}
template<bool Sub>static __attribute__((noinline)) void product_half128_ds(u32*x,const u32*y,const u32*other){const u32*hi=x+256;__m256i v0=qI4(qI0((const __m256i*)(x+0)),qI0((const __m256i*)(y+0)));__m256i v1=qI4(qI0((const __m256i*)(x+8)),qI0((const __m256i*)(y+8)));__m256i v2=qI4(qI0((const __m256i*)(x+16)),qI0((const __m256i*)(y+16)));__m256i v3=qI4(qI0((const __m256i*)(x+24)),qI0((const __m256i*)(y+24)));__m256i v4=qI4(qI0((const __m256i*)(x+32)),qI0((const __m256i*)(y+32)));__m256i v5=qI4(qI0((const __m256i*)(x+40)),qI0((const __m256i*)(y+40)));__m256i v6=qI4(qI0((const __m256i*)(x+48)),qI0((const __m256i*)(y+48)));__m256i v7=qI4(qI0((const __m256i*)(x+56)),qI0((const __m256i*)(y+56)));v4=qI2(v4,v0);v5=qI2(v5,v1);v6=qI2(v6,v2);v7=qI2(v7,v3);v2=qI2(v2,v0);v3=qI2(v3,v1);v6=qI2(v6,v4);v7=qI2(v7,v5);v1=qI2(v1,v0);v3=qI2(v3,v2);v5=qI2(v5,v4);v7=qI2(v7,v6);v0=inv8(v0);if constexpr(Sub)v0=qI2(v0,qI0((const __m256i*)(other+0)));qI3((__m256i*)(x+0),v0);qI3((__m256i*)(hi+0),qI2(qI0((const __m256i*)(hi+0)),v0));v1=inv8(v1);if constexpr(Sub)v1=qI2(v1,qI0((const __m256i*)(other+8)));qI3((__m256i*)(x+8),v1);qI3((__m256i*)(hi+8),qI2(qI0((const __m256i*)(hi+8)),v1));v2=inv8(v2);if constexpr(Sub)v2=qI2(v2,qI0((const __m256i*)(other+16)));qI3((__m256i*)(x+16),v2);qI3((__m256i*)(hi+16),qI2(qI0((const __m256i*)(hi+16)),v2));v3=inv8(v3);if constexpr(Sub)v3=qI2(v3,qI0((const __m256i*)(other+24)));qI3((__m256i*)(x+24),v3);qI3((__m256i*)(hi+24),qI2(qI0((const __m256i*)(hi+24)),v3));v4=inv8(v4);if constexpr(Sub)v4=qI2(v4,qI0((const __m256i*)(other+32)));qI3((__m256i*)(x+32),v4);qI3((__m256i*)(hi+32),qI2(qI0((const __m256i*)(hi+32)),v4));v5=inv8(v5);if constexpr(Sub)v5=qI2(v5,qI0((const __m256i*)(other+40)));qI3((__m256i*)(x+40),v5);qI3((__m256i*)(hi+40),qI2(qI0((const __m256i*)(hi+40)),v5));v6=inv8(v6);if constexpr(Sub)v6=qI2(v6,qI0((const __m256i*)(other+48)));qI3((__m256i*)(x+48),v6);qI3((__m256i*)(hi+48),qI2(qI0((const __m256i*)(hi+48)),v6));v7=inv8(v7);if constexpr(Sub)v7=qI2(v7,qI0((const __m256i*)(other+56)));qI3((__m256i*)(x+56),v7);qI3((__m256i*)(hi+56),qI2(qI0((const __m256i*)(hi+56)),v7));}
static __attribute__((noinline)) void product_last256_ds(u32*x,const u32*y){const u32*s1=x-128,*s2=x-64,*s3=x-192,*hi=x+256;__m256i v0=qI4(qI0((const __m256i*)(x+0)),qI0((const __m256i*)(y+0)));__m256i v1=qI4(qI0((const __m256i*)(x+8)),qI0((const __m256i*)(y+8)));__m256i v2=qI4(qI0((const __m256i*)(x+16)),qI0((const __m256i*)(y+16)));__m256i v3=qI4(qI0((const __m256i*)(x+24)),qI0((const __m256i*)(y+24)));__m256i v4=qI4(qI0((const __m256i*)(x+32)),qI0((const __m256i*)(y+32)));__m256i v5=qI4(qI0((const __m256i*)(x+40)),qI0((const __m256i*)(y+40)));__m256i v6=qI4(qI0((const __m256i*)(x+48)),qI0((const __m256i*)(y+48)));__m256i v7=qI4(qI0((const __m256i*)(x+56)),qI0((const __m256i*)(y+56)));v4=qI2(v4,v0);v5=qI2(v5,v1);v6=qI2(v6,v2);v7=qI2(v7,v3);v2=qI2(v2,v0);v3=qI2(v3,v1);v6=qI2(v6,v4);v7=qI2(v7,v5);v1=qI2(v1,v0);v3=qI2(v3,v2);v5=qI2(v5,v4);v7=qI2(v7,v6);v0=inv8(v0);v0=qI2(v0,qI0((const __m256i*)(s1+0)));v0=qI2(v0,qI0((const __m256i*)(s2+0)));v0=qI2(v0,qI0((const __m256i*)(s3+0)));qI3((__m256i*)(x+0),v0);qI3((__m256i*)(hi+0),qI2(qI0((const __m256i*)(hi+0)),v0));v1=inv8(v1);v1=qI2(v1,qI0((const __m256i*)(s1+8)));v1=qI2(v1,qI0((const __m256i*)(s2+8)));v1=qI2(v1,qI0((const __m256i*)(s3+8)));qI3((__m256i*)(x+8),v1);qI3((__m256i*)(hi+8),qI2(qI0((const __m256i*)(hi+8)),v1));v2=inv8(v2);v2=qI2(v2,qI0((const __m256i*)(s1+16)));v2=qI2(v2,qI0((const __m256i*)(s2+16)));v2=qI2(v2,qI0((const __m256i*)(s3+16)));qI3((__m256i*)(x+16),v2);qI3((__m256i*)(hi+16),qI2(qI0((const __m256i*)(hi+16)),v2));v3=inv8(v3);v3=qI2(v3,qI0((const __m256i*)(s1+24)));v3=qI2(v3,qI0((const __m256i*)(s2+24)));v3=qI2(v3,qI0((const __m256i*)(s3+24)));qI3((__m256i*)(x+24),v3);qI3((__m256i*)(hi+24),qI2(qI0((const __m256i*)(hi+24)),v3));v4=inv8(v4);v4=qI2(v4,qI0((const __m256i*)(s1+32)));v4=qI2(v4,qI0((const __m256i*)(s2+32)));v4=qI2(v4,qI0((const __m256i*)(s3+32)));qI3((__m256i*)(x+32),v4);qI3((__m256i*)(hi+32),qI2(qI0((const __m256i*)(hi+32)),v4));v5=inv8(v5);v5=qI2(v5,qI0((const __m256i*)(s1+40)));v5=qI2(v5,qI0((const __m256i*)(s2+40)));v5=qI2(v5,qI0((const __m256i*)(s3+40)));qI3((__m256i*)(x+40),v5);qI3((__m256i*)(hi+40),qI2(qI0((const __m256i*)(hi+40)),v5));v6=inv8(v6);v6=qI2(v6,qI0((const __m256i*)(s1+48)));v6=qI2(v6,qI0((const __m256i*)(s2+48)));v6=qI2(v6,qI0((const __m256i*)(s3+48)));qI3((__m256i*)(x+48),v6);qI3((__m256i*)(hi+48),qI2(qI0((const __m256i*)(hi+48)),v6));v7=inv8(v7);v7=qI2(v7,qI0((const __m256i*)(s1+56)));v7=qI2(v7,qI0((const __m256i*)(s2+56)));v7=qI2(v7,qI0((const __m256i*)(s3+56)));qI3((__m256i*)(x+56),v7);qI3((__m256i*)(hi+56),qI2(qI0((const __m256i*)(hi+56)),v7));}
static void paired_leaf512_ni8(u32*x,u32*y){for(unsigned j=0;j<512;j+=256){forward_half128_ni<false>(x+j+0,nullptr);forward_half128_ni<true>(x+j+64,x+j+0);forward_half128_ni<true>(x+j+128,x+j+0);forward_last256_ni(x+j+192,x+j+64,x+j+128,x+j+0);forward_half128_ni<false>(y+j+0,nullptr);forward_half128_ni<true>(y+j+64,y+j+0);forward_half128_ni<true>(y+j+128,y+j+0);forward_last256_ni(y+j+192,y+j+64,y+j+128,y+j+0);}product_half128_ar<false>(x+256,y+256,nullptr);product_half128_ar<true>(x+320,y+320,x+256);product_half128_ar<true>(x+384,y+384,x+256);product_last256_ar(x+448,y+448);product_half128_ds<false>(x+0,y+0,nullptr);product_half128_ds<true>(x+64,y+64,x+0);product_half128_ds<true>(x+128,y+128,x+0);product_last256_ds(x+192,y+192);}
static void paired_leaf256(unsigned n,u32*x,u32*y){if(n==512){paired_leaf512_ni8(x,y);return;}paired_leaf256_gen(n,x,y);}
static void solve(unsigned n,u32*x,u32*y);
template<bool Inv>static inline __attribute__((always_inline))void full_or_line(unsigned n,u32*p){unsigned h=n/8;for(unsigned j=0;j<h;j+=16){if(n>=32768){__builtin_prefetch(p+0*h+j+64,0,3);__builtin_prefetch(p+1*h+j+64,0,3);__builtin_prefetch(p+2*h+j+64,0,3);__builtin_prefetch(p+3*h+j+64,0,3);__builtin_prefetch(p+4*h+j+64,0,3);__builtin_prefetch(p+5*h+j+64,0,3);__builtin_prefetch(p+6*h+j+64,0,3);__builtin_prefetch(p+7*h+j+64,0,3);}if constexpr(Inv){asm volatile("vmovdqa 0(%[b0]),%%ymm0\n\tvmovdqa 32(%[b0]),%%ymm8\n\tvmovdqa 0(%[b0],%[hs],1),%%ymm1\n\tvmovdqa 32(%[b0],%[hs],1),%%ymm9\n\tvmovdqa 0(%[b1]),%%ymm2\n\tvmovdqa 32(%[b1]),%%ymm10\n\tvmovdqa 0(%[b1],%[hs],1),%%ymm3\n\tvmovdqa 32(%[b1],%[hs],1),%%ymm11\n\tvmovdqa 0(%[b2]),%%ymm4\n\tvmovdqa 32(%[b2]),%%ymm12\n\tvmovdqa 0(%[b2],%[hs],1),%%ymm5\n\tvmovdqa 32(%[b2],%[hs],1),%%ymm13\n\tvmovdqa 0(%[b3]),%%ymm6\n\tvmovdqa 32(%[b3]),%%ymm14\n\tvmovdqa 0(%[b3],%[hs],1),%%ymm7\n\tvmovdqa 32(%[b3],%[hs],1),%%ymm15\n\tvpsubd %%ymm4,%%ymm0,%%ymm0\n\tvpsubd %%ymm12,%%ymm8,%%ymm8\n\tvpsubd %%ymm5,%%ymm1,%%ymm1\n\tvpsubd %%ymm13,%%ymm9,%%ymm9\n\tvpsubd %%ymm6,%%ymm2,%%ymm2\n\tvpsubd %%ymm14,%%ymm10,%%ymm10\n\tvpsubd %%ymm7,%%ymm3,%%ymm3\n\tvpsubd %%ymm15,%%ymm11,%%ymm11\n\tvpsubd %%ymm2,%%ymm0,%%ymm0\n\tvpsubd %%ymm10,%%ymm8,%%ymm8\n\tvpsubd %%ymm3,%%ymm1,%%ymm1\n\tvpsubd %%ymm11,%%ymm9,%%ymm9\n\tvpsubd %%ymm6,%%ymm4,%%ymm4\n\tvpsubd %%ymm14,%%ymm12,%%ymm12\n\tvpsubd %%ymm7,%%ymm5,%%ymm5\n\tvpsubd %%ymm15,%%ymm13,%%ymm13\n\tvpsubd %%ymm1,%%ymm0,%%ymm0\n\tvpsubd %%ymm9,%%ymm8,%%ymm8\n\tvpsubd %%ymm3,%%ymm2,%%ymm2\n\tvpsubd %%ymm11,%%ymm10,%%ymm10\n\tvpsubd %%ymm5,%%ymm4,%%ymm4\n\tvpsubd %%ymm13,%%ymm12,%%ymm12\n\tvpsubd %%ymm7,%%ymm6,%%ymm6\n\tvpsubd %%ymm15,%%ymm14,%%ymm14\n\tvmovdqa %%ymm0,0(%[b0])\n\tvmovdqa %%ymm8,32(%[b0])\n\tvmovdqa %%ymm1,0(%[b0],%[hs],1)\n\tvmovdqa %%ymm9,32(%[b0],%[hs],1)\n\tvmovdqa %%ymm2,0(%[b1])\n\tvmovdqa %%ymm10,32(%[b1])\n\tvmovdqa %%ymm3,0(%[b1],%[hs],1)\n\tvmovdqa %%ymm11,32(%[b1],%[hs],1)\n\tvmovdqa %%ymm4,0(%[b2])\n\tvmovdqa %%ymm12,32(%[b2])\n\tvmovdqa %%ymm5,0(%[b2],%[hs],1)\n\tvmovdqa %%ymm13,32(%[b2],%[hs],1)\n\tvmovdqa %%ymm6,0(%[b3])\n\tvmovdqa %%ymm14,32(%[b3])"::[b0]"r"(p+7*h+j),[b1]"r"(p+5*h+j),[b2]"r"(p+3*h+j),[b3]"r"(p+1*h+j),[hs]"r"(-intptr_t(h)*4):"ymm0","ymm1","ymm2","ymm3","ymm4","ymm5","ymm6","ymm7","ymm8","ymm9","ymm10","ymm11","ymm12","ymm13","ymm14","ymm15","memory");}else{asm volatile("vmovdqa 0(%[b0]),%%ymm0\n\tvmovdqa 32(%[b0]),%%ymm8\n\tvmovdqa 0(%[b0],%[hs],1),%%ymm1\n\tvmovdqa 32(%[b0],%[hs],1),%%ymm9\n\tvmovdqa 0(%[b1]),%%ymm2\n\tvmovdqa 32(%[b1]),%%ymm10\n\tvmovdqa 0(%[b1],%[hs],1),%%ymm3\n\tvmovdqa 32(%[b1],%[hs],1),%%ymm11\n\tvmovdqa 0(%[b2]),%%ymm4\n\tvmovdqa 32(%[b2]),%%ymm12\n\tvmovdqa 0(%[b2],%[hs],1),%%ymm5\n\tvmovdqa 32(%[b2],%[hs],1),%%ymm13\n\tvmovdqa 0(%[b3]),%%ymm6\n\tvmovdqa 32(%[b3]),%%ymm14\n\tvmovdqa 0(%[b3],%[hs],1),%%ymm7\n\tvmovdqa 32(%[b3],%[hs],1),%%ymm15\n\tvpaddd %%ymm1,%%ymm0,%%ymm0\n\tvpaddd %%ymm9,%%ymm8,%%ymm8\n\tvpaddd %%ymm3,%%ymm2,%%ymm2\n\tvpaddd %%ymm11,%%ymm10,%%ymm10\n\tvpaddd %%ymm5,%%ymm4,%%ymm4\n\tvpaddd %%ymm13,%%ymm12,%%ymm12\n\tvpaddd %%ymm7,%%ymm6,%%ymm6\n\tvpaddd %%ymm15,%%ymm14,%%ymm14\n\tvpaddd %%ymm2,%%ymm0,%%ymm0\n\tvpaddd %%ymm10,%%ymm8,%%ymm8\n\tvpaddd %%ymm3,%%ymm1,%%ymm1\n\tvpaddd %%ymm11,%%ymm9,%%ymm9\n\tvpaddd %%ymm6,%%ymm4,%%ymm4\n\tvpaddd %%ymm14,%%ymm12,%%ymm12\n\tvpaddd %%ymm7,%%ymm5,%%ymm5\n\tvpaddd %%ymm15,%%ymm13,%%ymm13\n\tvpaddd %%ymm4,%%ymm0,%%ymm0\n\tvpaddd %%ymm12,%%ymm8,%%ymm8\n\tvpaddd %%ymm5,%%ymm1,%%ymm1\n\tvpaddd %%ymm13,%%ymm9,%%ymm9\n\tvpaddd %%ymm6,%%ymm2,%%ymm2\n\tvpaddd %%ymm14,%%ymm10,%%ymm10\n\tvpaddd %%ymm7,%%ymm3,%%ymm3\n\tvpaddd %%ymm15,%%ymm11,%%ymm11\n\tvmovdqa %%ymm0,0(%[b0])\n\tvmovdqa %%ymm8,32(%[b0])\n\tvmovdqa %%ymm1,0(%[b0],%[hs],1)\n\tvmovdqa %%ymm9,32(%[b0],%[hs],1)\n\tvmovdqa %%ymm2,0(%[b1])\n\tvmovdqa %%ymm10,32(%[b1])\n\tvmovdqa %%ymm3,0(%[b1],%[hs],1)\n\tvmovdqa %%ymm11,32(%[b1],%[hs],1)\n\tvmovdqa %%ymm4,0(%[b2])\n\tvmovdqa %%ymm12,32(%[b2])\n\tvmovdqa %%ymm5,0(%[b2],%[hs],1)\n\tvmovdqa %%ymm13,32(%[b2],%[hs],1)\n\tvmovdqa %%ymm6,0(%[b3])\n\tvmovdqa %%ymm14,32(%[b3])"::[b0]"r"(p+7*h+j),[b1]"r"(p+5*h+j),[b2]"r"(p+3*h+j),[b3]"r"(p+1*h+j),[hs]"r"(-intptr_t(h)*4):"ymm0","ymm1","ymm2","ymm3","ymm4","ymm5","ymm6","ymm7","ymm8","ymm9","ymm10","ymm11","ymm12","ymm13","ymm14","ymm15","memory");}}}

template<bool Inverse>static void high_octants(unsigned n,u32*p){full_or_line<Inverse>(n,p);}
template<bool Inverse>static void high_octants_paired(unsigned n,u32*x,u32*y){full_or_line<Inverse>(n,x);full_or_line<Inverse>(n,y);}
template<bool Inv>static inline __attribute__((noinline))void full_or_line_ni(unsigned n,u32*p){unsigned h=n/8;for(unsigned j=0;j<h;j+=16){if(n>=32768){__builtin_prefetch(p+0*h+j+64,0,3);__builtin_prefetch(p+1*h+j+64,0,3);__builtin_prefetch(p+2*h+j+64,0,3);__builtin_prefetch(p+3*h+j+64,0,3);__builtin_prefetch(p+4*h+j+64,0,3);__builtin_prefetch(p+5*h+j+64,0,3);__builtin_prefetch(p+6*h+j+64,0,3);__builtin_prefetch(p+7*h+j+64,0,3);}if constexpr(Inv){asm volatile("vmovdqa 0(%[b0]),%%ymm0\n\tvmovdqa 32(%[b0]),%%ymm8\n\tvmovdqa 0(%[b0],%[hs],1),%%ymm1\n\tvmovdqa 32(%[b0],%[hs],1),%%ymm9\n\tvmovdqa 0(%[b1]),%%ymm2\n\tvmovdqa 32(%[b1]),%%ymm10\n\tvmovdqa 0(%[b1],%[hs],1),%%ymm3\n\tvmovdqa 32(%[b1],%[hs],1),%%ymm11\n\tvmovdqa 0(%[b2]),%%ymm4\n\tvmovdqa 32(%[b2]),%%ymm12\n\tvmovdqa 0(%[b2],%[hs],1),%%ymm5\n\tvmovdqa 32(%[b2],%[hs],1),%%ymm13\n\tvmovdqa 0(%[b3]),%%ymm6\n\tvmovdqa 32(%[b3]),%%ymm14\n\tvmovdqa 0(%[b3],%[hs],1),%%ymm7\n\tvmovdqa 32(%[b3],%[hs],1),%%ymm15\n\tvpsubd %%ymm4,%%ymm0,%%ymm0\n\tvpsubd %%ymm12,%%ymm8,%%ymm8\n\tvpsubd %%ymm5,%%ymm1,%%ymm1\n\tvpsubd %%ymm13,%%ymm9,%%ymm9\n\tvpsubd %%ymm6,%%ymm2,%%ymm2\n\tvpsubd %%ymm14,%%ymm10,%%ymm10\n\tvpsubd %%ymm7,%%ymm3,%%ymm3\n\tvpsubd %%ymm15,%%ymm11,%%ymm11\n\tvpsubd %%ymm2,%%ymm0,%%ymm0\n\tvpsubd %%ymm10,%%ymm8,%%ymm8\n\tvpsubd %%ymm3,%%ymm1,%%ymm1\n\tvpsubd %%ymm11,%%ymm9,%%ymm9\n\tvpsubd %%ymm6,%%ymm4,%%ymm4\n\tvpsubd %%ymm14,%%ymm12,%%ymm12\n\tvpsubd %%ymm7,%%ymm5,%%ymm5\n\tvpsubd %%ymm15,%%ymm13,%%ymm13\n\tvpsubd %%ymm1,%%ymm0,%%ymm0\n\tvpsubd %%ymm9,%%ymm8,%%ymm8\n\tvpsubd %%ymm3,%%ymm2,%%ymm2\n\tvpsubd %%ymm11,%%ymm10,%%ymm10\n\tvpsubd %%ymm5,%%ymm4,%%ymm4\n\tvpsubd %%ymm13,%%ymm12,%%ymm12\n\tvpsubd %%ymm7,%%ymm6,%%ymm6\n\tvpsubd %%ymm15,%%ymm14,%%ymm14\n\tvmovdqa %%ymm0,0(%[b0])\n\tvmovdqa %%ymm8,32(%[b0])\n\tvmovdqa %%ymm1,0(%[b0],%[hs],1)\n\tvmovdqa %%ymm9,32(%[b0],%[hs],1)\n\tvmovdqa %%ymm2,0(%[b1])\n\tvmovdqa %%ymm10,32(%[b1])\n\tvmovdqa %%ymm3,0(%[b1],%[hs],1)\n\tvmovdqa %%ymm11,32(%[b1],%[hs],1)\n\tvmovdqa %%ymm4,0(%[b2])\n\tvmovdqa %%ymm12,32(%[b2])\n\tvmovdqa %%ymm5,0(%[b2],%[hs],1)\n\tvmovdqa %%ymm13,32(%[b2],%[hs],1)\n\tvmovdqa %%ymm6,0(%[b3])\n\tvmovdqa %%ymm14,32(%[b3])"::[b0]"r"(p+7*h+j),[b1]"r"(p+5*h+j),[b2]"r"(p+3*h+j),[b3]"r"(p+1*h+j),[hs]"r"(-intptr_t(h)*4):"ymm0","ymm1","ymm2","ymm3","ymm4","ymm5","ymm6","ymm7","ymm8","ymm9","ymm10","ymm11","ymm12","ymm13","ymm14","ymm15","memory");}else{asm volatile("vmovdqa 0(%[b0]),%%ymm0\n\tvmovdqa 32(%[b0]),%%ymm8\n\tvmovdqa 0(%[b0],%[hs],1),%%ymm1\n\tvmovdqa 32(%[b0],%[hs],1),%%ymm9\n\tvmovdqa 0(%[b1]),%%ymm2\n\tvmovdqa 32(%[b1]),%%ymm10\n\tvmovdqa 0(%[b1],%[hs],1),%%ymm3\n\tvmovdqa 32(%[b1],%[hs],1),%%ymm11\n\tvmovdqa 0(%[b2]),%%ymm4\n\tvmovdqa 32(%[b2]),%%ymm12\n\tvmovdqa 0(%[b2],%[hs],1),%%ymm5\n\tvmovdqa 32(%[b2],%[hs],1),%%ymm13\n\tvmovdqa 0(%[b3]),%%ymm6\n\tvmovdqa 32(%[b3]),%%ymm14\n\tvmovdqa 0(%[b3],%[hs],1),%%ymm7\n\tvmovdqa 32(%[b3],%[hs],1),%%ymm15\n\tvpaddd %%ymm1,%%ymm0,%%ymm0\n\tvpaddd %%ymm9,%%ymm8,%%ymm8\n\tvpaddd %%ymm3,%%ymm2,%%ymm2\n\tvpaddd %%ymm11,%%ymm10,%%ymm10\n\tvpaddd %%ymm5,%%ymm4,%%ymm4\n\tvpaddd %%ymm13,%%ymm12,%%ymm12\n\tvpaddd %%ymm7,%%ymm6,%%ymm6\n\tvpaddd %%ymm15,%%ymm14,%%ymm14\n\tvpaddd %%ymm2,%%ymm0,%%ymm0\n\tvpaddd %%ymm10,%%ymm8,%%ymm8\n\tvpaddd %%ymm3,%%ymm1,%%ymm1\n\tvpaddd %%ymm11,%%ymm9,%%ymm9\n\tvpaddd %%ymm6,%%ymm4,%%ymm4\n\tvpaddd %%ymm14,%%ymm12,%%ymm12\n\tvpaddd %%ymm7,%%ymm5,%%ymm5\n\tvpaddd %%ymm15,%%ymm13,%%ymm13\n\tvpaddd %%ymm4,%%ymm0,%%ymm0\n\tvpaddd %%ymm12,%%ymm8,%%ymm8\n\tvpaddd %%ymm5,%%ymm1,%%ymm1\n\tvpaddd %%ymm13,%%ymm9,%%ymm9\n\tvpaddd %%ymm6,%%ymm2,%%ymm2\n\tvpaddd %%ymm14,%%ymm10,%%ymm10\n\tvpaddd %%ymm7,%%ymm3,%%ymm3\n\tvpaddd %%ymm15,%%ymm11,%%ymm11\n\tvmovdqa %%ymm0,0(%[b0])\n\tvmovdqa %%ymm8,32(%[b0])\n\tvmovdqa %%ymm1,0(%[b0],%[hs],1)\n\tvmovdqa %%ymm9,32(%[b0],%[hs],1)\n\tvmovdqa %%ymm2,0(%[b1])\n\tvmovdqa %%ymm10,32(%[b1])\n\tvmovdqa %%ymm3,0(%[b1],%[hs],1)\n\tvmovdqa %%ymm11,32(%[b1],%[hs],1)\n\tvmovdqa %%ymm4,0(%[b2])\n\tvmovdqa %%ymm12,32(%[b2])\n\tvmovdqa %%ymm5,0(%[b2],%[hs],1)\n\tvmovdqa %%ymm13,32(%[b2],%[hs],1)\n\tvmovdqa %%ymm6,0(%[b3])\n\tvmovdqa %%ymm14,32(%[b3])"::[b0]"r"(p+7*h+j),[b1]"r"(p+5*h+j),[b2]"r"(p+3*h+j),[b3]"r"(p+1*h+j),[hs]"r"(-intptr_t(h)*4):"ymm0","ymm1","ymm2","ymm3","ymm4","ymm5","ymm6","ymm7","ymm8","ymm9","ymm10","ymm11","ymm12","ymm13","ymm14","ymm15","memory");}}}
static void fast4k(u32*x,u32*y){full_or_line_ni<false>(4096,x);full_or_line_ni<false>(4096,y);for(unsigned q=0;q<8;q++)paired_leaf256(512,x+q*512,y+q*512);full_or_line_ni<true>(4096,x);}
alignas(64) static unsigned ysave[38528];
static unsigned* g_ydst=0;
static inline void zeta_oop_top(unsigned*dst,const unsigned*src){for(unsigned j=0;j<4096;j+=16)asm volatile(R"arB(
vmovdqa 0(%[s]),%%ymm0
vmovdqa 32(%[s]),%%ymm8
vmovdqa 16384(%[s]),%%ymm1
vmovdqa 16416(%[s]),%%ymm9
vmovdqa 32768(%[s]),%%ymm2
vmovdqa 32800(%[s]),%%ymm10
vmovdqa 49152(%[s]),%%ymm3
vmovdqa 49184(%[s]),%%ymm11
vmovdqa 65536(%[s]),%%ymm4
vmovdqa 65568(%[s]),%%ymm12
vmovdqa 81920(%[s]),%%ymm5
vmovdqa 81952(%[s]),%%ymm13
vmovdqa 98304(%[s]),%%ymm6
vmovdqa 98336(%[s]),%%ymm14
vmovdqa 114688(%[s]),%%ymm7
vmovdqa 114720(%[s]),%%ymm15
vpaddd %%ymm0,%%ymm1,%%ymm1
vpaddd %%ymm8,%%ymm9,%%ymm9
vpaddd %%ymm2,%%ymm3,%%ymm3
vpaddd %%ymm10,%%ymm11,%%ymm11
vpaddd %%ymm4,%%ymm5,%%ymm5
vpaddd %%ymm12,%%ymm13,%%ymm13
vpaddd %%ymm6,%%ymm7,%%ymm7
vpaddd %%ymm14,%%ymm15,%%ymm15
vpaddd %%ymm0,%%ymm2,%%ymm2
vpaddd %%ymm8,%%ymm10,%%ymm10
vpaddd %%ymm1,%%ymm3,%%ymm3
vpaddd %%ymm9,%%ymm11,%%ymm11
vpaddd %%ymm4,%%ymm6,%%ymm6
vpaddd %%ymm12,%%ymm14,%%ymm14
vpaddd %%ymm5,%%ymm7,%%ymm7
vpaddd %%ymm13,%%ymm15,%%ymm15
vpaddd %%ymm0,%%ymm4,%%ymm4
vpaddd %%ymm8,%%ymm12,%%ymm12
vpaddd %%ymm1,%%ymm5,%%ymm5
vpaddd %%ymm9,%%ymm13,%%ymm13
vpaddd %%ymm2,%%ymm6,%%ymm6
vpaddd %%ymm10,%%ymm14,%%ymm14
vpaddd %%ymm3,%%ymm7,%%ymm7
vpaddd %%ymm11,%%ymm15,%%ymm15
vmovdqa %%ymm0,0(%[d])
vmovdqa %%ymm8,32(%[d])
vmovdqa %%ymm1,16384(%[d])
vmovdqa %%ymm9,16416(%[d])
vmovdqa %%ymm2,32768(%[d])
vmovdqa %%ymm10,32800(%[d])
vmovdqa %%ymm3,49152(%[d])
vmovdqa %%ymm11,49184(%[d])
vmovdqa %%ymm4,65536(%[d])
vmovdqa %%ymm12,65568(%[d])
vmovdqa %%ymm5,81920(%[d])
vmovdqa %%ymm13,81952(%[d])
vmovdqa %%ymm6,98304(%[d])
vmovdqa %%ymm14,98336(%[d])
vmovdqa %%ymm7,114688(%[d])
vmovdqa %%ymm15,114720(%[d])
)arB"::[s]"r"(src+j),[d]"r"(dst+j):"ymm0","ymm1","ymm2","ymm3","ymm4","ymm5","ymm6","ymm7","ymm8","ymm9","ymm10","ymm11","ymm12","ymm13","ymm14","ymm15","memory");}
static void fast32k(u32*x,u32*y){constexpr unsigned n=32768; u32*yy=y;if(g_ydst){zeta_oop_top(g_ydst,y);yy=g_ydst;}else high_octants<false>(32768,y);high_octants<false>(32768,x); for(unsigned q=8;q--;)fast4k(x+q*4096,yy+q*4096);high_octants<true>(32768,x);}
static void solve(unsigned n,u32*x,u32*y){if(n==32768){fast32k(x,y);return;}if(n<=1024){if(!(n&255u)){paired_leaf256(n,x,y);return;}if(!(n&127u)){paired_leaf128_onesave(n,x,y);return;}if(!(n&63u)){paired_leaf64(n,x,y);return;}if(!(n&15u)){paired_leaf16(n,x,y);return;}
leaf32<false,false>(x,n);leaf32<false,false>(y,n);
if(n&7u){for(unsigned j=0;j<n;j++)x[j]*=y[j];leaf32<false,true>(x,n);return;}
for(unsigned j=0;j<n;j+=8)qI3((__m256i*)(x+j),inv8(qI4(qI0((const __m256i*)(x+j)),qI0((const __m256i*)(y+j)))));
for(unsigned h=8;h<n;h*=2)for(unsigned base=0;base<n;base+=2*h)if(base+h<n){unsigned z=std::min(h,n-base-h),j=0;
for(;j+8<=z;j+=8)qI3((__m256i*)(x+base+h+j),qI2(qI0((const __m256i*)(x+base+h+j)),qI0((const __m256i*)(x+base+j))));
for(;j<z;j++)x[base+h+j]-=x[base+j];
}return;
}
if((n&(n-1))==0 && n>=4096){
high_octants_paired<false>(n,x,y);
const unsigned q=n/8;for(unsigned r=0;r<8;r++)solve(q,x+r*q,y+r*q);
high_octants<true>(n,x);return;
}
const unsigned h=1u<<(30-__builtin_clz(n-1)),r2=std::min(h,n-2*h),r3=n>3*h?n-3*h:0;unsigned j=0;
for(;j+8<=r3;j+=8){
{auto a=qI0((const __m256i*)(x+0*h+j));auto b=qI0((const __m256i*)(x+1*h+j));auto c=qI0((const __m256i*)(x+2*h+j));auto d=qI0((const __m256i*)(x+3*h+j));qI3((__m256i*)(x+1*h+j),qI1(a,b));qI3((__m256i*)(x+2*h+j),qI1(a,c));qI3((__m256i*)(x+3*h+j),qI1(qI1(a,b),qI1(c,d)));}
{auto a=qI0((const __m256i*)(y+0*h+j));auto b=qI0((const __m256i*)(y+1*h+j));auto c=qI0((const __m256i*)(y+2*h+j));auto d=qI0((const __m256i*)(y+3*h+j));qI3((__m256i*)(y+1*h+j),qI1(a,b));qI3((__m256i*)(y+2*h+j),qI1(a,c));qI3((__m256i*)(y+3*h+j),qI1(qI1(a,b),qI1(c,d)));}
}
for(;j<r3;j++){x[3*h+j]+=x[j]+x[h+j]+x[2*h+j];x[2*h+j]+=x[j];x[h+j]+=x[j];y[3*h+j]+=y[j]+y[h+j]+y[2*h+j];y[2*h+j]+=y[j];y[h+j]+=y[j];}
for(;j+8<=r2;j+=8){
{auto a=qI0((const __m256i*)(x+0*h+j));auto b=qI0((const __m256i*)(x+1*h+j));auto c=qI0((const __m256i*)(x+2*h+j));qI3((__m256i*)(x+1*h+j),qI1(a,b));qI3((__m256i*)(x+2*h+j),qI1(a,c));}
{auto a=qI0((const __m256i*)(y+0*h+j));auto b=qI0((const __m256i*)(y+1*h+j));auto c=qI0((const __m256i*)(y+2*h+j));qI3((__m256i*)(y+1*h+j),qI1(a,b));qI3((__m256i*)(y+2*h+j),qI1(a,c));}
}
for(;j<r2;j++){x[2*h+j]+=x[j];x[h+j]+=x[j];y[2*h+j]+=y[j];y[h+j]+=y[j];}
for(;j+8<=h;j+=8){
{auto a=qI0((const __m256i*)(x+0*h+j));auto b=qI0((const __m256i*)(x+1*h+j));qI3((__m256i*)(x+1*h+j),qI1(a,b));}
{auto a=qI0((const __m256i*)(y+0*h+j));auto b=qI0((const __m256i*)(y+1*h+j));qI3((__m256i*)(y+1*h+j),qI1(a,b));}
}
for(;j<h;j++){x[h+j]+=x[j];y[h+j]+=y[j];}
solve(h,x,y);solve(h,x+h,y+h);solve(r2,x+2*h,y+2*h);if(r3)solve(r3,x+3*h,y+3*h);
j=0;
for(;j+8<=r3;j+=8){
{auto a=qI0((const __m256i*)(x+0*h+j));auto b=qI0((const __m256i*)(x+1*h+j));auto c=qI0((const __m256i*)(x+2*h+j));auto d=qI0((const __m256i*)(x+3*h+j));qI3((__m256i*)(x+1*h+j),qI2(b,a));qI3((__m256i*)(x+2*h+j),qI2(c,a));qI3((__m256i*)(x+3*h+j),qI2(qI1(d,a),qI1(b,c)));}
}
for(;j<r3;j++){x[3*h+j]+=x[j]-x[h+j]-x[2*h+j];x[2*h+j]-=x[j];x[h+j]-=x[j];}
for(;j+8<=r2;j+=8){
{auto a=qI0((const __m256i*)(x+0*h+j));auto b=qI0((const __m256i*)(x+1*h+j));auto c=qI0((const __m256i*)(x+2*h+j));qI3((__m256i*)(x+1*h+j),qI2(b,a));qI3((__m256i*)(x+2*h+j),qI2(c,a));}
}
for(;j<r2;j++){x[2*h+j]-=x[j];x[h+j]-=x[j];}
for(;j+8<=h;j+=8){
{auto a=qI0((const __m256i*)(x+0*h+j));auto b=qI0((const __m256i*)(x+1*h+j));qI3((__m256i*)(x+1*h+j),qI2(b,a));}
}
for(;j<h;j++){x[h+j]-=x[j];}

}

static void direct_first(unsigned n,const unsigned*a,const unsigned*b,unsigned*x,unsigned*y){
const unsigned h=n/8,start=n==262144?3:1;
for(unsigned side=0;side<2;side++){const unsigned*in=side?b:a;unsigned*out=side?y:x;
for(unsigned j=0;j<h;j+=8){__m256i v[8];
#pragma GCC unroll 8
for(unsigned q=0;q<8;q++)v[q]=qI7((const __m256i*)(in+q*h+j));
#pragma GCC unroll 3
for(unsigned bit=0;bit<3;bit++){
#pragma GCC unroll 8
for(unsigned q=0;q<8;q++)if(q&(1u<<bit))v[q]=qI1(v[q],v[q^(1u<<bit)]);}
#pragma GCC unroll 8
for(unsigned q=0;q<8;q++)if(q>=start)qI9((__m256i*)(out+q*h+j),v[q]);}}
_mm_sfence();if(h==32768)solve(h,x,y);else direct_first(h,a,b,x,y);
for(unsigned q=1;q<8;q++)solve(h,x+q*h,y+q*h);high_octants<true>(n,x);}
}alignas(4096)static unsigned gtmp[10000000+16512];
alignas(64) static unsigned ysave[38528];
static inline void solve_save(unsigned n,unsigned*x,const unsigned*y){if(n==32768){root_or::g_ydst=ysave;root_or::solve(n,x,(unsigned*)y);root_or::g_ydst=0;}else{std::memcpy(ysave,y,size_t(n)*4);root_or::solve(n,x,ysave);}}
static void root8_fused(const unsigned*a,const unsigned*b,unsigned*c){
constexpr unsigned B18=262144u,BLK=512u,P38=9961472u;
alignas(64)static unsigned fsc[38*512];
unsigned*t=gtmp+384;
for(unsigned side=0;side<2;side++){
const unsigned*in=side?b:a;unsigned*out=side?c:t;
for(unsigned T=0;T<B18;T+=BLK){
for(unsigned g=0;g<4;g++){const unsigned*base=in+(g<<3)*B18+T;unsigned*sb=fsc+(g<<3)*BLK;
for(unsigned k=0;k<BLK;k+=8){__m256i v[8];
for(unsigned r=0;r<8;r++)v[r]=qI0((const __m256i*)(base+r*B18+k));
v[1]=qI1(v[1],v[0]);v[3]=qI1(v[3],v[2]);v[5]=qI1(v[5],v[4]);v[7]=qI1(v[7],v[6]);v[2]=qI1(v[2],v[0]);v[3]=qI1(v[3],v[1]);v[6]=qI1(v[6],v[4]);v[7]=qI1(v[7],v[5]);v[4]=qI1(v[4],v[0]);v[5]=qI1(v[5],v[1]);v[6]=qI1(v[6],v[2]);v[7]=qI1(v[7],v[3]);
for(unsigned r=0;r<8;r++)qI3((__m256i*)(sb+r*BLK+k),v[r]);}}
{const unsigned*base=in+32*B18+T;unsigned*sb=fsc+32*BLK;
for(unsigned k=0;k<BLK;k+=8){__m256i v[8];
for(unsigned r=0;r<6;r++)v[r]=qI0((const __m256i*)(base+r*B18+k));v[6]=qI8();v[7]=qI8();
v[1]=qI1(v[1],v[0]);v[3]=qI1(v[3],v[2]);v[5]=qI1(v[5],v[4]);v[7]=qI1(v[7],v[6]);v[2]=qI1(v[2],v[0]);v[3]=qI1(v[3],v[1]);v[6]=qI1(v[6],v[4]);v[7]=qI1(v[7],v[5]);v[4]=qI1(v[4],v[0]);v[5]=qI1(v[5],v[1]);v[6]=qI1(v[6],v[2]);v[7]=qI1(v[7],v[3]);
for(unsigned r=0;r<6;r++)qI3((__m256i*)(sb+r*BLK+k),v[r]);}}
for(unsigned r=0;r<6;r++){unsigned*sb=fsc+r*BLK;
for(unsigned k=0;k<BLK;k+=8){__m256i w[8];
for(unsigned g=0;g<5;g++)w[g]=qI0((const __m256i*)(sb+g*8*BLK+k));
for(unsigned g=5;g<8;g++)w[g]=qI8();
w[1]=qI1(w[1],w[0]);w[3]=qI1(w[3],w[2]);w[5]=qI1(w[5],w[4]);w[7]=qI1(w[7],w[6]);w[2]=qI1(w[2],w[0]);w[3]=qI1(w[3],w[1]);w[6]=qI1(w[6],w[4]);w[7]=qI1(w[7],w[5]);w[4]=qI1(w[4],w[0]);w[5]=qI1(w[5],w[1]);w[6]=qI1(w[6],w[2]);w[7]=qI1(w[7],w[3]);
for(unsigned g=1;g<5;g++)qI3((__m256i*)(sb+g*8*BLK+k),w[g]);}}
for(unsigned r=6;r<8;r++){unsigned*sb=fsc+r*BLK;
for(unsigned k=0;k<BLK;k+=8){__m256i w[8];
for(unsigned g=0;g<4;g++)w[g]=qI0((const __m256i*)(sb+g*8*BLK+k));
for(unsigned g=4;g<8;g++)w[g]=qI8();
w[1]=qI1(w[1],w[0]);w[3]=qI1(w[3],w[2]);w[5]=qI1(w[5],w[4]);w[7]=qI1(w[7],w[6]);w[2]=qI1(w[2],w[0]);w[3]=qI1(w[3],w[1]);w[6]=qI1(w[6],w[4]);w[7]=qI1(w[7],w[5]);w[4]=qI1(w[4],w[0]);w[5]=qI1(w[5],w[1]);w[6]=qI1(w[6],w[2]);w[7]=qI1(w[7],w[3]);
for(unsigned g=1;g<4;g++)qI3((__m256i*)(sb+g*8*BLK+k),w[g]);}}
for(unsigned g=0;g<4;g++){const unsigned*sb=fsc+(g<<3)*BLK;unsigned*d=out+(g<<3)*B18+T;
for(unsigned r=0;r<8;r++)for(unsigned k=0;k<BLK;k+=8)qI9((__m256i*)(d+r*B18+k),qI0((const __m256i*)(sb+r*BLK+k)));}
{const unsigned*sb=fsc+32*BLK;unsigned*d=out+32*B18+T;
for(unsigned r=0;r<6;r++)for(unsigned k=0;k<BLK;k+=8)qI9((__m256i*)(d+r*B18+k),qI0((const __m256i*)(sb+r*BLK+k)));}
}
for(unsigned pos=0;pos<38528;pos+=8){
__m256i v=qI0((const __m256i*)(in+P38+pos));
v=qI1(v,qI0((const __m256i*)(in+36*B18+pos)));v=qI1(v,qI0((const __m256i*)(in+34*B18+pos)));
v=qI1(v,qI0((const __m256i*)(in+32*B18+pos)));v=qI1(v,qI0((const __m256i*)(in+6*B18+pos)));
v=qI1(v,qI0((const __m256i*)(in+4*B18+pos)));v=qI1(v,qI0((const __m256i*)(in+2*B18+pos)));
v=qI1(v,qI0((const __m256i*)(in+pos)));
qI9((__m256i*)(out+P38+pos),v);}
}
_mm_sfence();
for(unsigned j=0;j<38;j++)root_or::solve(B18,c+j*B18,t+j*B18);
root_or::solve(38528,c+P38,t+P38);
for(unsigned pos=0;pos<38528;pos+=8){
__m256i v=qI0((const __m256i*)(c+P38+pos));
v=qI2(v,qI0((const __m256i*)(c+36*B18+pos)));v=qI2(v,qI0((const __m256i*)(c+34*B18+pos)));
v=qI1(v,qI0((const __m256i*)(c+32*B18+pos)));v=qI2(v,qI0((const __m256i*)(c+6*B18+pos)));
v=qI1(v,qI0((const __m256i*)(c+4*B18+pos)));v=qI1(v,qI0((const __m256i*)(c+2*B18+pos)));
v=qI2(v,qI0((const __m256i*)(c+pos)));
qI3((__m256i*)(c+P38+pos),v);}
for(unsigned T=0;T<B18;T+=BLK){
for(unsigned r=0;r<6;r++){const unsigned*base=c+r*B18+T;
for(unsigned k=0;k<BLK;k+=8){__m256i w[8];
for(unsigned g=0;g<5;g++)w[g]=qI0((const __m256i*)(base+g*8*B18+k));
for(unsigned g=5;g<8;g++)w[g]=qI8();
w[4]=qI2(w[4],w[0]);w[5]=qI2(w[5],w[1]);w[6]=qI2(w[6],w[2]);w[7]=qI2(w[7],w[3]);w[2]=qI2(w[2],w[0]);w[3]=qI2(w[3],w[1]);w[6]=qI2(w[6],w[4]);w[7]=qI2(w[7],w[5]);w[1]=qI2(w[1],w[0]);w[3]=qI2(w[3],w[2]);w[5]=qI2(w[5],w[4]);w[7]=qI2(w[7],w[6]);
unsigned*d=c+r*B18+T+k;
for(unsigned g=1;g<5;g++)qI3((__m256i*)(d+g*8*B18),w[g]);}}
for(unsigned r=6;r<8;r++){const unsigned*base=c+r*B18+T;
for(unsigned k=0;k<BLK;k+=8){__m256i w[8];
for(unsigned g=0;g<4;g++)w[g]=qI0((const __m256i*)(base+g*8*B18+k));
for(unsigned g=4;g<8;g++)w[g]=qI8();
w[4]=qI2(w[4],w[0]);w[5]=qI2(w[5],w[1]);w[6]=qI2(w[6],w[2]);w[7]=qI2(w[7],w[3]);w[2]=qI2(w[2],w[0]);w[3]=qI2(w[3],w[1]);w[6]=qI2(w[6],w[4]);w[7]=qI2(w[7],w[5]);w[1]=qI2(w[1],w[0]);w[3]=qI2(w[3],w[2]);w[5]=qI2(w[5],w[4]);w[7]=qI2(w[7],w[6]);
unsigned*d=c+r*B18+T+k;
for(unsigned g=1;g<4;g++)qI3((__m256i*)(d+g*8*B18),w[g]);}}
for(unsigned g=0;g<4;g++){const unsigned*base=c+(g<<3)*B18+T;
for(unsigned k=0;k<BLK;k+=8){__m256i v[8];
for(unsigned r=0;r<8;r++)v[r]=qI0((const __m256i*)(base+r*B18+k));
v[4]=qI2(v[4],v[0]);v[5]=qI2(v[5],v[1]);v[6]=qI2(v[6],v[2]);v[7]=qI2(v[7],v[3]);v[2]=qI2(v[2],v[0]);v[3]=qI2(v[3],v[1]);v[6]=qI2(v[6],v[4]);v[7]=qI2(v[7],v[5]);v[1]=qI2(v[1],v[0]);v[3]=qI2(v[3],v[2]);v[5]=qI2(v[5],v[4]);v[7]=qI2(v[7],v[6]);
unsigned*d=c+(g<<3)*B18+T+k;
for(unsigned r=1;r<8;r++)qI3((__m256i*)(d+r*B18),v[r]);}}
{const unsigned*base=c+32*B18+T;
for(unsigned k=0;k<BLK;k+=8){__m256i v[8];
for(unsigned r=0;r<6;r++)v[r]=qI0((const __m256i*)(base+r*B18+k));v[6]=qI8();v[7]=qI8();
v[4]=qI2(v[4],v[0]);v[5]=qI2(v[5],v[1]);v[6]=qI2(v[6],v[2]);v[7]=qI2(v[7],v[3]);v[2]=qI2(v[2],v[0]);v[3]=qI2(v[3],v[1]);v[6]=qI2(v[6],v[4]);v[7]=qI2(v[7],v[5]);v[1]=qI2(v[1],v[0]);v[3]=qI2(v[3],v[2]);v[5]=qI2(v[5],v[4]);v[7]=qI2(v[7],v[6]);
unsigned*d=c+32*B18+T+k;
for(unsigned r=1;r<6;r++)qI3((__m256i*)(d+r*B18),v[r]);}}
}
}
static void scalar(unsigned n,const unsigned*a,const unsigned*b,unsigned*c){if(!n)return;unsigned*t=(unsigned*)malloc(size_t(n)*4);if(!t)__builtin_trap();memcpy(c,a,size_t(n)*4);memcpy(t,b,size_t(n)*4);for(unsigned h=1;h<n;h*=2)for(unsigned q=0;q<n;q+=2*h)if(q+h<n)for(unsigned j=0,z=std::min(h,n-q-h);j<z;j++){c[q+h+j]+=c[q+j];t[q+h+j]+=t[q+j];}for(unsigned i=0;i<n;i++)c[i]*=t[i];for(unsigned h=1;h<n;h*=2)for(unsigned q=0;q<n;q+=2*h)if(q+h<n)for(unsigned j=0,z=std::min(h,n-q-h);j<z;j++)c[q+h+j]-=c[q+j];free(t);}
template<bool Inv>static inline void dashboard_or8(__m256i*v){
#pragma GCC unroll 3
for(unsigned st=0;st<3;st++){unsigned bit=Inv?2-st:st;
#pragma GCC unroll 8
for(unsigned z=0;z<8;z++)if(z&(1u<<bit)){if constexpr(Inv)v[z]=_mm256_sub_epi32(v[z],v[z^(1u<<bit)]);else v[z]=_mm256_add_epi32(v[z],v[z^(1u<<bit)]);}}}
template<bool Inv,unsigned T,unsigned LP,unsigned N>static inline void ar_plane_low(unsigned(&sc)[38][8][LP],unsigned g){
 for(unsigned rr=0;rr<8;rr++)for(unsigned j=0;j<T;j+=8){__m256i v[8];
#pragma GCC unroll 8
 for(unsigned r=0;r<8;r++)v[r]=r<N?_mm256_load_si256((const __m256i*)(sc[g*8+r][rr]+j)):_mm256_setzero_si256();dashboard_or8<Inv>(v);
#pragma GCC unroll 8
 for(unsigned r=1;r<N;r++)_mm256_store_si256((__m256i*)(sc[g*8+r][rr]+j),v[r]);}}
template<bool Inv,unsigned T,unsigned LP,bool Fifth>static inline void ar_plane_high(unsigned(&sc)[38][8][LP],unsigned r){
 for(unsigned rr=0;rr<8;rr++)for(unsigned j=0;j<T;j+=8){__m256i v[8];
#pragma GCC unroll 8
 for(unsigned g=0;g<8;g++)v[g]=(g<4||(Fifth&&g==4))?_mm256_load_si256((const __m256i*)(sc[g*8+r][rr]+j)):_mm256_setzero_si256();dashboard_or8<Inv>(v);
#pragma GCC unroll 4
 for(unsigned g=1;g<(Fifth?5:4);g++)_mm256_store_si256((__m256i*)(sc[g*8+r][rr]+j),v[g]);}}
template<bool Inv,unsigned T,unsigned LP>static void ar_root_high(unsigned(&sc)[38][8][LP]){for(unsigned r=0;r<6;r++)ar_plane_high<Inv,T,LP,true>(sc,r);for(unsigned r=6;r<8;r++)ar_plane_high<Inv,T,LP,false>(sc,r);}
template<bool Inv,unsigned T,unsigned LP>static void ar_root_six(unsigned(&sc)[38][8][LP]){if constexpr(Inv)ar_root_high<Inv,T,LP>(sc);for(unsigned g=0;g<4;g++)ar_plane_low<Inv,T,LP,8>(sc,g);ar_plane_low<Inv,T,LP,6>(sc,4);if constexpr(!Inv)ar_root_high<Inv,T,LP>(sc);}
template<unsigned LP,unsigned T,unsigned N,bool Skip0>static inline __attribute__((always_inline))void or_inverse_four_lines(const unsigned*src,unsigned*out,unsigned*stage){asm volatile(R"or4(
vmovdqa %c[p]*0+0(%[src]),%%ymm0
vmovdqa %c[p]*0+32(%[src]),%%ymm8
vmovdqa %c[p]*1+0(%[src]),%%ymm1
vmovdqa %c[p]*1+32(%[src]),%%ymm9
vmovdqa %c[p]*2+0(%[src]),%%ymm2
vmovdqa %c[p]*2+32(%[src]),%%ymm10
vmovdqa %c[p]*3+0(%[src]),%%ymm3
vmovdqa %c[p]*3+32(%[src]),%%ymm11
vmovdqa %c[p]*4+0(%[src]),%%ymm4
vmovdqa %c[p]*4+32(%[src]),%%ymm12
vmovdqa %c[p]*5+0(%[src]),%%ymm5
vmovdqa %c[p]*5+32(%[src]),%%ymm13
.if %c[n] == 8
vmovdqa %c[p]*6+0(%[src]),%%ymm6
vmovdqa %c[p]*6+32(%[src]),%%ymm14
vmovdqa %c[p]*7+0(%[src]),%%ymm7
vmovdqa %c[p]*7+32(%[src]),%%ymm15
.endif
vpsubd %%ymm0,%%ymm4,%%ymm4
vpsubd %%ymm8,%%ymm12,%%ymm12
vpsubd %%ymm1,%%ymm5,%%ymm5
vpsubd %%ymm9,%%ymm13,%%ymm13
.if %c[n] == 8
vpsubd %%ymm2,%%ymm6,%%ymm6
vpsubd %%ymm10,%%ymm14,%%ymm14
.endif
.if %c[n] == 8
vpsubd %%ymm3,%%ymm7,%%ymm7
vpsubd %%ymm11,%%ymm15,%%ymm15
.endif
vpsubd %%ymm0,%%ymm2,%%ymm2
vpsubd %%ymm8,%%ymm10,%%ymm10
vpsubd %%ymm1,%%ymm3,%%ymm3
vpsubd %%ymm9,%%ymm11,%%ymm11
.if %c[n] == 8
vpsubd %%ymm4,%%ymm6,%%ymm6
vpsubd %%ymm12,%%ymm14,%%ymm14
.endif
.if %c[n] == 8
vpsubd %%ymm5,%%ymm7,%%ymm7
vpsubd %%ymm13,%%ymm15,%%ymm15
.endif
vpsubd %%ymm0,%%ymm1,%%ymm1
vpsubd %%ymm8,%%ymm9,%%ymm9
vpsubd %%ymm2,%%ymm3,%%ymm3
vpsubd %%ymm10,%%ymm11,%%ymm11
vpsubd %%ymm4,%%ymm5,%%ymm5
vpsubd %%ymm12,%%ymm13,%%ymm13
.if %c[n] == 8
vpsubd %%ymm6,%%ymm7,%%ymm7
vpsubd %%ymm14,%%ymm15,%%ymm15
.endif
.if !%c[skip]
vmovntdq %%ymm0,0(%[out])
vmovntdq %%ymm8,32(%[out])
.endif
vmovntdq %%ymm1,1048576(%[out])
vmovntdq %%ymm9,1048608(%[out])
vmovntdq %%ymm2,2097152(%[out])
vmovntdq %%ymm10,2097184(%[out])
vmovntdq %%ymm3,3145728(%[out])
vmovntdq %%ymm11,3145760(%[out])
vmovdqa %%ymm4,%c[st]*0+0(%[stage])
vmovdqa %%ymm12,%c[st]*0+32(%[stage])
vmovdqa %%ymm5,%c[st]*1+0(%[stage])
vmovdqa %%ymm13,%c[st]*1+32(%[stage])
.if %c[n] == 8
vmovdqa %%ymm6,%c[st]*2+0(%[stage])
vmovdqa %%ymm14,%c[st]*2+32(%[stage])
vmovdqa %%ymm7,%c[st]*3+0(%[stage])
vmovdqa %%ymm15,%c[st]*3+32(%[stage])
.endif
)or4"::[src]"r"(src),[out]"r"(out),[stage]"r"(stage),[p]"i"(8*LP*4),[st]"i"(T*4),[n]"i"(N),[skip]"i"(Skip0):"ymm0","ymm1","ymm2","ymm3","ymm4","ymm5","ymm6","ymm7","ymm8","ymm9","ymm10","ymm11","ymm12","ymm13","ymm14","ymm15","memory");}
template<unsigned T,unsigned LP,unsigned N>static inline void ar_last_planes(unsigned(&sc)[38][8][LP],unsigned*c,unsigned j0,unsigned g){constexpr unsigned H=262144,L=32768;alignas(64)static unsigned st[4][T];
for(unsigned rr=0;rr<8;rr++){
if(g==0&&rr==0){for(unsigned j=0;j<T;j+=16)or_inverse_four_lines<LP,T,N,true>(sc[g*8][rr]+j,c+g*8*H+rr*L+j0+j,st[0]+j);}
else{for(unsigned j=0;j<T;j+=16)or_inverse_four_lines<LP,T,N,false>(sc[g*8][rr]+j,c+g*8*H+rr*L+j0+j,st[0]+j);}
for(unsigned r=4;r<N;r++)for(unsigned j=0;j<T;j+=8)_mm256_stream_si256((__m256i*)(c+(g*8+r)*H+rr*L+j0+j),_mm256_load_si256((const __m256i*)(st[r-4]+j)));
}}
template<unsigned T,unsigned LP>static void low_inv_store(unsigned(&sc)[38][8][LP],unsigned*c,unsigned j0){for(unsigned g=0;g<4;g++)ar_last_planes<T,LP,8>(sc,c,j0,g);ar_last_planes<T,LP,6>(sc,c,j0,4);}
template<unsigned LP,bool Fifth>static inline void ar_forward_direct(const unsigned*src,unsigned*dst){asm volatile(R"aror(
vmovdqa 0(%[src]),%%ymm0
vmovdqa 0 + 32(%[src]),%%ymm8
vmovdqa %c[s1](%[src]),%%ymm1
vmovdqa %c[s1] + 32(%[src]),%%ymm9
vmovdqa %c[s2](%[src]),%%ymm2
vmovdqa %c[s2] + 32(%[src]),%%ymm10
vmovdqa %c[s3](%[src]),%%ymm3
vmovdqa %c[s3] + 32(%[src]),%%ymm11
.if %c[fifth]
vmovdqa %c[s4](%[src]),%%ymm4
vmovdqa %c[s4] + 32(%[src]),%%ymm12
.endif
vpaddd %%ymm0,%%ymm1,%%ymm1
vpaddd %%ymm8,%%ymm9,%%ymm9
vpaddd %%ymm2,%%ymm3,%%ymm3
vpaddd %%ymm10,%%ymm11,%%ymm11
vpaddd %%ymm0,%%ymm2,%%ymm2
vpaddd %%ymm8,%%ymm10,%%ymm10
vpaddd %%ymm1,%%ymm3,%%ymm3
vpaddd %%ymm9,%%ymm11,%%ymm11
.if %c[fifth]
vpaddd %%ymm0,%%ymm4,%%ymm4
vpaddd %%ymm8,%%ymm12,%%ymm12
.endif
vmovntdq %%ymm0,0(%[dst])
vmovntdq %%ymm8,32(%[dst])
vmovntdq %%ymm1,8388608(%[dst])
vmovntdq %%ymm9,8388640(%[dst])
vmovntdq %%ymm2,16777216(%[dst])
vmovntdq %%ymm10,16777248(%[dst])
vmovntdq %%ymm3,25165824(%[dst])
vmovntdq %%ymm11,25165856(%[dst])
.if %c[fifth]
vmovntdq %%ymm4,33554432(%[dst])
vmovntdq %%ymm12,33554464(%[dst])
.endif
)aror"::[src]"r"(src),[dst]"r"(dst),[fifth]"i"(Fifth),[s1]"i"(1*64*LP*4),[s2]"i"(2*64*LP*4),[s3]"i"(3*64*LP*4),[s4]"i"(4*64*LP*4):"ymm0","ymm1","ymm2","ymm3","ymm4","ymm8","ymm9","ymm10","ymm11","ymm12","memory");}
template<unsigned LP,bool Fifth,bool Skip0=false>static inline void ar_inverse_direct(const unsigned*src,unsigned*dst){asm volatile(R"aror(
vmovdqa 0(%[src]),%%ymm0
vmovdqa 0 + 32(%[src]),%%ymm8
vmovdqa %c[s1](%[src]),%%ymm1
vmovdqa %c[s1] + 32(%[src]),%%ymm9
vmovdqa %c[s2](%[src]),%%ymm2
vmovdqa %c[s2] + 32(%[src]),%%ymm10
vmovdqa %c[s3](%[src]),%%ymm3
vmovdqa %c[s3] + 32(%[src]),%%ymm11
.if %c[fifth]
vmovdqa %c[s4](%[src]),%%ymm4
vmovdqa %c[s4] + 32(%[src]),%%ymm12
.endif
vpsubd %%ymm0,%%ymm1,%%ymm1
vpsubd %%ymm8,%%ymm9,%%ymm9
vpsubd %%ymm2,%%ymm3,%%ymm3
vpsubd %%ymm10,%%ymm11,%%ymm11
vpsubd %%ymm0,%%ymm2,%%ymm2
vpsubd %%ymm8,%%ymm10,%%ymm10
vpsubd %%ymm1,%%ymm3,%%ymm3
vpsubd %%ymm9,%%ymm11,%%ymm11
.if %c[fifth]
vpsubd %%ymm0,%%ymm4,%%ymm4
vpsubd %%ymm8,%%ymm12,%%ymm12
.endif
.if %c[skip] == 0
vmovntdq %%ymm0,0(%[dst])
vmovntdq %%ymm8,32(%[dst])
.endif
vmovntdq %%ymm1,8388608(%[dst])
vmovntdq %%ymm9,8388640(%[dst])
vmovntdq %%ymm2,16777216(%[dst])
vmovntdq %%ymm10,16777248(%[dst])
vmovntdq %%ymm3,25165824(%[dst])
vmovntdq %%ymm11,25165856(%[dst])
.if %c[fifth]
vmovntdq %%ymm4,33554432(%[dst])
vmovntdq %%ymm12,33554464(%[dst])
.endif
)aror"::[src]"r"(src),[dst]"r"(dst),[skip]"i"(Skip0),[fifth]"i"(Fifth),[s1]"i"(1*64*LP*4),[s2]"i"(2*64*LP*4),[s3]"i"(3*64*LP*4),[s4]"i"(4*64*LP*4):"ymm0","ymm1","ymm2","ymm3","ymm4","ymm8","ymm9","ymm10","ymm11","ymm12","memory");}
template<unsigned LP>static inline __attribute__((always_inline))void or7_inverse_global_lines(const unsigned*src,unsigned*dst){asm volatile(R"org64(
vmovdqa 0(%[src]),%%ymm0
vmovdqa 32(%[src]),%%ymm8
vmovdqa 131072(%[src]),%%ymm1
vmovdqa 131104(%[src]),%%ymm9
vmovdqa 262144(%[src]),%%ymm2
vmovdqa 262176(%[src]),%%ymm10
vmovdqa 393216(%[src]),%%ymm3
vmovdqa 393248(%[src]),%%ymm11
vmovdqa 524288(%[src]),%%ymm4
vmovdqa 524320(%[src]),%%ymm12
vmovdqa 655360(%[src]),%%ymm5
vmovdqa 655392(%[src]),%%ymm13
vmovdqa 786432(%[src]),%%ymm6
vmovdqa 786464(%[src]),%%ymm14
vmovdqa 917504(%[src]),%%ymm7
vmovdqa 917536(%[src]),%%ymm15
vpsubd %%ymm0,%%ymm4,%%ymm4
vpsubd %%ymm8,%%ymm12,%%ymm12
vpsubd %%ymm1,%%ymm5,%%ymm5
vpsubd %%ymm9,%%ymm13,%%ymm13
vpsubd %%ymm2,%%ymm6,%%ymm6
vpsubd %%ymm10,%%ymm14,%%ymm14
vpsubd %%ymm3,%%ymm7,%%ymm7
vpsubd %%ymm11,%%ymm15,%%ymm15
vpsubd %%ymm0,%%ymm2,%%ymm2
vpsubd %%ymm8,%%ymm10,%%ymm10
vpsubd %%ymm1,%%ymm3,%%ymm3
vpsubd %%ymm9,%%ymm11,%%ymm11
vpsubd %%ymm4,%%ymm6,%%ymm6
vpsubd %%ymm12,%%ymm14,%%ymm14
vpsubd %%ymm5,%%ymm7,%%ymm7
vpsubd %%ymm13,%%ymm15,%%ymm15
vpsubd %%ymm0,%%ymm1,%%ymm1
vpsubd %%ymm8,%%ymm9,%%ymm9
vpsubd %%ymm2,%%ymm3,%%ymm3
vpsubd %%ymm10,%%ymm11,%%ymm11
vpsubd %%ymm4,%%ymm5,%%ymm5
vpsubd %%ymm12,%%ymm13,%%ymm13
vpsubd %%ymm6,%%ymm7,%%ymm7
vpsubd %%ymm14,%%ymm15,%%ymm15
vmovdqa %%ymm0,%c[p]*0+0(%[dst])
vmovdqa %%ymm8,%c[p]*0+32(%[dst])
vmovdqa %%ymm1,%c[p]*1+0(%[dst])
vmovdqa %%ymm9,%c[p]*1+32(%[dst])
vmovdqa %%ymm2,%c[p]*2+0(%[dst])
vmovdqa %%ymm10,%c[p]*2+32(%[dst])
vmovdqa %%ymm3,%c[p]*3+0(%[dst])
vmovdqa %%ymm11,%c[p]*3+32(%[dst])
vmovdqa %%ymm4,%c[p]*4+0(%[dst])
vmovdqa %%ymm12,%c[p]*4+32(%[dst])
vmovdqa %%ymm5,%c[p]*5+0(%[dst])
vmovdqa %%ymm13,%c[p]*5+32(%[dst])
vmovdqa %%ymm6,%c[p]*6+0(%[dst])
vmovdqa %%ymm14,%c[p]*6+32(%[dst])
vmovdqa %%ymm7,%c[p]*7+0(%[dst])
vmovdqa %%ymm15,%c[p]*7+32(%[dst])
)org64"::[src]"r"(src),[dst]"r"(dst),[p]"i"(LP*4):"ymm0","ymm1","ymm2","ymm3","ymm4","ymm5","ymm6","ymm7","ymm8","ymm9","ymm10","ymm11","ymm12","ymm13","ymm14","ymm15","memory");}
template<unsigned LP>static inline __attribute__((always_inline))void ar_forward_global_lines(const unsigned*src,unsigned*dst){asm volatile(R"org64(
vmovdqa 0(%[src]),%%ymm0
vmovdqa 32(%[src]),%%ymm8
vmovdqa 131072(%[src]),%%ymm1
vmovdqa 131104(%[src]),%%ymm9
vmovdqa 262144(%[src]),%%ymm2
vmovdqa 262176(%[src]),%%ymm10
vmovdqa 393216(%[src]),%%ymm3
vmovdqa 393248(%[src]),%%ymm11
vmovdqa 524288(%[src]),%%ymm4
vmovdqa 524320(%[src]),%%ymm12
vmovdqa 655360(%[src]),%%ymm5
vmovdqa 655392(%[src]),%%ymm13
vmovdqa 786432(%[src]),%%ymm6
vmovdqa 786464(%[src]),%%ymm14
vmovdqa 917504(%[src]),%%ymm7
vmovdqa 917536(%[src]),%%ymm15
vpaddd %%ymm0,%%ymm4,%%ymm4
vpaddd %%ymm8,%%ymm12,%%ymm12
vpaddd %%ymm1,%%ymm5,%%ymm5
vpaddd %%ymm9,%%ymm13,%%ymm13
vpaddd %%ymm2,%%ymm6,%%ymm6
vpaddd %%ymm10,%%ymm14,%%ymm14
vpaddd %%ymm3,%%ymm7,%%ymm7
vpaddd %%ymm11,%%ymm15,%%ymm15
vpaddd %%ymm0,%%ymm2,%%ymm2
vpaddd %%ymm8,%%ymm10,%%ymm10
vpaddd %%ymm1,%%ymm3,%%ymm3
vpaddd %%ymm9,%%ymm11,%%ymm11
vpaddd %%ymm4,%%ymm6,%%ymm6
vpaddd %%ymm12,%%ymm14,%%ymm14
vpaddd %%ymm5,%%ymm7,%%ymm7
vpaddd %%ymm13,%%ymm15,%%ymm15
vpaddd %%ymm0,%%ymm1,%%ymm1
vpaddd %%ymm8,%%ymm9,%%ymm9
vpaddd %%ymm2,%%ymm3,%%ymm3
vpaddd %%ymm10,%%ymm11,%%ymm11
vpaddd %%ymm4,%%ymm5,%%ymm5
vpaddd %%ymm12,%%ymm13,%%ymm13
vpaddd %%ymm6,%%ymm7,%%ymm7
vpaddd %%ymm14,%%ymm15,%%ymm15
vmovdqa %%ymm0,%c[p]*0+0(%[dst])
vmovdqa %%ymm8,%c[p]*0+32(%[dst])
vmovdqa %%ymm1,%c[p]*1+0(%[dst])
vmovdqa %%ymm9,%c[p]*1+32(%[dst])
vmovdqa %%ymm2,%c[p]*2+0(%[dst])
vmovdqa %%ymm10,%c[p]*2+32(%[dst])
vmovdqa %%ymm3,%c[p]*3+0(%[dst])
vmovdqa %%ymm11,%c[p]*3+32(%[dst])
vmovdqa %%ymm4,%c[p]*4+0(%[dst])
vmovdqa %%ymm12,%c[p]*4+32(%[dst])
vmovdqa %%ymm5,%c[p]*5+0(%[dst])
vmovdqa %%ymm13,%c[p]*5+32(%[dst])
vmovdqa %%ymm6,%c[p]*6+0(%[dst])
vmovdqa %%ymm14,%c[p]*6+32(%[dst])
vmovdqa %%ymm7,%c[p]*7+0(%[dst])
vmovdqa %%ymm15,%c[p]*7+32(%[dst])
)org64"::[src]"r"(src),[dst]"r"(dst),[p]"i"(LP*4):"ymm0","ymm1","ymm2","ymm3","ymm4","ymm5","ymm6","ymm7","ymm8","ymm9","ymm10","ymm11","ymm12","ymm13","ymm14","ymm15","memory");}
static void dashboard_or_root9(const unsigned*a,const unsigned*b,unsigned*c){
constexpr unsigned H=262144,L=32768,P38=9961472,R=38528,T=1024,LP=T+16;
alignas(64)static unsigned sc[38][8][LP];

 
unsigned*t;{unsigned long long dq=(unsigned long long)((const char*)c-(const char*)gtmp);unsigned off=(unsigned)((32768u-(unsigned)dq)&65535u);t=(unsigned*)((char*)gtmp+off);}
for(unsigned side=0;side<2;side++){
 const unsigned*in=side?b:a;unsigned*out=side?t:c;
  for(unsigned j0=0;j0<L;j0+=T){
   for(unsigned g=0;g<5;g++){
    for(unsigned q=g*8;q<(g<4?g*8+8:38);q++)for(unsigned j=0;j<T;j+=16)ar_forward_global_lines<LP>(in+q*H+j0+j,sc[q][0]+j);
    if(g<4)ar_plane_low<false,T,LP,8>(sc,g);else ar_plane_low<false,T,LP,6>(sc,g);
   }
   for(unsigned r=0;r<8;r++)for(unsigned rr=0;rr<8;rr++){if(r<6){for(unsigned j=0;j<T;j+=16)ar_forward_direct<LP,true>(sc[r][rr]+j,out+r*H+rr*L+j0+j);}else for(unsigned j=0;j<T;j+=16)ar_forward_direct<LP,false>(sc[r][rr]+j,out+r*H+rr*L+j0+j);}
  }
 for(unsigned pos=0;pos<R;pos+=8){auto v=qI0((const __m256i*)(in+P38+pos));v=qI1(v,qI0((const __m256i*)(in+36*H+pos)));v=qI1(v,qI0((const __m256i*)(in+34*H+pos)));v=qI1(v,qI0((const __m256i*)(in+32*H+pos)));v=qI1(v,qI0((const __m256i*)(in+6*H+pos)));v=qI1(v,qI0((const __m256i*)(in+4*H+pos)));v=qI1(v,qI0((const __m256i*)(in+2*H+pos)));v=qI1(v,qI0((const __m256i*)(in+pos)));qI9((__m256i*)(out+P38+pos),v);}
}
_mm_sfence();
for(unsigned q=0;q<38;q++)for(unsigned rr=0;rr<8;rr++)solve_save(L,c+q*H+rr*L,t+q*H+rr*L);
solve_save(R,c+P38,t+P38);
for(unsigned j0=0;j0<L;j0+=T){
 alignas(64)unsigned ar_tail[2][T];
 for(unsigned g=0;g<5;g++){
 for(unsigned q=g*8;q<(g<4?g*8+8:38);q++)for(unsigned j=0;j<T;j+=16)or7_inverse_global_lines<LP>(c+q*H+j0+j,sc[q][0]+j);
 if(g==0)for(unsigned rr=0;rr<2;rr++)for(unsigned j=0;j<T;j+=8){unsigned pos=rr*L+j0+j;if(pos<R){auto v=qI0((const __m256i*)(c+P38+pos));v=qI2(v,qI0((const __m256i*)(sc[6][rr]+j)));v=qI1(v,qI0((const __m256i*)(sc[4][rr]+j)));v=qI1(v,qI0((const __m256i*)(sc[2][rr]+j)));v=qI2(v,qI0((const __m256i*)(sc[0][rr]+j)));qI3((__m256i*)(ar_tail[rr]+j),v);}}
 if(g==4)for(unsigned rr=0;rr<2;rr++)for(unsigned j=0;j<T;j+=8){unsigned pos=rr*L+j0+j;if(pos<R){auto v=qI0((const __m256i*)(ar_tail[rr]+j));v=qI2(v,qI0((const __m256i*)(sc[36][rr]+j)));v=qI2(v,qI0((const __m256i*)(sc[34][rr]+j)));v=qI1(v,qI0((const __m256i*)(sc[32][rr]+j)));qI3((__m256i*)(c+P38+pos),v);}}
 if(g<4)ar_plane_low<true,T,LP,8>(sc,g);else ar_plane_low<true,T,LP,6>(sc,g);
 }
 for(unsigned r=0;r<8;r++)for(unsigned rr=0;rr<8;rr++){if(r==0&&rr==0){for(unsigned j=0;j<T;j+=16)ar_inverse_direct<LP,true,true>(sc[r][rr]+j,c+r*H+rr*L+j0+j);}else if(r<6){for(unsigned j=0;j<T;j+=16)ar_inverse_direct<LP,true>(sc[r][rr]+j,c+r*H+rr*L+j0+j);}else{for(unsigned j=0;j<T;j+=16)ar_inverse_direct<LP,false>(sc[r][rr]+j,c+r*H+rr*L+j0+j);}}
}
_mm_sfence();
}

void convolution(unsigned n,const unsigned*a,const unsigned*b,unsigned*c){if(n!=10000000u){scalar(n,a,b,c);return;}dashboard_or_root9(a,b,c);}

 

CompilationN/AN/ACompile OKScore: N/A

Testcase #135.406 ms77 MB + 696 KBAcceptedScore: 100


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