# qm-1: Taylor Gaussian + qm-spline Solidity port The frozen port beats t03 on the assigned real engine sample: **+2.207150660219 edge, SE 0.096224495554, n=128**. Against IB: **+2.975182830869, SE 0.111932600425**. Engine afterSwap peak **229,132**, **zero OutOfGas**, runtime **20,135 bytes**. Gate P and validation pass; effective-fee Gate F passes. New figures are local measurements. **Gate-F qualification:** unchanged real.py can return an uncapped fee while storing the capped fee. Exactly one of the 200,000 raw reference outputs exceeds 10%. Effective fees, using real.py's own stored fb/fa and the replica's clamp, meet the requested tolerance. A literal comparison against uncapped return values fails; details below. This distinction is not hidden by changing the upstream reference. No values or results were fabricated. ## Sources and implementation Taylor (**gtmcknight**) wrote the solved policy at `4812a6382311624e1506aca131ca35c378f930d9`; read the [pinned README](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/README.md). The contract credits Taylor in its header. Starting contract: [trim-1](https://api.imd.fun/artifacts/fce772b9057867b241350b8e44c05298c6c877871a26b58702a5af431726f6c5), SHA-256 `d849c5f15d69499560b5c3ea08f55ad27153b393eba7abb7dd186f451ad46a24` (verified on extraction). Filter/setup/harness ancestry: [port-3](https://api.imd.fun/artifacts/0dbcc10af41b3c3467ff0d9b9cb64c81328fcf18295f9be06b2d81bb98874067). Tables, spline definition, decoder and frozen compression selection: [qm-spline](https://api.imd.fun/artifacts/17d249ab0c33fc44931d9b105cf3f9e3846a560bd518b67310c2a56defacdecc). Removed trim-1's Net2 inference and embedded Taylor's qm-spline coefficients instead: 4,896 int16 coefficients, 9,792 bytes, packed into **306 PUSH32 integer immediates**. The contract needs no payload installation, external calls, runtime libraries, assembly or external basis table. Knots are encoded as integer constants in 1/64 grid units. Runtime size is below both the 24,000-byte target and 24,576-byte deployment limit. The trim-1 Gaussian update, 12 separate silent-step truncations, timestamp handling, log/exp/CDF/root implementation, likelihood and mixture thresholds remain. Rival synchronization is now tracked as required by [RealPolicy](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/real.py): bit 256 in the existing cnt slot, reset on every new step and set when the retail candidate replaces the rival. The low count saturates at 2 because only phases 1 versus 2 matter. No extra storage slot is used. Initialization uses RealPolicy.init's unchanged **plain-table** center fee `0.002823606104386589` (encoded as 2823606104386590 WAD), not a qm lookup and not trim-1's Net2 initialization. Lookup chooses S=[0,4,8,12,16,20,26,34] by sqrt(v) in bps and linearly blends the two enclosing levels. Phase 0 uses 0c; otherwise phase and synced select 1s/1c/2s/2c. Own and rival grid positions, clipping and the nonuniform W2L search match real.py. Bid uses the point mirror. Fee conversion and 0..10% clamp use trim-1's fee function. At each of the surrounding grid nodes, evaluate the cubic spline and clamp F=A-w at zero **before** bilinear and sd interpolation. A also includes the clipped grid displacement; using a spline at the continuous query point would be a different reference. The Python decoder rounds A/B to 6 decimals as qm-spline does. Solidity evaluates at higher fixed precision without that final decimal round, covered by Gate F. Cox-de Boor bases are computed at runtime in Q23. Six divisions per basis, unrolled; partition-of-unity is preserved by complementary integer weights. Two adjacent bases are packed in 24-bit fields. Coefficients are biased by 32768 into four 64-bit sd lanes; row and column contractions consume 46 fractional bits, so each lane stays below 2^62 (coefficient magnitude <32768). Sd's Bernstein weights at integer level k are `(7-k)^3,3(7-k)^2k,3(7-k)k^2,k^3`, denominator 343, also computed at runtime. The QMS1 mirror exception and approximation loss are inherited from the supplied frozen decoder, not silently repaired with a different table. ## Setup and P, before policy changes Cloned both pinned repositories inside this item's permitted directory. No files were written to root scratch/, test/scratch/ or elsewhere. Successful installation of the pinned Linux x86_64 wheel and execution of the native engine establish the required platform compatibility; no machine inspection was performed. Ran port-3's Setup script once from the pinned challenge root, with curl download retries added (three retries, two seconds apart). Wheel SHA-256 matched `aedb68280aca34c110968f00148387c95885207913fb2cf19a1ab4c5cfd6887a`; venv/packages, solc 0.8.24 and StarterStrategy validation passed. An earlier shell invocation at the task root could not open `scratch/setup.sh`; it executed no setup steps. The script itself then ran successfully once at the correct checkout root. `blocked=null`; no download ultimately failed. Later toolchain commands sourced `. scratch/env.sh &&`. Every long command used `timeout 470`; no command ran over eight minutes. Before changing any policy code, plain `python3 -I gates.py` in the unmodified solved directory reproduced this output, exactly matching the [README](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/README.md): ```text seed perfect-info gaussian+plain gaussian+qm lattice+qm 10000 448.261189 443.455598 443.522608 443.663520 10001 576.779199 571.463409 571.623551 571.977293 10002 531.886497 525.168028 525.865859 526.411631 ``` **Gate P: PASS.** Compiler: unchanged [challenge compiler](https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/evm/compiler.py), solc 0.8.24, optimizer 200 runs, viaIR, Paris. Final `amm-match validate scratch/Strategy.sol` exited 0: ```text Validating strategy... Compiling strategy... Strategy 'TaylorGaussianQMSpline' validated successfully! ``` ## Q: exactly the compressed tables shipped Frozen profile: supplied QMS1 3-D sizes (24,10,4)/(24,14,4)/(18,12,4)/(24,14,4)/(12,8,4); no new table fitting or holdout-driven selection. The selected blob is 10,167 bytes, SHA-256 `3ac7cb8811ecfb6a17f499aa4e9b70dd55f7fb6432b3aec3b904e11a3dece38e` (verified). We repeated both requested paired ranges locally on the pure-Python replica with unchanged RealPolicy, soft=1, full versus decoded qm. Choose range completed before reading holdout results. | Range | n | Full mean | Decoded mean | Loss full-decoded | SE | |---|---:|---:|---:|---:|---:| | choose 60000..61023 | 1024 | 530.026094510303 | 529.971156871193 | 0.054937639110 | 0.010295841019 | | report 10000..12047 | 2048 | 533.326027337992 | 533.262830666503 | 0.063196671489 | 0.007194431268 | Holdout worst5 **losses** (largest full-minus-decoded): (10522,1.457596829663), (10711,1.359835282954), (12015,1.341616684156), (10268,1.171751677564), (10203,1.091629293394). Thus the spline's <0.2 edge loss target passes on this sample. These are paired replica results, not engine board scores. Decoded qm JSON: **10,639,373 bytes**, SHA-256 **`4d97c205783ddff731fecd9dbdaea09c295954d2d2e96fbf25eec1320a5c22fa`** (default json.dump spacing and insertion order). The included build_reference.py reconstructs it from the actual Strategy.sol constants; its output matched the upstream QMS1 decoder **byte for byte by SHA-256**. The large expanded JSON is intentionally not bundled. All values needed to regenerate it are in the contract. Q therefore measures the exact decoded tables shipped, not another approximation. Reference changes: **none to real.py or replica2.py**. qmref.py only locates the pinned sources and constructs `RealPolicy(T,{'soft':1,'qm':decoded_path})`. Decoder changes only the qm data; pol_mid.json supplies the original axes and initialization. The included Python scripts require the pinned measurement checkout and setup packages; they are measurement scaffolding, not Solidity runtime dependencies. ## F: 50 x 2,000 callbacks Each seed 70000..70049 drives unchanged [replica2.run](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/replica2.py) through the decoded-table RealPolicy. Stop after its first 2,000 own callbacks. Fresh pyrevm deployment per seed; initialize 100/10,000; amounts and reserves `int(float*1e18)`; **245,000 gas per call**. Both fees compared per callback; initialization is separate. The final contract was frozen before engine evaluation. | Metric | Result | |---|---:| | Runs / callbacks / fee comparisons | 50 / 100000 / 200000 | | Effective reference fee comparison | **PASS** | | Max absolute effective-fee difference, bps | 0.000988148793866495 | | Mean absolute effective-fee difference, bps | 2.53279836910865e-05 | | Initialization max difference, bps | 8.673617379884035e-15 | | Successful callbacks | 100000 | | Failed callbacks / OOG | 0 / 0 | | pyrevm afterSwap peak | 186205 | | pyrevm afterSwap mean | 94774.55865000 | | pyrevm sum callback gas | 9477455865 | Peak: seed 70016, zero-based callback 911. Trace-set SHA-256 (concatenated seed-ordered per-run SHA-256 hex strings): `316a54e2e52ff8373bc5a61ea353c24db71bc1a1cabc2e69898352acfd6f0f4d`. Trace hash is over compact JSON `{"init":fees,"rec":[[args,fees],...]}`; stored reference raw outputs are preserved in the trace. Max difference occurs in seed 70012. **Raw-return comparison: FAIL**, maximum **200.079335846508 bps**. In seed 70026 callback 1702, raw reference bid=0.12000793358465078, contract bid=0.1. RealPolicy itself stores the clamped 0.1 in self.fb; replica2 also clamps the returned fees before using them. See [real.py](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/real.py) and [replica2.clampf](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/replica2.py). The replay harness compares `min(.1,max(0,raw))`; it does not modify reference formulas or traces. Raw mean difference is effective mean +200.07933584650777/200000 = **0.00102572466292363 bps**. If the gate is interpreted to require raw uncapped returns, it is not met and the engine runs below should be treated as diagnostic; matching that interpretation requires changing the gate to compare effective fees, or explicitly authorizing returns above the requested trim-1 cap. Under the specified trim-1 fee clamp/effective-fee interpretation, F passes and the engine was run. ### One ask+bid lookup gas Measured on pyrevm with an instrumented copy adding `bench(w,r,ph,synced,sd)` returning fees. These totals include ABI dispatch/return, payload/knots initialization, both spline lookups and fee conversion; no filter or storage writes. w=R=0 in every row. Wrapper adds 39 runtime bytes; production source below has no bench entry point. | phase | synced | sd bps | gas | |---:|---|---:|---:| | 0 | false | 0 | 72890 | | 1 | true | 4 | 82153 | | 1 | false | 12 | 74802 | | 2 | true | 20 | 82321 | | 2 | false | 34 | 73321 | This is a specified-point measurement, not a proof of a global lookup bound. Optimization iterations used only replica traces, never engine seeds. ## Engine: assigned seeds once, chunks of 32 Each strategy ran **alone against 30 bps VanillaStrategy**, `amm_sim_rs.run_batch(X, VanillaStrategy, configs, 8)`. Seeds **9533000..9533127**, exactly once per strategy. Four separate chunks per strategy, no engine reruns and no other engine seeds used. Compilation/validation do not consume engine seeds. Configs transcribe [MatchRunner._build_configs](https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/match.py): NumPy default_rng(seed), draws size then rate then sigma, baseline fields otherwise. Gas counters reset immediately before each run_batch and read immediately after. Comparators extracted as zlib(base64(code_zb64)) from [t03](https://api.imd.fun/artifacts/2333ecf28d4356bd232b85c1e55842e94e1ada05e1cd067830b5625dfdbc5336) and [IB](https://api.imd.fun/artifacts/afd5183e9ff3235334e041c00b0cd19079599a2c6464db95f8c1586712105557); verified source hashes respectively `cb6d945511e1e10af78baa64c2a6cb25806f0998403ce6440654bfc3c70092d9` and `301941829a44bb60977bb28181a5e4bfa6544f3696763f987054789b2611d686`. Contract source hash was identical in all four port chunks. Paired submission-edge difference = port minus comparator; SE = sample SD / sqrt(n). worst5 is the five smallest differences, not their average. | Pair | n | mean_diff | se | worst5 (seed,difference) | |---|---:|---:|---:|---| | port - t03 | 128 | +2.207150660219 | 0.096224495554 | (9533052,-0.645451157990), (9533075,-0.311969954956), (9533003,-0.060601735768), (9533092,-0.027096654046), (9533024,+0.001551155035) | | port - IB | 128 | +2.975182830869 | 0.111932600425 | (9533088,-0.167590112162), (9533003,-0.037214513990), (9533117,+0.436349983036), (9533124,+0.532900507788), (9533092,+0.589756646450) | | Strategy | Mean submission edge | afterSwap calls | Peak gas | Mean gas | OOG | sum_ok_gas | |---|---:|---:|---:|---:|---:|---:| | port | 537.151367842100 | 1404904 | 229132 | 131282.35640585 | 0 | 184439107644 | | t03 | 534.944217181881 | 1393477 | 235406 | 135500.18926900 | 0 | 188816397242 | | IB | 534.176185011231 | 1382304 | 232014 | 135172.51164722 | 0 | 186849503540 | All calls succeeded; revert, other_halt, tx_error and bad_return are zero for all strategies. Port afterInitialize: 128 calls, peak/mean 140367; getName: 128 calls, peak/mean 21568; no failures. Engine gas is measured independently of pyrevm, not estimated by adding an overhead. | Strategy | First seed | Calls | Peak | OOG | |---|---:|---:|---:|---:| | port | 9533000 | 338091 | 220392 | 0 | | port | 9533032 | 354879 | 229132 | 0 | | port | 9533064 | 356662 | 219323 | 0 | | port | 9533096 | 355272 | 219829 | 0 | | t03 | 9533000 | 336687 | 232494 | 0 | | t03 | 9533032 | 352123 | 235406 | 0 | | t03 | 9533064 | 352956 | 235394 | 0 | | t03 | 9533096 | 351711 | 232600 | 0 | | IB | 9533000 | 334521 | 231801 | 0 | | IB | 9533032 | 349084 | 232014 | 0 | | IB | 9533064 | 349883 | 211295 | 0 | | IB | 9533096 | 348816 | 231962 | 0 | ## Complete Strategy.sol Source length **42710 bytes**, SHA-256 **`c96e646d5c76ebcdf1e57aecbfe207b3a0e92e71281ac437eeb3046babb94883`**. The block includes its final newline. Extract verbatim beside the unchanged pinned challenge base contracts. No additional contract dependency is introduced. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {AMMStrategyBase} from "./AMMStrategyBase.sol"; import {TradeInfo} from "./IAMMStrategy.sol"; // Gaussian solved policy by Taylor (gtmcknight), amm-sim 4812a638; filter ported from port-3. // QMS1 cubic spline coefficients from qm-spline, Taylor's qm policy. // Runtime Cox-de Boor bases, Q23; clamp each grid node before interpolation. // Four sd coefficients use four 64-bit lanes during row/column contraction. // Taylor source: https://github.com/gtmcknight/amm-sim/tree/4812a6382311624e1506aca131ca35c378f930d9/research/solved contract Strategy is AMMStrategyBase { int256 constant U=1e18; int256 constant LN2=693147180559945309; struct Belief { int256 m; int256 v; int256 fb; int256 fa; int256 sp; int256 r; uint256 t; uint256 cnt; } function getName() external pure override returns(string memory) { unchecked {return "TaylorGaussianQMSpline";} } function mul(int256 a,int256 b) internal pure returns(int256){ unchecked {return a*b/U;} } function divi(int256 a,int256 b) internal pure returns(int256){ unchecked {return a*U/b;} } function ab(int256 x) internal pure returns(int256){ unchecked {return x<0?-x:x;} } function clip(int256 x,int256 a,int256 b) internal pure returns(int256){ unchecked {return xb?b:x);} } function ln(int256 x) internal pure returns(int256 z){ unchecked { require(x>0); int256 k; while(x< U){x*=2;k--;} while(x>=2*U){x/=2;k++;} // Reduce to [1/sqrt(2),sqrt(2)]; |y| <= 0.171573. if(x>1414213562373095048){x/=2;k++;} int256 y=divi(x-U,x+U); int256 y2=mul(y,y); int256 q=y; z=y; q=mul(q,y2);z+=q/3; q=mul(q,y2);z+=q/5; q=mul(q,y2);z+=q/7; q=mul(q,y2);z+=q/9; q=mul(q,y2);z+=q/11; q=mul(q,y2);z+=q/13; q=mul(q,y2);z+=q/15; q=mul(q,y2);z+=q/17; q=mul(q,y2);z+=q/19; return 2*z+k*LN2; } } function exp(int256 x) internal pure returns(int256){ unchecked { if(x< -42*U)return 0; require(x<60*U); int256 k=(x>=0?x+LN2/2:x-LN2/2)/LN2; int256 r=x-k*LN2; int256 r2=mul(r,r); int256 even=665280*U+mul(r2,75600*U+mul(r2,840*U+r2)); int256 odd=mul(r,332640*U+mul(r2,10080*U+mul(r2,42*U))); int256 s=divi(even+odd,even-odd); return k>=0?s*int256(uint256(1)<>128>0){z>>=128;r<<=64;} if(z>>64>0){z>>=64;r<<=32;} if(z>>32>0){z>>=32;r<<=16;} if(z>>16>0){z>>=16;r<<=8;} if(z>>8>0){z>>=8;r<<=4;} if(z>>4>0){z>>=4;r<<=2;} if(z>>2>0){r<<=1;} for(uint256 i=0;i<7;i++)r=(r+n/r)/2; return int256(r10*U)return 0;return divi(exp(-mul(x,x)/2),2506628274631000200);} } // Hart rational normal tail approximation; erf(x)=2*Phi(x*sqrt(2))-1. function cdf(int256 x,int256 density) internal pure returns(int256){ unchecked { int256 y=ab(x);if(y>8*U)return x>0?U:int256(0); int256 n=35262496599891000; n=mul(n,y)+700383064443688000;n=mul(n,y)+6373962203531650000; n=mul(n,y)+33912866078383000000;n=mul(n,y)+112079291497871000000; n=mul(n,y)+221213596169931000000;n=mul(n,y)+220206867912376000000; int256 d=88388347648318400; d=mul(d,y)+1755667163182640000;d=mul(d,y)+16064177579207000000; d=mul(d,y)+86780732202946100000;d=mul(d,y)+296564248779674000000; d=mul(d,y)+637333633378831000000;d=mul(d,y)+793826512519948000000; d=mul(d,y)+440413735824752000000; int256 tail=(density*2506628274631000200/U)*n/d;return x>0?U-tail:tail; } } function trunc(int256 m,int256 v,int256 lo,int256 hi) internal pure returns(int256,int256,int256){ return truncSD(m,v,lo,hi,root(v)); } function truncSD(int256 m,int256 v,int256 lo,int256 hi,int256 sd) internal pure returns(int256 Z,int256 mt,int256 vt){ unchecked { if(v<=0)return (lo<=m&&m<=hi?U:int256(0),m,0); int256 a=divi(lo-m,sd);int256 b=divi(hi-m,sd); int256 pa=pdf(a);int256 pb=pdf(b); Z=cdf(b,pb)-cdf(a,pa); if(Z<1e6)return(Z,m -w?U-exp(-(b+w)/10000):int256(0);fa=a>w?U-exp(-(a-w)/10000):int256(0); fb=clip(fb,0,U/10);fa=clip(fa,0,U/10); } } uint256 constant Q=8388608; function payload() internal pure returns(uint256[306] memory D){ unchecked { D[0]=0x1813181b1872184717ef18cf17c618390000000000000000180018521836183e; D[1]=0x183218f917db18521850184518ac1880185417c919441863180c191d17aa1846; D[2]=0x0000000000000000144c14ad148114891849187d185a18620000000000000000; D[3]=0x143e17811158146514c512ff164b14cb143a158113b0147814801389158914aa; D[4]=0x14721595144a14a4000000000000000014a214b6152614f314591622136e141c; D[5]=0x0e500d880f2d0e780dd60ff00cdf0e1f00000000000000000e1e0e600e450e50; D[6]=0x0e560ed60e090e0e0ebd0cf810210f570eb20be6120b0ec90dde10c20c330e15; D[7]=0x0000000000000000074f075e074407460e9d0dbc0f040e970000000000000000; D[8]=0x077d0928059a072f07d20630085c078f073b07fe06d407320783068907e3076a; D[9]=0x077c08ee06b4073d000000000000000007a40882070a07b10767092f064e069b; D[10]=0x042a03e803ec03d703fe044d037903a00000000000000000041203fa03ba03ba; D[11]=0x047604cc053a054604db03cb062d0606044d04d904ca040d042804d9036903bd; D[12]=0x000000000000000002c802ed028702810492047105ba05cd0000000000000000; D[13]=0x03af02c30425052d03200309030c026f02c00331027802a502f202a702a6026f; D[14]=0x038803ee03ae0339000000000000000003a5038e041103ee032d0488032002eb; D[15]=0x0266025d023801d50232029c01db02540000000000000000026a024b020f0201; D[16]=0x033d022d048e06c7031202e90390035802c5031e037c025802b2026f02500326; D[17]=0x0000000000000000022e021201da01cc0305031f033f059b0000000000000000; D[18]=0x028e02a002f403a5028401e8026c021401fe024801c801f3027201a201ff01b5; D[19]=0x02d20301033a01d9000000000000000002800392032300ac02e202f702b30355; D[20]=0x0238018801e80195018a02b7017001ea0000000000000000022d01cb01c301b2; D[21]=0x03070232039f03aa025702c602ab02f802b60225033d01cc01e8025901c60294; D[22]=0x000000000000000001ec01c801b6019702ab02860340035d0000000000000000; D[23]=0x0203028702690308024a014a020c01b5019e022e017101c402ac00a0021b0178; D[24]=0x027902ed020303130000000000000000026d02660255033102ac0276031f026f; D[25]=0x0233009801de013300ff034f00660176000000000000000001d5016801660162; D[26]=0x026d026703a5017301d9025e016b02a202a0016902a401c201140270012b0200; D[27]=0x00000000000000000142010200f600fa024601ec037301bc0000000000000000; D[28]=0x00e302de006901ed01aefef60225009400f50236ffad01250233fdca03690205; D[29]=0x01a101d601a801ed0000000000000000015a0255008d029701f100fa02aa0182; D[30]=0x0121fe76021c017eff9404e5fad7fe17000000000000000000b9ffc80022016b; D[31]=0x01400044023700c4008f019c003900e70134ff34022400e2fff001e6fe96ffab; D[32]=0x0000000000000000000c00b8ffdffd4100f500ff011400f80000000000000000; D[33]=0xff960187fea6ffcf00b2fc7e02c8001effd102a8fc0e002d00eaf6730df70125; D[34]=0x0063005c00740084000000000000000000120121ff56008a008effaf011a0073; D[35]=0x005df6c704e8ffd6fe5514b4eccbff0300000000000000000010fbd9023801ea; D[36]=0x0089fea501250020ffb40140ff66fff90055fc9b00c3ffdfff3305d9fe12ffaf; D[37]=0x0000000000000000ffb2017efecafdb2000d004a000a001f0000000000000000; D[38]=0xffe20183ff6a00140043fd5c010cfff4ff9b0354fd6b000a00a2f92d0672000e; D[39]=0xffe0ffcaffd000000000000000000000ffe900cbff0d000c000bff290071ffee; D[40]=0x002efe7b007c0008ff8a0351fdc5ffc300000000000000000008ff64005a004d; D[41]=0xffddffc6005cfffefffe0062ffce00030010ff230047fffdffd70130ffa6fffb; D[42]=0x0000000000000000fffa0016ffebffc20001001e0014fffd0000000000000000; D[43]=0x00000038ffe800020006ffb0001ffffefff4004fffda00010010ff5e005ffffb; D[44]=0x0005ffc5fff400010000000000000000001dffcaffcf0002fffbffe50012fffe; D[45]=0x0002ffe100090000fffd0037ffe900000000000000000000fffffffe00020001; D[46]=0xffe10028000f000000040006fff90000fffeffe6000affffffff001efff60000; D[47]=0x000000000000000000000001ffff0000fffb00160004ffff0000000000000000; D[48]=0x0004000efff90000fffcfff0000700000002000efffa0000fffcffe9000b0000; D[49]=0x0005ffd2fffe000000000000000000000018ffaafff20000fffafffd00050000; D[50]=0xffffffea0008000000030024fff2000000000000000000000000ffff00010000; D[51]=0xffda003d002900000004fffefff70000fffeffe5000c00000001001bfff50000; D[52]=0x000000000000000000000001ffff0000fff8002c000700000000000000000000; D[53]=0x00000025ffea00000001ffda00120000ffff001afff300000001ffd500160000; D[54]=0x0008ff96ffe60000000000000000000000170009ff4f0000fffdfff300160000; D[55]=0x0001ffee00090000ffff001dfff1000000000000000000000000ffff00010000; D[56]=0xfff4ffe7006e00000001000cffec00000001ffe500110000ffff0019fff30000; D[57]=0x00000000000000000000000000000000fff7003c0013ffff0000000000000000; D[58]=0x00000008fffa00000001fff800040000ffff0005fffd00000001fff800050000; D[59]=0x0001ffd3fffa0000000000000000000000010014ffc40000fffffffb00050000; D[60]=0x17d8189617bc18221739180117d6180a16ed186b17d91806173b181917fb1806; D[61]=0x1841176019be186217c318c217e6180f17d018f91765182c17cd18371856182c; D[62]=0x181b18b917a517de181418c517b61893182c179a193f1875182f17171a31184e; D[63]=0x131a150f13a114351349140e142e141b185218bc17c1182b185d1875182d1809; D[64]=0x148d12be161214721404147513c8142c1405139314e7146113571439149d141b; D[65]=0x13f515fd12b2124313df173a10131345136517ce0f0c13b414a9139c148714c9; D[66]=0x1481145715ad14b0145a158713bb15bf145d140f155b1565144f13fc14ed1396; D[67]=0x0d3e0e610c400d3c0c620dfd0c5a0d6d0c710c910dcd0d320c810dcf0d030d5b; D[68]=0x0eae086515670e300c490f810c600cdd0cae0f8b0b3c0d440d000dcf0ddd0d91; D[69]=0x0d6e0e7f0be80c020d660ee40c430f150dec0ad6112f0fe70dc00a4313220f14; D[70]=0x05f4066105e805ff058f05e105c605f00db00ed20a900d020dfd0cba0df30abb; D[71]=0x06e3053807240636064405ff05a905ff0610059706f506240558059805e905df; D[72]=0x0646085c033e049e0646086402e6050f05a2094e019905b7074604d306ef0683; D[73]=0x06e8069b08f4079806ad081c06d2098a06d00601074e06b406a60633060304be; D[74]=0x028f0269022b0260034602de0284028102610252021802450290020f02930262; D[75]=0x03a5028a04a002da028004a601f8024902a603c4022c02870310034002a8029f; D[76]=0x038e0450047e04ae03750453046204ca0394035204d4043c0363035e044b0398; D[77]=0x014b00a5015401830169018effbc01350417049b04990477042d04e5049b042a; D[78]=0x0257023a025d01e601fc022d01d501c5021101d801b701bb0256022001d30193; D[79]=0x02c4031702e4031402b102bb02ca0331027802b6026e032a02c901c402f40319; D[80]=0x03bc03b50379039203c703c103bd03ec031e03a4032b033d031003140378030c; D[81]=0x01ee019b018b01a501b101ac01e2011d017d01ebffde01430165ffcf02e700f1; D[82]=0x024002220298022b022b01dd024b020e01f801fb01b1023801d201c101bf0198; D[83]=0x02c703490306032d02af02fd02f8032b027e028b02eb02c7025c024302ce0279; D[84]=0x00fa00a90052ffe000c50021ffff0194038a037b0387034203ae035b0390033d; D[85]=0x01d8019301cd01aa01b3017a017b018401b101810147010301d7016501280186; D[86]=0x0242025802730276022a0203024b025601fb01e10216024201e901bc01e50212; D[87]=0x0385034e0276031403a303460311033f02bd02ee02b602b20291029102bf0295; D[88]=0x019f010e012f00f90116012500ff00d80113011a000d002000b3ff38ff850112; D[89]=0x01c501c501e801d201c5016101cb0196017e0184013d01ae0176012e012d013d; D[90]=0x029c02b9027e0293024c02790267026e020d021f0237023201db01f5020601f4; D[91]=0x006a00caff3dfff60066fe3403be0044039302d103e502b4038c030e02e202b6; D[92]=0x015c01040144012f015700c7012d00f6013d012200af00e10150008600fd0087; D[93]=0x01d501dd01f901e101a101bd01b901c701a3015001b301910154016901320190; D[94]=0x03a2035c00df029403af033b02a903190282024c026b02020211027e01fd0230; D[95]=0x011e0084012d004800ba0114ff4b00d3002effdf0233feb200080479ee7800d2; D[96]=0x013f014301450158014300eb0138012700fc00ef00e3010a011800d1006e010e; D[97]=0x021502ef01ac024701d901f3024701bd017a01e3017501b80175015b01ae0164; D[98]=0x000702c8fb4cffd80020f7aa0ba9fe3903d4034d05c201b103fe025a02e20247; D[99]=0x00fc005e00de008300e7007a0079013a00e200e5ffb200a100cdff4501faffca; D[100]=0x0155014201a90161013c0131014e0141011800da012000fc00e200e600d20106; D[101]=0x03e5061105a80a39042504f701ad023501a3019a028d021e01bc0215017401a3; D[102]=0x0051005e00290124010f00c3ff58fdbbff40fcaf025e032aff58057af7c1fb4b; D[103]=0x00ce00c500d400c600cf006b00ba00e20083008b0054008500de0052002400b4; D[104]=0x01b80233018300ca0164015f01b901bd011b014f014600e400f600ee00fb0120; D[105]=0x0099fad90478fd14ff6400eeff4502650468072203a0073a0418019d04460686; D[106]=0x008b000ffff500c0008a0019005300b400d5ff57ffc900d8ffdc0198fe7300ac; D[107]=0x00e400ec012a009200ce0083010600e600900093006d0081007f002c00bb0015; D[108]=0x047e03330a8e044603f2007d056f068d01af01ee0128008001310147013601a9; D[109]=0x0024ffd9ffe3006300d8fbf1020d007dfde208bbfaebff95007cfcf2011afefd; D[110]=0x006b0021008f007d0046fffd002d0058004d0040ffe700310088fef200fe004f; D[111]=0x014300d801c0ffe500ed013200f9018e00ae00bb00c800700066008d0041006f; D[112]=0x015bf8220412000bff60025dff0afed7040e0775085e051d0311052a016306e9; D[113]=0x0091fd99010a004bffd1009cff90003e0043fdce0158003dff510426fd850042; D[114]=0x0062007200740068005afffa00b40052001f0002fff8fff0fff5ffd8ffe3ffc7; D[115]=0x03e5061e0831030702fb016702ff05f30152014d0125004b00aa00c600c700e3; D[116]=0xffc50114ff49002c00b4fd57017effd8fecd0471fdcbffdf0043fe6d0080002a; D[117]=0xff8afff60029ffee00110002ff78001fff580171ff85ffea002eff4a0076ffe6; D[118]=0x0032019affceff42009b003a00e600f70020006b00120010ffbeffccffa7ffc6; D[119]=0x006bfda50136fffdffd00091ffb0fff2030e089f093703be044401190457070e; D[120]=0x002dff3d0012fffcfff2005affc0000c0013ff6a0065ffd7ff990167ff2a0018; D[121]=0xffbcffa1ffbaffca0055ff82007a0015ffd900a9ff89fff7001dffb9006cfff3; D[122]=0x030102c90d0100d1027e014501b804ff00c2ffff0128fff0002d009d00200033; D[123]=0xfffa001bffe700050016ffae003cffffffde0089ff9dfff70007ffd800120003; D[124]=0x002eff21003bfff6ffe0004fffd70007ffe60022fffafff90006fff00012ffff; D[125]=0xff790098ffb3ff570000ffb0ffb60010ffd3ffdb0065fff6ffa600b1ffa90002; D[126]=0x000dffcbffe8fff9fffa000cfffc0002029e0375140e02f403c002f20279058c; D[127]=0x0010ffdcffb8fff6fff7000d000a00060006fff2ffecfff7ffee0027000d0008; D[128]=0xffebfe7afeceffc80006ffdb00ce0019000c0068fec9ffe5fffbffe30062000a; D[129]=0x01d5fd0304df0112018705cd031602dcfed3faf4fe77fecd00a8020a0146005e; D[130]=0x0003ffed000500090002fffa0009fff6fffc0014fffb00080002fff90004fffc; D[131]=0x00b7fd3b00780021ff7b0121ffc4fff0000dffae001a000cfff5001a000afff8; D[132]=0x022bfd8200bafd77fba7086cff94ff9a013ffb720107003efe9402bdff6fffd7; D[133]=0x0004ffe20024fff7fffe000afff20003fe3601df019cfc26fe2cfdfffaa30046; D[134]=0xfff1004c006dffee0008fffeff850009fffc000a0025fff2fffd0015ffbf000c; D[135]=0xfe5506300445ffa10130fdd0fb850032ff3202db023affcc0078fef4fe5f0013; D[136]=0x00fdfc2e00a5010e021004e8fe7201e1fceb01b317e503bb03fff3e1eddd0070; D[137]=0x0003fff9ffdc00080001fff50030fff9fffe0010ffe300050001fffb0009fffe; D[138]=0x008afe3afca50019ffa400aa0172fff6000cffccff6e0009fffa00030056fffb; D[139]=0x025c029fdd65fb5bfd2f05641178ffe70122fca6f7c30029ff22013904a9ffe7; D[140]=0x0001fff9000cfffeffff0002fffc0000ff860199ffce0008fe63fb0a01c8fcd8; D[141]=0xfffc000e0028fffd00010001ffd30002ffff0000000ffffcffff0006ffea0003; D[142]=0xffab01540169ffed0021ff9dfe2d0007ffd9008400c4fff6000fffb6ff600003; D[143]=0x000fffa20006ffe7002d009effe1009aff7d009f065e00660074fd27f94a0011; D[144]=0x17da180c18131828179c1808183f181e172018b817cf183617631852180e1826; D[145]=0x18a614971b5b185d1855182718161843180717731927182917b0185e1807182c; D[146]=0x17e618e917c9185c185b168319b217e1174a1b82163618aa18a7163a18d3184e; D[147]=0x12f913f0131d1327128c135912d5131a1245131b133513281275137812f41328; D[148]=0x119d19ad0e6d129611ac16c10f5a12e0127a17640ec1134413a5128a14101339; D[149]=0x1336127e13bd12f21202186c0f1c13a514ce0c561768129c113e1887119112cb; D[150]=0x0b960b900be20bfc0b950af30c9b0bee0ae40d7b0b190c1b0b3c0bec0c010bf4; D[151]=0x0d8407240fad0cdc0dad07c410470c780c4209690f220be20aaf0c5f0b980bf2; D[152]=0x0bb60d7c0b1c0c930d0506ee11a60b7a09fc13c105f30d330dd108000e170c9c; D[153]=0x051004910484047a03f1059d03f7045b048b039c04c00481046504be04510473; D[154]=0x046206fa02f903f1041b07160269043b04b405c0037404a205b40481048c0487; D[155]=0x050d04d8048a041404d9071c015204f2055602e506f7039004b20641035b0418; D[156]=0x0210029801cf01e202170095021b01a902fa034a01450264025d01c7020701a8; D[157]=0x02ea027a041b0399030d01e8043f0282025602d102a501c201c602f101e801ee; D[158]=0x02ba034c03eb047c035b011806c50233024304cd021e05fe02e902b1045a0406; D[159]=0x01df017701a0019901f30216015c00d501d10098040b020401da01f8008b0148; D[160]=0x023d021502f2012b01e602c8005f04fa01c4025a00b80438020b017a01f4016c; D[161]=0x027f026d02bf01ed021d0353005903e802c801f6043b00c702480260029101f7; D[162]=0x01a9012a014900f001a7014000e601e6019dffbc0202005101ad01c000e0016c; D[163]=0x01e6020201f8029f01dc018202850127020700cc02efff8a016f0177011c01d5; D[164]=0x02160275026102bc0281012903a401a601d703700180037b020d0213025b027a; D[165]=0x015400ea00cf0168015101ca00f6fde101bcfebf01140388012e01be0107fffb; D[166]=0x01b8016e0265010401670190015501900156016200730350013a00e101500031; D[167]=0x021501f3020701d900d3032a00d701c602f20143031c01e80191020101c601c6; D[168]=0x011100c40060009c00d8ff9101e6024600f7042efd38ffdb0129ff7600ee015b; D[169]=0x011b01a0011a0196015000db013a01a700e200db0148ffc60141002d00e20135; D[170]=0x016b01e3020701870215012700aa0209011f027c020601730177013c01eb0139; D[171]=0x00a2007b002900af01b3ff7fff2f016e0006fee5038f000d00ed009aff7600e5; D[172]=0x011000a001b2006600be00d10085010900bd003a00b100d700c80030004e002d; D[173]=0x01800144013b01340047020a0160013a025300ad023b010b00e5016000f7016f; D[174]=0x008d0008ffde0125ff910142fdd2ff56015dff5e012f012d0051ffd0ffe4003d; D[175]=0x007b00e2002201060095001600d000560065fff80083ff930087ffefffbe011e; D[176]=0x00d600fe00eb012c016500c0014800020093020a001f01fa00c100b101090093; D[177]=0x0003ffcdfeee016e00e7fdeb04a7ffa0ff92ff1bfd850073004eff4101160040; D[178]=0x007fffd2011cffc4fff10042ffc4002f0039ff2e004effbc005aff61001000b7; D[179]=0x00d7004800e700aa002c0215ff8b00990130007c01ae00ca0062007c006300ba; D[180]=0x0013ffdc006aff90ff560154fe22ff040069ff5f012100ceffd20042ff98ffaf; D[181]=0xfff4ffccff3c0019fff6ffc40010ffee00020037ffb0002affcd003bffedffc8; D[182]=0x008d0038ff400079ffe500ce02c0ff0900f60066ff6e00deffcf0074001dffe3; D[183]=0xfff7fff80005ffff0047ffa600620006ffba0045ffadfff1000effed00150000; D[184]=0xff5000df0034fff10047fff5ffbd0008ffd100060035fff3002affd4ffec0006; D[185]=0xffa70067006bffc700a6fd2cfe2b004cfed00331ff9fffad0086fdaf0039000a; D[186]=0x000e0009fff60000ffa10067ff92ffff0048ffb600560004ffe9001affe50000; D[187]=0x010cfd8fffe10009ff66002d0050fffa0054ffe9ffc10006ffb7004a0008fffd; D[188]=0x0038fe8dfff50018fedc05fdffc5ffca0182f7b701360035ff1003c2ffa1fff9; D[189]=0xffddffd90022ffff0069ffcb00570001ffac0031ffacfffb0013ffef0017ffff; D[190]=0xfdb2044400c9ffef00fa001cfef9000aff4500330091fff5008bff17ffed0005; D[191]=0xff9c01a0fffeffdc01a1f64f0068005cfd830e01fe79ff97019bf5c6008a000d; D[192]=0x0010004cffba0001ffc1ffedffee00000031ffff00230002fff30005fff40000; D[193]=0x017dfcf7fe15000cff53fecd018cfff800710059ff090007ff8b0090003bfffc; D[194]=0x0039fedefffe0016fed50650ffbfffbc01d9f68800b20048fe76073d0013fff6; D[195]=0xfffaffd400170000000d001cfffdfffffff4fff3fffa00000001000000020000; D[196]=0xff5b01770059fffc002fffbcff9b0002ffd80036001efffd0017ff8500000001; D[197]=0xffe4004afff5fff80056fd3e0032000fff700411ffeaffed004efc34ff4c0002; D[198]=0x17bb187d17b4180d172818051806180f1704187817c91803172f182817f51807; D[199]=0x17a4196a170a17f717b918be176f182b17dc1844181b181f17a5184618281821; D[200]=0x17cd196f1686196717f717f1193f183e17e0183e18f4183e17d7181818db1828; D[201]=0x133214c813e014361358141414201426180618a117ec1870182217ea19301795; D[202]=0x13f1148913f7143713f1146c13b4143013f2139315011457130f145e13f9141a; D[203]=0x14211496121f13a5141c151212231423149a11f8164f1515143b134e15cc1429; D[204]=0x1442144c144413ee140a1591122c151a14761245172311de13f0159c112213c7; D[205]=0x0d510e2b0c4b0d5f0c7a0e5d0d330d790cbd0cc80d9f0d660ca00e1a0d230d6e; D[206]=0x0c69118d09f80c8c0cdd0fa10b060d930d7c0d540dbf0d9d0ce10dfa0e020d8b; D[207]=0x0cf010d20a9a10000dae0c3912260ed20d420db011030e410d330d2d10760da2; D[208]=0x05e906da05ea062c05af05c5062b062a0d880e400ddc0e110dd80cf90f800dd4; D[209]=0x064b0694060e062f068d05f20601063606040629069e0644059c057d06360617; D[210]=0x06e105f5045a05cb06c7069604830658076203c0088206e706d00569079d0640; D[211]=0x06e1068105b605b50688081103cc0608073e03f7083804430665082701e40563; D[212]=0x02cb02b402780297032702f8029c02a602d702980275028a02c2023d02a1028b; D[213]=0x02ee05680136022f0306045501be02c2034b032a02c502cc0318035b02ba02b5; D[214]=0x02a206d303a50515040601c0059a0390030c050b03a70321036f03c90361028f; D[215]=0x01980134012b01820183006700fd017603a004d8054a0543046502140673051f; D[216]=0x021d02ee01a401b6020f021701d401d2022801e401b701bc0261020d01d901b8; D[217]=0x02fb02a3039f03d90261034102f503b3032b0140044f030a020e02d1029901b1; D[218]=0x035d037c03530302031e04dc02df03420353029e03b2035f027c0457032a03ce; D[219]=0x01f4019f01a1018501b001a101c0016f014201e2009100dc01ac01590192017e; D[220]=0x01f602d001d40276028e014e025e02e0020501c10206019e01d201c101a9019f; D[221]=0x026003be02c1031302b10289032d02d1026702d202db028a028701fc02fd0253; D[222]=0x0171017eff53004b00f5ff0301a4012602fa036f034503820365026204350381; D[223]=0x01bc01bf017001e901b301670179014601b701750139010d01bd014c01450142; D[224]=0x023f026b027602b50219021f025b027a020e019f026b022301ea019e021301ab; D[225]=0x030302f802b7029c03000364029f02d4029702b002bb02ad025e02d802ab02cd; D[226]=0x017d0123012b00e5015500c000eb00f3008d01d800be0007011c0074ff3800b3; D[227]=0x01b301da01d601df01c80160019f01d3017b015a0157016d019400fb013700ff; D[228]=0x0266029502a1026502510279024a0256020a0213026c022301e601e6020501f5; D[229]=0x0110012dff52ff570086feda01e200c002f7029802f40293030e0307026f02ff; D[230]=0x015300f901240142014500e700e500f8014800f700c2009b011c00af00cc00e7; D[231]=0x01de021401d30207019c01e201c901cf01aa013201c90191015c0153014c0159; D[232]=0x02ea02b70216025d02fa02d602b70211027f02610207023a020002770226022a; D[233]=0x00dc00dd009f009a0158000300590029ff8d015900fefff300f00056fb34ff66; D[234]=0x0146013901540157013700f0012c013d010200dd00be00f9013f007b00e0008c; D[235]=0x02340225022b01c901c4027201ea01d9017601c401d601a6016e0183018f017e; D[236]=0x0148ff420045fd81fff0fef100e000dc0334024a0292020e0303031e0253030f; D[237]=0x010e002800f900a900b00113ffae01200129ffef00ceffd40031012fff790125; D[238]=0x013b01c8015201860144011f0187013c011c00dc011e011200e300e000c700e7; D[239]=0x028902db01cd01be04260331018900e7011f02d701c1027c0203015c02320193; D[240]=0xffcd017dfeec008701f7fd9e02c0fe86fe1d03abfad302430112fdb00297fe0c; D[241]=0x00d000c400de00c700d0005200c800cf00810092001700740104ffda007f00d0; D[242]=0x023501b1013a0117013001db017501c6013401340180011800fb00ff00fb0111; D[243]=0x01a1f6720aaafdb1fe7204d0f9a10133033a048d0819092201c101d7053704b3; D[244]=0x0090fffd000900b800cfffdf000c00ac00cbff25003400dfff5f0383faff009b; D[245]=0x00ce0128010300f800d50093011200d400980081007a00a50087002100a30029; D[246]=0x020d051d079702190556fc760562066f011b02b8013b00bd015f01320157016e; D[247]=0x009cfed30002003c002efde302ec0073ff25069bf7d100970088fca50412fea3; D[248]=0x006c0029008000720044fff100350043007effd1ffec00340059fedd00ff0054; D[249]=0x01b800100276000500c7018a00b9017c00cb00ac010a00a200730093005f004e; D[250]=0x00b3f944042effeeff7c027bfd9a00a4033305d906c3037600a20759fdb206f5; D[251]=0x0074fe0e00d10066ffd000d0ff9d001e0053fe4d0104007effc40246fe69ffea; D[252]=0x0067008900830075004b0031008800710025ffd80026fffafff9ffeeffd1ffd5; D[253]=0x0293032c047a05ca03defdb004400604012201f200c2004600c000ca00d30108; D[254]=0xfff800c0ffc4ffb6ffcdfeb30061008dff9403d4fe4afef70027fe000129ffcf; D[255]=0xffc20019fff1ffebffcbffe1ff69001bffb30126ffcdffd00010ff3d00280018; D[256]=0x006601410037ff620091007e00a801200032005a00690030fff6ffd6ffa1ffbf; D[257]=0xfffffe7700de0047ffee006fffadfff10239091f0852022f029200e9042006f5; D[258]=0x0021ff570032000bfffb0053ffcdfff9fffcff9f003f0010001a009fff93ffd2; D[259]=0xffd5fff0ff9effc8ffb9ff620020001000370052003400030002ffdd001ffff7; D[260]=0x028fff2b04ce013702fbff8c020b057800bc00cd00a7fff50032004e004c0031; D[261]=0xfff70029ffcafff5fffdffc800520013fff3007fff61ffe00003ffdd00180003; D[262]=0xff9aff54ff84ffea001800250016000affd10046ffbbfff2000affdf00260006; D[263]=0xff8e0072ff19ff15ffddffd5fff9001cffd7ffcc002fffea005d00a00007000c; D[264]=0x0006ffc800190006fffd000dfff6ffff01dd08fd0ee501fe0348011f052a0632; D[265]=0x0024ffb6fff4fffcfff20022fff700010007ffd9000a0000fff9002bffeffffc; D[266]=0xffaafe73fee2ffc9ff81fff50084001800530031ff8effeaffd9fffd002c0005; D[267]=0x01a1ff0a02df0051005702f801eb0279ff19fd39ff0ffedd00cb011500b8005c; D[268]=0xfffa000dfff7ffff0004ffef000f0005fffc0019ffeffff90001fff700070001; D[269]=0xffb4fe81005a000a000300a7ffb9fffeffe3ffff000200010007fff9000c0000; D[270]=0x00ff03f90024fedafef0ff9bfe5dffeaff43ff1b01c8001c007301a8ff3fffef; D[271]=0x0002ffed0019000affff0007fff7fffdfe150460ffbcfed7ffbcfb37fdb3ff3f; D[272]=0x00080039003f0005fffefff2ffc3fffc0002fffe00180004ffff0004ffdffff7; D[273]=0xffd0047fff2e0020ffe8fc28fdcfffdfffec02ce00db000c0019fe91ff7fffee; D[274]=0x00d6faf0012d00030156056ffec90128fd7dfd4d0c1203d5017dfdebfafafee4; D[275]=0x0000fff9ffeafffc000000050017000800000004fff0fff80000fffd00050002; D[276]=0x0025fda3fe65ffdeffe30113009600140001ffb6ffaefff6ffff0013002c0005; D[277]=0x01eafff3ec85fadcfecd02a506b6012c005ffb78fdedffb9ffdb030c0265002b; D[278]=0x0000ffff0005000200000001fffeffffffb9019affc50025fea3fd6e0175fe7a; D[279]=0xfffd001b001100010001fff3ffeffffeffff0004000600010001fffcfff9fffd; D[280]=0xffbf0187001c000e001bfe71ff3cfff1ffe600ca00470006000aff71ffd2fffa; D[281]=0xfff5ffc20001fff3006a007fffe3004eff2d00ac031700ad0056feeefdb4ffa7; D[282]=0x180b17571da2181b18211669159b182016911a8818541808176717b8180b1828; D[283]=0x17e1185a15eb180b17b518161fe3183a17681b230e2a180a19d9120a16bc1842; D[284]=0x112b0fd90c0111cf0fea176c13f8119e12160c3012b711b210d813d810d911c9; D[285]=0x114513c814691238125c0d1c0722118f121a10f822cd121f0bcb23f50f0b1161; D[286]=0x0b6409120cca0a2109ba0b24093c0a3b08b80c3307990a60094409630b3e0a1d; D[287]=0x09e00a4d08b309bf0a9b0a730fb70a44086c0f9cfc1209f80e6601120d050aab; D[288]=0x029d03e901f502b202f6016b02a8026702a001e8046e02950314034401a40292; D[289]=0x03b5029302d102d602280547014e031f0474ff8208e502bd027e05d80138025d; D[290]=0x01d301a801ea00f501ae011e014d01f7039602b8ff93fc77012400d002480357; D[291]=0x016c051f039b058904a9fae8064cfc82010b06d3fde7092a02a100a804630289; D[292]=0x00c70196ff6904220210ff50019afba3febe05ff07b806a60212ff34fd4bfea0; D[293]=0x0261fe10033c0025ffec0b95fb03047a0275004204eeff440134021400cf0111; D[294]=0x00ceff230120fe7f002b018dfebd02b800c0f659fe67fe0700c102d200ea01b7; D[295]=0x00be04a4013e01f201e3f9c1028effcf010102a50073031900d9001f01a50078; D[296]=0xffd9ff8300110013ffd2fffbff9a0028004cff920340003bff7bff29fedcff89; D[297]=0x0068fe9e017fff9500040371fbfa00ee00af00fe01eeffb3ff9f0015fecbfffe; D[298]=0x004c0022ffbefffaffd4003c009bffea0036fde1fd87000fffe000470068fffa; D[299]=0xff99fdd4ff3f001b004d06060165ff6ffe92f7f0003f001affeb00ac007cfffc; D[300]=0xfdd7fed2012c0008015600c3fdcb0019ff0d00a80437fff60018ffe8fed0ffff; D[301]=0xff9e049500beffaa0192e88ffe550104fedb160a009fffc7005ffcf0fdf10006; D[302]=0x0194057afd1bfff6ff42fc2a039bffeb006101b0fb5f0009fff7ffa800f90002; D[303]=0x003dfb8fff24003bfee610d4046fff1600cfee1cfb4b002fff2901c70382fffb; D[304]=0xff24f9c902090002003a03e2fe230000fff2fde40180fff6fff10058ff6bffff; D[305]=0xffd3005e0074ffec006cfc70fc6c0020ff88017a0463fff6fffc00f8fc56ffff; } } function knots(uint256 tag,bool col) internal pure returns(uint256[32] memory t,uint256 n){ unchecked { if(tag==0){ if(col){ n=10; t[4]=11; t[5]=27; t[6]=184; t[7]=584; t[8]=736; t[9]=752; t[10]=768; t[11]=768; t[12]=768; t[13]=768; }else{ n=24; t[4]=4561; t[5]=7687; t[6]=8737; t[7]=9140; t[8]=9354; t[9]=9479; t[10]=9553; t[11]=9625; t[12]=9744; t[13]=9982; t[14]=10498; t[15]=10736; t[16]=10855; t[17]=10927; t[18]=11001; t[19]=11126; t[20]=11340; t[21]=11743; t[22]=12793; t[23]=15919; t[24]=20480; t[25]=20480; t[26]=20480; t[27]=20480; } } else if(tag==1){ if(col){ n=14; t[4]=752; t[5]=1111; t[6]=1290; t[7]=1395; t[8]=1488; t[9]=1584; t[10]=1677; t[11]=1782; t[12]=1961; t[13]=2320; t[14]=3072; t[15]=3072; t[16]=3072; t[17]=3072; }else{ n=24; t[4]=4805; t[5]=8408; t[6]=9204; t[7]=9439; t[8]=9591; t[9]=9721; t[10]=9847; t[11]=9967; t[12]=10080; t[13]=10188; t[14]=10292; t[15]=10400; t[16]=10513; t[17]=10633; t[18]=10759; t[19]=10889; t[20]=11041; t[21]=11276; t[22]=12072; t[23]=15675; t[24]=20480; t[25]=20480; t[26]=20480; t[27]=20480; } } else if(tag==2){ if(col){ n=12; t[4]=1151; t[5]=1216; t[6]=1348; t[7]=1467; t[8]=1605; t[9]=1724; t[10]=1856; t[11]=1921; t[12]=3072; t[13]=3072; t[14]=3072; t[15]=3072; }else{ n=18; t[4]=6179; t[5]=8805; t[6]=9484; t[7]=9683; t[8]=9842; t[9]=9993; t[10]=10155; t[11]=10325; t[12]=10487; t[13]=10638; t[14]=10797; t[15]=10996; t[16]=11675; t[17]=14301; t[18]=20480; t[19]=20480; t[20]=20480; t[21]=20480; } } else if(tag==3){ if(col){ n=14; t[4]=699; t[5]=1053; t[6]=1248; t[7]=1379; t[8]=1485; t[9]=1587; t[10]=1693; t[11]=1824; t[12]=2019; t[13]=2373; t[14]=3072; t[15]=3072; t[16]=3072; t[17]=3072; }else{ n=24; t[4]=4791; t[5]=8268; t[6]=9109; t[7]=9396; t[8]=9575; t[9]=9719; t[10]=9847; t[11]=9965; t[12]=10078; t[13]=10186; t[14]=10294; t[15]=10402; t[16]=10515; t[17]=10633; t[18]=10761; t[19]=10905; t[20]=11084; t[21]=11371; t[22]=12212; t[23]=15689; t[24]=20480; t[25]=20480; t[26]=20480; t[27]=20480; } } else if(tag==4){ if(col){ n=8; t[4]=1167; t[5]=1403; t[6]=1669; t[7]=1905; t[8]=3072; t[9]=3072; t[10]=3072; t[11]=3072; }else{ n=12; t[4]=7858; t[5]=9272; t[6]=9726; t[7]=10044; t[8]=10436; t[9]=10754; t[10]=11208; t[11]=12622; t[12]=20480; t[13]=20480; t[14]=20480; t[15]=20480; } } } } struct Basis {uint256 start;uint256 w;} struct Pair {uint256 start;uint256 n;uint256 a;uint256 b;} function basis(uint256[32] memory t,uint256 n,uint256 x) internal pure returns(Basis memory B){ unchecked { x*=64;uint256 span=3;uint256 high=n; while(high-span>1){uint256 mid=(span+high)/2;if(t[mid]<=x)span=mid;else high=mid;} B.start=span-3; uint256 l1=x-t[span];uint256 l2=x-t[span-1];uint256 l3=x-t[span-2]; uint256 r1=t[span+1]-x;uint256 r2=t[span+2]-x;uint256 r3=t[span+3]-x; uint256 b=Q*l1/(r1+l1);uint256 a=Q-b; uint256 c=a*l2/(r1+l2);uint256 d=b*l1/(r2+l1); uint256 n0=a-c;uint256 n1=c+b-d;uint256 n2=d; c=n0*l3/(r1+l3);d=n1*l2/(r2+l2);uint256 e=n2*l1/(r3+l1); B.w=(n0-c)|((c+n1-d)<<24)|((d+n2-e)<<48)|(e<<72); } } function pair(uint256[32] memory t,uint256 n,uint256 x) internal pure returns(Pair memory p){ unchecked { Basis memory a=basis(t,n,x);Basis memory b=basis(t,n,x+1); p.start=a.start;p.n=b.start-a.start+4; p.a=a.w;p.b=b.w<<(24*(b.start-a.start)); } } function expanded(uint256 z) internal pure returns(uint256){unchecked{ z^=0x8000800080008000; z=(z|(z<<96))&0x000000000000000000000000ffffffff000000000000000000000000ffffffff; return (z|(z<<48))&0x000000000000ffff000000000000ffff000000000000ffff000000000000ffff; }} function sdnode(uint256 z,uint256 k) internal pure returns(int256){unchecked{ uint256 h=7-k;uint256 a=h*h*h;uint256 b=3*h*h*k;uint256 c=3*h*k*k;uint256 d=k*k*k; uint256 mask=type(uint64).max; int256 v=int256((z&mask)*a+((z>>64)&mask)*b+((z>>128)&mask)*c+(z>>192)*d); v-=int256(32768*(uint256(1)<<46)*343); return v>0?v*U/int256(8*(uint256(1)<<46)*343):int256(0); }} struct Context {uint256[306] D;uint256[32] tr;uint256[32] tc;uint256 nr;uint256 nc;uint256 off;uint256 k;int256 tt;} function surface(Context memory c,int256 row,int256 col) internal pure returns(int256){ unchecked { uint256 i=uint256(row/U);uint256 j=uint256(col/U); if(i>318)i=319;uint256 last=c.off==0?12:48;if(j>=last)j=last-1; int256 f=row-int256(i)*U;int256 g=col-int256(j)*U; Pair memory r=pair(c.tr,c.nr,i);Pair memory s=pair(c.tc,c.nc,j); uint256 z00;uint256 z01;uint256 z10;uint256 z11; for(uint256 a=0;a>(64*(q%4)))); v0+=z*((s.a>>(b*24))&0xffffff);v1+=z*((s.b>>(b*24))&0xffffff); } uint256 ra=(r.a>>(a*24))&0xffffff;uint256 rb=(r.b>>(a*24))&0xffffff; z00+=v0*ra;z01+=v1*ra;z10+=v0*rb;z11+=v1*rb; } int256 A=mul(sdnode(z00,c.k),U-f)+mul(sdnode(z10,c.k),f); int256 B=mul(sdnode(z01,c.k),U-f)+mul(sdnode(z11,c.k),f); int256 lo=mul(A,U-g)+mul(B,g); A=mul(sdnode(z00,c.k+1),U-f)+mul(sdnode(z10,c.k+1),f); B=mul(sdnode(z01,c.k+1),U-f)+mul(sdnode(z11,c.k+1),f); int256 hi=mul(A,U-g)+mul(B,g); return mul(lo,U-c.tt)+mul(hi,c.tt)+(row-160*U)*5; } } function rival(uint256 j) internal pure returns(int256){unchecked{ bool neg=j<24;if(neg)j=48-j; int256 v=j<=36?int256(j-24):j==37?int256(14):j==38?int256(17):j==39?int256(20):j==40?int256(25):j==41?int256(30):j==42?int256(40):j==43?int256(50):j==44?int256(60):j==45?int256(80):j==46?int256(100):j==47?int256(130):int256(160); return (neg?-v:v)*U; }} function fees(int256 w,int256 R,uint256 ph,bool synced,int256 sd) internal pure returns(int256,int256){unchecked{ uint256 tag=ph==0?0:ph==1?(synced?1:2):(synced?3:4); Context memory c;c.D=payload();(c.tr,c.nr)=knots(tag,false);(c.tc,c.nc)=knots(tag,true); c.off=tag==0?0:tag==1?240:tag==2?576:tag==3?792:1128; int256 low;int256 high; if(sd<20*U){c.k=uint256(sd/(4*U));if(c.k>4)c.k=4;low=int256(c.k)*4*U;high=low+4*U;} else if(sd<26*U){c.k=5;low=20*U;high=26*U;} else{c.k=6;low=26*U;high=34*U;} c.tt=clip(divi(sd-low,high-low),0,U); int256 row=clip(w/5+160*U,0,320*U);int256 col; if(ph==0){col=clip(R/5+6*U,0,12*U);}else{ int256 v=R/5; if(v<=-160*U)col=0;else if(v>=160*U)col=48*U;else{ uint256 l;uint256 h=48; while(h-l>1){uint256 m=(l+h)/2;if(rival(m)<=v)l=m;else h=m;} col=int256(l)*U+divi(v-rival(l),rival(h)-rival(l)); } } int256 a=surface(c,row,col);int256 b=surface(c,320*U-row,(ph==0?int256(12):int256(48))*U-col); return fee(a,w,b); }} function save(Belief memory b) internal { unchecked { slots[0]=uint256(b.m);slots[1]=uint256(b.v);slots[2]=uint256(b.fb);slots[3]=uint256(b.fa); slots[4]=uint256(b.sp);slots[5]=uint256(b.r);slots[6]=b.t;slots[7]=b.cnt; } } function afterInitialize(uint256 x,uint256 y) external override returns(uint256,uint256){ unchecked { Belief memory b; b.sp=int256(y*1e18/x);b.r=b.sp;b.m=ln(b.sp); b.fb=2823606104386590;b.fa=2823606104386590;save(b);return(uint256(b.fb),uint256(b.fa)); } } function update(Belief memory b,int256 s,bool buy,uint256 dt) internal pure returns(bool arb){ unchecked { int256 lo;int256 hi;int256 m;int256 v;int256 lp;int256 la;int256 Z;int256 mt;int256 vt;int256 d;int256 pi; lo=ln(mul(b.sp,U-b.fb));hi=ln(divi(b.sp,U-b.fa));m=b.m;v=b.v; uint256 n=dt-1;if(n>12)n=12; for(uint256 i=0;i0?divi(la,la+lr):int256(0);arb=pi>U/2; if(pi>5e15&&pi<995e15){ b.m=mul(pi,lp)+mul(U-pi,mt); b.v=mul(pi,mul(lp-b.m,lp-b.m))+mul(U-pi,vt+mul(mt-b.m,mt-b.m)); }else if(arb){b.m=lp;b.v=0;}else{b.m=mt;b.v=vt;} int256 pe=exp(b.m);b.r=clip(b.r,mul(pe,997e15),divi(pe,997e15));b.cnt=0; } } function afterSwap(TradeInfo calldata t) external override returns(uint256,uint256){ unchecked { Belief memory b=Belief(int256(slots[0]),int256(slots[1]),int256(slots[2]),int256(slots[3]),int256(slots[4]),int256(slots[5]),slots[6],slots[7]); int256 s=int256(t.reserveY*1e18/t.reserveX);bool arb; if(t.timestamp>b.t)arb=update(b,s,t.isBuy,t.timestamp-b.t); uint256 ph; if(!arb){ int256 c=t.isBuy?divi(mul(s,U-b.fb),997e15):divi(mul(s,997e15),U-b.fa); if(t.isBuy?cb.r){b.r=c;b.cnt|=256;} uint256 count=b.cnt&255;count=count==0?1:2;b.cnt=count+(b.cnt&256);ph=count; } int256 w=(ln(s)-b.m)*10000;int256 r=(ln(b.r)-b.m)*10000; (b.fb,b.fa)=fees(w,r,ph,(b.cnt&256)!=0,root(b.v)*10000);b.sp=s;b.t=t.timestamp;save(b); return(uint256(b.fb),uint256(b.fa)); } } } ``` ## Reproduction sources Place these in the pinned challenge's scratch/ directory; place the pinned replica checkout beside that challenge checkout, as used here. First extract Strategy.sol above to scratch/Strategy.sol. Run the linked port-3 setup once (it installs the measurement environment, which is not bundled), then prefix later toolchain commands with `. scratch/env.sh &&`. Regenerate expanded tables with `python -I scratch/build_reference.py scratch/Strategy.sol scratch/qm_spline.json`. The script reconstructs the byte-identical JSON from this contract; no separate blob download is needed. The standalone replica and gates require only plain `python3 -I` as upstream specifies; table regeneration uses setup's NumPy. ### scratch/build_reference.py ```python """Decode the coefficients and knots in shipped Strategy.sol to Taylor's qm JSON. Requires numpy. Usage: python3 -I build_reference.py Strategy.sol qm_spline.json Then run unchanged pinned real.py with soft=1,qm=. """ import sys,re,json from pathlib import Path import numpy as np def basis(knots,x): t=np.asarray(knots,float);x=np.asarray(x,float);n=len(t)-4 B=np.zeros((len(x),len(t)-1)) for m in range(len(t)-1): if t[m]=t[m]) & (x=t[-1],:]=0.;B[x>=t[-1],last]=1. for d in range(1,4): Bn=np.zeros((len(x),len(t)-1-d)) for m in range(len(t)-1-d): a=t[m+d]-t[m];b=t[m+d+1]-t[m+1] if a>0:Bn[:,m]+=(x-t[m])/a*B[:,m] if b>0:Bn[:,m]+=(t[m+d+1]-x)/b*B[:,m+1] B=Bn return B[:,:n] def decode(src): words=[int(x,16) for x in re.findall(r'D\[\d+\]=0x([0-9a-f]{64});',src)];assert len(words)==306 vals=[(word>>(64*j))&((1<<64)-1) for word in words for j in range(4)] w2=[160,130,100,80,60,50,40,30,25,20,17,14]+list(range(12,0,-1)) w2=[-x for x in w2]+[0]+list(reversed(w2)) Q={'S':[float(x) for x in [0,4,8,12,16,20,26,34]],'W0':160,'NW':321,'N2':49,'FB':6,'H_bps':5.,'W2L':[float(x) for x in w2]} text=src.split('function knots(')[1].split('struct Basis')[0];off=0 for tag,name,nr,nc in zip(range(5),['0c','1s','1c','2s','2c'],[24,24,18,24,12],[10,14,12,14,8]): body=text.split(f'(tag=={tag})'+'{')[1].split('else if')[0] cbody,rbody=body.split('if(col){')[1].split('}else{') def knots(body,n): t=[0.]*(n+4) for i,v in re.findall(r't\[(\d+)\]=(\d+);',body):t[int(i)]=int(v)/64. return t kr=knots(rbody,nr);kc=knots(cbody,nc) C=np.empty((4,nr,nc)) for i in range(nr): for j in range(nc): z=vals[off+i*nc+j] for k in range(4): v=(z>>(16*k))&65535;C[k,i,j]=(v-65536 if v>=32768 else v)/8. off+=nr*nc Br=basis(kr,np.arange(321));Bc=basis(kc,np.arange(13 if tag==0 else 49));Bs=basis([0.]*4+[7.]*4,np.arange(8)) F=np.maximum(np.einsum('ks,src,ir,jc->kij',Bs,C,Br,Bc),0.) A=F+((np.arange(321)-160)*5.)[None,:,None];B=A[:,::-1,::-1] Q['A'+name]=np.round(A,6).tolist();Q['B'+name]=np.round(B,6).tolist() assert off==1224 return Q if __name__=='__main__':json.dump(decode(Path(sys.argv[1]).read_text()),open(sys.argv[2],'w')) ``` ### scratch/qmref.py ```python """Taylor's RealPolicy unchanged, over qm-spline's decoded tables.""" import sys from pathlib import Path HERE=Path(__file__).resolve().parent SOLVED=HERE.parent.parent/'replica/research/solved' sys.path.insert(0,str(SOLVED)) from real import RealPolicy from evalpol import load import replica2 as R def policy(full=False): return RealPolicy(load(str(SOLVED/'pol_mid.json')),{'soft':1,'qm':str(SOLVED/'qm_k1e-5.json') if full else str(HERE/'qm_spline.json')}) ``` ### scratch/replay.py ```python import sys,json,time,hashlib from pathlib import Path from check import compiled,call,HERE from amm_competition.evm.executor import EVMStrategyExecutor from qmref import policy,R class Stop(Exception): pass def trace(seed): p=HERE/f'trace{seed}.json' if p.exists():return json.loads(p.read_text()) pol=policy();init=pol.init();rec=[];orig=pol.on_trade def record(*args): f=orig(*args);rec.append([args,f]) if len(rec)==2000:raise Stop() return f pol.on_trade=record try:R.run(seed,pol) except Stop:pass assert len(rec)==2000 d={'init':init,'rec':rec};p.write_text(json.dumps(d,separators=(',',':')));return d def replay(seed,c): d=trace(seed);e=EVMStrategyExecutor(bytes.fromhex(c['creation']));ini=call(e,[100*10**18,10000*10**18],True) imax=max(abs(a-b)*1e4 for a,b in zip(ini,d['init']));diff=[];gas=[] for ix,(args,f) in enumerate(d['rec']): buy,ax,ay,t,x,y,*_=args try:fees=call(e,[buy,int(ax*1e18),int(ay*1e18),t,int(x*1e18),int(y*1e18)]) except Exception as err: return {'seed':seed,'failed_i':ix,'error':str(err),'n':len(gas),'peak':max(gas,default=0),'max_diff':max(diff,default=0),'sum_diff':sum(diff),'sum_gas':sum(gas)} gas.append(e.evm.result.gas_used);diff.extend(abs(a-min(.1,max(0,b)))*1e4 for a,b in zip(fees,f)) return {'seed':seed,'max_diff':max(diff),'sum_diff':sum(diff),'init_max':imax,'peak':max(gas),'peak_i':gas.index(max(gas)),'sum_gas':sum(gas),'n':len(gas),'trace_sha256':hashlib.sha256(json.dumps(d,separators=(',',':')).encode()).hexdigest()} if __name__=='__main__': src=sys.argv[1];a,b=map(int,sys.argv[2:4]);c=compiled(src);out=[] for seed in range(a,b): row=replay(seed,c);out.append(row);print(row,flush=True) (HERE/(Path(src).stem+f'_F{a}_{b}.json')).write_text(json.dumps(out)) ``` Use trim-1's linked check.py unchanged. Measurement engine.py is trim-1's complete linked harness, changing only its allowed bounds from 9530000/9530128 to 9533000/9533128 and its port source from scratch/v4.sol to scratch/Strategy.sol. Four chunks start at 9533000, 9533032, 9533064, 9533096; each end is start+32; run each for port, t03 and IB once. Use timeout 470 per invocation. Q's per-seed body is `a=R.run(seed,policy(True))['edge']; b=R.run(seed,policy(False))['edge']`; loss=a-b; eight workers, two-seed chunks. It ran choose in 60000..60127 and 60128..61023 segments, then holdout in 10000..11023 and 11024..12047 segments, plain python3 -I. SE uses sample SD/sqrt(n). F command: `. scratch/env.sh && timeout 470 python scratch/replay.py scratch/Strategy.sol 70000 70050`. Future engine work must reserve new seeds rather than reuse this campaign. No global gas bound or performance on other seeds is claimed. All requested measurements completed; the only gate qualification is the explicitly documented raw-return versus effective-fee discrepancy. Nothing was fabricated.