diff --git a/tasks/construct-ae-p32-spherical-design-l5-s0/environment/Dockerfile b/tasks/construct-ae-p32-spherical-design-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p32-spherical-design-l5-s0/environment/instance.json b/tasks/construct-ae-p32-spherical-design-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc94adf3c348628f8a0bf42c69f9b809eef04869 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"t": 19, "N": 198, "family": "ae_p32_spherical_designs", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p32-spherical-design-l5-s0/solution/solve.sh b/tasks/construct-ae-p32-spherical-design-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4755ef36041d1a54475a1934abc8b6f47dcc45ba --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"points": [[0.2527759326534977, -0.9566791840084274, -0.14446199069694396], [-0.9071773294756267, 0.015962244615743904, 0.4204455965190948], [-0.616471714044581, -0.20797033654468083, -0.7594148832492214], [-0.6669229800600651, 0.5278085911769907, 0.5259580113921283], [-0.6636953921393339, 0.3035315017983519, 0.6836498035317884], [0.31817569095244375, -0.44817056008107137, -0.8354085101096073], [0.2326406142491498, -0.24753928264553166, 0.9405331722747018], [-0.3319418441602898, -0.9192339146644295, 0.21171589979539565], [-0.989901155923375, 0.1415575057627732, -0.007561353304026967], [-0.6940970558319106, 0.6760457881341818, -0.2473688934193353], [-0.08911173314110848, 0.9893781402186134, -0.11484770208474272], [0.2735331014272552, 0.7929939249348656, 0.5443714517128755], [0.32114904661040294, -0.6978190818804829, -0.6402435621110993], [0.21606086388133405, 0.07253477182773413, -0.9736818833555189], [0.8306685695380677, -0.4996653571337416, 0.2456099722364527], [-0.7035966501809142, 0.24681134255272794, -0.6663601991727268], [0.4543377579132473, 0.7882960418129363, -0.4149295749840217], [-0.5919086482263421, -0.7718702467816513, 0.23207859506662187], [-0.2249564240346492, 0.21451439366744082, 0.9504620887731574], [-0.8011025199330664, 0.5981993327173948, 0.019806839559972398], [0.09650672442045342, -0.7614513104034255, -0.6409979360548214], [-0.4266304636681133, -0.9044257167599649, -0.0007552043131550039], [0.5235350644098383, -0.8265605597363971, 0.20666077862439322], [-0.9261324157660965, -0.33800494493485767, 0.16742582138618242], [0.9465137815640404, -0.2113845759594981, -0.24377904412759377], [0.12400589991688678, 0.888531738466774, 0.44173961393904376], [-0.12939512081224766, -0.9899593659558957, 0.056897772066969186], [0.4100400904645589, -0.5310449354787828, 0.7415243763452094], [0.6121495060822961, 0.7885835096084429, 0.058386904155225586], [-0.7078016213647221, 0.6476889699819802, 0.281985572249986], [-0.1194170666444374, 0.8959375342669865, 0.4278264822163659], [0.6086077390900811, -0.0016517171884538452, -0.7934695279278147], [-0.308138028628882, -0.5828648450548394, -0.7518773355487612], [-0.9126931985878572, 0.10092396281459982, -0.3959867156626136], [-0.9075848215163033, 0.4135334997082516, 0.07266248256332415], [-0.7874335947163372, -0.2277029010667165, -0.5727998976587794], [0.35617243852259417, -0.7157128445966555, 0.6007464674188543], [0.49712463559744313, -0.3049878550572983, -0.8123112118822796], [0.6355129615942835, -0.7707274245027393, -0.04585316526737344], [-0.823582504518911, 0.26161188229867044, 0.5032604507514024], [-0.4201349780087122, 0.05916594126653794, 0.9055307789620757], [-0.2253379394752148, -0.8181432292461877, 0.5290221824004023], [-0.9830920749470742, -0.18146865560772074, -0.024476503185355214], [-0.8033875419800142, -0.47840137728962945, 0.3545427754146127], [0.5398038974785598, 0.2398736117536441, -0.8068905766280943], [0.18478396225343577, 0.07036047252750102, 0.9802572576623075], [0.404307861510866, 0.11963473301407422, 0.9067649550887824], [0.6778781841518116, -0.4876071985105816, 0.5502003157139269], [-0.8358098645616144, 0.43872985822206406, 0.330057543173828], [-0.14984441916540825, -0.6995632380288731, 0.6986829939561573], [0.0963038700715653, 0.6802852343346977, 0.726593121736935], [-0.33744432759092335, -0.2667688050118576, 0.9027545239151422], [-0.3038737867589575, 0.9408790043663904, -0.14969108478223306], [0.07727695919431263, 0.43760558542338684, 0.8958401772548134], [0.5002309144546911, 0.4114399071385071, 0.7618964726507665], [0.21299187911141404, 0.9597274541901863, 0.18318753534619306], [-0.033254368176864536, 0.981169112540872, 0.190266443685993], [-0.5550674692406724, -0.7413685764233726, -0.3771905864185068], [0.44738173345883014, 0.6394806495135349, -0.6252312240004652], [-0.5132747276097992, 0.35942130959293683, -0.7793364974178899], [-0.908273120300105, -0.36781789712904284, -0.1993738535813558], [-0.9768756076125094, -0.025557939745362766, -0.21227538474270402], [0.41914159368881443, -0.1457417138413139, 0.896147129263157], [0.9819720031081934, 0.051074934296201316, -0.1819954290588663], [-0.6456468813502989, -0.40889643816847426, 0.6449370569720492], [-0.730168261847292, -0.6539132126792329, -0.19812071995232802], [0.9002405973380224, 0.2173386052333339, 0.37726754111599575], [-0.658609660927967, -0.5896536350330548, 0.4674846577425333], [-0.2856532096842435, -0.338834354695996, -0.8964337810875032], [0.45615708893873547, -0.885109791409485, -0.09220285983632291], [0.7541965839668618, 0.6406478050061248, -0.14407603087797236], [0.8073817596027736, -0.02094710596910639, 0.5896574539614063], [0.1221387974181635, 0.9305767959068604, -0.3451216323051431], [0.11181964695244331, -0.9155430576224537, 0.386364175609954], [-0.8860359794901508, -0.23651242737783115, 0.3987506924693364], [-0.021795294178684615, 0.2209727617537001, 0.9750364114814416], [0.14306901425289, 0.5109208299293874, -0.8476385802362776], [-0.020096912554200586, 0.08803980061814769, -0.9959142069540456], [0.4026370219134751, 0.8707978285727904, 0.28212509696508903], [0.4959527301737703, -0.5845756082399554, -0.6421076605087885], [0.1788190994230974, -0.45893101861561447, 0.8702907846426658], [-0.36556095187326415, 0.8407639172119178, -0.39935100598343864], [-0.11794637205580971, 0.643753088529289, -0.7560890253983812], [0.8624215507412237, 0.5060954097355691, 0.009823698982011181], [0.9398678224326774, -0.293004688620821, 0.1754899678097663], [-0.3526844893273538, 0.8468217430548174, 0.3981288566249682], [0.6754400632233013, 0.4675915503976405, 0.5702094904415689], [0.08877249205595145, -0.8062034468725888, 0.5849405498894165], [0.5310150431668822, -0.763080439370121, -0.3684172457705761], [-0.3919840334282161, -0.4962128757093599, 0.7746749637864867], [0.7726359079275378, 0.5087840035682575, 0.379700660381365], [-0.6194288470162496, 0.03579306714779061, -0.7842364183256688], [0.05985044578163838, 0.33165256956803507, -0.9415011934345378], [-0.12824565900342727, 0.5369778154222951, 0.8337912668594438], [-0.5807511705169693, 0.6554449759612124, -0.482824980122586], [-0.49272174249670225, -0.6488509094724098, -0.5798428940220274], [0.8340826825905289, -0.3325409293775602, 0.44013930623303293], [-0.7684859294902381, 0.032294968844228396, 0.6390511803939299], [0.7643670735167464, 0.22568566431123574, -0.603994170375709], [-0.2527759326534968, 0.9566791840084277, 0.14446199069694388], [0.9071773294756266, -0.01596224461574326, -0.4204455965190951], [0.6164717140445807, 0.20797033654468125, 0.7594148832492216], [0.6669229800600647, -0.5278085911769923, -0.5259580113921275], [0.6636953921393342, -0.3035315017983534, -0.6836498035317875], [-0.3181756909524427, 0.448170560081072, 0.8354085101096074], [-0.23264061424914967, 0.24753928264553246, -0.9405331722747016], [0.3319418441602907, 0.919233914664429, -0.21171589979539662], [0.989901155923375, -0.14155750576277343, 0.007561353304025757], [0.694097055831911, -0.676045788134181, 0.2473688934193365], [0.08911173314110969, -0.9893781402186133, 0.1148477020847424], [-0.27353310142725545, -0.7929939249348655, -0.5443714517128756], [-0.3211490466104028, 0.6978190818804832, 0.6402435621110991], [-0.21606086388133558, -0.07253477182773363, 0.9736818833555185], [-0.8306685695380671, 0.4996653571337424, -0.2456099722364526], [0.7035966501809146, -0.24681134255272658, 0.6663601991727272], [-0.45433775791324676, -0.7882960418129371, 0.414929574984021], [0.5919086482263427, 0.7718702467816507, -0.2320785950666222], [0.22495642403464883, -0.21451439366744066, -0.9504620887731575], [0.8011025199330667, -0.5981993327173944, -0.019806839559971607], [-0.09650672442045395, 0.7614513104034264, 0.6409979360548201], [0.4266304636681138, 0.9044257167599646, 0.0007552043131546822], [-0.5235350644098381, 0.8265605597363976, -0.20666077862439178], [0.9261324157660966, 0.3380049449348574, -0.16742582138618228], [-0.9465137815640406, 0.21138457595949808, 0.2437790441275926], [-0.12400589991688762, -0.8885317384667737, -0.44173961393904404], [0.1293951208122493, 0.9899593659558954, -0.05689777206696995], [-0.41004009046456014, 0.5310449354787834, -0.7415243763452083], [-0.6121495060822965, -0.7885835096084427, -0.058386904155225246], [0.7078016213647216, -0.6476889699819816, -0.28198557224998455], [0.1194170666444368, -0.8959375342669857, -0.4278264822163674], [-0.608607739090081, 0.0016517171884530132, 0.7934695279278148], [0.30813802862888084, 0.5828648450548393, 0.7518773355487617], [0.9126931985878572, -0.10092396281459975, 0.39598671566261373], [0.9075848215163032, -0.4135334997082516, -0.07266248256332514], [0.7874335947163371, 0.2277029010667176, 0.5727998976587794], [-0.35617243852259384, 0.7157128445966562, -0.6007464674188535], [-0.49712463559744247, 0.30498785505729914, 0.8123112118822797], [-0.635512961594283, 0.7707274245027396, 0.045853165267375116], [0.8235825045189108, -0.2616118822986709, -0.5032604507514022], [0.42013497800871114, -0.059165941266537896, -0.9055307789620761], [0.22533793947521502, 0.8181432292461873, -0.5290221824004026], [0.9830920749470742, 0.18146865560772032, 0.024476503185355113], [0.803387541980014, 0.4784013772896299, -0.3545427754146124], [-0.5398038974785595, -0.23987361175364486, 0.8068905766280943], [-0.18478396225343693, -0.07036047252750098, -0.9802572576623073], [-0.40430786151086634, -0.1196347330140753, -0.9067649550887821], [-0.6778781841518111, 0.4876071985105826, -0.5502003157139266], [0.8358098645616138, -0.4387298582220654, -0.3300575431738279], [0.14984441916540825, 0.6995632380288727, -0.6986829939561577], [-0.09630387007156574, -0.6802852343346971, -0.7265931217369357], [0.33744432759092347, 0.2667688050118574, -0.9027545239151422], [0.30387378675895843, -0.94087900436639, 0.1496910847822334], [-0.07727695919431204, -0.43760558542338723, -0.8958401772548132], [-0.5002309144546915, -0.41143990713850703, -0.7618964726507663], [-0.21299187911141224, -0.9597274541901867, -0.18318753534619295], [0.03325436817686638, -0.9811691125408718, -0.19026644368599416], [0.5550674692406736, 0.7413685764233714, 0.3771905864185075], [-0.4473817334588305, -0.6394806495135353, 0.6252312240004645], [0.5132747276097999, -0.3594213095929372, 0.7793364974178892], [0.9082731203001051, 0.3678178971290424, 0.1993738535813559], [0.9768756076125096, 0.02555793974536197, 0.21227538474270327], [-0.41914159368881376, 0.145741713841313, -0.8961471292631574], [-0.9819720031081937, -0.051074934296201184, 0.18199542905886554], [0.6456468813502991, 0.40889643816847365, -0.6449370569720493], [0.7301682618472926, 0.6539132126792325, 0.19812071995232772], [-0.9002405973380221, -0.2173386052333345, -0.37726754111599625], [0.6586096609279669, 0.589653635033054, -0.46748465774253417], [0.28565320968424435, 0.3388343546959951, 0.8964337810875033], [-0.4561570889387348, 0.8851097914094853, 0.0922028598363237], [-0.754196583966862, -0.6406478050061246, 0.1440760308779729], [-0.8073817596027738, 0.020947105969107437, -0.589657453961406], [-0.12213879741816341, -0.9305767959068605, 0.34512163230514276], [-0.11181964695244383, 0.9155430576224537, -0.3863641756099539], [0.8860359794901503, 0.2365124273778322, -0.39875069246933675], [0.021795294178683994, -0.22097276175369854, -0.9750364114814419], [-0.14306901425288976, -0.510920829929387, 0.8476385802362778], [0.020096912554199767, -0.08803980061814638, 0.9959142069540458], [-0.40263702191347434, -0.8707978285727911, -0.2821250969650881], [-0.49595273017377034, 0.5845756082399551, 0.6421076605087888], [-0.1788190994230981, 0.45893101861561525, -0.8702907846426652], [0.36556095187326376, -0.8407639172119177, 0.39935100598343914], [0.11794637205580955, -0.6437530885292885, 0.7560890253983816], [-0.8624215507412235, -0.5060954097355697, -0.00982369898201106], [-0.9398678224326774, 0.29300468862082085, -0.17548996780976683], [0.35268448932735325, -0.8468217430548174, -0.3981288566249687], [-0.6754400632233021, -0.46759155039763967, -0.5702094904415687], [-0.08877249205595086, 0.8062034468725892, -0.5849405498894161], [-0.5310150431668829, 0.7630804393701205, 0.3684172457705766], [0.3919840334282165, 0.4962128757093591, -0.774674963786487], [-0.7726359079275372, -0.508784003568258, -0.3797006603813651], [0.6194288470162492, -0.035793067147790125, 0.7842364183256691], [-0.059850445781638735, -0.3316525695680343, 0.941501193434538], [0.1282456590034283, -0.5369778154222943, -0.8337912668594442], [0.5807511705169689, -0.655444975961212, 0.4828249801225871], [0.492721742496701, 0.64885090947241, 0.5798428940220283], [-0.8340826825905289, 0.3325409293775607, -0.44013930623303266], [0.7684859294902381, -0.03229496884422952, -0.6390511803939298], [-0.7643670735167466, -0.2256856643112364, 0.6039941703757086]]} +RLMATH_EOF diff --git a/tasks/construct-ae-p32-spherical-design-l5-s0/tests/check.py b/tasks/construct-ae-p32-spherical-design-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..5973c15b3df2d6228d713d9b186ced8e47dcbb48 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l5-s0/tests/check.py @@ -0,0 +1,53 @@ +"""Spherical t-design with N points on S^2 (numerical, tolerance 1e-10 on every harmonic average). + +Upstream (AlphaEvolve `spherical_t_designs.ipynb`) scored sum_k dim_k/C_k(1) * sum_{i,j} C_k(), whose +pair sums cancel to ~1e-10 in float64 and can even go negative; its printed acceptance test +`calculate_design_score(...) < 1e-8` compares the NEGATED error and is therefore always true (bug). Here we +evaluate the point averages of an orthonormal real spherical-harmonic basis directly (no cancellation). +""" +import numpy as np + +from run import Invalid, float_matrix + +TOL = 1e-10 + + +def harmonics(X, t): + """Rows: real spherical harmonics Y_lm (1 <= l <= t) normalised so that their mean square on S^2 is 1.""" + ct = np.clip(X[:, 2], -1.0, 1.0) + st = np.sqrt(np.maximum(0.0, 1.0 - ct * ct)) + ph = np.arctan2(X[:, 1], X[:, 0]) + P = {(0, 0): np.ones_like(ct)} + for m in range(1, t + 1): + P[(m, m)] = (np.sqrt(3.0) if m == 1 else np.sqrt((2 * m + 1) / (2 * m))) * st * P[(m - 1, m - 1)] + for m in range(0, t): + P[(m + 1, m)] = np.sqrt(2 * m + 3) * ct * P[(m, m)] + for m in range(0, t + 1): + for l in range(m + 2, t + 1): + a = np.sqrt((4 * l * l - 1) / (l * l - m * m)) + b = np.sqrt(((l - 1) ** 2 - m * m) / (4 * (l - 1) ** 2 - 1)) + P[(l, m)] = a * (ct * P[(l - 1, m)] - b * P[(l - 2, m)]) + rows = [] + for l in range(1, t + 1): + rows.append(P[(l, 0)]) + for m in range(1, l + 1): + rows.append(P[(l, m)] * np.cos(m * ph)) + rows.append(P[(l, m)] * np.sin(m * ph)) + return np.array(rows) + + +def check(inst, ans): + t, n = inst["t"], inst["N"] + X = np.array(float_matrix(ans.get("points"), n, 3, "points")) + nr = np.linalg.norm(X, axis=1) + if nr.min() < 0.5 or nr.max() > 2.0: + raise Invalid("points must be (approximately) unit vectors") + X = X / nr[:, None] + G = X @ X.T + np.fill_diagonal(G, -1.0) + if G.max() > 1.0 - 1e-8: + raise Invalid("two points coincide (or nearly: distance < 1.4e-4)") + dev = np.abs(harmonics(X, t).mean(axis=1)).max() + if not dev <= TOL: + raise Invalid(f"not a {t}-design: some harmonic of degree <= {t} has point average {dev:.3e} > {TOL}") + return None, {"max_harmonic_average": float(dev)} diff --git a/tasks/construct-ae-p32-spherical-design-l5-s0/tests/instance.json b/tasks/construct-ae-p32-spherical-design-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc94adf3c348628f8a0bf42c69f9b809eef04869 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"t": 19, "N": 198, "family": "ae_p32_spherical_designs", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p32-spherical-design-l5-s0/tests/run.py b/tasks/construct-ae-p32-spherical-design-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p32-spherical-design-l5-s0/tests/test.sh b/tasks/construct-ae-p32-spherical-design-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s0/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s0/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5b510992eff625d4de23dc9cc763448218bc31be --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"N": 86, "t": 24, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s0/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ccc09ccca11a703887dd2911cab81de06f97c28e --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"factors": [288, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 31, 31, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 37, 37, 38, 38, 38, 38, 41, 41, 43, 43, 46, 46, 46, 47, 53, 59, 61, 67, 71, 73, 79, 83]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5b510992eff625d4de23dc9cc763448218bc31be --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"N": 86, "t": 24, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s7/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s7/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f323a81ecb3ea9fd72dde4ef83d99b0fcfa39555 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"N": 134, "t": 39, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s7/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..96a66b7c66e0b0848cc041a4415188e01b0df52a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"factors": [585, 39, 39, 39, 39, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 46, 46, 46, 46, 46, 47, 47, 51, 51, 51, 51, 51, 51, 51, 53, 53, 56, 57, 57, 57, 57, 57, 57, 57, 58, 58, 58, 58, 59, 59, 61, 61, 62, 62, 62, 62, 67, 67, 71, 73, 74, 74, 74, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f323a81ecb3ea9fd72dde4ef83d99b0fcfa39555 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"N": 134, "t": 39, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s9/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s9/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..562b2344cf60846454e251474b2442c8022c5e1f --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"N": 152, "t": 44, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s9/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cabe969a462a9007d29dde5d01a4126af49f880e --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"factors": [704, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 46, 46, 46, 46, 46, 46, 47, 47, 47, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 57, 57, 57, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, 59, 59, 61, 61, 62, 62, 62, 62, 64, 67, 67, 71, 71, 73, 73, 74, 74, 74, 74, 79, 82, 82, 82, 83, 86, 86, 86, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..562b2344cf60846454e251474b2442c8022c5e1f --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"N": 152, "t": 44, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s1/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s1/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cee8c0d43b5c74f12b445a67c2e27ceb19618f29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"N": 5728, "t": 1856, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s1/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d2d546606bdf702420e0ecce1b90d2936a656b2a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"factors": [1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1856, 1857, 1857, 1857, 1857, 1857, 1857, 1857, 1857, 1857, 1858, 1858, 1858, 1858, 1858, 1858, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1859, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1860, 1861, 1861, 1861, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1862, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1864, 1865, 1865, 1865, 1865, 1865, 1865, 1865, 1865, 1865, 1865, 1865, 1865, 1865, 1865, 1865, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1866, 1867, 1867, 1867, 1868, 1868, 1868, 1868, 1868, 1868, 1868, 1868, 1868, 1868, 1868, 1868, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1869, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1870, 1871, 1871, 1871, 1873, 1873, 1873, 1874, 1874, 1874, 1874, 1874, 1874, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1875, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1877, 1877, 1877, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1879, 1879, 1879, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1880, 1882, 1882, 1882, 1882, 1882, 1882, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1887, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1889, 1889, 1889, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1890, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1893, 1893, 1893, 1893, 1893, 1893, 1893, 1893, 1893, 1894, 1894, 1894, 1894, 1894, 1894, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1899, 1901, 1901, 1901, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1903, 1904, 1904, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1906, 1906, 1906, 1906, 1906, 1906, 1907, 1907, 1907, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1909, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1911, 1911, 1911, 1911, 1911, 1911, 1911, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1912, 1913, 1913, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1916, 1916, 1916, 1916, 1916, 1916, 1916, 1916, 1916, 1916, 1916, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1917, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1919, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1923, 1923, 1923, 1923, 1923, 1923, 1923, 1923, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1925, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1927, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1931, 1931, 1933, 1933, 1934, 1934, 1934, 1934, 1934, 1935, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1939, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1941, 1941, 1941, 1941, 1941, 1941, 1941, 1941, 1942, 1942, 1942, 1942, 1942, 1944, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1946, 1948, 1948, 1948, 1948, 1948, 1948, 1948, 1948, 1948, 1948, 1948, 1949, 1949, 1951, 1951, 1954, 1954, 1954, 1954, 1954, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1956, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1957, 1959, 1959, 1959, 1959, 1959, 1959, 1959, 1959, 1961, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1963, 1964, 1964, 1964, 1964, 1964, 1964, 1964, 1964, 1964, 1964, 1964, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1965, 1966, 1966, 1966, 1966, 1966, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1967, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1969, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1973, 1973, 1977, 1977, 1977, 1977, 1977, 1977, 1977, 1977, 1979, 1979, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1982, 1982, 1982, 1982, 1982, 1983, 1983, 1983, 1983, 1983, 1983, 1983, 1983, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1987, 1987, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1991, 1993, 1993, 1994, 1994, 1994, 1994, 1994, 1996, 1996, 1996, 1996, 1996, 1996, 1996, 1996, 1996, 1996, 1996, 1997, 1997, 1999, 1999, 2003, 2003, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2011, 2011, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2017, 2017, 2018, 2018, 2018, 2018, 2018, 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2023, 2026, 2026, 2026, 2026, 2026, 2027, 2027, 2029, 2029, 2031, 2031, 2031, 2031, 2031, 2031, 2031, 2031, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2038, 2038, 2038, 2038, 2038, 2039, 2039, 2042, 2042, 2042, 2042, 2042, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2049, 2049, 2049, 2049, 2049, 2049, 2049, 2049, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2053, 2053, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2062, 2062, 2062, 2062, 2062, 2063, 2063, 2066, 2066, 2066, 2066, 2066, 2069, 2069, 2073, 2073, 2073, 2073, 2073, 2073, 2073, 2073, 2078, 2078, 2078, 2078, 2078, 2081, 2081, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2083, 2083, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2087, 2087, 2089, 2089, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2098, 2098, 2098, 2098, 2098, 2099, 2099, 2102, 2102, 2102, 2102, 2102, 2103, 2103, 2103, 2103, 2103, 2103, 2103, 2103, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2111, 2111, 2113, 2113, 2115, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2122, 2122, 2122, 2122, 2122, 2126, 2126, 2126, 2126, 2126, 2127, 2127, 2127, 2127, 2127, 2127, 2127, 2127, 2129, 2129, 2131, 2131, 2137, 2137, 2138, 2138, 2138, 2138, 2138, 2141, 2141, 2143, 2143, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2153, 2153, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2157, 2157, 2157, 2157, 2157, 2157, 2157, 2161, 2161, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2174, 2174, 2174, 2174, 2174, 2179, 2179, 2181, 2181, 2181, 2181, 2181, 2181, 2181, 2182, 2182, 2182, 2182, 2182, 2186, 2186, 2186, 2186, 2186, 2188, 2188, 2188, 2188, 2188, 2188, 2188, 2188, 2188, 2188, 2194, 2194, 2194, 2194, 2194, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2199, 2199, 2199, 2199, 2199, 2199, 2199, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2203, 2203, 2206, 2206, 2206, 2206, 2206, 2207, 2207, 2213, 2213, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2217, 2217, 2217, 2217, 2217, 2217, 2217, 2218, 2218, 2218, 2218, 2218, 2221, 2221, 2228, 2228, 2228, 2228, 2228, 2228, 2228, 2228, 2228, 2228, 2229, 2229, 2229, 2229, 2229, 2229, 2229, 2234, 2234, 2234, 2234, 2234, 2237, 2237, 2239, 2239, 2243, 2243, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2246, 2246, 2246, 2246, 2246, 2251, 2251, 2252, 2252, 2252, 2252, 2252, 2252, 2252, 2252, 2252, 2252, 2253, 2253, 2253, 2253, 2253, 2253, 2253, 2258, 2258, 2258, 2258, 2258, 2267, 2267, 2269, 2269, 2271, 2271, 2271, 2271, 2271, 2271, 2271, 2273, 2273, 2276, 2276, 2276, 2276, 2276, 2276, 2276, 2276, 2276, 2276, 2281, 2281, 2283, 2283, 2283, 2283, 2283, 2283, 2283, 2284, 2284, 2284, 2284, 2284, 2284, 2284, 2284, 2284, 2284, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2286, 2287, 2287, 2293, 2293, 2297, 2297, 2302, 2302, 2302, 2302, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2306, 2306, 2306, 2306, 2307, 2307, 2307, 2307, 2307, 2307, 2307, 2308, 2308, 2308, 2308, 2308, 2308, 2308, 2308, 2308, 2309, 2309, 2311, 2311, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2319, 2319, 2319, 2319, 2319, 2319, 2319, 2326, 2326, 2326, 2326, 2333, 2333, 2339, 2339, 2341, 2341, 2342, 2342, 2342, 2342, 2347, 2347, 2348, 2348, 2348, 2348, 2348, 2348, 2348, 2348, 2348, 2351, 2351, 2357, 2357, 2361, 2361, 2361, 2361, 2361, 2361, 2361, 2362, 2362, 2362, 2362, 2371, 2371, 2372, 2372, 2372, 2372, 2372, 2372, 2372, 2372, 2372, 2374, 2374, 2374, 2374, 2377, 2377, 2381, 2381, 2383, 2383, 2386, 2386, 2386, 2386, 2389, 2389, 2391, 2391, 2391, 2391, 2391, 2391, 2391, 2393, 2393, 2396, 2396, 2396, 2396, 2396, 2396, 2396, 2396, 2396, 2399, 2399, 2402, 2402, 2402, 2402, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2411, 2411, 2417, 2417, 2423, 2423, 2426, 2426, 2426, 2426, 2427, 2427, 2427, 2427, 2427, 2427, 2427, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2434, 2434, 2434, 2434, 2437, 2437, 2441, 2441, 2446, 2446, 2446, 2446, 2447, 2447, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2458, 2458, 2458, 2458, 2459, 2459, 2462, 2462, 2462, 2462, 2463, 2463, 2463, 2463, 2463, 2463, 2467, 2467, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2469, 2469, 2469, 2469, 2469, 2469, 2473, 2473, 2474, 2474, 2474, 2474, 2477, 2477, 2481, 2481, 2481, 2481, 2481, 2481, 2487, 2487, 2487, 2487, 2487, 2487, 2498, 2498, 2498, 2498, 2503, 2503, 2517, 2517, 2517, 2517, 2517, 2517, 2518, 2518, 2518, 2518, 2521, 2521, 2531, 2531, 2539, 2539, 2543, 2543, 2549, 2549, 2551, 2551, 2554, 2554, 2554, 2554, 2557, 2557, 2558, 2558, 2558, 2558, 2559, 2559, 2559, 2559, 2559, 2559, 2566, 2566, 2566, 2566, 2571, 2571, 2571, 2571, 2571, 2571, 2577, 2577, 2577, 2577, 2577, 2577, 2578, 2578, 2578, 2578, 2579, 2579, 2582, 2582, 2582, 2582, 2589, 2589, 2589, 2589, 2589, 2589, 2591, 2591, 2593, 2593, 2594, 2594, 2594, 2594, 2602, 2602, 2602, 2602, 2606, 2606, 2606, 2606, 2609, 2609, 2614, 2614, 2614, 2614, 2617, 2617, 2621, 2621, 2631, 2631, 2631, 2631, 2631, 2631, 2633, 2633, 2638, 2638, 2638, 2638, 2642, 2642, 2642, 2642, 2643, 2643, 2643, 2643, 2643, 2643, 2647, 2647, 2649, 2649, 2649, 2649, 2649, 2649, 2654, 2654, 2654, 2654, 2657, 2657, 2659, 2659, 2661, 2661, 2661, 2661, 2661, 2661, 2663, 2663, 2671, 2671, 2677, 2677, 2683, 2683, 2687, 2687, 2689, 2689, 2693, 2693, 2699, 2699, 2707, 2707, 2711, 2711, 2713, 2713, 2719, 2719, 2721, 2721, 2721, 2721, 2721, 2721, 2722, 2722, 2722, 2722, 2729, 2729, 2731, 2731, 2733, 2733, 2733, 2733, 2733, 2733, 2734, 2734, 2734, 2734, 2741, 2741, 2746, 2746, 2746, 2746, 2749, 2749, 2753, 2753, 2757, 2757, 2757, 2757, 2757, 2757, 2762, 2762, 2762, 2762, 2767, 2767, 2777, 2777, 2789, 2789, 2791, 2791, 2797, 2797, 2798, 2798, 2798, 2798, 2801, 2801, 2803, 2803, 2818, 2818, 2818, 2818, 2819, 2819, 2833, 2833, 2837, 2837, 2843, 2843, 2846, 2846, 2846, 2846, 2851, 2851, 2854, 2854, 2854, 2854, 2857, 2857, 2858, 2858, 2858, 2858, 2861, 2861, 2866, 2866, 2866, 2878, 2878, 2878, 2879, 2887, 2894, 2894, 2894, 2897, 2902, 2902, 2902, 2903, 2906, 2906, 2906, 2909, 2917, 2918, 2918, 2918, 2927, 2939, 2942, 2942, 2942, 2953, 2957, 2962, 2962, 2962, 2963, 2966, 2966, 2966, 2969, 2971, 2974, 2974, 2974, 2978, 2978, 2978, 2986, 2986, 2986, 2998, 2998, 2998, 2999, 3001, 3011, 3019, 3022, 3022, 3022, 3023, 3037, 3041, 3046, 3046, 3046, 3049, 3061, 3062, 3062, 3062, 3067, 3079, 3083, 3086, 3086, 3086, 3089, 3098, 3098, 3098, 3106, 3106, 3106, 3109, 3118, 3118, 3118, 3119, 3121, 3134, 3134, 3134, 3137, 3142, 3142, 3142, 3158, 3158, 3158, 3163, 3166, 3166, 3166, 3167, 3169, 3181, 3187, 3191, 3194, 3194, 3194, 3202, 3202, 3202, 3203, 3209, 3214, 3214, 3214, 3217, 3218, 3218, 3218, 3221, 3226, 3226, 3226, 3229, 3238, 3238, 3238, 3242, 3242, 3242, 3251, 3253, 3254, 3254, 3254, 3257, 3259, 3271, 3274, 3274, 3274, 3299, 3301, 3307, 3313, 3314, 3314, 3314, 3319, 3323, 3326, 3326, 3326, 3329, 3331, 3334, 3334, 3334, 3338, 3338, 3338, 3343, 3347, 3359, 3361, 3371, 3373, 3386, 3386, 3386, 3389, 3391, 3394, 3394, 3394, 3398, 3398, 3398, 3407, 3413, 3418, 3418, 3418, 3433, 3442, 3442, 3442, 3446, 3446, 3446, 3449, 3457, 3461, 3463, 3466, 3466, 3466, 3467, 3469, 3482, 3482, 3482, 3491, 3494, 3494, 3494, 3499, 3506, 3506, 3506, 3511, 3517, 3518, 3518, 3518, 3527, 3529, 3533, 3539, 3541, 3547, 3554, 3554, 3554, 3557, 3559, 3566, 3566, 3566, 3571, 3574, 3574, 3574, 3578, 3578, 3578, 3581, 3583, 3593, 3602, 3602, 3602, 3607, 3613, 3617, 3622, 3622, 3622, 3623, 3631, 3637, 3643, 3646, 3646, 3646, 3659, 3662, 3662, 3662, 3671, 3673, 3677, 3691, 3694, 3694, 3694, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cee8c0d43b5c74f12b445a67c2e27ceb19618f29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"N": 5728, "t": 1856, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s6/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s6/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..514fe3b8b9bc0909196b33c1e895aa9d3ddbdc1e --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"N": 8484, "t": 2770, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s6/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8aa954dc15b28eb0bd888d7521c32ca05631c12a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"factors": [33240, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2772, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2773, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2775, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2777, 2777, 2777, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2780, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2781, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2782, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2784, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2786, 2787, 2787, 2787, 2787, 2787, 2787, 2787, 2787, 2787, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2788, 2789, 2789, 2789, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2790, 2791, 2791, 2791, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2793, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2794, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2795, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2796, 2797, 2797, 2797, 2798, 2798, 2798, 2798, 2798, 2798, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2800, 2801, 2801, 2801, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2803, 2803, 2803, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2806, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2808, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2809, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2810, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2813, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2814, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2818, 2818, 2818, 2818, 2818, 2818, 2819, 2819, 2819, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2820, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2821, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2822, 2823, 2823, 2823, 2823, 2823, 2823, 2823, 2823, 2823, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2825, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2827, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2828, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2830, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2831, 2833, 2833, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2834, 2835, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2837, 2837, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2839, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2840, 2841, 2841, 2841, 2841, 2841, 2841, 2841, 2841, 2843, 2843, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2844, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2846, 2846, 2846, 2846, 2846, 2847, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2848, 2851, 2851, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2853, 2854, 2854, 2854, 2854, 2854, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2857, 2857, 2858, 2858, 2858, 2858, 2858, 2859, 2859, 2859, 2859, 2859, 2859, 2859, 2859, 2861, 2861, 2862, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2864, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2865, 2866, 2866, 2866, 2866, 2866, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2868, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2869, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2877, 2878, 2878, 2878, 2878, 2878, 2879, 2879, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2887, 2887, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2894, 2894, 2894, 2894, 2894, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2897, 2897, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2902, 2902, 2902, 2902, 2902, 2903, 2903, 2906, 2906, 2906, 2906, 2906, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2909, 2909, 2913, 2913, 2913, 2913, 2913, 2913, 2913, 2913, 2917, 2917, 2918, 2918, 2918, 2918, 2918, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2927, 2927, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2931, 2931, 2931, 2931, 2931, 2931, 2931, 2931, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2939, 2939, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2942, 2942, 2942, 2942, 2942, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2949, 2949, 2949, 2949, 2949, 2949, 2949, 2949, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2953, 2953, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2957, 2957, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2962, 2962, 2962, 2962, 2962, 2963, 2963, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2966, 2966, 2966, 2966, 2966, 2969, 2969, 2971, 2971, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2973, 2973, 2973, 2973, 2973, 2973, 2973, 2973, 2974, 2974, 2974, 2974, 2974, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2978, 2978, 2978, 2978, 2978, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2986, 2986, 2986, 2986, 2986, 2991, 2991, 2991, 2991, 2991, 2991, 2991, 2991, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2998, 2998, 2998, 2998, 2998, 2999, 2999, 3001, 3001, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3008, 3011, 3011, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3019, 3019, 3022, 3022, 3022, 3022, 3022, 3023, 3023, 3027, 3027, 3027, 3027, 3027, 3027, 3027, 3027, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3037, 3037, 3039, 3039, 3039, 3039, 3039, 3039, 3039, 3039, 3041, 3041, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3046, 3046, 3046, 3046, 3046, 3049, 3049, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3057, 3057, 3057, 3057, 3057, 3057, 3057, 3057, 3061, 3061, 3062, 3062, 3062, 3062, 3062, 3063, 3063, 3063, 3063, 3063, 3063, 3063, 3063, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3067, 3067, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3079, 3079, 3083, 3083, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3086, 3086, 3086, 3086, 3086, 3089, 3089, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3093, 3093, 3093, 3093, 3093, 3093, 3093, 3093, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3098, 3098, 3098, 3098, 3098, 3099, 3099, 3099, 3099, 3099, 3099, 3099, 3099, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3106, 3106, 3106, 3106, 3106, 3109, 3109, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3117, 3117, 3117, 3117, 3117, 3117, 3117, 3117, 3118, 3118, 3118, 3118, 3118, 3119, 3119, 3121, 3121, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3134, 3134, 3134, 3134, 3134, 3137, 3137, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3142, 3142, 3142, 3142, 3142, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3147, 3147, 3147, 3147, 3147, 3147, 3147, 3147, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3153, 3153, 3153, 3153, 3153, 3153, 3153, 3153, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3158, 3158, 3158, 3158, 3158, 3163, 3163, 3166, 3166, 3166, 3166, 3166, 3167, 3167, 3169, 3169, 3181, 3181, 3183, 3183, 3183, 3183, 3183, 3183, 3183, 3187, 3187, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3189, 3189, 3189, 3189, 3189, 3189, 3189, 3191, 3191, 3194, 3194, 3194, 3194, 3194, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3202, 3202, 3202, 3202, 3202, 3203, 3203, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3207, 3207, 3207, 3207, 3207, 3207, 3207, 3209, 3209, 3214, 3214, 3214, 3214, 3214, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3217, 3217, 3218, 3218, 3218, 3218, 3218, 3221, 3221, 3226, 3226, 3226, 3226, 3226, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3229, 3229, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3238, 3238, 3238, 3238, 3238, 3242, 3242, 3242, 3242, 3242, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3251, 3251, 3253, 3253, 3254, 3254, 3254, 3254, 3254, 3257, 3257, 3259, 3259, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3271, 3271, 3273, 3273, 3273, 3273, 3273, 3273, 3273, 3274, 3274, 3274, 3274, 3274, 3279, 3279, 3279, 3279, 3279, 3279, 3279, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3291, 3291, 3291, 3291, 3291, 3291, 3291, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3299, 3299, 3301, 3301, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3307, 3307, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3309, 3309, 3309, 3309, 3309, 3309, 3309, 3313, 3313, 3314, 3314, 3314, 3314, 3314, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3319, 3319, 3323, 3323, 3326, 3326, 3326, 3326, 3326, 3327, 3327, 3327, 3327, 3327, 3327, 3327, 3329, 3329, 3331, 3331, 3334, 3334, 3334, 3334, 3334, 3338, 3338, 3338, 3338, 3338, 3343, 3343, 3347, 3347, 3351, 3351, 3351, 3351, 3351, 3351, 3351, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3359, 3359, 3361, 3361, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3369, 3369, 3369, 3369, 3369, 3369, 3369, 3371, 3371, 3373, 3373, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3386, 3386, 3386, 3386, 3386, 3387, 3387, 3387, 3387, 3387, 3387, 3387, 3389, 3389, 3391, 3391, 3394, 3394, 3394, 3394, 3398, 3398, 3398, 3398, 3407, 3407, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3413, 3413, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3418, 3418, 3418, 3418, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3433, 3433, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3442, 3442, 3442, 3442, 3446, 3446, 3446, 3446, 3449, 3449, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3453, 3453, 3453, 3453, 3453, 3453, 3453, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3457, 3457, 3459, 3459, 3459, 3459, 3459, 3459, 3459, 3461, 3461, 3463, 3463, 3466, 3466, 3466, 3466, 3467, 3467, 3469, 3469, 3482, 3482, 3482, 3482, 3489, 3489, 3489, 3489, 3489, 3489, 3489, 3491, 3491, 3494, 3494, 3494, 3494, 3499, 3499, 3506, 3506, 3506, 3506, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3511, 3511, 3513, 3513, 3513, 3513, 3513, 3513, 3513, 3517, 3517, 3518, 3518, 3518, 3518, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3527, 3527, 3529, 3529, 3532, 3532, 3532, 3532, 3532, 3532, 3532, 3532, 3532, 3533, 3533, 3539, 3539, 3541, 3541, 3543, 3543, 3543, 3543, 3543, 3543, 3543, 3547, 3547, 3548, 3548, 3548, 3548, 3548, 3548, 3548, 3548, 3548, 3554, 3554, 3554, 3554, 3557, 3557, 3559, 3559, 3561, 3561, 3561, 3561, 3561, 3561, 3561, 3566, 3566, 3566, 3566, 3571, 3571, 3574, 3574, 3574, 3574, 3578, 3578, 3578, 3578, 3579, 3579, 3579, 3579, 3579, 3579, 3579, 3581, 3581, 3583, 3583, 3593, 3593, 3602, 3602, 3602, 3602, 3603, 3603, 3603, 3603, 3603, 3603, 3603, 3607, 3607, 3613, 3613, 3617, 3617, 3622, 3622, 3622, 3622, 3623, 3623, 3628, 3628, 3628, 3628, 3628, 3628, 3628, 3628, 3628, 3631, 3631, 3637, 3637, 3639, 3639, 3639, 3639, 3639, 3639, 3643, 3643, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3646, 3646, 3646, 3646, 3651, 3651, 3651, 3651, 3651, 3651, 3659, 3659, 3662, 3662, 3662, 3662, 3669, 3669, 3669, 3669, 3669, 3669, 3671, 3671, 3673, 3673, 3676, 3676, 3676, 3676, 3676, 3676, 3676, 3676, 3676, 3677, 3677, 3687, 3687, 3687, 3687, 3687, 3687, 3691, 3691, 3693, 3693, 3693, 3693, 3693, 3693, 3694, 3694, 3694, 3694, 3697, 3697, 3701, 3701, 3709, 3709, 3711, 3711, 3711, 3711, 3711, 3711, 3719, 3719, 3722, 3722, 3722, 3722, 3727, 3727, 3733, 3733, 3734, 3734, 3734, 3734, 3739, 3739, 3742, 3742, 3742, 3742, 3746, 3746, 3746, 3746, 3747, 3747, 3747, 3747, 3747, 3747, 3754, 3754, 3754, 3754, 3758, 3758, 3758, 3758, 3761, 3761, 3767, 3767, 3769, 3769, 3777, 3777, 3777, 3777, 3777, 3777, 3778, 3778, 3778, 3778, 3779, 3779, 3793, 3793, 3797, 3797, 3802, 3802, 3802, 3802, 3803, 3803, 3814, 3814, 3814, 3814, 3821, 3821, 3823, 3823, 3826, 3826, 3826, 3826, 3831, 3831, 3831, 3831, 3831, 3831, 3833, 3833, 3837, 3837, 3837, 3837, 3837, 3837, 3847, 3847, 3849, 3849, 3849, 3849, 3849, 3849, 3851, 3851, 3853, 3853, 3862, 3862, 3862, 3862, 3863, 3863, 3866, 3866, 3866, 3866, 3867, 3867, 3867, 3867, 3867, 3867, 3873, 3873, 3873, 3873, 3873, 3873, 3877, 3877, 3881, 3881, 3889, 3889, 3891, 3891, 3891, 3891, 3891, 3891, 3898, 3898, 3898, 3898, 3902, 3902, 3902, 3902, 3903, 3903, 3903, 3903, 3903, 3903, 3907, 3907, 3909, 3909, 3909, 3909, 3909, 3909, 3911, 3911, 3917, 3917, 3919, 3919, 3921, 3921, 3921, 3921, 3921, 3921, 3923, 3923, 3929, 3929, 3931, 3931, 3943, 3943, 3946, 3946, 3946, 3946, 3947, 3947, 3957, 3957, 3957, 3957, 3957, 3957, 3958, 3958, 3958, 3958, 3963, 3963, 3963, 3963, 3963, 3963, 3967, 3967, 3974, 3974, 3974, 3974, 3981, 3981, 3981, 3981, 3981, 3981, 3986, 3986, 3986, 3986, 3989, 3989, 3994, 3994, 3994, 3994, 3998, 3998, 3998, 3998, 4001, 4001, 4003, 4003, 4006, 4006, 4006, 4006, 4007, 4007, 4013, 4013, 4019, 4019, 4021, 4021, 4022, 4022, 4022, 4022, 4027, 4027, 4034, 4034, 4034, 4034, 4049, 4049, 4051, 4051, 4054, 4054, 4054, 4054, 4057, 4057, 4058, 4058, 4058, 4058, 4073, 4073, 4078, 4078, 4078, 4078, 4079, 4079, 4083, 4083, 4083, 4083, 4083, 4083, 4091, 4091, 4093, 4093, 4099, 4099, 4101, 4101, 4101, 4101, 4101, 4101, 4106, 4106, 4106, 4106, 4111, 4111, 4119, 4119, 4119, 4119, 4119, 4119, 4126, 4126, 4126, 4126, 4127, 4127, 4129, 4129, 4133, 4133, 4138, 4138, 4138, 4138, 4139, 4139, 4143, 4143, 4143, 4143, 4143, 4143, 4153, 4153, 4157, 4157, 4159, 4159, 4162, 4162, 4162, 4162, 4166, 4166, 4166, 4166, 4174, 4174, 4174, 4174, 4177, 4177, 4178, 4178, 4178, 4178, 4198, 4198, 4198, 4198, 4201, 4201, 4211, 4211, 4217, 4217, 4219, 4219, 4222, 4222, 4222, 4222, 4226, 4226, 4226, 4226, 4229, 4229, 4231, 4231, 4241, 4241, 4243, 4253, 4258, 4258, 4258, 4259, 4261, 4262, 4262, 4262, 4271, 4273, 4274, 4274, 4274, 4282, 4282, 4282, 4283, 4286, 4286, 4286, 4289, 4297, 4306, 4306, 4306, 4322, 4322, 4322, 4327, 4337, 4339, 4349, 4357, 4358, 4358, 4358, 4363, 4373, 4391, 4397, 4406, 4406, 4406, 4409, 4414, 4414, 4414, 4421, 4423, 4426, 4426, 4426, 4441, 4442, 4442, 4442, 4447, 4451, 4457, 4463, 4474, 4474, 4474, 4478, 4478, 4478, 4481, 4483, 4486, 4486, 4486, 4493, 4502, 4502, 4502, 4507, 4513, 4517, 4519, 4523, 4534, 4534, 4534, 4538, 4538, 4538, 4546, 4546, 4546, 4547, 4549, 4561, 4562, 4562, 4562, 4567, 4574, 4574, 4574, 4583, 4586, 4586, 4586, 4591, 4594, 4594, 4594, 4597, 4603, 4618, 4618, 4618, 4621, 4622, 4622, 4622, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4666, 4666, 4666, 4673, 4678, 4678, 4678, 4679, 4682, 4682, 4682, 4691, 4694, 4694, 4694, 4702, 4702, 4702, 4703, 4714, 4714, 4714, 4721, 4723, 4729, 4733, 4742, 4742, 4742, 4751, 4754, 4754, 4754, 4759, 4762, 4762, 4762, 4766, 4766, 4766, 4778, 4778, 4778, 4783, 4786, 4786, 4786, 4787, 4789, 4793, 4798, 4798, 4798, 4799, 4801, 4813, 4817, 4822, 4822, 4822, 4831, 4834, 4834, 4834, 4846, 4846, 4846, 4861, 4871, 4874, 4874, 4874, 4877, 4882, 4882, 4882, 4889, 4894, 4894, 4894, 4903, 4909, 4918, 4918, 4918, 4919, 4931, 4933, 4934, 4934, 4934, 4937, 4943, 4946, 4946, 4946, 4951, 4954, 4954, 4954, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5006, 5006, 5006, 5009, 5011, 5021, 5023, 5039, 5042, 5042, 5042, 5051, 5059, 5062, 5062, 5062, 5077, 5078, 5078, 5078, 5081, 5086, 5086, 5086, 5087, 5098, 5098, 5098, 5099, 5101, 5102, 5102, 5102, 5107, 5113, 5114, 5114, 5114, 5119, 5147, 5153, 5158, 5158, 5158, 5167, 5171, 5179, 5182, 5182, 5182, 5186, 5186, 5186, 5189, 5197, 5209, 5218, 5218, 5218, 5227, 5231, 5233, 5234, 5234, 5234, 5237, 5242, 5242, 5242, 5261, 5266, 5266, 5266, 5273, 5279, 5281, 5294, 5294, 5294, 5297, 5303, 5309, 5314, 5314, 5314, 5318, 5318, 5318, 5323, 5326, 5326, 5326, 5333, 5342, 5342, 5342, 5347, 5351, 5354, 5354, 5354, 5366, 5366, 5366, 5374, 5374, 5374, 5378, 5378, 5378, 5381, 5386, 5386, 5386, 5387, 5393, 5398, 5398, 5398, 5399, 5407, 5413, 5414, 5414, 5414, 5417, 5419, 5422, 5422, 5422, 5426, 5426, 5426, 5431, 5437, 5438, 5438, 5438, 5441, 5443, 5449, 5458, 5458, 5458, 5462, 5462, 5462, 5471, 5477, 5479, 5482, 5482, 5482, 5483, 5498, 5498, 5498, 5501, 5503, 5506, 5506, 5506, 5507, 5519, 5521, 5527, 5531, 5534, 5534, 5534, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..514fe3b8b9bc0909196b33c1e895aa9d3ddbdc1e --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"N": 8484, "t": 2770, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s2/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s2/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a1d815590c34784321370e064318bc240fb72e34 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"N": 361, "t": 15, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s2/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b9ab628edfe999ea73d2c4c3b0d446de7fe1d001 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": [7, 32, 57, 82, 107, 132, 157, 182, 207, 232, 257, 282, 307, 332, 357]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/check.py @@ -0,0 +1,38 @@ +"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A +(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for +"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1.""" +import numpy as np + +from run import Invalid, int_list + + +def _primes(n): + s = np.ones(n + 1, dtype=bool) + s[:2] = False + for i in range(2, int(n ** .5) + 1): + if s[i]: + s[i * i::i] = False + return np.nonzero(s)[0] + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + a = ans.get("A") + if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20): + raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers") + int_list(a, None, 1, n, "A") + if len(set(a)) != len(a): + raise Invalid("A must consist of distinct integers") + x = np.array(sorted(a), dtype=np.int64) + iu, ju = np.triu_indices(len(x)) + va, vb = x[iu], x[ju] + left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet + for p in _primes(int((n * n + 1) ** .5) + 1): + q = int(p) * int(p) + idx = np.nonzero(left)[0] + hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0 + left[idx[hit]] = False + if not left.any(): + return None, {"size": len(a)} + k = int(np.nonzero(left)[0][0]) + raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree") diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a1d815590c34784321370e064318bc240fb72e34 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"N": 361, "t": 15, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s5/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s5/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3d4b9da1d0c151ef27b782ed9eb51c3bb453e4f9 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"N": 293, "t": 12, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s5/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..30ec22c27135f7d8b2e020c7da0f72153f5a0bb1 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": [7, 32, 57, 82, 107, 132, 157, 182, 207, 232, 257, 282]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/check.py @@ -0,0 +1,38 @@ +"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A +(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for +"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1.""" +import numpy as np + +from run import Invalid, int_list + + +def _primes(n): + s = np.ones(n + 1, dtype=bool) + s[:2] = False + for i in range(2, int(n ** .5) + 1): + if s[i]: + s[i * i::i] = False + return np.nonzero(s)[0] + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + a = ans.get("A") + if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20): + raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers") + int_list(a, None, 1, n, "A") + if len(set(a)) != len(a): + raise Invalid("A must consist of distinct integers") + x = np.array(sorted(a), dtype=np.int64) + iu, ju = np.triu_indices(len(x)) + va, vb = x[iu], x[ju] + left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet + for p in _primes(int((n * n + 1) ** .5) + 1): + q = int(p) * int(p) + idx = np.nonzero(left)[0] + hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0 + left[idx[hit]] = False + if not left.any(): + return None, {"size": len(a)} + k = int(np.nonzero(left)[0][0]) + raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree") diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3d4b9da1d0c151ef27b782ed9eb51c3bb453e4f9 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"N": 293, "t": 12, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p58-happy-ending-l5-s0/environment/Dockerfile b/tasks/construct-ae-p58-happy-ending-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p58-happy-ending-l5-s0/environment/instance.json b/tasks/construct-ae-p58-happy-ending-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cb5a16c1edce3ed22e78ce7adb33a1d84b61d7de --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 128, "k": 9, "max_abs": 1000000000000000000, "family": "ae_p58_happy_ending", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p58-happy-ending-l5-s0/solution/solve.sh b/tasks/construct-ae-p58-happy-ending-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c2660d244184e0d7cf446e9f9e37538702fc0ea8 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"points": [[0, 0], [515385000, -515385000000], [515385001, -515384999998], [515385002, -515384999990], [515385003, -515384999954], [515385004, -515384999762], [515385005, -515384998562], [515385006, -515384989922], [1030770000, -2061540000000], [1030770001, -2061539999990], [1030770002, -2061539999988], [1030770003, -2061539999924], [1030770004, -2061539999922], [1030770005, -2061539999914], [1030770006, -2061539999250], [1030770007, -2061539999248], [1030770008, -2061539999240], [1030770009, -2061539999204], [1030770010, -2061539989110], [1030770011, -2061539989108], [1030770012, -2061539989100], [1030770013, -2061539989064], [1030770014, -2061539988872], [1030770015, -2061539775862], [1030770016, -2061539775860], [1030770017, -2061539775852], [1030770018, -2061539775816], [1030770019, -2061539775624], [1030770020, -2061539774424], [1546155000, -4638465000000], [1546155001, -4638464999944], [1546155002, -4638464999934], [1546155003, -4638464999932], [1546155004, -4638464999250], [1546155005, -4638464999240], [1546155006, -4638464999238], [1546155007, -4638464999174], [1546155008, -4638464999172], [1546155009, -4638464999164], [1546155010, -4638464985368], [1546155011, -4638464985358], [1546155012, -4638464985356], [1546155013, -4638464985292], [1546155014, -4638464985290], [1546155015, -4638464985282], [1546155016, -4638464984618], [1546155017, -4638464984616], [1546155018, -4638464984608], [1546155019, -4638464984572], [1546155020, -4638464500078], [1546155021, -4638464500068], [1546155022, -4638464500066], [1546155023, -4638464500002], [1546155024, -4638464500000], [1546155025, -4638464499992], [1546155026, -4638464499328], [1546155027, -4638464499326], [1546155028, -4638464499318], [1546155029, -4638464499282], [1546155030, -4638464489188], [1546155031, -4638464489186], [1546155032, -4638464489178], [1546155033, -4638464489142], [1546155034, -4638464488950], [2061540000, -8246160000000], [2061540001, -8246159999638], [2061540002, -8246159999582], [2061540003, -8246159999572], [2061540004, -8246159999570], [2061540005, -8246159988778], [2061540006, -8246159988722], [2061540007, -8246159988712], [2061540008, -8246159988710], [2061540009, -8246159988028], [2061540010, -8246159988018], [2061540011, -8246159988016], [2061540012, -8246159987952], [2061540013, -8246159987950], [2061540014, -8246159987942], [2061540015, -8246159500078], [2061540016, -8246159500022], [2061540017, -8246159500012], [2061540018, -8246159500010], [2061540019, -8246159499328], [2061540020, -8246159499318], [2061540021, -8246159499316], [2061540022, -8246159499252], [2061540023, -8246159499250], [2061540024, -8246159499242], [2061540025, -8246159485446], [2061540026, -8246159485436], [2061540027, -8246159485434], [2061540028, -8246159485370], [2061540029, -8246159485368], [2061540030, -8246159485360], [2061540031, -8246159484696], [2061540032, -8246159484694], [2061540033, -8246159484686], [2061540034, -8246159484650], [2576925000, -12884625000000], [2576925001, -12884624997328], [2576925002, -12884624996966], [2576925003, -12884624996910], [2576925004, -12884624996900], [2576925005, -12884624996898], [2576925006, -12884624760042], [2576925007, -12884624759680], [2576925008, -12884624759624], [2576925009, -12884624759614], [2576925010, -12884624759612], [2576925011, -12884624748820], [2576925012, -12884624748764], [2576925013, -12884624748754], [2576925014, -12884624748752], [2576925015, -12884624748070], [2576925016, -12884624748060], [2576925017, -12884624748058], [2576925018, -12884624747994], [2576925019, -12884624747992], [2576925020, -12884624747984], [3092310000, -18553860000000], [3092310001, -18553859977762], [3092310002, -18553859975090], [3092310003, -18553859974728], [3092310004, -18553859974672], [3092310005, -18553859974662], [3092310006, -18553859974660], [3607695000, -25253865000000]]} +RLMATH_EOF diff --git a/tasks/construct-ae-p58-happy-ending-l5-s0/tests/check.py b/tasks/construct-ae-p58-happy-ending-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..47e4606e109bc165111a8138a5a2f60870d563c8 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l5-s0/tests/check.py @@ -0,0 +1,69 @@ +"""Erdos-Szekeres happy ending (AlphaEvolve problem 58): n = 2^(k-2) integer points in general position with no +k points in convex position. Exact integer orientation tests; the largest convex-position subset is computed by +the O(n^4) bottom-vertex / angular-order dynamic programme. + +Upstream bug: the notebook's verifier uses float orientations with a 1e-9 threshold (and numba fastmath); its +33- and 65-point sets (claimed to have "0 convex k-gons") contain a convex 7-gon / 8-gon under exact arithmetic.""" +import functools + +import numpy as np + +from run import Invalid, int_list + + +def orient_table(p): + n = len(p) + o = np.zeros((n, n, n), dtype=np.int8) + for i in range(n): + xi, yi = p[i] + for j in range(i + 1, n): + dx, dy = p[j][0] - xi, p[j][1] - yi + for k in range(j + 1, n): + c = dx * (p[k][1] - yi) - dy * (p[k][0] - xi) + if c == 0: + raise Invalid(f"points {p[i]}, {p[j]}, {p[k]} are collinear") + s = 1 if c > 0 else -1 + o[i, j, k] = o[j, k, i] = o[k, i, j] = s + o[i, k, j] = o[k, j, i] = o[j, i, k] = -s + return o + + +def max_convex(p, o): + n = len(p) + best = min(n, 3) + order = sorted(range(n), key=lambda i: (p[i][1], p[i][0])) + for bi, b in enumerate(order): + rest = order[bi + 1:] + m = len(rest) + if m < 2: + continue + rest = sorted(rest, key=functools.cmp_to_key(lambda u, v: -int(o[b, u, v]))) + r = np.array(rest) + chain = np.zeros((m, m), dtype=np.int32) # chain[i, j]: longest convex chain b .. r_i -> r_j + for j in range(1, m): + for i in range(j): + v = 3 + if i > 0: + ok = (chain[:i, i] > 0) & (o[r[:i], r[i], r[j]] > 0) + if ok.any(): + v = max(v, int(chain[:i, i][ok].max()) + 1) + chain[i, j] = v + close = o[r[:j], r[j], b] > 0 + if close.any(): + best = max(best, int(chain[:j, j][close].max())) + return best + + +def check(inst, ans): + n, k, lim = inst["n"], inst["k"], inst["max_abs"] + pts = ans.get("points") + if not isinstance(pts, list) or len(pts) != n: + raise Invalid(f"points must be a list of {n} [x, y] pairs") + p = [tuple(int_list(q, 2, -lim, lim, "point")) for q in pts] + if len(set(p)) != n: + raise Invalid("points must be distinct") + o = orient_table(p) + mc = max_convex(p, o) + if mc >= k: + raise Invalid(f"the set contains {mc} points in convex position (>= {k})") + return None, {"max_convex_subset": mc} diff --git a/tasks/construct-ae-p58-happy-ending-l5-s0/tests/instance.json b/tasks/construct-ae-p58-happy-ending-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cb5a16c1edce3ed22e78ce7adb33a1d84b61d7de --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 128, "k": 9, "max_abs": 1000000000000000000, "family": "ae_p58_happy_ending", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p58-happy-ending-l5-s0/tests/run.py b/tasks/construct-ae-p58-happy-ending-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p58-happy-ending-l5-s0/tests/test.sh b/tasks/construct-ae-p58-happy-ending-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-all-interval-l2-s0/environment/Dockerfile b/tasks/construct-mc-all-interval-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-all-interval-l2-s0/environment/instance.json b/tasks/construct-mc-all-interval-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0f364ea385bd471915e66488ea9083a8b1d3d938 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "fixed": [["x", 4, 2], ["d", 5, 2]], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s0/solution/solve.sh b/tasks/construct-mc-all-interval-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5304b8a8355bf07f758713166fdf377215470dcd --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 7, 1, 6, 2, 5, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l2-s0/tests/check.py b/tasks/construct-mc-all-interval-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s0/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l2-s0/tests/instance.json b/tasks/construct-mc-all-interval-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0f364ea385bd471915e66488ea9083a8b1d3d938 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "fixed": [["x", 4, 2], ["d", 5, 2]], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s0/tests/run.py b/tasks/construct-mc-all-interval-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-all-interval-l2-s0/tests/test.sh b/tasks/construct-mc-all-interval-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-all-interval-l6-s1/environment/Dockerfile b/tasks/construct-mc-all-interval-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-all-interval-l6-s1/environment/instance.json b/tasks/construct-mc-all-interval-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ecdd8f3233d6c527dbc76382814e4b1c2d306700 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 64, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s1/solution/solve.sh b/tasks/construct-mc-all-interval-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..42d661a2f1122e732dd2aca504abb98b82fae01e --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 63, 1, 62, 2, 61, 3, 60, 4, 59, 5, 58, 6, 57, 7, 56, 8, 55, 9, 54, 10, 53, 11, 52, 12, 51, 13, 50, 14, 49, 15, 48, 16, 47, 17, 46, 18, 45, 19, 44, 20, 43, 21, 42, 22, 41, 23, 40, 24, 39, 25, 38, 26, 37, 27, 36, 28, 35, 29, 34, 30, 33, 31, 32]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l6-s1/tests/check.py b/tasks/construct-mc-all-interval-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s1/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l6-s1/tests/instance.json b/tasks/construct-mc-all-interval-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ecdd8f3233d6c527dbc76382814e4b1c2d306700 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 64, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s1/tests/run.py b/tasks/construct-mc-all-interval-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-all-interval-l6-s1/tests/test.sh b/tasks/construct-mc-all-interval-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-all-interval-l6-s6/environment/Dockerfile b/tasks/construct-mc-all-interval-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-all-interval-l6-s6/environment/instance.json b/tasks/construct-mc-all-interval-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1d01ddc1fc554957d1006017bd7a68fce51f6d67 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 80, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s6/solution/solve.sh b/tasks/construct-mc-all-interval-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9e2a44f4bdac9768467152dbddfae27569fd9b88 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 79, 1, 78, 2, 77, 3, 76, 4, 75, 5, 74, 6, 73, 7, 72, 8, 71, 9, 70, 10, 69, 11, 68, 12, 67, 13, 66, 14, 65, 15, 64, 16, 63, 17, 62, 18, 61, 19, 60, 20, 59, 21, 58, 22, 57, 23, 56, 24, 55, 25, 54, 26, 53, 27, 52, 28, 51, 29, 50, 30, 49, 31, 48, 32, 47, 33, 46, 34, 45, 35, 44, 36, 43, 37, 42, 38, 41, 39, 40]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l6-s6/tests/check.py b/tasks/construct-mc-all-interval-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s6/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l6-s6/tests/instance.json b/tasks/construct-mc-all-interval-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1d01ddc1fc554957d1006017bd7a68fce51f6d67 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 80, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s6/tests/run.py b/tasks/construct-mc-all-interval-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-all-interval-l6-s6/tests/test.sh b/tasks/construct-mc-all-interval-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-all-interval-l6-s8/environment/Dockerfile b/tasks/construct-mc-all-interval-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-all-interval-l6-s8/environment/instance.json b/tasks/construct-mc-all-interval-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5a108402e6d2cd845e65875c8f54773edb2d254c --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 88, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s8/solution/solve.sh b/tasks/construct-mc-all-interval-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..52e03533ceaac64572d1b988297c6883aba33233 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 87, 1, 86, 2, 85, 3, 84, 4, 83, 5, 82, 6, 81, 7, 80, 8, 79, 9, 78, 10, 77, 11, 76, 12, 75, 13, 74, 14, 73, 15, 72, 16, 71, 17, 70, 18, 69, 19, 68, 20, 67, 21, 66, 22, 65, 23, 64, 24, 63, 25, 62, 26, 61, 27, 60, 28, 59, 29, 58, 30, 57, 31, 56, 32, 55, 33, 54, 34, 53, 35, 52, 36, 51, 37, 50, 38, 49, 39, 48, 40, 47, 41, 46, 42, 45, 43, 44]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l6-s8/tests/check.py b/tasks/construct-mc-all-interval-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s8/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l6-s8/tests/instance.json b/tasks/construct-mc-all-interval-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5a108402e6d2cd845e65875c8f54773edb2d254c --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 88, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s8/tests/run.py b/tasks/construct-mc-all-interval-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-all-interval-l6-s8/tests/test.sh b/tasks/construct-mc-all-interval-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-bibd-l1-s2/environment/Dockerfile b/tasks/construct-mc-bibd-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-bibd-l1-s2/environment/instance.json b/tasks/construct-mc-bibd-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..20f229107651d6bcdb5c2cfb485469306df88a29 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"v": 9, "k": 3, "lambda": 1, "b": 12, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l1-s2/solution/solve.sh b/tasks/construct-mc-bibd-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..63b42fafa19bda612396b77b7db7757fd227070d --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"blocks": [[0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [1, 5, 6], [2, 3, 7], [0, 5, 7], [1, 3, 8], [2, 4, 6], [0, 1, 2], [3, 4, 5], [6, 7, 8]]} +RLMATH_EOF diff --git a/tasks/construct-mc-bibd-l1-s2/tests/check.py b/tasks/construct-mc-bibd-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c4b5da62477026f27ff9869fe33602fcc41e2ea9 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s2/tests/check.py @@ -0,0 +1,25 @@ +"""Balanced incomplete block design BIBD(v, k, lambda) (MathConstraint bibd, CC-BY-4.0). +Answer = list of b blocks; every block is a k-subset of {0..v-1}, every pair of points lies in exactly +lambda blocks (which forces every point to lie in r blocks). Repeated blocks are allowed, as upstream +(its 0/1 incidence-matrix model does not forbid equal columns).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + v, k, lam, b = inst["v"], inst["k"], inst["lambda"], inst["b"] + blocks = ans.get("blocks") + if not isinstance(blocks, list) or len(blocks) != b: + raise Invalid(f"blocks must be a list of exactly {b} blocks") + pair = {} + for B in blocks: + B = int_list(B, k, 0, v - 1, "block") + if len(set(B)) != k: + raise Invalid("a block contains a repeated point") + for p in itertools.combinations(sorted(B), 2): + pair[p] = pair.get(p, 0) + 1 + for p in itertools.combinations(range(v), 2): + if pair.get(p, 0) != lam: + raise Invalid(f"points {p} lie together in {pair.get(p, 0)} blocks, need {lam}") + return None, {} diff --git a/tasks/construct-mc-bibd-l1-s2/tests/instance.json b/tasks/construct-mc-bibd-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..20f229107651d6bcdb5c2cfb485469306df88a29 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"v": 9, "k": 3, "lambda": 1, "b": 12, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l1-s2/tests/run.py b/tasks/construct-mc-bibd-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-bibd-l1-s2/tests/test.sh b/tasks/construct-mc-bibd-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-costas-array-l4-s1/environment/Dockerfile b/tasks/construct-mc-costas-array-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-costas-array-l4-s1/environment/instance.json b/tasks/construct-mc-costas-array-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5b43c43c751d218ef6426d9240915272407d995b --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 17, "fixed": [], "family": "mc_costas_array", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-costas-array-l4-s1/solution/solve.sh b/tasks/construct-mc-costas-array-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9096b5d8d443a16dc21fe7172338dcdc8c7de2a9 --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [5, 4, 2, 15, 1, 11, 6, 12, 13, 10, 0, 14, 8, 16, 3, 7, 9]} +RLMATH_EOF diff --git a/tasks/construct-mc-costas-array-l4-s1/tests/check.py b/tasks/construct-mc-costas-array-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c86323a5b639b23787ecd4d5f358b986bbd91b6c --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s1/tests/check.py @@ -0,0 +1,22 @@ +"""Costas array of order n (MathConstraint costas_array, CC-BY-4.0). Accepts any valid array. +Adapted from pilot/grader.py check_costas; adds the optional fixed entries (upstream partial assignment).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + for name, i, v in inst.get("fixed", []): + if x[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + vecs = set() + for i, j in itertools.combinations(range(n), 2): + d = (j - i, x[j] - x[i]) + if d in vecs: + raise Invalid(f"repeated displacement vector {d}") + vecs.add(d) + return None, {} diff --git a/tasks/construct-mc-costas-array-l4-s1/tests/instance.json b/tasks/construct-mc-costas-array-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5b43c43c751d218ef6426d9240915272407d995b --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 17, "fixed": [], "family": "mc_costas_array", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-costas-array-l4-s1/tests/run.py b/tasks/construct-mc-costas-array-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-costas-array-l4-s1/tests/test.sh b/tasks/construct-mc-costas-array-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-debruijn-l1-s2/environment/Dockerfile b/tasks/construct-mc-debruijn-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-debruijn-l1-s2/environment/instance.json b/tasks/construct-mc-debruijn-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aab634ff0f8f60d7745f816c33ee521620c618f6 --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"b": 3, "n": 2, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l1-s2/solution/solve.sh b/tasks/construct-mc-debruijn-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..db7e6f9dd36b8466504c34bcdbfcaf89881b8b6b --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [0, 0, 1, 0, 2, 1, 1, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-debruijn-l1-s2/tests/check.py b/tasks/construct-mc-debruijn-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c9d6f0177d2b3bde8306d74939ee9704c1501a23 --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s2/tests/check.py @@ -0,0 +1,15 @@ +"""De Bruijn sequence B(b, n) (MathConstraint debruijn, CC-BY-4.0). Accepts any valid cyclic sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + b, n = inst["b"], inst["n"] + m = b ** n + x = int_list(ans.get("seq"), m, 0, b - 1, "seq") + seen = set() + for i in range(m): + w = tuple(x[(i + k) % m] for k in range(n)) + if w in seen: + raise Invalid(f"window {w} occurs twice") + seen.add(w) + return None, {} diff --git a/tasks/construct-mc-debruijn-l1-s2/tests/instance.json b/tasks/construct-mc-debruijn-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aab634ff0f8f60d7745f816c33ee521620c618f6 --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"b": 3, "n": 2, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l1-s2/tests/run.py b/tasks/construct-mc-debruijn-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-debruijn-l1-s2/tests/test.sh b/tasks/construct-mc-debruijn-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-debruijn-l5-s3/environment/Dockerfile b/tasks/construct-mc-debruijn-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-debruijn-l5-s3/environment/instance.json b/tasks/construct-mc-debruijn-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9238aeca27d1cf36f3fe9a9aebcfea9066595a0a --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"b": 5, "n": 4, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l5-s3/solution/solve.sh b/tasks/construct-mc-debruijn-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..15ea29c6c57e8e6abab913da9abe743f1bd6427e --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 1, 1, 0, 0, 1, 2, 0, 0, 1, 3, 0, 0, 1, 4, 0, 0, 2, 1, 0, 0, 2, 2, 0, 0, 2, 3, 0, 0, 2, 4, 0, 0, 3, 1, 0, 0, 3, 2, 0, 0, 3, 3, 0, 0, 3, 4, 0, 0, 4, 1, 0, 0, 4, 2, 0, 0, 4, 3, 0, 0, 4, 4, 0, 1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 4, 0, 1, 1, 1, 0, 1, 1, 2, 0, 1, 1, 3, 0, 1, 1, 4, 0, 1, 2, 1, 0, 1, 2, 2, 0, 1, 2, 3, 0, 1, 2, 4, 0, 1, 3, 1, 0, 1, 3, 2, 0, 1, 3, 3, 0, 1, 3, 4, 0, 1, 4, 1, 0, 1, 4, 2, 0, 1, 4, 3, 0, 1, 4, 4, 0, 2, 0, 2, 0, 3, 0, 2, 0, 4, 0, 2, 1, 1, 0, 2, 1, 2, 0, 2, 1, 3, 0, 2, 1, 4, 0, 2, 2, 1, 0, 2, 2, 2, 0, 2, 2, 3, 0, 2, 2, 4, 0, 2, 3, 1, 0, 2, 3, 2, 0, 2, 3, 3, 0, 2, 3, 4, 0, 2, 4, 1, 0, 2, 4, 2, 0, 2, 4, 3, 0, 2, 4, 4, 0, 3, 0, 3, 0, 4, 0, 3, 1, 1, 0, 3, 1, 2, 0, 3, 1, 3, 0, 3, 1, 4, 0, 3, 2, 1, 0, 3, 2, 2, 0, 3, 2, 3, 0, 3, 2, 4, 0, 3, 3, 1, 0, 3, 3, 2, 0, 3, 3, 3, 0, 3, 3, 4, 0, 3, 4, 1, 0, 3, 4, 2, 0, 3, 4, 3, 0, 3, 4, 4, 0, 4, 0, 4, 1, 1, 0, 4, 1, 2, 0, 4, 1, 3, 0, 4, 1, 4, 0, 4, 2, 1, 0, 4, 2, 2, 0, 4, 2, 3, 0, 4, 2, 4, 0, 4, 3, 1, 0, 4, 3, 2, 0, 4, 3, 3, 0, 4, 3, 4, 0, 4, 4, 1, 0, 4, 4, 2, 0, 4, 4, 3, 0, 4, 4, 4, 1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 4, 1, 1, 2, 2, 1, 1, 2, 3, 1, 1, 2, 4, 1, 1, 3, 2, 1, 1, 3, 3, 1, 1, 3, 4, 1, 1, 4, 2, 1, 1, 4, 3, 1, 1, 4, 4, 1, 2, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 2, 2, 1, 2, 2, 3, 1, 2, 2, 4, 1, 2, 3, 2, 1, 2, 3, 3, 1, 2, 3, 4, 1, 2, 4, 2, 1, 2, 4, 3, 1, 2, 4, 4, 1, 3, 1, 3, 1, 4, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 2, 4, 1, 3, 3, 2, 1, 3, 3, 3, 1, 3, 3, 4, 1, 3, 4, 2, 1, 3, 4, 3, 1, 3, 4, 4, 1, 4, 1, 4, 2, 2, 1, 4, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 1, 4, 3, 3, 1, 4, 3, 4, 1, 4, 4, 2, 1, 4, 4, 3, 1, 4, 4, 4, 2, 2, 2, 2, 3, 2, 2, 2, 4, 2, 2, 3, 3, 2, 2, 3, 4, 2, 2, 4, 3, 2, 2, 4, 4, 2, 3, 2, 3, 2, 4, 2, 3, 3, 3, 2, 3, 3, 4, 2, 3, 4, 3, 2, 3, 4, 4, 2, 4, 2, 4, 3, 3, 2, 4, 3, 4, 2, 4, 4, 3, 2, 4, 4, 4, 3, 3, 3, 3, 4, 3, 3, 4, 4, 3, 4, 3, 4, 4, 4, 4]} +RLMATH_EOF diff --git a/tasks/construct-mc-debruijn-l5-s3/tests/check.py b/tasks/construct-mc-debruijn-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c9d6f0177d2b3bde8306d74939ee9704c1501a23 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s3/tests/check.py @@ -0,0 +1,15 @@ +"""De Bruijn sequence B(b, n) (MathConstraint debruijn, CC-BY-4.0). Accepts any valid cyclic sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + b, n = inst["b"], inst["n"] + m = b ** n + x = int_list(ans.get("seq"), m, 0, b - 1, "seq") + seen = set() + for i in range(m): + w = tuple(x[(i + k) % m] for k in range(n)) + if w in seen: + raise Invalid(f"window {w} occurs twice") + seen.add(w) + return None, {} diff --git a/tasks/construct-mc-debruijn-l5-s3/tests/instance.json b/tasks/construct-mc-debruijn-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9238aeca27d1cf36f3fe9a9aebcfea9066595a0a --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"b": 5, "n": 4, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l5-s3/tests/run.py b/tasks/construct-mc-debruijn-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-debruijn-l5-s3/tests/test.sh b/tasks/construct-mc-debruijn-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graceful-graph-l1-s1/environment/Dockerfile b/tasks/construct-mc-graceful-graph-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graceful-graph-l1-s1/environment/instance.json b/tasks/construct-mc-graceful-graph-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e57a7f430aae09e3bc886b8b0c93bfb5c842d7a7 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"k": 2, "p": 6, "num_vertices": 12, "edges": [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]], "fixed": [["labels", 0, 6], ["labels", 3, 4], ["d", 10, 11], ["d", 14, 1], ["d", 15, 12]], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l1-s1/solution/solve.sh b/tasks/construct-mc-graceful-graph-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6bd043a8b16043c556533c365c8d533a5ddd5dbf --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"labels": [6, 14, 9, 4, 5, 11, 16, 2, 0, 15, 1, 3]} +RLMATH_EOF diff --git a/tasks/construct-mc-graceful-graph-l1-s1/tests/check.py b/tasks/construct-mc-graceful-graph-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f4d33af1d63c0495c3b32d34db6ae10f0fb45923 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s1/tests/check.py @@ -0,0 +1,19 @@ +"""Graceful labelling of K_k x P_p (MathConstraint graceful_graph, CC-BY-4.0): distinct vertex labels in +0..m (m = number of edges) whose edge differences |l(u) - l(v)| are all distinct.""" +from run import Invalid, int_list + + +def check(inst, ans): + nv, edges = inst["num_vertices"], inst["edges"] + m = len(edges) + x = int_list(ans.get("labels"), nv, 0, m, "labels") + if len(set(x)) != nv: + raise Invalid("vertex labels must be distinct") + d = [abs(x[u] - x[v]) for u, v in edges] + if len(set(d)) != m: + raise Invalid("edge labels are not distinct") + seqs = {"labels": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-graceful-graph-l1-s1/tests/instance.json b/tasks/construct-mc-graceful-graph-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e57a7f430aae09e3bc886b8b0c93bfb5c842d7a7 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"k": 2, "p": 6, "num_vertices": 12, "edges": [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]], "fixed": [["labels", 0, 6], ["labels", 3, 4], ["d", 10, 11], ["d", 14, 1], ["d", 15, 12]], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l1-s1/tests/run.py b/tasks/construct-mc-graceful-graph-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graceful-graph-l1-s1/tests/test.sh b/tasks/construct-mc-graceful-graph-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graceful-graph-l5-s0/environment/Dockerfile b/tasks/construct-mc-graceful-graph-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graceful-graph-l5-s0/environment/instance.json b/tasks/construct-mc-graceful-graph-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e3e1d054f51f0e78d63c58377ae7b4d2a3b88c24 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"k": 4, "p": 4, "num_vertices": 16, "edges": [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l5-s0/solution/solve.sh b/tasks/construct-mc-graceful-graph-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2709e25d5709eff5e7c06b1c1dd2d9a66db04de7 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"labels": [14, 9, 25, 35, 6, 31, 12, 3, 2, 4, 19, 33, 36, 24, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-graceful-graph-l5-s0/tests/check.py b/tasks/construct-mc-graceful-graph-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f4d33af1d63c0495c3b32d34db6ae10f0fb45923 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s0/tests/check.py @@ -0,0 +1,19 @@ +"""Graceful labelling of K_k x P_p (MathConstraint graceful_graph, CC-BY-4.0): distinct vertex labels in +0..m (m = number of edges) whose edge differences |l(u) - l(v)| are all distinct.""" +from run import Invalid, int_list + + +def check(inst, ans): + nv, edges = inst["num_vertices"], inst["edges"] + m = len(edges) + x = int_list(ans.get("labels"), nv, 0, m, "labels") + if len(set(x)) != nv: + raise Invalid("vertex labels must be distinct") + d = [abs(x[u] - x[v]) for u, v in edges] + if len(set(d)) != m: + raise Invalid("edge labels are not distinct") + seqs = {"labels": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-graceful-graph-l5-s0/tests/instance.json b/tasks/construct-mc-graceful-graph-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e3e1d054f51f0e78d63c58377ae7b4d2a3b88c24 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"k": 4, "p": 4, "num_vertices": 16, "edges": [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l5-s0/tests/run.py b/tasks/construct-mc-graceful-graph-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graceful-graph-l5-s0/tests/test.sh b/tasks/construct-mc-graceful-graph-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l1-s8/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graph-k-coloring-l1-s8/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f03d6d576c025a20227af64df56cc2fea3c32b4c --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 7], [0, 8], [0, 9], [0, 11], [0, 13], [1, 7], [1, 9], [1, 17], [2, 16], [3, 6], [3, 8], [3, 9], [3, 14], [4, 13], [5, 6], [5, 16], [5, 19], [7, 13], [7, 18], [8, 19], [9, 10], [9, 12], [9, 16], [9, 19], [11, 12], [11, 17], [12, 13], [12, 15], [12, 17], [14, 19]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s8/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..28cf9e34ae0cf36b6f488da6c7a386c07d8e1a3e --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 1, 1, 1, 0, 0, 2, 0, 0, 0, 1, 0, 1, 2, 0, 2, 2, 2, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l1-s8/tests/check.py b/tasks/construct-mc-graph-k-coloring-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s8/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l1-s8/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f03d6d576c025a20227af64df56cc2fea3c32b4c --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 7], [0, 8], [0, 9], [0, 11], [0, 13], [1, 7], [1, 9], [1, 17], [2, 16], [3, 6], [3, 8], [3, 9], [3, 14], [4, 13], [5, 6], [5, 16], [5, 19], [7, 13], [7, 18], [8, 19], [9, 10], [9, 12], [9, 16], [9, 19], [11, 12], [11, 17], [12, 13], [12, 15], [12, 17], [14, 19]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s8/tests/run.py b/tasks/construct-mc-graph-k-coloring-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graph-k-coloring-l1-s8/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l5-s7/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graph-k-coloring-l5-s7/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c9e9c6072d072c418717d71ce29b5c0125d16983 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 10], [0, 16], [0, 41], [0, 45], [0, 57], [0, 65], [0, 73], [0, 76], [0, 79], [1, 9], [1, 13], [1, 18], [1, 21], [1, 38], [1, 58], [2, 24], [2, 56], [2, 60], [2, 82], [3, 13], [3, 19], [3, 57], [4, 27], [4, 43], [4, 49], [4, 76], [4, 87], [4, 92], [5, 35], [5, 36], [5, 43], [5, 47], [5, 60], [5, 67], [5, 76], [5, 80], [5, 83], [5, 84], [5, 85], [5, 93], [5, 97], [5, 98], [6, 32], [6, 35], [6, 38], [6, 52], [6, 62], [6, 69], [6, 71], [6, 87], [6, 98], [7, 80], [7, 81], [7, 87], [7, 90], [7, 98], [8, 22], [8, 29], [8, 30], [8, 70], [8, 71], [8, 75], [8, 95], [8, 96], [9, 16], [9, 30], [9, 48], [9, 52], [9, 54], [9, 57], [9, 61], [9, 71], [9, 78], [9, 89], [9, 93], [10, 20], [10, 43], [10, 50], [10, 81], [10, 83], [10, 94], [11, 15], [11, 20], [11, 24], [11, 29], [11, 31], [11, 41], [11, 47], [11, 54], [11, 57], [11, 85], [11, 88], [12, 23], [12, 43], [12, 89], [13, 33], [13, 48], [13, 73], [13, 76], [13, 81], [13, 83], [13, 85], [13, 86], [14, 16], [14, 47], [14, 50], [14, 51], [14, 59], [14, 75], [14, 85], [15, 18], [15, 25], [15, 29], [15, 34], [15, 39], [15, 44], [15, 58], [15, 77], [16, 41], [16, 63], [16, 74], [16, 90], [17, 34], [17, 49], [17, 51], [17, 88], [18, 23], [18, 40], [18, 44], [18, 48], [18, 73], [18, 77], [18, 84], [19, 21], [19, 23], [19, 25], [19, 35], [19, 62], [19, 65], [19, 77], [19, 92], [20, 22], [20, 35], [20, 36], [20, 49], [20, 52], [20, 65], [20, 72], [20, 76], [20, 82], [20, 86], [20, 99], [21, 23], [21, 27], [21, 34], [21, 39], [21, 58], [21, 66], [22, 32], [22, 56], [22, 57], [22, 59], [22, 71], [22, 84], [23, 33], [23, 38], [23, 47], [23, 50], [23, 63], [23, 66], [23, 82], [23, 84], [23, 93], [23, 99], [24, 41], [24, 45], [24, 52], [24, 62], [25, 35], [25, 53], [25, 67], [25, 74], [25, 76], [25, 80], [25, 97], [25, 99], [26, 28], [26, 42], [26, 76], [26, 77], [26, 80], [26, 84], [26, 95], [27, 35], [27, 42], [27, 45], [27, 56], [27, 79], [27, 96], [28, 41], [28, 45], [28, 48], [28, 51], [28, 65], [28, 80], [28, 81], [28, 87], [29, 36], [29, 56], [29, 79], [29, 80], [30, 31], [30, 33], [30, 46], [30, 60], [31, 43], [31, 51], [31, 59], [31, 70], [31, 78], [32, 41], [32, 42], [32, 47], [32, 55], [32, 67], [32, 83], [32, 85], [33, 69], [33, 73], [33, 95], [33, 98], [34, 52], [34, 65], [34, 82], [35, 39], [35, 56], [35, 80], [35, 81], [36, 50], [36, 60], [36, 63], [36, 70], [36, 75], [36, 79], [36, 84], [36, 92], [37, 54], [37, 67], [37, 72], [37, 89], [38, 73], [38, 74], [38, 79], [39, 40], [39, 74], [39, 77], [39, 83], [39, 98], [39, 99], [40, 41], [40, 61], [40, 62], [40, 75], [40, 92], [41, 64], [41, 68], [41, 73], [41, 80], [42, 48], [42, 60], [43, 50], [43, 59], [43, 64], [43, 68], [43, 70], [43, 84], [43, 88], [43, 90], [44, 49], [44, 50], [44, 75], [44, 96], [45, 57], [45, 65], [45, 75], [45, 84], [46, 75], [46, 96], [46, 99], [47, 75], [47, 80], [48, 54], [48, 75], [48, 90], [49, 51], [49, 55], [50, 78], [50, 88], [50, 91], [51, 64], [51, 77], [51, 85], [51, 88], [52, 60], [52, 66], [52, 78], [52, 82], [52, 96], [53, 55], [53, 75], [53, 84], [54, 65], [54, 87], [54, 88], [54, 94], [55, 60], [55, 95], [56, 65], [56, 76], [56, 78], [56, 88], [56, 90], [57, 76], [57, 78], [58, 68], [58, 73], [58, 74], [59, 61], [59, 71], [59, 73], [59, 79], [60, 62], [60, 76], [60, 82], [61, 82], [61, 85], [61, 92], [61, 93], [61, 97], [61, 98], [62, 63], [62, 69], [62, 71], [62, 81], [63, 73], [63, 89], [64, 66], [64, 76], [64, 89], [64, 96], [65, 81], [65, 86], [65, 89], [65, 90], [66, 69], [66, 73], [66, 74], [67, 73], [67, 75], [67, 89], [68, 72], [68, 74], [68, 82], [68, 86], [69, 85], [70, 76], [71, 73], [71, 85], [71, 99], [72, 88], [72, 89], [72, 94], [72, 98], [74, 75], [74, 89], [74, 97], [75, 80], [75, 98], [76, 86], [76, 93], [76, 96], [76, 98], [77, 95], [77, 98], [78, 79], [78, 98], [79, 90], [80, 92], [81, 88], [82, 87], [85, 98], [87, 89], [87, 93], [87, 99], [88, 91], [89, 99], [91, 92], [92, 94], [97, 98], [98, 99]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s7/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ac881b4b5b8b4df97424239d7e4ddb24f4c1499d --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [2, 0, 0, 2, 3, 1, 1, 1, 0, 1, 1, 0, 2, 3, 0, 2, 3, 0, 1, 3, 3, 2, 1, 0, 3, 1, 1, 1, 2, 1, 2, 3, 3, 1, 3, 2, 0, 0, 2, 1, 3, 1, 2, 0, 0, 0, 0, 2, 0, 2, 3, 1, 0, 3, 3, 1, 3, 3, 1, 2, 3, 0, 2, 1, 2, 1, 1, 2, 3, 3, 1, 3, 1, 0, 0, 1, 0, 0, 2, 3, 0, 0, 1, 2, 2, 2, 2, 0, 2, 3, 2, 0, 1, 3, 0, 3, 3, 2, 3, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l5-s7/tests/check.py b/tasks/construct-mc-graph-k-coloring-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s7/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l5-s7/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c9e9c6072d072c418717d71ce29b5c0125d16983 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 10], [0, 16], [0, 41], [0, 45], [0, 57], [0, 65], [0, 73], [0, 76], [0, 79], [1, 9], [1, 13], [1, 18], [1, 21], [1, 38], [1, 58], [2, 24], [2, 56], [2, 60], [2, 82], [3, 13], [3, 19], [3, 57], [4, 27], [4, 43], [4, 49], [4, 76], [4, 87], [4, 92], [5, 35], [5, 36], [5, 43], [5, 47], [5, 60], [5, 67], [5, 76], [5, 80], [5, 83], [5, 84], [5, 85], [5, 93], [5, 97], [5, 98], [6, 32], [6, 35], [6, 38], [6, 52], [6, 62], [6, 69], [6, 71], [6, 87], [6, 98], [7, 80], [7, 81], [7, 87], [7, 90], [7, 98], [8, 22], [8, 29], [8, 30], [8, 70], [8, 71], [8, 75], [8, 95], [8, 96], [9, 16], [9, 30], [9, 48], [9, 52], [9, 54], [9, 57], [9, 61], [9, 71], [9, 78], [9, 89], [9, 93], [10, 20], [10, 43], [10, 50], [10, 81], [10, 83], [10, 94], [11, 15], [11, 20], [11, 24], [11, 29], [11, 31], [11, 41], [11, 47], [11, 54], [11, 57], [11, 85], [11, 88], [12, 23], [12, 43], [12, 89], [13, 33], [13, 48], [13, 73], [13, 76], [13, 81], [13, 83], [13, 85], [13, 86], [14, 16], [14, 47], [14, 50], [14, 51], [14, 59], [14, 75], [14, 85], [15, 18], [15, 25], [15, 29], [15, 34], [15, 39], [15, 44], [15, 58], [15, 77], [16, 41], [16, 63], [16, 74], [16, 90], [17, 34], [17, 49], [17, 51], [17, 88], [18, 23], [18, 40], [18, 44], [18, 48], [18, 73], [18, 77], [18, 84], [19, 21], [19, 23], [19, 25], [19, 35], [19, 62], [19, 65], [19, 77], [19, 92], [20, 22], [20, 35], [20, 36], [20, 49], [20, 52], [20, 65], [20, 72], [20, 76], [20, 82], [20, 86], [20, 99], [21, 23], [21, 27], [21, 34], [21, 39], [21, 58], [21, 66], [22, 32], [22, 56], [22, 57], [22, 59], [22, 71], [22, 84], [23, 33], [23, 38], [23, 47], [23, 50], [23, 63], [23, 66], [23, 82], [23, 84], [23, 93], [23, 99], [24, 41], [24, 45], [24, 52], [24, 62], [25, 35], [25, 53], [25, 67], [25, 74], [25, 76], [25, 80], [25, 97], [25, 99], [26, 28], [26, 42], [26, 76], [26, 77], [26, 80], [26, 84], [26, 95], [27, 35], [27, 42], [27, 45], [27, 56], [27, 79], [27, 96], [28, 41], [28, 45], [28, 48], [28, 51], [28, 65], [28, 80], [28, 81], [28, 87], [29, 36], [29, 56], [29, 79], [29, 80], [30, 31], [30, 33], [30, 46], [30, 60], [31, 43], [31, 51], [31, 59], [31, 70], [31, 78], [32, 41], [32, 42], [32, 47], [32, 55], [32, 67], [32, 83], [32, 85], [33, 69], [33, 73], [33, 95], [33, 98], [34, 52], [34, 65], [34, 82], [35, 39], [35, 56], [35, 80], [35, 81], [36, 50], [36, 60], [36, 63], [36, 70], [36, 75], [36, 79], [36, 84], [36, 92], [37, 54], [37, 67], [37, 72], [37, 89], [38, 73], [38, 74], [38, 79], [39, 40], [39, 74], [39, 77], [39, 83], [39, 98], [39, 99], [40, 41], [40, 61], [40, 62], [40, 75], [40, 92], [41, 64], [41, 68], [41, 73], [41, 80], [42, 48], [42, 60], [43, 50], [43, 59], [43, 64], [43, 68], [43, 70], [43, 84], [43, 88], [43, 90], [44, 49], [44, 50], [44, 75], [44, 96], [45, 57], [45, 65], [45, 75], [45, 84], [46, 75], [46, 96], [46, 99], [47, 75], [47, 80], [48, 54], [48, 75], [48, 90], [49, 51], [49, 55], [50, 78], [50, 88], [50, 91], [51, 64], [51, 77], [51, 85], [51, 88], [52, 60], [52, 66], [52, 78], [52, 82], [52, 96], [53, 55], [53, 75], [53, 84], [54, 65], [54, 87], [54, 88], [54, 94], [55, 60], [55, 95], [56, 65], [56, 76], [56, 78], [56, 88], [56, 90], [57, 76], [57, 78], [58, 68], [58, 73], [58, 74], [59, 61], [59, 71], [59, 73], [59, 79], [60, 62], [60, 76], [60, 82], [61, 82], [61, 85], [61, 92], [61, 93], [61, 97], [61, 98], [62, 63], [62, 69], [62, 71], [62, 81], [63, 73], [63, 89], [64, 66], [64, 76], [64, 89], [64, 96], [65, 81], [65, 86], [65, 89], [65, 90], [66, 69], [66, 73], [66, 74], [67, 73], [67, 75], [67, 89], [68, 72], [68, 74], [68, 82], [68, 86], [69, 85], [70, 76], [71, 73], [71, 85], [71, 99], [72, 88], [72, 89], [72, 94], [72, 98], [74, 75], [74, 89], [74, 97], [75, 80], [75, 98], [76, 86], [76, 93], [76, 96], [76, 98], [77, 95], [77, 98], [78, 79], [78, 98], [79, 90], [80, 92], [81, 88], [82, 87], [85, 98], [87, 89], [87, 93], [87, 99], [88, 91], [89, 99], [91, 92], [92, 94], [97, 98], [98, 99]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s7/tests/run.py b/tasks/construct-mc-graph-k-coloring-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graph-k-coloring-l5-s7/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-hadamard-l1-s1/environment/Dockerfile b/tasks/construct-mc-hadamard-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-hadamard-l1-s1/environment/instance.json b/tasks/construct-mc-hadamard-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dd52438a66ed070129985b9eee676dfd7b50dee2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 7, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l1-s1/solution/solve.sh b/tasks/construct-mc-hadamard-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..64e85414e235c9f6e206101948ae1e2fdacbf1fd --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [1, 1, 1, -1, 1, -1, -1], "y": [1, 1, 1, -1, 1, -1, -1]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l1-s1/tests/check.py b/tasks/construct-mc-hadamard-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s1/tests/check.py @@ -0,0 +1,18 @@ +"""Legendre pair of odd length n (MathConstraint hadamard, CC-BY-4.0): x, y in {-1,+1}^n with +sum(x) = sum(y) = 1 and PAF_x(k) + PAF_y(k) = -2 for k = 1..(n-1)/2 (periodic autocorrelation).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, -1, 1, "x") + y = int_list(ans.get("y"), n, -1, 1, "y") + if 0 in x or 0 in y: + raise Invalid("entries must be -1 or +1") + if sum(x) != 1 or sum(y) != 1: + raise Invalid("sum(x) and sum(y) must both equal 1") + for k in range(1, (n - 1) // 2 + 1): + p = sum(x[i] * x[(i + k) % n] for i in range(n)) + sum(y[i] * y[(i + k) % n] for i in range(n)) + if p != -2: + raise Invalid(f"PAF_x({k}) + PAF_y({k}) = {p}, need -2") + return None, {} diff --git a/tasks/construct-mc-hadamard-l1-s1/tests/instance.json b/tasks/construct-mc-hadamard-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dd52438a66ed070129985b9eee676dfd7b50dee2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 7, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l1-s1/tests/run.py b/tasks/construct-mc-hadamard-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-hadamard-l1-s1/tests/test.sh b/tasks/construct-mc-hadamard-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-hadamard-l5-s0/environment/Dockerfile b/tasks/construct-mc-hadamard-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-hadamard-l5-s0/environment/instance.json b/tasks/construct-mc-hadamard-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae0600574971fefe3b76803caffe67abe2f2f8b3 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 37, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l5-s0/solution/solve.sh b/tasks/construct-mc-hadamard-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9201507d54d622357d977a788485994d895a7295 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1], "y": [1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l5-s0/tests/check.py b/tasks/construct-mc-hadamard-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s0/tests/check.py @@ -0,0 +1,18 @@ +"""Legendre pair of odd length n (MathConstraint hadamard, CC-BY-4.0): x, y in {-1,+1}^n with +sum(x) = sum(y) = 1 and PAF_x(k) + PAF_y(k) = -2 for k = 1..(n-1)/2 (periodic autocorrelation).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, -1, 1, "x") + y = int_list(ans.get("y"), n, -1, 1, "y") + if 0 in x or 0 in y: + raise Invalid("entries must be -1 or +1") + if sum(x) != 1 or sum(y) != 1: + raise Invalid("sum(x) and sum(y) must both equal 1") + for k in range(1, (n - 1) // 2 + 1): + p = sum(x[i] * x[(i + k) % n] for i in range(n)) + sum(y[i] * y[(i + k) % n] for i in range(n)) + if p != -2: + raise Invalid(f"PAF_x({k}) + PAF_y({k}) = {p}, need -2") + return None, {} diff --git a/tasks/construct-mc-hadamard-l5-s0/tests/instance.json b/tasks/construct-mc-hadamard-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae0600574971fefe3b76803caffe67abe2f2f8b3 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 37, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l5-s0/tests/run.py b/tasks/construct-mc-hadamard-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-hadamard-l5-s0/tests/test.sh b/tasks/construct-mc-hadamard-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-langford-l1-s0/environment/Dockerfile b/tasks/construct-mc-langford-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-langford-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-langford-l1-s0/environment/instance.json b/tasks/construct-mc-langford-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c0d6fc7e7c30e2015691a7b776965f84c75ef88d --- /dev/null +++ b/tasks/construct-mc-langford-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 7, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l1-s0/solution/solve.sh b/tasks/construct-mc-langford-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bf9017d5f1bfaa5161b9239cc3b0b2ff87b2d596 --- /dev/null +++ b/tasks/construct-mc-langford-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [1, 7, 1, 2, 5, 6, 2, 3, 4, 7, 5, 3, 6, 4]} +RLMATH_EOF diff --git a/tasks/construct-mc-langford-l1-s0/tests/check.py b/tasks/construct-mc-langford-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4672d7eacf321991933cb280d6c940f1c4a67935 --- /dev/null +++ b/tasks/construct-mc-langford-l1-s0/tests/check.py @@ -0,0 +1,17 @@ +"""Langford sequence L(2, n) (MathConstraint langford, CC-BY-4.0). Accepts any valid sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + seq = int_list(ans.get("seq"), 2 * n, 1, n, "seq") + for v in range(1, n + 1): + pos = [i for i, s in enumerate(seq) if s == v] + if len(pos) != 2: + raise Invalid(f"value {v} occurs {len(pos)} times (need exactly 2)") + if pos[1] - pos[0] != v + 1: + raise Invalid(f"the two copies of {v} are {pos[1] - pos[0]} positions apart (need {v + 1})") + for name, i, v in inst.get("fixed", []): + if seq[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-langford-l1-s0/tests/instance.json b/tasks/construct-mc-langford-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c0d6fc7e7c30e2015691a7b776965f84c75ef88d --- /dev/null +++ b/tasks/construct-mc-langford-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 7, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l1-s0/tests/run.py b/tasks/construct-mc-langford-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-langford-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-langford-l1-s0/tests/test.sh b/tasks/construct-mc-langford-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-langford-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-langford-l5-s1/environment/Dockerfile b/tasks/construct-mc-langford-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-langford-l5-s1/environment/instance.json b/tasks/construct-mc-langford-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..72bc28b37247d72f19a16d35b08775daa33be064 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 31, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l5-s1/solution/solve.sh b/tasks/construct-mc-langford-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3236438e7a5347e56e1fe03a9ddbfeaa8db6743a --- /dev/null +++ b/tasks/construct-mc-langford-l5-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [31, 28, 6, 3, 29, 4, 11, 3, 2, 6, 4, 2, 16, 5, 26, 30, 22, 18, 11, 5, 17, 13, 14, 23, 27, 1, 24, 1, 19, 16, 28, 21, 31, 25, 29, 13, 18, 14, 17, 22, 20, 26, 15, 12, 10, 8, 30, 23, 19, 7, 9, 24, 27, 21, 8, 10, 12, 7, 15, 25, 9, 20]} +RLMATH_EOF diff --git a/tasks/construct-mc-langford-l5-s1/tests/check.py b/tasks/construct-mc-langford-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4672d7eacf321991933cb280d6c940f1c4a67935 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s1/tests/check.py @@ -0,0 +1,17 @@ +"""Langford sequence L(2, n) (MathConstraint langford, CC-BY-4.0). Accepts any valid sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + seq = int_list(ans.get("seq"), 2 * n, 1, n, "seq") + for v in range(1, n + 1): + pos = [i for i, s in enumerate(seq) if s == v] + if len(pos) != 2: + raise Invalid(f"value {v} occurs {len(pos)} times (need exactly 2)") + if pos[1] - pos[0] != v + 1: + raise Invalid(f"the two copies of {v} are {pos[1] - pos[0]} positions apart (need {v + 1})") + for name, i, v in inst.get("fixed", []): + if seq[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-langford-l5-s1/tests/instance.json b/tasks/construct-mc-langford-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..72bc28b37247d72f19a16d35b08775daa33be064 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 31, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l5-s1/tests/run.py b/tasks/construct-mc-langford-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-langford-l5-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-langford-l5-s1/tests/test.sh b/tasks/construct-mc-langford-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-clique-l3-s2/environment/Dockerfile b/tasks/construct-mc-max-clique-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-clique-l3-s2/environment/instance.json b/tasks/construct-mc-max-clique-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9502a9a445758d8643ccea03cd1d9433674956fb --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 58, "k": 5, "edges": [[0, 2], [0, 3], [0, 7], [0, 12], [0, 15], [0, 17], [0, 19], [0, 21], [0, 24], [0, 26], [0, 32], [0, 33], [0, 34], [0, 36], [0, 42], [0, 44], [0, 45], [0, 48], [0, 50], [0, 53], [0, 56], [0, 57], [1, 7], [1, 8], [1, 9], [1, 11], [1, 12], [1, 14], [1, 15], [1, 16], [1, 19], [1, 20], [1, 21], [1, 23], [1, 25], [1, 26], [1, 29], [1, 32], [1, 33], [1, 34], [1, 38], [1, 39], [1, 43], [1, 44], [1, 48], [1, 49], [1, 50], [1, 53], [1, 54], [2, 3], [2, 4], [2, 7], [2, 8], [2, 11], [2, 13], [2, 15], [2, 20], [2, 23], [2, 25], [2, 26], [2, 27], [2, 28], [2, 30], [2, 33], [2, 34], [2, 35], [2, 38], [2, 39], [2, 41], [2, 43], [2, 44], [2, 47], [2, 51], [2, 52], [2, 54], [2, 55], [2, 56], [3, 7], [3, 9], [3, 17], [3, 18], [3, 19], [3, 21], [3, 22], [3, 24], [3, 28], [3, 29], [3, 33], [3, 37], [3, 38], [3, 43], [3, 47], [3, 48], [3, 51], [3, 52], [3, 55], [3, 56], [4, 8], [4, 15], [4, 16], [4, 17], [4, 19], [4, 20], [4, 22], [4, 24], [4, 26], [4, 28], [4, 30], [4, 33], [4, 38], [4, 39], [4, 45], [4, 47], [4, 48], [4, 52], [4, 53], [4, 54], [4, 56], [4, 57], [5, 11], [5, 12], [5, 13], [5, 14], [5, 20], [5, 26], [5, 27], [5, 35], [5, 39], [5, 40], [5, 41], [5, 44], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 54], [5, 56], [6, 7], [6, 8], [6, 10], [6, 11], [6, 12], [6, 15], [6, 20], [6, 21], [6, 31], [6, 32], [6, 33], [6, 38], [6, 41], [6, 42], [6, 43], [6, 47], [6, 49], [6, 50], [6, 52], [6, 53], [6, 55], [7, 8], [7, 11], [7, 12], [7, 15], [7, 16], [7, 19], [7, 25], [7, 28], [7, 29], [7, 32], [7, 37], [7, 38], [7, 41], [7, 42], [7, 45], [7, 48], [7, 49], [7, 52], [7, 54], [7, 56], [8, 10], [8, 16], [8, 18], [8, 21], [8, 22], [8, 23], [8, 25], [8, 30], [8, 31], [8, 34], [8, 38], [8, 40], [8, 41], [8, 42], [8, 51], [8, 52], [8, 54], [8, 55], [8, 57], [9, 11], [9, 15], [9, 17], [9, 18], [9, 20], [9, 21], [9, 23], [9, 28], [9, 33], [9, 36], [9, 39], [9, 40], [9, 46], [9, 47], [9, 48], [9, 52], [9, 57], [10, 13], [10, 17], [10, 21], [10, 22], [10, 23], [10, 26], [10, 27], [10, 29], [10, 31], [10, 32], [10, 33], [10, 35], [10, 37], [10, 45], [10, 46], [10, 50], [10, 53], [10, 55], [11, 12], [11, 13], [11, 16], [11, 18], [11, 21], [11, 22], [11, 24], [11, 25], [11, 27], [11, 28], [11, 29], [11, 31], [11, 32], [11, 35], [11, 37], [11, 38], [11, 40], [11, 46], [11, 47], [11, 48], [11, 50], [11, 51], [11, 53], [11, 55], [12, 16], [12, 17], [12, 19], [12, 20], [12, 24], [12, 25], [12, 26], [12, 27], [12, 29], [12, 30], [12, 31], [12, 32], [12, 34], [12, 39], [12, 40], [12, 43], [12, 44], [12, 47], [12, 52], [12, 55], [13, 14], [13, 17], [13, 20], [13, 27], [13, 31], [13, 34], [13, 36], [13, 38], [13, 41], [13, 44], [13, 47], [13, 49], [13, 50], [13, 55], [14, 16], [14, 21], [14, 24], [14, 26], [14, 28], [14, 30], [14, 34], [14, 35], [14, 43], [14, 47], [14, 49], [14, 50], [14, 51], [14, 54], [14, 55], [14, 56], [14, 57], [15, 17], [15, 18], [15, 22], [15, 23], [15, 24], [15, 27], [15, 28], [15, 29], [15, 32], [15, 33], [15, 39], [15, 40], [15, 43], [15, 45], [15, 48], [15, 53], [15, 54], [15, 56], [16, 18], [16, 19], [16, 22], [16, 23], [16, 25], [16, 26], [16, 28], [16, 32], [16, 33], [16, 36], [16, 38], [16, 39], [16, 42], [16, 44], [16, 45], [16, 51], [16, 52], [16, 56], [17, 18], [17, 19], [17, 20], [17, 24], [17, 26], [17, 28], [17, 31], [17, 33], [17, 38], [17, 39], [17, 45], [17, 47], [17, 48], [17, 54], [18, 20], [18, 21], [18, 23], [18, 27], [18, 28], [18, 29], [18, 30], [18, 34], [18, 37], [18, 42], [18, 46], [18, 47], [18, 49], [18, 50], [18, 51], [18, 53], [18, 57], [19, 24], [19, 27], [19, 28], [19, 30], [19, 34], [19, 37], [19, 39], [19, 40], [19, 43], [19, 47], [19, 48], [19, 49], [19, 51], [19, 55], [19, 56], [19, 57], [20, 25], [20, 27], [20, 30], [20, 34], [20, 36], [20, 38], [20, 39], [20, 40], [20, 45], [20, 46], [20, 51], [20, 52], [20, 55], [20, 57], [21, 25], [21, 27], [21, 29], [21, 31], [21, 32], [21, 37], [21, 38], [21, 39], [21, 41], [21, 43], [21, 45], [21, 47], [21, 50], [21, 52], [21, 53], [21, 54], [21, 55], [21, 57], [22, 24], [22, 25], [22, 26], [22, 31], [22, 32], [22, 34], [22, 35], [22, 36], [22, 42], [22, 43], [22, 45], [22, 46], [22, 52], [22, 53], [22, 56], [23, 27], [23, 30], [23, 31], [23, 32], [23, 38], [23, 43], [23, 44], [23, 47], [23, 54], [23, 55], [24, 28], [24, 30], [24, 31], [24, 34], [24, 35], [24, 37], [24, 40], [24, 43], [24, 45], [24, 46], [24, 49], [24, 51], [25, 26], [25, 30], [25, 31], [25, 33], [25, 34], [25, 40], [25, 41], [25, 42], [25, 44], [25, 45], [25, 48], [25, 50], [25, 51], [25, 52], [25, 53], [26, 27], [26, 31], [26, 32], [26, 33], [26, 35], [26, 37], [26, 38], [26, 39], [26, 44], [26, 46], [26, 48], [26, 52], [27, 29], [27, 35], [27, 36], [27, 37], [27, 38], [27, 39], [27, 45], [27, 46], [27, 48], [27, 51], [27, 54], [27, 55], [27, 56], [28, 31], [28, 36], [28, 37], [28, 38], [28, 40], [28, 41], [28, 42], [28, 46], [28, 51], [28, 52], [28, 53], [28, 55], [29, 30], [29, 31], [29, 32], [29, 33], [29, 37], [29, 39], [29, 44], [29, 45], [29, 47], [29, 49], [29, 51], [29, 52], [29, 56], [30, 31], [30, 32], [30, 34], [30, 35], [30, 37], [30, 41], [30, 42], [30, 46], [30, 47], [30, 50], [30, 52], [30, 53], [30, 55], [30, 57], [31, 32], [31, 36], [31, 39], [31, 41], [31, 44], [31, 45], [31, 47], [31, 49], [31, 50], [31, 51], [31, 53], [31, 57], [32, 39], [32, 40], [32, 43], [32, 45], [32, 50], [32, 52], [32, 54], [33, 40], [33, 46], [33, 47], [33, 48], [33, 50], [33, 51], [33, 52], [33, 55], [34, 39], [34, 40], [34, 41], [34, 43], [34, 44], [34, 45], [34, 47], [34, 49], [34, 52], [34, 56], [35, 36], [35, 37], [35, 42], [35, 44], [35, 46], [35, 47], [35, 48], [35, 49], [35, 50], [35, 55], [35, 56], [36, 38], [36, 39], [36, 42], [36, 48], [36, 51], [36, 53], [36, 54], [36, 55], [36, 57], [37, 39], [37, 48], [38, 39], [38, 40], [38, 43], [38, 44], [38, 46], [38, 48], [38, 49], [38, 51], [39, 40], [39, 41], [39, 42], [39, 46], [39, 47], [39, 48], [39, 49], [39, 56], [39, 57], [40, 41], [40, 42], [40, 43], [40, 44], [40, 47], [40, 48], [40, 49], [40, 50], [40, 52], [40, 57], [41, 42], [41, 49], [41, 50], [41, 51], [41, 54], [41, 55], [41, 56], [42, 43], [42, 45], [42, 47], [42, 48], [42, 51], [42, 54], [42, 55], [42, 57], [43, 44], [43, 45], [43, 47], [43, 49], [43, 50], [43, 53], [43, 55], [44, 47], [44, 49], [44, 50], [44, 52], [44, 53], [44, 56], [45, 47], [45, 53], [45, 54], [45, 56], [45, 57], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [46, 53], [46, 54], [46, 55], [46, 56], [46, 57], [47, 50], [47, 51], [47, 55], [47, 57], [48, 49], [48, 50], [48, 52], [48, 53], [48, 55], [48, 56], [48, 57], [49, 51], [49, 52], [49, 53], [49, 55], [49, 56], [49, 57], [50, 52], [50, 54], [50, 57], [51, 52], [51, 55], [52, 57], [53, 56], [54, 55]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s2/solution/solve.sh b/tasks/construct-mc-max-clique-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bf806782e706b8cb3bceaa190e0a23fca29b80cf --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [46, 48, 49, 53, 56]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l3-s2/tests/check.py b/tasks/construct-mc-max-clique-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s2/tests/check.py @@ -0,0 +1,18 @@ +"""Clique of size >= k in a given graph (MathConstraint max_clique decision version, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"clique has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) not in E: + raise Invalid(f"vertices {u} and {v} are not adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-clique-l3-s2/tests/instance.json b/tasks/construct-mc-max-clique-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9502a9a445758d8643ccea03cd1d9433674956fb --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 58, "k": 5, "edges": [[0, 2], [0, 3], [0, 7], [0, 12], [0, 15], [0, 17], [0, 19], [0, 21], [0, 24], [0, 26], [0, 32], [0, 33], [0, 34], [0, 36], [0, 42], [0, 44], [0, 45], [0, 48], [0, 50], [0, 53], [0, 56], [0, 57], [1, 7], [1, 8], [1, 9], [1, 11], [1, 12], [1, 14], [1, 15], [1, 16], [1, 19], [1, 20], [1, 21], [1, 23], [1, 25], [1, 26], [1, 29], [1, 32], [1, 33], [1, 34], [1, 38], [1, 39], [1, 43], [1, 44], [1, 48], [1, 49], [1, 50], [1, 53], [1, 54], [2, 3], [2, 4], [2, 7], [2, 8], [2, 11], [2, 13], [2, 15], [2, 20], [2, 23], [2, 25], [2, 26], [2, 27], [2, 28], [2, 30], [2, 33], [2, 34], [2, 35], [2, 38], [2, 39], [2, 41], [2, 43], [2, 44], [2, 47], [2, 51], [2, 52], [2, 54], [2, 55], [2, 56], [3, 7], [3, 9], [3, 17], [3, 18], [3, 19], [3, 21], [3, 22], [3, 24], [3, 28], [3, 29], [3, 33], [3, 37], [3, 38], [3, 43], [3, 47], [3, 48], [3, 51], [3, 52], [3, 55], [3, 56], [4, 8], [4, 15], [4, 16], [4, 17], [4, 19], [4, 20], [4, 22], [4, 24], [4, 26], [4, 28], [4, 30], [4, 33], [4, 38], [4, 39], [4, 45], [4, 47], [4, 48], [4, 52], [4, 53], [4, 54], [4, 56], [4, 57], [5, 11], [5, 12], [5, 13], [5, 14], [5, 20], [5, 26], [5, 27], [5, 35], [5, 39], [5, 40], [5, 41], [5, 44], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 54], [5, 56], [6, 7], [6, 8], [6, 10], [6, 11], [6, 12], [6, 15], [6, 20], [6, 21], [6, 31], [6, 32], [6, 33], [6, 38], [6, 41], [6, 42], [6, 43], [6, 47], [6, 49], [6, 50], [6, 52], [6, 53], [6, 55], [7, 8], [7, 11], [7, 12], [7, 15], [7, 16], [7, 19], [7, 25], [7, 28], [7, 29], [7, 32], [7, 37], [7, 38], [7, 41], [7, 42], [7, 45], [7, 48], [7, 49], [7, 52], [7, 54], [7, 56], [8, 10], [8, 16], [8, 18], [8, 21], [8, 22], [8, 23], [8, 25], [8, 30], [8, 31], [8, 34], [8, 38], [8, 40], [8, 41], [8, 42], [8, 51], [8, 52], [8, 54], [8, 55], [8, 57], [9, 11], [9, 15], [9, 17], [9, 18], [9, 20], [9, 21], [9, 23], [9, 28], [9, 33], [9, 36], [9, 39], [9, 40], [9, 46], [9, 47], [9, 48], [9, 52], [9, 57], [10, 13], [10, 17], [10, 21], [10, 22], [10, 23], [10, 26], [10, 27], [10, 29], [10, 31], [10, 32], [10, 33], [10, 35], [10, 37], [10, 45], [10, 46], [10, 50], [10, 53], [10, 55], [11, 12], [11, 13], [11, 16], [11, 18], [11, 21], [11, 22], [11, 24], [11, 25], [11, 27], [11, 28], [11, 29], [11, 31], [11, 32], [11, 35], [11, 37], [11, 38], [11, 40], [11, 46], [11, 47], [11, 48], [11, 50], [11, 51], [11, 53], [11, 55], [12, 16], [12, 17], [12, 19], [12, 20], [12, 24], [12, 25], [12, 26], [12, 27], [12, 29], [12, 30], [12, 31], [12, 32], [12, 34], [12, 39], [12, 40], [12, 43], [12, 44], [12, 47], [12, 52], [12, 55], [13, 14], [13, 17], [13, 20], [13, 27], [13, 31], [13, 34], [13, 36], [13, 38], [13, 41], [13, 44], [13, 47], [13, 49], [13, 50], [13, 55], [14, 16], [14, 21], [14, 24], [14, 26], [14, 28], [14, 30], [14, 34], [14, 35], [14, 43], [14, 47], [14, 49], [14, 50], [14, 51], [14, 54], [14, 55], [14, 56], [14, 57], [15, 17], [15, 18], [15, 22], [15, 23], [15, 24], [15, 27], [15, 28], [15, 29], [15, 32], [15, 33], [15, 39], [15, 40], [15, 43], [15, 45], [15, 48], [15, 53], [15, 54], [15, 56], [16, 18], [16, 19], [16, 22], [16, 23], [16, 25], [16, 26], [16, 28], [16, 32], [16, 33], [16, 36], [16, 38], [16, 39], [16, 42], [16, 44], [16, 45], [16, 51], [16, 52], [16, 56], [17, 18], [17, 19], [17, 20], [17, 24], [17, 26], [17, 28], [17, 31], [17, 33], [17, 38], [17, 39], [17, 45], [17, 47], [17, 48], [17, 54], [18, 20], [18, 21], [18, 23], [18, 27], [18, 28], [18, 29], [18, 30], [18, 34], [18, 37], [18, 42], [18, 46], [18, 47], [18, 49], [18, 50], [18, 51], [18, 53], [18, 57], [19, 24], [19, 27], [19, 28], [19, 30], [19, 34], [19, 37], [19, 39], [19, 40], [19, 43], [19, 47], [19, 48], [19, 49], [19, 51], [19, 55], [19, 56], [19, 57], [20, 25], [20, 27], [20, 30], [20, 34], [20, 36], [20, 38], [20, 39], [20, 40], [20, 45], [20, 46], [20, 51], [20, 52], [20, 55], [20, 57], [21, 25], [21, 27], [21, 29], [21, 31], [21, 32], [21, 37], [21, 38], [21, 39], [21, 41], [21, 43], [21, 45], [21, 47], [21, 50], [21, 52], [21, 53], [21, 54], [21, 55], [21, 57], [22, 24], [22, 25], [22, 26], [22, 31], [22, 32], [22, 34], [22, 35], [22, 36], [22, 42], [22, 43], [22, 45], [22, 46], [22, 52], [22, 53], [22, 56], [23, 27], [23, 30], [23, 31], [23, 32], [23, 38], [23, 43], [23, 44], [23, 47], [23, 54], [23, 55], [24, 28], [24, 30], [24, 31], [24, 34], [24, 35], [24, 37], [24, 40], [24, 43], [24, 45], [24, 46], [24, 49], [24, 51], [25, 26], [25, 30], [25, 31], [25, 33], [25, 34], [25, 40], [25, 41], [25, 42], [25, 44], [25, 45], [25, 48], [25, 50], [25, 51], [25, 52], [25, 53], [26, 27], [26, 31], [26, 32], [26, 33], [26, 35], [26, 37], [26, 38], [26, 39], [26, 44], [26, 46], [26, 48], [26, 52], [27, 29], [27, 35], [27, 36], [27, 37], [27, 38], [27, 39], [27, 45], [27, 46], [27, 48], [27, 51], [27, 54], [27, 55], [27, 56], [28, 31], [28, 36], [28, 37], [28, 38], [28, 40], [28, 41], [28, 42], [28, 46], [28, 51], [28, 52], [28, 53], [28, 55], [29, 30], [29, 31], [29, 32], [29, 33], [29, 37], [29, 39], [29, 44], [29, 45], [29, 47], [29, 49], [29, 51], [29, 52], [29, 56], [30, 31], [30, 32], [30, 34], [30, 35], [30, 37], [30, 41], [30, 42], [30, 46], [30, 47], [30, 50], [30, 52], [30, 53], [30, 55], [30, 57], [31, 32], [31, 36], [31, 39], [31, 41], [31, 44], [31, 45], [31, 47], [31, 49], [31, 50], [31, 51], [31, 53], [31, 57], [32, 39], [32, 40], [32, 43], [32, 45], [32, 50], [32, 52], [32, 54], [33, 40], [33, 46], [33, 47], [33, 48], [33, 50], [33, 51], [33, 52], [33, 55], [34, 39], [34, 40], [34, 41], [34, 43], [34, 44], [34, 45], [34, 47], [34, 49], [34, 52], [34, 56], [35, 36], [35, 37], [35, 42], [35, 44], [35, 46], [35, 47], [35, 48], [35, 49], [35, 50], [35, 55], [35, 56], [36, 38], [36, 39], [36, 42], [36, 48], [36, 51], [36, 53], [36, 54], [36, 55], [36, 57], [37, 39], [37, 48], [38, 39], [38, 40], [38, 43], [38, 44], [38, 46], [38, 48], [38, 49], [38, 51], [39, 40], [39, 41], [39, 42], [39, 46], [39, 47], [39, 48], [39, 49], [39, 56], [39, 57], [40, 41], [40, 42], [40, 43], [40, 44], [40, 47], [40, 48], [40, 49], [40, 50], [40, 52], [40, 57], [41, 42], [41, 49], [41, 50], [41, 51], [41, 54], [41, 55], [41, 56], [42, 43], [42, 45], [42, 47], [42, 48], [42, 51], [42, 54], [42, 55], [42, 57], [43, 44], [43, 45], [43, 47], [43, 49], [43, 50], [43, 53], [43, 55], [44, 47], [44, 49], [44, 50], [44, 52], [44, 53], [44, 56], [45, 47], [45, 53], [45, 54], [45, 56], [45, 57], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [46, 53], [46, 54], [46, 55], [46, 56], [46, 57], [47, 50], [47, 51], [47, 55], [47, 57], [48, 49], [48, 50], [48, 52], [48, 53], [48, 55], [48, 56], [48, 57], [49, 51], [49, 52], [49, 53], [49, 55], [49, 56], [49, 57], [50, 52], [50, 54], [50, 57], [51, 52], [51, 55], [52, 57], [53, 56], [54, 55]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s2/tests/run.py b/tasks/construct-mc-max-clique-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-clique-l3-s2/tests/test.sh b/tasks/construct-mc-max-clique-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-clique-l3-s5/environment/Dockerfile b/tasks/construct-mc-max-clique-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-clique-l3-s5/environment/instance.json b/tasks/construct-mc-max-clique-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7989979bdde259f7f7d75d956047c2ac6bbf4716 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 55, "k": 6, "edges": [[0, 1], [0, 3], [0, 6], [0, 7], [0, 8], [0, 10], [0, 11], [0, 12], [0, 14], [0, 15], [0, 17], [0, 18], [0, 21], [0, 22], [0, 23], [0, 26], [0, 27], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 37], [0, 38], [0, 40], [0, 41], [0, 42], [0, 43], [0, 44], [0, 45], [0, 47], [0, 48], [0, 50], [0, 51], [0, 52], [1, 3], [1, 4], [1, 5], [1, 8], [1, 10], [1, 11], [1, 14], [1, 15], [1, 17], [1, 19], [1, 22], [1, 23], [1, 24], [1, 26], [1, 28], [1, 29], [1, 30], [1, 31], [1, 34], [1, 35], [1, 38], [1, 39], [1, 43], [1, 44], [1, 46], [1, 47], [1, 49], [1, 51], [1, 52], [1, 53], [1, 54], [2, 5], [2, 10], [2, 11], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 20], [2, 21], [2, 22], [2, 25], [2, 26], [2, 29], [2, 30], [2, 32], [2, 33], [2, 34], [2, 37], [2, 40], [2, 41], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 47], [2, 48], [2, 50], [2, 51], [2, 52], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 12], [3, 13], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 28], [3, 30], [3, 32], [3, 33], [3, 34], [3, 37], [3, 38], [3, 40], [3, 41], [3, 43], [3, 44], [3, 45], [3, 46], [3, 47], [3, 49], [3, 50], [3, 51], [3, 54], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 15], [4, 18], [4, 19], [4, 21], [4, 28], [4, 29], [4, 30], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 42], [4, 43], [4, 44], [4, 45], [4, 46], [4, 49], [4, 50], [4, 51], [4, 52], [4, 53], [4, 54], [5, 6], [5, 8], [5, 11], [5, 12], [5, 13], [5, 15], [5, 16], [5, 19], [5, 20], [5, 21], [5, 22], [5, 25], [5, 27], [5, 28], [5, 31], [5, 32], [5, 35], [5, 36], [5, 37], [5, 39], [5, 44], [5, 45], [5, 46], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 54], [6, 7], [6, 9], [6, 10], [6, 11], [6, 15], [6, 16], [6, 19], [6, 24], [6, 26], [6, 27], [6, 29], [6, 30], [6, 31], [6, 33], [6, 35], [6, 36], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 45], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [7, 9], [7, 11], [7, 12], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 25], [7, 28], [7, 30], [7, 31], [7, 33], [7, 34], [7, 35], [7, 36], [7, 39], [7, 43], [7, 45], [7, 46], [7, 48], [7, 51], [7, 52], [7, 53], [7, 54], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 15], [8, 17], [8, 20], [8, 21], [8, 22], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 31], [8, 33], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 45], [8, 47], [8, 50], [8, 52], [8, 53], [9, 12], [9, 13], [9, 14], [9, 17], [9, 18], [9, 20], [9, 21], [9, 24], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 37], [9, 40], [9, 41], [9, 44], [9, 46], [9, 47], [9, 48], [9, 50], [9, 51], [9, 52], [9, 54], [10, 11], [10, 12], [10, 14], [10, 15], [10, 19], [10, 21], [10, 22], [10, 24], [10, 25], [10, 26], [10, 27], [10, 28], [10, 30], [10, 31], [10, 32], [10, 34], [10, 36], [10, 41], [10, 43], [10, 44], [10, 45], [10, 47], [10, 49], [10, 50], [10, 51], [11, 14], [11, 18], [11, 19], [11, 23], [11, 24], [11, 25], [11, 26], [11, 28], [11, 29], [11, 30], [11, 32], [11, 34], [11, 35], [11, 37], [11, 38], [11, 39], [11, 40], [11, 41], [11, 43], [11, 44], [11, 46], [11, 47], [11, 48], [11, 50], [11, 52], [11, 54], [12, 13], [12, 14], [12, 18], [12, 19], [12, 24], [12, 25], [12, 27], [12, 28], [12, 30], [12, 32], [12, 33], [12, 37], [12, 38], [12, 40], [12, 44], [12, 46], [12, 48], [12, 49], [12, 50], [12, 53], [13, 14], [13, 17], [13, 18], [13, 20], [13, 21], [13, 23], [13, 24], [13, 26], [13, 28], [13, 29], [13, 35], [13, 36], [13, 37], [13, 40], [13, 41], [13, 42], [13, 44], [13, 47], [13, 48], [13, 50], [13, 51], [13, 52], [13, 53], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 30], [14, 31], [14, 32], [14, 34], [14, 35], [14, 36], [14, 37], [14, 44], [14, 46], [14, 50], [14, 52], [14, 53], [15, 16], [15, 21], [15, 22], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 33], [15, 36], [15, 41], [15, 42], [15, 45], [15, 46], [15, 48], [15, 52], [15, 53], [15, 54], [16, 17], [16, 18], [16, 19], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 28], [16, 30], [16, 31], [16, 33], [16, 34], [16, 35], [16, 37], [16, 38], [16, 40], [16, 41], [16, 42], [16, 43], [16, 46], [16, 49], [16, 50], [16, 51], [16, 52], [17, 20], [17, 21], [17, 22], [17, 27], [17, 28], [17, 29], [17, 31], [17, 34], [17, 36], [17, 37], [17, 38], [17, 42], [17, 45], [17, 48], [17, 49], [17, 50], [17, 51], [17, 53], [17, 54], [18, 19], [18, 20], [18, 21], [18, 22], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 39], [18, 40], [18, 42], [18, 45], [18, 46], [18, 47], [18, 48], [18, 50], [18, 51], [18, 53], [19, 21], [19, 22], [19, 23], [19, 24], [19, 26], [19, 27], [19, 32], [19, 33], [19, 34], [19, 35], [19, 39], [19, 40], [19, 42], [19, 43], [19, 44], [19, 45], [19, 46], [19, 47], [19, 50], [19, 53], [19, 54], [20, 22], [20, 23], [20, 26], [20, 27], [20, 30], [20, 31], [20, 34], [20, 36], [20, 37], [20, 38], [20, 39], [20, 41], [20, 45], [20, 46], [20, 47], [20, 50], [20, 51], [20, 53], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 29], [21, 30], [21, 32], [21, 33], [21, 35], [21, 40], [21, 41], [21, 49], [21, 52], [21, 54], [22, 27], [22, 28], [22, 29], [22, 32], [22, 34], [22, 36], [22, 37], [22, 39], [22, 40], [22, 42], [22, 46], [22, 48], [22, 49], [22, 50], [22, 51], [22, 52], [22, 54], [23, 24], [23, 27], [23, 28], [23, 29], [23, 31], [23, 32], [23, 34], [23, 35], [23, 36], [23, 39], [23, 42], [23, 44], [23, 46], [23, 47], [23, 49], [23, 50], [23, 52], [23, 54], [24, 26], [24, 28], [24, 29], [24, 30], [24, 32], [24, 34], [24, 35], [24, 36], [24, 38], [24, 40], [24, 41], [24, 42], [24, 44], [24, 46], [24, 49], [24, 50], [24, 51], [24, 52], [24, 53], [24, 54], [25, 26], [25, 29], [25, 32], [25, 33], [25, 34], [25, 35], [25, 37], [25, 38], [25, 39], [25, 44], [25, 48], [25, 52], [25, 53], [26, 27], [26, 28], [26, 29], [26, 31], [26, 42], [26, 43], [26, 46], [26, 48], [26, 49], [27, 30], [27, 32], [27, 34], [27, 37], [27, 38], [27, 40], [27, 45], [27, 48], [27, 49], [27, 50], [27, 53], [27, 54], [28, 29], [28, 30], [28, 32], [28, 33], [28, 37], [28, 38], [28, 40], [28, 41], [28, 42], [28, 43], [28, 45], [28, 50], [28, 51], [28, 52], [28, 53], [29, 31], [29, 32], [29, 34], [29, 36], [29, 38], [29, 39], [29, 41], [29, 42], [29, 44], [29, 45], [29, 46], [29, 48], [29, 49], [29, 52], [30, 31], [30, 32], [30, 33], [30, 36], [30, 37], [30, 38], [30, 42], [30, 43], [30, 44], [30, 45], [30, 47], [30, 48], [30, 49], [31, 33], [31, 34], [31, 36], [31, 37], [31, 40], [31, 41], [31, 42], [31, 43], [31, 44], [31, 48], [31, 49], [31, 51], [31, 52], [31, 53], [31, 54], [32, 34], [32, 35], [32, 37], [32, 39], [32, 40], [32, 43], [32, 44], [32, 45], [32, 49], [32, 51], [32, 52], [32, 53], [32, 54], [33, 34], [33, 36], [33, 39], [33, 41], [33, 47], [33, 51], [33, 52], [33, 53], [34, 35], [34, 36], [34, 41], [34, 44], [34, 45], [34, 46], [34, 47], [34, 49], [34, 51], [34, 52], [34, 54], [35, 36], [35, 42], [35, 44], [35, 45], [35, 46], [35, 47], [35, 49], [35, 51], [36, 39], [36, 41], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 48], [36, 50], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [37, 43], [37, 46], [37, 48], [37, 50], [37, 51], [38, 39], [38, 40], [38, 43], [38, 47], [38, 48], [38, 50], [38, 51], [38, 53], [38, 54], [39, 41], [39, 43], [39, 44], [39, 45], [39, 46], [39, 47], [39, 51], [39, 54], [40, 43], [40, 44], [40, 47], [40, 48], [40, 49], [40, 50], [41, 42], [41, 43], [41, 45], [41, 46], [41, 49], [41, 52], [41, 54], [42, 43], [42, 44], [42, 45], [42, 46], [42, 47], [42, 51], [42, 53], [43, 47], [43, 51], [43, 53], [43, 54], [44, 45], [44, 46], [44, 47], [44, 48], [44, 49], [44, 51], [44, 53], [44, 54], [45, 48], [45, 49], [45, 50], [45, 52], [45, 53], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [46, 54], [47, 49], [47, 51], [47, 53], [48, 49], [48, 50], [48, 52], [48, 53], [48, 54], [49, 54], [50, 51], [50, 53], [50, 54], [51, 53], [51, 54], [52, 53], [52, 54]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s5/solution/solve.sh b/tasks/construct-mc-max-clique-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c69d5a26e0978e6a93906d8136eddaeff4f5522f --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 4, 11, 34, 35, 46]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l3-s5/tests/check.py b/tasks/construct-mc-max-clique-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s5/tests/check.py @@ -0,0 +1,18 @@ +"""Clique of size >= k in a given graph (MathConstraint max_clique decision version, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"clique has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) not in E: + raise Invalid(f"vertices {u} and {v} are not adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-clique-l3-s5/tests/instance.json b/tasks/construct-mc-max-clique-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7989979bdde259f7f7d75d956047c2ac6bbf4716 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 55, "k": 6, "edges": [[0, 1], [0, 3], [0, 6], [0, 7], [0, 8], [0, 10], [0, 11], [0, 12], [0, 14], [0, 15], [0, 17], [0, 18], [0, 21], [0, 22], [0, 23], [0, 26], [0, 27], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 37], [0, 38], [0, 40], [0, 41], [0, 42], [0, 43], [0, 44], [0, 45], [0, 47], [0, 48], [0, 50], [0, 51], [0, 52], [1, 3], [1, 4], [1, 5], [1, 8], [1, 10], [1, 11], [1, 14], [1, 15], [1, 17], [1, 19], [1, 22], [1, 23], [1, 24], [1, 26], [1, 28], [1, 29], [1, 30], [1, 31], [1, 34], [1, 35], [1, 38], [1, 39], [1, 43], [1, 44], [1, 46], [1, 47], [1, 49], [1, 51], [1, 52], [1, 53], [1, 54], [2, 5], [2, 10], [2, 11], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 20], [2, 21], [2, 22], [2, 25], [2, 26], [2, 29], [2, 30], [2, 32], [2, 33], [2, 34], [2, 37], [2, 40], [2, 41], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 47], [2, 48], [2, 50], [2, 51], [2, 52], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 12], [3, 13], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 28], [3, 30], [3, 32], [3, 33], [3, 34], [3, 37], [3, 38], [3, 40], [3, 41], [3, 43], [3, 44], [3, 45], [3, 46], [3, 47], [3, 49], [3, 50], [3, 51], [3, 54], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 15], [4, 18], [4, 19], [4, 21], [4, 28], [4, 29], [4, 30], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 42], [4, 43], [4, 44], [4, 45], [4, 46], [4, 49], [4, 50], [4, 51], [4, 52], [4, 53], [4, 54], [5, 6], [5, 8], [5, 11], [5, 12], [5, 13], [5, 15], [5, 16], [5, 19], [5, 20], [5, 21], [5, 22], [5, 25], [5, 27], [5, 28], [5, 31], [5, 32], [5, 35], [5, 36], [5, 37], [5, 39], [5, 44], [5, 45], [5, 46], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 54], [6, 7], [6, 9], [6, 10], [6, 11], [6, 15], [6, 16], [6, 19], [6, 24], [6, 26], [6, 27], [6, 29], [6, 30], [6, 31], [6, 33], [6, 35], [6, 36], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 45], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [7, 9], [7, 11], [7, 12], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 25], [7, 28], [7, 30], [7, 31], [7, 33], [7, 34], [7, 35], [7, 36], [7, 39], [7, 43], [7, 45], [7, 46], [7, 48], [7, 51], [7, 52], [7, 53], [7, 54], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 15], [8, 17], [8, 20], [8, 21], [8, 22], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 31], [8, 33], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 45], [8, 47], [8, 50], [8, 52], [8, 53], [9, 12], [9, 13], [9, 14], [9, 17], [9, 18], [9, 20], [9, 21], [9, 24], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 37], [9, 40], [9, 41], [9, 44], [9, 46], [9, 47], [9, 48], [9, 50], [9, 51], [9, 52], [9, 54], [10, 11], [10, 12], [10, 14], [10, 15], [10, 19], [10, 21], [10, 22], [10, 24], [10, 25], [10, 26], [10, 27], [10, 28], [10, 30], [10, 31], [10, 32], [10, 34], [10, 36], [10, 41], [10, 43], [10, 44], [10, 45], [10, 47], [10, 49], [10, 50], [10, 51], [11, 14], [11, 18], [11, 19], [11, 23], [11, 24], [11, 25], [11, 26], [11, 28], [11, 29], [11, 30], [11, 32], [11, 34], [11, 35], [11, 37], [11, 38], [11, 39], [11, 40], [11, 41], [11, 43], [11, 44], [11, 46], [11, 47], [11, 48], [11, 50], [11, 52], [11, 54], [12, 13], [12, 14], [12, 18], [12, 19], [12, 24], [12, 25], [12, 27], [12, 28], [12, 30], [12, 32], [12, 33], [12, 37], [12, 38], [12, 40], [12, 44], [12, 46], [12, 48], [12, 49], [12, 50], [12, 53], [13, 14], [13, 17], [13, 18], [13, 20], [13, 21], [13, 23], [13, 24], [13, 26], [13, 28], [13, 29], [13, 35], [13, 36], [13, 37], [13, 40], [13, 41], [13, 42], [13, 44], [13, 47], [13, 48], [13, 50], [13, 51], [13, 52], [13, 53], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 30], [14, 31], [14, 32], [14, 34], [14, 35], [14, 36], [14, 37], [14, 44], [14, 46], [14, 50], [14, 52], [14, 53], [15, 16], [15, 21], [15, 22], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 33], [15, 36], [15, 41], [15, 42], [15, 45], [15, 46], [15, 48], [15, 52], [15, 53], [15, 54], [16, 17], [16, 18], [16, 19], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 28], [16, 30], [16, 31], [16, 33], [16, 34], [16, 35], [16, 37], [16, 38], [16, 40], [16, 41], [16, 42], [16, 43], [16, 46], [16, 49], [16, 50], [16, 51], [16, 52], [17, 20], [17, 21], [17, 22], [17, 27], [17, 28], [17, 29], [17, 31], [17, 34], [17, 36], [17, 37], [17, 38], [17, 42], [17, 45], [17, 48], [17, 49], [17, 50], [17, 51], [17, 53], [17, 54], [18, 19], [18, 20], [18, 21], [18, 22], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 39], [18, 40], [18, 42], [18, 45], [18, 46], [18, 47], [18, 48], [18, 50], [18, 51], [18, 53], [19, 21], [19, 22], [19, 23], [19, 24], [19, 26], [19, 27], [19, 32], [19, 33], [19, 34], [19, 35], [19, 39], [19, 40], [19, 42], [19, 43], [19, 44], [19, 45], [19, 46], [19, 47], [19, 50], [19, 53], [19, 54], [20, 22], [20, 23], [20, 26], [20, 27], [20, 30], [20, 31], [20, 34], [20, 36], [20, 37], [20, 38], [20, 39], [20, 41], [20, 45], [20, 46], [20, 47], [20, 50], [20, 51], [20, 53], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 29], [21, 30], [21, 32], [21, 33], [21, 35], [21, 40], [21, 41], [21, 49], [21, 52], [21, 54], [22, 27], [22, 28], [22, 29], [22, 32], [22, 34], [22, 36], [22, 37], [22, 39], [22, 40], [22, 42], [22, 46], [22, 48], [22, 49], [22, 50], [22, 51], [22, 52], [22, 54], [23, 24], [23, 27], [23, 28], [23, 29], [23, 31], [23, 32], [23, 34], [23, 35], [23, 36], [23, 39], [23, 42], [23, 44], [23, 46], [23, 47], [23, 49], [23, 50], [23, 52], [23, 54], [24, 26], [24, 28], [24, 29], [24, 30], [24, 32], [24, 34], [24, 35], [24, 36], [24, 38], [24, 40], [24, 41], [24, 42], [24, 44], [24, 46], [24, 49], [24, 50], [24, 51], [24, 52], [24, 53], [24, 54], [25, 26], [25, 29], [25, 32], [25, 33], [25, 34], [25, 35], [25, 37], [25, 38], [25, 39], [25, 44], [25, 48], [25, 52], [25, 53], [26, 27], [26, 28], [26, 29], [26, 31], [26, 42], [26, 43], [26, 46], [26, 48], [26, 49], [27, 30], [27, 32], [27, 34], [27, 37], [27, 38], [27, 40], [27, 45], [27, 48], [27, 49], [27, 50], [27, 53], [27, 54], [28, 29], [28, 30], [28, 32], [28, 33], [28, 37], [28, 38], [28, 40], [28, 41], [28, 42], [28, 43], [28, 45], [28, 50], [28, 51], [28, 52], [28, 53], [29, 31], [29, 32], [29, 34], [29, 36], [29, 38], [29, 39], [29, 41], [29, 42], [29, 44], [29, 45], [29, 46], [29, 48], [29, 49], [29, 52], [30, 31], [30, 32], [30, 33], [30, 36], [30, 37], [30, 38], [30, 42], [30, 43], [30, 44], [30, 45], [30, 47], [30, 48], [30, 49], [31, 33], [31, 34], [31, 36], [31, 37], [31, 40], [31, 41], [31, 42], [31, 43], [31, 44], [31, 48], [31, 49], [31, 51], [31, 52], [31, 53], [31, 54], [32, 34], [32, 35], [32, 37], [32, 39], [32, 40], [32, 43], [32, 44], [32, 45], [32, 49], [32, 51], [32, 52], [32, 53], [32, 54], [33, 34], [33, 36], [33, 39], [33, 41], [33, 47], [33, 51], [33, 52], [33, 53], [34, 35], [34, 36], [34, 41], [34, 44], [34, 45], [34, 46], [34, 47], [34, 49], [34, 51], [34, 52], [34, 54], [35, 36], [35, 42], [35, 44], [35, 45], [35, 46], [35, 47], [35, 49], [35, 51], [36, 39], [36, 41], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 48], [36, 50], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [37, 43], [37, 46], [37, 48], [37, 50], [37, 51], [38, 39], [38, 40], [38, 43], [38, 47], [38, 48], [38, 50], [38, 51], [38, 53], [38, 54], [39, 41], [39, 43], [39, 44], [39, 45], [39, 46], [39, 47], [39, 51], [39, 54], [40, 43], [40, 44], [40, 47], [40, 48], [40, 49], [40, 50], [41, 42], [41, 43], [41, 45], [41, 46], [41, 49], [41, 52], [41, 54], [42, 43], [42, 44], [42, 45], [42, 46], [42, 47], [42, 51], [42, 53], [43, 47], [43, 51], [43, 53], [43, 54], [44, 45], [44, 46], [44, 47], [44, 48], [44, 49], [44, 51], [44, 53], [44, 54], [45, 48], [45, 49], [45, 50], [45, 52], [45, 53], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [46, 54], [47, 49], [47, 51], [47, 53], [48, 49], [48, 50], [48, 52], [48, 53], [48, 54], [49, 54], [50, 51], [50, 53], [50, 54], [51, 53], [51, 54], [52, 53], [52, 54]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s5/tests/run.py b/tasks/construct-mc-max-clique-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-clique-l3-s5/tests/test.sh b/tasks/construct-mc-max-clique-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-independent-set-l4-s1/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-independent-set-l4-s1/environment/instance.json b/tasks/construct-mc-max-independent-set-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2ca775a0e56ac304a35e2929e0940982612a7064 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 2], [0, 4], [0, 6], [0, 8], [0, 19], [0, 28], [0, 33], [0, 36], [0, 42], [0, 44], [0, 47], [0, 52], [0, 57], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [1, 12], [1, 18], [1, 19], [1, 24], [1, 28], [1, 31], [1, 32], [1, 33], [1, 41], [1, 44], [1, 45], [1, 46], [1, 54], [2, 8], [2, 9], [2, 13], [2, 14], [2, 17], [2, 25], [2, 35], [2, 36], [2, 46], [2, 48], [2, 51], [2, 52], [2, 53], [2, 57], [2, 59], [3, 7], [3, 10], [3, 12], [3, 17], [3, 28], [3, 36], [3, 40], [3, 41], [3, 43], [3, 44], [3, 46], [3, 47], [3, 49], [3, 50], [3, 51], [3, 53], [4, 5], [4, 6], [4, 8], [4, 10], [4, 12], [4, 13], [4, 16], [4, 20], [4, 21], [4, 22], [4, 30], [4, 31], [4, 37], [4, 38], [4, 45], [4, 47], [4, 49], [4, 51], [4, 59], [5, 8], [5, 12], [5, 14], [5, 17], [5, 19], [5, 20], [5, 27], [5, 28], [5, 29], [5, 35], [5, 39], [5, 40], [5, 42], [5, 43], [5, 46], [5, 48], [5, 50], [5, 52], [5, 53], [5, 55], [6, 10], [6, 16], [6, 26], [6, 31], [6, 33], [6, 36], [6, 37], [6, 39], [6, 43], [6, 47], [6, 49], [6, 54], [6, 59], [7, 8], [7, 10], [7, 12], [7, 26], [7, 27], [7, 28], [7, 32], [7, 34], [7, 38], [7, 42], [7, 46], [7, 47], [7, 54], [7, 59], [8, 11], [8, 20], [8, 24], [8, 26], [8, 27], [8, 29], [8, 34], [8, 36], [8, 38], [8, 41], [8, 43], [8, 44], [8, 45], [8, 51], [8, 58], [9, 11], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 21], [9, 24], [9, 25], [9, 26], [9, 29], [9, 32], [9, 36], [9, 38], [9, 39], [9, 40], [9, 41], [9, 56], [10, 14], [10, 19], [10, 21], [10, 27], [10, 29], [10, 30], [10, 31], [10, 33], [10, 40], [10, 41], [10, 50], [10, 54], [10, 57], [10, 58], [10, 59], [11, 12], [11, 15], [11, 16], [11, 21], [11, 27], [11, 28], [11, 36], [11, 40], [11, 43], [11, 48], [11, 53], [11, 54], [11, 57], [12, 16], [12, 17], [12, 35], [12, 36], [12, 42], [12, 56], [13, 18], [13, 20], [13, 23], [13, 24], [13, 25], [13, 28], [13, 42], [13, 44], [13, 45], [13, 47], [13, 52], [13, 53], [13, 54], [13, 55], [14, 15], [14, 16], [14, 21], [14, 28], [14, 32], [14, 34], [14, 35], [14, 39], [14, 40], [14, 41], [14, 44], [14, 49], [14, 59], [15, 22], [15, 23], [15, 24], [15, 34], [15, 35], [15, 38], [15, 40], [15, 43], [15, 48], [15, 51], [15, 53], [15, 57], [16, 18], [16, 26], [16, 28], [16, 31], [16, 35], [16, 43], [16, 44], [16, 47], [16, 50], [16, 55], [16, 58], [17, 22], [17, 24], [17, 27], [17, 30], [17, 33], [17, 34], [17, 41], [17, 43], [17, 50], [17, 52], [17, 55], [17, 56], [17, 57], [17, 58], [18, 20], [18, 21], [18, 22], [18, 24], [18, 30], [18, 33], [18, 35], [18, 37], [18, 39], [18, 44], [18, 46], [18, 47], [18, 55], [19, 22], [19, 25], [19, 26], [19, 28], [19, 34], [19, 38], [19, 41], [19, 42], [19, 43], [19, 46], [19, 47], [19, 49], [19, 50], [19, 54], [19, 55], [19, 56], [19, 57], [19, 58], [20, 21], [20, 26], [20, 33], [20, 41], [20, 42], [20, 44], [20, 48], [20, 52], [20, 59], [21, 22], [21, 23], [21, 26], [21, 32], [21, 36], [21, 38], [21, 39], [21, 40], [21, 44], [21, 45], [21, 49], [21, 52], [21, 56], [21, 58], [21, 59], [22, 23], [22, 24], [22, 27], [22, 28], [22, 30], [22, 31], [22, 36], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 47], [22, 48], [22, 49], [22, 50], [22, 54], [22, 58], [23, 31], [23, 33], [23, 36], [23, 41], [23, 42], [23, 43], [23, 44], [23, 46], [23, 47], [24, 31], [24, 38], [24, 39], [24, 48], [24, 49], [24, 56], [25, 26], [25, 34], [25, 42], [25, 43], [25, 44], [25, 46], [25, 48], [25, 57], [26, 27], [26, 31], [26, 34], [26, 36], [26, 37], [26, 38], [26, 50], [26, 51], [26, 56], [27, 28], [27, 31], [27, 32], [27, 33], [27, 47], [27, 48], [27, 50], [28, 30], [28, 33], [28, 39], [28, 44], [28, 48], [28, 49], [28, 50], [28, 52], [28, 53], [28, 56], [28, 58], [28, 59], [29, 30], [29, 34], [29, 39], [29, 41], [29, 52], [29, 59], [30, 31], [30, 38], [30, 39], [30, 59], [31, 33], [31, 37], [31, 39], [31, 41], [31, 43], [31, 45], [31, 49], [31, 51], [31, 52], [31, 53], [31, 59], [32, 33], [32, 34], [32, 39], [32, 40], [32, 48], [32, 52], [32, 59], [33, 39], [33, 42], [33, 43], [33, 44], [33, 47], [33, 48], [33, 50], [33, 53], [33, 54], [33, 56], [33, 58], [33, 59], [34, 36], [34, 39], [34, 40], [34, 45], [34, 53], [35, 40], [35, 42], [35, 48], [35, 50], [35, 55], [35, 57], [36, 44], [36, 56], [36, 58], [37, 38], [37, 39], [37, 40], [37, 47], [37, 48], [37, 49], [37, 57], [37, 59], [38, 42], [38, 44], [38, 45], [38, 49], [38, 50], [38, 54], [38, 56], [39, 41], [39, 45], [39, 50], [39, 51], [39, 52], [39, 54], [39, 56], [39, 57], [39, 58], [40, 48], [40, 51], [40, 54], [40, 55], [41, 46], [41, 47], [41, 48], [41, 58], [42, 46], [42, 53], [43, 47], [43, 50], [43, 52], [43, 54], [43, 59], [44, 53], [45, 47], [45, 48], [45, 52], [45, 55], [45, 59], [46, 49], [46, 52], [46, 56], [47, 50], [47, 59], [48, 51], [48, 54], [48, 56], [49, 52], [49, 55], [49, 57], [50, 52], [50, 59], [51, 57], [52, 58], [53, 59], [54, 57], [55, 56], [56, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s1/solution/solve.sh b/tasks/construct-mc-max-independent-set-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..24a9cc8d1f8cf14ff716ed886825c986d7230a17 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [0, 7, 14, 20, 23, 25, 30, 37, 45, 50, 51, 53, 56, 58]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l4-s1/tests/check.py b/tasks/construct-mc-max-independent-set-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s1/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l4-s1/tests/instance.json b/tasks/construct-mc-max-independent-set-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2ca775a0e56ac304a35e2929e0940982612a7064 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 2], [0, 4], [0, 6], [0, 8], [0, 19], [0, 28], [0, 33], [0, 36], [0, 42], [0, 44], [0, 47], [0, 52], [0, 57], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [1, 12], [1, 18], [1, 19], [1, 24], [1, 28], [1, 31], [1, 32], [1, 33], [1, 41], [1, 44], [1, 45], [1, 46], [1, 54], [2, 8], [2, 9], [2, 13], [2, 14], [2, 17], [2, 25], [2, 35], [2, 36], [2, 46], [2, 48], [2, 51], [2, 52], [2, 53], [2, 57], [2, 59], [3, 7], [3, 10], [3, 12], [3, 17], [3, 28], [3, 36], [3, 40], [3, 41], [3, 43], [3, 44], [3, 46], [3, 47], [3, 49], [3, 50], [3, 51], [3, 53], [4, 5], [4, 6], [4, 8], [4, 10], [4, 12], [4, 13], [4, 16], [4, 20], [4, 21], [4, 22], [4, 30], [4, 31], [4, 37], [4, 38], [4, 45], [4, 47], [4, 49], [4, 51], [4, 59], [5, 8], [5, 12], [5, 14], [5, 17], [5, 19], [5, 20], [5, 27], [5, 28], [5, 29], [5, 35], [5, 39], [5, 40], [5, 42], [5, 43], [5, 46], [5, 48], [5, 50], [5, 52], [5, 53], [5, 55], [6, 10], [6, 16], [6, 26], [6, 31], [6, 33], [6, 36], [6, 37], [6, 39], [6, 43], [6, 47], [6, 49], [6, 54], [6, 59], [7, 8], [7, 10], [7, 12], [7, 26], [7, 27], [7, 28], [7, 32], [7, 34], [7, 38], [7, 42], [7, 46], [7, 47], [7, 54], [7, 59], [8, 11], [8, 20], [8, 24], [8, 26], [8, 27], [8, 29], [8, 34], [8, 36], [8, 38], [8, 41], [8, 43], [8, 44], [8, 45], [8, 51], [8, 58], [9, 11], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 21], [9, 24], [9, 25], [9, 26], [9, 29], [9, 32], [9, 36], [9, 38], [9, 39], [9, 40], [9, 41], [9, 56], [10, 14], [10, 19], [10, 21], [10, 27], [10, 29], [10, 30], [10, 31], [10, 33], [10, 40], [10, 41], [10, 50], [10, 54], [10, 57], [10, 58], [10, 59], [11, 12], [11, 15], [11, 16], [11, 21], [11, 27], [11, 28], [11, 36], [11, 40], [11, 43], [11, 48], [11, 53], [11, 54], [11, 57], [12, 16], [12, 17], [12, 35], [12, 36], [12, 42], [12, 56], [13, 18], [13, 20], [13, 23], [13, 24], [13, 25], [13, 28], [13, 42], [13, 44], [13, 45], [13, 47], [13, 52], [13, 53], [13, 54], [13, 55], [14, 15], [14, 16], [14, 21], [14, 28], [14, 32], [14, 34], [14, 35], [14, 39], [14, 40], [14, 41], [14, 44], [14, 49], [14, 59], [15, 22], [15, 23], [15, 24], [15, 34], [15, 35], [15, 38], [15, 40], [15, 43], [15, 48], [15, 51], [15, 53], [15, 57], [16, 18], [16, 26], [16, 28], [16, 31], [16, 35], [16, 43], [16, 44], [16, 47], [16, 50], [16, 55], [16, 58], [17, 22], [17, 24], [17, 27], [17, 30], [17, 33], [17, 34], [17, 41], [17, 43], [17, 50], [17, 52], [17, 55], [17, 56], [17, 57], [17, 58], [18, 20], [18, 21], [18, 22], [18, 24], [18, 30], [18, 33], [18, 35], [18, 37], [18, 39], [18, 44], [18, 46], [18, 47], [18, 55], [19, 22], [19, 25], [19, 26], [19, 28], [19, 34], [19, 38], [19, 41], [19, 42], [19, 43], [19, 46], [19, 47], [19, 49], [19, 50], [19, 54], [19, 55], [19, 56], [19, 57], [19, 58], [20, 21], [20, 26], [20, 33], [20, 41], [20, 42], [20, 44], [20, 48], [20, 52], [20, 59], [21, 22], [21, 23], [21, 26], [21, 32], [21, 36], [21, 38], [21, 39], [21, 40], [21, 44], [21, 45], [21, 49], [21, 52], [21, 56], [21, 58], [21, 59], [22, 23], [22, 24], [22, 27], [22, 28], [22, 30], [22, 31], [22, 36], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 47], [22, 48], [22, 49], [22, 50], [22, 54], [22, 58], [23, 31], [23, 33], [23, 36], [23, 41], [23, 42], [23, 43], [23, 44], [23, 46], [23, 47], [24, 31], [24, 38], [24, 39], [24, 48], [24, 49], [24, 56], [25, 26], [25, 34], [25, 42], [25, 43], [25, 44], [25, 46], [25, 48], [25, 57], [26, 27], [26, 31], [26, 34], [26, 36], [26, 37], [26, 38], [26, 50], [26, 51], [26, 56], [27, 28], [27, 31], [27, 32], [27, 33], [27, 47], [27, 48], [27, 50], [28, 30], [28, 33], [28, 39], [28, 44], [28, 48], [28, 49], [28, 50], [28, 52], [28, 53], [28, 56], [28, 58], [28, 59], [29, 30], [29, 34], [29, 39], [29, 41], [29, 52], [29, 59], [30, 31], [30, 38], [30, 39], [30, 59], [31, 33], [31, 37], [31, 39], [31, 41], [31, 43], [31, 45], [31, 49], [31, 51], [31, 52], [31, 53], [31, 59], [32, 33], [32, 34], [32, 39], [32, 40], [32, 48], [32, 52], [32, 59], [33, 39], [33, 42], [33, 43], [33, 44], [33, 47], [33, 48], [33, 50], [33, 53], [33, 54], [33, 56], [33, 58], [33, 59], [34, 36], [34, 39], [34, 40], [34, 45], [34, 53], [35, 40], [35, 42], [35, 48], [35, 50], [35, 55], [35, 57], [36, 44], [36, 56], [36, 58], [37, 38], [37, 39], [37, 40], [37, 47], [37, 48], [37, 49], [37, 57], [37, 59], [38, 42], [38, 44], [38, 45], [38, 49], [38, 50], [38, 54], [38, 56], [39, 41], [39, 45], [39, 50], [39, 51], [39, 52], [39, 54], [39, 56], [39, 57], [39, 58], [40, 48], [40, 51], [40, 54], [40, 55], [41, 46], [41, 47], [41, 48], [41, 58], [42, 46], [42, 53], [43, 47], [43, 50], [43, 52], [43, 54], [43, 59], [44, 53], [45, 47], [45, 48], [45, 52], [45, 55], [45, 59], [46, 49], [46, 52], [46, 56], [47, 50], [47, 59], [48, 51], [48, 54], [48, 56], [49, 52], [49, 55], [49, 57], [50, 52], [50, 59], [51, 57], [52, 58], [53, 59], [54, 57], [55, 56], [56, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s1/tests/run.py b/tasks/construct-mc-max-independent-set-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-independent-set-l4-s1/tests/test.sh b/tasks/construct-mc-max-independent-set-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-independent-set-l4-s6/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-independent-set-l4-s6/environment/instance.json b/tasks/construct-mc-max-independent-set-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aca96d9e2347a7f5a25ecf800bf24ec2e6bdd3dc --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 7], [0, 8], [0, 13], [0, 14], [0, 15], [0, 21], [0, 24], [0, 25], [0, 32], [0, 41], [0, 42], [0, 49], [0, 58], [1, 4], [1, 9], [1, 12], [1, 14], [1, 18], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 35], [1, 41], [1, 44], [1, 57], [1, 58], [1, 59], [2, 16], [2, 20], [2, 26], [2, 32], [2, 39], [2, 40], [2, 43], [2, 45], [2, 47], [2, 52], [2, 56], [3, 5], [3, 15], [3, 17], [3, 23], [3, 24], [3, 25], [3, 30], [3, 33], [3, 38], [3, 43], [3, 44], [3, 48], [3, 51], [3, 53], [3, 58], [4, 5], [4, 6], [4, 9], [4, 12], [4, 30], [4, 33], [4, 34], [4, 35], [4, 39], [4, 41], [4, 46], [4, 50], [5, 9], [5, 12], [5, 20], [5, 21], [5, 27], [5, 29], [5, 30], [5, 31], [5, 33], [5, 34], [5, 47], [5, 49], [5, 51], [5, 53], [5, 56], [5, 58], [6, 10], [6, 15], [6, 20], [6, 32], [6, 33], [6, 40], [6, 45], [6, 47], [6, 51], [6, 59], [7, 8], [7, 9], [7, 12], [7, 13], [7, 20], [7, 24], [7, 25], [7, 26], [7, 34], [7, 39], [7, 47], [7, 52], [8, 10], [8, 14], [8, 15], [8, 16], [8, 21], [8, 22], [8, 27], [8, 30], [8, 35], [8, 40], [8, 43], [8, 47], [8, 48], [8, 50], [8, 59], [9, 14], [9, 15], [9, 17], [9, 18], [9, 21], [9, 23], [9, 25], [9, 26], [9, 31], [9, 35], [9, 36], [9, 37], [9, 40], [9, 45], [9, 48], [9, 50], [9, 57], [10, 13], [10, 14], [10, 15], [10, 19], [10, 22], [10, 24], [10, 32], [10, 39], [10, 41], [10, 42], [10, 44], [10, 48], [10, 49], [10, 51], [10, 57], [11, 12], [11, 13], [11, 18], [11, 20], [11, 23], [11, 25], [11, 26], [11, 35], [11, 39], [11, 46], [11, 51], [11, 52], [11, 55], [11, 57], [11, 58], [12, 13], [12, 15], [12, 18], [12, 19], [12, 21], [12, 24], [12, 29], [12, 30], [12, 34], [12, 35], [12, 37], [12, 43], [12, 44], [12, 45], [12, 47], [12, 49], [12, 55], [13, 17], [13, 18], [13, 22], [13, 24], [13, 26], [13, 31], [13, 34], [13, 40], [13, 43], [13, 46], [13, 47], [13, 49], [13, 51], [13, 54], [13, 55], [13, 57], [14, 24], [14, 27], [14, 29], [14, 31], [14, 36], [14, 37], [14, 38], [14, 40], [14, 41], [14, 43], [14, 46], [14, 54], [15, 18], [15, 24], [15, 26], [15, 27], [15, 28], [15, 33], [15, 35], [15, 39], [15, 43], [15, 44], [15, 45], [15, 54], [15, 55], [15, 56], [15, 58], [16, 18], [16, 21], [16, 24], [16, 28], [16, 30], [16, 32], [16, 37], [16, 40], [16, 42], [16, 50], [16, 53], [17, 19], [17, 21], [17, 22], [17, 27], [17, 34], [17, 35], [17, 37], [17, 39], [17, 40], [17, 41], [17, 42], [17, 43], [17, 51], [18, 19], [18, 33], [18, 36], [18, 37], [18, 43], [18, 45], [18, 49], [18, 52], [18, 53], [18, 56], [18, 58], [18, 59], [19, 22], [19, 23], [19, 25], [19, 33], [19, 34], [19, 37], [19, 39], [19, 40], [19, 41], [19, 43], [19, 45], [19, 46], [19, 54], [19, 55], [19, 56], [20, 31], [20, 34], [20, 35], [20, 36], [20, 37], [20, 42], [20, 45], [20, 46], [20, 47], [20, 49], [20, 53], [20, 56], [20, 58], [21, 23], [21, 24], [21, 25], [21, 31], [21, 33], [21, 37], [21, 39], [21, 42], [21, 46], [21, 52], [21, 56], [21, 57], [21, 59], [22, 23], [22, 25], [22, 26], [22, 30], [22, 31], [22, 38], [22, 39], [22, 43], [22, 44], [22, 49], [22, 53], [22, 54], [22, 57], [22, 59], [23, 27], [23, 37], [23, 40], [23, 41], [23, 50], [23, 57], [23, 59], [24, 26], [24, 28], [24, 29], [24, 31], [24, 34], [24, 37], [24, 39], [24, 41], [24, 43], [24, 44], [24, 53], [24, 54], [24, 58], [25, 27], [25, 28], [25, 36], [25, 40], [25, 41], [25, 44], [25, 50], [25, 55], [26, 47], [26, 51], [26, 52], [26, 54], [26, 58], [26, 59], [27, 31], [27, 35], [27, 39], [27, 40], [27, 43], [27, 46], [27, 47], [27, 52], [27, 53], [27, 58], [28, 37], [28, 41], [28, 45], [28, 46], [28, 48], [28, 52], [28, 56], [29, 36], [29, 55], [30, 34], [30, 37], [30, 39], [30, 41], [30, 42], [30, 43], [30, 45], [30, 47], [30, 50], [30, 51], [30, 54], [30, 56], [31, 35], [31, 37], [31, 45], [31, 46], [31, 53], [31, 54], [31, 55], [31, 58], [32, 42], [32, 45], [32, 47], [32, 51], [32, 58], [32, 59], [33, 40], [33, 42], [33, 47], [33, 58], [33, 59], [34, 36], [34, 42], [34, 43], [34, 46], [34, 50], [34, 53], [34, 54], [34, 55], [35, 37], [35, 40], [35, 48], [35, 49], [35, 52], [35, 54], [35, 55], [36, 37], [36, 38], [36, 42], [36, 49], [36, 54], [36, 57], [37, 39], [37, 41], [37, 42], [37, 45], [37, 46], [37, 48], [37, 49], [37, 51], [38, 47], [38, 50], [39, 40], [39, 42], [39, 53], [40, 42], [40, 43], [40, 49], [40, 54], [40, 58], [40, 59], [41, 43], [41, 48], [41, 53], [41, 54], [41, 58], [41, 59], [42, 43], [42, 46], [42, 51], [42, 54], [42, 59], [43, 45], [43, 46], [43, 51], [43, 56], [43, 58], [43, 59], [44, 47], [44, 51], [44, 53], [44, 59], [45, 46], [45, 47], [45, 48], [45, 49], [45, 50], [45, 54], [46, 47], [46, 56], [46, 58], [47, 48], [47, 52], [48, 49], [48, 52], [48, 53], [48, 56], [48, 59], [49, 51], [49, 54], [49, 55], [49, 58], [50, 55], [50, 59], [51, 52], [51, 58], [52, 54], [53, 55], [53, 57], [53, 58], [53, 59], [55, 57], [58, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s6/solution/solve.sh b/tasks/construct-mc-max-independent-set-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ee47fd94068b004e5c617ecd7fffc980b002792f --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [8, 26, 29, 31, 32, 33, 34, 38, 39, 41, 44, 49, 56, 57]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l4-s6/tests/check.py b/tasks/construct-mc-max-independent-set-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s6/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l4-s6/tests/instance.json b/tasks/construct-mc-max-independent-set-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aca96d9e2347a7f5a25ecf800bf24ec2e6bdd3dc --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 7], [0, 8], [0, 13], [0, 14], [0, 15], [0, 21], [0, 24], [0, 25], [0, 32], [0, 41], [0, 42], [0, 49], [0, 58], [1, 4], [1, 9], [1, 12], [1, 14], [1, 18], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 35], [1, 41], [1, 44], [1, 57], [1, 58], [1, 59], [2, 16], [2, 20], [2, 26], [2, 32], [2, 39], [2, 40], [2, 43], [2, 45], [2, 47], [2, 52], [2, 56], [3, 5], [3, 15], [3, 17], [3, 23], [3, 24], [3, 25], [3, 30], [3, 33], [3, 38], [3, 43], [3, 44], [3, 48], [3, 51], [3, 53], [3, 58], [4, 5], [4, 6], [4, 9], [4, 12], [4, 30], [4, 33], [4, 34], [4, 35], [4, 39], [4, 41], [4, 46], [4, 50], [5, 9], [5, 12], [5, 20], [5, 21], [5, 27], [5, 29], [5, 30], [5, 31], [5, 33], [5, 34], [5, 47], [5, 49], [5, 51], [5, 53], [5, 56], [5, 58], [6, 10], [6, 15], [6, 20], [6, 32], [6, 33], [6, 40], [6, 45], [6, 47], [6, 51], [6, 59], [7, 8], [7, 9], [7, 12], [7, 13], [7, 20], [7, 24], [7, 25], [7, 26], [7, 34], [7, 39], [7, 47], [7, 52], [8, 10], [8, 14], [8, 15], [8, 16], [8, 21], [8, 22], [8, 27], [8, 30], [8, 35], [8, 40], [8, 43], [8, 47], [8, 48], [8, 50], [8, 59], [9, 14], [9, 15], [9, 17], [9, 18], [9, 21], [9, 23], [9, 25], [9, 26], [9, 31], [9, 35], [9, 36], [9, 37], [9, 40], [9, 45], [9, 48], [9, 50], [9, 57], [10, 13], [10, 14], [10, 15], [10, 19], [10, 22], [10, 24], [10, 32], [10, 39], [10, 41], [10, 42], [10, 44], [10, 48], [10, 49], [10, 51], [10, 57], [11, 12], [11, 13], [11, 18], [11, 20], [11, 23], [11, 25], [11, 26], [11, 35], [11, 39], [11, 46], [11, 51], [11, 52], [11, 55], [11, 57], [11, 58], [12, 13], [12, 15], [12, 18], [12, 19], [12, 21], [12, 24], [12, 29], [12, 30], [12, 34], [12, 35], [12, 37], [12, 43], [12, 44], [12, 45], [12, 47], [12, 49], [12, 55], [13, 17], [13, 18], [13, 22], [13, 24], [13, 26], [13, 31], [13, 34], [13, 40], [13, 43], [13, 46], [13, 47], [13, 49], [13, 51], [13, 54], [13, 55], [13, 57], [14, 24], [14, 27], [14, 29], [14, 31], [14, 36], [14, 37], [14, 38], [14, 40], [14, 41], [14, 43], [14, 46], [14, 54], [15, 18], [15, 24], [15, 26], [15, 27], [15, 28], [15, 33], [15, 35], [15, 39], [15, 43], [15, 44], [15, 45], [15, 54], [15, 55], [15, 56], [15, 58], [16, 18], [16, 21], [16, 24], [16, 28], [16, 30], [16, 32], [16, 37], [16, 40], [16, 42], [16, 50], [16, 53], [17, 19], [17, 21], [17, 22], [17, 27], [17, 34], [17, 35], [17, 37], [17, 39], [17, 40], [17, 41], [17, 42], [17, 43], [17, 51], [18, 19], [18, 33], [18, 36], [18, 37], [18, 43], [18, 45], [18, 49], [18, 52], [18, 53], [18, 56], [18, 58], [18, 59], [19, 22], [19, 23], [19, 25], [19, 33], [19, 34], [19, 37], [19, 39], [19, 40], [19, 41], [19, 43], [19, 45], [19, 46], [19, 54], [19, 55], [19, 56], [20, 31], [20, 34], [20, 35], [20, 36], [20, 37], [20, 42], [20, 45], [20, 46], [20, 47], [20, 49], [20, 53], [20, 56], [20, 58], [21, 23], [21, 24], [21, 25], [21, 31], [21, 33], [21, 37], [21, 39], [21, 42], [21, 46], [21, 52], [21, 56], [21, 57], [21, 59], [22, 23], [22, 25], [22, 26], [22, 30], [22, 31], [22, 38], [22, 39], [22, 43], [22, 44], [22, 49], [22, 53], [22, 54], [22, 57], [22, 59], [23, 27], [23, 37], [23, 40], [23, 41], [23, 50], [23, 57], [23, 59], [24, 26], [24, 28], [24, 29], [24, 31], [24, 34], [24, 37], [24, 39], [24, 41], [24, 43], [24, 44], [24, 53], [24, 54], [24, 58], [25, 27], [25, 28], [25, 36], [25, 40], [25, 41], [25, 44], [25, 50], [25, 55], [26, 47], [26, 51], [26, 52], [26, 54], [26, 58], [26, 59], [27, 31], [27, 35], [27, 39], [27, 40], [27, 43], [27, 46], [27, 47], [27, 52], [27, 53], [27, 58], [28, 37], [28, 41], [28, 45], [28, 46], [28, 48], [28, 52], [28, 56], [29, 36], [29, 55], [30, 34], [30, 37], [30, 39], [30, 41], [30, 42], [30, 43], [30, 45], [30, 47], [30, 50], [30, 51], [30, 54], [30, 56], [31, 35], [31, 37], [31, 45], [31, 46], [31, 53], [31, 54], [31, 55], [31, 58], [32, 42], [32, 45], [32, 47], [32, 51], [32, 58], [32, 59], [33, 40], [33, 42], [33, 47], [33, 58], [33, 59], [34, 36], [34, 42], [34, 43], [34, 46], [34, 50], [34, 53], [34, 54], [34, 55], [35, 37], [35, 40], [35, 48], [35, 49], [35, 52], [35, 54], [35, 55], [36, 37], [36, 38], [36, 42], [36, 49], [36, 54], [36, 57], [37, 39], [37, 41], [37, 42], [37, 45], [37, 46], [37, 48], [37, 49], [37, 51], [38, 47], [38, 50], [39, 40], [39, 42], [39, 53], [40, 42], [40, 43], [40, 49], [40, 54], [40, 58], [40, 59], [41, 43], [41, 48], [41, 53], [41, 54], [41, 58], [41, 59], [42, 43], [42, 46], [42, 51], [42, 54], [42, 59], [43, 45], [43, 46], [43, 51], [43, 56], [43, 58], [43, 59], [44, 47], [44, 51], [44, 53], [44, 59], [45, 46], [45, 47], [45, 48], [45, 49], [45, 50], [45, 54], [46, 47], [46, 56], [46, 58], [47, 48], [47, 52], [48, 49], [48, 52], [48, 53], [48, 56], [48, 59], [49, 51], [49, 54], [49, 55], [49, 58], [50, 55], [50, 59], [51, 52], [51, 58], [52, 54], [53, 55], [53, 57], [53, 58], [53, 59], [55, 57], [58, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s6/tests/run.py b/tasks/construct-mc-max-independent-set-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-independent-set-l4-s6/tests/test.sh b/tasks/construct-mc-max-independent-set-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-independent-set-l4-s8/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-independent-set-l4-s8/environment/instance.json b/tasks/construct-mc-max-independent-set-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..74c3e3a285d3dbb50a22fbcfdc14a1467aea6a00 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 2], [0, 3], [0, 8], [0, 12], [0, 18], [0, 24], [0, 33], [0, 34], [0, 36], [0, 39], [0, 46], [0, 49], [0, 50], [0, 53], [0, 55], [1, 4], [1, 8], [1, 15], [1, 21], [1, 40], [1, 53], [1, 55], [2, 4], [2, 5], [2, 8], [2, 9], [2, 10], [2, 11], [2, 14], [2, 20], [2, 22], [2, 24], [2, 36], [2, 41], [2, 43], [2, 46], [2, 47], [2, 50], [2, 51], [2, 52], [2, 56], [3, 8], [3, 9], [3, 12], [3, 21], [3, 25], [3, 28], [3, 29], [3, 34], [3, 39], [3, 55], [3, 56], [4, 6], [4, 11], [4, 12], [4, 15], [4, 19], [4, 27], [4, 29], [4, 31], [4, 33], [4, 40], [4, 44], [4, 47], [4, 51], [4, 52], [4, 54], [4, 56], [5, 8], [5, 12], [5, 13], [5, 19], [5, 22], [5, 30], [5, 38], [5, 42], [5, 52], [5, 55], [5, 58], [6, 14], [6, 15], [6, 16], [6, 20], [6, 23], [6, 26], [6, 29], [6, 37], [6, 38], [6, 40], [6, 41], [6, 42], [6, 47], [6, 48], [6, 50], [6, 51], [6, 55], [6, 57], [6, 58], [6, 59], [7, 14], [7, 15], [7, 18], [7, 22], [7, 24], [7, 25], [7, 26], [7, 28], [7, 32], [7, 36], [7, 39], [7, 40], [7, 47], [7, 49], [8, 9], [8, 10], [8, 11], [8, 15], [8, 18], [8, 21], [8, 26], [8, 31], [8, 32], [8, 33], [8, 38], [8, 44], [8, 46], [8, 47], [8, 49], [8, 53], [8, 56], [9, 14], [9, 16], [9, 19], [9, 22], [9, 25], [9, 28], [9, 30], [9, 31], [9, 35], [9, 36], [9, 38], [9, 42], [9, 46], [9, 47], [9, 49], [9, 52], [9, 53], [9, 55], [9, 57], [9, 59], [10, 11], [10, 17], [10, 19], [10, 25], [10, 27], [10, 28], [10, 37], [10, 58], [11, 12], [11, 13], [11, 14], [11, 16], [11, 20], [11, 24], [11, 31], [11, 36], [11, 37], [11, 39], [11, 47], [11, 49], [12, 15], [12, 16], [12, 17], [12, 18], [12, 22], [12, 24], [12, 27], [12, 35], [12, 36], [12, 41], [12, 43], [12, 44], [12, 52], [12, 55], [12, 56], [12, 57], [13, 15], [13, 17], [13, 18], [13, 21], [13, 22], [13, 25], [13, 30], [13, 32], [13, 33], [13, 38], [13, 41], [13, 46], [13, 47], [13, 51], [13, 53], [13, 54], [14, 15], [14, 18], [14, 20], [14, 23], [14, 28], [14, 30], [14, 37], [14, 38], [14, 44], [14, 47], [14, 53], [14, 59], [15, 16], [15, 21], [15, 22], [15, 28], [15, 29], [15, 31], [15, 35], [15, 37], [15, 41], [15, 42], [15, 44], [15, 51], [15, 52], [15, 53], [15, 54], [15, 57], [15, 59], [16, 18], [16, 21], [16, 22], [16, 24], [16, 27], [16, 28], [16, 29], [16, 33], [16, 36], [16, 39], [16, 44], [16, 45], [16, 48], [16, 49], [16, 53], [16, 54], [16, 58], [16, 59], [17, 18], [17, 19], [17, 21], [17, 22], [17, 26], [17, 29], [17, 31], [17, 32], [17, 37], [17, 38], [17, 39], [17, 45], [17, 46], [17, 55], [17, 57], [17, 58], [18, 23], [18, 26], [18, 30], [18, 32], [18, 37], [18, 47], [18, 49], [18, 51], [18, 52], [18, 55], [18, 59], [19, 27], [19, 30], [19, 40], [19, 43], [19, 47], [19, 49], [19, 51], [19, 53], [19, 56], [19, 58], [19, 59], [20, 28], [20, 34], [20, 35], [20, 37], [20, 55], [21, 29], [21, 31], [21, 34], [21, 38], [21, 41], [21, 43], [21, 50], [21, 51], [21, 53], [21, 59], [22, 28], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 47], [22, 50], [22, 56], [22, 57], [23, 26], [23, 27], [23, 28], [23, 37], [23, 39], [23, 45], [23, 53], [23, 56], [24, 32], [24, 33], [24, 37], [24, 45], [24, 46], [24, 51], [24, 53], [24, 54], [24, 57], [24, 58], [25, 29], [25, 30], [25, 33], [25, 36], [25, 41], [25, 43], [25, 45], [25, 48], [25, 49], [25, 58], [26, 30], [26, 33], [26, 46], [26, 47], [26, 52], [26, 54], [27, 30], [27, 31], [27, 38], [27, 40], [27, 42], [27, 51], [27, 58], [28, 39], [28, 41], [28, 45], [28, 54], [28, 55], [29, 31], [29, 33], [29, 36], [29, 38], [29, 45], [29, 46], [29, 49], [29, 55], [29, 58], [30, 34], [30, 38], [30, 58], [31, 36], [31, 39], [31, 52], [31, 53], [31, 54], [31, 59], [32, 35], [32, 41], [32, 45], [32, 49], [32, 50], [32, 52], [32, 53], [33, 34], [33, 36], [33, 39], [33, 41], [33, 43], [33, 45], [33, 46], [33, 48], [33, 55], [33, 57], [33, 59], [34, 35], [34, 36], [34, 37], [34, 38], [34, 40], [34, 45], [34, 46], [34, 47], [34, 48], [34, 51], [34, 53], [34, 57], [34, 58], [35, 38], [35, 45], [35, 46], [35, 48], [35, 51], [35, 54], [35, 57], [36, 38], [36, 39], [36, 41], [36, 48], [36, 52], [36, 54], [37, 40], [37, 42], [37, 44], [37, 53], [37, 57], [38, 44], [38, 46], [38, 48], [38, 53], [38, 54], [38, 57], [39, 43], [39, 47], [39, 52], [39, 53], [39, 54], [39, 55], [40, 41], [40, 43], [40, 45], [40, 51], [40, 55], [40, 56], [40, 59], [41, 42], [41, 47], [41, 55], [41, 56], [41, 59], [42, 43], [42, 45], [42, 46], [42, 50], [42, 55], [42, 56], [42, 57], [43, 47], [43, 50], [43, 52], [43, 54], [43, 57], [43, 58], [44, 46], [44, 47], [44, 50], [44, 55], [44, 57], [44, 58], [45, 49], [45, 54], [45, 56], [45, 57], [45, 58], [45, 59], [46, 49], [46, 51], [46, 54], [46, 56], [47, 48], [47, 55], [47, 58], [47, 59], [48, 58], [49, 50], [49, 51], [49, 52], [50, 52], [50, 57], [51, 52], [51, 57], [52, 53], [52, 55], [52, 56], [52, 57], [53, 55], [54, 56], [55, 56], [58, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s8/solution/solve.sh b/tasks/construct-mc-max-independent-set-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..638d863ad3bb62bfb8e8ad19550d201c020fb770 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [0, 1, 10, 20, 22, 23, 29, 30, 42, 44, 48, 52, 54, 59]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l4-s8/tests/check.py b/tasks/construct-mc-max-independent-set-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s8/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l4-s8/tests/instance.json b/tasks/construct-mc-max-independent-set-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..74c3e3a285d3dbb50a22fbcfdc14a1467aea6a00 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 2], [0, 3], [0, 8], [0, 12], [0, 18], [0, 24], [0, 33], [0, 34], [0, 36], [0, 39], [0, 46], [0, 49], [0, 50], [0, 53], [0, 55], [1, 4], [1, 8], [1, 15], [1, 21], [1, 40], [1, 53], [1, 55], [2, 4], [2, 5], [2, 8], [2, 9], [2, 10], [2, 11], [2, 14], [2, 20], [2, 22], [2, 24], [2, 36], [2, 41], [2, 43], [2, 46], [2, 47], [2, 50], [2, 51], [2, 52], [2, 56], [3, 8], [3, 9], [3, 12], [3, 21], [3, 25], [3, 28], [3, 29], [3, 34], [3, 39], [3, 55], [3, 56], [4, 6], [4, 11], [4, 12], [4, 15], [4, 19], [4, 27], [4, 29], [4, 31], [4, 33], [4, 40], [4, 44], [4, 47], [4, 51], [4, 52], [4, 54], [4, 56], [5, 8], [5, 12], [5, 13], [5, 19], [5, 22], [5, 30], [5, 38], [5, 42], [5, 52], [5, 55], [5, 58], [6, 14], [6, 15], [6, 16], [6, 20], [6, 23], [6, 26], [6, 29], [6, 37], [6, 38], [6, 40], [6, 41], [6, 42], [6, 47], [6, 48], [6, 50], [6, 51], [6, 55], [6, 57], [6, 58], [6, 59], [7, 14], [7, 15], [7, 18], [7, 22], [7, 24], [7, 25], [7, 26], [7, 28], [7, 32], [7, 36], [7, 39], [7, 40], [7, 47], [7, 49], [8, 9], [8, 10], [8, 11], [8, 15], [8, 18], [8, 21], [8, 26], [8, 31], [8, 32], [8, 33], [8, 38], [8, 44], [8, 46], [8, 47], [8, 49], [8, 53], [8, 56], [9, 14], [9, 16], [9, 19], [9, 22], [9, 25], [9, 28], [9, 30], [9, 31], [9, 35], [9, 36], [9, 38], [9, 42], [9, 46], [9, 47], [9, 49], [9, 52], [9, 53], [9, 55], [9, 57], [9, 59], [10, 11], [10, 17], [10, 19], [10, 25], [10, 27], [10, 28], [10, 37], [10, 58], [11, 12], [11, 13], [11, 14], [11, 16], [11, 20], [11, 24], [11, 31], [11, 36], [11, 37], [11, 39], [11, 47], [11, 49], [12, 15], [12, 16], [12, 17], [12, 18], [12, 22], [12, 24], [12, 27], [12, 35], [12, 36], [12, 41], [12, 43], [12, 44], [12, 52], [12, 55], [12, 56], [12, 57], [13, 15], [13, 17], [13, 18], [13, 21], [13, 22], [13, 25], [13, 30], [13, 32], [13, 33], [13, 38], [13, 41], [13, 46], [13, 47], [13, 51], [13, 53], [13, 54], [14, 15], [14, 18], [14, 20], [14, 23], [14, 28], [14, 30], [14, 37], [14, 38], [14, 44], [14, 47], [14, 53], [14, 59], [15, 16], [15, 21], [15, 22], [15, 28], [15, 29], [15, 31], [15, 35], [15, 37], [15, 41], [15, 42], [15, 44], [15, 51], [15, 52], [15, 53], [15, 54], [15, 57], [15, 59], [16, 18], [16, 21], [16, 22], [16, 24], [16, 27], [16, 28], [16, 29], [16, 33], [16, 36], [16, 39], [16, 44], [16, 45], [16, 48], [16, 49], [16, 53], [16, 54], [16, 58], [16, 59], [17, 18], [17, 19], [17, 21], [17, 22], [17, 26], [17, 29], [17, 31], [17, 32], [17, 37], [17, 38], [17, 39], [17, 45], [17, 46], [17, 55], [17, 57], [17, 58], [18, 23], [18, 26], [18, 30], [18, 32], [18, 37], [18, 47], [18, 49], [18, 51], [18, 52], [18, 55], [18, 59], [19, 27], [19, 30], [19, 40], [19, 43], [19, 47], [19, 49], [19, 51], [19, 53], [19, 56], [19, 58], [19, 59], [20, 28], [20, 34], [20, 35], [20, 37], [20, 55], [21, 29], [21, 31], [21, 34], [21, 38], [21, 41], [21, 43], [21, 50], [21, 51], [21, 53], [21, 59], [22, 28], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 47], [22, 50], [22, 56], [22, 57], [23, 26], [23, 27], [23, 28], [23, 37], [23, 39], [23, 45], [23, 53], [23, 56], [24, 32], [24, 33], [24, 37], [24, 45], [24, 46], [24, 51], [24, 53], [24, 54], [24, 57], [24, 58], [25, 29], [25, 30], [25, 33], [25, 36], [25, 41], [25, 43], [25, 45], [25, 48], [25, 49], [25, 58], [26, 30], [26, 33], [26, 46], [26, 47], [26, 52], [26, 54], [27, 30], [27, 31], [27, 38], [27, 40], [27, 42], [27, 51], [27, 58], [28, 39], [28, 41], [28, 45], [28, 54], [28, 55], [29, 31], [29, 33], [29, 36], [29, 38], [29, 45], [29, 46], [29, 49], [29, 55], [29, 58], [30, 34], [30, 38], [30, 58], [31, 36], [31, 39], [31, 52], [31, 53], [31, 54], [31, 59], [32, 35], [32, 41], [32, 45], [32, 49], [32, 50], [32, 52], [32, 53], [33, 34], [33, 36], [33, 39], [33, 41], [33, 43], [33, 45], [33, 46], [33, 48], [33, 55], [33, 57], [33, 59], [34, 35], [34, 36], [34, 37], [34, 38], [34, 40], [34, 45], [34, 46], [34, 47], [34, 48], [34, 51], [34, 53], [34, 57], [34, 58], [35, 38], [35, 45], [35, 46], [35, 48], [35, 51], [35, 54], [35, 57], [36, 38], [36, 39], [36, 41], [36, 48], [36, 52], [36, 54], [37, 40], [37, 42], [37, 44], [37, 53], [37, 57], [38, 44], [38, 46], [38, 48], [38, 53], [38, 54], [38, 57], [39, 43], [39, 47], [39, 52], [39, 53], [39, 54], [39, 55], [40, 41], [40, 43], [40, 45], [40, 51], [40, 55], [40, 56], [40, 59], [41, 42], [41, 47], [41, 55], [41, 56], [41, 59], [42, 43], [42, 45], [42, 46], [42, 50], [42, 55], [42, 56], [42, 57], [43, 47], [43, 50], [43, 52], [43, 54], [43, 57], [43, 58], [44, 46], [44, 47], [44, 50], [44, 55], [44, 57], [44, 58], [45, 49], [45, 54], [45, 56], [45, 57], [45, 58], [45, 59], [46, 49], [46, 51], [46, 54], [46, 56], [47, 48], [47, 55], [47, 58], [47, 59], [48, 58], [49, 50], [49, 51], [49, 52], [50, 52], [50, 57], [51, 52], [51, 57], [52, 53], [52, 55], [52, 56], [52, 57], [53, 55], [54, 56], [55, 56], [58, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s8/tests/run.py b/tasks/construct-mc-max-independent-set-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-independent-set-l4-s8/tests/test.sh b/tasks/construct-mc-max-independent-set-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ortholatin-l2-s2/environment/Dockerfile b/tasks/construct-mc-ortholatin-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ortholatin-l2-s2/environment/instance.json b/tasks/construct-mc-ortholatin-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ce228b36a73042af6f18efc0caa65f642f4fcba8 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 7, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l2-s2/solution/solve.sh b/tasks/construct-mc-ortholatin-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6075f963a4d5944dee223e52347fd6e3e4239aa8 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 0], [2, 3, 4, 5, 6, 0, 1], [3, 4, 5, 6, 0, 1, 2], [4, 5, 6, 0, 1, 2, 3], [5, 6, 0, 1, 2, 3, 4], [6, 0, 1, 2, 3, 4, 5]], "Y": [[0, 2, 4, 6, 1, 3, 5], [1, 3, 5, 0, 2, 4, 6], [2, 4, 6, 1, 3, 5, 0], [3, 5, 0, 2, 4, 6, 1], [4, 6, 1, 3, 5, 0, 2], [5, 0, 2, 4, 6, 1, 3], [6, 1, 3, 5, 0, 2, 4]]} +RLMATH_EOF diff --git a/tasks/construct-mc-ortholatin-l2-s2/tests/check.py b/tasks/construct-mc-ortholatin-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a5418a59fae1c86318eee903e90d75b36d8a3306 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s2/tests/check.py @@ -0,0 +1,25 @@ +"""Pair of orthogonal Latin squares of order n (MathConstraint ortholatin, CC-BY-4.0).""" +from run import Invalid, int_list + + +def _square(v, n, name): + if not isinstance(v, list) or len(v) != n: + raise Invalid(f"{name} must be a list of {n} rows") + S = [int_list(r, n, 0, n - 1, f"{name} row") for r in v] + full = list(range(n)) + for i in range(n): + if sorted(S[i]) != full: + raise Invalid(f"{name}: row {i} is not a permutation of 0..{n - 1}") + if sorted(S[r][i] for r in range(n)) != full: + raise Invalid(f"{name}: column {i} is not a permutation of 0..{n - 1}") + return S + + +def check(inst, ans): + n = inst["n"] + X = _square(ans.get("X"), n, "X") + Y = _square(ans.get("Y"), n, "Y") + pairs = {(X[i][j], Y[i][j]) for i in range(n) for j in range(n)} + if len(pairs) != n * n: + raise Invalid("X and Y are not orthogonal (some ordered pair repeats)") + return None, {} diff --git a/tasks/construct-mc-ortholatin-l2-s2/tests/instance.json b/tasks/construct-mc-ortholatin-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ce228b36a73042af6f18efc0caa65f642f4fcba8 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 7, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l2-s2/tests/run.py b/tasks/construct-mc-ortholatin-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ortholatin-l2-s2/tests/test.sh b/tasks/construct-mc-ortholatin-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s3/environment/Dockerfile b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s3/environment/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83941052f7df452b2275082bd65e179d330e428c --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 25, "required_edges": [], "max_chromatic_number": 4, "min_edges": 31, "min_girth": 7, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s3/solution/solve.sh b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ca595611d295514bbc4393f3e342bf0bf1a708f5 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 24], [1, 22], [1, 23], [2, 20], [2, 21], [3, 18], [3, 19], [4, 16], [4, 17], [4, 24], [5, 15], [5, 17], [5, 23], [6, 14], [6, 17], [6, 21], [7, 13], [7, 16], [7, 22], [8, 12], [8, 14], [8, 19], [9, 11], [9, 13], [9, 21], [10, 11], [10, 12], [10, 23], [11, 18], [12, 20], [13, 15], [14, 22], [15, 19], [16, 20], [18, 24]], "coloring": [0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1, 0, 1, 0, 1, 2, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/check.py b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83941052f7df452b2275082bd65e179d330e428c --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 25, "required_edges": [], "max_chromatic_number": 4, "min_edges": 31, "min_girth": 7, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/run.py b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/test.sh b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s4/environment/Dockerfile b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s4/environment/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9965ff50b10556b96aceb7fc7ed7b9eb9816cfe1 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 30, "required_edges": [], "max_chromatic_number": 5, "min_edges": 42, "min_girth": 7, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s4/solution/solve.sh b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..96ea57d331d8e7f17e27c6f587a809281608f5c3 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 28], [0, 29], [1, 27], [1, 29], [2, 26], [2, 28], [3, 26], [3, 27], [4, 24], [4, 25], [5, 23], [5, 25], [6, 22], [6, 24], [6, 29], [7, 21], [7, 24], [7, 26], [8, 20], [8, 23], [8, 29], [9, 19], [9, 22], [10, 18], [10, 20], [11, 17], [11, 19], [12, 17], [12, 18], [12, 24], [13, 16], [13, 18], [13, 28], [14, 15], [14, 17], [14, 27], [15, 16], [16, 22], [17, 23], [19, 21], [20, 21], [25, 28]], "coloring": [1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 1, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/check.py b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9965ff50b10556b96aceb7fc7ed7b9eb9816cfe1 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 30, "required_edges": [], "max_chromatic_number": 5, "min_edges": 42, "min_girth": 7, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/run.py b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/test.sh b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s1/environment/Dockerfile b/tasks/construct-mc-pysms-girth-degree-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s1/environment/instance.json b/tasks/construct-mc-pysms-girth-degree-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..750b59172862d6183833f00112c3e06316e41845 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 26, "required_edges": [], "max_degree": 4, "min_degree": 3, "min_girth": 7, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s1/solution/solve.sh b/tasks/construct-mc-pysms-girth-degree-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4e8d44a44732c4103378843549e8403db9078f2e --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 23], [0, 24], [0, 25], [1, 21], [1, 22], [1, 25], [2, 19], [2, 20], [2, 25], [3, 17], [3, 18], [3, 24], [4, 16], [4, 18], [4, 22], [5, 15], [5, 18], [5, 20], [6, 14], [6, 17], [6, 21], [7, 12], [7, 13], [7, 24], [8, 11], [8, 13], [8, 22], [9, 10], [9, 12], [9, 19], [10, 11], [10, 15], [11, 23], [12, 16], [13, 20], [14, 16], [14, 23], [15, 21], [17, 19]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/check.py b/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/instance.json b/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..750b59172862d6183833f00112c3e06316e41845 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 26, "required_edges": [], "max_degree": 4, "min_degree": 3, "min_girth": 7, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/run.py b/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/test.sh b/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s0/environment/Dockerfile b/tasks/construct-mc-pysms-graph-builder-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s0/environment/instance.json b/tasks/construct-mc-pysms-graph-builder-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..75c5cebc3e82a84abc934d8c349476594ebde2f5 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 9, "required_edges": [[5, 6], [2, 3]], "max_degree": 3, "min_degree": 2, "max_chromatic_number": 4, "min_chromatic_number": 2, "min_edges": 9, "max_edges": 18, "family": "mc_pysms_graph_builder", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s0/solution/solve.sh b/tasks/construct-mc-pysms-graph-builder-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3b4405dac03781aa53de155da787d0d617cbc864 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 7], [0, 8], [1, 5], [1, 6], [1, 8], [2, 3], [2, 4], [2, 8], [3, 4], [3, 7], [4, 6], [5, 6], [5, 7]], "coloring": [2, 0, 0, 1, 2, 1, 3, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/check.py b/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/instance.json b/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..75c5cebc3e82a84abc934d8c349476594ebde2f5 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 9, "required_edges": [[5, 6], [2, 3]], "max_degree": 3, "min_degree": 2, "max_chromatic_number": 4, "min_chromatic_number": 2, "min_edges": 9, "max_edges": 18, "family": "mc_pysms_graph_builder", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/run.py b/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/test.sh b/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s0/environment/Dockerfile b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s0/environment/instance.json b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a1333e722fbded8401f2c605793b5fec100fd855 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 12, "required_edges": [], "max_independent_set": 3, "min_connectivity": 4, "family": "mc_pysms_independent_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s0/solution/solve.sh b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9099c841c9e48c114f5c02b50d3a66619d4ef75d --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [7, 11], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/check.py b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/instance.json b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a1333e722fbded8401f2c605793b5fec100fd855 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 12, "required_edges": [], "max_independent_set": 3, "min_connectivity": 4, "family": "mc_pysms_independent_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/run.py b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/test.sh b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-min-girth-l4-s1/environment/Dockerfile b/tasks/construct-mc-pysms-min-girth-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-min-girth-l4-s1/environment/instance.json b/tasks/construct-mc-pysms-min-girth-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f73201834f0c220cc4bef7145d05d9a291975136 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 17, "required_edges": [[1, 16], [5, 15], [4, 13], [2, 7], [6, 13], [8, 9], [2, 6], [8, 15], [5, 6], [7, 15], [2, 5], [3, 12], [1, 11], [9, 14], [4, 7], [12, 16], [4, 16], [1, 9], [7, 11], [6, 11], [13, 14], [3, 16], [10, 12], [12, 13], [0, 12], [1, 3], [0, 14]], "min_girth": 3, "family": "mc_pysms_min_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-girth-l4-s1/solution/solve.sh b/tasks/construct-mc-pysms-min-girth-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..91678b0bbaa9db4dc3d237a7c871b1f009c90fd7 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [12, 13], [12, 14], [12, 15], [12, 16], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-girth-l4-s1/tests/check.py b/tasks/construct-mc-pysms-min-girth-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s1/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-min-girth-l4-s1/tests/instance.json b/tasks/construct-mc-pysms-min-girth-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f73201834f0c220cc4bef7145d05d9a291975136 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 17, "required_edges": [[1, 16], [5, 15], [4, 13], [2, 7], [6, 13], [8, 9], [2, 6], [8, 15], [5, 6], [7, 15], [2, 5], [3, 12], [1, 11], [9, 14], [4, 7], [12, 16], [4, 16], [1, 9], [7, 11], [6, 11], [13, 14], [3, 16], [10, 12], [12, 13], [0, 12], [1, 3], [0, 14]], "min_girth": 3, "family": "mc_pysms_min_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-girth-l4-s1/tests/run.py b/tasks/construct-mc-pysms-min-girth-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-min-girth-l4-s1/tests/test.sh b/tasks/construct-mc-pysms-min-girth-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/environment/Dockerfile b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/environment/instance.json b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4f4163a7989c8e80db8d64f7dfc88fe5c1a4f0f2 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 10, "required_edges": [[4, 8], [3, 7], [6, 7], [2, 8], [0, 8], [0, 5]], "max_edges": 31, "min_edges": 27, "family": "mc_pysms_num_edges_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/solution/solve.sh b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..915d33d11b423b7ea4e9c438f3c3af89776979a8 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 6], [3, 7], [3, 8], [3, 9], [4, 5], [4, 8], [4, 9], [5, 6], [5, 7], [6, 7], [8, 9]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/check.py b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/instance.json b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4f4163a7989c8e80db8d64f7dfc88fe5c1a4f0f2 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 10, "required_edges": [[4, 8], [3, 7], [6, 7], [2, 8], [0, 8], [0, 5]], "max_edges": 31, "min_edges": 27, "family": "mc_pysms_num_edges_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/run.py b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/test.sh b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l2-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ramsey-l4-s1/environment/Dockerfile b/tasks/construct-mc-ramsey-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ramsey-l4-s1/environment/instance.json b/tasks/construct-mc-ramsey-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0df7dc68bdf7ede706689523ff95892935a04120 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "r": 7, "s": 3, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s1/solution/solve.sh b/tasks/construct-mc-ramsey-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cf89282db024cf767de56db19a67d7c94c0d5891 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l4-s1/tests/check.py b/tasks/construct-mc-ramsey-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s1/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l4-s1/tests/instance.json b/tasks/construct-mc-ramsey-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0df7dc68bdf7ede706689523ff95892935a04120 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "r": 7, "s": 3, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s1/tests/run.py b/tasks/construct-mc-ramsey-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ramsey-l4-s1/tests/test.sh b/tasks/construct-mc-ramsey-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ramsey-l4-s6/environment/Dockerfile b/tasks/construct-mc-ramsey-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ramsey-l4-s6/environment/instance.json b/tasks/construct-mc-ramsey-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6c8d1383f30d2d34bfb92eaba5185790cded15b7 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 19, "r": 7, "s": 3, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s6/solution/solve.sh b/tasks/construct-mc-ramsey-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..69928e54d37c72d251c474d69c3135edfee83247 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l4-s6/tests/check.py b/tasks/construct-mc-ramsey-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s6/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l4-s6/tests/instance.json b/tasks/construct-mc-ramsey-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6c8d1383f30d2d34bfb92eaba5185790cded15b7 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 19, "r": 7, "s": 3, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s6/tests/run.py b/tasks/construct-mc-ramsey-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ramsey-l4-s6/tests/test.sh b/tasks/construct-mc-ramsey-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ramsey-l4-s8/environment/Dockerfile b/tasks/construct-mc-ramsey-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ramsey-l4-s8/environment/instance.json b/tasks/construct-mc-ramsey-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0579629a4c397d3fc4780a44f686950f64e00875 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "r": 3, "s": 7, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s8/solution/solve.sh b/tasks/construct-mc-ramsey-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d35f46299aa8972905828827c13de9aa49f69d6a --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l4-s8/tests/check.py b/tasks/construct-mc-ramsey-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s8/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l4-s8/tests/instance.json b/tasks/construct-mc-ramsey-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0579629a4c397d3fc4780a44f686950f64e00875 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "r": 3, "s": 7, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s8/tests/run.py b/tasks/construct-mc-ramsey-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ramsey-l4-s8/tests/test.sh b/tasks/construct-mc-ramsey-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-social-golfers-l5-s2/environment/Dockerfile b/tasks/construct-mc-social-golfers-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-social-golfers-l5-s2/environment/instance.json b/tasks/construct-mc-social-golfers-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..657dc2fa487c51158f7aafacf8ab002cb7e05c98 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"n_groups": 10, "group_size": 5, "n_weeks": 6, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l5-s2/solution/solve.sh b/tasks/construct-mc-social-golfers-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b3c47799f6f9aafcfc33e646e34a315a934039f7 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"schedule": [[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9], [5, 6, 0, 1, 9, 3, 9, 4, 1, 2, 5, 6, 2, 1, 4, 8, 7, 4, 2, 1, 7, 0, 9, 3, 8, 8, 3, 7, 6, 0, 2, 0, 5, 7, 9, 5, 8, 1, 9, 6, 4, 3, 2, 6, 5, 4, 7, 8, 3, 0], [3, 6, 5, 4, 2, 3, 9, 5, 0, 4, 0, 1, 8, 9, 4, 1, 3, 9, 6, 7, 2, 0, 7, 1, 3, 9, 4, 5, 2, 8, 2, 7, 9, 6, 8, 7, 4, 8, 6, 5, 1, 2, 0, 3, 5, 7, 0, 6, 8, 1], [0, 3, 4, 5, 7, 8, 2, 1, 4, 0, 9, 7, 8, 6, 3, 6, 4, 8, 9, 7, 8, 6, 9, 2, 5, 3, 1, 5, 0, 2, 6, 3, 5, 2, 4, 8, 4, 3, 1, 9, 0, 9, 5, 1, 7, 2, 0, 7, 6, 1], [8, 3, 4, 1, 5, 9, 6, 5, 2, 4, 4, 0, 5, 3, 8, 9, 6, 1, 7, 4, 7, 5, 3, 8, 4, 0, 7, 8, 6, 3, 2, 1, 7, 9, 0, 2, 5, 6, 8, 9, 7, 0, 9, 2, 1, 0, 3, 2, 1, 6], [0, 8, 9, 5, 6, 9, 0, 2, 3, 1, 8, 1, 3, 7, 9, 6, 5, 8, 2, 4, 4, 0, 1, 2, 7, 5, 0, 1, 3, 4, 5, 7, 9, 3, 8, 2, 4, 6, 7, 0, 5, 7, 4, 6, 3, 6, 2, 9, 1, 8]]} +RLMATH_EOF diff --git a/tasks/construct-mc-social-golfers-l5-s2/tests/check.py b/tasks/construct-mc-social-golfers-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..73977815b7b6094a8491075b6dc2ae1293e44930 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s2/tests/check.py @@ -0,0 +1,25 @@ +"""Social golfer problem (MathConstraint social_golfers, CSPLib prob010, CC-BY-4.0): each week partition +the g*s players into g groups of size s; no two players share a group in more than one week.""" +from run import Invalid, int_list + + +def check(inst, ans): + g, s, w = inst["n_groups"], inst["group_size"], inst["n_weeks"] + P = g * s + sched = ans.get("schedule") + if not isinstance(sched, list) or len(sched) != w: + raise Invalid(f"schedule must be a list of {w} weeks") + met = set() + for wk, row in enumerate(sched): + row = int_list(row, P, 0, g - 1, f"week {wk}") + groups = [[p for p in range(P) if row[p] == grp] for grp in range(g)] + for grp, mem in enumerate(groups): + if len(mem) != s: + raise Invalid(f"week {wk}: group {grp} has {len(mem)} players, need {s}") + for i in range(s): + for j in range(i + 1, s): + pr = (mem[i], mem[j]) + if pr in met: + raise Invalid(f"players {pr} play together in more than one week") + met.add(pr) + return None, {} diff --git a/tasks/construct-mc-social-golfers-l5-s2/tests/instance.json b/tasks/construct-mc-social-golfers-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..657dc2fa487c51158f7aafacf8ab002cb7e05c98 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"n_groups": 10, "group_size": 5, "n_weeks": 6, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l5-s2/tests/run.py b/tasks/construct-mc-social-golfers-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-social-golfers-l5-s2/tests/test.sh b/tasks/construct-mc-social-golfers-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-vertex-cover-l1-s2/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l1-s2/environment/instance.json b/tasks/construct-mc-vertex-cover-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ce9d538bae0cfd3517ed2e149020d4c3d46575bd --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 8], [0, 14], [1, 9], [1, 12], [1, 19], [2, 4], [2, 9], [3, 10], [3, 15], [4, 5], [4, 8], [4, 10], [4, 15], [5, 15], [6, 8], [6, 18], [7, 9], [7, 10], [7, 16], [8, 10], [8, 11], [8, 14], [8, 15], [8, 16], [8, 18], [9, 16], [9, 17], [9, 19], [10, 11], [11, 13], [12, 17], [14, 16]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s2/solution/solve.sh b/tasks/construct-mc-vertex-cover-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dc22735b495b600a2b83191cfb301647dd9a8ebc --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [1, 4, 6, 7, 8, 9, 10, 12, 13, 14, 15]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l1-s2/tests/check.py b/tasks/construct-mc-vertex-cover-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s2/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l1-s2/tests/instance.json b/tasks/construct-mc-vertex-cover-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ce9d538bae0cfd3517ed2e149020d4c3d46575bd --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 8], [0, 14], [1, 9], [1, 12], [1, 19], [2, 4], [2, 9], [3, 10], [3, 15], [4, 5], [4, 8], [4, 10], [4, 15], [5, 15], [6, 8], [6, 18], [7, 9], [7, 10], [7, 16], [8, 10], [8, 11], [8, 14], [8, 15], [8, 16], [8, 18], [9, 16], [9, 17], [9, 19], [10, 11], [11, 13], [12, 17], [14, 16]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s2/tests/run.py b/tasks/construct-mc-vertex-cover-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l1-s2/tests/test.sh b/tasks/construct-mc-vertex-cover-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-vertex-cover-l1-s5/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l1-s5/environment/instance.json b/tasks/construct-mc-vertex-cover-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3e793979e944066e57db6d7f5b8bf79e5a20f46d --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 5], [0, 6], [0, 13], [1, 2], [1, 12], [2, 13], [2, 15], [3, 8], [3, 12], [3, 19], [4, 6], [4, 14], [4, 15], [4, 17], [4, 18], [5, 7], [5, 8], [5, 9], [5, 11], [6, 12], [6, 13], [6, 14], [6, 15], [7, 15], [7, 16], [8, 17], [9, 14], [9, 15], [10, 13], [12, 13], [13, 15], [13, 19], [15, 16], [15, 19], [17, 18]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s5/solution/solve.sh b/tasks/construct-mc-vertex-cover-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..42692c46cc32e84450b8d00ad145f1cf370ed101 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [2, 3, 5, 6, 12, 13, 14, 15, 16, 17, 18]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l1-s5/tests/check.py b/tasks/construct-mc-vertex-cover-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s5/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l1-s5/tests/instance.json b/tasks/construct-mc-vertex-cover-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3e793979e944066e57db6d7f5b8bf79e5a20f46d --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 5], [0, 6], [0, 13], [1, 2], [1, 12], [2, 13], [2, 15], [3, 8], [3, 12], [3, 19], [4, 6], [4, 14], [4, 15], [4, 17], [4, 18], [5, 7], [5, 8], [5, 9], [5, 11], [6, 12], [6, 13], [6, 14], [6, 15], [7, 15], [7, 16], [8, 17], [9, 14], [9, 15], [10, 13], [12, 13], [13, 15], [13, 19], [15, 16], [15, 19], [17, 18]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s5/tests/run.py b/tasks/construct-mc-vertex-cover-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l1-s5/tests/test.sh b/tasks/construct-mc-vertex-cover-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-vertex-cover-l5-s3/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l5-s3/environment/instance.json b/tasks/construct-mc-vertex-cover-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..245a1f87bf6eafb7cefda467a6640cef34c0cd2e --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 13], [0, 19], [0, 20], [0, 25], [0, 31], [0, 32], [0, 33], [0, 38], [0, 48], [0, 56], [0, 60], [0, 69], [0, 75], [0, 89], [1, 35], [1, 36], [1, 41], [1, 46], [1, 47], [1, 56], [1, 62], [1, 76], [1, 80], [1, 89], [2, 5], [2, 13], [2, 18], [2, 20], [2, 25], [2, 30], [2, 35], [2, 41], [2, 57], [2, 58], [2, 64], [2, 65], [2, 70], [2, 73], [2, 77], [2, 80], [2, 84], [3, 8], [3, 14], [3, 30], [3, 31], [3, 32], [4, 15], [4, 23], [4, 34], [4, 35], [4, 41], [4, 54], [4, 71], [4, 75], [4, 76], [4, 80], [4, 84], [4, 85], [4, 87], [5, 21], [5, 29], [5, 32], [5, 35], [5, 40], [5, 45], [5, 48], [5, 53], [5, 61], [5, 88], [6, 7], [6, 18], [6, 24], [6, 30], [6, 32], [6, 52], [6, 53], [6, 54], [6, 73], [7, 8], [7, 11], [7, 12], [7, 15], [7, 16], [7, 19], [7, 25], [7, 27], [7, 28], [7, 30], [7, 31], [7, 34], [7, 35], [7, 54], [7, 55], [7, 56], [7, 57], [7, 72], [7, 73], [7, 77], [7, 84], [8, 9], [8, 14], [8, 16], [8, 23], [8, 29], [8, 34], [8, 37], [8, 52], [8, 54], [8, 57], [8, 63], [8, 67], [8, 72], [8, 83], [9, 17], [9, 27], [9, 28], [9, 29], [9, 39], [9, 40], [9, 43], [9, 45], [9, 47], [9, 81], [9, 85], [10, 15], [10, 25], [10, 31], [10, 32], [10, 36], [10, 66], [10, 74], [10, 88], [11, 15], [11, 20], [11, 21], [11, 35], [11, 38], [11, 45], [11, 74], [11, 80], [12, 18], [12, 24], [12, 60], [12, 61], [12, 66], [12, 68], [12, 80], [12, 81], [13, 80], [13, 87], [14, 18], [14, 28], [14, 42], [14, 52], [14, 55], [14, 56], [14, 60], [14, 63], [14, 82], [14, 88], [15, 29], [15, 33], [15, 44], [15, 47], [15, 48], [15, 49], [15, 58], [15, 60], [15, 61], [15, 63], [15, 73], [15, 79], [15, 87], [16, 31], [16, 36], [16, 38], [16, 51], [16, 54], [16, 79], [17, 35], [17, 41], [17, 46], [17, 52], [17, 62], [17, 67], [17, 76], [17, 77], [17, 80], [17, 87], [18, 31], [18, 34], [18, 38], [18, 43], [18, 50], [18, 54], [18, 66], [18, 72], [18, 76], [18, 85], [18, 87], [19, 27], [19, 28], [19, 30], [19, 32], [19, 35], [19, 44], [19, 52], [19, 72], [19, 73], [19, 74], [19, 84], [20, 23], [20, 45], [20, 50], [20, 51], [20, 53], [20, 60], [20, 64], [20, 70], [20, 76], [20, 78], [20, 82], [20, 83], [21, 29], [21, 35], [21, 37], [21, 38], [21, 50], [21, 51], [21, 57], [21, 72], [21, 74], [21, 77], [21, 87], [22, 36], [22, 46], [22, 75], [22, 79], [23, 24], [23, 26], [23, 35], [23, 41], [23, 51], [23, 56], [23, 64], [23, 74], [23, 85], [24, 28], [24, 31], [24, 35], [24, 47], [24, 48], [24, 50], [24, 51], [24, 54], [24, 60], [24, 69], [24, 80], [24, 82], [24, 85], [25, 28], [25, 32], [25, 49], [25, 50], [25, 51], [25, 57], [25, 66], [25, 69], [25, 75], [25, 80], [25, 84], [26, 40], [26, 47], [26, 49], [26, 60], [26, 69], [26, 76], [26, 77], [26, 87], [27, 38], [27, 76], [28, 29], [28, 31], [28, 48], [28, 50], [28, 78], [28, 80], [28, 87], [29, 31], [29, 32], [29, 34], [29, 44], [29, 46], [29, 54], [29, 60], [29, 63], [29, 64], [29, 69], [29, 85], [29, 87], [30, 39], [30, 45], [30, 46], [30, 59], [30, 66], [30, 73], [30, 74], [30, 75], [30, 80], [30, 82], [30, 85], [30, 87], [31, 33], [31, 35], [31, 36], [31, 40], [31, 43], [31, 49], [31, 58], [31, 70], [31, 73], [31, 81], [31, 87], [32, 36], [32, 39], [32, 41], [32, 48], [32, 52], [32, 62], [32, 70], [32, 77], [33, 47], [33, 52], [33, 75], [33, 86], [33, 89], [34, 41], [34, 47], [34, 61], [34, 62], [34, 63], [34, 88], [34, 89], [35, 36], [35, 50], [35, 55], [35, 57], [35, 70], [35, 82], [35, 85], [36, 77], [36, 81], [36, 87], [37, 45], [37, 58], [37, 65], [37, 71], [37, 78], [37, 86], [37, 87], [37, 88], [38, 40], [38, 44], [38, 51], [38, 59], [38, 62], [38, 86], [39, 45], [39, 48], [39, 60], [39, 63], [39, 64], [39, 68], [39, 83], [40, 50], [40, 67], [40, 81], [40, 84], [41, 47], [41, 48], [41, 49], [41, 56], [41, 60], [41, 82], [41, 87], [42, 44], [42, 69], [42, 70], [42, 81], [42, 88], [43, 45], [43, 49], [43, 53], [43, 58], [43, 68], [43, 78], [43, 82], [43, 88], [43, 89], [44, 47], [44, 48], [44, 49], [44, 50], [44, 66], [44, 71], [44, 77], [45, 51], [45, 59], [45, 69], [45, 71], [45, 73], [45, 75], [45, 81], [45, 83], [46, 49], [46, 57], [46, 65], [46, 66], [46, 75], [46, 80], [46, 81], [46, 82], [46, 84], [47, 49], [47, 53], [47, 56], [47, 58], [47, 74], [48, 57], [48, 61], [48, 63], [48, 67], [48, 84], [49, 54], [49, 55], [49, 64], [49, 69], [49, 73], [50, 57], [50, 68], [50, 85], [50, 89], [51, 54], [51, 60], [51, 61], [51, 62], [51, 67], [51, 69], [51, 79], [51, 84], [51, 88], [52, 55], [52, 57], [52, 61], [52, 68], [52, 75], [52, 78], [52, 82], [53, 76], [54, 63], [54, 66], [54, 82], [54, 85], [54, 86], [55, 58], [55, 65], [55, 71], [55, 74], [55, 75], [55, 86], [56, 60], [56, 65], [56, 67], [56, 68], [56, 72], [56, 78], [57, 63], [57, 65], [57, 74], [57, 76], [57, 77], [58, 66], [58, 67], [58, 72], [58, 76], [58, 83], [59, 61], [59, 65], [59, 79], [59, 80], [59, 85], [59, 87], [59, 88], [59, 89], [60, 87], [61, 63], [61, 68], [61, 71], [61, 73], [61, 74], [61, 78], [61, 79], [61, 89], [62, 74], [62, 77], [62, 84], [63, 65], [63, 71], [63, 79], [63, 80], [64, 65], [64, 87], [64, 89], [65, 71], [65, 72], [65, 84], [66, 71], [66, 83], [66, 84], [66, 87], [66, 88], [67, 70], [67, 75], [68, 89], [69, 76], [69, 80], [70, 71], [70, 73], [70, 87], [70, 89], [71, 78], [73, 76], [73, 84], [73, 85], [73, 88], [74, 78], [74, 82], [74, 84], [74, 87], [74, 88], [75, 85], [75, 86], [76, 77], [76, 84], [77, 78], [77, 80], [77, 89], [78, 79], [78, 80], [84, 89], [86, 87]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s3/solution/solve.sh b/tasks/construct-mc-vertex-cover-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..16476c02a11a9e7d6dcea1fd691213c4903af5bd --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [0, 2, 4, 5, 7, 8, 9, 12, 14, 15, 18, 19, 20, 21, 24, 25, 26, 29, 30, 31, 32, 35, 36, 38, 39, 40, 41, 42, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 58, 61, 62, 63, 64, 65, 66, 67, 68, 71, 73, 74, 75, 76, 77, 78, 79, 80, 82, 85, 86, 87, 88, 89]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l5-s3/tests/check.py b/tasks/construct-mc-vertex-cover-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s3/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l5-s3/tests/instance.json b/tasks/construct-mc-vertex-cover-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..245a1f87bf6eafb7cefda467a6640cef34c0cd2e --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 13], [0, 19], [0, 20], [0, 25], [0, 31], [0, 32], [0, 33], [0, 38], [0, 48], [0, 56], [0, 60], [0, 69], [0, 75], [0, 89], [1, 35], [1, 36], [1, 41], [1, 46], [1, 47], [1, 56], [1, 62], [1, 76], [1, 80], [1, 89], [2, 5], [2, 13], [2, 18], [2, 20], [2, 25], [2, 30], [2, 35], [2, 41], [2, 57], [2, 58], [2, 64], [2, 65], [2, 70], [2, 73], [2, 77], [2, 80], [2, 84], [3, 8], [3, 14], [3, 30], [3, 31], [3, 32], [4, 15], [4, 23], [4, 34], [4, 35], [4, 41], [4, 54], [4, 71], [4, 75], [4, 76], [4, 80], [4, 84], [4, 85], [4, 87], [5, 21], [5, 29], [5, 32], [5, 35], [5, 40], [5, 45], [5, 48], [5, 53], [5, 61], [5, 88], [6, 7], [6, 18], [6, 24], [6, 30], [6, 32], [6, 52], [6, 53], [6, 54], [6, 73], [7, 8], [7, 11], [7, 12], [7, 15], [7, 16], [7, 19], [7, 25], [7, 27], [7, 28], [7, 30], [7, 31], [7, 34], [7, 35], [7, 54], [7, 55], [7, 56], [7, 57], [7, 72], [7, 73], [7, 77], [7, 84], [8, 9], [8, 14], [8, 16], [8, 23], [8, 29], [8, 34], [8, 37], [8, 52], [8, 54], [8, 57], [8, 63], [8, 67], [8, 72], [8, 83], [9, 17], [9, 27], [9, 28], [9, 29], [9, 39], [9, 40], [9, 43], [9, 45], [9, 47], [9, 81], [9, 85], [10, 15], [10, 25], [10, 31], [10, 32], [10, 36], [10, 66], [10, 74], [10, 88], [11, 15], [11, 20], [11, 21], [11, 35], [11, 38], [11, 45], [11, 74], [11, 80], [12, 18], [12, 24], [12, 60], [12, 61], [12, 66], [12, 68], [12, 80], [12, 81], [13, 80], [13, 87], [14, 18], [14, 28], [14, 42], [14, 52], [14, 55], [14, 56], [14, 60], [14, 63], [14, 82], [14, 88], [15, 29], [15, 33], [15, 44], [15, 47], [15, 48], [15, 49], [15, 58], [15, 60], [15, 61], [15, 63], [15, 73], [15, 79], [15, 87], [16, 31], [16, 36], [16, 38], [16, 51], [16, 54], [16, 79], [17, 35], [17, 41], [17, 46], [17, 52], [17, 62], [17, 67], [17, 76], [17, 77], [17, 80], [17, 87], [18, 31], [18, 34], [18, 38], [18, 43], [18, 50], [18, 54], [18, 66], [18, 72], [18, 76], [18, 85], [18, 87], [19, 27], [19, 28], [19, 30], [19, 32], [19, 35], [19, 44], [19, 52], [19, 72], [19, 73], [19, 74], [19, 84], [20, 23], [20, 45], [20, 50], [20, 51], [20, 53], [20, 60], [20, 64], [20, 70], [20, 76], [20, 78], [20, 82], [20, 83], [21, 29], [21, 35], [21, 37], [21, 38], [21, 50], [21, 51], [21, 57], [21, 72], [21, 74], [21, 77], [21, 87], [22, 36], [22, 46], [22, 75], [22, 79], [23, 24], [23, 26], [23, 35], [23, 41], [23, 51], [23, 56], [23, 64], [23, 74], [23, 85], [24, 28], [24, 31], [24, 35], [24, 47], [24, 48], [24, 50], [24, 51], [24, 54], [24, 60], [24, 69], [24, 80], [24, 82], [24, 85], [25, 28], [25, 32], [25, 49], [25, 50], [25, 51], [25, 57], [25, 66], [25, 69], [25, 75], [25, 80], [25, 84], [26, 40], [26, 47], [26, 49], [26, 60], [26, 69], [26, 76], [26, 77], [26, 87], [27, 38], [27, 76], [28, 29], [28, 31], [28, 48], [28, 50], [28, 78], [28, 80], [28, 87], [29, 31], [29, 32], [29, 34], [29, 44], [29, 46], [29, 54], [29, 60], [29, 63], [29, 64], [29, 69], [29, 85], [29, 87], [30, 39], [30, 45], [30, 46], [30, 59], [30, 66], [30, 73], [30, 74], [30, 75], [30, 80], [30, 82], [30, 85], [30, 87], [31, 33], [31, 35], [31, 36], [31, 40], [31, 43], [31, 49], [31, 58], [31, 70], [31, 73], [31, 81], [31, 87], [32, 36], [32, 39], [32, 41], [32, 48], [32, 52], [32, 62], [32, 70], [32, 77], [33, 47], [33, 52], [33, 75], [33, 86], [33, 89], [34, 41], [34, 47], [34, 61], [34, 62], [34, 63], [34, 88], [34, 89], [35, 36], [35, 50], [35, 55], [35, 57], [35, 70], [35, 82], [35, 85], [36, 77], [36, 81], [36, 87], [37, 45], [37, 58], [37, 65], [37, 71], [37, 78], [37, 86], [37, 87], [37, 88], [38, 40], [38, 44], [38, 51], [38, 59], [38, 62], [38, 86], [39, 45], [39, 48], [39, 60], [39, 63], [39, 64], [39, 68], [39, 83], [40, 50], [40, 67], [40, 81], [40, 84], [41, 47], [41, 48], [41, 49], [41, 56], [41, 60], [41, 82], [41, 87], [42, 44], [42, 69], [42, 70], [42, 81], [42, 88], [43, 45], [43, 49], [43, 53], [43, 58], [43, 68], [43, 78], [43, 82], [43, 88], [43, 89], [44, 47], [44, 48], [44, 49], [44, 50], [44, 66], [44, 71], [44, 77], [45, 51], [45, 59], [45, 69], [45, 71], [45, 73], [45, 75], [45, 81], [45, 83], [46, 49], [46, 57], [46, 65], [46, 66], [46, 75], [46, 80], [46, 81], [46, 82], [46, 84], [47, 49], [47, 53], [47, 56], [47, 58], [47, 74], [48, 57], [48, 61], [48, 63], [48, 67], [48, 84], [49, 54], [49, 55], [49, 64], [49, 69], [49, 73], [50, 57], [50, 68], [50, 85], [50, 89], [51, 54], [51, 60], [51, 61], [51, 62], [51, 67], [51, 69], [51, 79], [51, 84], [51, 88], [52, 55], [52, 57], [52, 61], [52, 68], [52, 75], [52, 78], [52, 82], [53, 76], [54, 63], [54, 66], [54, 82], [54, 85], [54, 86], [55, 58], [55, 65], [55, 71], [55, 74], [55, 75], [55, 86], [56, 60], [56, 65], [56, 67], [56, 68], [56, 72], [56, 78], [57, 63], [57, 65], [57, 74], [57, 76], [57, 77], [58, 66], [58, 67], [58, 72], [58, 76], [58, 83], [59, 61], [59, 65], [59, 79], [59, 80], [59, 85], [59, 87], [59, 88], [59, 89], [60, 87], [61, 63], [61, 68], [61, 71], [61, 73], [61, 74], [61, 78], [61, 79], [61, 89], [62, 74], [62, 77], [62, 84], [63, 65], [63, 71], [63, 79], [63, 80], [64, 65], [64, 87], [64, 89], [65, 71], [65, 72], [65, 84], [66, 71], [66, 83], [66, 84], [66, 87], [66, 88], [67, 70], [67, 75], [68, 89], [69, 76], [69, 80], [70, 71], [70, 73], [70, 87], [70, 89], [71, 78], [73, 76], [73, 84], [73, 85], [73, 88], [74, 78], [74, 82], [74, 84], [74, 87], [74, 88], [75, 85], [75, 86], [76, 77], [76, 84], [77, 78], [77, 80], [77, 89], [78, 79], [78, 80], [84, 89], [86, 87]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s3/tests/run.py b/tasks/construct-mc-vertex-cover-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l5-s3/tests/test.sh b/tasks/construct-mc-vertex-cover-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-vertex-cover-l5-s4/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l5-s4/environment/instance.json b/tasks/construct-mc-vertex-cover-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ac65a4439539d467d46a23bfa01c9c711c1ff0ae --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 3], [0, 5], [0, 28], [0, 29], [0, 33], [0, 35], [0, 48], [0, 58], [0, 72], [0, 73], [0, 78], [1, 9], [1, 14], [1, 15], [1, 20], [1, 27], [1, 31], [1, 32], [1, 34], [1, 35], [1, 40], [1, 41], [1, 47], [1, 52], [1, 54], [1, 57], [1, 60], [1, 81], [1, 82], [1, 86], [2, 3], [2, 4], [2, 7], [2, 10], [2, 12], [2, 23], [2, 29], [2, 39], [2, 50], [2, 52], [2, 69], [2, 78], [2, 88], [3, 10], [3, 14], [3, 20], [3, 27], [3, 32], [3, 55], [3, 56], [3, 63], [3, 69], [3, 72], [3, 78], [4, 6], [4, 7], [4, 15], [4, 21], [4, 30], [4, 34], [4, 37], [4, 45], [4, 51], [4, 57], [4, 59], [4, 60], [4, 61], [4, 69], [4, 70], [4, 77], [4, 80], [5, 11], [5, 24], [5, 27], [5, 30], [5, 37], [5, 38], [5, 61], [5, 63], [5, 69], [5, 82], [6, 8], [6, 13], [6, 39], [6, 58], [6, 61], [6, 64], [6, 65], [6, 78], [6, 80], [6, 84], [7, 9], [7, 25], [7, 38], [7, 40], [7, 42], [7, 50], [7, 61], [7, 62], [7, 73], [7, 82], [8, 13], [8, 20], [8, 44], [8, 55], [8, 68], [8, 75], [9, 22], [9, 25], [9, 26], [9, 40], [9, 64], [9, 72], [9, 79], [9, 81], [9, 86], [10, 12], [10, 16], [10, 17], [10, 26], [10, 39], [10, 40], [10, 49], [10, 59], [10, 65], [10, 70], [10, 75], [10, 83], [11, 29], [11, 38], [11, 44], [11, 53], [11, 63], [11, 77], [11, 88], [12, 19], [12, 21], [12, 26], [12, 28], [12, 31], [12, 34], [12, 50], [12, 56], [12, 61], [12, 71], [12, 73], [13, 19], [13, 21], [13, 24], [13, 51], [13, 60], [13, 61], [13, 71], [13, 79], [13, 85], [13, 86], [13, 87], [14, 18], [14, 22], [14, 25], [14, 26], [14, 29], [14, 47], [14, 52], [14, 59], [14, 77], [14, 82], [14, 86], [14, 87], [15, 22], [15, 30], [15, 39], [15, 48], [15, 53], [15, 54], [15, 69], [15, 72], [15, 82], [15, 89], [16, 31], [16, 36], [16, 83], [17, 20], [17, 24], [17, 61], [17, 62], [17, 67], [17, 68], [18, 29], [18, 31], [18, 34], [18, 38], [18, 45], [18, 48], [18, 58], [18, 60], [18, 65], [18, 81], [19, 22], [19, 23], [19, 28], [19, 36], [19, 52], [19, 72], [19, 73], [19, 76], [19, 81], [19, 82], [19, 83], [19, 87], [20, 30], [20, 34], [20, 37], [20, 39], [20, 42], [20, 61], [20, 65], [20, 79], [20, 83], [20, 89], [21, 25], [21, 29], [21, 31], [21, 42], [21, 59], [21, 60], [21, 62], [21, 73], [21, 79], [22, 29], [22, 49], [22, 55], [22, 57], [22, 58], [22, 62], [22, 66], [22, 73], [22, 75], [22, 79], [22, 80], [23, 27], [23, 28], [23, 31], [23, 32], [23, 39], [23, 46], [23, 47], [23, 56], [23, 59], [23, 63], [23, 64], [23, 74], [23, 83], [23, 88], [24, 26], [24, 28], [24, 29], [24, 71], [25, 37], [25, 43], [25, 44], [25, 45], [25, 49], [25, 56], [25, 58], [25, 72], [25, 74], [25, 75], [25, 86], [26, 31], [26, 41], [26, 44], [26, 47], [26, 48], [26, 52], [26, 53], [26, 55], [26, 56], [26, 66], [26, 77], [27, 31], [27, 74], [27, 82], [28, 42], [28, 45], [28, 46], [28, 55], [28, 61], [28, 67], [28, 70], [28, 88], [29, 39], [29, 40], [29, 47], [29, 48], [29, 51], [29, 55], [29, 61], [29, 68], [29, 72], [29, 75], [29, 76], [30, 41], [30, 47], [30, 49], [30, 61], [30, 62], [30, 66], [30, 67], [30, 72], [30, 80], [30, 85], [31, 68], [31, 69], [31, 81], [32, 38], [32, 42], [32, 44], [32, 47], [32, 60], [32, 70], [32, 74], [32, 82], [32, 83], [32, 85], [33, 64], [33, 77], [33, 81], [33, 87], [33, 89], [34, 38], [34, 45], [34, 46], [34, 50], [34, 55], [34, 83], [35, 38], [35, 42], [35, 50], [35, 55], [35, 62], [35, 68], [36, 38], [36, 41], [36, 46], [36, 58], [36, 60], [36, 74], [36, 75], [36, 77], [36, 78], [36, 84], [37, 40], [37, 61], [37, 62], [37, 70], [37, 78], [37, 81], [38, 39], [38, 43], [38, 46], [38, 55], [38, 64], [38, 65], [38, 66], [38, 74], [38, 78], [38, 80], [38, 81], [38, 85], [38, 87], [39, 40], [39, 52], [39, 55], [39, 64], [39, 88], [40, 47], [40, 57], [40, 71], [41, 50], [41, 74], [41, 77], [41, 82], [41, 83], [41, 86], [41, 88], [42, 47], [42, 50], [42, 61], [42, 76], [42, 78], [42, 82], [42, 86], [43, 44], [43, 48], [43, 50], [43, 70], [43, 73], [43, 83], [43, 88], [44, 63], [44, 64], [44, 69], [44, 74], [44, 82], [44, 85], [44, 89], [45, 56], [45, 57], [45, 61], [45, 76], [45, 84], [45, 85], [46, 49], [46, 57], [46, 63], [46, 77], [46, 78], [46, 85], [46, 88], [47, 48], [47, 49], [47, 60], [47, 63], [47, 65], [47, 80], [47, 83], [48, 55], [48, 66], [48, 67], [48, 76], [48, 86], [49, 58], [49, 68], [49, 69], [49, 82], [50, 52], [50, 55], [50, 59], [50, 60], [50, 65], [50, 74], [50, 78], [51, 59], [51, 62], [51, 76], [51, 79], [51, 86], [51, 87], [52, 53], [52, 67], [52, 79], [52, 86], [53, 54], [53, 57], [53, 61], [53, 67], [53, 70], [53, 80], [53, 87], [54, 69], [54, 70], [54, 73], [54, 79], [55, 57], [55, 68], [55, 72], [55, 78], [55, 87], [56, 63], [56, 85], [57, 61], [57, 63], [57, 73], [58, 76], [58, 88], [59, 60], [59, 68], [59, 74], [59, 80], [59, 86], [60, 66], [60, 77], [60, 83], [61, 68], [61, 72], [61, 78], [61, 88], [62, 64], [62, 70], [62, 88], [63, 68], [63, 71], [63, 73], [63, 86], [65, 75], [65, 79], [65, 86], [66, 69], [66, 72], [66, 74], [66, 76], [66, 79], [66, 88], [67, 69], [67, 72], [67, 73], [67, 81], [67, 84], [67, 86], [68, 78], [68, 87], [69, 77], [69, 79], [69, 88], [70, 72], [71, 73], [71, 77], [72, 76], [72, 77], [72, 84], [72, 85], [72, 88], [72, 89], [73, 79], [73, 86], [74, 80], [74, 89], [75, 83], [76, 78], [76, 84], [76, 87], [77, 84], [77, 85], [79, 82], [79, 83], [79, 88], [79, 89], [81, 85], [82, 84], [82, 89], [83, 85], [84, 89]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s4/solution/solve.sh b/tasks/construct-mc-vertex-cover-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eef06c04e746c9abaa01a954b4702b7d1064aa2c --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [0, 1, 2, 3, 4, 5, 6, 7, 10, 12, 13, 15, 18, 19, 20, 22, 23, 24, 25, 26, 29, 30, 31, 36, 38, 40, 42, 44, 45, 46, 47, 48, 50, 52, 53, 55, 58, 59, 60, 61, 62, 63, 64, 67, 68, 69, 70, 72, 73, 74, 75, 76, 77, 78, 79, 81, 82, 83, 85, 86, 87, 88, 89]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l5-s4/tests/check.py b/tasks/construct-mc-vertex-cover-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s4/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l5-s4/tests/instance.json b/tasks/construct-mc-vertex-cover-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ac65a4439539d467d46a23bfa01c9c711c1ff0ae --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 3], [0, 5], [0, 28], [0, 29], [0, 33], [0, 35], [0, 48], [0, 58], [0, 72], [0, 73], [0, 78], [1, 9], [1, 14], [1, 15], [1, 20], [1, 27], [1, 31], [1, 32], [1, 34], [1, 35], [1, 40], [1, 41], [1, 47], [1, 52], [1, 54], [1, 57], [1, 60], [1, 81], [1, 82], [1, 86], [2, 3], [2, 4], [2, 7], [2, 10], [2, 12], [2, 23], [2, 29], [2, 39], [2, 50], [2, 52], [2, 69], [2, 78], [2, 88], [3, 10], [3, 14], [3, 20], [3, 27], [3, 32], [3, 55], [3, 56], [3, 63], [3, 69], [3, 72], [3, 78], [4, 6], [4, 7], [4, 15], [4, 21], [4, 30], [4, 34], [4, 37], [4, 45], [4, 51], [4, 57], [4, 59], [4, 60], [4, 61], [4, 69], [4, 70], [4, 77], [4, 80], [5, 11], [5, 24], [5, 27], [5, 30], [5, 37], [5, 38], [5, 61], [5, 63], [5, 69], [5, 82], [6, 8], [6, 13], [6, 39], [6, 58], [6, 61], [6, 64], [6, 65], [6, 78], [6, 80], [6, 84], [7, 9], [7, 25], [7, 38], [7, 40], [7, 42], [7, 50], [7, 61], [7, 62], [7, 73], [7, 82], [8, 13], [8, 20], [8, 44], [8, 55], [8, 68], [8, 75], [9, 22], [9, 25], [9, 26], [9, 40], [9, 64], [9, 72], [9, 79], [9, 81], [9, 86], [10, 12], [10, 16], [10, 17], [10, 26], [10, 39], [10, 40], [10, 49], [10, 59], [10, 65], [10, 70], [10, 75], [10, 83], [11, 29], [11, 38], [11, 44], [11, 53], [11, 63], [11, 77], [11, 88], [12, 19], [12, 21], [12, 26], [12, 28], [12, 31], [12, 34], [12, 50], [12, 56], [12, 61], [12, 71], [12, 73], [13, 19], [13, 21], [13, 24], [13, 51], [13, 60], [13, 61], [13, 71], [13, 79], [13, 85], [13, 86], [13, 87], [14, 18], [14, 22], [14, 25], [14, 26], [14, 29], [14, 47], [14, 52], [14, 59], [14, 77], [14, 82], [14, 86], [14, 87], [15, 22], [15, 30], [15, 39], [15, 48], [15, 53], [15, 54], [15, 69], [15, 72], [15, 82], [15, 89], [16, 31], [16, 36], [16, 83], [17, 20], [17, 24], [17, 61], [17, 62], [17, 67], [17, 68], [18, 29], [18, 31], [18, 34], [18, 38], [18, 45], [18, 48], [18, 58], [18, 60], [18, 65], [18, 81], [19, 22], [19, 23], [19, 28], [19, 36], [19, 52], [19, 72], [19, 73], [19, 76], [19, 81], [19, 82], [19, 83], [19, 87], [20, 30], [20, 34], [20, 37], [20, 39], [20, 42], [20, 61], [20, 65], [20, 79], [20, 83], [20, 89], [21, 25], [21, 29], [21, 31], [21, 42], [21, 59], [21, 60], [21, 62], [21, 73], [21, 79], [22, 29], [22, 49], [22, 55], [22, 57], [22, 58], [22, 62], [22, 66], [22, 73], [22, 75], [22, 79], [22, 80], [23, 27], [23, 28], [23, 31], [23, 32], [23, 39], [23, 46], [23, 47], [23, 56], [23, 59], [23, 63], [23, 64], [23, 74], [23, 83], [23, 88], [24, 26], [24, 28], [24, 29], [24, 71], [25, 37], [25, 43], [25, 44], [25, 45], [25, 49], [25, 56], [25, 58], [25, 72], [25, 74], [25, 75], [25, 86], [26, 31], [26, 41], [26, 44], [26, 47], [26, 48], [26, 52], [26, 53], [26, 55], [26, 56], [26, 66], [26, 77], [27, 31], [27, 74], [27, 82], [28, 42], [28, 45], [28, 46], [28, 55], [28, 61], [28, 67], [28, 70], [28, 88], [29, 39], [29, 40], [29, 47], [29, 48], [29, 51], [29, 55], [29, 61], [29, 68], [29, 72], [29, 75], [29, 76], [30, 41], [30, 47], [30, 49], [30, 61], [30, 62], [30, 66], [30, 67], [30, 72], [30, 80], [30, 85], [31, 68], [31, 69], [31, 81], [32, 38], [32, 42], [32, 44], [32, 47], [32, 60], [32, 70], [32, 74], [32, 82], [32, 83], [32, 85], [33, 64], [33, 77], [33, 81], [33, 87], [33, 89], [34, 38], [34, 45], [34, 46], [34, 50], [34, 55], [34, 83], [35, 38], [35, 42], [35, 50], [35, 55], [35, 62], [35, 68], [36, 38], [36, 41], [36, 46], [36, 58], [36, 60], [36, 74], [36, 75], [36, 77], [36, 78], [36, 84], [37, 40], [37, 61], [37, 62], [37, 70], [37, 78], [37, 81], [38, 39], [38, 43], [38, 46], [38, 55], [38, 64], [38, 65], [38, 66], [38, 74], [38, 78], [38, 80], [38, 81], [38, 85], [38, 87], [39, 40], [39, 52], [39, 55], [39, 64], [39, 88], [40, 47], [40, 57], [40, 71], [41, 50], [41, 74], [41, 77], [41, 82], [41, 83], [41, 86], [41, 88], [42, 47], [42, 50], [42, 61], [42, 76], [42, 78], [42, 82], [42, 86], [43, 44], [43, 48], [43, 50], [43, 70], [43, 73], [43, 83], [43, 88], [44, 63], [44, 64], [44, 69], [44, 74], [44, 82], [44, 85], [44, 89], [45, 56], [45, 57], [45, 61], [45, 76], [45, 84], [45, 85], [46, 49], [46, 57], [46, 63], [46, 77], [46, 78], [46, 85], [46, 88], [47, 48], [47, 49], [47, 60], [47, 63], [47, 65], [47, 80], [47, 83], [48, 55], [48, 66], [48, 67], [48, 76], [48, 86], [49, 58], [49, 68], [49, 69], [49, 82], [50, 52], [50, 55], [50, 59], [50, 60], [50, 65], [50, 74], [50, 78], [51, 59], [51, 62], [51, 76], [51, 79], [51, 86], [51, 87], [52, 53], [52, 67], [52, 79], [52, 86], [53, 54], [53, 57], [53, 61], [53, 67], [53, 70], [53, 80], [53, 87], [54, 69], [54, 70], [54, 73], [54, 79], [55, 57], [55, 68], [55, 72], [55, 78], [55, 87], [56, 63], [56, 85], [57, 61], [57, 63], [57, 73], [58, 76], [58, 88], [59, 60], [59, 68], [59, 74], [59, 80], [59, 86], [60, 66], [60, 77], [60, 83], [61, 68], [61, 72], [61, 78], [61, 88], [62, 64], [62, 70], [62, 88], [63, 68], [63, 71], [63, 73], [63, 86], [65, 75], [65, 79], [65, 86], [66, 69], [66, 72], [66, 74], [66, 76], [66, 79], [66, 88], [67, 69], [67, 72], [67, 73], [67, 81], [67, 84], [67, 86], [68, 78], [68, 87], [69, 77], [69, 79], [69, 88], [70, 72], [71, 73], [71, 77], [72, 76], [72, 77], [72, 84], [72, 85], [72, 88], [72, 89], [73, 79], [73, 86], [74, 80], [74, 89], [75, 83], [76, 78], [76, 84], [76, 87], [77, 84], [77, 85], [79, 82], [79, 83], [79, 88], [79, 89], [81, 85], [82, 84], [82, 89], [83, 85], [84, 89]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s4/tests/run.py b/tasks/construct-mc-vertex-cover-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l5-s4/tests/test.sh b/tasks/construct-mc-vertex-cover-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l1-s3/environment/Dockerfile b/tasks/construct-nppc-3col-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l1-s3/environment/instance.json b/tasks/construct-nppc-3col-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..edf6f540f0dd7fa363361d4953cbbfc686819600 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [1, 3], [1, 6], [1, 8], [2, 4], [2, 6], [2, 7], [2, 8], [3, 4], [3, 5], [3, 6], [3, 8], [4, 7], [4, 8], [8, 9]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s3/solution/solve.sh b/tasks/construct-nppc-3col-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..be514ea53a765f4d5c39f065bed35226f21e9de8 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 2, 1, 1, 2, 0, 0, 0, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l1-s3/tests/check.py b/tasks/construct-nppc-3col-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s3/tests/check.py @@ -0,0 +1,12 @@ +"""Proper 3-colouring of a given graph. Accepts any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["num_nodes"] + # upstream NPPC verifier skips the range/length check, so an all-distinct colouring passed it + c = int_list(ans.get("coloring"), n, 0, 2, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-nppc-3col-l1-s3/tests/instance.json b/tasks/construct-nppc-3col-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..edf6f540f0dd7fa363361d4953cbbfc686819600 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [1, 3], [1, 6], [1, 8], [2, 4], [2, 6], [2, 7], [2, 8], [3, 4], [3, 5], [3, 6], [3, 8], [4, 7], [4, 8], [8, 9]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s3/tests/run.py b/tasks/construct-nppc-3col-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-3col-l1-s3/tests/test.sh b/tasks/construct-nppc-3col-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l1-s4/environment/Dockerfile b/tasks/construct-nppc-3col-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l1-s4/environment/instance.json b/tasks/construct-nppc-3col-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4f80fe7346c897db7abe77586e31d923f8025cf2 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 2], [0, 3], [0, 7], [0, 9], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [2, 3], [2, 7], [3, 6], [3, 8], [4, 5], [4, 8], [5, 6], [5, 7], [6, 7], [6, 9], [8, 9]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s4/solution/solve.sh b/tasks/construct-nppc-3col-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0af84efb62a87c25a08a363cfa60f9a222c31da2 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [2, 2, 1, 0, 0, 1, 2, 0, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l1-s4/tests/check.py b/tasks/construct-nppc-3col-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s4/tests/check.py @@ -0,0 +1,12 @@ +"""Proper 3-colouring of a given graph. Accepts any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["num_nodes"] + # upstream NPPC verifier skips the range/length check, so an all-distinct colouring passed it + c = int_list(ans.get("coloring"), n, 0, 2, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-nppc-3col-l1-s4/tests/instance.json b/tasks/construct-nppc-3col-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4f80fe7346c897db7abe77586e31d923f8025cf2 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 2], [0, 3], [0, 7], [0, 9], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [2, 3], [2, 7], [3, 6], [3, 8], [4, 5], [4, 8], [5, 6], [5, 7], [6, 7], [6, 9], [8, 9]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s4/tests/test.sh b/tasks/construct-nppc-3col-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-bandwidth-l3-s1/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l3-s1/environment/instance.json b/tasks/construct-nppc-bandwidth-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4e4f2637f526eb7b9c700ca3a2a88ba852a76347 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 2], [0, 4], [1, 2], [2, 3], [3, 7], [4, 5], [5, 6], [6, 7]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s1/solution/solve.sh b/tasks/construct-nppc-bandwidth-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ca782fc17e019ff07b8091f0a16ca95e7d6ffedf --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"layout": [3, 0, 1, 2, 5, 7, 6, 4]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l3-s1/tests/check.py b/tasks/construct-nppc-bandwidth-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s1/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l3-s1/tests/instance.json b/tasks/construct-nppc-bandwidth-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4e4f2637f526eb7b9c700ca3a2a88ba852a76347 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 2], [0, 4], [1, 2], [2, 3], [3, 7], [4, 5], [5, 6], [6, 7]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s1/tests/run.py b/tasks/construct-nppc-bandwidth-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l3-s1/tests/test.sh b/tasks/construct-nppc-bandwidth-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-bandwidth-l3-s8/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l3-s8/environment/instance.json b/tasks/construct-nppc-bandwidth-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d03714fcaf5e025d8c36aef4aed506d327612386 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 1], [0, 4], [1, 2], [1, 3], [2, 7], [3, 4], [4, 5], [5, 6]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s8/solution/solve.sh b/tasks/construct-nppc-bandwidth-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bc73dae478ba690f2ad398fd071339c35022f713 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"layout": [5, 4, 6, 2, 3, 1, 0, 7]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l3-s8/tests/check.py b/tasks/construct-nppc-bandwidth-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s8/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l3-s8/tests/instance.json b/tasks/construct-nppc-bandwidth-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d03714fcaf5e025d8c36aef4aed506d327612386 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 1], [0, 4], [1, 2], [1, 3], [2, 7], [3, 4], [4, 5], [5, 6]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s8/tests/run.py b/tasks/construct-nppc-bandwidth-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l3-s8/tests/test.sh b/tasks/construct-nppc-bandwidth-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l2-s1/environment/Dockerfile b/tasks/construct-nppc-clique-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l2-s1/environment/instance.json b/tasks/construct-nppc-clique-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..900bf6c9d8846af227a6c47df879c950b65bee10 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 4], [0, 6], [0, 8], [0, 9], [0, 11], [0, 13], [1, 2], [1, 3], [1, 5], [1, 6], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [2, 3], [2, 5], [2, 6], [2, 7], [2, 9], [2, 10], [2, 11], [2, 12], [3, 4], [3, 5], [3, 6], [3, 8], [3, 9], [3, 11], [3, 12], [4, 8], [4, 11], [4, 12], [4, 13], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [6, 7], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [7, 11], [7, 12], [7, 13], [8, 9], [8, 10], [8, 11], [8, 13], [9, 10], [9, 11], [9, 12], [10, 12], [11, 12], [11, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s1/solution/solve.sh b/tasks/construct-nppc-clique-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d8575a613cc0d910ebc6fe11b65d4bcc0b1d0ca5 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 2, 3, 5, 6, 9, 12]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l2-s1/tests/check.py b/tasks/construct-nppc-clique-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s1/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l2-s1/tests/instance.json b/tasks/construct-nppc-clique-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..900bf6c9d8846af227a6c47df879c950b65bee10 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 4], [0, 6], [0, 8], [0, 9], [0, 11], [0, 13], [1, 2], [1, 3], [1, 5], [1, 6], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [2, 3], [2, 5], [2, 6], [2, 7], [2, 9], [2, 10], [2, 11], [2, 12], [3, 4], [3, 5], [3, 6], [3, 8], [3, 9], [3, 11], [3, 12], [4, 8], [4, 11], [4, 12], [4, 13], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [6, 7], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [7, 11], [7, 12], [7, 13], [8, 9], [8, 10], [8, 11], [8, 13], [9, 10], [9, 11], [9, 12], [10, 12], [11, 12], [11, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s1/tests/run.py b/tasks/construct-nppc-clique-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l2-s1/tests/test.sh b/tasks/construct-nppc-clique-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l2-s6/environment/Dockerfile b/tasks/construct-nppc-clique-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l2-s6/environment/instance.json b/tasks/construct-nppc-clique-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bcdf1c1b8c82555c42bb40107e466bb2e3b7f08b --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 8], [0, 9], [0, 12], [0, 13], [1, 2], [1, 3], [1, 4], [1, 6], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [2, 3], [2, 4], [2, 5], [2, 7], [2, 9], [2, 13], [3, 4], [3, 6], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 8], [4, 9], [4, 10], [4, 11], [4, 13], [5, 8], [5, 10], [5, 12], [5, 13], [6, 10], [6, 12], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 11], [8, 12], [8, 13], [9, 10], [9, 12], [9, 13], [10, 11], [11, 12], [12, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s6/solution/solve.sh b/tasks/construct-nppc-clique-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c1e33938f7d1f7c478124476984e02f657866b57 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 1, 3, 8, 9, 12, 13]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l2-s6/tests/check.py b/tasks/construct-nppc-clique-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s6/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l2-s6/tests/instance.json b/tasks/construct-nppc-clique-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bcdf1c1b8c82555c42bb40107e466bb2e3b7f08b --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 8], [0, 9], [0, 12], [0, 13], [1, 2], [1, 3], [1, 4], [1, 6], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [2, 3], [2, 4], [2, 5], [2, 7], [2, 9], [2, 13], [3, 4], [3, 6], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 8], [4, 9], [4, 10], [4, 11], [4, 13], [5, 8], [5, 10], [5, 12], [5, 13], [6, 10], [6, 12], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 11], [8, 12], [8, 13], [9, 10], [9, 12], [9, 13], [10, 11], [11, 12], [12, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s6/tests/run.py b/tasks/construct-nppc-clique-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l2-s6/tests/test.sh b/tasks/construct-nppc-clique-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l2-s8/environment/Dockerfile b/tasks/construct-nppc-clique-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l2-s8/environment/instance.json b/tasks/construct-nppc-clique-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc0edfc0b18c2ed96349b0c339525649ba1c5a42 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 10], [0, 11], [0, 12], [0, 13], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 12], [2, 4], [2, 5], [2, 9], [2, 11], [3, 10], [3, 11], [3, 13], [4, 5], [4, 6], [4, 7], [4, 10], [4, 12], [4, 13], [5, 6], [5, 7], [5, 10], [5, 12], [5, 13], [6, 7], [6, 10], [6, 11], [6, 12], [7, 8], [7, 10], [7, 12], [8, 10], [8, 11], [8, 12], [9, 10], [9, 12], [10, 12], [11, 13], [12, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s8/solution/solve.sh b/tasks/construct-nppc-clique-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c5aa5d8a568940f309fb185b14aa26c2a7a12789 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 1, 5, 6, 7, 10, 12]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l2-s8/tests/check.py b/tasks/construct-nppc-clique-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s8/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l2-s8/tests/instance.json b/tasks/construct-nppc-clique-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc0edfc0b18c2ed96349b0c339525649ba1c5a42 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 10], [0, 11], [0, 12], [0, 13], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 12], [2, 4], [2, 5], [2, 9], [2, 11], [3, 10], [3, 11], [3, 13], [4, 5], [4, 6], [4, 7], [4, 10], [4, 12], [4, 13], [5, 6], [5, 7], [5, 10], [5, 12], [5, 13], [6, 7], [6, 10], [6, 11], [6, 12], [7, 8], [7, 10], [7, 12], [8, 10], [8, 11], [8, 12], [9, 10], [9, 12], [10, 12], [11, 13], [12, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s8/tests/run.py b/tasks/construct-nppc-clique-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l2-s8/tests/test.sh b/tasks/construct-nppc-clique-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l6-s7/environment/Dockerfile b/tasks/construct-nppc-clique-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l6-s7/environment/instance.json b/tasks/construct-nppc-clique-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aaa00a146518607199cb220a39c1bd95c87df965 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 4], [0, 5], [0, 6], [0, 9], [0, 11], [0, 13], [0, 14], [0, 15], [0, 16], [0, 18], [0, 20], [0, 25], [0, 28], [0, 32], [0, 33], [0, 34], [0, 38], [0, 39], [0, 40], [0, 41], [0, 42], [0, 47], [0, 49], [0, 52], [0, 53], [0, 54], [0, 55], [0, 56], [0, 57], [0, 59], [0, 61], [0, 62], [0, 63], [0, 64], [0, 71], [0, 73], [0, 74], [0, 77], [0, 79], [0, 80], [0, 81], [0, 84], [0, 85], [0, 86], [0, 87], [0, 90], [0, 93], [0, 94], [1, 2], [1, 3], [1, 6], [1, 10], [1, 12], [1, 16], [1, 19], [1, 20], [1, 22], [1, 27], [1, 30], [1, 31], [1, 32], [1, 34], [1, 35], [1, 36], [1, 38], [1, 39], [1, 44], [1, 46], [1, 47], [1, 50], [1, 51], [1, 53], [1, 54], [1, 55], [1, 60], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 74], [1, 75], [1, 77], [1, 79], [1, 80], [1, 81], [1, 82], [1, 84], [1, 85], [1, 86], [1, 88], [1, 89], [1, 92], [1, 98], [2, 3], [2, 5], [2, 9], [2, 10], [2, 12], [2, 15], [2, 17], [2, 18], [2, 19], [2, 21], [2, 22], [2, 25], [2, 26], [2, 35], [2, 38], [2, 43], [2, 45], [2, 46], [2, 50], [2, 55], [2, 56], [2, 57], [2, 58], [2, 59], [2, 60], [2, 61], [2, 63], [2, 65], [2, 66], [2, 68], [2, 69], [2, 76], [2, 77], [2, 80], [2, 82], [2, 83], [2, 86], [2, 87], [2, 89], [2, 92], [2, 98], [3, 5], [3, 7], [3, 8], [3, 10], [3, 13], [3, 15], [3, 16], [3, 17], [3, 18], [3, 20], [3, 23], [3, 25], [3, 26], [3, 27], [3, 30], [3, 31], [3, 35], [3, 36], [3, 38], [3, 40], [3, 42], [3, 46], [3, 47], [3, 49], [3, 51], [3, 53], [3, 54], [3, 55], [3, 56], [3, 58], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 71], [3, 73], [3, 74], [3, 75], [3, 77], [3, 78], [3, 79], [3, 81], [3, 82], [3, 83], [3, 87], [3, 88], [3, 89], [3, 90], [3, 91], [3, 92], [3, 93], [3, 97], [3, 99], [4, 7], [4, 12], [4, 17], [4, 19], [4, 20], [4, 22], [4, 23], [4, 25], [4, 28], [4, 36], [4, 37], [4, 38], [4, 42], [4, 43], [4, 45], [4, 46], [4, 47], [4, 51], [4, 53], [4, 55], [4, 57], [4, 58], [4, 59], [4, 60], [4, 68], [4, 71], [4, 72], [4, 73], [4, 74], [4, 76], [4, 77], [4, 78], [4, 80], [4, 82], [4, 86], [4, 87], [4, 89], [4, 93], [4, 95], [4, 97], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 13], [5, 14], [5, 15], [5, 19], [5, 24], [5, 25], [5, 26], [5, 28], [5, 29], [5, 32], [5, 34], [5, 37], [5, 38], [5, 40], [5, 44], [5, 45], [5, 46], [5, 49], [5, 53], [5, 54], [5, 56], [5, 57], [5, 58], [5, 59], [5, 60], [5, 65], [5, 69], [5, 74], [5, 75], [5, 78], [5, 81], [5, 83], [5, 87], [5, 88], [5, 90], [5, 92], [5, 98], [5, 99], [6, 7], [6, 9], [6, 10], [6, 14], [6, 15], [6, 21], [6, 22], [6, 24], [6, 26], [6, 28], [6, 30], [6, 31], [6, 32], [6, 33], [6, 37], [6, 40], [6, 41], [6, 42], [6, 43], [6, 45], [6, 46], [6, 47], [6, 50], [6, 53], [6, 55], [6, 61], [6, 62], [6, 64], [6, 65], [6, 68], [6, 69], [6, 72], [6, 73], [6, 74], [6, 78], [6, 80], [6, 82], [6, 84], [6, 85], [6, 90], [6, 95], [6, 96], [6, 97], [6, 98], [7, 8], [7, 13], [7, 14], [7, 15], [7, 17], [7, 18], [7, 19], [7, 20], [7, 22], [7, 24], [7, 25], [7, 26], [7, 27], [7, 29], [7, 30], [7, 34], [7, 36], [7, 37], [7, 38], [7, 41], [7, 42], [7, 46], [7, 48], [7, 50], [7, 55], [7, 56], [7, 57], [7, 63], [7, 64], [7, 65], [7, 67], [7, 69], [7, 70], [7, 71], [7, 73], [7, 74], [7, 76], [7, 77], [7, 79], [7, 81], [7, 84], [7, 87], [7, 90], [7, 91], [7, 92], [7, 94], [7, 95], [7, 96], [8, 10], [8, 13], [8, 15], [8, 19], [8, 20], [8, 21], [8, 22], [8, 25], [8, 27], [8, 28], [8, 30], [8, 31], [8, 32], [8, 39], [8, 40], [8, 41], [8, 44], [8, 46], [8, 47], [8, 48], [8, 50], [8, 51], [8, 53], [8, 54], [8, 57], [8, 58], [8, 59], [8, 61], [8, 62], [8, 65], [8, 66], [8, 67], [8, 68], [8, 74], [8, 79], [8, 82], [8, 83], [8, 84], [8, 85], [8, 86], [8, 88], [8, 90], [8, 93], [8, 95], [8, 96], [8, 97], [8, 98], [8, 99], [9, 13], [9, 14], [9, 16], [9, 17], [9, 18], [9, 23], [9, 24], [9, 26], [9, 27], [9, 29], [9, 31], [9, 32], [9, 34], [9, 39], [9, 41], [9, 44], [9, 49], [9, 51], [9, 53], [9, 56], [9, 57], [9, 59], [9, 62], [9, 63], [9, 65], [9, 67], [9, 68], [9, 70], [9, 72], [9, 74], [9, 79], [9, 80], [9, 81], [9, 82], [9, 85], [9, 86], [9, 87], [9, 90], [9, 93], [9, 95], [9, 96], [9, 98], [9, 99], [10, 11], [10, 14], [10, 16], [10, 19], [10, 22], [10, 23], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 30], [10, 32], [10, 34], [10, 36], [10, 38], [10, 39], [10, 42], [10, 44], [10, 50], [10, 51], [10, 57], [10, 59], [10, 60], [10, 63], [10, 66], [10, 67], [10, 70], [10, 72], [10, 74], [10, 75], [10, 76], [10, 77], [10, 80], [10, 82], [10, 89], [10, 90], [10, 94], [10, 98], [11, 12], [11, 13], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 23], [11, 25], [11, 26], [11, 28], [11, 30], [11, 31], [11, 32], [11, 33], [11, 36], [11, 38], [11, 39], [11, 41], [11, 42], [11, 43], [11, 44], [11, 45], [11, 47], [11, 48], [11, 50], [11, 51], [11, 52], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 60], [11, 61], [11, 62], [11, 65], [11, 70], [11, 74], [11, 78], [11, 80], [11, 81], [11, 84], [11, 85], [11, 87], [11, 90], [11, 94], [11, 95], [11, 96], [11, 97], [11, 98], [11, 99], [12, 13], [12, 14], [12, 16], [12, 18], [12, 19], [12, 20], [12, 21], [12, 26], [12, 27], [12, 34], [12, 36], [12, 37], [12, 41], [12, 46], [12, 48], [12, 49], [12, 51], [12, 52], [12, 56], [12, 57], [12, 58], [12, 59], [12, 60], [12, 62], [12, 63], [12, 65], [12, 66], [12, 67], [12, 68], [12, 70], [12, 73], [12, 75], [12, 76], [12, 77], [12, 78], [12, 80], [12, 85], [12, 86], [12, 87], [12, 89], [12, 91], [12, 94], [12, 96], [13, 16], [13, 18], [13, 19], [13, 20], [13, 22], [13, 23], [13, 25], [13, 29], [13, 32], [13, 34], [13, 36], [13, 38], [13, 40], [13, 41], [13, 42], [13, 43], [13, 44], [13, 46], [13, 50], [13, 52], [13, 53], [13, 54], [13, 56], [13, 57], [13, 58], [13, 60], [13, 61], [13, 62], [13, 63], [13, 64], [13, 65], [13, 70], [13, 72], [13, 74], [13, 75], [13, 80], [13, 81], [13, 82], [13, 83], [13, 85], [13, 87], [13, 89], [13, 90], [13, 91], [13, 92], [13, 93], [13, 96], [13, 97], [13, 98], [14, 17], [14, 18], [14, 22], [14, 26], [14, 29], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [14, 38], [14, 39], [14, 40], [14, 41], [14, 43], [14, 44], [14, 48], [14, 50], [14, 51], [14, 52], [14, 55], [14, 56], [14, 57], [14, 59], [14, 60], [14, 63], [14, 64], [14, 65], [14, 67], [14, 68], [14, 71], [14, 74], [14, 75], [14, 76], [14, 79], [14, 80], [14, 81], [14, 83], [14, 87], [14, 89], [14, 91], [14, 92], [14, 93], [14, 95], [14, 97], [15, 17], [15, 19], [15, 23], [15, 24], [15, 25], [15, 27], [15, 29], [15, 30], [15, 33], [15, 34], [15, 36], [15, 41], [15, 42], [15, 44], [15, 45], [15, 46], [15, 50], [15, 55], [15, 56], [15, 57], [15, 59], [15, 60], [15, 66], [15, 68], [15, 73], [15, 74], [15, 78], [15, 83], [15, 85], [15, 86], [15, 87], [15, 89], [15, 91], [15, 92], [15, 95], [15, 98], [15, 99], [16, 17], [16, 20], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 35], [16, 36], [16, 39], [16, 41], [16, 42], [16, 44], [16, 45], [16, 48], [16, 54], [16, 55], [16, 56], [16, 57], [16, 59], [16, 60], [16, 62], [16, 63], [16, 65], [16, 69], [16, 71], [16, 75], [16, 76], [16, 77], [16, 80], [16, 82], [16, 85], [16, 86], [16, 89], [16, 90], [16, 91], [16, 92], [16, 93], [16, 94], [16, 95], [16, 96], [16, 97], [16, 98], [17, 20], [17, 21], [17, 22], [17, 27], [17, 28], [17, 30], [17, 31], [17, 32], [17, 35], [17, 37], [17, 38], [17, 39], [17, 42], [17, 43], [17, 44], [17, 47], [17, 48], [17, 49], [17, 50], [17, 52], [17, 53], [17, 54], [17, 60], [17, 61], [17, 63], [17, 65], [17, 66], [17, 67], [17, 68], [17, 69], [17, 70], [17, 71], [17, 72], [17, 73], [17, 75], [17, 78], [17, 81], [17, 85], [17, 86], [17, 88], [17, 90], [17, 91], [17, 96], [18, 23], [18, 26], [18, 27], [18, 29], [18, 30], [18, 32], [18, 35], [18, 36], [18, 37], [18, 39], [18, 40], [18, 43], [18, 44], [18, 47], [18, 48], [18, 49], [18, 54], [18, 58], [18, 60], [18, 61], [18, 62], [18, 63], [18, 65], [18, 66], [18, 67], [18, 68], [18, 69], [18, 70], [18, 71], [18, 72], [18, 74], [18, 76], [18, 77], [18, 78], [18, 79], [18, 82], [18, 83], [18, 84], [18, 87], [18, 90], [18, 91], [18, 93], [18, 95], [18, 97], [18, 98], [18, 99], [19, 20], [19, 21], [19, 22], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 34], [19, 36], [19, 38], [19, 39], [19, 43], [19, 46], [19, 51], [19, 52], [19, 53], [19, 54], [19, 57], [19, 58], [19, 61], [19, 62], [19, 63], [19, 66], [19, 68], [19, 69], [19, 70], [19, 72], [19, 75], [19, 76], [19, 77], [19, 83], [19, 85], [19, 86], [19, 87], [19, 89], [19, 90], [19, 93], [19, 95], [19, 96], [19, 98], [19, 99], [20, 21], [20, 23], [20, 24], [20, 25], [20, 26], [20, 29], [20, 31], [20, 33], [20, 35], [20, 36], [20, 38], [20, 39], [20, 41], [20, 42], [20, 44], [20, 45], [20, 46], [20, 47], [20, 48], [20, 50], [20, 51], [20, 52], [20, 53], [20, 55], [20, 56], [20, 57], [20, 58], [20, 60], [20, 62], [20, 65], [20, 68], [20, 69], [20, 70], [20, 71], [20, 74], [20, 75], [20, 76], [20, 78], [20, 79], [20, 80], [20, 83], [20, 84], [20, 85], [20, 86], [20, 89], [20, 90], [20, 94], [20, 96], [20, 97], [20, 98], [20, 99], [21, 22], [21, 23], [21, 24], [21, 25], [21, 28], [21, 34], [21, 35], [21, 37], [21, 42], [21, 43], [21, 44], [21, 50], [21, 52], [21, 54], [21, 60], [21, 62], [21, 63], [21, 65], [21, 66], [21, 68], [21, 69], [21, 70], [21, 75], [21, 78], [21, 79], [21, 80], [21, 82], [21, 83], [21, 84], [21, 85], [21, 86], [21, 87], [21, 89], [21, 90], [21, 91], [21, 94], [21, 96], [21, 97], [21, 98], [21, 99], [22, 23], [22, 25], [22, 28], [22, 31], [22, 32], [22, 33], [22, 37], [22, 39], [22, 40], [22, 41], [22, 44], [22, 46], [22, 48], [22, 49], [22, 50], [22, 51], [22, 53], [22, 54], [22, 58], [22, 59], [22, 60], [22, 61], [22, 64], [22, 68], [22, 69], [22, 71], [22, 72], [22, 76], [22, 80], [22, 84], [22, 85], [22, 86], [22, 90], [22, 92], [22, 93], [22, 95], [22, 98], [22, 99], [23, 24], [23, 28], [23, 33], [23, 34], [23, 36], [23, 37], [23, 38], [23, 41], [23, 42], [23, 44], [23, 45], [23, 47], [23, 48], [23, 49], [23, 51], [23, 52], [23, 53], [23, 56], [23, 57], [23, 58], [23, 59], [23, 60], [23, 62], [23, 64], [23, 65], [23, 67], [23, 74], [23, 75], [23, 78], [23, 80], [23, 82], [23, 83], [23, 85], [23, 87], [23, 88], [23, 90], [23, 91], [23, 92], [23, 96], [23, 97], [23, 98], [24, 25], [24, 26], [24, 28], [24, 31], [24, 33], [24, 34], [24, 35], [24, 36], [24, 37], [24, 38], [24, 41], [24, 42], [24, 43], [24, 44], [24, 46], [24, 47], [24, 51], [24, 53], [24, 54], [24, 60], [24, 66], [24, 70], [24, 71], [24, 72], [24, 73], [24, 75], [24, 79], [24, 80], [24, 81], [24, 83], [24, 84], [24, 89], [24, 92], [24, 93], [24, 95], [24, 99], [25, 28], [25, 29], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 45], [25, 47], [25, 49], [25, 52], [25, 53], [25, 55], [25, 56], [25, 60], [25, 64], [25, 65], [25, 66], [25, 67], [25, 69], [25, 72], [25, 73], [25, 77], [25, 78], [25, 80], [25, 81], [25, 83], [25, 85], [25, 87], [25, 88], [25, 89], [25, 94], [25, 99], [26, 27], [26, 29], [26, 31], [26, 32], [26, 35], [26, 39], [26, 40], [26, 41], [26, 42], [26, 47], [26, 48], [26, 49], [26, 52], [26, 56], [26, 58], [26, 60], [26, 61], [26, 67], [26, 72], [26, 73], [26, 74], [26, 75], [26, 77], [26, 79], [26, 80], [26, 81], [26, 82], [26, 85], [26, 86], [26, 88], [26, 91], [26, 94], [26, 96], [26, 97], [27, 28], [27, 36], [27, 38], [27, 40], [27, 41], [27, 42], [27, 43], [27, 44], [27, 45], [27, 46], [27, 47], [27, 49], [27, 52], [27, 57], [27, 59], [27, 60], [27, 63], [27, 64], [27, 69], [27, 70], [27, 71], [27, 73], [27, 74], [27, 78], [27, 80], [27, 82], [27, 85], [27, 86], [27, 89], [27, 90], [27, 92], [27, 94], [27, 96], [27, 97], [28, 29], [28, 35], [28, 36], [28, 38], [28, 39], [28, 40], [28, 41], [28, 42], [28, 47], [28, 48], [28, 52], [28, 53], [28, 55], [28, 57], [28, 58], [28, 59], [28, 60], [28, 61], [28, 62], [28, 63], [28, 64], [28, 65], [28, 66], [28, 67], [28, 69], [28, 71], [28, 73], [28, 74], [28, 75], [28, 76], [28, 77], [28, 82], [28, 84], [28, 85], [28, 88], [28, 95], [28, 98], [29, 30], [29, 32], [29, 33], [29, 34], [29, 35], [29, 40], [29, 41], [29, 42], [29, 43], [29, 45], [29, 46], [29, 47], [29, 49], [29, 52], [29, 53], [29, 57], [29, 61], [29, 62], [29, 66], [29, 67], [29, 68], [29, 70], [29, 73], [29, 74], [29, 75], [29, 76], [29, 79], [29, 82], [29, 84], [29, 88], [29, 90], [29, 91], [29, 92], [29, 97], [29, 98], [29, 99], [30, 31], [30, 33], [30, 34], [30, 38], [30, 39], [30, 43], [30, 44], [30, 45], [30, 47], [30, 49], [30, 50], [30, 51], [30, 52], [30, 53], [30, 56], [30, 59], [30, 60], [30, 61], [30, 62], [30, 64], [30, 66], [30, 68], [30, 69], [30, 70], [30, 71], [30, 72], [30, 73], [30, 74], [30, 76], [30, 77], [30, 78], [30, 79], [30, 80], [30, 81], [30, 83], [30, 85], [30, 87], [30, 88], [30, 90], [30, 93], [30, 95], [30, 96], [30, 97], [30, 98], [30, 99], [31, 32], [31, 46], [31, 47], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 53], [31, 56], [31, 57], [31, 58], [31, 59], [31, 61], [31, 63], [31, 64], [31, 65], [31, 67], [31, 68], [31, 69], [31, 71], [31, 73], [31, 74], [31, 77], [31, 80], [31, 83], [31, 86], [31, 90], [31, 91], [31, 93], [31, 94], [31, 95], [31, 96], [31, 97], [31, 98], [32, 34], [32, 35], [32, 36], [32, 40], [32, 41], [32, 42], [32, 45], [32, 46], [32, 48], [32, 50], [32, 51], [32, 52], [32, 53], [32, 59], [32, 60], [32, 61], [32, 64], [32, 65], [32, 66], [32, 68], [32, 72], [32, 73], [32, 74], [32, 75], [32, 77], [32, 78], [32, 79], [32, 80], [32, 82], [32, 83], [32, 88], [32, 92], [32, 93], [32, 94], [32, 98], [33, 35], [33, 38], [33, 39], [33, 42], [33, 43], [33, 46], [33, 48], [33, 50], [33, 61], [33, 63], [33, 64], [33, 65], [33, 66], [33, 67], [33, 69], [33, 72], [33, 75], [33, 77], [33, 79], [33, 81], [33, 82], [33, 87], [33, 88], [33, 90], [33, 94], [33, 97], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [34, 41], [34, 42], [34, 43], [34, 44], [34, 47], [34, 48], [34, 51], [34, 52], [34, 53], [34, 54], [34, 55], [34, 56], [34, 57], [34, 60], [34, 61], [34, 62], [34, 63], [34, 64], [34, 65], [34, 66], [34, 67], [34, 69], [34, 70], [34, 74], [34, 75], [34, 78], [34, 79], [34, 80], [34, 85], [34, 86], [34, 88], [34, 93], [34, 94], [34, 98], [34, 99], [35, 36], [35, 38], [35, 40], [35, 44], [35, 45], [35, 46], [35, 48], [35, 49], [35, 53], [35, 56], [35, 57], [35, 62], [35, 63], [35, 65], [35, 67], [35, 68], [35, 73], [35, 74], [35, 75], [35, 78], [35, 80], [35, 82], [35, 83], [35, 85], [35, 86], [35, 87], [35, 88], [35, 92], [35, 93], [35, 94], [35, 98], [36, 38], [36, 39], [36, 40], [36, 41], [36, 42], [36, 44], [36, 47], [36, 50], [36, 51], [36, 52], [36, 53], [36, 55], [36, 56], [36, 57], [36, 58], [36, 60], [36, 62], [36, 63], [36, 64], [36, 65], [36, 66], [36, 67], [36, 68], [36, 69], [36, 70], [36, 73], [36, 74], [36, 79], [36, 80], [36, 81], [36, 84], [36, 85], [36, 87], [36, 88], [36, 90], [36, 91], [36, 95], [36, 96], [36, 98], [36, 99], [37, 38], [37, 40], [37, 44], [37, 45], [37, 46], [37, 57], [37, 58], [37, 60], [37, 61], [37, 63], [37, 65], [37, 69], [37, 71], [37, 72], [37, 74], [37, 78], [37, 79], [37, 80], [37, 81], [37, 82], [37, 84], [37, 86], [37, 87], [37, 88], [37, 89], [37, 90], [37, 91], [37, 92], [37, 94], [37, 96], [37, 97], [37, 99], [38, 41], [38, 42], [38, 43], [38, 46], [38, 47], [38, 50], [38, 52], [38, 53], [38, 54], [38, 56], [38, 57], [38, 60], [38, 62], [38, 65], [38, 66], [38, 67], [38, 68], [38, 69], [38, 70], [38, 72], [38, 74], [38, 76], [38, 77], [38, 78], [38, 79], [38, 80], [38, 81], [38, 82], [38, 83], [38, 85], [38, 86], [38, 88], [38, 90], [38, 93], [38, 94], [38, 96], [38, 98], [38, 99], [39, 41], [39, 42], [39, 43], [39, 44], [39, 46], [39, 47], [39, 51], [39, 54], [39, 57], [39, 58], [39, 59], [39, 61], [39, 63], [39, 64], [39, 68], [39, 69], [39, 71], [39, 72], [39, 76], [39, 77], [39, 78], [39, 80], [39, 82], [39, 83], [39, 84], [39, 85], [39, 86], [39, 87], [39, 89], [39, 93], [39, 95], [39, 96], [39, 99], [40, 41], [40, 42], [40, 48], [40, 49], [40, 50], [40, 52], [40, 53], [40, 54], [40, 57], [40, 58], [40, 59], [40, 60], [40, 61], [40, 62], [40, 63], [40, 65], [40, 66], [40, 68], [40, 69], [40, 70], [40, 71], [40, 74], [40, 75], [40, 76], [40, 77], [40, 78], [40, 79], [40, 80], [40, 81], [40, 82], [40, 83], [40, 87], [40, 88], [40, 89], [40, 90], [40, 91], [40, 94], [40, 95], [40, 96], [40, 98], [40, 99], [41, 42], [41, 43], [41, 45], [41, 47], [41, 48], [41, 49], [41, 50], [41, 51], [41, 52], [41, 53], [41, 55], [41, 56], [41, 57], [41, 59], [41, 60], [41, 62], [41, 64], [41, 65], [41, 66], [41, 67], [41, 68], [41, 71], [41, 72], [41, 74], [41, 78], [41, 79], [41, 80], [41, 83], [41, 85], [41, 90], [41, 91], [41, 92], [41, 94], [41, 96], [41, 98], [41, 99], [42, 43], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 51], [42, 52], [42, 53], [42, 54], [42, 55], [42, 56], [42, 57], [42, 58], [42, 59], [42, 60], [42, 61], [42, 62], [42, 63], [42, 65], [42, 66], [42, 67], [42, 73], [42, 74], [42, 75], [42, 77], [42, 78], [42, 80], [42, 84], [42, 85], [42, 86], [42, 88], [42, 90], [42, 93], [42, 95], [42, 96], [42, 97], [42, 98], [42, 99], [43, 44], [43, 46], [43, 47], [43, 49], [43, 51], [43, 56], [43, 57], [43, 60], [43, 61], [43, 62], [43, 63], [43, 64], [43, 66], [43, 67], [43, 69], [43, 71], [43, 73], [43, 76], [43, 77], [43, 78], [43, 80], [43, 81], [43, 82], [43, 89], [43, 90], [43, 91], [43, 94], [43, 95], [43, 96], [44, 46], [44, 49], [44, 50], [44, 51], [44, 53], [44, 54], [44, 58], [44, 64], [44, 65], [44, 69], [44, 70], [44, 71], [44, 73], [44, 74], [44, 75], [44, 79], [44, 80], [44, 81], [44, 82], [44, 84], [44, 85], [44, 86], [44, 87], [44, 89], [44, 90], [44, 95], [44, 97], [44, 98], [44, 99], [45, 48], [45, 49], [45, 50], [45, 52], [45, 53], [45, 54], [45, 58], [45, 59], [45, 61], [45, 64], [45, 65], [45, 67], [45, 69], [45, 71], [45, 72], [45, 74], [45, 78], [45, 81], [45, 82], [45, 83], [45, 84], [45, 85], [45, 86], [45, 88], [45, 91], [45, 93], [45, 99], [46, 50], [46, 56], [46, 57], [46, 58], [46, 59], [46, 60], [46, 61], [46, 64], [46, 65], [46, 67], [46, 68], [46, 74], [46, 75], [46, 77], [46, 81], [46, 83], [46, 85], [46, 87], [46, 88], [46, 90], [46, 92], [46, 96], [47, 49], [47, 53], [47, 56], [47, 57], [47, 60], [47, 62], [47, 64], [47, 66], [47, 67], [47, 68], [47, 69], [47, 70], [47, 71], [47, 75], [47, 78], [47, 79], [47, 81], [47, 82], [47, 83], [47, 85], [47, 87], [47, 90], [47, 91], [47, 93], [47, 94], [47, 96], [47, 97], [48, 50], [48, 53], [48, 55], [48, 57], [48, 58], [48, 59], [48, 60], [48, 61], [48, 62], [48, 65], [48, 68], [48, 70], [48, 76], [48, 77], [48, 78], [48, 79], [48, 80], [48, 81], [48, 82], [48, 83], [48, 84], [48, 86], [48, 87], [48, 88], [48, 90], [48, 92], [48, 96], [48, 99], [49, 51], [49, 53], [49, 55], [49, 56], [49, 57], [49, 58], [49, 60], [49, 61], [49, 62], [49, 64], [49, 69], [49, 70], [49, 73], [49, 74], [49, 78], [49, 79], [49, 81], [49, 84], [49, 86], [49, 88], [49, 90], [49, 91], [49, 98], [50, 51], [50, 54], [50, 57], [50, 58], [50, 59], [50, 60], [50, 62], [50, 64], [50, 68], [50, 69], [50, 76], [50, 78], [50, 79], [50, 81], [50, 83], [50, 85], [50, 86], [50, 88], [50, 89], [50, 90], [50, 91], [50, 92], [50, 97], [51, 53], [51, 56], [51, 63], [51, 64], [51, 66], [51, 67], [51, 69], [51, 70], [51, 71], [51, 73], [51, 74], [51, 76], [51, 78], [51, 79], [51, 85], [51, 88], [51, 91], [51, 92], [51, 93], [51, 94], [51, 95], [51, 96], [51, 98], [51, 99], [52, 53], [52, 54], [52, 55], [52, 56], [52, 57], [52, 58], [52, 60], [52, 62], [52, 65], [52, 66], [52, 67], [52, 72], [52, 74], [52, 75], [52, 76], [52, 77], [52, 78], [52, 79], [52, 80], [52, 81], [52, 85], [52, 86], [52, 89], [52, 90], [52, 92], [52, 93], [52, 95], [52, 96], [52, 98], [53, 54], [53, 56], [53, 57], [53, 58], [53, 59], [53, 60], [53, 62], [53, 64], [53, 65], [53, 66], [53, 67], [53, 72], [53, 73], [53, 74], [53, 78], [53, 79], [53, 80], [53, 81], [53, 83], [53, 84], [53, 85], [53, 86], [53, 89], [53, 90], [53, 91], [53, 93], [53, 95], [53, 96], [53, 97], [53, 98], [54, 55], [54, 56], [54, 59], [54, 60], [54, 61], [54, 65], [54, 66], [54, 67], [54, 68], [54, 71], [54, 72], [54, 73], [54, 76], [54, 79], [54, 83], [54, 84], [54, 85], [54, 88], [54, 90], [54, 93], [54, 94], [54, 95], [54, 96], [55, 56], [55, 57], [55, 61], [55, 62], [55, 65], [55, 71], [55, 72], [55, 74], [55, 75], [55, 78], [55, 79], [55, 82], [55, 83], [55, 84], [55, 85], [55, 86], [55, 88], [55, 91], [55, 93], [55, 94], [55, 95], [55, 96], [55, 97], [56, 57], [56, 60], [56, 61], [56, 62], [56, 66], [56, 70], [56, 71], [56, 72], [56, 74], [56, 75], [56, 78], [56, 79], [56, 81], [56, 82], [56, 83], [56, 84], [56, 87], [56, 89], [56, 92], [56, 93], [56, 94], [56, 95], [56, 98], [57, 58], [57, 59], [57, 60], [57, 62], [57, 63], [57, 64], [57, 65], [57, 66], [57, 67], [57, 71], [57, 72], [57, 74], [57, 78], [57, 80], [57, 81], [57, 82], [57, 85], [57, 86], [57, 87], [57, 88], [57, 89], [57, 90], [57, 91], [57, 92], [57, 94], [57, 95], [57, 96], [57, 97], [57, 98], [57, 99], [58, 59], [58, 64], [58, 66], [58, 68], [58, 69], [58, 73], [58, 74], [58, 75], [58, 77], [58, 78], [58, 79], [58, 80], [58, 85], [58, 86], [58, 87], [58, 90], [58, 94], [58, 98], [58, 99], [59, 61], [59, 65], [59, 69], [59, 71], [59, 72], [59, 73], [59, 75], [59, 78], [59, 81], [59, 82], [59, 86], [59, 87], [59, 90], [59, 91], [59, 92], [59, 95], [59, 97], [59, 99], [60, 61], [60, 62], [60, 64], [60, 65], [60, 66], [60, 68], [60, 72], [60, 73], [60, 74], [60, 76], [60, 77], [60, 80], [60, 81], [60, 85], [60, 86], [60, 88], [60, 89], [60, 90], [60, 93], [60, 96], [60, 97], [60, 98], [61, 63], [61, 64], [61, 65], [61, 67], [61, 68], [61, 69], [61, 70], [61, 73], [61, 74], [61, 75], [61, 77], [61, 78], [61, 79], [61, 80], [61, 81], [61, 83], [61, 87], [61, 88], [61, 89], [61, 90], [61, 94], [61, 95], [61, 96], [61, 99], [62, 63], [62, 64], [62, 65], [62, 70], [62, 74], [62, 75], [62, 76], [62, 77], [62, 78], [62, 79], [62, 80], [62, 82], [62, 83], [62, 84], [62, 85], [62, 88], [62, 89], [62, 90], [62, 92], [62, 93], [62, 96], [62, 97], [62, 98], [63, 64], [63, 67], [63, 68], [63, 69], [63, 71], [63, 74], [63, 75], [63, 76], [63, 80], [63, 81], [63, 82], [63, 88], [63, 90], [63, 91], [63, 92], [63, 93], [63, 98], [64, 70], [64, 71], [64, 72], [64, 75], [64, 78], [64, 83], [64, 84], [64, 86], [64, 87], [64, 88], [64, 89], [64, 92], [64, 95], [64, 96], [64, 98], [64, 99], [65, 68], [65, 72], [65, 73], [65, 74], [65, 76], [65, 78], [65, 80], [65, 81], [65, 83], [65, 84], [65, 85], [65, 86], [65, 87], [65, 90], [65, 91], [65, 92], [65, 95], [65, 96], [65, 97], [65, 98], [65, 99], [66, 67], [66, 69], [66, 70], [66, 72], [66, 73], [66, 75], [66, 76], [66, 78], [66, 82], [66, 85], [66, 87], [66, 88], [66, 90], [66, 91], [66, 92], [66, 95], [66, 96], [66, 97], [66, 99], [67, 68], [67, 70], [67, 75], [67, 77], [67, 78], [67, 79], [67, 80], [67, 81], [67, 84], [67, 87], [67, 91], [67, 94], [67, 98], [67, 99], [68, 69], [68, 70], [68, 71], [68, 74], [68, 76], [68, 80], [68, 81], [68, 83], [68, 84], [68, 85], [68, 86], [68, 87], [68, 89], [68, 96], [68, 97], [68, 98], [69, 70], [69, 73], [69, 74], [69, 82], [69, 84], [69, 85], [69, 87], [69, 88], [69, 89], [69, 90], [69, 91], [69, 93], [69, 94], [69, 95], [69, 97], [69, 98], [70, 71], [70, 74], [70, 77], [70, 78], [70, 79], [70, 81], [70, 82], [70, 84], [70, 86], [70, 88], [70, 89], [70, 90], [70, 92], [70, 98], [71, 72], [71, 75], [71, 76], [71, 78], [71, 83], [71, 84], [71, 85], [71, 86], [71, 87], [71, 88], [71, 89], [71, 90], [71, 91], [71, 93], [71, 94], [71, 95], [71, 98], [71, 99], [72, 73], [72, 74], [72, 77], [72, 80], [72, 81], [72, 83], [72, 87], [72, 88], [72, 90], [72, 91], [72, 92], [72, 95], [72, 96], [72, 97], [72, 98], [72, 99], [73, 74], [73, 78], [73, 79], [73, 83], [73, 84], [73, 87], [73, 88], [73, 89], [73, 91], [73, 95], [73, 96], [73, 98], [74, 77], [74, 80], [74, 81], [74, 85], [74, 90], [74, 91], [74, 92], [74, 93], [74, 95], [74, 96], [74, 98], [75, 76], [75, 77], [75, 82], [75, 83], [75, 85], [75, 87], [75, 88], [75, 90], [75, 91], [75, 92], [76, 84], [76, 88], [76, 89], [76, 90], [76, 91], [76, 92], [76, 93], [76, 96], [76, 97], [77, 78], [77, 79], [77, 83], [77, 88], [77, 89], [77, 91], [77, 92], [77, 93], [77, 94], [77, 96], [77, 99], [78, 79], [78, 80], [78, 81], [78, 82], [78, 84], [78, 85], [78, 89], [78, 90], [78, 91], [78, 96], [78, 98], [79, 80], [79, 81], [79, 82], [79, 85], [79, 86], [79, 87], [79, 88], [79, 89], [79, 92], [79, 94], [79, 96], [80, 84], [80, 85], [80, 86], [80, 88], [80, 89], [80, 90], [80, 91], [80, 94], [80, 95], [80, 96], [80, 97], [80, 98], [81, 83], [81, 87], [81, 90], [81, 93], [81, 96], [81, 97], [81, 99], [82, 83], [82, 87], [82, 88], [82, 96], [82, 98], [82, 99], [83, 84], [83, 85], [83, 91], [83, 94], [83, 95], [83, 96], [83, 99], [84, 87], [84, 88], [84, 90], [84, 91], [84, 92], [84, 96], [84, 97], [84, 99], [85, 86], [85, 88], [85, 89], [85, 90], [85, 91], [85, 95], [85, 96], [85, 97], [85, 98], [86, 88], [86, 90], [86, 94], [86, 95], [86, 97], [86, 98], [87, 88], [87, 90], [87, 91], [87, 93], [87, 94], [87, 96], [88, 89], [88, 91], [88, 95], [88, 98], [89, 90], [89, 92], [89, 93], [89, 96], [89, 98], [89, 99], [90, 92], [90, 94], [90, 95], [90, 96], [90, 97], [90, 98], [90, 99], [91, 93], [91, 95], [91, 96], [91, 97], [91, 99], [92, 93], [92, 94], [92, 95], [92, 97], [92, 99], [93, 95], [93, 96], [93, 97], [93, 98], [94, 98], [94, 99], [95, 96], [95, 97], [95, 98], [95, 99], [96, 97], [96, 98], [96, 99], [97, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s7/solution/solve.sh b/tasks/construct-nppc-clique-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a0cf599baf92c2fda6c0746a436dc0e8fa66769 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [11, 13, 20, 23, 36, 38, 41, 42, 52, 53, 57, 60, 62, 65, 74, 80, 85, 90, 96, 98]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l6-s7/tests/check.py b/tasks/construct-nppc-clique-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s7/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l6-s7/tests/instance.json b/tasks/construct-nppc-clique-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aaa00a146518607199cb220a39c1bd95c87df965 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 4], [0, 5], [0, 6], [0, 9], [0, 11], [0, 13], [0, 14], [0, 15], [0, 16], [0, 18], [0, 20], [0, 25], [0, 28], [0, 32], [0, 33], [0, 34], [0, 38], [0, 39], [0, 40], [0, 41], [0, 42], [0, 47], [0, 49], [0, 52], [0, 53], [0, 54], [0, 55], [0, 56], [0, 57], [0, 59], [0, 61], [0, 62], [0, 63], [0, 64], [0, 71], [0, 73], [0, 74], [0, 77], [0, 79], [0, 80], [0, 81], [0, 84], [0, 85], [0, 86], [0, 87], [0, 90], [0, 93], [0, 94], [1, 2], [1, 3], [1, 6], [1, 10], [1, 12], [1, 16], [1, 19], [1, 20], [1, 22], [1, 27], [1, 30], [1, 31], [1, 32], [1, 34], [1, 35], [1, 36], [1, 38], [1, 39], [1, 44], [1, 46], [1, 47], [1, 50], [1, 51], [1, 53], [1, 54], [1, 55], [1, 60], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 74], [1, 75], [1, 77], [1, 79], [1, 80], [1, 81], [1, 82], [1, 84], [1, 85], [1, 86], [1, 88], [1, 89], [1, 92], [1, 98], [2, 3], [2, 5], [2, 9], [2, 10], [2, 12], [2, 15], [2, 17], [2, 18], [2, 19], [2, 21], [2, 22], [2, 25], [2, 26], [2, 35], [2, 38], [2, 43], [2, 45], [2, 46], [2, 50], [2, 55], [2, 56], [2, 57], [2, 58], [2, 59], [2, 60], [2, 61], [2, 63], [2, 65], [2, 66], [2, 68], [2, 69], [2, 76], [2, 77], [2, 80], [2, 82], [2, 83], [2, 86], [2, 87], [2, 89], [2, 92], [2, 98], [3, 5], [3, 7], [3, 8], [3, 10], [3, 13], [3, 15], [3, 16], [3, 17], [3, 18], [3, 20], [3, 23], [3, 25], [3, 26], [3, 27], [3, 30], [3, 31], [3, 35], [3, 36], [3, 38], [3, 40], [3, 42], [3, 46], [3, 47], [3, 49], [3, 51], [3, 53], [3, 54], [3, 55], [3, 56], [3, 58], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 71], [3, 73], [3, 74], [3, 75], [3, 77], [3, 78], [3, 79], [3, 81], [3, 82], [3, 83], [3, 87], [3, 88], [3, 89], [3, 90], [3, 91], [3, 92], [3, 93], [3, 97], [3, 99], [4, 7], [4, 12], [4, 17], [4, 19], [4, 20], [4, 22], [4, 23], [4, 25], [4, 28], [4, 36], [4, 37], [4, 38], [4, 42], [4, 43], [4, 45], [4, 46], [4, 47], [4, 51], [4, 53], [4, 55], [4, 57], [4, 58], [4, 59], [4, 60], [4, 68], [4, 71], [4, 72], [4, 73], [4, 74], [4, 76], [4, 77], [4, 78], [4, 80], [4, 82], [4, 86], [4, 87], [4, 89], [4, 93], [4, 95], [4, 97], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 13], [5, 14], [5, 15], [5, 19], [5, 24], [5, 25], [5, 26], [5, 28], [5, 29], [5, 32], [5, 34], [5, 37], [5, 38], [5, 40], [5, 44], [5, 45], [5, 46], [5, 49], [5, 53], [5, 54], [5, 56], [5, 57], [5, 58], [5, 59], [5, 60], [5, 65], [5, 69], [5, 74], [5, 75], [5, 78], [5, 81], [5, 83], [5, 87], [5, 88], [5, 90], [5, 92], [5, 98], [5, 99], [6, 7], [6, 9], [6, 10], [6, 14], [6, 15], [6, 21], [6, 22], [6, 24], [6, 26], [6, 28], [6, 30], [6, 31], [6, 32], [6, 33], [6, 37], [6, 40], [6, 41], [6, 42], [6, 43], [6, 45], [6, 46], [6, 47], [6, 50], [6, 53], [6, 55], [6, 61], [6, 62], [6, 64], [6, 65], [6, 68], [6, 69], [6, 72], [6, 73], [6, 74], [6, 78], [6, 80], [6, 82], [6, 84], [6, 85], [6, 90], [6, 95], [6, 96], [6, 97], [6, 98], [7, 8], [7, 13], [7, 14], [7, 15], [7, 17], [7, 18], [7, 19], [7, 20], [7, 22], [7, 24], [7, 25], [7, 26], [7, 27], [7, 29], [7, 30], [7, 34], [7, 36], [7, 37], [7, 38], [7, 41], [7, 42], [7, 46], [7, 48], [7, 50], [7, 55], [7, 56], [7, 57], [7, 63], [7, 64], [7, 65], [7, 67], [7, 69], [7, 70], [7, 71], [7, 73], [7, 74], [7, 76], [7, 77], [7, 79], [7, 81], [7, 84], [7, 87], [7, 90], [7, 91], [7, 92], [7, 94], [7, 95], [7, 96], [8, 10], [8, 13], [8, 15], [8, 19], [8, 20], [8, 21], [8, 22], [8, 25], [8, 27], [8, 28], [8, 30], [8, 31], [8, 32], [8, 39], [8, 40], [8, 41], [8, 44], [8, 46], [8, 47], [8, 48], [8, 50], [8, 51], [8, 53], [8, 54], [8, 57], [8, 58], [8, 59], [8, 61], [8, 62], [8, 65], [8, 66], [8, 67], [8, 68], [8, 74], [8, 79], [8, 82], [8, 83], [8, 84], [8, 85], [8, 86], [8, 88], [8, 90], [8, 93], [8, 95], [8, 96], [8, 97], [8, 98], [8, 99], [9, 13], [9, 14], [9, 16], [9, 17], [9, 18], [9, 23], [9, 24], [9, 26], [9, 27], [9, 29], [9, 31], [9, 32], [9, 34], [9, 39], [9, 41], [9, 44], [9, 49], [9, 51], [9, 53], [9, 56], [9, 57], [9, 59], [9, 62], [9, 63], [9, 65], [9, 67], [9, 68], [9, 70], [9, 72], [9, 74], [9, 79], [9, 80], [9, 81], [9, 82], [9, 85], [9, 86], [9, 87], [9, 90], [9, 93], [9, 95], [9, 96], [9, 98], [9, 99], [10, 11], [10, 14], [10, 16], [10, 19], [10, 22], [10, 23], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 30], [10, 32], [10, 34], [10, 36], [10, 38], [10, 39], [10, 42], [10, 44], [10, 50], [10, 51], [10, 57], [10, 59], [10, 60], [10, 63], [10, 66], [10, 67], [10, 70], [10, 72], [10, 74], [10, 75], [10, 76], [10, 77], [10, 80], [10, 82], [10, 89], [10, 90], [10, 94], [10, 98], [11, 12], [11, 13], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 23], [11, 25], [11, 26], [11, 28], [11, 30], [11, 31], [11, 32], [11, 33], [11, 36], [11, 38], [11, 39], [11, 41], [11, 42], [11, 43], [11, 44], [11, 45], [11, 47], [11, 48], [11, 50], [11, 51], [11, 52], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 60], [11, 61], [11, 62], [11, 65], [11, 70], [11, 74], [11, 78], [11, 80], [11, 81], [11, 84], [11, 85], [11, 87], [11, 90], [11, 94], [11, 95], [11, 96], [11, 97], [11, 98], [11, 99], [12, 13], [12, 14], [12, 16], [12, 18], [12, 19], [12, 20], [12, 21], [12, 26], [12, 27], [12, 34], [12, 36], [12, 37], [12, 41], [12, 46], [12, 48], [12, 49], [12, 51], [12, 52], [12, 56], [12, 57], [12, 58], [12, 59], [12, 60], [12, 62], [12, 63], [12, 65], [12, 66], [12, 67], [12, 68], [12, 70], [12, 73], [12, 75], [12, 76], [12, 77], [12, 78], [12, 80], [12, 85], [12, 86], [12, 87], [12, 89], [12, 91], [12, 94], [12, 96], [13, 16], [13, 18], [13, 19], [13, 20], [13, 22], [13, 23], [13, 25], [13, 29], [13, 32], [13, 34], [13, 36], [13, 38], [13, 40], [13, 41], [13, 42], [13, 43], [13, 44], [13, 46], [13, 50], [13, 52], [13, 53], [13, 54], [13, 56], [13, 57], [13, 58], [13, 60], [13, 61], [13, 62], [13, 63], [13, 64], [13, 65], [13, 70], [13, 72], [13, 74], [13, 75], [13, 80], [13, 81], [13, 82], [13, 83], [13, 85], [13, 87], [13, 89], [13, 90], [13, 91], [13, 92], [13, 93], [13, 96], [13, 97], [13, 98], [14, 17], [14, 18], [14, 22], [14, 26], [14, 29], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [14, 38], [14, 39], [14, 40], [14, 41], [14, 43], [14, 44], [14, 48], [14, 50], [14, 51], [14, 52], [14, 55], [14, 56], [14, 57], [14, 59], [14, 60], [14, 63], [14, 64], [14, 65], [14, 67], [14, 68], [14, 71], [14, 74], [14, 75], [14, 76], [14, 79], [14, 80], [14, 81], [14, 83], [14, 87], [14, 89], [14, 91], [14, 92], [14, 93], [14, 95], [14, 97], [15, 17], [15, 19], [15, 23], [15, 24], [15, 25], [15, 27], [15, 29], [15, 30], [15, 33], [15, 34], [15, 36], [15, 41], [15, 42], [15, 44], [15, 45], [15, 46], [15, 50], [15, 55], [15, 56], [15, 57], [15, 59], [15, 60], [15, 66], [15, 68], [15, 73], [15, 74], [15, 78], [15, 83], [15, 85], [15, 86], [15, 87], [15, 89], [15, 91], [15, 92], [15, 95], [15, 98], [15, 99], [16, 17], [16, 20], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 35], [16, 36], [16, 39], [16, 41], [16, 42], [16, 44], [16, 45], [16, 48], [16, 54], [16, 55], [16, 56], [16, 57], [16, 59], [16, 60], [16, 62], [16, 63], [16, 65], [16, 69], [16, 71], [16, 75], [16, 76], [16, 77], [16, 80], [16, 82], [16, 85], [16, 86], [16, 89], [16, 90], [16, 91], [16, 92], [16, 93], [16, 94], [16, 95], [16, 96], [16, 97], [16, 98], [17, 20], [17, 21], [17, 22], [17, 27], [17, 28], [17, 30], [17, 31], [17, 32], [17, 35], [17, 37], [17, 38], [17, 39], [17, 42], [17, 43], [17, 44], [17, 47], [17, 48], [17, 49], [17, 50], [17, 52], [17, 53], [17, 54], [17, 60], [17, 61], [17, 63], [17, 65], [17, 66], [17, 67], [17, 68], [17, 69], [17, 70], [17, 71], [17, 72], [17, 73], [17, 75], [17, 78], [17, 81], [17, 85], [17, 86], [17, 88], [17, 90], [17, 91], [17, 96], [18, 23], [18, 26], [18, 27], [18, 29], [18, 30], [18, 32], [18, 35], [18, 36], [18, 37], [18, 39], [18, 40], [18, 43], [18, 44], [18, 47], [18, 48], [18, 49], [18, 54], [18, 58], [18, 60], [18, 61], [18, 62], [18, 63], [18, 65], [18, 66], [18, 67], [18, 68], [18, 69], [18, 70], [18, 71], [18, 72], [18, 74], [18, 76], [18, 77], [18, 78], [18, 79], [18, 82], [18, 83], [18, 84], [18, 87], [18, 90], [18, 91], [18, 93], [18, 95], [18, 97], [18, 98], [18, 99], [19, 20], [19, 21], [19, 22], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 34], [19, 36], [19, 38], [19, 39], [19, 43], [19, 46], [19, 51], [19, 52], [19, 53], [19, 54], [19, 57], [19, 58], [19, 61], [19, 62], [19, 63], [19, 66], [19, 68], [19, 69], [19, 70], [19, 72], [19, 75], [19, 76], [19, 77], [19, 83], [19, 85], [19, 86], [19, 87], [19, 89], [19, 90], [19, 93], [19, 95], [19, 96], [19, 98], [19, 99], [20, 21], [20, 23], [20, 24], [20, 25], [20, 26], [20, 29], [20, 31], [20, 33], [20, 35], [20, 36], [20, 38], [20, 39], [20, 41], [20, 42], [20, 44], [20, 45], [20, 46], [20, 47], [20, 48], [20, 50], [20, 51], [20, 52], [20, 53], [20, 55], [20, 56], [20, 57], [20, 58], [20, 60], [20, 62], [20, 65], [20, 68], [20, 69], [20, 70], [20, 71], [20, 74], [20, 75], [20, 76], [20, 78], [20, 79], [20, 80], [20, 83], [20, 84], [20, 85], [20, 86], [20, 89], [20, 90], [20, 94], [20, 96], [20, 97], [20, 98], [20, 99], [21, 22], [21, 23], [21, 24], [21, 25], [21, 28], [21, 34], [21, 35], [21, 37], [21, 42], [21, 43], [21, 44], [21, 50], [21, 52], [21, 54], [21, 60], [21, 62], [21, 63], [21, 65], [21, 66], [21, 68], [21, 69], [21, 70], [21, 75], [21, 78], [21, 79], [21, 80], [21, 82], [21, 83], [21, 84], [21, 85], [21, 86], [21, 87], [21, 89], [21, 90], [21, 91], [21, 94], [21, 96], [21, 97], [21, 98], [21, 99], [22, 23], [22, 25], [22, 28], [22, 31], [22, 32], [22, 33], [22, 37], [22, 39], [22, 40], [22, 41], [22, 44], [22, 46], [22, 48], [22, 49], [22, 50], [22, 51], [22, 53], [22, 54], [22, 58], [22, 59], [22, 60], [22, 61], [22, 64], [22, 68], [22, 69], [22, 71], [22, 72], [22, 76], [22, 80], [22, 84], [22, 85], [22, 86], [22, 90], [22, 92], [22, 93], [22, 95], [22, 98], [22, 99], [23, 24], [23, 28], [23, 33], [23, 34], [23, 36], [23, 37], [23, 38], [23, 41], [23, 42], [23, 44], [23, 45], [23, 47], [23, 48], [23, 49], [23, 51], [23, 52], [23, 53], [23, 56], [23, 57], [23, 58], [23, 59], [23, 60], [23, 62], [23, 64], [23, 65], [23, 67], [23, 74], [23, 75], [23, 78], [23, 80], [23, 82], [23, 83], [23, 85], [23, 87], [23, 88], [23, 90], [23, 91], [23, 92], [23, 96], [23, 97], [23, 98], [24, 25], [24, 26], [24, 28], [24, 31], [24, 33], [24, 34], [24, 35], [24, 36], [24, 37], [24, 38], [24, 41], [24, 42], [24, 43], [24, 44], [24, 46], [24, 47], [24, 51], [24, 53], [24, 54], [24, 60], [24, 66], [24, 70], [24, 71], [24, 72], [24, 73], [24, 75], [24, 79], [24, 80], [24, 81], [24, 83], [24, 84], [24, 89], [24, 92], [24, 93], [24, 95], [24, 99], [25, 28], [25, 29], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 45], [25, 47], [25, 49], [25, 52], [25, 53], [25, 55], [25, 56], [25, 60], [25, 64], [25, 65], [25, 66], [25, 67], [25, 69], [25, 72], [25, 73], [25, 77], [25, 78], [25, 80], [25, 81], [25, 83], [25, 85], [25, 87], [25, 88], [25, 89], [25, 94], [25, 99], [26, 27], [26, 29], [26, 31], [26, 32], [26, 35], [26, 39], [26, 40], [26, 41], [26, 42], [26, 47], [26, 48], [26, 49], [26, 52], [26, 56], [26, 58], [26, 60], [26, 61], [26, 67], [26, 72], [26, 73], [26, 74], [26, 75], [26, 77], [26, 79], [26, 80], [26, 81], [26, 82], [26, 85], [26, 86], [26, 88], [26, 91], [26, 94], [26, 96], [26, 97], [27, 28], [27, 36], [27, 38], [27, 40], [27, 41], [27, 42], [27, 43], [27, 44], [27, 45], [27, 46], [27, 47], [27, 49], [27, 52], [27, 57], [27, 59], [27, 60], [27, 63], [27, 64], [27, 69], [27, 70], [27, 71], [27, 73], [27, 74], [27, 78], [27, 80], [27, 82], [27, 85], [27, 86], [27, 89], [27, 90], [27, 92], [27, 94], [27, 96], [27, 97], [28, 29], [28, 35], [28, 36], [28, 38], [28, 39], [28, 40], [28, 41], [28, 42], [28, 47], [28, 48], [28, 52], [28, 53], [28, 55], [28, 57], [28, 58], [28, 59], [28, 60], [28, 61], [28, 62], [28, 63], [28, 64], [28, 65], [28, 66], [28, 67], [28, 69], [28, 71], [28, 73], [28, 74], [28, 75], [28, 76], [28, 77], [28, 82], [28, 84], [28, 85], [28, 88], [28, 95], [28, 98], [29, 30], [29, 32], [29, 33], [29, 34], [29, 35], [29, 40], [29, 41], [29, 42], [29, 43], [29, 45], [29, 46], [29, 47], [29, 49], [29, 52], [29, 53], [29, 57], [29, 61], [29, 62], [29, 66], [29, 67], [29, 68], [29, 70], [29, 73], [29, 74], [29, 75], [29, 76], [29, 79], [29, 82], [29, 84], [29, 88], [29, 90], [29, 91], [29, 92], [29, 97], [29, 98], [29, 99], [30, 31], [30, 33], [30, 34], [30, 38], [30, 39], [30, 43], [30, 44], [30, 45], [30, 47], [30, 49], [30, 50], [30, 51], [30, 52], [30, 53], [30, 56], [30, 59], [30, 60], [30, 61], [30, 62], [30, 64], [30, 66], [30, 68], [30, 69], [30, 70], [30, 71], [30, 72], [30, 73], [30, 74], [30, 76], [30, 77], [30, 78], [30, 79], [30, 80], [30, 81], [30, 83], [30, 85], [30, 87], [30, 88], [30, 90], [30, 93], [30, 95], [30, 96], [30, 97], [30, 98], [30, 99], [31, 32], [31, 46], [31, 47], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 53], [31, 56], [31, 57], [31, 58], [31, 59], [31, 61], [31, 63], [31, 64], [31, 65], [31, 67], [31, 68], [31, 69], [31, 71], [31, 73], [31, 74], [31, 77], [31, 80], [31, 83], [31, 86], [31, 90], [31, 91], [31, 93], [31, 94], [31, 95], [31, 96], [31, 97], [31, 98], [32, 34], [32, 35], [32, 36], [32, 40], [32, 41], [32, 42], [32, 45], [32, 46], [32, 48], [32, 50], [32, 51], [32, 52], [32, 53], [32, 59], [32, 60], [32, 61], [32, 64], [32, 65], [32, 66], [32, 68], [32, 72], [32, 73], [32, 74], [32, 75], [32, 77], [32, 78], [32, 79], [32, 80], [32, 82], [32, 83], [32, 88], [32, 92], [32, 93], [32, 94], [32, 98], [33, 35], [33, 38], [33, 39], [33, 42], [33, 43], [33, 46], [33, 48], [33, 50], [33, 61], [33, 63], [33, 64], [33, 65], [33, 66], [33, 67], [33, 69], [33, 72], [33, 75], [33, 77], [33, 79], [33, 81], [33, 82], [33, 87], [33, 88], [33, 90], [33, 94], [33, 97], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [34, 41], [34, 42], [34, 43], [34, 44], [34, 47], [34, 48], [34, 51], [34, 52], [34, 53], [34, 54], [34, 55], [34, 56], [34, 57], [34, 60], [34, 61], [34, 62], [34, 63], [34, 64], [34, 65], [34, 66], [34, 67], [34, 69], [34, 70], [34, 74], [34, 75], [34, 78], [34, 79], [34, 80], [34, 85], [34, 86], [34, 88], [34, 93], [34, 94], [34, 98], [34, 99], [35, 36], [35, 38], [35, 40], [35, 44], [35, 45], [35, 46], [35, 48], [35, 49], [35, 53], [35, 56], [35, 57], [35, 62], [35, 63], [35, 65], [35, 67], [35, 68], [35, 73], [35, 74], [35, 75], [35, 78], [35, 80], [35, 82], [35, 83], [35, 85], [35, 86], [35, 87], [35, 88], [35, 92], [35, 93], [35, 94], [35, 98], [36, 38], [36, 39], [36, 40], [36, 41], [36, 42], [36, 44], [36, 47], [36, 50], [36, 51], [36, 52], [36, 53], [36, 55], [36, 56], [36, 57], [36, 58], [36, 60], [36, 62], [36, 63], [36, 64], [36, 65], [36, 66], [36, 67], [36, 68], [36, 69], [36, 70], [36, 73], [36, 74], [36, 79], [36, 80], [36, 81], [36, 84], [36, 85], [36, 87], [36, 88], [36, 90], [36, 91], [36, 95], [36, 96], [36, 98], [36, 99], [37, 38], [37, 40], [37, 44], [37, 45], [37, 46], [37, 57], [37, 58], [37, 60], [37, 61], [37, 63], [37, 65], [37, 69], [37, 71], [37, 72], [37, 74], [37, 78], [37, 79], [37, 80], [37, 81], [37, 82], [37, 84], [37, 86], [37, 87], [37, 88], [37, 89], [37, 90], [37, 91], [37, 92], [37, 94], [37, 96], [37, 97], [37, 99], [38, 41], [38, 42], [38, 43], [38, 46], [38, 47], [38, 50], [38, 52], [38, 53], [38, 54], [38, 56], [38, 57], [38, 60], [38, 62], [38, 65], [38, 66], [38, 67], [38, 68], [38, 69], [38, 70], [38, 72], [38, 74], [38, 76], [38, 77], [38, 78], [38, 79], [38, 80], [38, 81], [38, 82], [38, 83], [38, 85], [38, 86], [38, 88], [38, 90], [38, 93], [38, 94], [38, 96], [38, 98], [38, 99], [39, 41], [39, 42], [39, 43], [39, 44], [39, 46], [39, 47], [39, 51], [39, 54], [39, 57], [39, 58], [39, 59], [39, 61], [39, 63], [39, 64], [39, 68], [39, 69], [39, 71], [39, 72], [39, 76], [39, 77], [39, 78], [39, 80], [39, 82], [39, 83], [39, 84], [39, 85], [39, 86], [39, 87], [39, 89], [39, 93], [39, 95], [39, 96], [39, 99], [40, 41], [40, 42], [40, 48], [40, 49], [40, 50], [40, 52], [40, 53], [40, 54], [40, 57], [40, 58], [40, 59], [40, 60], [40, 61], [40, 62], [40, 63], [40, 65], [40, 66], [40, 68], [40, 69], [40, 70], [40, 71], [40, 74], [40, 75], [40, 76], [40, 77], [40, 78], [40, 79], [40, 80], [40, 81], [40, 82], [40, 83], [40, 87], [40, 88], [40, 89], [40, 90], [40, 91], [40, 94], [40, 95], [40, 96], [40, 98], [40, 99], [41, 42], [41, 43], [41, 45], [41, 47], [41, 48], [41, 49], [41, 50], [41, 51], [41, 52], [41, 53], [41, 55], [41, 56], [41, 57], [41, 59], [41, 60], [41, 62], [41, 64], [41, 65], [41, 66], [41, 67], [41, 68], [41, 71], [41, 72], [41, 74], [41, 78], [41, 79], [41, 80], [41, 83], [41, 85], [41, 90], [41, 91], [41, 92], [41, 94], [41, 96], [41, 98], [41, 99], [42, 43], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 51], [42, 52], [42, 53], [42, 54], [42, 55], [42, 56], [42, 57], [42, 58], [42, 59], [42, 60], [42, 61], [42, 62], [42, 63], [42, 65], [42, 66], [42, 67], [42, 73], [42, 74], [42, 75], [42, 77], [42, 78], [42, 80], [42, 84], [42, 85], [42, 86], [42, 88], [42, 90], [42, 93], [42, 95], [42, 96], [42, 97], [42, 98], [42, 99], [43, 44], [43, 46], [43, 47], [43, 49], [43, 51], [43, 56], [43, 57], [43, 60], [43, 61], [43, 62], [43, 63], [43, 64], [43, 66], [43, 67], [43, 69], [43, 71], [43, 73], [43, 76], [43, 77], [43, 78], [43, 80], [43, 81], [43, 82], [43, 89], [43, 90], [43, 91], [43, 94], [43, 95], [43, 96], [44, 46], [44, 49], [44, 50], [44, 51], [44, 53], [44, 54], [44, 58], [44, 64], [44, 65], [44, 69], [44, 70], [44, 71], [44, 73], [44, 74], [44, 75], [44, 79], [44, 80], [44, 81], [44, 82], [44, 84], [44, 85], [44, 86], [44, 87], [44, 89], [44, 90], [44, 95], [44, 97], [44, 98], [44, 99], [45, 48], [45, 49], [45, 50], [45, 52], [45, 53], [45, 54], [45, 58], [45, 59], [45, 61], [45, 64], [45, 65], [45, 67], [45, 69], [45, 71], [45, 72], [45, 74], [45, 78], [45, 81], [45, 82], [45, 83], [45, 84], [45, 85], [45, 86], [45, 88], [45, 91], [45, 93], [45, 99], [46, 50], [46, 56], [46, 57], [46, 58], [46, 59], [46, 60], [46, 61], [46, 64], [46, 65], [46, 67], [46, 68], [46, 74], [46, 75], [46, 77], [46, 81], [46, 83], [46, 85], [46, 87], [46, 88], [46, 90], [46, 92], [46, 96], [47, 49], [47, 53], [47, 56], [47, 57], [47, 60], [47, 62], [47, 64], [47, 66], [47, 67], [47, 68], [47, 69], [47, 70], [47, 71], [47, 75], [47, 78], [47, 79], [47, 81], [47, 82], [47, 83], [47, 85], [47, 87], [47, 90], [47, 91], [47, 93], [47, 94], [47, 96], [47, 97], [48, 50], [48, 53], [48, 55], [48, 57], [48, 58], [48, 59], [48, 60], [48, 61], [48, 62], [48, 65], [48, 68], [48, 70], [48, 76], [48, 77], [48, 78], [48, 79], [48, 80], [48, 81], [48, 82], [48, 83], [48, 84], [48, 86], [48, 87], [48, 88], [48, 90], [48, 92], [48, 96], [48, 99], [49, 51], [49, 53], [49, 55], [49, 56], [49, 57], [49, 58], [49, 60], [49, 61], [49, 62], [49, 64], [49, 69], [49, 70], [49, 73], [49, 74], [49, 78], [49, 79], [49, 81], [49, 84], [49, 86], [49, 88], [49, 90], [49, 91], [49, 98], [50, 51], [50, 54], [50, 57], [50, 58], [50, 59], [50, 60], [50, 62], [50, 64], [50, 68], [50, 69], [50, 76], [50, 78], [50, 79], [50, 81], [50, 83], [50, 85], [50, 86], [50, 88], [50, 89], [50, 90], [50, 91], [50, 92], [50, 97], [51, 53], [51, 56], [51, 63], [51, 64], [51, 66], [51, 67], [51, 69], [51, 70], [51, 71], [51, 73], [51, 74], [51, 76], [51, 78], [51, 79], [51, 85], [51, 88], [51, 91], [51, 92], [51, 93], [51, 94], [51, 95], [51, 96], [51, 98], [51, 99], [52, 53], [52, 54], [52, 55], [52, 56], [52, 57], [52, 58], [52, 60], [52, 62], [52, 65], [52, 66], [52, 67], [52, 72], [52, 74], [52, 75], [52, 76], [52, 77], [52, 78], [52, 79], [52, 80], [52, 81], [52, 85], [52, 86], [52, 89], [52, 90], [52, 92], [52, 93], [52, 95], [52, 96], [52, 98], [53, 54], [53, 56], [53, 57], [53, 58], [53, 59], [53, 60], [53, 62], [53, 64], [53, 65], [53, 66], [53, 67], [53, 72], [53, 73], [53, 74], [53, 78], [53, 79], [53, 80], [53, 81], [53, 83], [53, 84], [53, 85], [53, 86], [53, 89], [53, 90], [53, 91], [53, 93], [53, 95], [53, 96], [53, 97], [53, 98], [54, 55], [54, 56], [54, 59], [54, 60], [54, 61], [54, 65], [54, 66], [54, 67], [54, 68], [54, 71], [54, 72], [54, 73], [54, 76], [54, 79], [54, 83], [54, 84], [54, 85], [54, 88], [54, 90], [54, 93], [54, 94], [54, 95], [54, 96], [55, 56], [55, 57], [55, 61], [55, 62], [55, 65], [55, 71], [55, 72], [55, 74], [55, 75], [55, 78], [55, 79], [55, 82], [55, 83], [55, 84], [55, 85], [55, 86], [55, 88], [55, 91], [55, 93], [55, 94], [55, 95], [55, 96], [55, 97], [56, 57], [56, 60], [56, 61], [56, 62], [56, 66], [56, 70], [56, 71], [56, 72], [56, 74], [56, 75], [56, 78], [56, 79], [56, 81], [56, 82], [56, 83], [56, 84], [56, 87], [56, 89], [56, 92], [56, 93], [56, 94], [56, 95], [56, 98], [57, 58], [57, 59], [57, 60], [57, 62], [57, 63], [57, 64], [57, 65], [57, 66], [57, 67], [57, 71], [57, 72], [57, 74], [57, 78], [57, 80], [57, 81], [57, 82], [57, 85], [57, 86], [57, 87], [57, 88], [57, 89], [57, 90], [57, 91], [57, 92], [57, 94], [57, 95], [57, 96], [57, 97], [57, 98], [57, 99], [58, 59], [58, 64], [58, 66], [58, 68], [58, 69], [58, 73], [58, 74], [58, 75], [58, 77], [58, 78], [58, 79], [58, 80], [58, 85], [58, 86], [58, 87], [58, 90], [58, 94], [58, 98], [58, 99], [59, 61], [59, 65], [59, 69], [59, 71], [59, 72], [59, 73], [59, 75], [59, 78], [59, 81], [59, 82], [59, 86], [59, 87], [59, 90], [59, 91], [59, 92], [59, 95], [59, 97], [59, 99], [60, 61], [60, 62], [60, 64], [60, 65], [60, 66], [60, 68], [60, 72], [60, 73], [60, 74], [60, 76], [60, 77], [60, 80], [60, 81], [60, 85], [60, 86], [60, 88], [60, 89], [60, 90], [60, 93], [60, 96], [60, 97], [60, 98], [61, 63], [61, 64], [61, 65], [61, 67], [61, 68], [61, 69], [61, 70], [61, 73], [61, 74], [61, 75], [61, 77], [61, 78], [61, 79], [61, 80], [61, 81], [61, 83], [61, 87], [61, 88], [61, 89], [61, 90], [61, 94], [61, 95], [61, 96], [61, 99], [62, 63], [62, 64], [62, 65], [62, 70], [62, 74], [62, 75], [62, 76], [62, 77], [62, 78], [62, 79], [62, 80], [62, 82], [62, 83], [62, 84], [62, 85], [62, 88], [62, 89], [62, 90], [62, 92], [62, 93], [62, 96], [62, 97], [62, 98], [63, 64], [63, 67], [63, 68], [63, 69], [63, 71], [63, 74], [63, 75], [63, 76], [63, 80], [63, 81], [63, 82], [63, 88], [63, 90], [63, 91], [63, 92], [63, 93], [63, 98], [64, 70], [64, 71], [64, 72], [64, 75], [64, 78], [64, 83], [64, 84], [64, 86], [64, 87], [64, 88], [64, 89], [64, 92], [64, 95], [64, 96], [64, 98], [64, 99], [65, 68], [65, 72], [65, 73], [65, 74], [65, 76], [65, 78], [65, 80], [65, 81], [65, 83], [65, 84], [65, 85], [65, 86], [65, 87], [65, 90], [65, 91], [65, 92], [65, 95], [65, 96], [65, 97], [65, 98], [65, 99], [66, 67], [66, 69], [66, 70], [66, 72], [66, 73], [66, 75], [66, 76], [66, 78], [66, 82], [66, 85], [66, 87], [66, 88], [66, 90], [66, 91], [66, 92], [66, 95], [66, 96], [66, 97], [66, 99], [67, 68], [67, 70], [67, 75], [67, 77], [67, 78], [67, 79], [67, 80], [67, 81], [67, 84], [67, 87], [67, 91], [67, 94], [67, 98], [67, 99], [68, 69], [68, 70], [68, 71], [68, 74], [68, 76], [68, 80], [68, 81], [68, 83], [68, 84], [68, 85], [68, 86], [68, 87], [68, 89], [68, 96], [68, 97], [68, 98], [69, 70], [69, 73], [69, 74], [69, 82], [69, 84], [69, 85], [69, 87], [69, 88], [69, 89], [69, 90], [69, 91], [69, 93], [69, 94], [69, 95], [69, 97], [69, 98], [70, 71], [70, 74], [70, 77], [70, 78], [70, 79], [70, 81], [70, 82], [70, 84], [70, 86], [70, 88], [70, 89], [70, 90], [70, 92], [70, 98], [71, 72], [71, 75], [71, 76], [71, 78], [71, 83], [71, 84], [71, 85], [71, 86], [71, 87], [71, 88], [71, 89], [71, 90], [71, 91], [71, 93], [71, 94], [71, 95], [71, 98], [71, 99], [72, 73], [72, 74], [72, 77], [72, 80], [72, 81], [72, 83], [72, 87], [72, 88], [72, 90], [72, 91], [72, 92], [72, 95], [72, 96], [72, 97], [72, 98], [72, 99], [73, 74], [73, 78], [73, 79], [73, 83], [73, 84], [73, 87], [73, 88], [73, 89], [73, 91], [73, 95], [73, 96], [73, 98], [74, 77], [74, 80], [74, 81], [74, 85], [74, 90], [74, 91], [74, 92], [74, 93], [74, 95], [74, 96], [74, 98], [75, 76], [75, 77], [75, 82], [75, 83], [75, 85], [75, 87], [75, 88], [75, 90], [75, 91], [75, 92], [76, 84], [76, 88], [76, 89], [76, 90], [76, 91], [76, 92], [76, 93], [76, 96], [76, 97], [77, 78], [77, 79], [77, 83], [77, 88], [77, 89], [77, 91], [77, 92], [77, 93], [77, 94], [77, 96], [77, 99], [78, 79], [78, 80], [78, 81], [78, 82], [78, 84], [78, 85], [78, 89], [78, 90], [78, 91], [78, 96], [78, 98], [79, 80], [79, 81], [79, 82], [79, 85], [79, 86], [79, 87], [79, 88], [79, 89], [79, 92], [79, 94], [79, 96], [80, 84], [80, 85], [80, 86], [80, 88], [80, 89], [80, 90], [80, 91], [80, 94], [80, 95], [80, 96], [80, 97], [80, 98], [81, 83], [81, 87], [81, 90], [81, 93], [81, 96], [81, 97], [81, 99], [82, 83], [82, 87], [82, 88], [82, 96], [82, 98], [82, 99], [83, 84], [83, 85], [83, 91], [83, 94], [83, 95], [83, 96], [83, 99], [84, 87], [84, 88], [84, 90], [84, 91], [84, 92], [84, 96], [84, 97], [84, 99], [85, 86], [85, 88], [85, 89], [85, 90], [85, 91], [85, 95], [85, 96], [85, 97], [85, 98], [86, 88], [86, 90], [86, 94], [86, 95], [86, 97], [86, 98], [87, 88], [87, 90], [87, 91], [87, 93], [87, 94], [87, 96], [88, 89], [88, 91], [88, 95], [88, 98], [89, 90], [89, 92], [89, 93], [89, 96], [89, 98], [89, 99], [90, 92], [90, 94], [90, 95], [90, 96], [90, 97], [90, 98], [90, 99], [91, 93], [91, 95], [91, 96], [91, 97], [91, 99], [92, 93], [92, 94], [92, 95], [92, 97], [92, 99], [93, 95], [93, 96], [93, 97], [93, 98], [94, 98], [94, 99], [95, 96], [95, 97], [95, 98], [95, 99], [96, 97], [96, 98], [96, 99], [97, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s7/tests/run.py b/tasks/construct-nppc-clique-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l6-s7/tests/test.sh b/tasks/construct-nppc-clique-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l6-s9/environment/Dockerfile b/tasks/construct-nppc-clique-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l6-s9/environment/instance.json b/tasks/construct-nppc-clique-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8069f89dbbce43165d48b3dc0856d76c91abfa3f --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 3], [0, 7], [0, 12], [0, 15], [0, 16], [0, 18], [0, 19], [0, 22], [0, 27], [0, 29], [0, 30], [0, 31], [0, 33], [0, 34], [0, 36], [0, 37], [0, 39], [0, 43], [0, 47], [0, 48], [0, 50], [0, 51], [0, 54], [0, 55], [0, 56], [0, 58], [0, 65], [0, 66], [0, 68], [0, 69], [0, 71], [0, 73], [0, 74], [0, 75], [0, 77], [0, 79], [0, 80], [0, 81], [0, 84], [0, 85], [0, 89], [0, 90], [0, 93], [0, 94], [0, 96], [0, 99], [1, 2], [1, 5], [1, 6], [1, 8], [1, 9], [1, 10], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 37], [1, 39], [1, 41], [1, 43], [1, 48], [1, 49], [1, 51], [1, 52], [1, 56], [1, 58], [1, 60], [1, 63], [1, 64], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 72], [1, 74], [1, 75], [1, 77], [1, 78], [1, 79], [1, 81], [1, 82], [1, 83], [1, 85], [1, 86], [1, 87], [1, 91], [1, 92], [1, 93], [1, 94], [1, 96], [1, 98], [2, 3], [2, 5], [2, 7], [2, 8], [2, 10], [2, 13], [2, 16], [2, 18], [2, 19], [2, 21], [2, 22], [2, 27], [2, 28], [2, 29], [2, 30], [2, 32], [2, 33], [2, 35], [2, 36], [2, 38], [2, 39], [2, 40], [2, 43], [2, 47], [2, 48], [2, 49], [2, 50], [2, 52], [2, 54], [2, 55], [2, 56], [2, 59], [2, 60], [2, 61], [2, 62], [2, 63], [2, 68], [2, 71], [2, 86], [2, 87], [2, 88], [2, 89], [2, 92], [2, 93], [2, 95], [2, 97], [3, 4], [3, 7], [3, 13], [3, 16], [3, 18], [3, 20], [3, 21], [3, 22], [3, 26], [3, 29], [3, 30], [3, 31], [3, 32], [3, 35], [3, 36], [3, 37], [3, 39], [3, 40], [3, 41], [3, 43], [3, 45], [3, 47], [3, 49], [3, 50], [3, 52], [3, 54], [3, 55], [3, 58], [3, 61], [3, 63], [3, 66], [3, 67], [3, 69], [3, 70], [3, 72], [3, 74], [3, 77], [3, 79], [3, 82], [3, 83], [3, 84], [3, 89], [3, 90], [3, 91], [3, 92], [3, 93], [3, 94], [3, 98], [4, 5], [4, 11], [4, 12], [4, 13], [4, 14], [4, 16], [4, 17], [4, 24], [4, 25], [4, 26], [4, 28], [4, 30], [4, 31], [4, 32], [4, 33], [4, 36], [4, 37], [4, 40], [4, 42], [4, 43], [4, 44], [4, 46], [4, 48], [4, 49], [4, 50], [4, 53], [4, 55], [4, 56], [4, 57], [4, 61], [4, 62], [4, 63], [4, 64], [4, 65], [4, 67], [4, 71], [4, 74], [4, 75], [4, 76], [4, 79], [4, 81], [4, 83], [4, 84], [4, 85], [4, 92], [4, 94], [4, 99], [5, 6], [5, 8], [5, 9], [5, 10], [5, 11], [5, 14], [5, 15], [5, 16], [5, 17], [5, 22], [5, 25], [5, 26], [5, 29], [5, 33], [5, 34], [5, 36], [5, 37], [5, 39], [5, 40], [5, 47], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [5, 56], [5, 57], [5, 58], [5, 60], [5, 61], [5, 62], [5, 65], [5, 66], [5, 69], [5, 70], [5, 71], [5, 72], [5, 74], [5, 75], [5, 76], [5, 77], [5, 79], [5, 87], [5, 89], [5, 91], [5, 93], [5, 95], [5, 98], [6, 7], [6, 8], [6, 10], [6, 11], [6, 13], [6, 14], [6, 21], [6, 24], [6, 26], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 39], [6, 43], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 55], [6, 59], [6, 61], [6, 62], [6, 63], [6, 66], [6, 67], [6, 69], [6, 70], [6, 72], [6, 73], [6, 77], [6, 78], [6, 80], [6, 82], [6, 83], [6, 86], [6, 88], [6, 89], [6, 90], [6, 91], [6, 94], [6, 95], [6, 96], [6, 97], [6, 98], [7, 8], [7, 9], [7, 10], [7, 13], [7, 14], [7, 15], [7, 17], [7, 19], [7, 22], [7, 24], [7, 25], [7, 26], [7, 28], [7, 29], [7, 30], [7, 32], [7, 35], [7, 37], [7, 39], [7, 42], [7, 44], [7, 46], [7, 47], [7, 48], [7, 50], [7, 51], [7, 52], [7, 56], [7, 57], [7, 59], [7, 62], [7, 63], [7, 64], [7, 67], [7, 70], [7, 72], [7, 73], [7, 74], [7, 77], [7, 78], [7, 81], [7, 84], [7, 89], [7, 94], [7, 95], [7, 97], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 20], [8, 23], [8, 26], [8, 28], [8, 31], [8, 32], [8, 33], [8, 34], [8, 36], [8, 39], [8, 44], [8, 45], [8, 46], [8, 47], [8, 48], [8, 50], [8, 52], [8, 54], [8, 56], [8, 57], [8, 61], [8, 65], [8, 70], [8, 74], [8, 76], [8, 77], [8, 78], [8, 79], [8, 80], [8, 88], [8, 91], [8, 92], [8, 93], [8, 94], [8, 95], [8, 97], [9, 10], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 22], [9, 23], [9, 24], [9, 25], [9, 29], [9, 32], [9, 35], [9, 36], [9, 37], [9, 38], [9, 40], [9, 43], [9, 45], [9, 47], [9, 48], [9, 49], [9, 51], [9, 52], [9, 56], [9, 58], [9, 59], [9, 60], [9, 62], [9, 63], [9, 64], [9, 65], [9, 67], [9, 68], [9, 69], [9, 71], [9, 73], [9, 74], [9, 76], [9, 77], [9, 78], [9, 79], [9, 81], [9, 82], [9, 83], [9, 86], [9, 87], [9, 88], [9, 89], [9, 90], [9, 92], [9, 93], [9, 94], [9, 95], [9, 97], [10, 11], [10, 13], [10, 14], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 22], [10, 29], [10, 31], [10, 32], [10, 34], [10, 35], [10, 37], [10, 38], [10, 43], [10, 46], [10, 47], [10, 48], [10, 52], [10, 53], [10, 55], [10, 56], [10, 71], [10, 72], [10, 76], [10, 77], [10, 78], [10, 80], [10, 84], [10, 92], [10, 93], [10, 94], [10, 98], [11, 12], [11, 15], [11, 18], [11, 21], [11, 24], [11, 25], [11, 27], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [11, 37], [11, 38], [11, 42], [11, 43], [11, 44], [11, 47], [11, 48], [11, 50], [11, 51], [11, 52], [11, 53], [11, 59], [11, 60], [11, 63], [11, 64], [11, 66], [11, 67], [11, 69], [11, 71], [11, 72], [11, 73], [11, 76], [11, 78], [11, 80], [11, 81], [11, 82], [11, 84], [11, 96], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 22], [12, 31], [12, 33], [12, 34], [12, 35], [12, 37], [12, 39], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 50], [12, 55], [12, 56], [12, 59], [12, 62], [12, 66], [12, 68], [12, 69], [12, 71], [12, 72], [12, 74], [12, 78], [12, 79], [12, 80], [12, 81], [12, 85], [12, 86], [12, 87], [12, 89], [12, 90], [12, 92], [12, 96], [12, 97], [12, 98], [13, 14], [13, 17], [13, 18], [13, 24], [13, 25], [13, 27], [13, 28], [13, 32], [13, 33], [13, 36], [13, 37], [13, 39], [13, 41], [13, 42], [13, 43], [13, 46], [13, 47], [13, 51], [13, 54], [13, 56], [13, 57], [13, 60], [13, 61], [13, 64], [13, 67], [13, 68], [13, 69], [13, 73], [13, 74], [13, 76], [13, 79], [13, 82], [13, 83], [13, 85], [13, 86], [13, 88], [13, 90], [13, 91], [13, 92], [13, 93], [13, 96], [13, 98], [14, 16], [14, 19], [14, 21], [14, 23], [14, 24], [14, 27], [14, 28], [14, 30], [14, 31], [14, 32], [14, 34], [14, 35], [14, 37], [14, 40], [14, 43], [14, 44], [14, 45], [14, 46], [14, 47], [14, 49], [14, 50], [14, 51], [14, 53], [14, 54], [14, 56], [14, 57], [14, 60], [14, 61], [14, 63], [14, 64], [14, 67], [14, 68], [14, 70], [14, 71], [14, 72], [14, 73], [14, 74], [14, 77], [14, 78], [14, 80], [14, 81], [14, 83], [14, 85], [14, 87], [14, 92], [14, 93], [14, 94], [14, 96], [14, 97], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 25], [15, 29], [15, 34], [15, 36], [15, 38], [15, 40], [15, 46], [15, 47], [15, 48], [15, 52], [15, 53], [15, 54], [15, 58], [15, 60], [15, 63], [15, 64], [15, 67], [15, 69], [15, 72], [15, 73], [15, 76], [15, 79], [15, 80], [15, 82], [15, 84], [15, 89], [15, 94], [15, 95], [15, 96], [15, 97], [15, 98], [16, 18], [16, 22], [16, 24], [16, 26], [16, 27], [16, 28], [16, 31], [16, 32], [16, 34], [16, 39], [16, 44], [16, 45], [16, 46], [16, 48], [16, 50], [16, 55], [16, 56], [16, 58], [16, 59], [16, 62], [16, 63], [16, 64], [16, 65], [16, 66], [16, 68], [16, 70], [16, 72], [16, 78], [16, 79], [16, 80], [16, 81], [16, 83], [16, 84], [16, 85], [16, 86], [16, 89], [16, 90], [16, 91], [16, 92], [16, 94], [16, 96], [16, 97], [16, 99], [17, 19], [17, 21], [17, 24], [17, 25], [17, 29], [17, 30], [17, 31], [17, 33], [17, 36], [17, 37], [17, 39], [17, 41], [17, 46], [17, 47], [17, 48], [17, 49], [17, 50], [17, 51], [17, 54], [17, 57], [17, 58], [17, 63], [17, 65], [17, 70], [17, 76], [17, 77], [17, 81], [17, 83], [17, 84], [17, 85], [17, 86], [17, 90], [17, 91], [17, 93], [17, 95], [17, 97], [17, 98], [17, 99], [18, 19], [18, 20], [18, 22], [18, 23], [18, 25], [18, 27], [18, 29], [18, 32], [18, 33], [18, 35], [18, 36], [18, 37], [18, 38], [18, 40], [18, 41], [18, 42], [18, 43], [18, 45], [18, 46], [18, 47], [18, 52], [18, 57], [18, 58], [18, 60], [18, 61], [18, 62], [18, 64], [18, 70], [18, 72], [18, 74], [18, 76], [18, 77], [18, 79], [18, 80], [18, 83], [18, 84], [18, 85], [18, 87], [18, 90], [18, 91], [18, 94], [18, 95], [18, 96], [18, 97], [19, 20], [19, 23], [19, 27], [19, 29], [19, 31], [19, 33], [19, 34], [19, 35], [19, 38], [19, 39], [19, 41], [19, 42], [19, 43], [19, 45], [19, 46], [19, 47], [19, 48], [19, 49], [19, 50], [19, 54], [19, 57], [19, 58], [19, 59], [19, 60], [19, 61], [19, 62], [19, 64], [19, 67], [19, 69], [19, 71], [19, 72], [19, 74], [19, 77], [19, 79], [19, 83], [19, 86], [19, 90], [19, 91], [19, 93], [19, 95], [19, 99], [20, 23], [20, 24], [20, 26], [20, 29], [20, 30], [20, 32], [20, 33], [20, 37], [20, 39], [20, 40], [20, 41], [20, 44], [20, 45], [20, 46], [20, 47], [20, 48], [20, 50], [20, 52], [20, 53], [20, 54], [20, 55], [20, 56], [20, 57], [20, 59], [20, 62], [20, 64], [20, 70], [20, 73], [20, 77], [20, 79], [20, 84], [20, 85], [20, 87], [20, 89], [20, 91], [20, 92], [20, 93], [20, 94], [20, 95], [20, 97], [20, 99], [21, 22], [21, 27], [21, 31], [21, 32], [21, 34], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [21, 47], [21, 52], [21, 55], [21, 61], [21, 62], [21, 64], [21, 68], [21, 69], [21, 72], [21, 73], [21, 75], [21, 79], [21, 83], [21, 87], [21, 88], [21, 89], [21, 90], [21, 93], [21, 94], [21, 96], [21, 97], [22, 24], [22, 25], [22, 26], [22, 28], [22, 29], [22, 30], [22, 31], [22, 33], [22, 34], [22, 36], [22, 37], [22, 40], [22, 42], [22, 43], [22, 44], [22, 45], [22, 46], [22, 48], [22, 49], [22, 51], [22, 52], [22, 53], [22, 54], [22, 56], [22, 58], [22, 59], [22, 60], [22, 61], [22, 62], [22, 64], [22, 65], [22, 67], [22, 68], [22, 70], [22, 71], [22, 72], [22, 73], [22, 78], [22, 79], [22, 80], [22, 82], [22, 83], [22, 85], [22, 86], [22, 87], [22, 88], [22, 93], [22, 95], [22, 99], [23, 24], [23, 26], [23, 27], [23, 30], [23, 31], [23, 32], [23, 33], [23, 35], [23, 36], [23, 37], [23, 38], [23, 41], [23, 43], [23, 47], [23, 49], [23, 51], [23, 52], [23, 54], [23, 55], [23, 57], [23, 61], [23, 63], [23, 64], [23, 67], [23, 70], [23, 71], [23, 74], [23, 77], [23, 79], [23, 80], [23, 81], [23, 82], [23, 83], [23, 86], [23, 88], [23, 90], [23, 91], [23, 92], [23, 93], [23, 94], [23, 96], [23, 97], [23, 98], [24, 26], [24, 27], [24, 29], [24, 32], [24, 34], [24, 35], [24, 36], [24, 37], [24, 40], [24, 43], [24, 48], [24, 49], [24, 51], [24, 55], [24, 59], [24, 63], [24, 64], [24, 65], [24, 67], [24, 68], [24, 71], [24, 74], [24, 75], [24, 77], [24, 78], [24, 80], [24, 81], [24, 83], [24, 84], [24, 86], [24, 87], [24, 89], [24, 90], [24, 92], [24, 93], [24, 94], [24, 99], [25, 28], [25, 31], [25, 32], [25, 33], [25, 34], [25, 37], [25, 42], [25, 43], [25, 48], [25, 52], [25, 53], [25, 54], [25, 56], [25, 57], [25, 59], [25, 60], [25, 61], [25, 62], [25, 63], [25, 66], [25, 68], [25, 69], [25, 70], [25, 73], [25, 76], [25, 78], [25, 83], [25, 84], [25, 85], [25, 89], [25, 93], [25, 94], [25, 99], [26, 28], [26, 30], [26, 34], [26, 35], [26, 37], [26, 39], [26, 41], [26, 43], [26, 46], [26, 47], [26, 49], [26, 50], [26, 53], [26, 54], [26, 55], [26, 56], [26, 57], [26, 60], [26, 65], [26, 67], [26, 68], [26, 72], [26, 75], [26, 79], [26, 80], [26, 83], [26, 84], [26, 86], [26, 87], [26, 88], [26, 89], [26, 91], [26, 93], [26, 95], [26, 98], [26, 99], [27, 29], [27, 32], [27, 34], [27, 35], [27, 36], [27, 38], [27, 40], [27, 42], [27, 44], [27, 45], [27, 47], [27, 48], [27, 50], [27, 51], [27, 52], [27, 55], [27, 56], [27, 57], [27, 59], [27, 60], [27, 61], [27, 64], [27, 65], [27, 66], [27, 70], [27, 71], [27, 72], [27, 73], [27, 78], [27, 79], [27, 80], [27, 82], [27, 86], [27, 89], [27, 91], [27, 92], [27, 94], [27, 97], [27, 98], [27, 99], [28, 29], [28, 30], [28, 31], [28, 34], [28, 35], [28, 37], [28, 38], [28, 39], [28, 41], [28, 43], [28, 47], [28, 48], [28, 49], [28, 53], [28, 55], [28, 57], [28, 58], [28, 61], [28, 63], [28, 65], [28, 69], [28, 75], [28, 76], [28, 81], [28, 86], [28, 89], [28, 92], [28, 94], [28, 95], [28, 96], [28, 98], [29, 30], [29, 36], [29, 40], [29, 43], [29, 44], [29, 48], [29, 51], [29, 54], [29, 60], [29, 63], [29, 64], [29, 66], [29, 67], [29, 68], [29, 69], [29, 70], [29, 71], [29, 74], [29, 76], [29, 78], [29, 80], [29, 83], [29, 91], [29, 93], [29, 97], [30, 32], [30, 33], [30, 35], [30, 36], [30, 39], [30, 41], [30, 42], [30, 45], [30, 46], [30, 47], [30, 49], [30, 51], [30, 56], [30, 59], [30, 60], [30, 61], [30, 62], [30, 64], [30, 65], [30, 66], [30, 67], [30, 75], [30, 76], [30, 77], [30, 79], [30, 81], [30, 82], [30, 85], [30, 86], [30, 87], [30, 88], [30, 90], [30, 91], [30, 92], [30, 95], [30, 96], [30, 97], [30, 98], [31, 35], [31, 36], [31, 40], [31, 41], [31, 42], [31, 44], [31, 45], [31, 46], [31, 48], [31, 49], [31, 52], [31, 53], [31, 54], [31, 55], [31, 58], [31, 63], [31, 66], [31, 67], [31, 68], [31, 70], [31, 72], [31, 74], [31, 75], [31, 76], [31, 77], [31, 81], [31, 83], [31, 87], [31, 89], [31, 90], [31, 92], [31, 94], [31, 95], [31, 96], [31, 98], [31, 99], [32, 35], [32, 37], [32, 40], [32, 41], [32, 42], [32, 43], [32, 44], [32, 45], [32, 49], [32, 50], [32, 52], [32, 53], [32, 54], [32, 55], [32, 61], [32, 63], [32, 64], [32, 66], [32, 67], [32, 71], [32, 73], [32, 74], [32, 75], [32, 77], [32, 79], [32, 80], [32, 81], [32, 82], [32, 83], [32, 86], [32, 88], [32, 89], [32, 90], [32, 93], [32, 94], [32, 95], [32, 97], [33, 35], [33, 37], [33, 38], [33, 40], [33, 41], [33, 42], [33, 43], [33, 45], [33, 46], [33, 47], [33, 48], [33, 49], [33, 53], [33, 56], [33, 57], [33, 58], [33, 60], [33, 61], [33, 64], [33, 67], [33, 68], [33, 69], [33, 71], [33, 73], [33, 74], [33, 75], [33, 76], [33, 79], [33, 84], [33, 86], [33, 88], [33, 90], [33, 91], [33, 93], [33, 94], [33, 98], [34, 35], [34, 38], [34, 40], [34, 42], [34, 43], [34, 46], [34, 50], [34, 53], [34, 55], [34, 58], [34, 63], [34, 66], [34, 67], [34, 69], [34, 72], [34, 73], [34, 76], [34, 77], [34, 78], [34, 83], [34, 84], [34, 85], [34, 86], [34, 87], [34, 88], [34, 89], [34, 90], [34, 92], [34, 93], [34, 94], [34, 95], [34, 96], [34, 97], [35, 36], [35, 37], [35, 38], [35, 40], [35, 41], [35, 42], [35, 43], [35, 44], [35, 46], [35, 47], [35, 48], [35, 49], [35, 53], [35, 54], [35, 55], [35, 57], [35, 61], [35, 62], [35, 63], [35, 64], [35, 66], [35, 67], [35, 69], [35, 70], [35, 71], [35, 72], [35, 74], [35, 75], [35, 76], [35, 77], [35, 79], [35, 81], [35, 82], [35, 83], [35, 86], [35, 87], [35, 88], [35, 89], [35, 90], [35, 91], [35, 93], [35, 94], [35, 95], [35, 97], [35, 98], [35, 99], [36, 37], [36, 38], [36, 42], [36, 44], [36, 46], [36, 47], [36, 48], [36, 50], [36, 51], [36, 53], [36, 54], [36, 60], [36, 62], [36, 64], [36, 66], [36, 67], [36, 68], [36, 70], [36, 71], [36, 72], [36, 73], [36, 75], [36, 76], [36, 77], [36, 78], [36, 81], [36, 85], [36, 86], [36, 87], [36, 88], [36, 89], [36, 90], [36, 91], [36, 93], [36, 94], [36, 95], [36, 96], [36, 97], [37, 38], [37, 39], [37, 41], [37, 42], [37, 43], [37, 44], [37, 46], [37, 47], [37, 48], [37, 49], [37, 54], [37, 57], [37, 58], [37, 60], [37, 63], [37, 64], [37, 65], [37, 67], [37, 68], [37, 70], [37, 71], [37, 72], [37, 74], [37, 75], [37, 76], [37, 77], [37, 79], [37, 81], [37, 83], [37, 90], [37, 93], [37, 94], [38, 40], [38, 41], [38, 43], [38, 44], [38, 48], [38, 49], [38, 53], [38, 54], [38, 55], [38, 58], [38, 60], [38, 62], [38, 65], [38, 67], [38, 68], [38, 70], [38, 75], [38, 77], [38, 78], [38, 79], [38, 81], [38, 82], [38, 85], [38, 86], [38, 87], [38, 91], [38, 92], [38, 94], [38, 95], [38, 97], [38, 98], [38, 99], [39, 41], [39, 42], [39, 43], [39, 44], [39, 46], [39, 47], [39, 48], [39, 49], [39, 50], [39, 52], [39, 57], [39, 64], [39, 69], [39, 71], [39, 72], [39, 73], [39, 75], [39, 76], [39, 78], [39, 79], [39, 82], [39, 83], [39, 84], [39, 85], [39, 87], [39, 89], [39, 93], [39, 94], [39, 99], [40, 41], [40, 43], [40, 44], [40, 45], [40, 46], [40, 57], [40, 61], [40, 62], [40, 63], [40, 64], [40, 67], [40, 68], [40, 70], [40, 72], [40, 73], [40, 76], [40, 77], [40, 78], [40, 80], [40, 81], [40, 85], [40, 89], [40, 90], [40, 91], [40, 92], [40, 95], [40, 97], [41, 43], [41, 45], [41, 47], [41, 48], [41, 50], [41, 54], [41, 57], [41, 60], [41, 61], [41, 62], [41, 63], [41, 66], [41, 67], [41, 68], [41, 70], [41, 71], [41, 72], [41, 77], [41, 78], [41, 80], [41, 81], [41, 85], [41, 87], [41, 93], [41, 94], [41, 96], [41, 97], [41, 99], [42, 43], [42, 44], [42, 45], [42, 49], [42, 50], [42, 51], [42, 52], [42, 55], [42, 56], [42, 58], [42, 63], [42, 65], [42, 68], [42, 70], [42, 71], [42, 74], [42, 76], [42, 77], [42, 83], [42, 85], [42, 86], [42, 91], [42, 93], [42, 94], [42, 95], [42, 98], [42, 99], [43, 44], [43, 47], [43, 49], [43, 50], [43, 51], [43, 52], [43, 57], [43, 58], [43, 60], [43, 62], [43, 63], [43, 64], [43, 67], [43, 68], [43, 69], [43, 71], [43, 73], [43, 74], [43, 75], [43, 77], [43, 79], [43, 81], [43, 83], [43, 85], [43, 86], [43, 88], [43, 89], [43, 90], [43, 91], [43, 93], [43, 94], [43, 95], [44, 47], [44, 49], [44, 53], [44, 55], [44, 56], [44, 59], [44, 62], [44, 64], [44, 65], [44, 66], [44, 67], [44, 68], [44, 71], [44, 72], [44, 74], [44, 75], [44, 77], [44, 81], [44, 82], [44, 84], [44, 85], [44, 86], [44, 87], [44, 88], [44, 93], [44, 95], [45, 46], [45, 49], [45, 51], [45, 54], [45, 59], [45, 60], [45, 62], [45, 68], [45, 69], [45, 71], [45, 72], [45, 73], [45, 74], [45, 75], [45, 77], [45, 78], [45, 79], [45, 81], [45, 82], [45, 84], [45, 89], [45, 91], [45, 92], [45, 95], [45, 96], [45, 97], [45, 98], [45, 99], [46, 47], [46, 49], [46, 50], [46, 52], [46, 53], [46, 54], [46, 55], [46, 59], [46, 64], [46, 67], [46, 68], [46, 71], [46, 72], [46, 74], [46, 76], [46, 77], [46, 81], [46, 82], [46, 86], [46, 87], [46, 88], [46, 89], [46, 91], [46, 92], [46, 96], [47, 49], [47, 50], [47, 53], [47, 56], [47, 57], [47, 61], [47, 62], [47, 67], [47, 68], [47, 71], [47, 72], [47, 74], [47, 76], [47, 78], [47, 80], [47, 81], [47, 83], [47, 84], [47, 85], [47, 87], [47, 88], [47, 90], [47, 92], [47, 93], [47, 94], [47, 95], [48, 49], [48, 50], [48, 51], [48, 53], [48, 54], [48, 55], [48, 56], [48, 57], [48, 58], [48, 61], [48, 64], [48, 65], [48, 67], [48, 68], [48, 69], [48, 71], [48, 73], [48, 75], [48, 77], [48, 80], [48, 82], [48, 83], [48, 84], [48, 85], [48, 87], [48, 88], [48, 90], [48, 91], [48, 92], [48, 97], [48, 98], [48, 99], [49, 50], [49, 51], [49, 55], [49, 56], [49, 57], [49, 60], [49, 63], [49, 64], [49, 67], [49, 68], [49, 69], [49, 71], [49, 72], [49, 74], [49, 75], [49, 77], [49, 78], [49, 81], [49, 83], [49, 84], [49, 85], [49, 86], [49, 88], [49, 90], [49, 93], [49, 94], [49, 96], [49, 99], [50, 52], [50, 60], [50, 62], [50, 63], [50, 64], [50, 65], [50, 68], [50, 69], [50, 70], [50, 77], [50, 78], [50, 79], [50, 80], [50, 81], [50, 85], [50, 86], [50, 87], [50, 91], [50, 92], [50, 93], [50, 94], [50, 98], [51, 54], [51, 55], [51, 56], [51, 61], [51, 63], [51, 65], [51, 68], [51, 71], [51, 73], [51, 77], [51, 78], [51, 79], [51, 80], [51, 83], [51, 85], [51, 87], [51, 88], [51, 89], [51, 90], [51, 93], [51, 97], [51, 98], [51, 99], [52, 56], [52, 62], [52, 65], [52, 69], [52, 71], [52, 72], [52, 74], [52, 76], [52, 77], [52, 78], [52, 81], [52, 91], [52, 93], [52, 94], [52, 96], [52, 98], [53, 54], [53, 56], [53, 59], [53, 61], [53, 62], [53, 63], [53, 64], [53, 68], [53, 70], [53, 72], [53, 73], [53, 74], [53, 76], [53, 77], [53, 80], [53, 81], [53, 85], [53, 88], [53, 93], [53, 95], [53, 96], [53, 98], [54, 55], [54, 56], [54, 57], [54, 59], [54, 61], [54, 66], [54, 67], [54, 70], [54, 71], [54, 72], [54, 76], [54, 77], [54, 78], [54, 79], [54, 80], [54, 81], [54, 83], [54, 88], [54, 94], [54, 95], [54, 98], [54, 99], [55, 56], [55, 58], [55, 59], [55, 60], [55, 62], [55, 63], [55, 64], [55, 66], [55, 68], [55, 69], [55, 71], [55, 76], [55, 81], [55, 82], [55, 87], [55, 89], [55, 90], [55, 92], [55, 93], [55, 97], [55, 98], [55, 99], [56, 58], [56, 59], [56, 60], [56, 61], [56, 63], [56, 64], [56, 66], [56, 67], [56, 69], [56, 70], [56, 75], [56, 76], [56, 81], [56, 83], [56, 84], [56, 86], [56, 88], [56, 91], [56, 92], [56, 94], [56, 96], [56, 99], [57, 58], [57, 59], [57, 62], [57, 64], [57, 68], [57, 69], [57, 73], [57, 77], [57, 78], [57, 79], [57, 80], [57, 82], [57, 85], [57, 87], [57, 88], [57, 89], [57, 90], [57, 91], [57, 92], [57, 98], [57, 99], [58, 59], [58, 62], [58, 65], [58, 66], [58, 67], [58, 69], [58, 70], [58, 71], [58, 73], [58, 74], [58, 75], [58, 76], [58, 79], [58, 81], [58, 83], [58, 85], [58, 88], [58, 90], [58, 92], [58, 94], [58, 96], [58, 98], [58, 99], [59, 60], [59, 62], [59, 63], [59, 64], [59, 65], [59, 66], [59, 68], [59, 69], [59, 70], [59, 71], [59, 72], [59, 75], [59, 76], [59, 77], [59, 78], [59, 80], [59, 82], [59, 84], [59, 85], [59, 87], [59, 90], [59, 93], [59, 94], [59, 97], [60, 61], [60, 63], [60, 65], [60, 66], [60, 68], [60, 69], [60, 78], [60, 79], [60, 80], [60, 81], [60, 82], [60, 83], [60, 84], [60, 85], [60, 86], [60, 88], [60, 90], [60, 91], [60, 92], [60, 93], [60, 94], [60, 97], [60, 98], [61, 62], [61, 64], [61, 68], [61, 70], [61, 71], [61, 74], [61, 77], [61, 78], [61, 80], [61, 82], [61, 86], [61, 87], [61, 88], [61, 92], [61, 95], [61, 97], [61, 99], [62, 65], [62, 66], [62, 70], [62, 73], [62, 74], [62, 75], [62, 77], [62, 81], [62, 82], [62, 84], [62, 85], [62, 90], [62, 91], [62, 92], [62, 93], [62, 94], [62, 96], [62, 97], [62, 98], [62, 99], [63, 64], [63, 66], [63, 67], [63, 68], [63, 69], [63, 71], [63, 72], [63, 74], [63, 75], [63, 77], [63, 80], [63, 81], [63, 83], [63, 88], [63, 91], [63, 93], [63, 94], [63, 95], [63, 96], [63, 97], [64, 65], [64, 66], [64, 67], [64, 68], [64, 69], [64, 71], [64, 72], [64, 73], [64, 74], [64, 76], [64, 77], [64, 81], [64, 83], [64, 85], [64, 87], [64, 88], [64, 89], [64, 91], [64, 93], [64, 94], [64, 95], [64, 96], [64, 97], [64, 98], [65, 67], [65, 68], [65, 69], [65, 70], [65, 71], [65, 73], [65, 77], [65, 78], [65, 79], [65, 80], [65, 83], [65, 86], [65, 87], [65, 89], [65, 90], [65, 91], [65, 93], [65, 94], [65, 97], [65, 99], [66, 67], [66, 69], [66, 70], [66, 71], [66, 72], [66, 73], [66, 75], [66, 78], [66, 79], [66, 85], [66, 89], [66, 90], [66, 93], [66, 94], [66, 96], [66, 97], [66, 98], [67, 68], [67, 71], [67, 72], [67, 74], [67, 75], [67, 76], [67, 77], [67, 81], [67, 82], [67, 83], [67, 85], [67, 86], [67, 90], [67, 93], [67, 94], [67, 96], [67, 97], [67, 99], [68, 69], [68, 70], [68, 71], [68, 72], [68, 74], [68, 80], [68, 82], [68, 93], [68, 95], [68, 96], [68, 98], [69, 70], [69, 73], [69, 78], [69, 79], [69, 81], [69, 82], [69, 83], [69, 84], [69, 85], [69, 87], [69, 88], [69, 90], [69, 92], [69, 94], [69, 96], [70, 71], [70, 72], [70, 73], [70, 75], [70, 77], [70, 78], [70, 79], [70, 80], [70, 82], [70, 83], [70, 84], [70, 87], [70, 89], [70, 90], [70, 92], [70, 93], [70, 99], [71, 74], [71, 77], [71, 78], [71, 79], [71, 80], [71, 81], [71, 83], [71, 84], [71, 85], [71, 86], [71, 87], [71, 91], [71, 92], [71, 93], [71, 94], [71, 97], [71, 99], [72, 73], [72, 75], [72, 77], [72, 79], [72, 80], [72, 82], [72, 85], [72, 90], [72, 91], [72, 93], [72, 94], [72, 96], [72, 97], [72, 98], [73, 77], [73, 78], [73, 80], [73, 81], [73, 82], [73, 86], [73, 88], [73, 91], [73, 92], [73, 95], [73, 96], [73, 98], [73, 99], [74, 75], [74, 77], [74, 80], [74, 81], [74, 82], [74, 83], [74, 85], [74, 87], [74, 88], [74, 91], [74, 93], [74, 94], [74, 95], [74, 96], [74, 98], [74, 99], [75, 78], [75, 79], [75, 83], [75, 85], [75, 90], [75, 93], [75, 95], [75, 96], [75, 98], [75, 99], [76, 77], [76, 78], [76, 80], [76, 81], [76, 85], [76, 87], [76, 88], [76, 92], [76, 93], [76, 97], [77, 78], [77, 79], [77, 80], [77, 81], [77, 83], [77, 84], [77, 85], [77, 88], [77, 90], [77, 91], [77, 92], [77, 93], [77, 94], [77, 96], [77, 98], [78, 81], [78, 83], [78, 87], [78, 91], [78, 92], [78, 93], [78, 94], [78, 96], [79, 81], [79, 88], [79, 90], [79, 93], [79, 94], [79, 95], [79, 97], [79, 98], [79, 99], [80, 81], [80, 82], [80, 85], [80, 86], [80, 87], [80, 88], [80, 90], [80, 93], [80, 95], [80, 96], [80, 97], [80, 99], [81, 83], [81, 85], [81, 88], [81, 89], [81, 91], [81, 93], [81, 94], [81, 96], [82, 84], [82, 85], [82, 86], [82, 87], [82, 88], [82, 89], [82, 91], [82, 96], [82, 97], [82, 98], [82, 99], [83, 84], [83, 85], [83, 87], [83, 90], [83, 93], [83, 94], [83, 98], [84, 85], [84, 87], [84, 88], [84, 89], [84, 91], [84, 92], [84, 94], [84, 95], [84, 97], [84, 98], [84, 99], [85, 88], [85, 90], [85, 91], [85, 93], [85, 95], [85, 97], [85, 98], [86, 88], [86, 89], [86, 90], [86, 92], [86, 93], [86, 95], [86, 96], [86, 98], [86, 99], [87, 88], [87, 90], [87, 93], [87, 96], [87, 97], [87, 98], [88, 94], [88, 96], [89, 91], [89, 92], [89, 93], [89, 94], [89, 95], [89, 99], [90, 92], [90, 93], [90, 94], [90, 95], [90, 98], [90, 99], [91, 93], [91, 96], [91, 98], [91, 99], [92, 93], [92, 94], [92, 95], [92, 96], [92, 97], [92, 99], [93, 94], [93, 98], [95, 96], [96, 97], [96, 99], [97, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s9/solution/solve.sh b/tasks/construct-nppc-clique-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9d52758dec83fcf645a23be33a34d9ae614bece7 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 9, 14, 23, 24, 32, 35, 37, 43, 49, 63, 64, 67, 71, 74, 77, 81, 83, 93, 94]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l6-s9/tests/check.py b/tasks/construct-nppc-clique-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s9/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l6-s9/tests/instance.json b/tasks/construct-nppc-clique-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8069f89dbbce43165d48b3dc0856d76c91abfa3f --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 3], [0, 7], [0, 12], [0, 15], [0, 16], [0, 18], [0, 19], [0, 22], [0, 27], [0, 29], [0, 30], [0, 31], [0, 33], [0, 34], [0, 36], [0, 37], [0, 39], [0, 43], [0, 47], [0, 48], [0, 50], [0, 51], [0, 54], [0, 55], [0, 56], [0, 58], [0, 65], [0, 66], [0, 68], [0, 69], [0, 71], [0, 73], [0, 74], [0, 75], [0, 77], [0, 79], [0, 80], [0, 81], [0, 84], [0, 85], [0, 89], [0, 90], [0, 93], [0, 94], [0, 96], [0, 99], [1, 2], [1, 5], [1, 6], [1, 8], [1, 9], [1, 10], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 37], [1, 39], [1, 41], [1, 43], [1, 48], [1, 49], [1, 51], [1, 52], [1, 56], [1, 58], [1, 60], [1, 63], [1, 64], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 72], [1, 74], [1, 75], [1, 77], [1, 78], [1, 79], [1, 81], [1, 82], [1, 83], [1, 85], [1, 86], [1, 87], [1, 91], [1, 92], [1, 93], [1, 94], [1, 96], [1, 98], [2, 3], [2, 5], [2, 7], [2, 8], [2, 10], [2, 13], [2, 16], [2, 18], [2, 19], [2, 21], [2, 22], [2, 27], [2, 28], [2, 29], [2, 30], [2, 32], [2, 33], [2, 35], [2, 36], [2, 38], [2, 39], [2, 40], [2, 43], [2, 47], [2, 48], [2, 49], [2, 50], [2, 52], [2, 54], [2, 55], [2, 56], [2, 59], [2, 60], [2, 61], [2, 62], [2, 63], [2, 68], [2, 71], [2, 86], [2, 87], [2, 88], [2, 89], [2, 92], [2, 93], [2, 95], [2, 97], [3, 4], [3, 7], [3, 13], [3, 16], [3, 18], [3, 20], [3, 21], [3, 22], [3, 26], [3, 29], [3, 30], [3, 31], [3, 32], [3, 35], [3, 36], [3, 37], [3, 39], [3, 40], [3, 41], [3, 43], [3, 45], [3, 47], [3, 49], [3, 50], [3, 52], [3, 54], [3, 55], [3, 58], [3, 61], [3, 63], [3, 66], [3, 67], [3, 69], [3, 70], [3, 72], [3, 74], [3, 77], [3, 79], [3, 82], [3, 83], [3, 84], [3, 89], [3, 90], [3, 91], [3, 92], [3, 93], [3, 94], [3, 98], [4, 5], [4, 11], [4, 12], [4, 13], [4, 14], [4, 16], [4, 17], [4, 24], [4, 25], [4, 26], [4, 28], [4, 30], [4, 31], [4, 32], [4, 33], [4, 36], [4, 37], [4, 40], [4, 42], [4, 43], [4, 44], [4, 46], [4, 48], [4, 49], [4, 50], [4, 53], [4, 55], [4, 56], [4, 57], [4, 61], [4, 62], [4, 63], [4, 64], [4, 65], [4, 67], [4, 71], [4, 74], [4, 75], [4, 76], [4, 79], [4, 81], [4, 83], [4, 84], [4, 85], [4, 92], [4, 94], [4, 99], [5, 6], [5, 8], [5, 9], [5, 10], [5, 11], [5, 14], [5, 15], [5, 16], [5, 17], [5, 22], [5, 25], [5, 26], [5, 29], [5, 33], [5, 34], [5, 36], [5, 37], [5, 39], [5, 40], [5, 47], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [5, 56], [5, 57], [5, 58], [5, 60], [5, 61], [5, 62], [5, 65], [5, 66], [5, 69], [5, 70], [5, 71], [5, 72], [5, 74], [5, 75], [5, 76], [5, 77], [5, 79], [5, 87], [5, 89], [5, 91], [5, 93], [5, 95], [5, 98], [6, 7], [6, 8], [6, 10], [6, 11], [6, 13], [6, 14], [6, 21], [6, 24], [6, 26], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 39], [6, 43], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 55], [6, 59], [6, 61], [6, 62], [6, 63], [6, 66], [6, 67], [6, 69], [6, 70], [6, 72], [6, 73], [6, 77], [6, 78], [6, 80], [6, 82], [6, 83], [6, 86], [6, 88], [6, 89], [6, 90], [6, 91], [6, 94], [6, 95], [6, 96], [6, 97], [6, 98], [7, 8], [7, 9], [7, 10], [7, 13], [7, 14], [7, 15], [7, 17], [7, 19], [7, 22], [7, 24], [7, 25], [7, 26], [7, 28], [7, 29], [7, 30], [7, 32], [7, 35], [7, 37], [7, 39], [7, 42], [7, 44], [7, 46], [7, 47], [7, 48], [7, 50], [7, 51], [7, 52], [7, 56], [7, 57], [7, 59], [7, 62], [7, 63], [7, 64], [7, 67], [7, 70], [7, 72], [7, 73], [7, 74], [7, 77], [7, 78], [7, 81], [7, 84], [7, 89], [7, 94], [7, 95], [7, 97], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 20], [8, 23], [8, 26], [8, 28], [8, 31], [8, 32], [8, 33], [8, 34], [8, 36], [8, 39], [8, 44], [8, 45], [8, 46], [8, 47], [8, 48], [8, 50], [8, 52], [8, 54], [8, 56], [8, 57], [8, 61], [8, 65], [8, 70], [8, 74], [8, 76], [8, 77], [8, 78], [8, 79], [8, 80], [8, 88], [8, 91], [8, 92], [8, 93], [8, 94], [8, 95], [8, 97], [9, 10], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 22], [9, 23], [9, 24], [9, 25], [9, 29], [9, 32], [9, 35], [9, 36], [9, 37], [9, 38], [9, 40], [9, 43], [9, 45], [9, 47], [9, 48], [9, 49], [9, 51], [9, 52], [9, 56], [9, 58], [9, 59], [9, 60], [9, 62], [9, 63], [9, 64], [9, 65], [9, 67], [9, 68], [9, 69], [9, 71], [9, 73], [9, 74], [9, 76], [9, 77], [9, 78], [9, 79], [9, 81], [9, 82], [9, 83], [9, 86], [9, 87], [9, 88], [9, 89], [9, 90], [9, 92], [9, 93], [9, 94], [9, 95], [9, 97], [10, 11], [10, 13], [10, 14], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 22], [10, 29], [10, 31], [10, 32], [10, 34], [10, 35], [10, 37], [10, 38], [10, 43], [10, 46], [10, 47], [10, 48], [10, 52], [10, 53], [10, 55], [10, 56], [10, 71], [10, 72], [10, 76], [10, 77], [10, 78], [10, 80], [10, 84], [10, 92], [10, 93], [10, 94], [10, 98], [11, 12], [11, 15], [11, 18], [11, 21], [11, 24], [11, 25], [11, 27], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [11, 37], [11, 38], [11, 42], [11, 43], [11, 44], [11, 47], [11, 48], [11, 50], [11, 51], [11, 52], [11, 53], [11, 59], [11, 60], [11, 63], [11, 64], [11, 66], [11, 67], [11, 69], [11, 71], [11, 72], [11, 73], [11, 76], [11, 78], [11, 80], [11, 81], [11, 82], [11, 84], [11, 96], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 22], [12, 31], [12, 33], [12, 34], [12, 35], [12, 37], [12, 39], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 50], [12, 55], [12, 56], [12, 59], [12, 62], [12, 66], [12, 68], [12, 69], [12, 71], [12, 72], [12, 74], [12, 78], [12, 79], [12, 80], [12, 81], [12, 85], [12, 86], [12, 87], [12, 89], [12, 90], [12, 92], [12, 96], [12, 97], [12, 98], [13, 14], [13, 17], [13, 18], [13, 24], [13, 25], [13, 27], [13, 28], [13, 32], [13, 33], [13, 36], [13, 37], [13, 39], [13, 41], [13, 42], [13, 43], [13, 46], [13, 47], [13, 51], [13, 54], [13, 56], [13, 57], [13, 60], [13, 61], [13, 64], [13, 67], [13, 68], [13, 69], [13, 73], [13, 74], [13, 76], [13, 79], [13, 82], [13, 83], [13, 85], [13, 86], [13, 88], [13, 90], [13, 91], [13, 92], [13, 93], [13, 96], [13, 98], [14, 16], [14, 19], [14, 21], [14, 23], [14, 24], [14, 27], [14, 28], [14, 30], [14, 31], [14, 32], [14, 34], [14, 35], [14, 37], [14, 40], [14, 43], [14, 44], [14, 45], [14, 46], [14, 47], [14, 49], [14, 50], [14, 51], [14, 53], [14, 54], [14, 56], [14, 57], [14, 60], [14, 61], [14, 63], [14, 64], [14, 67], [14, 68], [14, 70], [14, 71], [14, 72], [14, 73], [14, 74], [14, 77], [14, 78], [14, 80], [14, 81], [14, 83], [14, 85], [14, 87], [14, 92], [14, 93], [14, 94], [14, 96], [14, 97], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 25], [15, 29], [15, 34], [15, 36], [15, 38], [15, 40], [15, 46], [15, 47], [15, 48], [15, 52], [15, 53], [15, 54], [15, 58], [15, 60], [15, 63], [15, 64], [15, 67], [15, 69], [15, 72], [15, 73], [15, 76], [15, 79], [15, 80], [15, 82], [15, 84], [15, 89], [15, 94], [15, 95], [15, 96], [15, 97], [15, 98], [16, 18], [16, 22], [16, 24], [16, 26], [16, 27], [16, 28], [16, 31], [16, 32], [16, 34], [16, 39], [16, 44], [16, 45], [16, 46], [16, 48], [16, 50], [16, 55], [16, 56], [16, 58], [16, 59], [16, 62], [16, 63], [16, 64], [16, 65], [16, 66], [16, 68], [16, 70], [16, 72], [16, 78], [16, 79], [16, 80], [16, 81], [16, 83], [16, 84], [16, 85], [16, 86], [16, 89], [16, 90], [16, 91], [16, 92], [16, 94], [16, 96], [16, 97], [16, 99], [17, 19], [17, 21], [17, 24], [17, 25], [17, 29], [17, 30], [17, 31], [17, 33], [17, 36], [17, 37], [17, 39], [17, 41], [17, 46], [17, 47], [17, 48], [17, 49], [17, 50], [17, 51], [17, 54], [17, 57], [17, 58], [17, 63], [17, 65], [17, 70], [17, 76], [17, 77], [17, 81], [17, 83], [17, 84], [17, 85], [17, 86], [17, 90], [17, 91], [17, 93], [17, 95], [17, 97], [17, 98], [17, 99], [18, 19], [18, 20], [18, 22], [18, 23], [18, 25], [18, 27], [18, 29], [18, 32], [18, 33], [18, 35], [18, 36], [18, 37], [18, 38], [18, 40], [18, 41], [18, 42], [18, 43], [18, 45], [18, 46], [18, 47], [18, 52], [18, 57], [18, 58], [18, 60], [18, 61], [18, 62], [18, 64], [18, 70], [18, 72], [18, 74], [18, 76], [18, 77], [18, 79], [18, 80], [18, 83], [18, 84], [18, 85], [18, 87], [18, 90], [18, 91], [18, 94], [18, 95], [18, 96], [18, 97], [19, 20], [19, 23], [19, 27], [19, 29], [19, 31], [19, 33], [19, 34], [19, 35], [19, 38], [19, 39], [19, 41], [19, 42], [19, 43], [19, 45], [19, 46], [19, 47], [19, 48], [19, 49], [19, 50], [19, 54], [19, 57], [19, 58], [19, 59], [19, 60], [19, 61], [19, 62], [19, 64], [19, 67], [19, 69], [19, 71], [19, 72], [19, 74], [19, 77], [19, 79], [19, 83], [19, 86], [19, 90], [19, 91], [19, 93], [19, 95], [19, 99], [20, 23], [20, 24], [20, 26], [20, 29], [20, 30], [20, 32], [20, 33], [20, 37], [20, 39], [20, 40], [20, 41], [20, 44], [20, 45], [20, 46], [20, 47], [20, 48], [20, 50], [20, 52], [20, 53], [20, 54], [20, 55], [20, 56], [20, 57], [20, 59], [20, 62], [20, 64], [20, 70], [20, 73], [20, 77], [20, 79], [20, 84], [20, 85], [20, 87], [20, 89], [20, 91], [20, 92], [20, 93], [20, 94], [20, 95], [20, 97], [20, 99], [21, 22], [21, 27], [21, 31], [21, 32], [21, 34], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [21, 47], [21, 52], [21, 55], [21, 61], [21, 62], [21, 64], [21, 68], [21, 69], [21, 72], [21, 73], [21, 75], [21, 79], [21, 83], [21, 87], [21, 88], [21, 89], [21, 90], [21, 93], [21, 94], [21, 96], [21, 97], [22, 24], [22, 25], [22, 26], [22, 28], [22, 29], [22, 30], [22, 31], [22, 33], [22, 34], [22, 36], [22, 37], [22, 40], [22, 42], [22, 43], [22, 44], [22, 45], [22, 46], [22, 48], [22, 49], [22, 51], [22, 52], [22, 53], [22, 54], [22, 56], [22, 58], [22, 59], [22, 60], [22, 61], [22, 62], [22, 64], [22, 65], [22, 67], [22, 68], [22, 70], [22, 71], [22, 72], [22, 73], [22, 78], [22, 79], [22, 80], [22, 82], [22, 83], [22, 85], [22, 86], [22, 87], [22, 88], [22, 93], [22, 95], [22, 99], [23, 24], [23, 26], [23, 27], [23, 30], [23, 31], [23, 32], [23, 33], [23, 35], [23, 36], [23, 37], [23, 38], [23, 41], [23, 43], [23, 47], [23, 49], [23, 51], [23, 52], [23, 54], [23, 55], [23, 57], [23, 61], [23, 63], [23, 64], [23, 67], [23, 70], [23, 71], [23, 74], [23, 77], [23, 79], [23, 80], [23, 81], [23, 82], [23, 83], [23, 86], [23, 88], [23, 90], [23, 91], [23, 92], [23, 93], [23, 94], [23, 96], [23, 97], [23, 98], [24, 26], [24, 27], [24, 29], [24, 32], [24, 34], [24, 35], [24, 36], [24, 37], [24, 40], [24, 43], [24, 48], [24, 49], [24, 51], [24, 55], [24, 59], [24, 63], [24, 64], [24, 65], [24, 67], [24, 68], [24, 71], [24, 74], [24, 75], [24, 77], [24, 78], [24, 80], [24, 81], [24, 83], [24, 84], [24, 86], [24, 87], [24, 89], [24, 90], [24, 92], [24, 93], [24, 94], [24, 99], [25, 28], [25, 31], [25, 32], [25, 33], [25, 34], [25, 37], [25, 42], [25, 43], [25, 48], [25, 52], [25, 53], [25, 54], [25, 56], [25, 57], [25, 59], [25, 60], [25, 61], [25, 62], [25, 63], [25, 66], [25, 68], [25, 69], [25, 70], [25, 73], [25, 76], [25, 78], [25, 83], [25, 84], [25, 85], [25, 89], [25, 93], [25, 94], [25, 99], [26, 28], [26, 30], [26, 34], [26, 35], [26, 37], [26, 39], [26, 41], [26, 43], [26, 46], [26, 47], [26, 49], [26, 50], [26, 53], [26, 54], [26, 55], [26, 56], [26, 57], [26, 60], [26, 65], [26, 67], [26, 68], [26, 72], [26, 75], [26, 79], [26, 80], [26, 83], [26, 84], [26, 86], [26, 87], [26, 88], [26, 89], [26, 91], [26, 93], [26, 95], [26, 98], [26, 99], [27, 29], [27, 32], [27, 34], [27, 35], [27, 36], [27, 38], [27, 40], [27, 42], [27, 44], [27, 45], [27, 47], [27, 48], [27, 50], [27, 51], [27, 52], [27, 55], [27, 56], [27, 57], [27, 59], [27, 60], [27, 61], [27, 64], [27, 65], [27, 66], [27, 70], [27, 71], [27, 72], [27, 73], [27, 78], [27, 79], [27, 80], [27, 82], [27, 86], [27, 89], [27, 91], [27, 92], [27, 94], [27, 97], [27, 98], [27, 99], [28, 29], [28, 30], [28, 31], [28, 34], [28, 35], [28, 37], [28, 38], [28, 39], [28, 41], [28, 43], [28, 47], [28, 48], [28, 49], [28, 53], [28, 55], [28, 57], [28, 58], [28, 61], [28, 63], [28, 65], [28, 69], [28, 75], [28, 76], [28, 81], [28, 86], [28, 89], [28, 92], [28, 94], [28, 95], [28, 96], [28, 98], [29, 30], [29, 36], [29, 40], [29, 43], [29, 44], [29, 48], [29, 51], [29, 54], [29, 60], [29, 63], [29, 64], [29, 66], [29, 67], [29, 68], [29, 69], [29, 70], [29, 71], [29, 74], [29, 76], [29, 78], [29, 80], [29, 83], [29, 91], [29, 93], [29, 97], [30, 32], [30, 33], [30, 35], [30, 36], [30, 39], [30, 41], [30, 42], [30, 45], [30, 46], [30, 47], [30, 49], [30, 51], [30, 56], [30, 59], [30, 60], [30, 61], [30, 62], [30, 64], [30, 65], [30, 66], [30, 67], [30, 75], [30, 76], [30, 77], [30, 79], [30, 81], [30, 82], [30, 85], [30, 86], [30, 87], [30, 88], [30, 90], [30, 91], [30, 92], [30, 95], [30, 96], [30, 97], [30, 98], [31, 35], [31, 36], [31, 40], [31, 41], [31, 42], [31, 44], [31, 45], [31, 46], [31, 48], [31, 49], [31, 52], [31, 53], [31, 54], [31, 55], [31, 58], [31, 63], [31, 66], [31, 67], [31, 68], [31, 70], [31, 72], [31, 74], [31, 75], [31, 76], [31, 77], [31, 81], [31, 83], [31, 87], [31, 89], [31, 90], [31, 92], [31, 94], [31, 95], [31, 96], [31, 98], [31, 99], [32, 35], [32, 37], [32, 40], [32, 41], [32, 42], [32, 43], [32, 44], [32, 45], [32, 49], [32, 50], [32, 52], [32, 53], [32, 54], [32, 55], [32, 61], [32, 63], [32, 64], [32, 66], [32, 67], [32, 71], [32, 73], [32, 74], [32, 75], [32, 77], [32, 79], [32, 80], [32, 81], [32, 82], [32, 83], [32, 86], [32, 88], [32, 89], [32, 90], [32, 93], [32, 94], [32, 95], [32, 97], [33, 35], [33, 37], [33, 38], [33, 40], [33, 41], [33, 42], [33, 43], [33, 45], [33, 46], [33, 47], [33, 48], [33, 49], [33, 53], [33, 56], [33, 57], [33, 58], [33, 60], [33, 61], [33, 64], [33, 67], [33, 68], [33, 69], [33, 71], [33, 73], [33, 74], [33, 75], [33, 76], [33, 79], [33, 84], [33, 86], [33, 88], [33, 90], [33, 91], [33, 93], [33, 94], [33, 98], [34, 35], [34, 38], [34, 40], [34, 42], [34, 43], [34, 46], [34, 50], [34, 53], [34, 55], [34, 58], [34, 63], [34, 66], [34, 67], [34, 69], [34, 72], [34, 73], [34, 76], [34, 77], [34, 78], [34, 83], [34, 84], [34, 85], [34, 86], [34, 87], [34, 88], [34, 89], [34, 90], [34, 92], [34, 93], [34, 94], [34, 95], [34, 96], [34, 97], [35, 36], [35, 37], [35, 38], [35, 40], [35, 41], [35, 42], [35, 43], [35, 44], [35, 46], [35, 47], [35, 48], [35, 49], [35, 53], [35, 54], [35, 55], [35, 57], [35, 61], [35, 62], [35, 63], [35, 64], [35, 66], [35, 67], [35, 69], [35, 70], [35, 71], [35, 72], [35, 74], [35, 75], [35, 76], [35, 77], [35, 79], [35, 81], [35, 82], [35, 83], [35, 86], [35, 87], [35, 88], [35, 89], [35, 90], [35, 91], [35, 93], [35, 94], [35, 95], [35, 97], [35, 98], [35, 99], [36, 37], [36, 38], [36, 42], [36, 44], [36, 46], [36, 47], [36, 48], [36, 50], [36, 51], [36, 53], [36, 54], [36, 60], [36, 62], [36, 64], [36, 66], [36, 67], [36, 68], [36, 70], [36, 71], [36, 72], [36, 73], [36, 75], [36, 76], [36, 77], [36, 78], [36, 81], [36, 85], [36, 86], [36, 87], [36, 88], [36, 89], [36, 90], [36, 91], [36, 93], [36, 94], [36, 95], [36, 96], [36, 97], [37, 38], [37, 39], [37, 41], [37, 42], [37, 43], [37, 44], [37, 46], [37, 47], [37, 48], [37, 49], [37, 54], [37, 57], [37, 58], [37, 60], [37, 63], [37, 64], [37, 65], [37, 67], [37, 68], [37, 70], [37, 71], [37, 72], [37, 74], [37, 75], [37, 76], [37, 77], [37, 79], [37, 81], [37, 83], [37, 90], [37, 93], [37, 94], [38, 40], [38, 41], [38, 43], [38, 44], [38, 48], [38, 49], [38, 53], [38, 54], [38, 55], [38, 58], [38, 60], [38, 62], [38, 65], [38, 67], [38, 68], [38, 70], [38, 75], [38, 77], [38, 78], [38, 79], [38, 81], [38, 82], [38, 85], [38, 86], [38, 87], [38, 91], [38, 92], [38, 94], [38, 95], [38, 97], [38, 98], [38, 99], [39, 41], [39, 42], [39, 43], [39, 44], [39, 46], [39, 47], [39, 48], [39, 49], [39, 50], [39, 52], [39, 57], [39, 64], [39, 69], [39, 71], [39, 72], [39, 73], [39, 75], [39, 76], [39, 78], [39, 79], [39, 82], [39, 83], [39, 84], [39, 85], [39, 87], [39, 89], [39, 93], [39, 94], [39, 99], [40, 41], [40, 43], [40, 44], [40, 45], [40, 46], [40, 57], [40, 61], [40, 62], [40, 63], [40, 64], [40, 67], [40, 68], [40, 70], [40, 72], [40, 73], [40, 76], [40, 77], [40, 78], [40, 80], [40, 81], [40, 85], [40, 89], [40, 90], [40, 91], [40, 92], [40, 95], [40, 97], [41, 43], [41, 45], [41, 47], [41, 48], [41, 50], [41, 54], [41, 57], [41, 60], [41, 61], [41, 62], [41, 63], [41, 66], [41, 67], [41, 68], [41, 70], [41, 71], [41, 72], [41, 77], [41, 78], [41, 80], [41, 81], [41, 85], [41, 87], [41, 93], [41, 94], [41, 96], [41, 97], [41, 99], [42, 43], [42, 44], [42, 45], [42, 49], [42, 50], [42, 51], [42, 52], [42, 55], [42, 56], [42, 58], [42, 63], [42, 65], [42, 68], [42, 70], [42, 71], [42, 74], [42, 76], [42, 77], [42, 83], [42, 85], [42, 86], [42, 91], [42, 93], [42, 94], [42, 95], [42, 98], [42, 99], [43, 44], [43, 47], [43, 49], [43, 50], [43, 51], [43, 52], [43, 57], [43, 58], [43, 60], [43, 62], [43, 63], [43, 64], [43, 67], [43, 68], [43, 69], [43, 71], [43, 73], [43, 74], [43, 75], [43, 77], [43, 79], [43, 81], [43, 83], [43, 85], [43, 86], [43, 88], [43, 89], [43, 90], [43, 91], [43, 93], [43, 94], [43, 95], [44, 47], [44, 49], [44, 53], [44, 55], [44, 56], [44, 59], [44, 62], [44, 64], [44, 65], [44, 66], [44, 67], [44, 68], [44, 71], [44, 72], [44, 74], [44, 75], [44, 77], [44, 81], [44, 82], [44, 84], [44, 85], [44, 86], [44, 87], [44, 88], [44, 93], [44, 95], [45, 46], [45, 49], [45, 51], [45, 54], [45, 59], [45, 60], [45, 62], [45, 68], [45, 69], [45, 71], [45, 72], [45, 73], [45, 74], [45, 75], [45, 77], [45, 78], [45, 79], [45, 81], [45, 82], [45, 84], [45, 89], [45, 91], [45, 92], [45, 95], [45, 96], [45, 97], [45, 98], [45, 99], [46, 47], [46, 49], [46, 50], [46, 52], [46, 53], [46, 54], [46, 55], [46, 59], [46, 64], [46, 67], [46, 68], [46, 71], [46, 72], [46, 74], [46, 76], [46, 77], [46, 81], [46, 82], [46, 86], [46, 87], [46, 88], [46, 89], [46, 91], [46, 92], [46, 96], [47, 49], [47, 50], [47, 53], [47, 56], [47, 57], [47, 61], [47, 62], [47, 67], [47, 68], [47, 71], [47, 72], [47, 74], [47, 76], [47, 78], [47, 80], [47, 81], [47, 83], [47, 84], [47, 85], [47, 87], [47, 88], [47, 90], [47, 92], [47, 93], [47, 94], [47, 95], [48, 49], [48, 50], [48, 51], [48, 53], [48, 54], [48, 55], [48, 56], [48, 57], [48, 58], [48, 61], [48, 64], [48, 65], [48, 67], [48, 68], [48, 69], [48, 71], [48, 73], [48, 75], [48, 77], [48, 80], [48, 82], [48, 83], [48, 84], [48, 85], [48, 87], [48, 88], [48, 90], [48, 91], [48, 92], [48, 97], [48, 98], [48, 99], [49, 50], [49, 51], [49, 55], [49, 56], [49, 57], [49, 60], [49, 63], [49, 64], [49, 67], [49, 68], [49, 69], [49, 71], [49, 72], [49, 74], [49, 75], [49, 77], [49, 78], [49, 81], [49, 83], [49, 84], [49, 85], [49, 86], [49, 88], [49, 90], [49, 93], [49, 94], [49, 96], [49, 99], [50, 52], [50, 60], [50, 62], [50, 63], [50, 64], [50, 65], [50, 68], [50, 69], [50, 70], [50, 77], [50, 78], [50, 79], [50, 80], [50, 81], [50, 85], [50, 86], [50, 87], [50, 91], [50, 92], [50, 93], [50, 94], [50, 98], [51, 54], [51, 55], [51, 56], [51, 61], [51, 63], [51, 65], [51, 68], [51, 71], [51, 73], [51, 77], [51, 78], [51, 79], [51, 80], [51, 83], [51, 85], [51, 87], [51, 88], [51, 89], [51, 90], [51, 93], [51, 97], [51, 98], [51, 99], [52, 56], [52, 62], [52, 65], [52, 69], [52, 71], [52, 72], [52, 74], [52, 76], [52, 77], [52, 78], [52, 81], [52, 91], [52, 93], [52, 94], [52, 96], [52, 98], [53, 54], [53, 56], [53, 59], [53, 61], [53, 62], [53, 63], [53, 64], [53, 68], [53, 70], [53, 72], [53, 73], [53, 74], [53, 76], [53, 77], [53, 80], [53, 81], [53, 85], [53, 88], [53, 93], [53, 95], [53, 96], [53, 98], [54, 55], [54, 56], [54, 57], [54, 59], [54, 61], [54, 66], [54, 67], [54, 70], [54, 71], [54, 72], [54, 76], [54, 77], [54, 78], [54, 79], [54, 80], [54, 81], [54, 83], [54, 88], [54, 94], [54, 95], [54, 98], [54, 99], [55, 56], [55, 58], [55, 59], [55, 60], [55, 62], [55, 63], [55, 64], [55, 66], [55, 68], [55, 69], [55, 71], [55, 76], [55, 81], [55, 82], [55, 87], [55, 89], [55, 90], [55, 92], [55, 93], [55, 97], [55, 98], [55, 99], [56, 58], [56, 59], [56, 60], [56, 61], [56, 63], [56, 64], [56, 66], [56, 67], [56, 69], [56, 70], [56, 75], [56, 76], [56, 81], [56, 83], [56, 84], [56, 86], [56, 88], [56, 91], [56, 92], [56, 94], [56, 96], [56, 99], [57, 58], [57, 59], [57, 62], [57, 64], [57, 68], [57, 69], [57, 73], [57, 77], [57, 78], [57, 79], [57, 80], [57, 82], [57, 85], [57, 87], [57, 88], [57, 89], [57, 90], [57, 91], [57, 92], [57, 98], [57, 99], [58, 59], [58, 62], [58, 65], [58, 66], [58, 67], [58, 69], [58, 70], [58, 71], [58, 73], [58, 74], [58, 75], [58, 76], [58, 79], [58, 81], [58, 83], [58, 85], [58, 88], [58, 90], [58, 92], [58, 94], [58, 96], [58, 98], [58, 99], [59, 60], [59, 62], [59, 63], [59, 64], [59, 65], [59, 66], [59, 68], [59, 69], [59, 70], [59, 71], [59, 72], [59, 75], [59, 76], [59, 77], [59, 78], [59, 80], [59, 82], [59, 84], [59, 85], [59, 87], [59, 90], [59, 93], [59, 94], [59, 97], [60, 61], [60, 63], [60, 65], [60, 66], [60, 68], [60, 69], [60, 78], [60, 79], [60, 80], [60, 81], [60, 82], [60, 83], [60, 84], [60, 85], [60, 86], [60, 88], [60, 90], [60, 91], [60, 92], [60, 93], [60, 94], [60, 97], [60, 98], [61, 62], [61, 64], [61, 68], [61, 70], [61, 71], [61, 74], [61, 77], [61, 78], [61, 80], [61, 82], [61, 86], [61, 87], [61, 88], [61, 92], [61, 95], [61, 97], [61, 99], [62, 65], [62, 66], [62, 70], [62, 73], [62, 74], [62, 75], [62, 77], [62, 81], [62, 82], [62, 84], [62, 85], [62, 90], [62, 91], [62, 92], [62, 93], [62, 94], [62, 96], [62, 97], [62, 98], [62, 99], [63, 64], [63, 66], [63, 67], [63, 68], [63, 69], [63, 71], [63, 72], [63, 74], [63, 75], [63, 77], [63, 80], [63, 81], [63, 83], [63, 88], [63, 91], [63, 93], [63, 94], [63, 95], [63, 96], [63, 97], [64, 65], [64, 66], [64, 67], [64, 68], [64, 69], [64, 71], [64, 72], [64, 73], [64, 74], [64, 76], [64, 77], [64, 81], [64, 83], [64, 85], [64, 87], [64, 88], [64, 89], [64, 91], [64, 93], [64, 94], [64, 95], [64, 96], [64, 97], [64, 98], [65, 67], [65, 68], [65, 69], [65, 70], [65, 71], [65, 73], [65, 77], [65, 78], [65, 79], [65, 80], [65, 83], [65, 86], [65, 87], [65, 89], [65, 90], [65, 91], [65, 93], [65, 94], [65, 97], [65, 99], [66, 67], [66, 69], [66, 70], [66, 71], [66, 72], [66, 73], [66, 75], [66, 78], [66, 79], [66, 85], [66, 89], [66, 90], [66, 93], [66, 94], [66, 96], [66, 97], [66, 98], [67, 68], [67, 71], [67, 72], [67, 74], [67, 75], [67, 76], [67, 77], [67, 81], [67, 82], [67, 83], [67, 85], [67, 86], [67, 90], [67, 93], [67, 94], [67, 96], [67, 97], [67, 99], [68, 69], [68, 70], [68, 71], [68, 72], [68, 74], [68, 80], [68, 82], [68, 93], [68, 95], [68, 96], [68, 98], [69, 70], [69, 73], [69, 78], [69, 79], [69, 81], [69, 82], [69, 83], [69, 84], [69, 85], [69, 87], [69, 88], [69, 90], [69, 92], [69, 94], [69, 96], [70, 71], [70, 72], [70, 73], [70, 75], [70, 77], [70, 78], [70, 79], [70, 80], [70, 82], [70, 83], [70, 84], [70, 87], [70, 89], [70, 90], [70, 92], [70, 93], [70, 99], [71, 74], [71, 77], [71, 78], [71, 79], [71, 80], [71, 81], [71, 83], [71, 84], [71, 85], [71, 86], [71, 87], [71, 91], [71, 92], [71, 93], [71, 94], [71, 97], [71, 99], [72, 73], [72, 75], [72, 77], [72, 79], [72, 80], [72, 82], [72, 85], [72, 90], [72, 91], [72, 93], [72, 94], [72, 96], [72, 97], [72, 98], [73, 77], [73, 78], [73, 80], [73, 81], [73, 82], [73, 86], [73, 88], [73, 91], [73, 92], [73, 95], [73, 96], [73, 98], [73, 99], [74, 75], [74, 77], [74, 80], [74, 81], [74, 82], [74, 83], [74, 85], [74, 87], [74, 88], [74, 91], [74, 93], [74, 94], [74, 95], [74, 96], [74, 98], [74, 99], [75, 78], [75, 79], [75, 83], [75, 85], [75, 90], [75, 93], [75, 95], [75, 96], [75, 98], [75, 99], [76, 77], [76, 78], [76, 80], [76, 81], [76, 85], [76, 87], [76, 88], [76, 92], [76, 93], [76, 97], [77, 78], [77, 79], [77, 80], [77, 81], [77, 83], [77, 84], [77, 85], [77, 88], [77, 90], [77, 91], [77, 92], [77, 93], [77, 94], [77, 96], [77, 98], [78, 81], [78, 83], [78, 87], [78, 91], [78, 92], [78, 93], [78, 94], [78, 96], [79, 81], [79, 88], [79, 90], [79, 93], [79, 94], [79, 95], [79, 97], [79, 98], [79, 99], [80, 81], [80, 82], [80, 85], [80, 86], [80, 87], [80, 88], [80, 90], [80, 93], [80, 95], [80, 96], [80, 97], [80, 99], [81, 83], [81, 85], [81, 88], [81, 89], [81, 91], [81, 93], [81, 94], [81, 96], [82, 84], [82, 85], [82, 86], [82, 87], [82, 88], [82, 89], [82, 91], [82, 96], [82, 97], [82, 98], [82, 99], [83, 84], [83, 85], [83, 87], [83, 90], [83, 93], [83, 94], [83, 98], [84, 85], [84, 87], [84, 88], [84, 89], [84, 91], [84, 92], [84, 94], [84, 95], [84, 97], [84, 98], [84, 99], [85, 88], [85, 90], [85, 91], [85, 93], [85, 95], [85, 97], [85, 98], [86, 88], [86, 89], [86, 90], [86, 92], [86, 93], [86, 95], [86, 96], [86, 98], [86, 99], [87, 88], [87, 90], [87, 93], [87, 96], [87, 97], [87, 98], [88, 94], [88, 96], [89, 91], [89, 92], [89, 93], [89, 94], [89, 95], [89, 99], [90, 92], [90, 93], [90, 94], [90, 95], [90, 98], [90, 99], [91, 93], [91, 96], [91, 98], [91, 99], [92, 93], [92, 94], [92, 95], [92, 96], [92, 97], [92, 99], [93, 94], [93, 98], [95, 96], [96, 97], [96, 99], [97, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s9/tests/run.py b/tasks/construct-nppc-clique-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l6-s9/tests/test.sh b/tasks/construct-nppc-clique-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l2-s7/solution/solve.sh b/tasks/construct-nppc-dominating-set-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7af6c7d000c60e7e32967063cda7438a82a4e7d9 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"dominating_set": [1, 4, 6, 8, 9, 11, 12, 14, 15, 17, 18, 23, 24, 26, 29]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l2-s7/tests/check.py b/tasks/construct-nppc-dominating-set-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s7/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l2-s7/tests/instance.json b/tasks/construct-nppc-dominating-set-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1032527a02f28dbd0d5f7e1e5302d7de5946cf8e --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 4], [0, 11], [0, 16], [0, 20], [0, 28], [1, 2], [1, 3], [1, 8], [1, 9], [1, 10], [1, 16], [1, 21], [1, 22], [2, 7], [2, 12], [2, 15], [2, 27], [3, 4], [3, 6], [3, 10], [3, 15], [3, 17], [3, 19], [3, 22], [4, 6], [4, 10], [4, 19], [4, 20], [4, 23], [4, 25], [4, 27], [4, 28], [4, 29], [5, 6], [5, 7], [5, 11], [5, 12], [5, 17], [5, 19], [5, 21], [5, 22], [5, 23], [5, 25], [5, 28], [6, 10], [6, 11], [6, 19], [6, 21], [6, 25], [6, 27], [6, 28], [7, 17], [7, 18], [7, 20], [7, 22], [7, 27], [7, 28], [7, 29], [8, 11], [8, 21], [8, 22], [8, 25], [8, 26], [8, 27], [8, 29], [9, 10], [9, 12], [9, 15], [9, 17], [9, 18], [9, 24], [9, 27], [9, 28], [10, 15], [11, 17], [11, 18], [11, 25], [11, 26], [11, 28], [12, 14], [12, 15], [12, 19], [12, 20], [12, 22], [12, 24], [12, 25], [12, 27], [12, 28], [13, 14], [13, 16], [13, 17], [13, 18], [13, 21], [13, 22], [13, 23], [13, 27], [13, 28], [14, 16], [14, 19], [14, 21], [14, 22], [14, 23], [14, 24], [15, 16], [15, 19], [15, 22], [15, 25], [15, 29], [16, 17], [16, 18], [16, 19], [16, 22], [16, 26], [17, 22], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [18, 21], [18, 25], [18, 29], [19, 21], [19, 28], [20, 21], [20, 25], [20, 29], [21, 23], [21, 24], [21, 26], [21, 29], [22, 23], [22, 24], [22, 25], [22, 26], [23, 24], [24, 25], [24, 29], [25, 27], [25, 29], [27, 28], [27, 29]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s7/tests/run.py b/tasks/construct-nppc-dominating-set-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l2-s7/tests/test.sh b/tasks/construct-nppc-dominating-set-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l6-s8/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l6-s8/environment/instance.json b/tasks/construct-nppc-dominating-set-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9785e808c9dcc2fd30d5adb00946bb1ce02919fb --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 8], [0, 25], [0, 32], [0, 35], [0, 40], [0, 72], [0, 93], [0, 103], [0, 107], [0, 119], [0, 123], [0, 152], [0, 163], [0, 214], [0, 217], [0, 251], [0, 284], [0, 295], [1, 6], [1, 19], [1, 30], [1, 42], [1, 52], [1, 54], [1, 64], [1, 68], [1, 74], [1, 81], [1, 100], [1, 116], [1, 122], [1, 137], [1, 150], [1, 167], [1, 195], [1, 203], [1, 212], [1, 235], [1, 252], [1, 262], [2, 31], [2, 42], [2, 47], [2, 49], [2, 61], [2, 132], [2, 148], [2, 191], [2, 209], [2, 217], [2, 250], [2, 293], [3, 7], [3, 25], [3, 34], [3, 41], [3, 62], [3, 75], [3, 77], [3, 89], [3, 113], [3, 133], [3, 141], [3, 147], [3, 149], [3, 151], [3, 156], [3, 158], [3, 170], [3, 181], [3, 198], [3, 202], [3, 210], [3, 218], [3, 222], [3, 226], [3, 228], [3, 242], [3, 254], [3, 261], [3, 281], [3, 293], [4, 17], [4, 32], [4, 56], [4, 75], [4, 147], [4, 150], [4, 151], [4, 153], [4, 171], [4, 245], [4, 251], [4, 260], [4, 263], [4, 264], [4, 275], [4, 283], [4, 286], [5, 10], [5, 11], [5, 15], [5, 25], [5, 26], [5, 30], [5, 42], [5, 43], [5, 46], [5, 60], [5, 97], [5, 98], [5, 99], [5, 104], [5, 119], [5, 142], [5, 143], [5, 159], [5, 190], [5, 209], [5, 253], [5, 271], [5, 275], [5, 276], [5, 278], [5, 282], [6, 8], [6, 12], [6, 34], [6, 39], [6, 69], [6, 80], [6, 105], [6, 143], [6, 165], [6, 174], [6, 184], [6, 200], [6, 202], [6, 215], [6, 237], [6, 271], [6, 286], [6, 293], [7, 22], [7, 46], [7, 80], [7, 81], [7, 94], [7, 109], [7, 139], [7, 148], [7, 162], [7, 166], [7, 169], [7, 176], [7, 179], [7, 215], [7, 240], [7, 244], [7, 251], [7, 259], [7, 282], [7, 293], [8, 57], [8, 63], [8, 94], [8, 135], [8, 136], [8, 182], [8, 194], [8, 210], [8, 233], [8, 235], [8, 236], [8, 237], [8, 241], [8, 248], [8, 275], [9, 11], [9, 16], [9, 26], [9, 42], [9, 53], [9, 64], [9, 67], [9, 89], [9, 104], [9, 113], [9, 121], [9, 136], [9, 148], [9, 154], [9, 160], [9, 183], [9, 196], [9, 201], [9, 215], [9, 224], [9, 240], [9, 245], [9, 297], [10, 33], [10, 34], [10, 64], [10, 70], [10, 88], [10, 108], [10, 110], [10, 112], [10, 113], [10, 117], [10, 127], [10, 142], [10, 143], [10, 146], [10, 156], [10, 168], [10, 178], [10, 199], [10, 210], [10, 250], [10, 274], [10, 290], [10, 297], [11, 26], [11, 27], [11, 75], [11, 83], [11, 89], [11, 94], [11, 117], [11, 137], [11, 151], [11, 200], [11, 219], [11, 287], [11, 288], [11, 290], [12, 18], [12, 34], [12, 37], [12, 39], [12, 47], [12, 71], [12, 102], [12, 115], [12, 120], [12, 136], [12, 187], [12, 211], [12, 221], [12, 225], [12, 249], [12, 256], [13, 15], [13, 45], [13, 67], [13, 79], [13, 92], [13, 102], [13, 106], [13, 116], [13, 135], [13, 146], [13, 148], [13, 159], [13, 172], [13, 174], [13, 197], [13, 198], [13, 207], [13, 249], [13, 255], [13, 273], [13, 282], [13, 287], [13, 295], [14, 23], [14, 44], [14, 47], [14, 61], [14, 67], [14, 74], [14, 86], [14, 90], [14, 95], [14, 99], [14, 110], [14, 124], [14, 133], [14, 148], [14, 163], [14, 168], [14, 189], [15, 24], [15, 38], [15, 55], [15, 63], [15, 77], [15, 147], [15, 169], [15, 181], [15, 242], [15, 258], [15, 297], [16, 37], [16, 44], [16, 69], [16, 101], [16, 118], [16, 164], [16, 184], [16, 219], [16, 235], [16, 255], [16, 281], [17, 29], [17, 33], [17, 38], [17, 40], [17, 41], [17, 55], [17, 62], [17, 70], [17, 102], [17, 103], [17, 145], [17, 183], [17, 200], [17, 222], [17, 246], [17, 248], [17, 265], [17, 272], [17, 280], [17, 297], [18, 26], [18, 59], [18, 62], [18, 69], [18, 97], [18, 108], [18, 111], [18, 117], [18, 136], [18, 146], [18, 161], [18, 167], [18, 196], [18, 216], [18, 218], [18, 264], [18, 298], [19, 24], [19, 65], [19, 115], [19, 147], [19, 148], [19, 161], [19, 171], [19, 178], [19, 195], [19, 215], [19, 235], [19, 236], [19, 243], [19, 250], [19, 262], [19, 266], [19, 267], [19, 270], [20, 33], [20, 36], [20, 40], [20, 57], [20, 84], [20, 99], [20, 113], [20, 127], [20, 154], [20, 164], [20, 200], [20, 203], [20, 206], [20, 213], [20, 242], [20, 245], [20, 266], [20, 290], [20, 294], [21, 30], [21, 54], [21, 75], [21, 112], [21, 141], [21, 155], [21, 156], [21, 180], [21, 191], [21, 227], [21, 233], [21, 250], [21, 254], [21, 257], [21, 280], [21, 281], [22, 37], [22, 76], [22, 77], [22, 79], [22, 92], [22, 93], [22, 94], [22, 98], [22, 166], [22, 175], [22, 233], [22, 261], [22, 270], [22, 273], [22, 299], [23, 27], [23, 41], [23, 49], [23, 71], [23, 84], [23, 86], [23, 128], [23, 135], [23, 163], [23, 168], [23, 176], [23, 177], [23, 178], [23, 179], [23, 198], [23, 208], [23, 217], [23, 238], [23, 259], [23, 260], [23, 266], [24, 25], [24, 32], [24, 34], [24, 39], [24, 42], [24, 48], [24, 50], [24, 69], [24, 77], [24, 80], [24, 87], [24, 146], [24, 151], [24, 168], [24, 178], [24, 195], [24, 209], [24, 228], [24, 231], [24, 247], [24, 256], [24, 260], [24, 261], [24, 280], [24, 289], [24, 295], [24, 298], [25, 47], [25, 78], [25, 99], [25, 100], [25, 105], [25, 112], [25, 117], [25, 126], [25, 179], [25, 214], [25, 227], [25, 262], [25, 268], [25, 269], [25, 270], [25, 298], [26, 37], [26, 56], [26, 78], [26, 98], [26, 110], [26, 111], [26, 112], [26, 117], [26, 118], [26, 186], [26, 188], [26, 191], [26, 222], [26, 240], [26, 250], [26, 259], [26, 283], [26, 292], [27, 30], [27, 37], [27, 64], [27, 80], [27, 92], [27, 101], [27, 106], [27, 107], [27, 112], [27, 135], [27, 145], [27, 151], [27, 159], [27, 160], [27, 176], [27, 203], [27, 205], [27, 211], [27, 264], [27, 268], [27, 279], [27, 286], [28, 51], [28, 66], [28, 67], [28, 79], [28, 85], [28, 138], [28, 148], [28, 165], [28, 171], [28, 172], [28, 178], [28, 186], [28, 191], [28, 199], [28, 222], [28, 250], [28, 251], [28, 274], [28, 286], [29, 57], [29, 65], [29, 68], [29, 76], [29, 78], [29, 104], [29, 136], [29, 139], [29, 147], [29, 150], [29, 152], [29, 157], [29, 177], [29, 187], [29, 196], [29, 200], [29, 206], [29, 277], [30, 48], [30, 57], [30, 60], [30, 76], [30, 80], [30, 93], [30, 95], [30, 99], [30, 107], [30, 114], [30, 141], [30, 171], [30, 190], [30, 192], [30, 214], [30, 220], [30, 222], [30, 241], [30, 276], [30, 278], [30, 289], [30, 294], [31, 41], [31, 46], [31, 52], [31, 60], [31, 81], [31, 100], [31, 116], [31, 117], [31, 144], [31, 168], [31, 231], [31, 264], [31, 290], [32, 75], [32, 104], [32, 127], [32, 128], [32, 132], [32, 192], [32, 206], [32, 230], [32, 249], [32, 259], [32, 291], [32, 296], [33, 53], [33, 97], [33, 99], [33, 112], [33, 130], [33, 153], [33, 160], [33, 171], [33, 173], [33, 177], [33, 181], [33, 182], [33, 198], [33, 200], [33, 204], [33, 210], [33, 228], [33, 250], [33, 269], [33, 270], [33, 276], [33, 288], [34, 42], [34, 58], [34, 71], [34, 112], [34, 119], [34, 130], [34, 133], [34, 135], [34, 157], [34, 163], [34, 178], [34, 182], [34, 218], [34, 236], [34, 256], [34, 260], [34, 267], [34, 268], [35, 56], [35, 65], [35, 76], [35, 79], [35, 93], [35, 97], [35, 118], [35, 137], [35, 162], [35, 179], [35, 207], [35, 230], [35, 239], [35, 259], [35, 260], [36, 42], [36, 64], [36, 86], [36, 90], [36, 99], [36, 102], [36, 183], [36, 203], [36, 212], [36, 214], [36, 219], [36, 222], [36, 238], [36, 245], [36, 262], [36, 287], [36, 292], [37, 41], [37, 62], [37, 67], [37, 72], [37, 75], [37, 94], [37, 95], [37, 121], [37, 123], [37, 130], [37, 165], [37, 188], [37, 189], [37, 199], [37, 204], [37, 209], [37, 220], [37, 226], [37, 227], [37, 246], [37, 248], [37, 254], [37, 293], [37, 298], [38, 45], [38, 62], [38, 81], [38, 89], [38, 96], [38, 114], [38, 137], [38, 145], [38, 147], [38, 175], [38, 178], [38, 181], [38, 211], [38, 237], [38, 255], [38, 259], [38, 262], [38, 291], [39, 64], [39, 84], [39, 88], [39, 93], [39, 95], [39, 101], [39, 107], [39, 119], [39, 128], [39, 139], [39, 152], [39, 156], [39, 181], [39, 272], [39, 299], [40, 43], [40, 57], [40, 66], [40, 71], [40, 101], [40, 109], [40, 112], [40, 113], [40, 135], [40, 197], [40, 200], [40, 201], [40, 214], [40, 217], [40, 224], [40, 275], [41, 45], [41, 59], [41, 61], [41, 66], [41, 69], [41, 89], [41, 105], [41, 110], [41, 113], [41, 119], [41, 127], [41, 133], [41, 136], [41, 161], [41, 166], [41, 177], [41, 179], [41, 223], [41, 233], [41, 237], [41, 238], [41, 257], [41, 282], [41, 286], [41, 287], [42, 60], [42, 69], [42, 75], [42, 83], [42, 93], [42, 117], [42, 158], [42, 181], [42, 194], [42, 212], [42, 248], [42, 258], [42, 263], [42, 267], [42, 268], [42, 276], [42, 277], [42, 283], [43, 49], [43, 55], [43, 88], [43, 100], [43, 104], [43, 111], [43, 136], [43, 149], [43, 181], [43, 187], [43, 190], [43, 203], [43, 221], [43, 251], [43, 284], [44, 59], [44, 89], [44, 108], [44, 118], [44, 123], [44, 124], [44, 125], [44, 128], [44, 146], [44, 151], [44, 213], [44, 243], [44, 269], [44, 273], [44, 274], [44, 286], [45, 50], [45, 60], [45, 77], [45, 88], [45, 110], [45, 112], [45, 120], [45, 147], [45, 161], [45, 163], [45, 170], [45, 188], [45, 209], [45, 283], [46, 53], [46, 97], [46, 106], [46, 108], [46, 109], [46, 112], [46, 118], [46, 123], [46, 139], [46, 146], [46, 164], [46, 165], [46, 166], [46, 171], [46, 180], [46, 189], [46, 225], [46, 229], [46, 230], [46, 233], [46, 237], [46, 249], [46, 257], [46, 260], [46, 284], [47, 57], [47, 74], [47, 82], [47, 87], [47, 104], [47, 111], [47, 116], [47, 119], [47, 138], [47, 146], [47, 150], [47, 153], [47, 161], [47, 164], [47, 172], [47, 177], [47, 182], [47, 198], [47, 202], [47, 203], [47, 214], [47, 237], [47, 240], [47, 247], [47, 252], [47, 255], [47, 261], [47, 273], [47, 280], [48, 54], [48, 78], [48, 86], [48, 94], [48, 105], [48, 112], [48, 128], [48, 135], [48, 163], [48, 177], [48, 198], [48, 246], [48, 253], [49, 58], [49, 63], [49, 67], [49, 132], [49, 139], [49, 144], [49, 158], [49, 162], [49, 169], [49, 170], [49, 173], [49, 200], [49, 202], [49, 207], [49, 258], [49, 263], [49, 293], [50, 76], [50, 78], [50, 107], [50, 109], [50, 115], [50, 117], [50, 128], [50, 131], [50, 141], [50, 175], [50, 189], [50, 205], [50, 224], [50, 251], [50, 265], [50, 276], [51, 58], [51, 61], [51, 87], [51, 88], [51, 93], [51, 94], [51, 106], [51, 117], [51, 120], [51, 127], [51, 153], [51, 168], [51, 195], [51, 198], [51, 218], [51, 220], [51, 230], [51, 237], [51, 280], [51, 287], [51, 290], [51, 292], [51, 299], [52, 55], [52, 59], [52, 60], [52, 72], [52, 93], [52, 97], [52, 101], [52, 108], [52, 128], [52, 165], [52, 177], [52, 180], [52, 222], [52, 256], [52, 282], [52, 283], [53, 59], [53, 83], [53, 152], [53, 174], [53, 176], [53, 186], [53, 204], [53, 227], [53, 246], [53, 286], [53, 298], [54, 71], [54, 82], [54, 92], [54, 107], [54, 114], [54, 122], [54, 134], [54, 137], [54, 148], [54, 181], [54, 191], [54, 202], [54, 205], [54, 208], [54, 236], [54, 255], [54, 299], [55, 66], [55, 73], [55, 90], [55, 92], [55, 101], [55, 106], [55, 115], [55, 120], [55, 121], [55, 125], [55, 127], [55, 142], [55, 145], [55, 165], [55, 184], [55, 185], [55, 207], [55, 217], [55, 227], [55, 237], [55, 257], [55, 262], [55, 268], [55, 271], [55, 285], [55, 296], [55, 299], [56, 75], [56, 78], [56, 92], [56, 161], [56, 163], [56, 168], [56, 172], [56, 175], [56, 196], [56, 201], [56, 203], [56, 204], [56, 259], [56, 287], [57, 137], [57, 138], [57, 146], [57, 152], [57, 178], [57, 186], [57, 189], [57, 194], [57, 197], [57, 242], [57, 248], [57, 252], [57, 297], [58, 62], [58, 81], [58, 99], [58, 110], [58, 148], [58, 155], [58, 180], [58, 209], [58, 219], [58, 251], [58, 257], [58, 264], [58, 277], [58, 288], [58, 298], [59, 77], [59, 99], [59, 100], [59, 108], [59, 112], [59, 116], [59, 141], [59, 147], [59, 172], [59, 200], [59, 216], [59, 239], [59, 257], [59, 285], [60, 97], [60, 111], [60, 133], [60, 174], [60, 184], [60, 191], [60, 243], [60, 257], [60, 265], [61, 67], [61, 85], [61, 97], [61, 123], [61, 124], [61, 130], [61, 140], [61, 152], [61, 189], [61, 197], [61, 200], [61, 203], [61, 205], [61, 230], [61, 253], [61, 255], [61, 262], [61, 263], [61, 264], [61, 272], [61, 274], [61, 278], [62, 73], [62, 79], [62, 88], [62, 93], [62, 114], [62, 138], [62, 160], [62, 166], [62, 171], [62, 179], [62, 188], [62, 190], [62, 202], [62, 206], [62, 223], [62, 232], [62, 242], [62, 252], [62, 278], [63, 81], [63, 105], [63, 108], [63, 110], [63, 117], [63, 132], [63, 148], [63, 172], [63, 178], [63, 200], [63, 216], [63, 262], [63, 263], [63, 265], [64, 68], [64, 75], [64, 85], [64, 117], [64, 122], [64, 135], [64, 142], [64, 167], [64, 186], [64, 193], [64, 202], [64, 212], [64, 230], [64, 231], [64, 247], [64, 261], [64, 270], [64, 274], [64, 276], [64, 283], [64, 292], [64, 295], [64, 299], [65, 68], [65, 105], [65, 128], [65, 138], [65, 163], [65, 176], [65, 184], [65, 185], [65, 194], [65, 222], [65, 237], [65, 241], [65, 248], [65, 289], [66, 71], [66, 76], [66, 84], [66, 106], [66, 118], [66, 143], [66, 149], [66, 162], [66, 167], [66, 181], [66, 202], [66, 208], [66, 253], [66, 270], [66, 271], [67, 76], [67, 82], [67, 86], [67, 97], [67, 105], [67, 119], [67, 125], [67, 155], [67, 162], [67, 181], [67, 185], [67, 187], [67, 200], [67, 223], [67, 235], [67, 237], [67, 250], [67, 257], [67, 262], [67, 288], [67, 290], [67, 295], [68, 96], [68, 111], [68, 119], [68, 121], [68, 142], [68, 148], [68, 194], [68, 245], [68, 272], [68, 285], [68, 295], [69, 78], [69, 102], [69, 103], [69, 117], [69, 153], [69, 160], [69, 213], [69, 214], [69, 215], [69, 263], [69, 276], [69, 280], [70, 121], [70, 124], [70, 140], [70, 168], [70, 174], [70, 189], [70, 191], [70, 235], [70, 237], [70, 249], [70, 273], [70, 282], [71, 74], [71, 114], [71, 125], [71, 182], [71, 208], [71, 217], [71, 222], [71, 226], [71, 258], [72, 74], [72, 86], [72, 87], [72, 111], [72, 112], [72, 121], [72, 123], [72, 125], [72, 158], [72, 180], [72, 186], [72, 189], [72, 193], [72, 194], [72, 202], [72, 218], [72, 223], [72, 224], [72, 267], [72, 270], [73, 88], [73, 92], [73, 109], [73, 115], [73, 136], [73, 145], [73, 163], [73, 178], [73, 182], [73, 183], [73, 197], [73, 223], [73, 225], [73, 228], [73, 231], [73, 246], [73, 264], [73, 282], [74, 77], [74, 94], [74, 108], [74, 146], [74, 171], [74, 189], [74, 201], [74, 209], [74, 218], [74, 259], [74, 265], [74, 274], [74, 280], [75, 79], [75, 80], [75, 97], [75, 108], [75, 124], [75, 125], [75, 133], [75, 141], [75, 159], [75, 165], [75, 193], [75, 204], [75, 215], [75, 218], [75, 221], [75, 232], [75, 233], [75, 236], [75, 246], [75, 258], [75, 284], [75, 288], [75, 291], [76, 77], [76, 83], [76, 84], [76, 165], [76, 216], [76, 221], [76, 250], [76, 268], [76, 269], [76, 273], [76, 285], [76, 286], [76, 294], [76, 295], [76, 297], [77, 84], [77, 86], [77, 109], [77, 163], [77, 166], [77, 219], [77, 248], [77, 281], [77, 291], [77, 298], [78, 82], [78, 96], [78, 119], [78, 133], [78, 140], [78, 151], [78, 190], [78, 194], [78, 238], [78, 242], [78, 258], [78, 261], [78, 285], [79, 91], [79, 107], [79, 116], [79, 167], [79, 183], [79, 220], [79, 250], [79, 251], [79, 264], [80, 85], [80, 105], [80, 108], [80, 131], [80, 143], [80, 169], [80, 215], [80, 226], [80, 227], [80, 256], [80, 270], [80, 273], [80, 274], [80, 286], [81, 89], [81, 96], [81, 126], [81, 173], [81, 174], [81, 215], [81, 227], [81, 264], [81, 285], [81, 287], [82, 99], [82, 101], [82, 107], [82, 108], [82, 120], [82, 132], [82, 141], [82, 155], [82, 192], [82, 217], [82, 218], [82, 233], [82, 241], [82, 248], [82, 262], [82, 264], [82, 279], [82, 283], [82, 293], [83, 96], [83, 101], [83, 119], [83, 133], [83, 136], [83, 144], [83, 165], [83, 166], [83, 176], [83, 180], [83, 193], [83, 199], [83, 200], [83, 257], [83, 273], [83, 284], [83, 297], [84, 85], [84, 93], [84, 99], [84, 120], [84, 124], [84, 129], [84, 134], [84, 145], [84, 160], [84, 168], [84, 188], [84, 200], [84, 210], [84, 223], [84, 233], [84, 246], [84, 264], [84, 286], [85, 96], [85, 104], [85, 110], [85, 112], [85, 115], [85, 120], [85, 153], [85, 169], [85, 187], [85, 202], [85, 210], [85, 213], [85, 221], [85, 229], [85, 277], [85, 284], [86, 92], [86, 100], [86, 101], [86, 107], [86, 108], [86, 137], [86, 194], [86, 197], [86, 200], [86, 236], [86, 271], [86, 294], [86, 299], [87, 91], [87, 101], [87, 103], [87, 120], [87, 129], [87, 144], [87, 176], [87, 189], [87, 195], [87, 210], [87, 219], [87, 264], [87, 273], [87, 282], [87, 290], [87, 296], [88, 90], [88, 97], [88, 109], [88, 111], [88, 152], [88, 157], [88, 168], [88, 181], [88, 191], [88, 207], [88, 208], [88, 210], [88, 228], [88, 249], [88, 254], [88, 285], [88, 286], [89, 116], [89, 138], [89, 150], [89, 158], [89, 162], [89, 165], [89, 166], [89, 200], [89, 203], [89, 227], [89, 231], [89, 235], [89, 245], [89, 280], [90, 100], [90, 115], [90, 117], [90, 125], [90, 128], [90, 134], [90, 135], [90, 136], [90, 139], [90, 169], [90, 178], [90, 189], [90, 248], [90, 273], [90, 286], [91, 101], [91, 117], [91, 149], [91, 163], [91, 172], [91, 174], [91, 179], [91, 201], [91, 206], [91, 217], [91, 220], [91, 250], [92, 98], [92, 99], [92, 107], [92, 116], [92, 140], [92, 141], [92, 145], [92, 186], [92, 219], [92, 241], [92, 258], [92, 267], [92, 298], [93, 163], [93, 175], [93, 179], [93, 204], [93, 208], [93, 225], [93, 231], [93, 244], [93, 247], [93, 260], [93, 276], [93, 281], [94, 96], [94, 112], [94, 114], [94, 119], [94, 130], [94, 146], [94, 166], [94, 168], [94, 233], [94, 238], [94, 240], [94, 250], [94, 256], [94, 264], [94, 267], [94, 272], [94, 276], [95, 123], [95, 126], [95, 130], [95, 170], [95, 172], [95, 176], [95, 202], [95, 210], [95, 246], [95, 266], [95, 272], [95, 287], [95, 299], [96, 132], [96, 140], [96, 146], [96, 150], [96, 194], [96, 287], [97, 102], [97, 118], [97, 154], [97, 160], [97, 170], [97, 180], [97, 183], [97, 184], [97, 189], [97, 226], [97, 229], [97, 232], [97, 259], [97, 262], [97, 271], [97, 276], [97, 281], [97, 291], [97, 292], [98, 106], [98, 119], [98, 141], [98, 144], [98, 153], [98, 184], [98, 187], [98, 191], [98, 192], [98, 202], [98, 224], [98, 252], [98, 256], [98, 262], [98, 273], [98, 277], [99, 102], [99, 108], [99, 124], [99, 136], [99, 160], [99, 186], [99, 189], [99, 192], [99, 210], [99, 217], [99, 257], [99, 284], [99, 297], [100, 118], [100, 126], [100, 128], [100, 132], [100, 133], [100, 137], [100, 138], [100, 152], [100, 155], [100, 167], [100, 181], [100, 199], [100, 202], [100, 211], [100, 232], [100, 234], [100, 249], [100, 254], [100, 263], [100, 266], [100, 297], [101, 114], [101, 125], [101, 131], [101, 132], [101, 173], [101, 222], [101, 228], [101, 230], [101, 245], [101, 261], [101, 268], [101, 279], [101, 281], [102, 104], [102, 127], [102, 148], [102, 166], [102, 174], [102, 200], [102, 201], [102, 205], [102, 208], [102, 215], [102, 221], [102, 225], [102, 230], [102, 233], [102, 237], [102, 241], [102, 268], [102, 282], [102, 285], [102, 287], [103, 117], [103, 119], [103, 124], [103, 145], [103, 160], [103, 163], [103, 174], [103, 185], [103, 198], [103, 200], [103, 222], [103, 246], [103, 247], [103, 248], [103, 253], [103, 264], [103, 282], [104, 116], [104, 127], [104, 137], [104, 148], [104, 150], [104, 156], [104, 165], [104, 167], [104, 184], [104, 226], [104, 231], [104, 233], [104, 236], [104, 266], [104, 275], [105, 116], [105, 137], [105, 173], [105, 179], [105, 181], [105, 200], [105, 219], [105, 241], [105, 264], [105, 287], [105, 290], [105, 292], [106, 136], [106, 171], [106, 180], [106, 212], [106, 226], [106, 228], [106, 236], [106, 257], [106, 288], [107, 147], [107, 181], [107, 194], [107, 203], [107, 206], [108, 138], [108, 140], [108, 154], [108, 161], [108, 170], [108, 173], [108, 182], [108, 202], [108, 209], [108, 225], [108, 231], [108, 240], [108, 245], [108, 251], [108, 255], [108, 284], [108, 290], [108, 291], [108, 293], [109, 130], [109, 154], [109, 157], [109, 158], [109, 209], [109, 249], [109, 270], [109, 290], [110, 114], [110, 127], [110, 141], [110, 158], [110, 176], [110, 178], [110, 183], [110, 184], [110, 185], [110, 202], [110, 203], [110, 221], [110, 244], [110, 279], [110, 283], [110, 293], [111, 122], [111, 139], [111, 168], [111, 171], [111, 191], [111, 192], [111, 208], [111, 240], [111, 264], [111, 290], [112, 128], [112, 152], [112, 162], [112, 174], [112, 178], [112, 265], [112, 292], [113, 169], [113, 175], [113, 187], [113, 203], [113, 205], [113, 222], [113, 223], [113, 275], [113, 276], [113, 285], [113, 289], [114, 124], [114, 137], [114, 140], [114, 148], [114, 151], [114, 176], [114, 189], [114, 190], [114, 192], [114, 194], [114, 209], [114, 213], [114, 234], [114, 256], [114, 269], [114, 289], [115, 118], [115, 137], [115, 140], [115, 142], [115, 145], [115, 206], [115, 219], [115, 230], [115, 234], [115, 237], [115, 259], [115, 262], [115, 266], [115, 273], [115, 297], [116, 118], [116, 135], [116, 151], [116, 168], [116, 209], [116, 219], [116, 248], [116, 297], [117, 120], [117, 128], [117, 158], [117, 164], [117, 181], [117, 214], [117, 216], [117, 236], [117, 242], [117, 248], [117, 256], [117, 266], [117, 272], [117, 288], [118, 144], [118, 149], [118, 154], [118, 164], [118, 165], [118, 177], [118, 187], [118, 190], [118, 192], [118, 205], [118, 206], [118, 233], [118, 253], [119, 134], [119, 176], [119, 185], [119, 207], [119, 211], [119, 227], [119, 228], [119, 250], [119, 251], [119, 257], [120, 130], [120, 146], [120, 151], [120, 163], [120, 184], [120, 200], [120, 225], [120, 265], [120, 292], [121, 126], [121, 143], [121, 199], [121, 212], [121, 279], [122, 139], [122, 149], [122, 152], [122, 172], [122, 193], [122, 199], [122, 200], [122, 224], [122, 228], [122, 241], [122, 249], [122, 262], [122, 288], [122, 290], [123, 124], [123, 139], [123, 146], [123, 162], [123, 169], [123, 226], [123, 253], [123, 255], [123, 261], [123, 264], [123, 273], [124, 169], [124, 179], [124, 182], [124, 205], [124, 207], [124, 228], [124, 238], [124, 246], [124, 247], [124, 256], [124, 264], [124, 265], [124, 286], [125, 159], [125, 164], [125, 173], [125, 235], [125, 253], [125, 262], [125, 267], [125, 268], [125, 279], [125, 281], [126, 163], [126, 198], [126, 227], [126, 241], [126, 249], [126, 262], [126, 268], [126, 279], [127, 147], [127, 169], [127, 172], [127, 186], [127, 198], [127, 201], [127, 203], [127, 205], [127, 210], [127, 260], [127, 263], [127, 264], [127, 272], [127, 299], [128, 138], [128, 147], [128, 175], [128, 195], [128, 197], [128, 209], [128, 222], [128, 231], [128, 263], [128, 294], [129, 156], [129, 164], [129, 167], [129, 194], [129, 202], [129, 205], [129, 245], [129, 267], [129, 274], [129, 293], [130, 132], [130, 145], [130, 153], [130, 174], [130, 210], [130, 236], [130, 261], [130, 263], [130, 274], [130, 281], [130, 283], [131, 199], [131, 212], [131, 226], [131, 233], [131, 250], [131, 267], [131, 270], [132, 137], [132, 146], [132, 159], [132, 170], [132, 177], [132, 185], [132, 191], [132, 210], [132, 228], [132, 243], [132, 253], [132, 284], [133, 135], [133, 145], [133, 152], [133, 165], [133, 179], [133, 208], [133, 225], [133, 235], [133, 244], [133, 288], [133, 289], [134, 142], [134, 150], [134, 157], [134, 163], [134, 197], [134, 228], [134, 234], [134, 240], [135, 146], [135, 148], [135, 161], [135, 162], [135, 188], [135, 190], [135, 197], [135, 250], [135, 269], [135, 280], [135, 298], [136, 143], [136, 161], [136, 180], [136, 188], [136, 196], [136, 208], [136, 216], [136, 221], [136, 240], [136, 253], [136, 268], [136, 290], [136, 293], [137, 139], [137, 148], [137, 183], [137, 198], [137, 201], [137, 229], [137, 235], [137, 241], [137, 242], [137, 256], [137, 271], [137, 277], [137, 279], [137, 293], [137, 294], [138, 140], [138, 163], [138, 167], [138, 191], [138, 192], [138, 206], [138, 231], [138, 236], [138, 262], [138, 271], [138, 286], [138, 299], [139, 150], [139, 154], [139, 164], [139, 189], [139, 191], [139, 200], [139, 202], [139, 205], [139, 218], [139, 219], [139, 247], [139, 264], [139, 272], [139, 288], [139, 292], [140, 159], [140, 194], [140, 213], [140, 223], [140, 273], [141, 151], [141, 167], [141, 180], [141, 198], [141, 199], [141, 211], [141, 213], [141, 226], [141, 251], [141, 257], [141, 277], [142, 144], [142, 162], [142, 164], [142, 180], [142, 184], [142, 260], [142, 262], [142, 264], [142, 276], [142, 283], [143, 215], [143, 222], [143, 243], [143, 253], [144, 179], [144, 182], [144, 194], [144, 198], [144, 200], [144, 201], [144, 225], [144, 229], [144, 231], [144, 234], [144, 298], [145, 190], [145, 191], [145, 208], [145, 210], [145, 216], [145, 251], [145, 257], [145, 259], [145, 265], [145, 274], [145, 277], [145, 293], [146, 157], [146, 168], [146, 181], [146, 191], [146, 205], [146, 219], [146, 235], [146, 244], [146, 269], [146, 270], [147, 154], [147, 156], [147, 168], [147, 220], [147, 232], [147, 240], [147, 250], [147, 269], [147, 288], [147, 297], [148, 152], [148, 180], [148, 181], [148, 186], [148, 209], [148, 217], [148, 231], [148, 264], [149, 158], [149, 165], [149, 168], [149, 169], [149, 176], [149, 203], [149, 204], [149, 259], [149, 287], [149, 289], [150, 152], [150, 167], [150, 168], [150, 246], [150, 251], [150, 256], [150, 269], [150, 285], [150, 290], [150, 298], [151, 175], [151, 180], [151, 182], [151, 201], [151, 229], [151, 236], [151, 249], [151, 269], [151, 294], [151, 298], [152, 188], [152, 194], [152, 197], [152, 210], [152, 216], [152, 221], [152, 224], [152, 261], [152, 263], [152, 269], [152, 271], [152, 278], [153, 161], [153, 184], [153, 202], [153, 203], [153, 241], [153, 247], [153, 278], [153, 287], [153, 290], [154, 201], [154, 206], [154, 213], [154, 277], [154, 283], [154, 296], [154, 297], [155, 163], [155, 178], [155, 185], [155, 190], [155, 210], [155, 223], [155, 241], [155, 253], [155, 274], [155, 285], [156, 163], [156, 194], [156, 199], [156, 200], [156, 202], [156, 206], [156, 215], [156, 226], [156, 231], [156, 273], [156, 293], [157, 158], [157, 181], [157, 200], [157, 231], [157, 236], [157, 241], [157, 247], [157, 250], [157, 273], [158, 166], [158, 171], [158, 177], [158, 193], [158, 195], [158, 198], [158, 211], [158, 222], [158, 240], [159, 164], [159, 177], [159, 179], [159, 207], [159, 220], [159, 243], [159, 262], [159, 267], [159, 289], [159, 291], [159, 298], [159, 299], [160, 194], [160, 208], [160, 211], [160, 244], [160, 250], [160, 282], [161, 171], [161, 179], [161, 196], [161, 221], [161, 225], [161, 231], [161, 235], [161, 252], [161, 255], [161, 259], [161, 284], [161, 286], [162, 193], [162, 200], [162, 218], [162, 238], [162, 255], [162, 266], [162, 273], [162, 283], [162, 289], [163, 177], [163, 183], [163, 204], [163, 209], [163, 217], [163, 234], [163, 238], [163, 239], [163, 244], [163, 254], [163, 267], [163, 276], [163, 296], [164, 174], [164, 177], [164, 186], [164, 188], [164, 189], [164, 192], [164, 193], [164, 205], [164, 225], [165, 200], [165, 219], [165, 225], [165, 230], [165, 255], [165, 289], [166, 182], [166, 191], [166, 196], [166, 217], [166, 220], [166, 222], [166, 231], [166, 285], [167, 173], [167, 201], [167, 205], [167, 242], [167, 253], [168, 212], [168, 249], [168, 259], [168, 274], [168, 288], [169, 177], [169, 200], [169, 218], [169, 221], [169, 253], [169, 261], [169, 262], [169, 265], [169, 271], [169, 275], [169, 286], [170, 173], [170, 175], [170, 176], [170, 177], [170, 259], [170, 262], [170, 264], [170, 278], [171, 173], [171, 174], [171, 176], [171, 199], [171, 247], [171, 250], [171, 270], [171, 272], [171, 284], [171, 290], [171, 297], [172, 179], [172, 204], [172, 206], [172, 216], [172, 241], [172, 251], [172, 262], [172, 268], [172, 280], [172, 281], [172, 289], [173, 182], [173, 193], [173, 194], [173, 221], [173, 241], [173, 246], [173, 274], [173, 275], [173, 278], [173, 279], [174, 222], [174, 223], [174, 229], [174, 237], [174, 244], [174, 257], [174, 278], [174, 289], [174, 290], [175, 184], [175, 192], [175, 209], [175, 239], [175, 261], [175, 263], [175, 264], [176, 188], [176, 191], [176, 229], [176, 238], [176, 241], [176, 244], [176, 253], [176, 260], [176, 264], [176, 270], [177, 180], [177, 235], [177, 263], [178, 179], [178, 183], [178, 185], [178, 200], [178, 218], [178, 228], [178, 263], [179, 186], [179, 187], [179, 188], [179, 190], [179, 196], [179, 200], [179, 204], [179, 205], [179, 220], [179, 224], [179, 231], [179, 239], [179, 244], [179, 251], [179, 264], [179, 266], [179, 268], [180, 199], [180, 204], [180, 220], [180, 227], [180, 252], [180, 256], [180, 277], [181, 194], [181, 197], [181, 227], [181, 230], [181, 253], [181, 259], [181, 265], [182, 187], [182, 192], [182, 220], [182, 296], [183, 193], [183, 200], [183, 237], [183, 245], [183, 266], [183, 280], [183, 288], [184, 189], [184, 205], [184, 214], [184, 218], [184, 245], [184, 261], [185, 206], [185, 263], [185, 267], [185, 284], [185, 293], [185, 297], [186, 226], [186, 271], [186, 272], [186, 287], [187, 192], [187, 250], [187, 255], [187, 276], [187, 286], [188, 198], [188, 200], [188, 250], [188, 274], [189, 205], [189, 228], [189, 229], [189, 245], [189, 253], [189, 289], [190, 220], [190, 237], [191, 199], [191, 200], [191, 204], [191, 226], [192, 193], [192, 194], [192, 208], [192, 221], [192, 279], [193, 203], [193, 219], [193, 251], [193, 289], [194, 210], [194, 212], [194, 221], [194, 223], [194, 265], [194, 272], [194, 298], [195, 206], [195, 261], [195, 277], [195, 297], [196, 197], [196, 218], [196, 234], [196, 239], [196, 251], [196, 285], [197, 239], [197, 240], [197, 264], [197, 286], [198, 213], [198, 219], [198, 221], [198, 269], [198, 279], [198, 283], [198, 289], [199, 214], [199, 225], [199, 226], [199, 241], [199, 259], [199, 268], [200, 205], [200, 208], [200, 216], [200, 219], [200, 220], [200, 223], [200, 224], [200, 236], [200, 269], [200, 294], [201, 285], [201, 297], [202, 206], [202, 212], [202, 222], [202, 240], [202, 262], [202, 279], [203, 213], [203, 217], [203, 224], [203, 233], [203, 252], [203, 262], [203, 265], [203, 275], [203, 299], [204, 220], [204, 244], [204, 245], [204, 266], [204, 286], [205, 213], [205, 223], [205, 243], [205, 280], [205, 283], [205, 289], [206, 230], [206, 235], [206, 261], [206, 264], [206, 271], [206, 280], [206, 295], [207, 224], [207, 236], [207, 246], [208, 212], [208, 227], [208, 238], [208, 264], [208, 295], [208, 297], [209, 214], [209, 237], [209, 239], [209, 262], [209, 272], [209, 290], [210, 220], [210, 227], [210, 242], [210, 250], [210, 253], [210, 273], [210, 293], [211, 222], [211, 235], [211, 245], [211, 253], [211, 256], [211, 262], [211, 277], [211, 283], [211, 293], [212, 214], [212, 219], [212, 226], [212, 236], [212, 239], [212, 272], [213, 221], [213, 285], [214, 222], [214, 254], [214, 273], [214, 292], [214, 299], [215, 222], [215, 231], [215, 256], [215, 264], [215, 271], [215, 275], [215, 298], [216, 221], [216, 298], [217, 228], [217, 231], [217, 234], [217, 235], [217, 244], [217, 290], [218, 241], [218, 245], [218, 248], [218, 250], [218, 254], [218, 278], [218, 283], [219, 270], [219, 294], [220, 232], [220, 250], [220, 257], [220, 259], [221, 225], [221, 244], [221, 248], [221, 259], [221, 267], [222, 238], [222, 261], [222, 263], [222, 270], [223, 244], [223, 266], [223, 293], [224, 249], [224, 250], [224, 272], [225, 237], [225, 245], [225, 266], [225, 293], [226, 234], [226, 256], [226, 273], [227, 242], [227, 246], [227, 264], [227, 267], [227, 273], [227, 296], [228, 232], [229, 233], [229, 253], [229, 261], [230, 232], [230, 233], [230, 251], [230, 278], [230, 288], [230, 289], [230, 298], [231, 237], [231, 258], [231, 276], [231, 288], [231, 290], [231, 294], [232, 243], [232, 249], [232, 253], [232, 257], [232, 266], [232, 271], [232, 293], [233, 257], [233, 264], [233, 275], [233, 277], [233, 298], [234, 239], [234, 258], [234, 259], [234, 270], [234, 285], [234, 290], [234, 292], [235, 239], [235, 263], [235, 268], [235, 289], [236, 259], [236, 262], [236, 269], [236, 294], [237, 250], [237, 252], [237, 263], [238, 249], [238, 250], [238, 267], [238, 295], [238, 296], [239, 258], [239, 263], [239, 283], [239, 288], [240, 241], [240, 285], [241, 248], [241, 255], [242, 244], [242, 293], [243, 253], [243, 261], [243, 266], [243, 273], [243, 276], [244, 260], [244, 264], [244, 298], [245, 265], [245, 272], [245, 295], [246, 256], [246, 276], [246, 296], [247, 253], [247, 267], [247, 285], [248, 258], [248, 281], [249, 289], [249, 298], [250, 252], [250, 259], [250, 283], [250, 288], [252, 260], [252, 279], [252, 288], [252, 292], [252, 294], [253, 264], [253, 265], [253, 274], [253, 275], [253, 286], [253, 292], [253, 293], [253, 297], [254, 260], [255, 276], [255, 285], [255, 289], [255, 294], [256, 259], [256, 260], [256, 277], [256, 288], [256, 295], [257, 273], [257, 290], [258, 280], [258, 287], [259, 287], [259, 293], [260, 261], [260, 273], [260, 291], [261, 262], [261, 263], [261, 286], [261, 296], [262, 273], [263, 278], [263, 282], [263, 296], [264, 285], [265, 299], [266, 292], [267, 271], [267, 272], [268, 274], [268, 284], [268, 285], [268, 291], [269, 279], [269, 299], [270, 274], [271, 272], [271, 273], [271, 276], [271, 279], [271, 284], [273, 275], [273, 277], [274, 286], [274, 293], [275, 286], [275, 289], [275, 295], [276, 284], [276, 290], [276, 293], [277, 282], [277, 295], [278, 287], [278, 293], [278, 295], [279, 287], [281, 282], [281, 285], [281, 287], [282, 287], [283, 288], [283, 296], [284, 288], [284, 297], [285, 287], [287, 291], [288, 293], [288, 294], [288, 297], [288, 299], [289, 291], [289, 292], [292, 293]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s8/solution/solve.sh b/tasks/construct-nppc-dominating-set-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f94a6e8c02bf28f2ea26b903cc515c02d822117 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"dominating_set": [10, 24, 37, 46, 47, 55, 64, 97, 108, 137, 141, 163, 179, 194, 200, 222, 250, 253, 264, 287]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l6-s8/tests/check.py b/tasks/construct-nppc-dominating-set-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s8/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l6-s8/tests/instance.json b/tasks/construct-nppc-dominating-set-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9785e808c9dcc2fd30d5adb00946bb1ce02919fb --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 8], [0, 25], [0, 32], [0, 35], [0, 40], [0, 72], [0, 93], [0, 103], [0, 107], [0, 119], [0, 123], [0, 152], [0, 163], [0, 214], [0, 217], [0, 251], [0, 284], [0, 295], [1, 6], [1, 19], [1, 30], [1, 42], [1, 52], [1, 54], [1, 64], [1, 68], [1, 74], [1, 81], [1, 100], [1, 116], [1, 122], [1, 137], [1, 150], [1, 167], [1, 195], [1, 203], [1, 212], [1, 235], [1, 252], [1, 262], [2, 31], [2, 42], [2, 47], [2, 49], [2, 61], [2, 132], [2, 148], [2, 191], [2, 209], [2, 217], [2, 250], [2, 293], [3, 7], [3, 25], [3, 34], [3, 41], [3, 62], [3, 75], [3, 77], [3, 89], [3, 113], [3, 133], [3, 141], [3, 147], [3, 149], [3, 151], [3, 156], [3, 158], [3, 170], [3, 181], [3, 198], [3, 202], [3, 210], [3, 218], [3, 222], [3, 226], [3, 228], [3, 242], [3, 254], [3, 261], [3, 281], [3, 293], [4, 17], [4, 32], [4, 56], [4, 75], [4, 147], [4, 150], [4, 151], [4, 153], [4, 171], [4, 245], [4, 251], [4, 260], [4, 263], [4, 264], [4, 275], [4, 283], [4, 286], [5, 10], [5, 11], [5, 15], [5, 25], [5, 26], [5, 30], [5, 42], [5, 43], [5, 46], [5, 60], [5, 97], [5, 98], [5, 99], [5, 104], [5, 119], [5, 142], [5, 143], [5, 159], [5, 190], [5, 209], [5, 253], [5, 271], [5, 275], [5, 276], [5, 278], [5, 282], [6, 8], [6, 12], [6, 34], [6, 39], [6, 69], [6, 80], [6, 105], [6, 143], [6, 165], [6, 174], [6, 184], [6, 200], [6, 202], [6, 215], [6, 237], [6, 271], [6, 286], [6, 293], [7, 22], [7, 46], [7, 80], [7, 81], [7, 94], [7, 109], [7, 139], [7, 148], [7, 162], [7, 166], [7, 169], [7, 176], [7, 179], [7, 215], [7, 240], [7, 244], [7, 251], [7, 259], [7, 282], [7, 293], [8, 57], [8, 63], [8, 94], [8, 135], [8, 136], [8, 182], [8, 194], [8, 210], [8, 233], [8, 235], [8, 236], [8, 237], [8, 241], [8, 248], [8, 275], [9, 11], [9, 16], [9, 26], [9, 42], [9, 53], [9, 64], [9, 67], [9, 89], [9, 104], [9, 113], [9, 121], [9, 136], [9, 148], [9, 154], [9, 160], [9, 183], [9, 196], [9, 201], [9, 215], [9, 224], [9, 240], [9, 245], [9, 297], [10, 33], [10, 34], [10, 64], [10, 70], [10, 88], [10, 108], [10, 110], [10, 112], [10, 113], [10, 117], [10, 127], [10, 142], [10, 143], [10, 146], [10, 156], [10, 168], [10, 178], [10, 199], [10, 210], [10, 250], [10, 274], [10, 290], [10, 297], [11, 26], [11, 27], [11, 75], [11, 83], [11, 89], [11, 94], [11, 117], [11, 137], [11, 151], [11, 200], [11, 219], [11, 287], [11, 288], [11, 290], [12, 18], [12, 34], [12, 37], [12, 39], [12, 47], [12, 71], [12, 102], [12, 115], [12, 120], [12, 136], [12, 187], [12, 211], [12, 221], [12, 225], [12, 249], [12, 256], [13, 15], [13, 45], [13, 67], [13, 79], [13, 92], [13, 102], [13, 106], [13, 116], [13, 135], [13, 146], [13, 148], [13, 159], [13, 172], [13, 174], [13, 197], [13, 198], [13, 207], [13, 249], [13, 255], [13, 273], [13, 282], [13, 287], [13, 295], [14, 23], [14, 44], [14, 47], [14, 61], [14, 67], [14, 74], [14, 86], [14, 90], [14, 95], [14, 99], [14, 110], [14, 124], [14, 133], [14, 148], [14, 163], [14, 168], [14, 189], [15, 24], [15, 38], [15, 55], [15, 63], [15, 77], [15, 147], [15, 169], [15, 181], [15, 242], [15, 258], [15, 297], [16, 37], [16, 44], [16, 69], [16, 101], [16, 118], [16, 164], [16, 184], [16, 219], [16, 235], [16, 255], [16, 281], [17, 29], [17, 33], [17, 38], [17, 40], [17, 41], [17, 55], [17, 62], [17, 70], [17, 102], [17, 103], [17, 145], [17, 183], [17, 200], [17, 222], [17, 246], [17, 248], [17, 265], [17, 272], [17, 280], [17, 297], [18, 26], [18, 59], [18, 62], [18, 69], [18, 97], [18, 108], [18, 111], [18, 117], [18, 136], [18, 146], [18, 161], [18, 167], [18, 196], [18, 216], [18, 218], [18, 264], [18, 298], [19, 24], [19, 65], [19, 115], [19, 147], [19, 148], [19, 161], [19, 171], [19, 178], [19, 195], [19, 215], [19, 235], [19, 236], [19, 243], [19, 250], [19, 262], [19, 266], [19, 267], [19, 270], [20, 33], [20, 36], [20, 40], [20, 57], [20, 84], [20, 99], [20, 113], [20, 127], [20, 154], [20, 164], [20, 200], [20, 203], [20, 206], [20, 213], [20, 242], [20, 245], [20, 266], [20, 290], [20, 294], [21, 30], [21, 54], [21, 75], [21, 112], [21, 141], [21, 155], [21, 156], [21, 180], [21, 191], [21, 227], [21, 233], [21, 250], [21, 254], [21, 257], [21, 280], [21, 281], [22, 37], [22, 76], [22, 77], [22, 79], [22, 92], [22, 93], [22, 94], [22, 98], [22, 166], [22, 175], [22, 233], [22, 261], [22, 270], [22, 273], [22, 299], [23, 27], [23, 41], [23, 49], [23, 71], [23, 84], [23, 86], [23, 128], [23, 135], [23, 163], [23, 168], [23, 176], [23, 177], [23, 178], [23, 179], [23, 198], [23, 208], [23, 217], [23, 238], [23, 259], [23, 260], [23, 266], [24, 25], [24, 32], [24, 34], [24, 39], [24, 42], [24, 48], [24, 50], [24, 69], [24, 77], [24, 80], [24, 87], [24, 146], [24, 151], [24, 168], [24, 178], [24, 195], [24, 209], [24, 228], [24, 231], [24, 247], [24, 256], [24, 260], [24, 261], [24, 280], [24, 289], [24, 295], [24, 298], [25, 47], [25, 78], [25, 99], [25, 100], [25, 105], [25, 112], [25, 117], [25, 126], [25, 179], [25, 214], [25, 227], [25, 262], [25, 268], [25, 269], [25, 270], [25, 298], [26, 37], [26, 56], [26, 78], [26, 98], [26, 110], [26, 111], [26, 112], [26, 117], [26, 118], [26, 186], [26, 188], [26, 191], [26, 222], [26, 240], [26, 250], [26, 259], [26, 283], [26, 292], [27, 30], [27, 37], [27, 64], [27, 80], [27, 92], [27, 101], [27, 106], [27, 107], [27, 112], [27, 135], [27, 145], [27, 151], [27, 159], [27, 160], [27, 176], [27, 203], [27, 205], [27, 211], [27, 264], [27, 268], [27, 279], [27, 286], [28, 51], [28, 66], [28, 67], [28, 79], [28, 85], [28, 138], [28, 148], [28, 165], [28, 171], [28, 172], [28, 178], [28, 186], [28, 191], [28, 199], [28, 222], [28, 250], [28, 251], [28, 274], [28, 286], [29, 57], [29, 65], [29, 68], [29, 76], [29, 78], [29, 104], [29, 136], [29, 139], [29, 147], [29, 150], [29, 152], [29, 157], [29, 177], [29, 187], [29, 196], [29, 200], [29, 206], [29, 277], [30, 48], [30, 57], [30, 60], [30, 76], [30, 80], [30, 93], [30, 95], [30, 99], [30, 107], [30, 114], [30, 141], [30, 171], [30, 190], [30, 192], [30, 214], [30, 220], [30, 222], [30, 241], [30, 276], [30, 278], [30, 289], [30, 294], [31, 41], [31, 46], [31, 52], [31, 60], [31, 81], [31, 100], [31, 116], [31, 117], [31, 144], [31, 168], [31, 231], [31, 264], [31, 290], [32, 75], [32, 104], [32, 127], [32, 128], [32, 132], [32, 192], [32, 206], [32, 230], [32, 249], [32, 259], [32, 291], [32, 296], [33, 53], [33, 97], [33, 99], [33, 112], [33, 130], [33, 153], [33, 160], [33, 171], [33, 173], [33, 177], [33, 181], [33, 182], [33, 198], [33, 200], [33, 204], [33, 210], [33, 228], [33, 250], [33, 269], [33, 270], [33, 276], [33, 288], [34, 42], [34, 58], [34, 71], [34, 112], [34, 119], [34, 130], [34, 133], [34, 135], [34, 157], [34, 163], [34, 178], [34, 182], [34, 218], [34, 236], [34, 256], [34, 260], [34, 267], [34, 268], [35, 56], [35, 65], [35, 76], [35, 79], [35, 93], [35, 97], [35, 118], [35, 137], [35, 162], [35, 179], [35, 207], [35, 230], [35, 239], [35, 259], [35, 260], [36, 42], [36, 64], [36, 86], [36, 90], [36, 99], [36, 102], [36, 183], [36, 203], [36, 212], [36, 214], [36, 219], [36, 222], [36, 238], [36, 245], [36, 262], [36, 287], [36, 292], [37, 41], [37, 62], [37, 67], [37, 72], [37, 75], [37, 94], [37, 95], [37, 121], [37, 123], [37, 130], [37, 165], [37, 188], [37, 189], [37, 199], [37, 204], [37, 209], [37, 220], [37, 226], [37, 227], [37, 246], [37, 248], [37, 254], [37, 293], [37, 298], [38, 45], [38, 62], [38, 81], [38, 89], [38, 96], [38, 114], [38, 137], [38, 145], [38, 147], [38, 175], [38, 178], [38, 181], [38, 211], [38, 237], [38, 255], [38, 259], [38, 262], [38, 291], [39, 64], [39, 84], [39, 88], [39, 93], [39, 95], [39, 101], [39, 107], [39, 119], [39, 128], [39, 139], [39, 152], [39, 156], [39, 181], [39, 272], [39, 299], [40, 43], [40, 57], [40, 66], [40, 71], [40, 101], [40, 109], [40, 112], [40, 113], [40, 135], [40, 197], [40, 200], [40, 201], [40, 214], [40, 217], [40, 224], [40, 275], [41, 45], [41, 59], [41, 61], [41, 66], [41, 69], [41, 89], [41, 105], [41, 110], [41, 113], [41, 119], [41, 127], [41, 133], [41, 136], [41, 161], [41, 166], [41, 177], [41, 179], [41, 223], [41, 233], [41, 237], [41, 238], [41, 257], [41, 282], [41, 286], [41, 287], [42, 60], [42, 69], [42, 75], [42, 83], [42, 93], [42, 117], [42, 158], [42, 181], [42, 194], [42, 212], [42, 248], [42, 258], [42, 263], [42, 267], [42, 268], [42, 276], [42, 277], [42, 283], [43, 49], [43, 55], [43, 88], [43, 100], [43, 104], [43, 111], [43, 136], [43, 149], [43, 181], [43, 187], [43, 190], [43, 203], [43, 221], [43, 251], [43, 284], [44, 59], [44, 89], [44, 108], [44, 118], [44, 123], [44, 124], [44, 125], [44, 128], [44, 146], [44, 151], [44, 213], [44, 243], [44, 269], [44, 273], [44, 274], [44, 286], [45, 50], [45, 60], [45, 77], [45, 88], [45, 110], [45, 112], [45, 120], [45, 147], [45, 161], [45, 163], [45, 170], [45, 188], [45, 209], [45, 283], [46, 53], [46, 97], [46, 106], [46, 108], [46, 109], [46, 112], [46, 118], [46, 123], [46, 139], [46, 146], [46, 164], [46, 165], [46, 166], [46, 171], [46, 180], [46, 189], [46, 225], [46, 229], [46, 230], [46, 233], [46, 237], [46, 249], [46, 257], [46, 260], [46, 284], [47, 57], [47, 74], [47, 82], [47, 87], [47, 104], [47, 111], [47, 116], [47, 119], [47, 138], [47, 146], [47, 150], [47, 153], [47, 161], [47, 164], [47, 172], [47, 177], [47, 182], [47, 198], [47, 202], [47, 203], [47, 214], [47, 237], [47, 240], [47, 247], [47, 252], [47, 255], [47, 261], [47, 273], [47, 280], [48, 54], [48, 78], [48, 86], [48, 94], [48, 105], [48, 112], [48, 128], [48, 135], [48, 163], [48, 177], [48, 198], [48, 246], [48, 253], [49, 58], [49, 63], [49, 67], [49, 132], [49, 139], [49, 144], [49, 158], [49, 162], [49, 169], [49, 170], [49, 173], [49, 200], [49, 202], [49, 207], [49, 258], [49, 263], [49, 293], [50, 76], [50, 78], [50, 107], [50, 109], [50, 115], [50, 117], [50, 128], [50, 131], [50, 141], [50, 175], [50, 189], [50, 205], [50, 224], [50, 251], [50, 265], [50, 276], [51, 58], [51, 61], [51, 87], [51, 88], [51, 93], [51, 94], [51, 106], [51, 117], [51, 120], [51, 127], [51, 153], [51, 168], [51, 195], [51, 198], [51, 218], [51, 220], [51, 230], [51, 237], [51, 280], [51, 287], [51, 290], [51, 292], [51, 299], [52, 55], [52, 59], [52, 60], [52, 72], [52, 93], [52, 97], [52, 101], [52, 108], [52, 128], [52, 165], [52, 177], [52, 180], [52, 222], [52, 256], [52, 282], [52, 283], [53, 59], [53, 83], [53, 152], [53, 174], [53, 176], [53, 186], [53, 204], [53, 227], [53, 246], [53, 286], [53, 298], [54, 71], [54, 82], [54, 92], [54, 107], [54, 114], [54, 122], [54, 134], [54, 137], [54, 148], [54, 181], [54, 191], [54, 202], [54, 205], [54, 208], [54, 236], [54, 255], [54, 299], [55, 66], [55, 73], [55, 90], [55, 92], [55, 101], [55, 106], [55, 115], [55, 120], [55, 121], [55, 125], [55, 127], [55, 142], [55, 145], [55, 165], [55, 184], [55, 185], [55, 207], [55, 217], [55, 227], [55, 237], [55, 257], [55, 262], [55, 268], [55, 271], [55, 285], [55, 296], [55, 299], [56, 75], [56, 78], [56, 92], [56, 161], [56, 163], [56, 168], [56, 172], [56, 175], [56, 196], [56, 201], [56, 203], [56, 204], [56, 259], [56, 287], [57, 137], [57, 138], [57, 146], [57, 152], [57, 178], [57, 186], [57, 189], [57, 194], [57, 197], [57, 242], [57, 248], [57, 252], [57, 297], [58, 62], [58, 81], [58, 99], [58, 110], [58, 148], [58, 155], [58, 180], [58, 209], [58, 219], [58, 251], [58, 257], [58, 264], [58, 277], [58, 288], [58, 298], [59, 77], [59, 99], [59, 100], [59, 108], [59, 112], [59, 116], [59, 141], [59, 147], [59, 172], [59, 200], [59, 216], [59, 239], [59, 257], [59, 285], [60, 97], [60, 111], [60, 133], [60, 174], [60, 184], [60, 191], [60, 243], [60, 257], [60, 265], [61, 67], [61, 85], [61, 97], [61, 123], [61, 124], [61, 130], [61, 140], [61, 152], [61, 189], [61, 197], [61, 200], [61, 203], [61, 205], [61, 230], [61, 253], [61, 255], [61, 262], [61, 263], [61, 264], [61, 272], [61, 274], [61, 278], [62, 73], [62, 79], [62, 88], [62, 93], [62, 114], [62, 138], [62, 160], [62, 166], [62, 171], [62, 179], [62, 188], [62, 190], [62, 202], [62, 206], [62, 223], [62, 232], [62, 242], [62, 252], [62, 278], [63, 81], [63, 105], [63, 108], [63, 110], [63, 117], [63, 132], [63, 148], [63, 172], [63, 178], [63, 200], [63, 216], [63, 262], [63, 263], [63, 265], [64, 68], [64, 75], [64, 85], [64, 117], [64, 122], [64, 135], [64, 142], [64, 167], [64, 186], [64, 193], [64, 202], [64, 212], [64, 230], [64, 231], [64, 247], [64, 261], [64, 270], [64, 274], [64, 276], [64, 283], [64, 292], [64, 295], [64, 299], [65, 68], [65, 105], [65, 128], [65, 138], [65, 163], [65, 176], [65, 184], [65, 185], [65, 194], [65, 222], [65, 237], [65, 241], [65, 248], [65, 289], [66, 71], [66, 76], [66, 84], [66, 106], [66, 118], [66, 143], [66, 149], [66, 162], [66, 167], [66, 181], [66, 202], [66, 208], [66, 253], [66, 270], [66, 271], [67, 76], [67, 82], [67, 86], [67, 97], [67, 105], [67, 119], [67, 125], [67, 155], [67, 162], [67, 181], [67, 185], [67, 187], [67, 200], [67, 223], [67, 235], [67, 237], [67, 250], [67, 257], [67, 262], [67, 288], [67, 290], [67, 295], [68, 96], [68, 111], [68, 119], [68, 121], [68, 142], [68, 148], [68, 194], [68, 245], [68, 272], [68, 285], [68, 295], [69, 78], [69, 102], [69, 103], [69, 117], [69, 153], [69, 160], [69, 213], [69, 214], [69, 215], [69, 263], [69, 276], [69, 280], [70, 121], [70, 124], [70, 140], [70, 168], [70, 174], [70, 189], [70, 191], [70, 235], [70, 237], [70, 249], [70, 273], [70, 282], [71, 74], [71, 114], [71, 125], [71, 182], [71, 208], [71, 217], [71, 222], [71, 226], [71, 258], [72, 74], [72, 86], [72, 87], [72, 111], [72, 112], [72, 121], [72, 123], [72, 125], [72, 158], [72, 180], [72, 186], [72, 189], [72, 193], [72, 194], [72, 202], [72, 218], [72, 223], [72, 224], [72, 267], [72, 270], [73, 88], [73, 92], [73, 109], [73, 115], [73, 136], [73, 145], [73, 163], [73, 178], [73, 182], [73, 183], [73, 197], [73, 223], [73, 225], [73, 228], [73, 231], [73, 246], [73, 264], [73, 282], [74, 77], [74, 94], [74, 108], [74, 146], [74, 171], [74, 189], [74, 201], [74, 209], [74, 218], [74, 259], [74, 265], [74, 274], [74, 280], [75, 79], [75, 80], [75, 97], [75, 108], [75, 124], [75, 125], [75, 133], [75, 141], [75, 159], [75, 165], [75, 193], [75, 204], [75, 215], [75, 218], [75, 221], [75, 232], [75, 233], [75, 236], [75, 246], [75, 258], [75, 284], [75, 288], [75, 291], [76, 77], [76, 83], [76, 84], [76, 165], [76, 216], [76, 221], [76, 250], [76, 268], [76, 269], [76, 273], [76, 285], [76, 286], [76, 294], [76, 295], [76, 297], [77, 84], [77, 86], [77, 109], [77, 163], [77, 166], [77, 219], [77, 248], [77, 281], [77, 291], [77, 298], [78, 82], [78, 96], [78, 119], [78, 133], [78, 140], [78, 151], [78, 190], [78, 194], [78, 238], [78, 242], [78, 258], [78, 261], [78, 285], [79, 91], [79, 107], [79, 116], [79, 167], [79, 183], [79, 220], [79, 250], [79, 251], [79, 264], [80, 85], [80, 105], [80, 108], [80, 131], [80, 143], [80, 169], [80, 215], [80, 226], [80, 227], [80, 256], [80, 270], [80, 273], [80, 274], [80, 286], [81, 89], [81, 96], [81, 126], [81, 173], [81, 174], [81, 215], [81, 227], [81, 264], [81, 285], [81, 287], [82, 99], [82, 101], [82, 107], [82, 108], [82, 120], [82, 132], [82, 141], [82, 155], [82, 192], [82, 217], [82, 218], [82, 233], [82, 241], [82, 248], [82, 262], [82, 264], [82, 279], [82, 283], [82, 293], [83, 96], [83, 101], [83, 119], [83, 133], [83, 136], [83, 144], [83, 165], [83, 166], [83, 176], [83, 180], [83, 193], [83, 199], [83, 200], [83, 257], [83, 273], [83, 284], [83, 297], [84, 85], [84, 93], [84, 99], [84, 120], [84, 124], [84, 129], [84, 134], [84, 145], [84, 160], [84, 168], [84, 188], [84, 200], [84, 210], [84, 223], [84, 233], [84, 246], [84, 264], [84, 286], [85, 96], [85, 104], [85, 110], [85, 112], [85, 115], [85, 120], [85, 153], [85, 169], [85, 187], [85, 202], [85, 210], [85, 213], [85, 221], [85, 229], [85, 277], [85, 284], [86, 92], [86, 100], [86, 101], [86, 107], [86, 108], [86, 137], [86, 194], [86, 197], [86, 200], [86, 236], [86, 271], [86, 294], [86, 299], [87, 91], [87, 101], [87, 103], [87, 120], [87, 129], [87, 144], [87, 176], [87, 189], [87, 195], [87, 210], [87, 219], [87, 264], [87, 273], [87, 282], [87, 290], [87, 296], [88, 90], [88, 97], [88, 109], [88, 111], [88, 152], [88, 157], [88, 168], [88, 181], [88, 191], [88, 207], [88, 208], [88, 210], [88, 228], [88, 249], [88, 254], [88, 285], [88, 286], [89, 116], [89, 138], [89, 150], [89, 158], [89, 162], [89, 165], [89, 166], [89, 200], [89, 203], [89, 227], [89, 231], [89, 235], [89, 245], [89, 280], [90, 100], [90, 115], [90, 117], [90, 125], [90, 128], [90, 134], [90, 135], [90, 136], [90, 139], [90, 169], [90, 178], [90, 189], [90, 248], [90, 273], [90, 286], [91, 101], [91, 117], [91, 149], [91, 163], [91, 172], [91, 174], [91, 179], [91, 201], [91, 206], [91, 217], [91, 220], [91, 250], [92, 98], [92, 99], [92, 107], [92, 116], [92, 140], [92, 141], [92, 145], [92, 186], [92, 219], [92, 241], [92, 258], [92, 267], [92, 298], [93, 163], [93, 175], [93, 179], [93, 204], [93, 208], [93, 225], [93, 231], [93, 244], [93, 247], [93, 260], [93, 276], [93, 281], [94, 96], [94, 112], [94, 114], [94, 119], [94, 130], [94, 146], [94, 166], [94, 168], [94, 233], [94, 238], [94, 240], [94, 250], [94, 256], [94, 264], [94, 267], [94, 272], [94, 276], [95, 123], [95, 126], [95, 130], [95, 170], [95, 172], [95, 176], [95, 202], [95, 210], [95, 246], [95, 266], [95, 272], [95, 287], [95, 299], [96, 132], [96, 140], [96, 146], [96, 150], [96, 194], [96, 287], [97, 102], [97, 118], [97, 154], [97, 160], [97, 170], [97, 180], [97, 183], [97, 184], [97, 189], [97, 226], [97, 229], [97, 232], [97, 259], [97, 262], [97, 271], [97, 276], [97, 281], [97, 291], [97, 292], [98, 106], [98, 119], [98, 141], [98, 144], [98, 153], [98, 184], [98, 187], [98, 191], [98, 192], [98, 202], [98, 224], [98, 252], [98, 256], [98, 262], [98, 273], [98, 277], [99, 102], [99, 108], [99, 124], [99, 136], [99, 160], [99, 186], [99, 189], [99, 192], [99, 210], [99, 217], [99, 257], [99, 284], [99, 297], [100, 118], [100, 126], [100, 128], [100, 132], [100, 133], [100, 137], [100, 138], [100, 152], [100, 155], [100, 167], [100, 181], [100, 199], [100, 202], [100, 211], [100, 232], [100, 234], [100, 249], [100, 254], [100, 263], [100, 266], [100, 297], [101, 114], [101, 125], [101, 131], [101, 132], [101, 173], [101, 222], [101, 228], [101, 230], [101, 245], [101, 261], [101, 268], [101, 279], [101, 281], [102, 104], [102, 127], [102, 148], [102, 166], [102, 174], [102, 200], [102, 201], [102, 205], [102, 208], [102, 215], [102, 221], [102, 225], [102, 230], [102, 233], [102, 237], [102, 241], [102, 268], [102, 282], [102, 285], [102, 287], [103, 117], [103, 119], [103, 124], [103, 145], [103, 160], [103, 163], [103, 174], [103, 185], [103, 198], [103, 200], [103, 222], [103, 246], [103, 247], [103, 248], [103, 253], [103, 264], [103, 282], [104, 116], [104, 127], [104, 137], [104, 148], [104, 150], [104, 156], [104, 165], [104, 167], [104, 184], [104, 226], [104, 231], [104, 233], [104, 236], [104, 266], [104, 275], [105, 116], [105, 137], [105, 173], [105, 179], [105, 181], [105, 200], [105, 219], [105, 241], [105, 264], [105, 287], [105, 290], [105, 292], [106, 136], [106, 171], [106, 180], [106, 212], [106, 226], [106, 228], [106, 236], [106, 257], [106, 288], [107, 147], [107, 181], [107, 194], [107, 203], [107, 206], [108, 138], [108, 140], [108, 154], [108, 161], [108, 170], [108, 173], [108, 182], [108, 202], [108, 209], [108, 225], [108, 231], [108, 240], [108, 245], [108, 251], [108, 255], [108, 284], [108, 290], [108, 291], [108, 293], [109, 130], [109, 154], [109, 157], [109, 158], [109, 209], [109, 249], [109, 270], [109, 290], [110, 114], [110, 127], [110, 141], [110, 158], [110, 176], [110, 178], [110, 183], [110, 184], [110, 185], [110, 202], [110, 203], [110, 221], [110, 244], [110, 279], [110, 283], [110, 293], [111, 122], [111, 139], [111, 168], [111, 171], [111, 191], [111, 192], [111, 208], [111, 240], [111, 264], [111, 290], [112, 128], [112, 152], [112, 162], [112, 174], [112, 178], [112, 265], [112, 292], [113, 169], [113, 175], [113, 187], [113, 203], [113, 205], [113, 222], [113, 223], [113, 275], [113, 276], [113, 285], [113, 289], [114, 124], [114, 137], [114, 140], [114, 148], [114, 151], [114, 176], [114, 189], [114, 190], [114, 192], [114, 194], [114, 209], [114, 213], [114, 234], [114, 256], [114, 269], [114, 289], [115, 118], [115, 137], [115, 140], [115, 142], [115, 145], [115, 206], [115, 219], [115, 230], [115, 234], [115, 237], [115, 259], [115, 262], [115, 266], [115, 273], [115, 297], [116, 118], [116, 135], [116, 151], [116, 168], [116, 209], [116, 219], [116, 248], [116, 297], [117, 120], [117, 128], [117, 158], [117, 164], [117, 181], [117, 214], [117, 216], [117, 236], [117, 242], [117, 248], [117, 256], [117, 266], [117, 272], [117, 288], [118, 144], [118, 149], [118, 154], [118, 164], [118, 165], [118, 177], [118, 187], [118, 190], [118, 192], [118, 205], [118, 206], [118, 233], [118, 253], [119, 134], [119, 176], [119, 185], [119, 207], [119, 211], [119, 227], [119, 228], [119, 250], [119, 251], [119, 257], [120, 130], [120, 146], [120, 151], [120, 163], [120, 184], [120, 200], [120, 225], [120, 265], [120, 292], [121, 126], [121, 143], [121, 199], [121, 212], [121, 279], [122, 139], [122, 149], [122, 152], [122, 172], [122, 193], [122, 199], [122, 200], [122, 224], [122, 228], [122, 241], [122, 249], [122, 262], [122, 288], [122, 290], [123, 124], [123, 139], [123, 146], [123, 162], [123, 169], [123, 226], [123, 253], [123, 255], [123, 261], [123, 264], [123, 273], [124, 169], [124, 179], [124, 182], [124, 205], [124, 207], [124, 228], [124, 238], [124, 246], [124, 247], [124, 256], [124, 264], [124, 265], [124, 286], [125, 159], [125, 164], [125, 173], [125, 235], [125, 253], [125, 262], [125, 267], [125, 268], [125, 279], [125, 281], [126, 163], [126, 198], [126, 227], [126, 241], [126, 249], [126, 262], [126, 268], [126, 279], [127, 147], [127, 169], [127, 172], [127, 186], [127, 198], [127, 201], [127, 203], [127, 205], [127, 210], [127, 260], [127, 263], [127, 264], [127, 272], [127, 299], [128, 138], [128, 147], [128, 175], [128, 195], [128, 197], [128, 209], [128, 222], [128, 231], [128, 263], [128, 294], [129, 156], [129, 164], [129, 167], [129, 194], [129, 202], [129, 205], [129, 245], [129, 267], [129, 274], [129, 293], [130, 132], [130, 145], [130, 153], [130, 174], [130, 210], [130, 236], [130, 261], [130, 263], [130, 274], [130, 281], [130, 283], [131, 199], [131, 212], [131, 226], [131, 233], [131, 250], [131, 267], [131, 270], [132, 137], [132, 146], [132, 159], [132, 170], [132, 177], [132, 185], [132, 191], [132, 210], [132, 228], [132, 243], [132, 253], [132, 284], [133, 135], [133, 145], [133, 152], [133, 165], [133, 179], [133, 208], [133, 225], [133, 235], [133, 244], [133, 288], [133, 289], [134, 142], [134, 150], [134, 157], [134, 163], [134, 197], [134, 228], [134, 234], [134, 240], [135, 146], [135, 148], [135, 161], [135, 162], [135, 188], [135, 190], [135, 197], [135, 250], [135, 269], [135, 280], [135, 298], [136, 143], [136, 161], [136, 180], [136, 188], [136, 196], [136, 208], [136, 216], [136, 221], [136, 240], [136, 253], [136, 268], [136, 290], [136, 293], [137, 139], [137, 148], [137, 183], [137, 198], [137, 201], [137, 229], [137, 235], [137, 241], [137, 242], [137, 256], [137, 271], [137, 277], [137, 279], [137, 293], [137, 294], [138, 140], [138, 163], [138, 167], [138, 191], [138, 192], [138, 206], [138, 231], [138, 236], [138, 262], [138, 271], [138, 286], [138, 299], [139, 150], [139, 154], [139, 164], [139, 189], [139, 191], [139, 200], [139, 202], [139, 205], [139, 218], [139, 219], [139, 247], [139, 264], [139, 272], [139, 288], [139, 292], [140, 159], [140, 194], [140, 213], [140, 223], [140, 273], [141, 151], [141, 167], [141, 180], [141, 198], [141, 199], [141, 211], [141, 213], [141, 226], [141, 251], [141, 257], [141, 277], [142, 144], [142, 162], [142, 164], [142, 180], [142, 184], [142, 260], [142, 262], [142, 264], [142, 276], [142, 283], [143, 215], [143, 222], [143, 243], [143, 253], [144, 179], [144, 182], [144, 194], [144, 198], [144, 200], [144, 201], [144, 225], [144, 229], [144, 231], [144, 234], [144, 298], [145, 190], [145, 191], [145, 208], [145, 210], [145, 216], [145, 251], [145, 257], [145, 259], [145, 265], [145, 274], [145, 277], [145, 293], [146, 157], [146, 168], [146, 181], [146, 191], [146, 205], [146, 219], [146, 235], [146, 244], [146, 269], [146, 270], [147, 154], [147, 156], [147, 168], [147, 220], [147, 232], [147, 240], [147, 250], [147, 269], [147, 288], [147, 297], [148, 152], [148, 180], [148, 181], [148, 186], [148, 209], [148, 217], [148, 231], [148, 264], [149, 158], [149, 165], [149, 168], [149, 169], [149, 176], [149, 203], [149, 204], [149, 259], [149, 287], [149, 289], [150, 152], [150, 167], [150, 168], [150, 246], [150, 251], [150, 256], [150, 269], [150, 285], [150, 290], [150, 298], [151, 175], [151, 180], [151, 182], [151, 201], [151, 229], [151, 236], [151, 249], [151, 269], [151, 294], [151, 298], [152, 188], [152, 194], [152, 197], [152, 210], [152, 216], [152, 221], [152, 224], [152, 261], [152, 263], [152, 269], [152, 271], [152, 278], [153, 161], [153, 184], [153, 202], [153, 203], [153, 241], [153, 247], [153, 278], [153, 287], [153, 290], [154, 201], [154, 206], [154, 213], [154, 277], [154, 283], [154, 296], [154, 297], [155, 163], [155, 178], [155, 185], [155, 190], [155, 210], [155, 223], [155, 241], [155, 253], [155, 274], [155, 285], [156, 163], [156, 194], [156, 199], [156, 200], [156, 202], [156, 206], [156, 215], [156, 226], [156, 231], [156, 273], [156, 293], [157, 158], [157, 181], [157, 200], [157, 231], [157, 236], [157, 241], [157, 247], [157, 250], [157, 273], [158, 166], [158, 171], [158, 177], [158, 193], [158, 195], [158, 198], [158, 211], [158, 222], [158, 240], [159, 164], [159, 177], [159, 179], [159, 207], [159, 220], [159, 243], [159, 262], [159, 267], [159, 289], [159, 291], [159, 298], [159, 299], [160, 194], [160, 208], [160, 211], [160, 244], [160, 250], [160, 282], [161, 171], [161, 179], [161, 196], [161, 221], [161, 225], [161, 231], [161, 235], [161, 252], [161, 255], [161, 259], [161, 284], [161, 286], [162, 193], [162, 200], [162, 218], [162, 238], [162, 255], [162, 266], [162, 273], [162, 283], [162, 289], [163, 177], [163, 183], [163, 204], [163, 209], [163, 217], [163, 234], [163, 238], [163, 239], [163, 244], [163, 254], [163, 267], [163, 276], [163, 296], [164, 174], [164, 177], [164, 186], [164, 188], [164, 189], [164, 192], [164, 193], [164, 205], [164, 225], [165, 200], [165, 219], [165, 225], [165, 230], [165, 255], [165, 289], [166, 182], [166, 191], [166, 196], [166, 217], [166, 220], [166, 222], [166, 231], [166, 285], [167, 173], [167, 201], [167, 205], [167, 242], [167, 253], [168, 212], [168, 249], [168, 259], [168, 274], [168, 288], [169, 177], [169, 200], [169, 218], [169, 221], [169, 253], [169, 261], [169, 262], [169, 265], [169, 271], [169, 275], [169, 286], [170, 173], [170, 175], [170, 176], [170, 177], [170, 259], [170, 262], [170, 264], [170, 278], [171, 173], [171, 174], [171, 176], [171, 199], [171, 247], [171, 250], [171, 270], [171, 272], [171, 284], [171, 290], [171, 297], [172, 179], [172, 204], [172, 206], [172, 216], [172, 241], [172, 251], [172, 262], [172, 268], [172, 280], [172, 281], [172, 289], [173, 182], [173, 193], [173, 194], [173, 221], [173, 241], [173, 246], [173, 274], [173, 275], [173, 278], [173, 279], [174, 222], [174, 223], [174, 229], [174, 237], [174, 244], [174, 257], [174, 278], [174, 289], [174, 290], [175, 184], [175, 192], [175, 209], [175, 239], [175, 261], [175, 263], [175, 264], [176, 188], [176, 191], [176, 229], [176, 238], [176, 241], [176, 244], [176, 253], [176, 260], [176, 264], [176, 270], [177, 180], [177, 235], [177, 263], [178, 179], [178, 183], [178, 185], [178, 200], [178, 218], [178, 228], [178, 263], [179, 186], [179, 187], [179, 188], [179, 190], [179, 196], [179, 200], [179, 204], [179, 205], [179, 220], [179, 224], [179, 231], [179, 239], [179, 244], [179, 251], [179, 264], [179, 266], [179, 268], [180, 199], [180, 204], [180, 220], [180, 227], [180, 252], [180, 256], [180, 277], [181, 194], [181, 197], [181, 227], [181, 230], [181, 253], [181, 259], [181, 265], [182, 187], [182, 192], [182, 220], [182, 296], [183, 193], [183, 200], [183, 237], [183, 245], [183, 266], [183, 280], [183, 288], [184, 189], [184, 205], [184, 214], [184, 218], [184, 245], [184, 261], [185, 206], [185, 263], [185, 267], [185, 284], [185, 293], [185, 297], [186, 226], [186, 271], [186, 272], [186, 287], [187, 192], [187, 250], [187, 255], [187, 276], [187, 286], [188, 198], [188, 200], [188, 250], [188, 274], [189, 205], [189, 228], [189, 229], [189, 245], [189, 253], [189, 289], [190, 220], [190, 237], [191, 199], [191, 200], [191, 204], [191, 226], [192, 193], [192, 194], [192, 208], [192, 221], [192, 279], [193, 203], [193, 219], [193, 251], [193, 289], [194, 210], [194, 212], [194, 221], [194, 223], [194, 265], [194, 272], [194, 298], [195, 206], [195, 261], [195, 277], [195, 297], [196, 197], [196, 218], [196, 234], [196, 239], [196, 251], [196, 285], [197, 239], [197, 240], [197, 264], [197, 286], [198, 213], [198, 219], [198, 221], [198, 269], [198, 279], [198, 283], [198, 289], [199, 214], [199, 225], [199, 226], [199, 241], [199, 259], [199, 268], [200, 205], [200, 208], [200, 216], [200, 219], [200, 220], [200, 223], [200, 224], [200, 236], [200, 269], [200, 294], [201, 285], [201, 297], [202, 206], [202, 212], [202, 222], [202, 240], [202, 262], [202, 279], [203, 213], [203, 217], [203, 224], [203, 233], [203, 252], [203, 262], [203, 265], [203, 275], [203, 299], [204, 220], [204, 244], [204, 245], [204, 266], [204, 286], [205, 213], [205, 223], [205, 243], [205, 280], [205, 283], [205, 289], [206, 230], [206, 235], [206, 261], [206, 264], [206, 271], [206, 280], [206, 295], [207, 224], [207, 236], [207, 246], [208, 212], [208, 227], [208, 238], [208, 264], [208, 295], [208, 297], [209, 214], [209, 237], [209, 239], [209, 262], [209, 272], [209, 290], [210, 220], [210, 227], [210, 242], [210, 250], [210, 253], [210, 273], [210, 293], [211, 222], [211, 235], [211, 245], [211, 253], [211, 256], [211, 262], [211, 277], [211, 283], [211, 293], [212, 214], [212, 219], [212, 226], [212, 236], [212, 239], [212, 272], [213, 221], [213, 285], [214, 222], [214, 254], [214, 273], [214, 292], [214, 299], [215, 222], [215, 231], [215, 256], [215, 264], [215, 271], [215, 275], [215, 298], [216, 221], [216, 298], [217, 228], [217, 231], [217, 234], [217, 235], [217, 244], [217, 290], [218, 241], [218, 245], [218, 248], [218, 250], [218, 254], [218, 278], [218, 283], [219, 270], [219, 294], [220, 232], [220, 250], [220, 257], [220, 259], [221, 225], [221, 244], [221, 248], [221, 259], [221, 267], [222, 238], [222, 261], [222, 263], [222, 270], [223, 244], [223, 266], [223, 293], [224, 249], [224, 250], [224, 272], [225, 237], [225, 245], [225, 266], [225, 293], [226, 234], [226, 256], [226, 273], [227, 242], [227, 246], [227, 264], [227, 267], [227, 273], [227, 296], [228, 232], [229, 233], [229, 253], [229, 261], [230, 232], [230, 233], [230, 251], [230, 278], [230, 288], [230, 289], [230, 298], [231, 237], [231, 258], [231, 276], [231, 288], [231, 290], [231, 294], [232, 243], [232, 249], [232, 253], [232, 257], [232, 266], [232, 271], [232, 293], [233, 257], [233, 264], [233, 275], [233, 277], [233, 298], [234, 239], [234, 258], [234, 259], [234, 270], [234, 285], [234, 290], [234, 292], [235, 239], [235, 263], [235, 268], [235, 289], [236, 259], [236, 262], [236, 269], [236, 294], [237, 250], [237, 252], [237, 263], [238, 249], [238, 250], [238, 267], [238, 295], [238, 296], [239, 258], [239, 263], [239, 283], [239, 288], [240, 241], [240, 285], [241, 248], [241, 255], [242, 244], [242, 293], [243, 253], [243, 261], [243, 266], [243, 273], [243, 276], [244, 260], [244, 264], [244, 298], [245, 265], [245, 272], [245, 295], [246, 256], [246, 276], [246, 296], [247, 253], [247, 267], [247, 285], [248, 258], [248, 281], [249, 289], [249, 298], [250, 252], [250, 259], [250, 283], [250, 288], [252, 260], [252, 279], [252, 288], [252, 292], [252, 294], [253, 264], [253, 265], [253, 274], [253, 275], [253, 286], [253, 292], [253, 293], [253, 297], [254, 260], [255, 276], [255, 285], [255, 289], [255, 294], [256, 259], [256, 260], [256, 277], [256, 288], [256, 295], [257, 273], [257, 290], [258, 280], [258, 287], [259, 287], [259, 293], [260, 261], [260, 273], [260, 291], [261, 262], [261, 263], [261, 286], [261, 296], [262, 273], [263, 278], [263, 282], [263, 296], [264, 285], [265, 299], [266, 292], [267, 271], [267, 272], [268, 274], [268, 284], [268, 285], [268, 291], [269, 279], [269, 299], [270, 274], [271, 272], [271, 273], [271, 276], [271, 279], [271, 284], [273, 275], [273, 277], [274, 286], [274, 293], [275, 286], [275, 289], [275, 295], [276, 284], [276, 290], [276, 293], [277, 282], [277, 295], [278, 287], [278, 293], [278, 295], [279, 287], [281, 282], [281, 285], [281, 287], [282, 287], [283, 288], [283, 296], [284, 288], [284, 297], [285, 287], [287, 291], [288, 293], [288, 294], [288, 297], [288, 299], [289, 291], [289, 292], [292, 293]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s8/tests/run.py b/tasks/construct-nppc-dominating-set-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l6-s8/tests/test.sh b/tasks/construct-nppc-dominating-set-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l3-s1/environment/Dockerfile b/tasks/construct-nppc-independent-set-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l3-s1/environment/instance.json b/tasks/construct-nppc-independent-set-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d1cdebae072d0cf9b69d29e812c9083d2c43ede7 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 7], [0, 8], [0, 11], [0, 14], [0, 15], [0, 16], [0, 19], [0, 20], [0, 21], [0, 23], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 15], [1, 16], [1, 19], [2, 3], [2, 4], [2, 6], [2, 16], [2, 18], [2, 20], [2, 22], [3, 5], [3, 10], [3, 15], [3, 16], [3, 19], [3, 20], [3, 22], [3, 23], [4, 5], [4, 7], [4, 12], [4, 14], [4, 16], [4, 20], [4, 23], [5, 16], [5, 17], [5, 20], [5, 22], [6, 7], [6, 11], [6, 12], [6, 16], [6, 18], [6, 20], [6, 22], [6, 23], [7, 10], [7, 15], [7, 16], [7, 17], [7, 18], [7, 22], [8, 16], [8, 20], [8, 22], [9, 15], [9, 16], [9, 18], [9, 20], [9, 22], [10, 13], [10, 14], [10, 16], [10, 20], [10, 21], [11, 15], [12, 22], [13, 16], [13, 17], [14, 20], [14, 22], [15, 16], [15, 18], [15, 19], [15, 20], [15, 21], [15, 23], [16, 17], [16, 19], [16, 21], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [18, 19], [18, 20], [18, 21], [18, 23], [20, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s1/solution/solve.sh b/tasks/construct-nppc-independent-set-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea9578aa4f1b9255eeac7ef11101ddc11eccdf4e --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [2, 5, 7, 8, 9, 11, 12, 13, 14, 19, 21, 23]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l3-s1/tests/check.py b/tasks/construct-nppc-independent-set-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s1/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l3-s1/tests/instance.json b/tasks/construct-nppc-independent-set-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d1cdebae072d0cf9b69d29e812c9083d2c43ede7 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 7], [0, 8], [0, 11], [0, 14], [0, 15], [0, 16], [0, 19], [0, 20], [0, 21], [0, 23], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 15], [1, 16], [1, 19], [2, 3], [2, 4], [2, 6], [2, 16], [2, 18], [2, 20], [2, 22], [3, 5], [3, 10], [3, 15], [3, 16], [3, 19], [3, 20], [3, 22], [3, 23], [4, 5], [4, 7], [4, 12], [4, 14], [4, 16], [4, 20], [4, 23], [5, 16], [5, 17], [5, 20], [5, 22], [6, 7], [6, 11], [6, 12], [6, 16], [6, 18], [6, 20], [6, 22], [6, 23], [7, 10], [7, 15], [7, 16], [7, 17], [7, 18], [7, 22], [8, 16], [8, 20], [8, 22], [9, 15], [9, 16], [9, 18], [9, 20], [9, 22], [10, 13], [10, 14], [10, 16], [10, 20], [10, 21], [11, 15], [12, 22], [13, 16], [13, 17], [14, 20], [14, 22], [15, 16], [15, 18], [15, 19], [15, 20], [15, 21], [15, 23], [16, 17], [16, 19], [16, 21], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [18, 19], [18, 20], [18, 21], [18, 23], [20, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s1/tests/run.py b/tasks/construct-nppc-independent-set-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l3-s1/tests/test.sh b/tasks/construct-nppc-independent-set-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l3-s6/environment/Dockerfile b/tasks/construct-nppc-independent-set-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l3-s6/environment/instance.json b/tasks/construct-nppc-independent-set-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..798062eb022fee61fcedd7d8a45ec74ebb994d48 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 6], [0, 8], [0, 9], [0, 11], [0, 14], [0, 21], [0, 22], [0, 23], [1, 3], [1, 7], [1, 10], [1, 11], [1, 12], [1, 16], [1, 17], [1, 19], [1, 20], [1, 21], [2, 3], [2, 4], [2, 5], [2, 7], [2, 8], [2, 14], [2, 16], [2, 18], [2, 19], [2, 20], [2, 23], [3, 4], [3, 5], [3, 9], [3, 21], [4, 10], [4, 11], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 20], [5, 8], [5, 15], [5, 18], [5, 20], [5, 22], [6, 9], [6, 10], [6, 16], [6, 17], [7, 10], [7, 13], [7, 16], [7, 17], [8, 9], [8, 13], [8, 16], [8, 17], [9, 11], [9, 12], [9, 14], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [10, 11], [10, 12], [10, 14], [10, 16], [10, 18], [10, 20], [10, 21], [11, 14], [11, 15], [11, 17], [11, 18], [11, 19], [11, 23], [12, 17], [12, 21], [13, 18], [13, 19], [13, 22], [13, 23], [16, 18], [16, 19], [16, 21], [17, 19], [17, 20], [17, 22], [17, 23], [21, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s6/solution/solve.sh b/tasks/construct-nppc-independent-set-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..44c425625b0446796e5b4aba8aa58289d5f8dd3b --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [3, 6, 7, 8, 12, 14, 15, 18, 19, 20, 22, 23]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l3-s6/tests/check.py b/tasks/construct-nppc-independent-set-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s6/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l3-s6/tests/instance.json b/tasks/construct-nppc-independent-set-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..798062eb022fee61fcedd7d8a45ec74ebb994d48 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 6], [0, 8], [0, 9], [0, 11], [0, 14], [0, 21], [0, 22], [0, 23], [1, 3], [1, 7], [1, 10], [1, 11], [1, 12], [1, 16], [1, 17], [1, 19], [1, 20], [1, 21], [2, 3], [2, 4], [2, 5], [2, 7], [2, 8], [2, 14], [2, 16], [2, 18], [2, 19], [2, 20], [2, 23], [3, 4], [3, 5], [3, 9], [3, 21], [4, 10], [4, 11], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 20], [5, 8], [5, 15], [5, 18], [5, 20], [5, 22], [6, 9], [6, 10], [6, 16], [6, 17], [7, 10], [7, 13], [7, 16], [7, 17], [8, 9], [8, 13], [8, 16], [8, 17], [9, 11], [9, 12], [9, 14], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [10, 11], [10, 12], [10, 14], [10, 16], [10, 18], [10, 20], [10, 21], [11, 14], [11, 15], [11, 17], [11, 18], [11, 19], [11, 23], [12, 17], [12, 21], [13, 18], [13, 19], [13, 22], [13, 23], [16, 18], [16, 19], [16, 21], [17, 19], [17, 20], [17, 22], [17, 23], [21, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s6/tests/run.py b/tasks/construct-nppc-independent-set-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l3-s6/tests/test.sh b/tasks/construct-nppc-independent-set-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l3-s8/environment/Dockerfile b/tasks/construct-nppc-independent-set-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l3-s8/environment/instance.json b/tasks/construct-nppc-independent-set-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3a1d012f76676f5c195c8a455dc149c5a728c34 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 20], [0, 21], [0, 22], [0, 23], [1, 4], [1, 5], [1, 6], [1, 8], [1, 10], [1, 11], [1, 13], [1, 14], [1, 15], [1, 16], [1, 19], [1, 23], [2, 3], [2, 12], [2, 15], [2, 17], [2, 23], [3, 4], [3, 7], [3, 8], [3, 9], [3, 11], [3, 13], [3, 14], [3, 21], [3, 22], [3, 23], [4, 8], [4, 10], [4, 16], [4, 17], [4, 23], [5, 7], [5, 8], [5, 14], [5, 17], [5, 18], [5, 21], [6, 8], [6, 10], [6, 12], [6, 16], [6, 18], [7, 8], [7, 10], [7, 12], [7, 17], [7, 18], [8, 10], [8, 11], [8, 12], [8, 18], [8, 21], [8, 22], [8, 23], [9, 12], [9, 15], [9, 18], [10, 13], [10, 14], [10, 15], [10, 18], [10, 20], [10, 21], [10, 22], [10, 23], [11, 15], [11, 16], [11, 17], [11, 18], [12, 14], [12, 15], [12, 16], [12, 18], [13, 15], [13, 16], [13, 23], [14, 15], [14, 16], [14, 23], [15, 17], [15, 19], [15, 20], [15, 22], [16, 18], [16, 19], [16, 20], [16, 21], [17, 19], [17, 20], [17, 22], [18, 19], [18, 20], [18, 21], [18, 23], [20, 23], [21, 23], [22, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s8/solution/solve.sh b/tasks/construct-nppc-independent-set-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c01388a0628349f6e0550c57a350ac2e1a6f665c --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [2, 4, 6, 7, 9, 11, 13, 14, 19, 20, 21, 22]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l3-s8/tests/check.py b/tasks/construct-nppc-independent-set-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s8/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l3-s8/tests/instance.json b/tasks/construct-nppc-independent-set-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3a1d012f76676f5c195c8a455dc149c5a728c34 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 20], [0, 21], [0, 22], [0, 23], [1, 4], [1, 5], [1, 6], [1, 8], [1, 10], [1, 11], [1, 13], [1, 14], [1, 15], [1, 16], [1, 19], [1, 23], [2, 3], [2, 12], [2, 15], [2, 17], [2, 23], [3, 4], [3, 7], [3, 8], [3, 9], [3, 11], [3, 13], [3, 14], [3, 21], [3, 22], [3, 23], [4, 8], [4, 10], [4, 16], [4, 17], [4, 23], [5, 7], [5, 8], [5, 14], [5, 17], [5, 18], [5, 21], [6, 8], [6, 10], [6, 12], [6, 16], [6, 18], [7, 8], [7, 10], [7, 12], [7, 17], [7, 18], [8, 10], [8, 11], [8, 12], [8, 18], [8, 21], [8, 22], [8, 23], [9, 12], [9, 15], [9, 18], [10, 13], [10, 14], [10, 15], [10, 18], [10, 20], [10, 21], [10, 22], [10, 23], [11, 15], [11, 16], [11, 17], [11, 18], [12, 14], [12, 15], [12, 16], [12, 18], [13, 15], [13, 16], [13, 23], [14, 15], [14, 16], [14, 23], [15, 17], [15, 19], [15, 20], [15, 22], [16, 18], [16, 19], [16, 20], [16, 21], [17, 19], [17, 20], [17, 22], [18, 19], [18, 20], [18, 21], [18, 23], [20, 23], [21, 23], [22, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s8/tests/run.py b/tasks/construct-nppc-independent-set-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l3-s8/tests/test.sh b/tasks/construct-nppc-independent-set-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l2-s0/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l2-s0/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ff19c2337f2d2b9ca0b81b07b2b0fb971be4ea28 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"a": 549, "b": 298, "c": 388500505, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s0/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c4df2267fe238da83c37bc18ca6fa1237b7bf3e0 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 841, "y": 682} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l2-s0/tests/check.py b/tasks/construct-nppc-quad-diophantine-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s0/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l2-s0/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ff19c2337f2d2b9ca0b81b07b2b0fb971be4ea28 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"a": 549, "b": 298, "c": 388500505, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s0/tests/run.py b/tasks/construct-nppc-quad-diophantine-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l2-s0/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l2-s7/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l2-s7/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd2abdbaf0b79a2736d0293420eede51179820b5 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"a": 826, "b": 935, "c": 347643869, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s7/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0d2575398ff70f93f5ea3dfd7b4e7af5a13be5bf --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 648, "y": 859} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l2-s7/tests/check.py b/tasks/construct-nppc-quad-diophantine-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s7/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l2-s7/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd2abdbaf0b79a2736d0293420eede51179820b5 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"a": 826, "b": 935, "c": 347643869, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s7/tests/run.py b/tasks/construct-nppc-quad-diophantine-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l2-s7/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l2-s9/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l2-s9/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..21225ab2893cfc138c84423847c1427eb9d8e4c7 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"a": 760, "b": 418, "c": 187894458, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s9/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..21fa0ea6fb21a111e5e9d0becc82a26ad1d911df --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 497, "y": 401} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l2-s9/tests/check.py b/tasks/construct-nppc-quad-diophantine-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s9/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l2-s9/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..21225ab2893cfc138c84423847c1427eb9d8e4c7 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"a": 760, "b": 418, "c": 187894458, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s9/tests/run.py b/tasks/construct-nppc-quad-diophantine-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l2-s9/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l6-s1/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l6-s1/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..794cf35603e20997446f84012cd95b302a1dbae3 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"a": 3308500998, "b": 9524488904, "c": 5031832088770617016907664376, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s1/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d3e0a88b8f50a6750e64458ce56b6451f24b4281 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 1233239524, "y": 582547307} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l6-s1/tests/check.py b/tasks/construct-nppc-quad-diophantine-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s1/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l6-s1/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..794cf35603e20997446f84012cd95b302a1dbae3 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"a": 3308500998, "b": 9524488904, "c": 5031832088770617016907664376, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s1/tests/run.py b/tasks/construct-nppc-quad-diophantine-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l6-s1/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l6-s6/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l6-s6/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c796676adb87debc561e6d9d670f060adf22b08d --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"a": 7705139195, "b": 2778365384, "c": 709528365362096612891392679019, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s6/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..29e49ece8955839f7551a550f5f24f047cf15abb --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 9596097165, "y": 5162045391} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l6-s6/tests/check.py b/tasks/construct-nppc-quad-diophantine-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s6/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l6-s6/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c796676adb87debc561e6d9d670f060adf22b08d --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"a": 7705139195, "b": 2778365384, "c": 709528365362096612891392679019, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s6/tests/run.py b/tasks/construct-nppc-quad-diophantine-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l6-s6/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l6-s8/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l6-s8/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..89a837e1a1e26cceef7e865a94b8b84a4c30abee --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"a": 6146000422, "b": 1960459692, "c": 251173296283535903833923124060, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s8/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f3f2ea7a40706285ab972f4e5e387fa633b30e8 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 6392790020, "y": 9924865405} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l6-s8/tests/check.py b/tasks/construct-nppc-quad-diophantine-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s8/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l6-s8/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..89a837e1a1e26cceef7e865a94b8b84a4c30abee --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"a": 6146000422, "b": 1960459692, "c": 251173296283535903833923124060, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s8/tests/run.py b/tasks/construct-nppc-quad-diophantine-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l6-s8/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s0/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s0/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..74d5d990af612da5fef7fc4f312de58075bb25c6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"a": 3645, "b": 9801, "c": 13428, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s0/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..602fd6126a2607dc74251916940d1748893c1157 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 3474} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..74d5d990af612da5fef7fc4f312de58075bb25c6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"a": 3645, "b": 9801, "c": 13428, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s7/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s7/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f02557e7903ddeae4020f5a0d9a4193a560bbf76 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"a": 1689, "b": 6784, "c": 11336, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s7/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..08054385123a3a56931853e252b5ecd5e83fdb6b --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 1349} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f02557e7903ddeae4020f5a0d9a4193a560bbf76 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"a": 1689, "b": 6784, "c": 11336, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s9/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s9/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1c09d530dfc2b704099a6f07e28e86f5c8e070a0 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"a": 193, "b": 236, "c": 4167, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s9/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..77b52898dddca11bcc31ba48cdb6c05952a2922a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 1235} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1c09d530dfc2b704099a6f07e28e86f5c8e070a0 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"a": 193, "b": 236, "c": 4167, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s1/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s1/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..664521c99a62b41c3438cd9b0346b0a499c16159 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"a": 56971645208274324388161791583706293536497471683, "b": 178767624844011001516469591730795906116766759349, "c": 177087527427745295577607238672554831430928095168, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s1/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..246c4116b890621fe35e6a4c036432f6a63522a3 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 177081166447422316793371438406633507409738315106} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..664521c99a62b41c3438cd9b0346b0a499c16159 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"a": 56971645208274324388161791583706293536497471683, "b": 178767624844011001516469591730795906116766759349, "c": 177087527427745295577607238672554831430928095168, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s6/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s6/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e3fd36bbfff02e96a98def77d1ff4ecef4c7e382 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"a": 11192067037090352334951661408803249306769261793, "b": 79169842608946254330773699028375623815776039893, "c": 33519316894089097533880334306886325399338659963, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s6/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e574a50d84c9b8464c466339c99a2efa32b772ce --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 33516363461005447307033998190117305949956576999} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e3fd36bbfff02e96a98def77d1ff4ecef4c7e382 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"a": 11192067037090352334951661408803249306769261793, "b": 79169842608946254330773699028375623815776039893, "c": 33519316894089097533880334306886325399338659963, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s8/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s8/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c27bd1975c5a9fe23771b29aa1e88127db753332 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"a": 89728043748840914874583959461029348010361798650, "b": 110563576442392745193097775043744294746082258649, "c": 24626609658804355909636411953818077473565084769, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s8/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f7572a4f21dce83b212a6c25f7749860139af6d4 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 24625282150616629253534138003686707079318217308} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c27bd1975c5a9fe23771b29aa1e88127db753332 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"a": 89728043748840914874583959461029348010361798650, "b": 110563576442392745193097775043744294746082258649, "c": 24626609658804355909636411953818077473565084769, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-vertex-cover-l4-s3/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-vertex-cover-l4-s3/environment/instance.json b/tasks/construct-nppc-vertex-cover-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd14454bc84f579dda564312c41cb9d97d96c517 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 4], [0, 8], [0, 17], [0, 21], [0, 24], [0, 27], [0, 28], [0, 29], [0, 37], [0, 39], [1, 3], [1, 6], [1, 8], [1, 11], [1, 12], [1, 14], [1, 17], [1, 20], [1, 21], [1, 23], [1, 26], [1, 27], [1, 39], [2, 6], [2, 11], [2, 12], [2, 17], [2, 24], [2, 27], [2, 28], [2, 29], [2, 37], [3, 6], [3, 8], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 19], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 33], [3, 34], [3, 35], [3, 36], [3, 39], [4, 5], [4, 6], [4, 7], [4, 9], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 23], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 34], [4, 35], [4, 38], [4, 39], [5, 8], [5, 11], [5, 16], [5, 21], [5, 23], [5, 24], [5, 28], [5, 33], [5, 39], [6, 7], [6, 8], [6, 12], [6, 13], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 23], [6, 24], [6, 25], [6, 26], [6, 28], [6, 30], [6, 33], [6, 34], [6, 37], [6, 38], [7, 11], [7, 12], [7, 14], [7, 16], [7, 17], [7, 20], [7, 28], [8, 9], [8, 12], [8, 13], [8, 14], [8, 16], [8, 17], [8, 19], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 39], [9, 12], [9, 14], [9, 16], [9, 17], [9, 20], [9, 24], [9, 27], [9, 33], [9, 39], [10, 14], [10, 17], [10, 20], [10, 21], [10, 27], [10, 29], [10, 37], [10, 39], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 22], [11, 23], [11, 24], [11, 27], [11, 33], [11, 34], [11, 36], [11, 37], [11, 39], [12, 13], [12, 14], [12, 16], [12, 17], [12, 18], [12, 20], [12, 21], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 32], [12, 33], [12, 35], [12, 37], [12, 39], [13, 20], [13, 23], [13, 26], [13, 27], [13, 29], [13, 33], [14, 15], [14, 17], [14, 18], [14, 20], [14, 21], [14, 24], [14, 26], [14, 28], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 37], [14, 38], [14, 39], [15, 16], [15, 17], [15, 20], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [15, 37], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 29], [16, 30], [16, 33], [16, 36], [16, 37], [16, 39], [17, 19], [17, 20], [17, 21], [17, 22], [17, 26], [17, 27], [17, 28], [17, 31], [17, 33], [17, 34], [17, 37], [17, 38], [18, 20], [18, 21], [18, 24], [18, 27], [19, 21], [19, 23], [19, 24], [19, 26], [19, 29], [19, 33], [19, 37], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 33], [20, 36], [20, 37], [20, 38], [20, 39], [21, 23], [21, 24], [21, 26], [21, 27], [21, 28], [21, 29], [21, 31], [21, 32], [21, 37], [21, 38], [21, 39], [22, 23], [22, 26], [22, 27], [22, 29], [22, 33], [22, 39], [23, 25], [23, 26], [23, 27], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 38], [23, 39], [24, 25], [24, 29], [24, 30], [24, 32], [24, 33], [24, 35], [24, 37], [24, 39], [25, 29], [25, 39], [26, 27], [26, 28], [26, 29], [26, 30], [26, 32], [26, 33], [26, 34], [26, 36], [26, 37], [26, 38], [27, 28], [27, 35], [27, 36], [27, 39], [28, 29], [28, 30], [28, 31], [28, 36], [28, 37], [29, 30], [29, 33], [29, 36], [29, 37], [29, 39], [30, 37], [30, 39], [31, 33], [33, 38], [33, 39], [34, 37], [34, 39], [35, 39], [36, 37], [36, 39], [37, 38], [37, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s3/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..96b0e88847033e169d0dd2fb611e078da60f0315 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [3, 4, 6, 8, 11, 12, 14, 16, 17, 20, 21, 23, 24, 26, 27, 28, 29, 33, 37, 39]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l4-s3/tests/check.py b/tasks/construct-nppc-vertex-cover-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s3/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l4-s3/tests/instance.json b/tasks/construct-nppc-vertex-cover-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd14454bc84f579dda564312c41cb9d97d96c517 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 4], [0, 8], [0, 17], [0, 21], [0, 24], [0, 27], [0, 28], [0, 29], [0, 37], [0, 39], [1, 3], [1, 6], [1, 8], [1, 11], [1, 12], [1, 14], [1, 17], [1, 20], [1, 21], [1, 23], [1, 26], [1, 27], [1, 39], [2, 6], [2, 11], [2, 12], [2, 17], [2, 24], [2, 27], [2, 28], [2, 29], [2, 37], [3, 6], [3, 8], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 19], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 33], [3, 34], [3, 35], [3, 36], [3, 39], [4, 5], [4, 6], [4, 7], [4, 9], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 23], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 34], [4, 35], [4, 38], [4, 39], [5, 8], [5, 11], [5, 16], [5, 21], [5, 23], [5, 24], [5, 28], [5, 33], [5, 39], [6, 7], [6, 8], [6, 12], [6, 13], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 23], [6, 24], [6, 25], [6, 26], [6, 28], [6, 30], [6, 33], [6, 34], [6, 37], [6, 38], [7, 11], [7, 12], [7, 14], [7, 16], [7, 17], [7, 20], [7, 28], [8, 9], [8, 12], [8, 13], [8, 14], [8, 16], [8, 17], [8, 19], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 39], [9, 12], [9, 14], [9, 16], [9, 17], [9, 20], [9, 24], [9, 27], [9, 33], [9, 39], [10, 14], [10, 17], [10, 20], [10, 21], [10, 27], [10, 29], [10, 37], [10, 39], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 22], [11, 23], [11, 24], [11, 27], [11, 33], [11, 34], [11, 36], [11, 37], [11, 39], [12, 13], [12, 14], [12, 16], [12, 17], [12, 18], [12, 20], [12, 21], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 32], [12, 33], [12, 35], [12, 37], [12, 39], [13, 20], [13, 23], [13, 26], [13, 27], [13, 29], [13, 33], [14, 15], [14, 17], [14, 18], [14, 20], [14, 21], [14, 24], [14, 26], [14, 28], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 37], [14, 38], [14, 39], [15, 16], [15, 17], [15, 20], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [15, 37], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 29], [16, 30], [16, 33], [16, 36], [16, 37], [16, 39], [17, 19], [17, 20], [17, 21], [17, 22], [17, 26], [17, 27], [17, 28], [17, 31], [17, 33], [17, 34], [17, 37], [17, 38], [18, 20], [18, 21], [18, 24], [18, 27], [19, 21], [19, 23], [19, 24], [19, 26], [19, 29], [19, 33], [19, 37], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 33], [20, 36], [20, 37], [20, 38], [20, 39], [21, 23], [21, 24], [21, 26], [21, 27], [21, 28], [21, 29], [21, 31], [21, 32], [21, 37], [21, 38], [21, 39], [22, 23], [22, 26], [22, 27], [22, 29], [22, 33], [22, 39], [23, 25], [23, 26], [23, 27], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 38], [23, 39], [24, 25], [24, 29], [24, 30], [24, 32], [24, 33], [24, 35], [24, 37], [24, 39], [25, 29], [25, 39], [26, 27], [26, 28], [26, 29], [26, 30], [26, 32], [26, 33], [26, 34], [26, 36], [26, 37], [26, 38], [27, 28], [27, 35], [27, 36], [27, 39], [28, 29], [28, 30], [28, 31], [28, 36], [28, 37], [29, 30], [29, 33], [29, 36], [29, 37], [29, 39], [30, 37], [30, 39], [31, 33], [33, 38], [33, 39], [34, 37], [34, 39], [35, 39], [36, 37], [36, 39], [37, 38], [37, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s3/tests/run.py b/tasks/construct-nppc-vertex-cover-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-vertex-cover-l4-s3/tests/test.sh b/tasks/construct-nppc-vertex-cover-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-vertex-cover-l4-s4/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-vertex-cover-l4-s4/environment/instance.json b/tasks/construct-nppc-vertex-cover-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc8125c29b342153b181377dace1d38aef59db56 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 1], [0, 2], [0, 3], [0, 8], [0, 9], [0, 11], [0, 12], [0, 19], [0, 20], [0, 23], [0, 33], [0, 37], [1, 3], [1, 4], [1, 7], [1, 8], [1, 9], [1, 11], [1, 14], [1, 16], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 28], [1, 31], [1, 33], [1, 34], [1, 36], [1, 37], [1, 39], [2, 3], [2, 5], [2, 6], [2, 7], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 23], [2, 24], [2, 27], [2, 31], [2, 33], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [3, 4], [3, 8], [3, 9], [3, 11], [3, 12], [3, 13], [3, 14], [3, 16], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 26], [3, 31], [3, 32], [3, 33], [3, 34], [3, 36], [3, 37], [3, 38], [3, 39], [4, 5], [4, 6], [4, 7], [4, 9], [4, 12], [4, 13], [4, 14], [4, 15], [4, 17], [4, 19], [4, 20], [4, 21], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 31], [4, 33], [4, 36], [4, 37], [4, 39], [5, 12], [5, 18], [5, 23], [5, 25], [5, 35], [5, 37], [6, 8], [6, 9], [6, 12], [6, 19], [6, 20], [6, 33], [7, 9], [7, 18], [7, 23], [7, 25], [7, 31], [7, 33], [7, 37], [7, 39], [8, 9], [8, 10], [8, 11], [8, 13], [8, 14], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 23], [8, 25], [8, 26], [8, 29], [8, 32], [8, 33], [8, 35], [8, 37], [8, 38], [8, 39], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 17], [9, 18], [9, 19], [9, 20], [9, 23], [9, 24], [9, 25], [9, 28], [9, 31], [9, 32], [9, 33], [9, 35], [9, 36], [9, 37], [9, 38], [9, 39], [10, 12], [10, 19], [10, 20], [10, 33], [10, 35], [10, 39], [11, 12], [11, 14], [11, 16], [11, 19], [11, 22], [11, 23], [11, 26], [11, 27], [11, 29], [11, 30], [11, 31], [11, 33], [11, 34], [11, 35], [11, 36], [11, 37], [11, 38], [11, 39], [12, 13], [12, 14], [12, 16], [12, 18], [12, 19], [12, 20], [12, 21], [12, 24], [12, 25], [12, 26], [12, 27], [12, 29], [12, 31], [12, 32], [12, 33], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [13, 19], [13, 21], [13, 23], [13, 31], [13, 33], [13, 35], [14, 20], [14, 25], [14, 33], [14, 36], [14, 37], [14, 39], [15, 23], [15, 25], [15, 31], [15, 33], [15, 35], [15, 36], [15, 37], [15, 39], [16, 20], [16, 23], [16, 33], [16, 35], [17, 20], [17, 21], [17, 23], [17, 31], [17, 35], [18, 19], [18, 21], [18, 23], [18, 25], [18, 27], [18, 29], [18, 30], [18, 33], [18, 34], [18, 36], [18, 39], [19, 20], [19, 21], [19, 22], [19, 23], [19, 25], [19, 26], [19, 27], [19, 31], [19, 32], [19, 33], [19, 34], [19, 35], [19, 36], [19, 37], [20, 21], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 32], [20, 33], [20, 34], [20, 35], [20, 37], [20, 38], [20, 39], [21, 22], [21, 25], [21, 26], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 36], [21, 37], [21, 38], [22, 23], [22, 33], [22, 37], [22, 39], [23, 24], [23, 26], [23, 29], [23, 30], [23, 31], [23, 33], [23, 34], [23, 35], [23, 36], [23, 38], [23, 39], [24, 33], [24, 36], [24, 37], [25, 27], [25, 28], [25, 30], [25, 33], [25, 35], [25, 36], [25, 37], [25, 38], [26, 31], [26, 33], [26, 35], [26, 39], [27, 36], [28, 33], [28, 37], [30, 36], [30, 39], [31, 33], [31, 34], [31, 35], [31, 36], [31, 38], [31, 39], [32, 35], [32, 36], [32, 37], [32, 39], [33, 36], [33, 37], [33, 39], [34, 35], [34, 37], [35, 36], [35, 38], [37, 39], [38, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s4/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4e5a52e58c8b4fbae127ad6f6559b42e708fe00d --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [1, 2, 3, 4, 8, 9, 11, 12, 18, 19, 20, 21, 23, 25, 31, 33, 35, 36, 37, 39]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l4-s4/tests/check.py b/tasks/construct-nppc-vertex-cover-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s4/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l4-s4/tests/instance.json b/tasks/construct-nppc-vertex-cover-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc8125c29b342153b181377dace1d38aef59db56 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 1], [0, 2], [0, 3], [0, 8], [0, 9], [0, 11], [0, 12], [0, 19], [0, 20], [0, 23], [0, 33], [0, 37], [1, 3], [1, 4], [1, 7], [1, 8], [1, 9], [1, 11], [1, 14], [1, 16], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 28], [1, 31], [1, 33], [1, 34], [1, 36], [1, 37], [1, 39], [2, 3], [2, 5], [2, 6], [2, 7], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 23], [2, 24], [2, 27], [2, 31], [2, 33], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [3, 4], [3, 8], [3, 9], [3, 11], [3, 12], [3, 13], [3, 14], [3, 16], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 26], [3, 31], [3, 32], [3, 33], [3, 34], [3, 36], [3, 37], [3, 38], [3, 39], [4, 5], [4, 6], [4, 7], [4, 9], [4, 12], [4, 13], [4, 14], [4, 15], [4, 17], [4, 19], [4, 20], [4, 21], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 31], [4, 33], [4, 36], [4, 37], [4, 39], [5, 12], [5, 18], [5, 23], [5, 25], [5, 35], [5, 37], [6, 8], [6, 9], [6, 12], [6, 19], [6, 20], [6, 33], [7, 9], [7, 18], [7, 23], [7, 25], [7, 31], [7, 33], [7, 37], [7, 39], [8, 9], [8, 10], [8, 11], [8, 13], [8, 14], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 23], [8, 25], [8, 26], [8, 29], [8, 32], [8, 33], [8, 35], [8, 37], [8, 38], [8, 39], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 17], [9, 18], [9, 19], [9, 20], [9, 23], [9, 24], [9, 25], [9, 28], [9, 31], [9, 32], [9, 33], [9, 35], [9, 36], [9, 37], [9, 38], [9, 39], [10, 12], [10, 19], [10, 20], [10, 33], [10, 35], [10, 39], [11, 12], [11, 14], [11, 16], [11, 19], [11, 22], [11, 23], [11, 26], [11, 27], [11, 29], [11, 30], [11, 31], [11, 33], [11, 34], [11, 35], [11, 36], [11, 37], [11, 38], [11, 39], [12, 13], [12, 14], [12, 16], [12, 18], [12, 19], [12, 20], [12, 21], [12, 24], [12, 25], [12, 26], [12, 27], [12, 29], [12, 31], [12, 32], [12, 33], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [13, 19], [13, 21], [13, 23], [13, 31], [13, 33], [13, 35], [14, 20], [14, 25], [14, 33], [14, 36], [14, 37], [14, 39], [15, 23], [15, 25], [15, 31], [15, 33], [15, 35], [15, 36], [15, 37], [15, 39], [16, 20], [16, 23], [16, 33], [16, 35], [17, 20], [17, 21], [17, 23], [17, 31], [17, 35], [18, 19], [18, 21], [18, 23], [18, 25], [18, 27], [18, 29], [18, 30], [18, 33], [18, 34], [18, 36], [18, 39], [19, 20], [19, 21], [19, 22], [19, 23], [19, 25], [19, 26], [19, 27], [19, 31], [19, 32], [19, 33], [19, 34], [19, 35], [19, 36], [19, 37], [20, 21], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 32], [20, 33], [20, 34], [20, 35], [20, 37], [20, 38], [20, 39], [21, 22], [21, 25], [21, 26], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 36], [21, 37], [21, 38], [22, 23], [22, 33], [22, 37], [22, 39], [23, 24], [23, 26], [23, 29], [23, 30], [23, 31], [23, 33], [23, 34], [23, 35], [23, 36], [23, 38], [23, 39], [24, 33], [24, 36], [24, 37], [25, 27], [25, 28], [25, 30], [25, 33], [25, 35], [25, 36], [25, 37], [25, 38], [26, 31], [26, 33], [26, 35], [26, 39], [27, 36], [28, 33], [28, 37], [30, 36], [30, 39], [31, 33], [31, 34], [31, 35], [31, 36], [31, 38], [31, 39], [32, 35], [32, 36], [32, 37], [32, 39], [33, 36], [33, 37], [33, 39], [34, 35], [34, 37], [35, 36], [35, 38], [37, 39], [38, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s4/tests/run.py b/tasks/construct-nppc-vertex-cover-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-vertex-cover-l4-s4/tests/test.sh b/tasks/construct-nppc-vertex-cover-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-graph-color-l3-s1/environment/Dockerfile b/tasks/construct-rg-graph-color-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-graph-color-l3-s1/environment/instance.json b/tasks/construct-rg-graph-color-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f31735fda088b0be5c4cc2ab997d4e7eb421e143 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 5], [0, 6], [0, 8], [1, 3], [1, 7], [1, 8], [2, 5], [2, 6], [2, 7], [3, 9], [4, 5], [4, 7], [5, 6], [5, 7], [6, 8], [7, 8], [7, 9]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s1/solution/solve.sh b/tasks/construct-rg-graph-color-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..72fd8f178c039ced0008c31a4401af8b9959567b --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 1, 1, 2, 1, 2, 3, 3, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l3-s1/tests/check.py b/tasks/construct-rg-graph-color-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s1/tests/check.py @@ -0,0 +1,13 @@ +"""Proper colouring with colours 1..k (Reasoning Gym graph_color, Apache-2.0). Any valid colouring. +Upstream note: its verifier checks `color in allowed_colors`, so True (== 1) and 1.0 were accepted as +colours, and extra keys were ignored. Here colours must be ints in 1..k, one per vertex.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_vertices"], inst["num_colors"] + c = int_list(ans.get("coloring"), n, 1, k, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"adjacent vertices {u} and {v} share colour {c[u]}") + return None, {} diff --git a/tasks/construct-rg-graph-color-l3-s1/tests/instance.json b/tasks/construct-rg-graph-color-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f31735fda088b0be5c4cc2ab997d4e7eb421e143 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 5], [0, 6], [0, 8], [1, 3], [1, 7], [1, 8], [2, 5], [2, 6], [2, 7], [3, 9], [4, 5], [4, 7], [5, 6], [5, 7], [6, 8], [7, 8], [7, 9]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s1/tests/run.py b/tasks/construct-rg-graph-color-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-graph-color-l3-s1/tests/test.sh b/tasks/construct-rg-graph-color-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-intermediate-integration-l1-s5/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-intermediate-integration-l1-s5/environment/instance.json b/tasks/construct-rg-intermediate-integration-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d26d52d46766a08ae873f10a0f2599aa90e20090 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-3*(5*x - 4)**2", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s5/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..af42110d79e7fedac43ec0e2832d33f02c7b94a8 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "-25*x**3 + 60*x**2 - 48*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l1-s5/tests/check.py b/tasks/construct-rg-intermediate-integration-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s5/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l1-s5/tests/instance.json b/tasks/construct-rg-intermediate-integration-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d26d52d46766a08ae873f10a0f2599aa90e20090 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-3*(5*x - 4)**2", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s5/tests/run.py b/tasks/construct-rg-intermediate-integration-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-intermediate-integration-l1-s5/tests/test.sh b/tasks/construct-rg-intermediate-integration-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-intermediate-integration-l5-s3/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-intermediate-integration-l5-s3/environment/instance.json b/tasks/construct-rg-intermediate-integration-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3d1ff16dac3962171a462957b74927a0bef492be --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "3*x**2*exp(x)", "problem_type": "polynomial_exp_trig", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s3/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a13653532e515c2fac460488c9cab86cc77bf7e --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "(3*x**2 - 6*x + 6)*exp(x) + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l5-s3/tests/check.py b/tasks/construct-rg-intermediate-integration-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s3/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l5-s3/tests/instance.json b/tasks/construct-rg-intermediate-integration-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3d1ff16dac3962171a462957b74927a0bef492be --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "3*x**2*exp(x)", "problem_type": "polynomial_exp_trig", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s3/tests/run.py b/tasks/construct-rg-intermediate-integration-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-intermediate-integration-l5-s3/tests/test.sh b/tasks/construct-rg-intermediate-integration-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-intermediate-integration-l5-s4/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-intermediate-integration-l5-s4/environment/instance.json b/tasks/construct-rg-intermediate-integration-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8753d939632fd04230d41962be6f881ffafbe963 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "3*exp(x)*sin(x)", "problem_type": "cyclic", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s4/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f07fd8bb5e7c9027eb50084e28b5b2e6e8b45f4c --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "3*exp(x)*sin(x)/2 - 3*exp(x)*cos(x)/2 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l5-s4/tests/check.py b/tasks/construct-rg-intermediate-integration-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s4/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l5-s4/tests/instance.json b/tasks/construct-rg-intermediate-integration-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8753d939632fd04230d41962be6f881ffafbe963 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "3*exp(x)*sin(x)", "problem_type": "cyclic", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s4/tests/run.py b/tasks/construct-rg-intermediate-integration-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-intermediate-integration-l5-s4/tests/test.sh b/tasks/construct-rg-intermediate-integration-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-simple-integration-l3-s7/environment/Dockerfile b/tasks/construct-rg-simple-integration-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-simple-integration-l3-s7/environment/instance.json b/tasks/construct-rg-simple-integration-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8dc91899caebf029622c6eff0c362524455fe5b4 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "10*X**9/9 + 16*X**5/3 - 21*X**2/5 - 14*X", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s7/solution/solve.sh b/tasks/construct-rg-simple-integration-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ddba85bd9e958bb8c2eeda5c69aea4f9aeb62332 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "X**10/9 + 8*X**6/9 - 7*X**3/5 - 7*X**2 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l3-s7/tests/check.py b/tasks/construct-rg-simple-integration-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s7/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-simple-integration-l3-s7/tests/instance.json b/tasks/construct-rg-simple-integration-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8dc91899caebf029622c6eff0c362524455fe5b4 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "10*X**9/9 + 16*X**5/3 - 21*X**2/5 - 14*X", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s7/tests/run.py b/tasks/construct-rg-simple-integration-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-simple-integration-l3-s7/tests/test.sh b/tasks/construct-rg-simple-integration-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-antiderivative-l2-s9/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-antiderivative-l2-s9/environment/instance.json b/tasks/construct-rlve-antiderivative-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b30fa511c860fa2f68a4b0781ae7d7db280b4123 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "-exp(x) - 3", "max_ops": 36, "max_len": 660, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s9/solution/solve.sh b/tasks/construct-rlve-antiderivative-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9c305ee6b80e101dbd7ec8491eb04650b8aa40ff --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"F": "-3*x - exp(x)"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l2-s9/tests/check.py b/tasks/construct-rlve-antiderivative-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s9/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l2-s9/tests/instance.json b/tasks/construct-rlve-antiderivative-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b30fa511c860fa2f68a4b0781ae7d7db280b4123 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "-exp(x) - 3", "max_ops": 36, "max_len": 660, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s9/tests/run.py b/tasks/construct-rlve-antiderivative-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-antiderivative-l2-s9/tests/test.sh b/tasks/construct-rlve-antiderivative-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-antiderivative-l6-s0/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-antiderivative-l6-s0/environment/instance.json b/tasks/construct-rlve-antiderivative-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d8bc0b23f9f064667b884e69a131cce72e9622dc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "-(2*x*(2*x**x*(log(x) + 1) + 6) + 12*x + 4*x**x - 8)*sin(2*x*(6*x + 2*x**x - 4))", "max_ops": 52, "max_len": 940, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s0/solution/solve.sh b/tasks/construct-rlve-antiderivative-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3cb68292b516b2a9b25ab3590ca5fd74544a65e7 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"F": "cos(2*x*(6*x + 2*x**x - 4))"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l6-s0/tests/check.py b/tasks/construct-rlve-antiderivative-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s0/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l6-s0/tests/instance.json b/tasks/construct-rlve-antiderivative-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d8bc0b23f9f064667b884e69a131cce72e9622dc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "-(2*x*(2*x**x*(log(x) + 1) + 6) + 12*x + 4*x**x - 8)*sin(2*x*(6*x + 2*x**x - 4))", "max_ops": 52, "max_len": 940, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s0/tests/run.py b/tasks/construct-rlve-antiderivative-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-antiderivative-l6-s0/tests/test.sh b/tasks/construct-rlve-antiderivative-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-antiderivative-l6-s1/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-antiderivative-l6-s1/environment/instance.json b/tasks/construct-rlve-antiderivative-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..01fd6446d07203b793396d795d14f0e069f536d0 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "x*(20 - 36*x)*sin((2 - 18*x)*(x - 1))*sin(sin(cos((2 - 18*x)*(x - 1))))*cos(cos((2 - 18*x)*(x - 1))) + cos(sin(cos((2 - 18*x)*(x - 1))))", "max_ops": 52, "max_len": 1100, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s1/solution/solve.sh b/tasks/construct-rlve-antiderivative-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..08a00d910a5479ca8813a6822332a9d8804000f4 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"F": "x*cos(sin(cos((2 - 18*x)*(x - 1))))"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l6-s1/tests/check.py b/tasks/construct-rlve-antiderivative-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s1/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l6-s1/tests/instance.json b/tasks/construct-rlve-antiderivative-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..01fd6446d07203b793396d795d14f0e069f536d0 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "x*(20 - 36*x)*sin((2 - 18*x)*(x - 1))*sin(sin(cos((2 - 18*x)*(x - 1))))*cos(cos((2 - 18*x)*(x - 1))) + cos(sin(cos((2 - 18*x)*(x - 1))))", "max_ops": 52, "max_len": 1100, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s1/tests/run.py b/tasks/construct-rlve-antiderivative-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-antiderivative-l6-s1/tests/test.sh b/tasks/construct-rlve-antiderivative-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-bezout-identity-l3-s4/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-bezout-identity-l3-s4/environment/instance.json b/tasks/construct-rlve-bezout-identity-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a24545ffde32689352b1fc2a7df24eeb08c3fa66 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": [-206, -254, -480, -280, 208, 402], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s4/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f88878569dc818e2b43602d028732d5809c0a32e --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [-37, 30, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l3-s4/tests/check.py b/tasks/construct-rlve-bezout-identity-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s4/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + X = int_list(ans.get("X"), len(A), name="X") + S = sum(a * x for a, x in zip(A, X)) + if S != inst["target"]: + raise Invalid(f"S = {S}, required {inst['target']}") + return None, {} diff --git a/tasks/construct-rlve-bezout-identity-l3-s4/tests/instance.json b/tasks/construct-rlve-bezout-identity-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a24545ffde32689352b1fc2a7df24eeb08c3fa66 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": [-206, -254, -480, -280, 208, 402], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s4/tests/run.py b/tasks/construct-rlve-bezout-identity-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-bezout-identity-l3-s4/tests/test.sh b/tasks/construct-rlve-bezout-identity-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-bezout-identity-l3-s5/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-bezout-identity-l3-s5/environment/instance.json b/tasks/construct-rlve-bezout-identity-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..47e9968af2bb0d0a1aebaf2f9d7b7d8bfcb4dce4 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"A": [4, 418, -296, 402, -316, -302], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s5/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..540de039aac2465280d19298ee794a10141d215c --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [-104, 1, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l3-s5/tests/check.py b/tasks/construct-rlve-bezout-identity-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s5/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + X = int_list(ans.get("X"), len(A), name="X") + S = sum(a * x for a, x in zip(A, X)) + if S != inst["target"]: + raise Invalid(f"S = {S}, required {inst['target']}") + return None, {} diff --git a/tasks/construct-rlve-bezout-identity-l3-s5/tests/instance.json b/tasks/construct-rlve-bezout-identity-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..47e9968af2bb0d0a1aebaf2f9d7b7d8bfcb4dce4 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"A": [4, 418, -296, 402, -316, -302], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s5/tests/run.py b/tasks/construct-rlve-bezout-identity-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-bezout-identity-l3-s5/tests/test.sh b/tasks/construct-rlve-bezout-identity-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s1/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s1/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..69dc01c30efab693faa6416119d05162f139276d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"mod": 18, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s1/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c055ee938ffaaa6c6cf76f15ffc27d82f7b43b9e --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 3, "R": 6} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..69dc01c30efab693faa6416119d05162f139276d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"mod": 18, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s6/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s6/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..92661d7950ab01b8632361d3355c27a8b2a1b28c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"mod": 45, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s6/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4ac2e27cb27757cdc23eeab58e6972fcdeaf24d5 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 1, "R": 9} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..92661d7950ab01b8632361d3355c27a8b2a1b28c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"mod": 45, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s0/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s0/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2983b71082315dbd413a022d4e55ef474fd5b69d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"mod": 846421353413990, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s0/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f95c8d308a7ffd0744d9da42b36f1b53c75cf481 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 471370827311920, "R": 571370827311919} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2983b71082315dbd413a022d4e55ef474fd5b69d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"mod": 846421353413990, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s7/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s7/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1fbdb207a46d40c8d35711a5ea9b219edcdf113c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"mod": 445964140404775, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s7/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..67e41ba209cecb5ea95dadd46a38d188f583bd30 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 389462106071625, "R": 489462106071624} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1fbdb207a46d40c8d35711a5ea9b219edcdf113c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"mod": 445964140404775, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s9/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s9/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9520c0d3124ec03e7ca859ecb6be4f034116525a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"mod": 371940793237566, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s9/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..abe1f0f2106a152a8d43072faaed097d71c8d2dd --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 22993485038622, "R": 122993485038621} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9520c0d3124ec03e7ca859ecb6be4f034116525a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"mod": 371940793237566, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-crt-l4-s0/environment/Dockerfile b/tasks/construct-rlve-crt-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-crt-l4-s0/environment/instance.json b/tasks/construct-rlve-crt-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5977c72b803b5734dfdc32b192e29aa410627e43 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [8702, 103279, 22592, 23902, 39067], "residues": [1470, 63529, 8664, 23396, 10540], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s0/solution/solve.sh b/tasks/construct-rlve-crt-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c34e80dfba3c2eea7b52bd1fffccfad8b4c27d86 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 166808} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l4-s0/tests/check.py b/tasks/construct-rlve-crt-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s0/tests/check.py @@ -0,0 +1,11 @@ +from run import Invalid, as_int + + +def check(inst, ans): + x = as_int(ans.get("x"), "x", lo=0) + if x.bit_length() > 20000: + raise Invalid("x is unreasonably large") + for a, b in zip(inst["residues"], inst["moduli"]): + if x % b != a: + raise Invalid(f"x mod {b} = {x % b}, need {a}") + return None, {} diff --git a/tasks/construct-rlve-crt-l4-s0/tests/instance.json b/tasks/construct-rlve-crt-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5977c72b803b5734dfdc32b192e29aa410627e43 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [8702, 103279, 22592, 23902, 39067], "residues": [1470, 63529, 8664, 23396, 10540], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s0/tests/run.py b/tasks/construct-rlve-crt-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-crt-l4-s0/tests/test.sh b/tasks/construct-rlve-crt-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-crt-l4-s1/tests/run.py b/tasks/construct-rlve-crt-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ceb95320571ac00a8254a4abbfb1f5cf0e7595e5 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"A": [4, 2, 6, 3], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..994a2d6dfc038b7315136bf4b888a853d4858cf0 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"B": [6, 3, 2, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ceb95320571ac00a8254a4abbfb1f5cf0e7595e5 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"A": [4, 2, 6, 3], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..48408af84195073065121c189994f3a4ebf9f30b --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"A": [17, 30, 24, 2, 13, 35, 25, 26, 7, 28, 6, 29, 22, 1, 3, 10, 34, 5], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed7d8081db8e1df76f3e998ef9052f28863a816d --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"B": [22, 34, 25, 3, 17, 1, 26, 28, 10, 29, 7, 30, 24, 2, 5, 13, 35, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..48408af84195073065121c189994f3a4ebf9f30b --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"A": [17, 30, 24, 2, 13, 35, 25, 26, 7, 28, 6, 29, 22, 1, 3, 10, 34, 5], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-even-degree-partition-l4-s9/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-even-degree-partition-l4-s9/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..641fa8b122bc51dfffd59b5b3b71a0d09869dd70 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[0, 6], [0, 8], [0, 16], [1, 6], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 15], [1, 16], [2, 3], [2, 4], [2, 8], [2, 9], [2, 10], [2, 11], [2, 15], [2, 16], [2, 17], [3, 4], [3, 5], [3, 6], [3, 9], [3, 11], [3, 13], [4, 5], [4, 6], [4, 9], [4, 10], [4, 11], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 6], [5, 7], [5, 11], [5, 15], [6, 7], [6, 9], [6, 14], [6, 15], [6, 16], [7, 10], [7, 13], [7, 14], [8, 16], [9, 13], [9, 14], [9, 17], [10, 11], [10, 12], [10, 13], [11, 13], [11, 14], [12, 15], [12, 16], [12, 17], [14, 17], [16, 17]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l4-s9/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d1f987fc93e52902a1264a365199823fcb5728a0 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"groups": [2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l4-s9/tests/check.py b/tasks/construct-rlve-even-degree-partition-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + g = int_list(ans.get("groups"), n, 1, 2, "groups") + deg = [0] * n + for u, v in inst["edges"]: + if g[u] == g[v]: + deg[u] += 1 + deg[v] += 1 + for v in range(n): + if deg[v] % 2: + raise Invalid(f"vertex {v} has {deg[v]} same-group neighbours") + return None, {} diff --git a/tasks/construct-rlve-even-degree-partition-l4-s9/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..641fa8b122bc51dfffd59b5b3b71a0d09869dd70 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[0, 6], [0, 8], [0, 16], [1, 6], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 15], [1, 16], [2, 3], [2, 4], [2, 8], [2, 9], [2, 10], [2, 11], [2, 15], [2, 16], [2, 17], [3, 4], [3, 5], [3, 6], [3, 9], [3, 11], [3, 13], [4, 5], [4, 6], [4, 9], [4, 10], [4, 11], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 6], [5, 7], [5, 11], [5, 15], [6, 7], [6, 9], [6, 14], [6, 15], [6, 16], [7, 10], [7, 13], [7, 14], [8, 16], [9, 13], [9, 14], [9, 17], [10, 11], [10, 12], [10, 13], [11, 13], [11, 14], [12, 15], [12, 16], [12, 17], [14, 17], [16, 17]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l4-s9/tests/run.py b/tasks/construct-rlve-even-degree-partition-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-even-degree-partition-l4-s9/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s4/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s4/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..df45e39b8036c91123e126505034256cd85d9705 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[5, 6], [1, 7], [1, 4], [0, 4]], "edges2": [[0, 3], [1, 5], [3, 6], [0, 7]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s4/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e754e3235af5053ab724e056191bf4d255dcf7e --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [7, 3, 4, 2, 0, 1, 5, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..df45e39b8036c91123e126505034256cd85d9705 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[5, 6], [1, 7], [1, 4], [0, 4]], "edges2": [[0, 3], [1, 5], [3, 6], [0, 7]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s5/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s5/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..15dcf7f9e1b23fd0585c6ebbd2070e7a40951b7c --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[0, 3], [3, 6], [2, 4], [5, 7], [1, 5], [1, 6], [0, 5]], "edges2": [[1, 3], [2, 4], [5, 6], [0, 1], [3, 7], [1, 2], [4, 7]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s5/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ecb28394de6c89c54b56cea4bcacc381d5ab6282 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [3, 2, 5, 7, 6, 1, 4, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..15dcf7f9e1b23fd0585c6ebbd2070e7a40951b7c --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[0, 3], [3, 6], [2, 4], [5, 7], [1, 5], [1, 6], [0, 5]], "edges2": [[1, 3], [2, 4], [5, 6], [0, 1], [3, 7], [1, 2], [4, 7]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s3/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s3/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..abdb6e7c6bb8d84a9c4580cb097c06bc4c93a3c3 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["0111", "0011", "1011", "1101"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s3/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c5c6256746c67df26953a9a03d14c2635b1731e6 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"grid": ["0010", "0000", "0001", "1000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/check.py @@ -0,0 +1,22 @@ +from run import Invalid + + +def check(inst, ans): + P = inst["parity"] + N, M = len(P), len(P[0]) + G = ans.get("grid") + if not isinstance(G, list) or len(G) != N: + raise Invalid(f"grid must be a list of {N} strings") + for r in G: + if not isinstance(r, str) or len(r) != M or set(r) - {"0", "1"}: + raise Invalid(f"each row must be a string of {M} characters '0'/'1'") + for i in range(N): + for j in range(M): + v = int(G[i][j]) + for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)): + a, b = i + di, j + dj + if 0 <= a < N and 0 <= b < M: + v ^= int(G[a][b]) + if v != int(P[i][j]): + raise Invalid(f"parity mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..abdb6e7c6bb8d84a9c4580cb097c06bc4c93a3c3 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["0111", "0011", "1011", "1101"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-imp-party-l4-s2/environment/Dockerfile b/tasks/construct-rlve-imp-party-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-imp-party-l4-s2/environment/instance.json b/tasks/construct-rlve-imp-party-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e1d051e59e286262d83a81eddb300057bd2c98f6 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 6], [0, 10], [0, 13], [0, 17], [0, 18], [0, 21], [0, 23], [0, 27], [0, 32], [1, 14], [1, 18], [1, 28], [1, 35], [2, 4], [2, 5], [2, 8], [2, 10], [2, 13], [2, 17], [2, 35], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 17], [3, 18], [3, 20], [3, 21], [3, 22], [3, 23], [3, 25], [3, 27], [3, 28], [3, 31], [3, 32], [3, 33], [3, 35], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 13], [4, 14], [4, 15], [4, 17], [4, 18], [4, 20], [4, 21], [4, 23], [4, 25], [4, 27], [4, 28], [4, 29], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [5, 25], [5, 27], [5, 28], [5, 30], [5, 31], [5, 32], [5, 33], [5, 35], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 17], [6, 18], [6, 20], [6, 21], [6, 23], [6, 24], [6, 25], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 35], [7, 8], [7, 9], [7, 10], [7, 11], [7, 13], [7, 14], [7, 15], [7, 17], [7, 18], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 17], [8, 18], [8, 20], [8, 21], [8, 22], [8, 23], [8, 25], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [9, 10], [9, 11], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 23], [9, 25], [9, 26], [9, 27], [9, 28], [9, 31], [9, 32], [9, 33], [9, 35], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 17], [10, 18], [10, 20], [10, 21], [10, 23], [10, 24], [10, 25], [10, 27], [10, 28], [10, 31], [10, 32], [10, 33], [10, 35], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 23], [11, 25], [11, 27], [11, 28], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [12, 21], [12, 32], [13, 14], [13, 15], [13, 17], [13, 18], [13, 20], [13, 21], [13, 23], [13, 25], [13, 27], [13, 28], [13, 30], [13, 31], [13, 32], [13, 33], [13, 34], [13, 35], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [14, 23], [14, 25], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 23], [15, 24], [15, 25], [15, 27], [15, 28], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [16, 18], [16, 20], [16, 32], [16, 35], [17, 18], [17, 20], [17, 21], [17, 23], [17, 25], [17, 27], [17, 28], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [18, 20], [18, 21], [18, 23], [18, 24], [18, 25], [18, 27], [18, 28], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [19, 20], [19, 21], [19, 33], [19, 35], [20, 21], [20, 23], [20, 24], [20, 25], [20, 27], [20, 28], [20, 29], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [21, 23], [21, 25], [21, 27], [21, 28], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 25], [22, 27], [23, 24], [23, 25], [23, 27], [23, 28], [23, 30], [23, 31], [23, 32], [23, 33], [23, 35], [24, 28], [24, 32], [25, 27], [25, 28], [25, 29], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [26, 28], [26, 33], [26, 35], [27, 28], [27, 30], [27, 31], [27, 32], [27, 33], [27, 35], [28, 30], [28, 31], [28, 32], [28, 33], [28, 35], [29, 31], [29, 32], [29, 35], [31, 32], [31, 33], [31, 35], [32, 33], [32, 35], [33, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s2/solution/solve.sh b/tasks/construct-rlve-imp-party-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cc72889599c603b755009e7fcfb07c22ad2ba979 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [4, 5, 7, 8, 9, 11, 13, 14, 15, 21, 23, 27]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l4-s2/tests/check.py b/tasks/construct-rlve-imp-party-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s2/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l4-s2/tests/instance.json b/tasks/construct-rlve-imp-party-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e1d051e59e286262d83a81eddb300057bd2c98f6 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 6], [0, 10], [0, 13], [0, 17], [0, 18], [0, 21], [0, 23], [0, 27], [0, 32], [1, 14], [1, 18], [1, 28], [1, 35], [2, 4], [2, 5], [2, 8], [2, 10], [2, 13], [2, 17], [2, 35], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 17], [3, 18], [3, 20], [3, 21], [3, 22], [3, 23], [3, 25], [3, 27], [3, 28], [3, 31], [3, 32], [3, 33], [3, 35], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 13], [4, 14], [4, 15], [4, 17], [4, 18], [4, 20], [4, 21], [4, 23], [4, 25], [4, 27], [4, 28], [4, 29], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [5, 25], [5, 27], [5, 28], [5, 30], [5, 31], [5, 32], [5, 33], [5, 35], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 17], [6, 18], [6, 20], [6, 21], [6, 23], [6, 24], [6, 25], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 35], [7, 8], [7, 9], [7, 10], [7, 11], [7, 13], [7, 14], [7, 15], [7, 17], [7, 18], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 17], [8, 18], [8, 20], [8, 21], [8, 22], [8, 23], [8, 25], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [9, 10], [9, 11], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 23], [9, 25], [9, 26], [9, 27], [9, 28], [9, 31], [9, 32], [9, 33], [9, 35], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 17], [10, 18], [10, 20], [10, 21], [10, 23], [10, 24], [10, 25], [10, 27], [10, 28], [10, 31], [10, 32], [10, 33], [10, 35], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 23], [11, 25], [11, 27], [11, 28], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [12, 21], [12, 32], [13, 14], [13, 15], [13, 17], [13, 18], [13, 20], [13, 21], [13, 23], [13, 25], [13, 27], [13, 28], [13, 30], [13, 31], [13, 32], [13, 33], [13, 34], [13, 35], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [14, 23], [14, 25], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 23], [15, 24], [15, 25], [15, 27], [15, 28], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [16, 18], [16, 20], [16, 32], [16, 35], [17, 18], [17, 20], [17, 21], [17, 23], [17, 25], [17, 27], [17, 28], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [18, 20], [18, 21], [18, 23], [18, 24], [18, 25], [18, 27], [18, 28], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [19, 20], [19, 21], [19, 33], [19, 35], [20, 21], [20, 23], [20, 24], [20, 25], [20, 27], [20, 28], [20, 29], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [21, 23], [21, 25], [21, 27], [21, 28], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 25], [22, 27], [23, 24], [23, 25], [23, 27], [23, 28], [23, 30], [23, 31], [23, 32], [23, 33], [23, 35], [24, 28], [24, 32], [25, 27], [25, 28], [25, 29], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [26, 28], [26, 33], [26, 35], [27, 28], [27, 30], [27, 31], [27, 32], [27, 33], [27, 35], [28, 30], [28, 31], [28, 32], [28, 33], [28, 35], [29, 31], [29, 32], [29, 35], [31, 32], [31, 33], [31, 35], [32, 33], [32, 35], [33, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s2/tests/run.py b/tasks/construct-rlve-imp-party-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-imp-party-l4-s2/tests/test.sh b/tasks/construct-rlve-imp-party-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-imp-party-l4-s5/environment/Dockerfile b/tasks/construct-rlve-imp-party-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-imp-party-l4-s5/environment/instance.json b/tasks/construct-rlve-imp-party-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4eba2f7562c9471c37da8ab328aa1e0906c59c9e --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 7], [0, 9], [0, 10], [0, 11], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 26], [0, 27], [0, 28], [0, 33], [0, 34], [0, 35], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 26], [1, 27], [1, 28], [1, 29], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [3, 4], [3, 5], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 21], [5, 22], [5, 23], [5, 25], [5, 26], [5, 27], [5, 28], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [6, 7], [6, 9], [6, 11], [6, 16], [6, 17], [6, 18], [6, 21], [6, 26], [6, 27], [6, 34], [6, 35], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 23], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [8, 9], [8, 10], [8, 11], [8, 12], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 32], [8, 33], [8, 34], [8, 35], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 21], [9, 22], [9, 23], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [10, 11], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 26], [10, 27], [10, 28], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 32], [11, 33], [11, 34], [11, 35], [12, 15], [12, 16], [12, 17], [12, 21], [12, 26], [12, 27], [12, 33], [13, 14], [13, 17], [13, 21], [13, 26], [13, 27], [13, 28], [13, 32], [13, 33], [13, 35], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [15, 16], [15, 17], [15, 18], [15, 19], [15, 21], [15, 22], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 32], [16, 33], [16, 34], [16, 35], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [18, 21], [18, 22], [18, 23], [18, 26], [18, 27], [18, 28], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [19, 22], [19, 26], [19, 27], [19, 28], [19, 32], [19, 34], [19, 35], [20, 26], [20, 27], [20, 28], [20, 32], [20, 33], [20, 34], [20, 35], [21, 22], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 32], [22, 33], [22, 34], [22, 35], [23, 26], [23, 27], [23, 32], [23, 33], [23, 34], [23, 35], [24, 28], [24, 32], [24, 34], [24, 35], [25, 26], [25, 27], [25, 28], [25, 32], [25, 33], [25, 34], [25, 35], [26, 27], [26, 28], [26, 29], [26, 30], [26, 32], [26, 33], [26, 34], [26, 35], [27, 28], [27, 32], [27, 33], [27, 34], [27, 35], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [29, 33], [30, 32], [30, 33], [30, 34], [30, 35], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 34], [32, 35], [33, 34], [33, 35], [34, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s5/solution/solve.sh b/tasks/construct-rlve-imp-party-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0681c5a1a559355f29eb1181fd076f259746516a --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 7, 8, 9, 11, 14, 18, 22, 28, 33, 34, 35]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l4-s5/tests/check.py b/tasks/construct-rlve-imp-party-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s5/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l4-s5/tests/instance.json b/tasks/construct-rlve-imp-party-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4eba2f7562c9471c37da8ab328aa1e0906c59c9e --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 7], [0, 9], [0, 10], [0, 11], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 26], [0, 27], [0, 28], [0, 33], [0, 34], [0, 35], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 26], [1, 27], [1, 28], [1, 29], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [3, 4], [3, 5], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 21], [5, 22], [5, 23], [5, 25], [5, 26], [5, 27], [5, 28], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [6, 7], [6, 9], [6, 11], [6, 16], [6, 17], [6, 18], [6, 21], [6, 26], [6, 27], [6, 34], [6, 35], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 23], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [8, 9], [8, 10], [8, 11], [8, 12], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 32], [8, 33], [8, 34], [8, 35], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 21], [9, 22], [9, 23], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [10, 11], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 26], [10, 27], [10, 28], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 32], [11, 33], [11, 34], [11, 35], [12, 15], [12, 16], [12, 17], [12, 21], [12, 26], [12, 27], [12, 33], [13, 14], [13, 17], [13, 21], [13, 26], [13, 27], [13, 28], [13, 32], [13, 33], [13, 35], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [15, 16], [15, 17], [15, 18], [15, 19], [15, 21], [15, 22], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 32], [16, 33], [16, 34], [16, 35], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [18, 21], [18, 22], [18, 23], [18, 26], [18, 27], [18, 28], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [19, 22], [19, 26], [19, 27], [19, 28], [19, 32], [19, 34], [19, 35], [20, 26], [20, 27], [20, 28], [20, 32], [20, 33], [20, 34], [20, 35], [21, 22], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 32], [22, 33], [22, 34], [22, 35], [23, 26], [23, 27], [23, 32], [23, 33], [23, 34], [23, 35], [24, 28], [24, 32], [24, 34], [24, 35], [25, 26], [25, 27], [25, 28], [25, 32], [25, 33], [25, 34], [25, 35], [26, 27], [26, 28], [26, 29], [26, 30], [26, 32], [26, 33], [26, 34], [26, 35], [27, 28], [27, 32], [27, 33], [27, 34], [27, 35], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [29, 33], [30, 32], [30, 33], [30, 34], [30, 35], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 34], [32, 35], [33, 34], [33, 35], [34, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s5/tests/run.py b/tasks/construct-rlve-imp-party-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-imp-party-l4-s5/tests/test.sh b/tasks/construct-rlve-imp-party-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-integer-linear-system-l3-s2/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-integer-linear-system-l3-s2/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e61677d1c69bac5a30365aaad6293d27329ca7e2 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1, 1, 1], [0, 1, 1, 0, 0, 1, 0, 1], [1, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 1, 0, 0, 1], [0, 0, 0, 0, 1, 0, 1, 1], [1, 0, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0, 1], [1, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0, 0, 1], [0, 1, 0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 1, 0, 1, 1], [0, 1, 0, 1, 1, 1, 1, 0], [0, 1, 0, 1, 1, 1, 0, 0], [1, 1, 0, 1, 0, 1, 1, 1]], "rhs": [15, 14, 23, 33, 23, 24, 26, 26, 16, 28, 23, 36, 27, 21, 25, 29, 28, 25, 29], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s2/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6974ebc253d87990218a3344fa2490f261c15377 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [2, 5, 8, 8, 7, 5, 3, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l3-s2/tests/check.py b/tasks/construct-rlve-integer-linear-system-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s2/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l3-s2/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e61677d1c69bac5a30365aaad6293d27329ca7e2 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1, 1, 1], [0, 1, 1, 0, 0, 1, 0, 1], [1, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 1, 0, 0, 1], [0, 0, 0, 0, 1, 0, 1, 1], [1, 0, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0, 1], [1, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0, 0, 1], [0, 1, 0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 1, 0, 1, 1], [0, 1, 0, 1, 1, 1, 1, 0], [0, 1, 0, 1, 1, 1, 0, 0], [1, 1, 0, 1, 0, 1, 1, 1]], "rhs": [15, 14, 23, 33, 23, 24, 26, 26, 16, 28, 23, 36, 27, 21, 25, 29, 28, 25, 29], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s2/tests/run.py b/tasks/construct-rlve-integer-linear-system-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-integer-linear-system-l3-s2/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-integer-linear-system-l3-s5/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-integer-linear-system-l3-s5/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c944f722ef6eb04b12508ed49701adf89b2145dd --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 0, 1, 1, 1, 0, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 1], [1, 1, 0, 1, 0, 0, 0, 1], [1, 1, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 1, 1], [1, 0, 1, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1, 1, 0], [1, 1, 0, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 1, 0, 1, 1], [0, 0, 1, 0, 1, 0, 0, 0], [1, 0, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 1, 0, 0, 1], [1, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1]], "rhs": [27, 24, 17, 16, 19, 20, 28, 28, 22, 22, 16, 6, 27, 30, 29, 14, 27, 11, 34, 12, 16, 11], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s5/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..40eb5ab1c554b60808575fb0ff9ef4a089268050 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [7, 3, 6, 2, 5, 4, 8, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l3-s5/tests/check.py b/tasks/construct-rlve-integer-linear-system-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s5/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l3-s5/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c944f722ef6eb04b12508ed49701adf89b2145dd --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 0, 1, 1, 1, 0, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 1], [1, 1, 0, 1, 0, 0, 0, 1], [1, 1, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 1, 1], [1, 0, 1, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1, 1, 0], [1, 1, 0, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 1, 0, 1, 1], [0, 0, 1, 0, 1, 0, 0, 0], [1, 0, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 1, 0, 0, 1], [1, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1]], "rhs": [27, 24, 17, 16, 19, 20, 28, 28, 22, 22, 16, 6, 27, 30, 29, 14, 27, 11, 34, 12, 16, 11], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s5/tests/run.py b/tasks/construct-rlve-integer-linear-system-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-integer-linear-system-l3-s5/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-largest-rectangle-l2-s3/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-largest-rectangle-l2-s3/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8a4d68840d992a55f337f1c5b48fc80fe04e885d --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"points": [[5, 5], [2, 1], [-5, 0], [-8, -1], [10, 5], [7, 8], [-8, 8], [-2, 4], [-1, -3], [-8, -7]], "area": 25, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s3/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c02d585650ca94e22774e80ddb139c2c67d7b62 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [1, 7, 2, 8]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l2-s3/tests/check.py b/tasks/construct-rlve-largest-rectangle-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s3/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid, int_list + + +def check(inst, ans): + P = inst["points"] + idx = int_list(ans.get("indices"), 4, 0, len(P) - 1, "indices") + if len(set(idx)) != 4: + raise Invalid("indices must be distinct") + A, *rest = [tuple(P[i]) for i in idx] + if len(set([A] + rest)) != 4: + raise Invalid("points must be distinct") + # the vertex farthest from A is opposite; the other two are A's neighbours + rest.sort(key=lambda X: (X[0] - A[0]) ** 2 + (X[1] - A[1]) ** 2) + B, D, C = rest + u = (B[0] - A[0], B[1] - A[1]) + v = (D[0] - A[0], D[1] - A[1]) + if u[0] * v[0] + u[1] * v[1] != 0: + raise Invalid("not a rectangle (no right angle at the first vertex)") + if (B[0] + D[0] - A[0], B[1] + D[1] - A[1]) != C: + raise Invalid("not a rectangle") + area = abs(u[0] * v[1] - u[1] * v[0]) + if area < inst["area"]: + raise Invalid(f"area {area} < {inst['area']}") + return None, {"area": area} diff --git a/tasks/construct-rlve-largest-rectangle-l2-s3/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8a4d68840d992a55f337f1c5b48fc80fe04e885d --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"points": [[5, 5], [2, 1], [-5, 0], [-8, -1], [10, 5], [7, 8], [-8, 8], [-2, 4], [-1, -3], [-8, -7]], "area": 25, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s3/tests/run.py b/tasks/construct-rlve-largest-rectangle-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-largest-rectangle-l2-s3/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-largest-rectangle-l2-s4/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-largest-rectangle-l2-s4/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e31fff71455841b8cb0c3a46e1d4442f18a31c66 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"points": [[3, 0], [-5, -2], [-3, 2], [-4, -5], [8, 4], [4, 9], [-8, -3], [10, 10], [6, -9], [-7, -6]], "area": 10, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s4/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d470cee8d96ebd59d308b6934956913956d8db8a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [1, 3, 9, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l2-s4/tests/check.py b/tasks/construct-rlve-largest-rectangle-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s4/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid, int_list + + +def check(inst, ans): + P = inst["points"] + idx = int_list(ans.get("indices"), 4, 0, len(P) - 1, "indices") + if len(set(idx)) != 4: + raise Invalid("indices must be distinct") + A, *rest = [tuple(P[i]) for i in idx] + if len(set([A] + rest)) != 4: + raise Invalid("points must be distinct") + # the vertex farthest from A is opposite; the other two are A's neighbours + rest.sort(key=lambda X: (X[0] - A[0]) ** 2 + (X[1] - A[1]) ** 2) + B, D, C = rest + u = (B[0] - A[0], B[1] - A[1]) + v = (D[0] - A[0], D[1] - A[1]) + if u[0] * v[0] + u[1] * v[1] != 0: + raise Invalid("not a rectangle (no right angle at the first vertex)") + if (B[0] + D[0] - A[0], B[1] + D[1] - A[1]) != C: + raise Invalid("not a rectangle") + area = abs(u[0] * v[1] - u[1] * v[0]) + if area < inst["area"]: + raise Invalid(f"area {area} < {inst['area']}") + return None, {"area": area} diff --git a/tasks/construct-rlve-largest-rectangle-l2-s4/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e31fff71455841b8cb0c3a46e1d4442f18a31c66 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"points": [[3, 0], [-5, -2], [-3, 2], [-4, -5], [8, 4], [4, 9], [-8, -3], [10, 10], [6, -9], [-7, -6]], "area": 10, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s4/tests/run.py b/tasks/construct-rlve-largest-rectangle-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-largest-rectangle-l2-s4/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3f324831cef2aa911c6cd0cbe19c94fb0c0342f4 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"A": ["01", "10"], "B": ["10", "01"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9b12c704025e110759128dd7331fb223c0dd6792 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [1, 0], "b": [0, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3f324831cef2aa911c6cd0cbe19c94fb0c0342f4 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"A": ["01", "10"], "B": ["10", "01"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..710142838b6fc0e9648acedab2960864ee2e9cd9 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"A": ["110", "011"], "B": ["011", "110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c17857e29b3e8687f37ab7d62c4e836cdab648a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [0, 1], "b": [2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..710142838b6fc0e9648acedab2960864ee2e9cd9 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"A": ["110", "011"], "B": ["011", "110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0d58479b77f8916a6298fb90d2f41e3aad4a5b2b --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"A": ["1100100000", "0010110001", "0010000001"], "B": ["0000110000", "0100000101", "0000111001"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a5e2b76fde30a27fbca2963687fd1d8bdfc92f95 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [2, 0, 1], "b": [7, 0, 8, 3, 9, 2, 5, 1, 6, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0d58479b77f8916a6298fb90d2f41e3aad4a5b2b --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"A": ["1100100000", "0010110001", "0010000001"], "B": ["0000110000", "0100000101", "0000111001"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bda7b1aecc5b38780f5bd3b60b9a96898d788cc6 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"A": ["000000110000100", "000000000001010", "100000101000100", "000100000000010", "011000101000010", "000111000001100", "011100000001000", "000000001010000", "000000000000100", "000000110000000", "000100001100000", "000000100100100", "000011001000000"], "B": ["100100100100010", "000000000100101", "000000000100100", "000000000000001", "000000100001000", "000100010100001", "000100001000000", "000001100000000", "000011000011001", "010000000100001", "010100000001000", "100001000001010", "000110000010000"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b5e7f4ad99e8f1ace4dc42363579fdb7df163f3d --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [4, 0, 9, 8, 3, 2, 7, 1, 5, 11, 10, 6, 12], "b": [2, 9, 14, 8, 5, 11, 13, 0, 10, 6, 4, 3, 7, 1, 12]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bda7b1aecc5b38780f5bd3b60b9a96898d788cc6 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"A": ["000000110000100", "000000000001010", "100000101000100", "000100000000010", "011000101000010", "000111000001100", "011100000001000", "000000001010000", "000000000000100", "000000110000000", "000100001100000", "000000100100100", "000011001000000"], "B": ["100100100100010", "000000000100101", "000000000100100", "000000000000001", "000000100001000", "000100010100001", "000100001000000", "000001100000000", "000011000011001", "010000000100001", "010100000001000", "100001000001010", "000110000010000"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4c1087bf4b6c790d6a836b24239582aaba757e32 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"A": ["110011100010", "100110001110", "011010011010", "010110101011", "010110000111"], "B": ["100100101011", "000101101101", "110101101010", "101111100000", "110100110100"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..188cd1f4e1025e102a92bb23557ec10c82ee757a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [4, 1, 3, 2, 0], "b": [1, 6, 7, 10, 2, 8, 4, 5, 3, 0, 11, 9]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4c1087bf4b6c790d6a836b24239582aaba757e32 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"A": ["110011100010", "100110001110", "011010011010", "010110101011", "010110000111"], "B": ["100100101011", "000101101101", "110101101010", "101111100000", "110100110100"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-maximum-clique-l2-s0/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l2-s0/environment/instance.json b/tasks/construct-rlve-maximum-clique-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e54c6d7c0e8958cbe2f04002109667d2a4a50925 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 4, "edges": [[0, 1], [0, 3], [0, 4], [0, 7], [0, 10], [0, 12], [1, 4], [1, 6], [1, 7], [2, 4], [2, 5], [2, 6], [2, 12], [2, 13], [3, 8], [3, 10], [3, 11], [3, 12], [4, 5], [4, 7], [4, 9], [4, 12], [5, 6], [5, 8], [5, 10], [5, 13], [6, 9], [6, 11], [7, 11], [8, 10], [9, 11]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s0/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d355cff37e1913b9f5bed7e63d4cc8aa0ec993f5 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 1, 4, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l2-s0/tests/check.py b/tasks/construct-rlve-maximum-clique-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s0/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l2-s0/tests/instance.json b/tasks/construct-rlve-maximum-clique-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e54c6d7c0e8958cbe2f04002109667d2a4a50925 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 4, "edges": [[0, 1], [0, 3], [0, 4], [0, 7], [0, 10], [0, 12], [1, 4], [1, 6], [1, 7], [2, 4], [2, 5], [2, 6], [2, 12], [2, 13], [3, 8], [3, 10], [3, 11], [3, 12], [4, 5], [4, 7], [4, 9], [4, 12], [5, 6], [5, 8], [5, 10], [5, 13], [6, 9], [6, 11], [7, 11], [8, 10], [9, 11]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s0/tests/run.py b/tasks/construct-rlve-maximum-clique-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l2-s0/tests/test.sh b/tasks/construct-rlve-maximum-clique-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-maximum-clique-l2-s7/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l2-s7/environment/instance.json b/tasks/construct-rlve-maximum-clique-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..af8778099461b6c51c09604aa1f1a9d5b74abf2d --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 5, "edges": [[0, 1], [0, 3], [0, 7], [0, 9], [0, 10], [0, 11], [0, 13], [1, 2], [1, 5], [1, 6], [1, 7], [1, 8], [1, 10], [1, 13], [2, 3], [2, 5], [2, 6], [2, 8], [2, 9], [2, 10], [3, 4], [3, 6], [3, 9], [3, 10], [3, 11], [4, 5], [4, 8], [4, 9], [4, 11], [4, 12], [4, 13], [5, 7], [5, 8], [5, 9], [5, 11], [6, 8], [6, 10], [6, 12], [7, 9], [7, 11], [7, 12], [7, 13], [8, 10], [8, 11], [9, 10], [9, 11], [10, 12], [10, 13], [11, 12], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s7/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6bd2fc89c99b3b94c830eef66fbe34f0eb5831a3 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 2, 6, 8, 10]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l2-s7/tests/check.py b/tasks/construct-rlve-maximum-clique-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s7/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l2-s7/tests/instance.json b/tasks/construct-rlve-maximum-clique-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..af8778099461b6c51c09604aa1f1a9d5b74abf2d --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 5, "edges": [[0, 1], [0, 3], [0, 7], [0, 9], [0, 10], [0, 11], [0, 13], [1, 2], [1, 5], [1, 6], [1, 7], [1, 8], [1, 10], [1, 13], [2, 3], [2, 5], [2, 6], [2, 8], [2, 9], [2, 10], [3, 4], [3, 6], [3, 9], [3, 10], [3, 11], [4, 5], [4, 8], [4, 9], [4, 11], [4, 12], [4, 13], [5, 7], [5, 8], [5, 9], [5, 11], [6, 8], [6, 10], [6, 12], [7, 9], [7, 11], [7, 12], [7, 13], [8, 10], [8, 11], [9, 10], [9, 11], [10, 12], [10, 13], [11, 12], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s7/tests/run.py b/tasks/construct-rlve-maximum-clique-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l2-s7/tests/test.sh b/tasks/construct-rlve-maximum-clique-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-maximum-clique-l2-s9/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l2-s9/environment/instance.json b/tasks/construct-rlve-maximum-clique-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2114aa0ccfd26d24eff2aae3f398ed7744622db8 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 3, "edges": [[0, 1], [0, 4], [0, 6], [0, 7], [0, 13], [1, 5], [1, 6], [1, 8], [2, 5], [2, 6], [2, 12], [3, 5], [3, 7], [3, 11], [3, 13], [4, 5], [4, 11], [4, 13], [5, 9], [5, 10], [5, 11], [5, 13], [6, 7], [6, 8], [6, 9], [6, 11], [7, 8], [7, 12], [8, 9], [8, 12], [10, 12]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s9/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1071b46bcf60e66a2c4817dbb7c39946b590cf97 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 1, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l2-s9/tests/check.py b/tasks/construct-rlve-maximum-clique-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s9/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l2-s9/tests/instance.json b/tasks/construct-rlve-maximum-clique-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2114aa0ccfd26d24eff2aae3f398ed7744622db8 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 3, "edges": [[0, 1], [0, 4], [0, 6], [0, 7], [0, 13], [1, 5], [1, 6], [1, 8], [2, 5], [2, 6], [2, 12], [3, 5], [3, 7], [3, 11], [3, 13], [4, 5], [4, 11], [4, 13], [5, 9], [5, 10], [5, 11], [5, 13], [6, 7], [6, 8], [6, 9], [6, 11], [7, 8], [7, 12], [8, 9], [8, 12], [10, 12]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s9/tests/run.py b/tasks/construct-rlve-maximum-clique-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l2-s9/tests/test.sh b/tasks/construct-rlve-maximum-clique-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-maximum-clique-l6-s6/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l6-s6/environment/instance.json b/tasks/construct-rlve-maximum-clique-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9e272f3be80bd08bf02dff707251f42ea21c9fcb --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 9, "edges": [[0, 4], [0, 6], [0, 8], [0, 10], [0, 14], [0, 18], [0, 20], [0, 21], [0, 22], [0, 25], [0, 26], [0, 27], [0, 28], [0, 32], [0, 33], [0, 34], [0, 36], [0, 39], [0, 40], [0, 42], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 48], [0, 50], [0, 51], [0, 53], [0, 54], [0, 55], [1, 2], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 13], [1, 14], [1, 15], [1, 17], [1, 18], [1, 19], [1, 21], [1, 23], [1, 25], [1, 29], [1, 30], [1, 31], [1, 32], [1, 35], [1, 38], [1, 40], [1, 41], [1, 42], [1, 44], [1, 47], [1, 48], [1, 49], [1, 54], [1, 55], [2, 3], [2, 4], [2, 6], [2, 8], [2, 9], [2, 10], [2, 13], [2, 15], [2, 18], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 34], [2, 35], [2, 36], [2, 39], [2, 44], [2, 45], [2, 47], [2, 49], [2, 52], [2, 54], [2, 55], [3, 7], [3, 8], [3, 10], [3, 12], [3, 14], [3, 17], [3, 19], [3, 20], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 31], [3, 35], [3, 37], [3, 38], [3, 39], [3, 40], [3, 41], [3, 43], [3, 45], [3, 47], [3, 49], [3, 52], [3, 53], [4, 5], [4, 7], [4, 8], [4, 10], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 22], [4, 23], [4, 24], [4, 25], [4, 28], [4, 30], [4, 32], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 46], [4, 49], [4, 50], [4, 53], [4, 55], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 12], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [5, 24], [5, 26], [5, 27], [5, 30], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [5, 38], [5, 39], [5, 42], [5, 43], [5, 44], [5, 45], [5, 46], [5, 47], [5, 48], [5, 51], [5, 53], [6, 8], [6, 9], [6, 10], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 26], [6, 27], [6, 28], [6, 29], [6, 30], [6, 32], [6, 34], [6, 35], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 46], [6, 47], [6, 48], [6, 49], [6, 51], [6, 53], [6, 55], [7, 8], [7, 9], [7, 11], [7, 13], [7, 14], [7, 15], [7, 17], [7, 20], [7, 21], [7, 22], [7, 23], [7, 26], [7, 29], [7, 33], [7, 34], [7, 35], [7, 36], [7, 38], [7, 39], [7, 40], [7, 43], [7, 44], [7, 46], [7, 47], [7, 53], [7, 55], [8, 9], [8, 13], [8, 16], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 27], [8, 28], [8, 29], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 40], [8, 41], [8, 46], [8, 47], [8, 48], [8, 51], [8, 52], [8, 53], [8, 54], [8, 55], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 26], [9, 27], [9, 28], [9, 32], [9, 34], [9, 35], [9, 36], [9, 38], [9, 40], [9, 41], [9, 42], [9, 46], [9, 48], [9, 49], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [10, 11], [10, 12], [10, 14], [10, 15], [10, 16], [10, 18], [10, 21], [10, 22], [10, 23], [10, 24], [10, 27], [10, 29], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 38], [10, 39], [10, 42], [10, 43], [10, 46], [10, 47], [10, 49], [10, 50], [10, 51], [10, 52], [10, 54], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 35], [11, 40], [11, 42], [11, 44], [11, 47], [11, 48], [11, 49], [11, 51], [11, 52], [11, 53], [11, 54], [12, 15], [12, 20], [12, 23], [12, 24], [12, 25], [12, 26], [12, 28], [12, 29], [12, 30], [12, 32], [12, 33], [12, 37], [12, 38], [12, 39], [12, 40], [12, 42], [12, 43], [12, 44], [12, 46], [12, 47], [12, 48], [12, 49], [12, 50], [12, 53], [12, 55], [13, 16], [13, 17], [13, 19], [13, 22], [13, 25], [13, 26], [13, 27], [13, 28], [13, 30], [13, 32], [13, 33], [13, 37], [13, 40], [13, 41], [13, 42], [13, 45], [13, 46], [13, 47], [13, 48], [13, 49], [13, 50], [13, 51], [13, 53], [13, 54], [14, 15], [14, 18], [14, 19], [14, 20], [14, 23], [14, 26], [14, 27], [14, 30], [14, 31], [14, 33], [14, 34], [14, 36], [14, 37], [14, 39], [14, 40], [14, 41], [14, 42], [14, 45], [14, 46], [14, 47], [14, 48], [14, 49], [14, 50], [14, 51], [14, 53], [14, 54], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 24], [15, 25], [15, 27], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [15, 37], [15, 40], [15, 41], [15, 42], [15, 43], [15, 47], [15, 48], [15, 49], [15, 51], [15, 52], [15, 53], [15, 55], [16, 18], [16, 19], [16, 22], [16, 24], [16, 25], [16, 27], [16, 29], [16, 30], [16, 32], [16, 33], [16, 35], [16, 36], [16, 37], [16, 38], [16, 39], [16, 42], [16, 43], [16, 49], [16, 55], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 30], [17, 31], [17, 32], [17, 33], [17, 35], [17, 36], [17, 39], [17, 40], [17, 41], [17, 43], [17, 47], [17, 51], [17, 52], [17, 53], [17, 54], [18, 19], [18, 22], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 39], [18, 41], [18, 42], [18, 43], [18, 45], [18, 46], [18, 49], [18, 50], [18, 52], [18, 55], [19, 22], [19, 23], [19, 28], [19, 32], [19, 33], [19, 34], [19, 38], [19, 40], [19, 46], [19, 47], [19, 49], [19, 50], [19, 51], [19, 52], [19, 53], [19, 54], [20, 21], [20, 22], [20, 23], [20, 26], [20, 27], [20, 29], [20, 30], [20, 35], [20, 37], [20, 39], [20, 40], [20, 41], [20, 44], [20, 45], [20, 46], [20, 48], [20, 49], [20, 50], [20, 52], [20, 53], [20, 54], [20, 55], [21, 22], [21, 25], [21, 27], [21, 28], [21, 29], [21, 30], [21, 32], [21, 35], [21, 36], [21, 37], [21, 41], [21, 42], [21, 46], [21, 49], [21, 50], [21, 51], [21, 52], [21, 53], [21, 55], [22, 25], [22, 26], [22, 29], [22, 30], [22, 32], [22, 33], [22, 36], [22, 39], [22, 40], [22, 43], [22, 46], [22, 47], [22, 49], [22, 50], [22, 52], [22, 53], [22, 54], [22, 55], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 31], [23, 33], [23, 37], [23, 38], [23, 39], [23, 40], [23, 41], [23, 44], [23, 45], [23, 47], [23, 48], [23, 49], [23, 51], [23, 53], [23, 55], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 34], [24, 35], [24, 38], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 46], [24, 47], [24, 48], [24, 50], [24, 52], [24, 53], [24, 54], [24, 55], [25, 26], [25, 28], [25, 29], [25, 33], [25, 34], [25, 36], [25, 37], [25, 38], [25, 39], [25, 42], [25, 44], [25, 45], [25, 46], [25, 47], [25, 49], [25, 51], [25, 53], [25, 55], [26, 28], [26, 31], [26, 32], [26, 35], [26, 36], [26, 37], [26, 38], [26, 40], [26, 41], [26, 43], [26, 44], [26, 46], [26, 48], [26, 53], [26, 55], [27, 28], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [27, 36], [27, 37], [27, 38], [27, 42], [27, 43], [27, 44], [27, 45], [27, 46], [27, 49], [27, 50], [27, 51], [27, 52], [27, 53], [27, 54], [27, 55], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 36], [28, 39], [28, 40], [28, 41], [28, 43], [28, 44], [28, 45], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 53], [28, 55], [29, 30], [29, 31], [29, 32], [29, 35], [29, 37], [29, 38], [29, 39], [29, 40], [29, 42], [29, 43], [29, 44], [29, 45], [29, 47], [29, 50], [29, 52], [29, 53], [29, 54], [30, 31], [30, 34], [30, 36], [30, 37], [30, 38], [30, 39], [30, 40], [30, 41], [30, 42], [30, 43], [30, 47], [30, 51], [30, 52], [30, 54], [30, 55], [31, 32], [31, 34], [31, 38], [31, 39], [31, 41], [31, 42], [31, 43], [31, 44], [31, 47], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 54], [31, 55], [32, 33], [32, 35], [32, 36], [32, 38], [32, 39], [32, 43], [32, 47], [32, 48], [32, 49], [32, 50], [32, 51], [32, 52], [32, 54], [32, 55], [33, 40], [33, 41], [33, 43], [33, 44], [33, 45], [33, 47], [33, 48], [33, 49], [33, 50], [33, 51], [33, 55], [34, 36], [34, 38], [34, 39], [34, 40], [34, 42], [34, 43], [34, 45], [34, 46], [34, 47], [34, 48], [34, 50], [34, 51], [34, 53], [34, 54], [35, 40], [35, 41], [35, 42], [35, 43], [35, 45], [35, 46], [35, 48], [35, 50], [35, 52], [35, 55], [36, 37], [36, 40], [36, 41], [36, 42], [36, 43], [36, 46], [36, 47], [36, 49], [36, 50], [36, 52], [36, 53], [36, 54], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [37, 44], [37, 45], [37, 48], [37, 49], [37, 51], [37, 52], [37, 55], [38, 41], [38, 46], [38, 47], [38, 48], [38, 49], [38, 51], [38, 53], [38, 55], [39, 40], [39, 41], [39, 43], [39, 44], [39, 45], [39, 48], [39, 51], [39, 52], [39, 54], [39, 55], [40, 42], [40, 45], [40, 46], [40, 47], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 55], [41, 44], [41, 46], [41, 47], [41, 48], [41, 50], [41, 53], [41, 55], [42, 43], [42, 45], [42, 46], [42, 48], [42, 49], [42, 50], [42, 53], [42, 54], [43, 44], [43, 46], [43, 47], [43, 48], [43, 50], [43, 52], [43, 53], [43, 54], [44, 45], [44, 46], [44, 47], [44, 48], [44, 50], [44, 51], [44, 54], [45, 46], [45, 48], [45, 49], [45, 50], [45, 51], [45, 52], [45, 53], [45, 54], [45, 55], [46, 47], [46, 49], [46, 51], [46, 52], [46, 55], [47, 48], [47, 49], [47, 51], [47, 52], [47, 53], [47, 54], [48, 49], [48, 52], [48, 53], [48, 55], [49, 52], [49, 54], [51, 52], [51, 53], [51, 54], [51, 55], [52, 55], [53, 54], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s6/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f277b76c9b943ea030c1bf81b65921cdc772a818 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [2, 8, 9, 20, 21, 27, 35, 52, 55]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l6-s6/tests/check.py b/tasks/construct-rlve-maximum-clique-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s6/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l6-s6/tests/instance.json b/tasks/construct-rlve-maximum-clique-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9e272f3be80bd08bf02dff707251f42ea21c9fcb --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 9, "edges": [[0, 4], [0, 6], [0, 8], [0, 10], [0, 14], [0, 18], [0, 20], [0, 21], [0, 22], [0, 25], [0, 26], [0, 27], [0, 28], [0, 32], [0, 33], [0, 34], [0, 36], [0, 39], [0, 40], [0, 42], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 48], [0, 50], [0, 51], [0, 53], [0, 54], [0, 55], [1, 2], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 13], [1, 14], [1, 15], [1, 17], [1, 18], [1, 19], [1, 21], [1, 23], [1, 25], [1, 29], [1, 30], [1, 31], [1, 32], [1, 35], [1, 38], [1, 40], [1, 41], [1, 42], [1, 44], [1, 47], [1, 48], [1, 49], [1, 54], [1, 55], [2, 3], [2, 4], [2, 6], [2, 8], [2, 9], [2, 10], [2, 13], [2, 15], [2, 18], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 34], [2, 35], [2, 36], [2, 39], [2, 44], [2, 45], [2, 47], [2, 49], [2, 52], [2, 54], [2, 55], [3, 7], [3, 8], [3, 10], [3, 12], [3, 14], [3, 17], [3, 19], [3, 20], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 31], [3, 35], [3, 37], [3, 38], [3, 39], [3, 40], [3, 41], [3, 43], [3, 45], [3, 47], [3, 49], [3, 52], [3, 53], [4, 5], [4, 7], [4, 8], [4, 10], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 22], [4, 23], [4, 24], [4, 25], [4, 28], [4, 30], [4, 32], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 46], [4, 49], [4, 50], [4, 53], [4, 55], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 12], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [5, 24], [5, 26], [5, 27], [5, 30], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [5, 38], [5, 39], [5, 42], [5, 43], [5, 44], [5, 45], [5, 46], [5, 47], [5, 48], [5, 51], [5, 53], [6, 8], [6, 9], [6, 10], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 26], [6, 27], [6, 28], [6, 29], [6, 30], [6, 32], [6, 34], [6, 35], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 46], [6, 47], [6, 48], [6, 49], [6, 51], [6, 53], [6, 55], [7, 8], [7, 9], [7, 11], [7, 13], [7, 14], [7, 15], [7, 17], [7, 20], [7, 21], [7, 22], [7, 23], [7, 26], [7, 29], [7, 33], [7, 34], [7, 35], [7, 36], [7, 38], [7, 39], [7, 40], [7, 43], [7, 44], [7, 46], [7, 47], [7, 53], [7, 55], [8, 9], [8, 13], [8, 16], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 27], [8, 28], [8, 29], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 40], [8, 41], [8, 46], [8, 47], [8, 48], [8, 51], [8, 52], [8, 53], [8, 54], [8, 55], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 26], [9, 27], [9, 28], [9, 32], [9, 34], [9, 35], [9, 36], [9, 38], [9, 40], [9, 41], [9, 42], [9, 46], [9, 48], [9, 49], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [10, 11], [10, 12], [10, 14], [10, 15], [10, 16], [10, 18], [10, 21], [10, 22], [10, 23], [10, 24], [10, 27], [10, 29], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 38], [10, 39], [10, 42], [10, 43], [10, 46], [10, 47], [10, 49], [10, 50], [10, 51], [10, 52], [10, 54], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 35], [11, 40], [11, 42], [11, 44], [11, 47], [11, 48], [11, 49], [11, 51], [11, 52], [11, 53], [11, 54], [12, 15], [12, 20], [12, 23], [12, 24], [12, 25], [12, 26], [12, 28], [12, 29], [12, 30], [12, 32], [12, 33], [12, 37], [12, 38], [12, 39], [12, 40], [12, 42], [12, 43], [12, 44], [12, 46], [12, 47], [12, 48], [12, 49], [12, 50], [12, 53], [12, 55], [13, 16], [13, 17], [13, 19], [13, 22], [13, 25], [13, 26], [13, 27], [13, 28], [13, 30], [13, 32], [13, 33], [13, 37], [13, 40], [13, 41], [13, 42], [13, 45], [13, 46], [13, 47], [13, 48], [13, 49], [13, 50], [13, 51], [13, 53], [13, 54], [14, 15], [14, 18], [14, 19], [14, 20], [14, 23], [14, 26], [14, 27], [14, 30], [14, 31], [14, 33], [14, 34], [14, 36], [14, 37], [14, 39], [14, 40], [14, 41], [14, 42], [14, 45], [14, 46], [14, 47], [14, 48], [14, 49], [14, 50], [14, 51], [14, 53], [14, 54], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 24], [15, 25], [15, 27], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [15, 37], [15, 40], [15, 41], [15, 42], [15, 43], [15, 47], [15, 48], [15, 49], [15, 51], [15, 52], [15, 53], [15, 55], [16, 18], [16, 19], [16, 22], [16, 24], [16, 25], [16, 27], [16, 29], [16, 30], [16, 32], [16, 33], [16, 35], [16, 36], [16, 37], [16, 38], [16, 39], [16, 42], [16, 43], [16, 49], [16, 55], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 30], [17, 31], [17, 32], [17, 33], [17, 35], [17, 36], [17, 39], [17, 40], [17, 41], [17, 43], [17, 47], [17, 51], [17, 52], [17, 53], [17, 54], [18, 19], [18, 22], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 39], [18, 41], [18, 42], [18, 43], [18, 45], [18, 46], [18, 49], [18, 50], [18, 52], [18, 55], [19, 22], [19, 23], [19, 28], [19, 32], [19, 33], [19, 34], [19, 38], [19, 40], [19, 46], [19, 47], [19, 49], [19, 50], [19, 51], [19, 52], [19, 53], [19, 54], [20, 21], [20, 22], [20, 23], [20, 26], [20, 27], [20, 29], [20, 30], [20, 35], [20, 37], [20, 39], [20, 40], [20, 41], [20, 44], [20, 45], [20, 46], [20, 48], [20, 49], [20, 50], [20, 52], [20, 53], [20, 54], [20, 55], [21, 22], [21, 25], [21, 27], [21, 28], [21, 29], [21, 30], [21, 32], [21, 35], [21, 36], [21, 37], [21, 41], [21, 42], [21, 46], [21, 49], [21, 50], [21, 51], [21, 52], [21, 53], [21, 55], [22, 25], [22, 26], [22, 29], [22, 30], [22, 32], [22, 33], [22, 36], [22, 39], [22, 40], [22, 43], [22, 46], [22, 47], [22, 49], [22, 50], [22, 52], [22, 53], [22, 54], [22, 55], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 31], [23, 33], [23, 37], [23, 38], [23, 39], [23, 40], [23, 41], [23, 44], [23, 45], [23, 47], [23, 48], [23, 49], [23, 51], [23, 53], [23, 55], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 34], [24, 35], [24, 38], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 46], [24, 47], [24, 48], [24, 50], [24, 52], [24, 53], [24, 54], [24, 55], [25, 26], [25, 28], [25, 29], [25, 33], [25, 34], [25, 36], [25, 37], [25, 38], [25, 39], [25, 42], [25, 44], [25, 45], [25, 46], [25, 47], [25, 49], [25, 51], [25, 53], [25, 55], [26, 28], [26, 31], [26, 32], [26, 35], [26, 36], [26, 37], [26, 38], [26, 40], [26, 41], [26, 43], [26, 44], [26, 46], [26, 48], [26, 53], [26, 55], [27, 28], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [27, 36], [27, 37], [27, 38], [27, 42], [27, 43], [27, 44], [27, 45], [27, 46], [27, 49], [27, 50], [27, 51], [27, 52], [27, 53], [27, 54], [27, 55], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 36], [28, 39], [28, 40], [28, 41], [28, 43], [28, 44], [28, 45], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 53], [28, 55], [29, 30], [29, 31], [29, 32], [29, 35], [29, 37], [29, 38], [29, 39], [29, 40], [29, 42], [29, 43], [29, 44], [29, 45], [29, 47], [29, 50], [29, 52], [29, 53], [29, 54], [30, 31], [30, 34], [30, 36], [30, 37], [30, 38], [30, 39], [30, 40], [30, 41], [30, 42], [30, 43], [30, 47], [30, 51], [30, 52], [30, 54], [30, 55], [31, 32], [31, 34], [31, 38], [31, 39], [31, 41], [31, 42], [31, 43], [31, 44], [31, 47], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 54], [31, 55], [32, 33], [32, 35], [32, 36], [32, 38], [32, 39], [32, 43], [32, 47], [32, 48], [32, 49], [32, 50], [32, 51], [32, 52], [32, 54], [32, 55], [33, 40], [33, 41], [33, 43], [33, 44], [33, 45], [33, 47], [33, 48], [33, 49], [33, 50], [33, 51], [33, 55], [34, 36], [34, 38], [34, 39], [34, 40], [34, 42], [34, 43], [34, 45], [34, 46], [34, 47], [34, 48], [34, 50], [34, 51], [34, 53], [34, 54], [35, 40], [35, 41], [35, 42], [35, 43], [35, 45], [35, 46], [35, 48], [35, 50], [35, 52], [35, 55], [36, 37], [36, 40], [36, 41], [36, 42], [36, 43], [36, 46], [36, 47], [36, 49], [36, 50], [36, 52], [36, 53], [36, 54], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [37, 44], [37, 45], [37, 48], [37, 49], [37, 51], [37, 52], [37, 55], [38, 41], [38, 46], [38, 47], [38, 48], [38, 49], [38, 51], [38, 53], [38, 55], [39, 40], [39, 41], [39, 43], [39, 44], [39, 45], [39, 48], [39, 51], [39, 52], [39, 54], [39, 55], [40, 42], [40, 45], [40, 46], [40, 47], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 55], [41, 44], [41, 46], [41, 47], [41, 48], [41, 50], [41, 53], [41, 55], [42, 43], [42, 45], [42, 46], [42, 48], [42, 49], [42, 50], [42, 53], [42, 54], [43, 44], [43, 46], [43, 47], [43, 48], [43, 50], [43, 52], [43, 53], [43, 54], [44, 45], [44, 46], [44, 47], [44, 48], [44, 50], [44, 51], [44, 54], [45, 46], [45, 48], [45, 49], [45, 50], [45, 51], [45, 52], [45, 53], [45, 54], [45, 55], [46, 47], [46, 49], [46, 51], [46, 52], [46, 55], [47, 48], [47, 49], [47, 51], [47, 52], [47, 53], [47, 54], [48, 49], [48, 52], [48, 53], [48, 55], [49, 52], [49, 54], [51, 52], [51, 53], [51, 54], [51, 55], [52, 55], [53, 54], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s6/tests/run.py b/tasks/construct-rlve-maximum-clique-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l6-s6/tests/test.sh b/tasks/construct-rlve-maximum-clique-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-maximum-clique-l6-s8/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l6-s8/environment/instance.json b/tasks/construct-rlve-maximum-clique-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c543eaf4b89eae4e81b2f773ca5e67787c6ffcc5 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 12, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 6], [0, 8], [0, 10], [0, 11], [0, 12], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 21], [0, 24], [0, 25], [0, 27], [0, 28], [0, 29], [0, 30], [0, 32], [0, 33], [0, 35], [0, 36], [0, 38], [0, 41], [0, 43], [0, 45], [0, 46], [0, 48], [0, 49], [0, 50], [0, 52], [0, 53], [0, 54], [0, 55], [1, 2], [1, 3], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 15], [1, 16], [1, 17], [1, 19], [1, 20], [1, 21], [1, 23], [1, 24], [1, 26], [1, 27], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 48], [1, 49], [1, 51], [1, 52], [1, 53], [1, 55], [2, 5], [2, 6], [2, 8], [2, 9], [2, 11], [2, 13], [2, 15], [2, 16], [2, 18], [2, 19], [2, 20], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [2, 40], [2, 41], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 48], [2, 49], [2, 50], [2, 52], [2, 54], [3, 4], [3, 5], [3, 7], [3, 8], [3, 9], [3, 11], [3, 12], [3, 13], [3, 14], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 31], [3, 32], [3, 34], [3, 35], [3, 36], [3, 38], [3, 39], [3, 40], [3, 41], [3, 42], [3, 43], [3, 44], [3, 46], [3, 47], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 25], [4, 26], [4, 27], [4, 28], [4, 30], [4, 31], [4, 35], [4, 36], [4, 37], [4, 40], [4, 46], [4, 48], [4, 51], [4, 52], [4, 53], [4, 54], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 13], [5, 14], [5, 17], [5, 18], [5, 23], [5, 24], [5, 25], [5, 28], [5, 30], [5, 33], [5, 35], [5, 36], [5, 38], [5, 39], [5, 40], [5, 41], [5, 43], [5, 44], [5, 45], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [6, 7], [6, 8], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 19], [6, 20], [6, 21], [6, 23], [6, 26], [6, 27], [6, 28], [6, 30], [6, 32], [6, 33], [6, 34], [6, 36], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 46], [6, 48], [6, 50], [6, 51], [6, 52], [6, 54], [6, 55], [7, 8], [7, 9], [7, 12], [7, 14], [7, 15], [7, 16], [7, 18], [7, 19], [7, 21], [7, 22], [7, 23], [7, 25], [7, 26], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 39], [7, 40], [7, 41], [7, 42], [7, 43], [7, 45], [7, 46], [7, 47], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 55], [8, 11], [8, 12], [8, 13], [8, 15], [8, 16], [8, 17], [8, 18], [8, 20], [8, 21], [8, 22], [8, 23], [8, 27], [8, 31], [8, 34], [8, 35], [8, 36], [8, 37], [8, 39], [8, 42], [8, 43], [8, 44], [8, 46], [8, 47], [8, 48], [8, 49], [8, 50], [8, 51], [8, 53], [8, 54], [8, 55], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 20], [9, 21], [9, 23], [9, 28], [9, 29], [9, 30], [9, 31], [9, 33], [9, 34], [9, 36], [9, 37], [9, 38], [9, 39], [9, 41], [9, 43], [9, 44], [9, 45], [9, 46], [9, 47], [9, 48], [9, 49], [9, 50], [9, 52], [9, 53], [9, 55], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 20], [10, 21], [10, 22], [10, 23], [10, 24], [10, 26], [10, 28], [10, 30], [10, 32], [10, 34], [10, 35], [10, 37], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 45], [10, 46], [10, 48], [10, 49], [10, 50], [10, 51], [10, 53], [10, 54], [10, 55], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 27], [11, 29], [11, 30], [11, 32], [11, 36], [11, 37], [11, 40], [11, 41], [11, 43], [11, 44], [11, 46], [11, 48], [11, 49], [11, 50], [11, 51], [11, 52], [11, 54], [11, 55], [12, 13], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 26], [12, 28], [12, 29], [12, 30], [12, 31], [12, 33], [12, 37], [12, 38], [12, 40], [12, 42], [12, 46], [12, 47], [12, 50], [12, 51], [12, 52], [12, 53], [13, 14], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 25], [13, 26], [13, 27], [13, 28], [13, 30], [13, 32], [13, 33], [13, 35], [13, 36], [13, 37], [13, 38], [13, 40], [13, 43], [13, 44], [13, 45], [13, 46], [13, 48], [13, 49], [13, 51], [13, 52], [13, 53], [13, 54], [13, 55], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 26], [14, 28], [14, 29], [14, 30], [14, 31], [14, 33], [14, 34], [14, 36], [14, 37], [14, 38], [14, 39], [14, 42], [14, 43], [14, 44], [14, 45], [14, 46], [14, 47], [14, 48], [14, 49], [14, 52], [14, 53], [14, 54], [15, 16], [15, 18], [15, 20], [15, 24], [15, 25], [15, 26], [15, 27], [15, 29], [15, 32], [15, 36], [15, 38], [15, 39], [15, 41], [15, 42], [15, 44], [15, 47], [15, 48], [15, 50], [15, 51], [15, 52], [15, 54], [15, 55], [16, 17], [16, 18], [16, 19], [16, 21], [16, 22], [16, 23], [16, 26], [16, 27], [16, 29], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [16, 36], [16, 38], [16, 39], [16, 40], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 46], [16, 47], [16, 49], [16, 53], [16, 55], [17, 18], [17, 21], [17, 22], [17, 23], [17, 26], [17, 27], [17, 29], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 38], [17, 39], [17, 41], [17, 42], [17, 45], [17, 46], [17, 48], [17, 49], [17, 52], [17, 54], [17, 55], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 29], [18, 31], [18, 32], [18, 33], [18, 34], [18, 36], [18, 37], [18, 39], [18, 42], [18, 43], [18, 44], [18, 45], [18, 46], [18, 49], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 34], [19, 35], [19, 36], [19, 37], [19, 39], [19, 40], [19, 41], [19, 42], [19, 43], [19, 46], [19, 49], [19, 51], [19, 53], [19, 54], [19, 55], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 30], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [20, 36], [20, 37], [20, 39], [20, 40], [20, 41], [20, 42], [20, 43], [20, 45], [20, 48], [20, 49], [20, 50], [20, 51], [20, 52], [20, 54], [20, 55], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [21, 41], [21, 42], [21, 44], [21, 45], [21, 46], [21, 47], [21, 48], [21, 50], [21, 52], [21, 53], [21, 55], [22, 23], [22, 24], [22, 26], [22, 27], [22, 28], [22, 29], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [22, 37], [22, 38], [22, 40], [22, 41], [22, 43], [22, 44], [22, 46], [22, 50], [22, 52], [22, 53], [22, 54], [22, 55], [23, 24], [23, 28], [23, 29], [23, 30], [23, 34], [23, 35], [23, 36], [23, 37], [23, 38], [23, 39], [23, 41], [23, 42], [23, 43], [23, 44], [23, 47], [23, 48], [23, 50], [23, 52], [23, 54], [23, 55], [24, 25], [24, 28], [24, 29], [24, 31], [24, 33], [24, 38], [24, 40], [24, 42], [24, 43], [24, 45], [24, 46], [24, 49], [24, 51], [24, 53], [24, 55], [25, 26], [25, 27], [25, 29], [25, 30], [25, 32], [25, 33], [25, 36], [25, 37], [25, 38], [25, 39], [25, 41], [25, 43], [25, 44], [25, 45], [25, 47], [25, 48], [25, 49], [25, 50], [25, 52], [25, 53], [25, 54], [25, 55], [26, 27], [26, 28], [26, 29], [26, 30], [26, 33], [26, 34], [26, 36], [26, 37], [26, 38], [26, 40], [26, 41], [26, 43], [26, 45], [26, 46], [26, 47], [26, 48], [26, 49], [26, 50], [26, 52], [26, 53], [26, 54], [26, 55], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 36], [27, 38], [27, 39], [27, 40], [27, 42], [27, 44], [27, 45], [27, 46], [27, 48], [27, 49], [27, 50], [27, 51], [27, 53], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [28, 37], [28, 39], [28, 40], [28, 41], [28, 43], [28, 45], [28, 46], [28, 47], [28, 48], [28, 50], [28, 51], [28, 52], [28, 53], [28, 54], [28, 55], [29, 33], [29, 34], [29, 35], [29, 37], [29, 39], [29, 42], [29, 43], [29, 44], [29, 45], [29, 46], [29, 48], [29, 49], [29, 53], [30, 32], [30, 33], [30, 34], [30, 36], [30, 37], [30, 40], [30, 42], [30, 43], [30, 44], [30, 46], [30, 47], [30, 48], [30, 49], [30, 50], [30, 51], [30, 52], [30, 53], [30, 54], [30, 55], [31, 33], [31, 34], [31, 35], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [31, 43], [31, 45], [31, 46], [31, 47], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [32, 33], [32, 36], [32, 42], [32, 44], [32, 46], [32, 47], [32, 49], [32, 50], [32, 52], [32, 55], [33, 34], [33, 35], [33, 36], [33, 37], [33, 38], [33, 39], [33, 40], [33, 42], [33, 45], [33, 46], [33, 47], [33, 49], [33, 50], [33, 51], [33, 53], [33, 54], [33, 55], [34, 36], [34, 39], [34, 42], [34, 43], [34, 45], [34, 47], [34, 49], [34, 50], [34, 51], [34, 52], [34, 53], [34, 54], [35, 38], [35, 40], [35, 41], [35, 42], [35, 43], [35, 44], [35, 45], [35, 49], [35, 51], [35, 54], [35, 55], [36, 38], [36, 39], [36, 40], [36, 42], [36, 43], [36, 45], [36, 46], [36, 47], [36, 48], [36, 49], [36, 50], [36, 54], [36, 55], [37, 38], [37, 39], [37, 41], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 48], [37, 50], [37, 51], [37, 55], [38, 39], [38, 40], [38, 43], [38, 45], [38, 46], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [39, 43], [39, 44], [39, 46], [39, 50], [39, 51], [39, 52], [39, 53], [39, 55], [40, 42], [40, 44], [40, 45], [40, 46], [40, 47], [40, 48], [40, 49], [40, 50], [40, 51], [41, 42], [41, 43], [41, 44], [41, 47], [41, 48], [41, 49], [41, 50], [41, 51], [41, 52], [41, 53], [41, 54], [41, 55], [42, 43], [42, 44], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 50], [42, 51], [42, 52], [42, 53], [43, 44], [43, 45], [43, 46], [43, 47], [43, 48], [43, 50], [43, 51], [43, 53], [43, 55], [44, 45], [44, 48], [44, 49], [44, 50], [44, 51], [44, 52], [44, 53], [44, 54], [44, 55], [45, 46], [45, 47], [45, 48], [45, 49], [45, 50], [45, 51], [45, 52], [45, 54], [45, 55], [46, 47], [46, 48], [46, 49], [46, 50], [46, 52], [46, 53], [46, 54], [47, 48], [47, 49], [47, 50], [47, 52], [47, 53], [47, 54], [47, 55], [48, 50], [48, 51], [48, 52], [48, 53], [48, 54], [49, 50], [49, 52], [49, 53], [50, 51], [50, 53], [50, 54], [51, 52], [51, 55], [52, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s8/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4069e43e227f56e8d481d08307b8a07e20602fd7 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 2, 13, 16, 26, 27, 33, 38, 40, 45, 46, 49]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l6-s8/tests/check.py b/tasks/construct-rlve-maximum-clique-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s8/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l6-s8/tests/instance.json b/tasks/construct-rlve-maximum-clique-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c543eaf4b89eae4e81b2f773ca5e67787c6ffcc5 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 12, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 6], [0, 8], [0, 10], [0, 11], [0, 12], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 21], [0, 24], [0, 25], [0, 27], [0, 28], [0, 29], [0, 30], [0, 32], [0, 33], [0, 35], [0, 36], [0, 38], [0, 41], [0, 43], [0, 45], [0, 46], [0, 48], [0, 49], [0, 50], [0, 52], [0, 53], [0, 54], [0, 55], [1, 2], [1, 3], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 15], [1, 16], [1, 17], [1, 19], [1, 20], [1, 21], [1, 23], [1, 24], [1, 26], [1, 27], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 48], [1, 49], [1, 51], [1, 52], [1, 53], [1, 55], [2, 5], [2, 6], [2, 8], [2, 9], [2, 11], [2, 13], [2, 15], [2, 16], [2, 18], [2, 19], [2, 20], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [2, 40], [2, 41], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 48], [2, 49], [2, 50], [2, 52], [2, 54], [3, 4], [3, 5], [3, 7], [3, 8], [3, 9], [3, 11], [3, 12], [3, 13], [3, 14], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 31], [3, 32], [3, 34], [3, 35], [3, 36], [3, 38], [3, 39], [3, 40], [3, 41], [3, 42], [3, 43], [3, 44], [3, 46], [3, 47], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 25], [4, 26], [4, 27], [4, 28], [4, 30], [4, 31], [4, 35], [4, 36], [4, 37], [4, 40], [4, 46], [4, 48], [4, 51], [4, 52], [4, 53], [4, 54], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 13], [5, 14], [5, 17], [5, 18], [5, 23], [5, 24], [5, 25], [5, 28], [5, 30], [5, 33], [5, 35], [5, 36], [5, 38], [5, 39], [5, 40], [5, 41], [5, 43], [5, 44], [5, 45], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [6, 7], [6, 8], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 19], [6, 20], [6, 21], [6, 23], [6, 26], [6, 27], [6, 28], [6, 30], [6, 32], [6, 33], [6, 34], [6, 36], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 46], [6, 48], [6, 50], [6, 51], [6, 52], [6, 54], [6, 55], [7, 8], [7, 9], [7, 12], [7, 14], [7, 15], [7, 16], [7, 18], [7, 19], [7, 21], [7, 22], [7, 23], [7, 25], [7, 26], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 39], [7, 40], [7, 41], [7, 42], [7, 43], [7, 45], [7, 46], [7, 47], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 55], [8, 11], [8, 12], [8, 13], [8, 15], [8, 16], [8, 17], [8, 18], [8, 20], [8, 21], [8, 22], [8, 23], [8, 27], [8, 31], [8, 34], [8, 35], [8, 36], [8, 37], [8, 39], [8, 42], [8, 43], [8, 44], [8, 46], [8, 47], [8, 48], [8, 49], [8, 50], [8, 51], [8, 53], [8, 54], [8, 55], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 20], [9, 21], [9, 23], [9, 28], [9, 29], [9, 30], [9, 31], [9, 33], [9, 34], [9, 36], [9, 37], [9, 38], [9, 39], [9, 41], [9, 43], [9, 44], [9, 45], [9, 46], [9, 47], [9, 48], [9, 49], [9, 50], [9, 52], [9, 53], [9, 55], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 20], [10, 21], [10, 22], [10, 23], [10, 24], [10, 26], [10, 28], [10, 30], [10, 32], [10, 34], [10, 35], [10, 37], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 45], [10, 46], [10, 48], [10, 49], [10, 50], [10, 51], [10, 53], [10, 54], [10, 55], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 27], [11, 29], [11, 30], [11, 32], [11, 36], [11, 37], [11, 40], [11, 41], [11, 43], [11, 44], [11, 46], [11, 48], [11, 49], [11, 50], [11, 51], [11, 52], [11, 54], [11, 55], [12, 13], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 26], [12, 28], [12, 29], [12, 30], [12, 31], [12, 33], [12, 37], [12, 38], [12, 40], [12, 42], [12, 46], [12, 47], [12, 50], [12, 51], [12, 52], [12, 53], [13, 14], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 25], [13, 26], [13, 27], [13, 28], [13, 30], [13, 32], [13, 33], [13, 35], [13, 36], [13, 37], [13, 38], [13, 40], [13, 43], [13, 44], [13, 45], [13, 46], [13, 48], [13, 49], [13, 51], [13, 52], [13, 53], [13, 54], [13, 55], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 26], [14, 28], [14, 29], [14, 30], [14, 31], [14, 33], [14, 34], [14, 36], [14, 37], [14, 38], [14, 39], [14, 42], [14, 43], [14, 44], [14, 45], [14, 46], [14, 47], [14, 48], [14, 49], [14, 52], [14, 53], [14, 54], [15, 16], [15, 18], [15, 20], [15, 24], [15, 25], [15, 26], [15, 27], [15, 29], [15, 32], [15, 36], [15, 38], [15, 39], [15, 41], [15, 42], [15, 44], [15, 47], [15, 48], [15, 50], [15, 51], [15, 52], [15, 54], [15, 55], [16, 17], [16, 18], [16, 19], [16, 21], [16, 22], [16, 23], [16, 26], [16, 27], [16, 29], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [16, 36], [16, 38], [16, 39], [16, 40], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 46], [16, 47], [16, 49], [16, 53], [16, 55], [17, 18], [17, 21], [17, 22], [17, 23], [17, 26], [17, 27], [17, 29], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 38], [17, 39], [17, 41], [17, 42], [17, 45], [17, 46], [17, 48], [17, 49], [17, 52], [17, 54], [17, 55], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 29], [18, 31], [18, 32], [18, 33], [18, 34], [18, 36], [18, 37], [18, 39], [18, 42], [18, 43], [18, 44], [18, 45], [18, 46], [18, 49], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 34], [19, 35], [19, 36], [19, 37], [19, 39], [19, 40], [19, 41], [19, 42], [19, 43], [19, 46], [19, 49], [19, 51], [19, 53], [19, 54], [19, 55], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 30], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [20, 36], [20, 37], [20, 39], [20, 40], [20, 41], [20, 42], [20, 43], [20, 45], [20, 48], [20, 49], [20, 50], [20, 51], [20, 52], [20, 54], [20, 55], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [21, 41], [21, 42], [21, 44], [21, 45], [21, 46], [21, 47], [21, 48], [21, 50], [21, 52], [21, 53], [21, 55], [22, 23], [22, 24], [22, 26], [22, 27], [22, 28], [22, 29], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [22, 37], [22, 38], [22, 40], [22, 41], [22, 43], [22, 44], [22, 46], [22, 50], [22, 52], [22, 53], [22, 54], [22, 55], [23, 24], [23, 28], [23, 29], [23, 30], [23, 34], [23, 35], [23, 36], [23, 37], [23, 38], [23, 39], [23, 41], [23, 42], [23, 43], [23, 44], [23, 47], [23, 48], [23, 50], [23, 52], [23, 54], [23, 55], [24, 25], [24, 28], [24, 29], [24, 31], [24, 33], [24, 38], [24, 40], [24, 42], [24, 43], [24, 45], [24, 46], [24, 49], [24, 51], [24, 53], [24, 55], [25, 26], [25, 27], [25, 29], [25, 30], [25, 32], [25, 33], [25, 36], [25, 37], [25, 38], [25, 39], [25, 41], [25, 43], [25, 44], [25, 45], [25, 47], [25, 48], [25, 49], [25, 50], [25, 52], [25, 53], [25, 54], [25, 55], [26, 27], [26, 28], [26, 29], [26, 30], [26, 33], [26, 34], [26, 36], [26, 37], [26, 38], [26, 40], [26, 41], [26, 43], [26, 45], [26, 46], [26, 47], [26, 48], [26, 49], [26, 50], [26, 52], [26, 53], [26, 54], [26, 55], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 36], [27, 38], [27, 39], [27, 40], [27, 42], [27, 44], [27, 45], [27, 46], [27, 48], [27, 49], [27, 50], [27, 51], [27, 53], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [28, 37], [28, 39], [28, 40], [28, 41], [28, 43], [28, 45], [28, 46], [28, 47], [28, 48], [28, 50], [28, 51], [28, 52], [28, 53], [28, 54], [28, 55], [29, 33], [29, 34], [29, 35], [29, 37], [29, 39], [29, 42], [29, 43], [29, 44], [29, 45], [29, 46], [29, 48], [29, 49], [29, 53], [30, 32], [30, 33], [30, 34], [30, 36], [30, 37], [30, 40], [30, 42], [30, 43], [30, 44], [30, 46], [30, 47], [30, 48], [30, 49], [30, 50], [30, 51], [30, 52], [30, 53], [30, 54], [30, 55], [31, 33], [31, 34], [31, 35], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [31, 43], [31, 45], [31, 46], [31, 47], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [32, 33], [32, 36], [32, 42], [32, 44], [32, 46], [32, 47], [32, 49], [32, 50], [32, 52], [32, 55], [33, 34], [33, 35], [33, 36], [33, 37], [33, 38], [33, 39], [33, 40], [33, 42], [33, 45], [33, 46], [33, 47], [33, 49], [33, 50], [33, 51], [33, 53], [33, 54], [33, 55], [34, 36], [34, 39], [34, 42], [34, 43], [34, 45], [34, 47], [34, 49], [34, 50], [34, 51], [34, 52], [34, 53], [34, 54], [35, 38], [35, 40], [35, 41], [35, 42], [35, 43], [35, 44], [35, 45], [35, 49], [35, 51], [35, 54], [35, 55], [36, 38], [36, 39], [36, 40], [36, 42], [36, 43], [36, 45], [36, 46], [36, 47], [36, 48], [36, 49], [36, 50], [36, 54], [36, 55], [37, 38], [37, 39], [37, 41], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 48], [37, 50], [37, 51], [37, 55], [38, 39], [38, 40], [38, 43], [38, 45], [38, 46], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [39, 43], [39, 44], [39, 46], [39, 50], [39, 51], [39, 52], [39, 53], [39, 55], [40, 42], [40, 44], [40, 45], [40, 46], [40, 47], [40, 48], [40, 49], [40, 50], [40, 51], [41, 42], [41, 43], [41, 44], [41, 47], [41, 48], [41, 49], [41, 50], [41, 51], [41, 52], [41, 53], [41, 54], [41, 55], [42, 43], [42, 44], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 50], [42, 51], [42, 52], [42, 53], [43, 44], [43, 45], [43, 46], [43, 47], [43, 48], [43, 50], [43, 51], [43, 53], [43, 55], [44, 45], [44, 48], [44, 49], [44, 50], [44, 51], [44, 52], [44, 53], [44, 54], [44, 55], [45, 46], [45, 47], [45, 48], [45, 49], [45, 50], [45, 51], [45, 52], [45, 54], [45, 55], [46, 47], [46, 48], [46, 49], [46, 50], [46, 52], [46, 53], [46, 54], [47, 48], [47, 49], [47, 50], [47, 52], [47, 53], [47, 54], [47, 55], [48, 50], [48, 51], [48, 52], [48, 53], [48, 54], [49, 50], [49, 52], [49, 53], [50, 51], [50, 53], [50, 54], [51, 52], [51, 55], [52, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s8/tests/run.py b/tasks/construct-rlve-maximum-clique-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l6-s8/tests/test.sh b/tasks/construct-rlve-maximum-clique-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s1/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s1/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4f60dd66228b06bfead8451016dca604201a1bf7 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 3], [0, 5], [2, 4]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s1/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..575b530fc848f44fa13288801c3fe60fec1c91d7 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 1, 1, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4f60dd66228b06bfead8451016dca604201a1bf7 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 3], [0, 5], [2, 4]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6525387117825ef79c4c06a3d88869d8adb9598e --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [20, 25, 31, 25, 19, 14, 28, 12, 18, 13, 27, 29, 27, 30, 22, 15, 26, 16, 29, 24, 21, 7, 17, 23, 27, 17, 28, 26], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8ae5998720763ef81cc4c1997b8ce588f86472ed --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"numbers": [1, 6, 11, 12, 13, 14, 15, 16]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6525387117825ef79c4c06a3d88869d8adb9598e --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [20, 25, 31, 25, 19, 14, 28, 12, 18, 13, 27, 29, 27, 30, 22, 15, 26, 16, 29, 24, 21, 7, 17, 23, 27, 17, 28, 26], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b30776a7dca93ad642913c1a53848dcdb53c9069 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [10, 22, 22, 17, 17, 31, 20, 19, 21, 30, 13, 26, 7, 15, 26, 28, 14, 19, 27, 25, 18, 29, 24, 19, 11, 23, 18, 16], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1922d11c885981fc879e3fe1822c5a1232bc1957 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"numbers": [3, 4, 7, 10, 12, 14, 15, 16]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b30776a7dca93ad642913c1a53848dcdb53c9069 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [10, 22, 22, 17, 17, 31, 20, 19, 21, 30, 13, 26, 7, 15, 26, 28, 14, 19, 27, 25, 18, 29, 24, 19, 11, 23, 18, 16], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s4/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s4/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..85e61a20785127b6fc381d56c399eb48a774fa77 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": 433, "B": 809, "C": 169, "D": 339, "target": 339, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s4/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8621e22c2a916b3779f64a427d23eac94637d696 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": 678, "Y": 339} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..85e61a20785127b6fc381d56c399eb48a774fa77 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": 433, "B": 809, "C": 169, "D": 339, "target": 339, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s4/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s4/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f6caef52e7aaa5360a02287569778715a2c883ea --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"X": [2, -3, 4, 6, -4, 5, -5], "Y": [208, 4343, 16236, 200768, 23788, 65071, 88821], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s4/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c3e31319ad616ca3129c9465baf62010a366c8af --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coeffs": [-4, 0, 3, 5, -2, -4, 5]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + X, Y = inst["X"], inst["Y"] + c = int_list(ans.get("coeffs"), len(X), name="coeffs") + for x, y in zip(X, Y): + v = 0 + for a in reversed(c): + v = v * x + a + if v != y: + raise Invalid(f"f({x}) = {v}, need {y}") + return None, {} diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f6caef52e7aaa5360a02287569778715a2c883ea --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"X": [2, -3, 4, 6, -4, 5, -5], "Y": [208, 4343, 16236, 200768, 23788, 65071, 88821], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s5/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s5/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2653fa92decc745ee2b6398ab82df3dc661593c3 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"X": [-3, -5, 4, 0, 2, -2, 5], "Y": [-4, 15292, 11098, 2, 186, -110, 40812], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s5/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..134ede6d65141eae185170ba8ec1eee497aea789 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coeffs": [2, 2, -3, 2, -5, 4, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + X, Y = inst["X"], inst["Y"] + c = int_list(ans.get("coeffs"), len(X), name="coeffs") + for x, y in zip(X, Y): + v = 0 + for a in reversed(c): + v = v * x + a + if v != y: + raise Invalid(f"f({x}) = {v}, need {y}") + return None, {} diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2653fa92decc745ee2b6398ab82df3dc661593c3 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"X": [-3, -5, 4, 0, 2, -2, 5], "Y": [-4, 15292, 11098, 2, 186, -110, 40812], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s0/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s0/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5fdda9818d8b876fbaab498bf9553e55bda895ea --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s0/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fd8999051427ea3d98da11c09bcf82cd39123c04 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [40, 1, 38, 3, 36, 5, 34, 7, 32, 9, 30, 11, 28, 13, 26, 15, 24, 17, 22, 19, 20, 21, 18, 23, 16, 25, 14, 27, 12, 29, 10, 31, 8, 33, 6, 35, 4, 37, 2, 39]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5fdda9818d8b876fbaab498bf9553e55bda895ea --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s7/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s7/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2bde86f78236a891900fd09948d5ca3fc5800866 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 32, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s7/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7c4e5cd635eb3236e9a5c795cac8de635c10018d --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [32, 1, 30, 3, 28, 5, 26, 7, 24, 9, 22, 11, 20, 13, 18, 15, 16, 17, 14, 19, 12, 21, 10, 23, 8, 25, 6, 27, 4, 29, 2, 31]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2bde86f78236a891900fd09948d5ca3fc5800866 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 32, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s9/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s9/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fd1870ab6fb78c3b88136769f4835fed43934ca8 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 52, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s9/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ac324cb8dd6147b05ee48918a9014ac661defaf1 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [52, 1, 50, 3, 48, 5, 46, 7, 44, 9, 42, 11, 40, 13, 38, 15, 36, 17, 34, 19, 32, 21, 30, 23, 28, 25, 26, 27, 24, 29, 22, 31, 20, 33, 18, 35, 16, 37, 14, 39, 12, 41, 10, 43, 8, 45, 6, 47, 4, 49, 2, 51]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fd1870ab6fb78c3b88136769f4835fed43934ca8 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 52, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s1/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s1/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..79664067fd30cc3ebde09afa76ab866525ea6111 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 16894, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s1/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..376903f6f3162ae86eb4a582a468ef85d807c832 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [16894, 1, 16892, 3, 16890, 5, 16888, 7, 16886, 9, 16884, 11, 16882, 13, 16880, 15, 16878, 17, 16876, 19, 16874, 21, 16872, 23, 16870, 25, 16868, 27, 16866, 29, 16864, 31, 16862, 33, 16860, 35, 16858, 37, 16856, 39, 16854, 41, 16852, 43, 16850, 45, 16848, 47, 16846, 49, 16844, 51, 16842, 53, 16840, 55, 16838, 57, 16836, 59, 16834, 61, 16832, 63, 16830, 65, 16828, 67, 16826, 69, 16824, 71, 16822, 73, 16820, 75, 16818, 77, 16816, 79, 16814, 81, 16812, 83, 16810, 85, 16808, 87, 16806, 89, 16804, 91, 16802, 93, 16800, 95, 16798, 97, 16796, 99, 16794, 101, 16792, 103, 16790, 105, 16788, 107, 16786, 109, 16784, 111, 16782, 113, 16780, 115, 16778, 117, 16776, 119, 16774, 121, 16772, 123, 16770, 125, 16768, 127, 16766, 129, 16764, 131, 16762, 133, 16760, 135, 16758, 137, 16756, 139, 16754, 141, 16752, 143, 16750, 145, 16748, 147, 16746, 149, 16744, 151, 16742, 153, 16740, 155, 16738, 157, 16736, 159, 16734, 161, 16732, 163, 16730, 165, 16728, 167, 16726, 169, 16724, 171, 16722, 173, 16720, 175, 16718, 177, 16716, 179, 16714, 181, 16712, 183, 16710, 185, 16708, 187, 16706, 189, 16704, 191, 16702, 193, 16700, 195, 16698, 197, 16696, 199, 16694, 201, 16692, 203, 16690, 205, 16688, 207, 16686, 209, 16684, 211, 16682, 213, 16680, 215, 16678, 217, 16676, 219, 16674, 221, 16672, 223, 16670, 225, 16668, 227, 16666, 229, 16664, 231, 16662, 233, 16660, 235, 16658, 237, 16656, 239, 16654, 241, 16652, 243, 16650, 245, 16648, 247, 16646, 249, 16644, 251, 16642, 253, 16640, 255, 16638, 257, 16636, 259, 16634, 261, 16632, 263, 16630, 265, 16628, 267, 16626, 269, 16624, 271, 16622, 273, 16620, 275, 16618, 277, 16616, 279, 16614, 281, 16612, 283, 16610, 285, 16608, 287, 16606, 289, 16604, 291, 16602, 293, 16600, 295, 16598, 297, 16596, 299, 16594, 301, 16592, 303, 16590, 305, 16588, 307, 16586, 309, 16584, 311, 16582, 313, 16580, 315, 16578, 317, 16576, 319, 16574, 321, 16572, 323, 16570, 325, 16568, 327, 16566, 329, 16564, 331, 16562, 333, 16560, 335, 16558, 337, 16556, 339, 16554, 341, 16552, 343, 16550, 345, 16548, 347, 16546, 349, 16544, 351, 16542, 353, 16540, 355, 16538, 357, 16536, 359, 16534, 361, 16532, 363, 16530, 365, 16528, 367, 16526, 369, 16524, 371, 16522, 373, 16520, 375, 16518, 377, 16516, 379, 16514, 381, 16512, 383, 16510, 385, 16508, 387, 16506, 389, 16504, 391, 16502, 393, 16500, 395, 16498, 397, 16496, 399, 16494, 401, 16492, 403, 16490, 405, 16488, 407, 16486, 409, 16484, 411, 16482, 413, 16480, 415, 16478, 417, 16476, 419, 16474, 421, 16472, 423, 16470, 425, 16468, 427, 16466, 429, 16464, 431, 16462, 433, 16460, 435, 16458, 437, 16456, 439, 16454, 441, 16452, 443, 16450, 445, 16448, 447, 16446, 449, 16444, 451, 16442, 453, 16440, 455, 16438, 457, 16436, 459, 16434, 461, 16432, 463, 16430, 465, 16428, 467, 16426, 469, 16424, 471, 16422, 473, 16420, 475, 16418, 477, 16416, 479, 16414, 481, 16412, 483, 16410, 485, 16408, 487, 16406, 489, 16404, 491, 16402, 493, 16400, 495, 16398, 497, 16396, 499, 16394, 501, 16392, 503, 16390, 505, 16388, 507, 16386, 509, 16384, 511, 16382, 513, 16380, 515, 16378, 517, 16376, 519, 16374, 521, 16372, 523, 16370, 525, 16368, 527, 16366, 529, 16364, 531, 16362, 533, 16360, 535, 16358, 537, 16356, 539, 16354, 541, 16352, 543, 16350, 545, 16348, 547, 16346, 549, 16344, 551, 16342, 553, 16340, 555, 16338, 557, 16336, 559, 16334, 561, 16332, 563, 16330, 565, 16328, 567, 16326, 569, 16324, 571, 16322, 573, 16320, 575, 16318, 577, 16316, 579, 16314, 581, 16312, 583, 16310, 585, 16308, 587, 16306, 589, 16304, 591, 16302, 593, 16300, 595, 16298, 597, 16296, 599, 16294, 601, 16292, 603, 16290, 605, 16288, 607, 16286, 609, 16284, 611, 16282, 613, 16280, 615, 16278, 617, 16276, 619, 16274, 621, 16272, 623, 16270, 625, 16268, 627, 16266, 629, 16264, 631, 16262, 633, 16260, 635, 16258, 637, 16256, 639, 16254, 641, 16252, 643, 16250, 645, 16248, 647, 16246, 649, 16244, 651, 16242, 653, 16240, 655, 16238, 657, 16236, 659, 16234, 661, 16232, 663, 16230, 665, 16228, 667, 16226, 669, 16224, 671, 16222, 673, 16220, 675, 16218, 677, 16216, 679, 16214, 681, 16212, 683, 16210, 685, 16208, 687, 16206, 689, 16204, 691, 16202, 693, 16200, 695, 16198, 697, 16196, 699, 16194, 701, 16192, 703, 16190, 705, 16188, 707, 16186, 709, 16184, 711, 16182, 713, 16180, 715, 16178, 717, 16176, 719, 16174, 721, 16172, 723, 16170, 725, 16168, 727, 16166, 729, 16164, 731, 16162, 733, 16160, 735, 16158, 737, 16156, 739, 16154, 741, 16152, 743, 16150, 745, 16148, 747, 16146, 749, 16144, 751, 16142, 753, 16140, 755, 16138, 757, 16136, 759, 16134, 761, 16132, 763, 16130, 765, 16128, 767, 16126, 769, 16124, 771, 16122, 773, 16120, 775, 16118, 777, 16116, 779, 16114, 781, 16112, 783, 16110, 785, 16108, 787, 16106, 789, 16104, 791, 16102, 793, 16100, 795, 16098, 797, 16096, 799, 16094, 801, 16092, 803, 16090, 805, 16088, 807, 16086, 809, 16084, 811, 16082, 813, 16080, 815, 16078, 817, 16076, 819, 16074, 821, 16072, 823, 16070, 825, 16068, 827, 16066, 829, 16064, 831, 16062, 833, 16060, 835, 16058, 837, 16056, 839, 16054, 841, 16052, 843, 16050, 845, 16048, 847, 16046, 849, 16044, 851, 16042, 853, 16040, 855, 16038, 857, 16036, 859, 16034, 861, 16032, 863, 16030, 865, 16028, 867, 16026, 869, 16024, 871, 16022, 873, 16020, 875, 16018, 877, 16016, 879, 16014, 881, 16012, 883, 16010, 885, 16008, 887, 16006, 889, 16004, 891, 16002, 893, 16000, 895, 15998, 897, 15996, 899, 15994, 901, 15992, 903, 15990, 905, 15988, 907, 15986, 909, 15984, 911, 15982, 913, 15980, 915, 15978, 917, 15976, 919, 15974, 921, 15972, 923, 15970, 925, 15968, 927, 15966, 929, 15964, 931, 15962, 933, 15960, 935, 15958, 937, 15956, 939, 15954, 941, 15952, 943, 15950, 945, 15948, 947, 15946, 949, 15944, 951, 15942, 953, 15940, 955, 15938, 957, 15936, 959, 15934, 961, 15932, 963, 15930, 965, 15928, 967, 15926, 969, 15924, 971, 15922, 973, 15920, 975, 15918, 977, 15916, 979, 15914, 981, 15912, 983, 15910, 985, 15908, 987, 15906, 989, 15904, 991, 15902, 993, 15900, 995, 15898, 997, 15896, 999, 15894, 1001, 15892, 1003, 15890, 1005, 15888, 1007, 15886, 1009, 15884, 1011, 15882, 1013, 15880, 1015, 15878, 1017, 15876, 1019, 15874, 1021, 15872, 1023, 15870, 1025, 15868, 1027, 15866, 1029, 15864, 1031, 15862, 1033, 15860, 1035, 15858, 1037, 15856, 1039, 15854, 1041, 15852, 1043, 15850, 1045, 15848, 1047, 15846, 1049, 15844, 1051, 15842, 1053, 15840, 1055, 15838, 1057, 15836, 1059, 15834, 1061, 15832, 1063, 15830, 1065, 15828, 1067, 15826, 1069, 15824, 1071, 15822, 1073, 15820, 1075, 15818, 1077, 15816, 1079, 15814, 1081, 15812, 1083, 15810, 1085, 15808, 1087, 15806, 1089, 15804, 1091, 15802, 1093, 15800, 1095, 15798, 1097, 15796, 1099, 15794, 1101, 15792, 1103, 15790, 1105, 15788, 1107, 15786, 1109, 15784, 1111, 15782, 1113, 15780, 1115, 15778, 1117, 15776, 1119, 15774, 1121, 15772, 1123, 15770, 1125, 15768, 1127, 15766, 1129, 15764, 1131, 15762, 1133, 15760, 1135, 15758, 1137, 15756, 1139, 15754, 1141, 15752, 1143, 15750, 1145, 15748, 1147, 15746, 1149, 15744, 1151, 15742, 1153, 15740, 1155, 15738, 1157, 15736, 1159, 15734, 1161, 15732, 1163, 15730, 1165, 15728, 1167, 15726, 1169, 15724, 1171, 15722, 1173, 15720, 1175, 15718, 1177, 15716, 1179, 15714, 1181, 15712, 1183, 15710, 1185, 15708, 1187, 15706, 1189, 15704, 1191, 15702, 1193, 15700, 1195, 15698, 1197, 15696, 1199, 15694, 1201, 15692, 1203, 15690, 1205, 15688, 1207, 15686, 1209, 15684, 1211, 15682, 1213, 15680, 1215, 15678, 1217, 15676, 1219, 15674, 1221, 15672, 1223, 15670, 1225, 15668, 1227, 15666, 1229, 15664, 1231, 15662, 1233, 15660, 1235, 15658, 1237, 15656, 1239, 15654, 1241, 15652, 1243, 15650, 1245, 15648, 1247, 15646, 1249, 15644, 1251, 15642, 1253, 15640, 1255, 15638, 1257, 15636, 1259, 15634, 1261, 15632, 1263, 15630, 1265, 15628, 1267, 15626, 1269, 15624, 1271, 15622, 1273, 15620, 1275, 15618, 1277, 15616, 1279, 15614, 1281, 15612, 1283, 15610, 1285, 15608, 1287, 15606, 1289, 15604, 1291, 15602, 1293, 15600, 1295, 15598, 1297, 15596, 1299, 15594, 1301, 15592, 1303, 15590, 1305, 15588, 1307, 15586, 1309, 15584, 1311, 15582, 1313, 15580, 1315, 15578, 1317, 15576, 1319, 15574, 1321, 15572, 1323, 15570, 1325, 15568, 1327, 15566, 1329, 15564, 1331, 15562, 1333, 15560, 1335, 15558, 1337, 15556, 1339, 15554, 1341, 15552, 1343, 15550, 1345, 15548, 1347, 15546, 1349, 15544, 1351, 15542, 1353, 15540, 1355, 15538, 1357, 15536, 1359, 15534, 1361, 15532, 1363, 15530, 1365, 15528, 1367, 15526, 1369, 15524, 1371, 15522, 1373, 15520, 1375, 15518, 1377, 15516, 1379, 15514, 1381, 15512, 1383, 15510, 1385, 15508, 1387, 15506, 1389, 15504, 1391, 15502, 1393, 15500, 1395, 15498, 1397, 15496, 1399, 15494, 1401, 15492, 1403, 15490, 1405, 15488, 1407, 15486, 1409, 15484, 1411, 15482, 1413, 15480, 1415, 15478, 1417, 15476, 1419, 15474, 1421, 15472, 1423, 15470, 1425, 15468, 1427, 15466, 1429, 15464, 1431, 15462, 1433, 15460, 1435, 15458, 1437, 15456, 1439, 15454, 1441, 15452, 1443, 15450, 1445, 15448, 1447, 15446, 1449, 15444, 1451, 15442, 1453, 15440, 1455, 15438, 1457, 15436, 1459, 15434, 1461, 15432, 1463, 15430, 1465, 15428, 1467, 15426, 1469, 15424, 1471, 15422, 1473, 15420, 1475, 15418, 1477, 15416, 1479, 15414, 1481, 15412, 1483, 15410, 1485, 15408, 1487, 15406, 1489, 15404, 1491, 15402, 1493, 15400, 1495, 15398, 1497, 15396, 1499, 15394, 1501, 15392, 1503, 15390, 1505, 15388, 1507, 15386, 1509, 15384, 1511, 15382, 1513, 15380, 1515, 15378, 1517, 15376, 1519, 15374, 1521, 15372, 1523, 15370, 1525, 15368, 1527, 15366, 1529, 15364, 1531, 15362, 1533, 15360, 1535, 15358, 1537, 15356, 1539, 15354, 1541, 15352, 1543, 15350, 1545, 15348, 1547, 15346, 1549, 15344, 1551, 15342, 1553, 15340, 1555, 15338, 1557, 15336, 1559, 15334, 1561, 15332, 1563, 15330, 1565, 15328, 1567, 15326, 1569, 15324, 1571, 15322, 1573, 15320, 1575, 15318, 1577, 15316, 1579, 15314, 1581, 15312, 1583, 15310, 1585, 15308, 1587, 15306, 1589, 15304, 1591, 15302, 1593, 15300, 1595, 15298, 1597, 15296, 1599, 15294, 1601, 15292, 1603, 15290, 1605, 15288, 1607, 15286, 1609, 15284, 1611, 15282, 1613, 15280, 1615, 15278, 1617, 15276, 1619, 15274, 1621, 15272, 1623, 15270, 1625, 15268, 1627, 15266, 1629, 15264, 1631, 15262, 1633, 15260, 1635, 15258, 1637, 15256, 1639, 15254, 1641, 15252, 1643, 15250, 1645, 15248, 1647, 15246, 1649, 15244, 1651, 15242, 1653, 15240, 1655, 15238, 1657, 15236, 1659, 15234, 1661, 15232, 1663, 15230, 1665, 15228, 1667, 15226, 1669, 15224, 1671, 15222, 1673, 15220, 1675, 15218, 1677, 15216, 1679, 15214, 1681, 15212, 1683, 15210, 1685, 15208, 1687, 15206, 1689, 15204, 1691, 15202, 1693, 15200, 1695, 15198, 1697, 15196, 1699, 15194, 1701, 15192, 1703, 15190, 1705, 15188, 1707, 15186, 1709, 15184, 1711, 15182, 1713, 15180, 1715, 15178, 1717, 15176, 1719, 15174, 1721, 15172, 1723, 15170, 1725, 15168, 1727, 15166, 1729, 15164, 1731, 15162, 1733, 15160, 1735, 15158, 1737, 15156, 1739, 15154, 1741, 15152, 1743, 15150, 1745, 15148, 1747, 15146, 1749, 15144, 1751, 15142, 1753, 15140, 1755, 15138, 1757, 15136, 1759, 15134, 1761, 15132, 1763, 15130, 1765, 15128, 1767, 15126, 1769, 15124, 1771, 15122, 1773, 15120, 1775, 15118, 1777, 15116, 1779, 15114, 1781, 15112, 1783, 15110, 1785, 15108, 1787, 15106, 1789, 15104, 1791, 15102, 1793, 15100, 1795, 15098, 1797, 15096, 1799, 15094, 1801, 15092, 1803, 15090, 1805, 15088, 1807, 15086, 1809, 15084, 1811, 15082, 1813, 15080, 1815, 15078, 1817, 15076, 1819, 15074, 1821, 15072, 1823, 15070, 1825, 15068, 1827, 15066, 1829, 15064, 1831, 15062, 1833, 15060, 1835, 15058, 1837, 15056, 1839, 15054, 1841, 15052, 1843, 15050, 1845, 15048, 1847, 15046, 1849, 15044, 1851, 15042, 1853, 15040, 1855, 15038, 1857, 15036, 1859, 15034, 1861, 15032, 1863, 15030, 1865, 15028, 1867, 15026, 1869, 15024, 1871, 15022, 1873, 15020, 1875, 15018, 1877, 15016, 1879, 15014, 1881, 15012, 1883, 15010, 1885, 15008, 1887, 15006, 1889, 15004, 1891, 15002, 1893, 15000, 1895, 14998, 1897, 14996, 1899, 14994, 1901, 14992, 1903, 14990, 1905, 14988, 1907, 14986, 1909, 14984, 1911, 14982, 1913, 14980, 1915, 14978, 1917, 14976, 1919, 14974, 1921, 14972, 1923, 14970, 1925, 14968, 1927, 14966, 1929, 14964, 1931, 14962, 1933, 14960, 1935, 14958, 1937, 14956, 1939, 14954, 1941, 14952, 1943, 14950, 1945, 14948, 1947, 14946, 1949, 14944, 1951, 14942, 1953, 14940, 1955, 14938, 1957, 14936, 1959, 14934, 1961, 14932, 1963, 14930, 1965, 14928, 1967, 14926, 1969, 14924, 1971, 14922, 1973, 14920, 1975, 14918, 1977, 14916, 1979, 14914, 1981, 14912, 1983, 14910, 1985, 14908, 1987, 14906, 1989, 14904, 1991, 14902, 1993, 14900, 1995, 14898, 1997, 14896, 1999, 14894, 2001, 14892, 2003, 14890, 2005, 14888, 2007, 14886, 2009, 14884, 2011, 14882, 2013, 14880, 2015, 14878, 2017, 14876, 2019, 14874, 2021, 14872, 2023, 14870, 2025, 14868, 2027, 14866, 2029, 14864, 2031, 14862, 2033, 14860, 2035, 14858, 2037, 14856, 2039, 14854, 2041, 14852, 2043, 14850, 2045, 14848, 2047, 14846, 2049, 14844, 2051, 14842, 2053, 14840, 2055, 14838, 2057, 14836, 2059, 14834, 2061, 14832, 2063, 14830, 2065, 14828, 2067, 14826, 2069, 14824, 2071, 14822, 2073, 14820, 2075, 14818, 2077, 14816, 2079, 14814, 2081, 14812, 2083, 14810, 2085, 14808, 2087, 14806, 2089, 14804, 2091, 14802, 2093, 14800, 2095, 14798, 2097, 14796, 2099, 14794, 2101, 14792, 2103, 14790, 2105, 14788, 2107, 14786, 2109, 14784, 2111, 14782, 2113, 14780, 2115, 14778, 2117, 14776, 2119, 14774, 2121, 14772, 2123, 14770, 2125, 14768, 2127, 14766, 2129, 14764, 2131, 14762, 2133, 14760, 2135, 14758, 2137, 14756, 2139, 14754, 2141, 14752, 2143, 14750, 2145, 14748, 2147, 14746, 2149, 14744, 2151, 14742, 2153, 14740, 2155, 14738, 2157, 14736, 2159, 14734, 2161, 14732, 2163, 14730, 2165, 14728, 2167, 14726, 2169, 14724, 2171, 14722, 2173, 14720, 2175, 14718, 2177, 14716, 2179, 14714, 2181, 14712, 2183, 14710, 2185, 14708, 2187, 14706, 2189, 14704, 2191, 14702, 2193, 14700, 2195, 14698, 2197, 14696, 2199, 14694, 2201, 14692, 2203, 14690, 2205, 14688, 2207, 14686, 2209, 14684, 2211, 14682, 2213, 14680, 2215, 14678, 2217, 14676, 2219, 14674, 2221, 14672, 2223, 14670, 2225, 14668, 2227, 14666, 2229, 14664, 2231, 14662, 2233, 14660, 2235, 14658, 2237, 14656, 2239, 14654, 2241, 14652, 2243, 14650, 2245, 14648, 2247, 14646, 2249, 14644, 2251, 14642, 2253, 14640, 2255, 14638, 2257, 14636, 2259, 14634, 2261, 14632, 2263, 14630, 2265, 14628, 2267, 14626, 2269, 14624, 2271, 14622, 2273, 14620, 2275, 14618, 2277, 14616, 2279, 14614, 2281, 14612, 2283, 14610, 2285, 14608, 2287, 14606, 2289, 14604, 2291, 14602, 2293, 14600, 2295, 14598, 2297, 14596, 2299, 14594, 2301, 14592, 2303, 14590, 2305, 14588, 2307, 14586, 2309, 14584, 2311, 14582, 2313, 14580, 2315, 14578, 2317, 14576, 2319, 14574, 2321, 14572, 2323, 14570, 2325, 14568, 2327, 14566, 2329, 14564, 2331, 14562, 2333, 14560, 2335, 14558, 2337, 14556, 2339, 14554, 2341, 14552, 2343, 14550, 2345, 14548, 2347, 14546, 2349, 14544, 2351, 14542, 2353, 14540, 2355, 14538, 2357, 14536, 2359, 14534, 2361, 14532, 2363, 14530, 2365, 14528, 2367, 14526, 2369, 14524, 2371, 14522, 2373, 14520, 2375, 14518, 2377, 14516, 2379, 14514, 2381, 14512, 2383, 14510, 2385, 14508, 2387, 14506, 2389, 14504, 2391, 14502, 2393, 14500, 2395, 14498, 2397, 14496, 2399, 14494, 2401, 14492, 2403, 14490, 2405, 14488, 2407, 14486, 2409, 14484, 2411, 14482, 2413, 14480, 2415, 14478, 2417, 14476, 2419, 14474, 2421, 14472, 2423, 14470, 2425, 14468, 2427, 14466, 2429, 14464, 2431, 14462, 2433, 14460, 2435, 14458, 2437, 14456, 2439, 14454, 2441, 14452, 2443, 14450, 2445, 14448, 2447, 14446, 2449, 14444, 2451, 14442, 2453, 14440, 2455, 14438, 2457, 14436, 2459, 14434, 2461, 14432, 2463, 14430, 2465, 14428, 2467, 14426, 2469, 14424, 2471, 14422, 2473, 14420, 2475, 14418, 2477, 14416, 2479, 14414, 2481, 14412, 2483, 14410, 2485, 14408, 2487, 14406, 2489, 14404, 2491, 14402, 2493, 14400, 2495, 14398, 2497, 14396, 2499, 14394, 2501, 14392, 2503, 14390, 2505, 14388, 2507, 14386, 2509, 14384, 2511, 14382, 2513, 14380, 2515, 14378, 2517, 14376, 2519, 14374, 2521, 14372, 2523, 14370, 2525, 14368, 2527, 14366, 2529, 14364, 2531, 14362, 2533, 14360, 2535, 14358, 2537, 14356, 2539, 14354, 2541, 14352, 2543, 14350, 2545, 14348, 2547, 14346, 2549, 14344, 2551, 14342, 2553, 14340, 2555, 14338, 2557, 14336, 2559, 14334, 2561, 14332, 2563, 14330, 2565, 14328, 2567, 14326, 2569, 14324, 2571, 14322, 2573, 14320, 2575, 14318, 2577, 14316, 2579, 14314, 2581, 14312, 2583, 14310, 2585, 14308, 2587, 14306, 2589, 14304, 2591, 14302, 2593, 14300, 2595, 14298, 2597, 14296, 2599, 14294, 2601, 14292, 2603, 14290, 2605, 14288, 2607, 14286, 2609, 14284, 2611, 14282, 2613, 14280, 2615, 14278, 2617, 14276, 2619, 14274, 2621, 14272, 2623, 14270, 2625, 14268, 2627, 14266, 2629, 14264, 2631, 14262, 2633, 14260, 2635, 14258, 2637, 14256, 2639, 14254, 2641, 14252, 2643, 14250, 2645, 14248, 2647, 14246, 2649, 14244, 2651, 14242, 2653, 14240, 2655, 14238, 2657, 14236, 2659, 14234, 2661, 14232, 2663, 14230, 2665, 14228, 2667, 14226, 2669, 14224, 2671, 14222, 2673, 14220, 2675, 14218, 2677, 14216, 2679, 14214, 2681, 14212, 2683, 14210, 2685, 14208, 2687, 14206, 2689, 14204, 2691, 14202, 2693, 14200, 2695, 14198, 2697, 14196, 2699, 14194, 2701, 14192, 2703, 14190, 2705, 14188, 2707, 14186, 2709, 14184, 2711, 14182, 2713, 14180, 2715, 14178, 2717, 14176, 2719, 14174, 2721, 14172, 2723, 14170, 2725, 14168, 2727, 14166, 2729, 14164, 2731, 14162, 2733, 14160, 2735, 14158, 2737, 14156, 2739, 14154, 2741, 14152, 2743, 14150, 2745, 14148, 2747, 14146, 2749, 14144, 2751, 14142, 2753, 14140, 2755, 14138, 2757, 14136, 2759, 14134, 2761, 14132, 2763, 14130, 2765, 14128, 2767, 14126, 2769, 14124, 2771, 14122, 2773, 14120, 2775, 14118, 2777, 14116, 2779, 14114, 2781, 14112, 2783, 14110, 2785, 14108, 2787, 14106, 2789, 14104, 2791, 14102, 2793, 14100, 2795, 14098, 2797, 14096, 2799, 14094, 2801, 14092, 2803, 14090, 2805, 14088, 2807, 14086, 2809, 14084, 2811, 14082, 2813, 14080, 2815, 14078, 2817, 14076, 2819, 14074, 2821, 14072, 2823, 14070, 2825, 14068, 2827, 14066, 2829, 14064, 2831, 14062, 2833, 14060, 2835, 14058, 2837, 14056, 2839, 14054, 2841, 14052, 2843, 14050, 2845, 14048, 2847, 14046, 2849, 14044, 2851, 14042, 2853, 14040, 2855, 14038, 2857, 14036, 2859, 14034, 2861, 14032, 2863, 14030, 2865, 14028, 2867, 14026, 2869, 14024, 2871, 14022, 2873, 14020, 2875, 14018, 2877, 14016, 2879, 14014, 2881, 14012, 2883, 14010, 2885, 14008, 2887, 14006, 2889, 14004, 2891, 14002, 2893, 14000, 2895, 13998, 2897, 13996, 2899, 13994, 2901, 13992, 2903, 13990, 2905, 13988, 2907, 13986, 2909, 13984, 2911, 13982, 2913, 13980, 2915, 13978, 2917, 13976, 2919, 13974, 2921, 13972, 2923, 13970, 2925, 13968, 2927, 13966, 2929, 13964, 2931, 13962, 2933, 13960, 2935, 13958, 2937, 13956, 2939, 13954, 2941, 13952, 2943, 13950, 2945, 13948, 2947, 13946, 2949, 13944, 2951, 13942, 2953, 13940, 2955, 13938, 2957, 13936, 2959, 13934, 2961, 13932, 2963, 13930, 2965, 13928, 2967, 13926, 2969, 13924, 2971, 13922, 2973, 13920, 2975, 13918, 2977, 13916, 2979, 13914, 2981, 13912, 2983, 13910, 2985, 13908, 2987, 13906, 2989, 13904, 2991, 13902, 2993, 13900, 2995, 13898, 2997, 13896, 2999, 13894, 3001, 13892, 3003, 13890, 3005, 13888, 3007, 13886, 3009, 13884, 3011, 13882, 3013, 13880, 3015, 13878, 3017, 13876, 3019, 13874, 3021, 13872, 3023, 13870, 3025, 13868, 3027, 13866, 3029, 13864, 3031, 13862, 3033, 13860, 3035, 13858, 3037, 13856, 3039, 13854, 3041, 13852, 3043, 13850, 3045, 13848, 3047, 13846, 3049, 13844, 3051, 13842, 3053, 13840, 3055, 13838, 3057, 13836, 3059, 13834, 3061, 13832, 3063, 13830, 3065, 13828, 3067, 13826, 3069, 13824, 3071, 13822, 3073, 13820, 3075, 13818, 3077, 13816, 3079, 13814, 3081, 13812, 3083, 13810, 3085, 13808, 3087, 13806, 3089, 13804, 3091, 13802, 3093, 13800, 3095, 13798, 3097, 13796, 3099, 13794, 3101, 13792, 3103, 13790, 3105, 13788, 3107, 13786, 3109, 13784, 3111, 13782, 3113, 13780, 3115, 13778, 3117, 13776, 3119, 13774, 3121, 13772, 3123, 13770, 3125, 13768, 3127, 13766, 3129, 13764, 3131, 13762, 3133, 13760, 3135, 13758, 3137, 13756, 3139, 13754, 3141, 13752, 3143, 13750, 3145, 13748, 3147, 13746, 3149, 13744, 3151, 13742, 3153, 13740, 3155, 13738, 3157, 13736, 3159, 13734, 3161, 13732, 3163, 13730, 3165, 13728, 3167, 13726, 3169, 13724, 3171, 13722, 3173, 13720, 3175, 13718, 3177, 13716, 3179, 13714, 3181, 13712, 3183, 13710, 3185, 13708, 3187, 13706, 3189, 13704, 3191, 13702, 3193, 13700, 3195, 13698, 3197, 13696, 3199, 13694, 3201, 13692, 3203, 13690, 3205, 13688, 3207, 13686, 3209, 13684, 3211, 13682, 3213, 13680, 3215, 13678, 3217, 13676, 3219, 13674, 3221, 13672, 3223, 13670, 3225, 13668, 3227, 13666, 3229, 13664, 3231, 13662, 3233, 13660, 3235, 13658, 3237, 13656, 3239, 13654, 3241, 13652, 3243, 13650, 3245, 13648, 3247, 13646, 3249, 13644, 3251, 13642, 3253, 13640, 3255, 13638, 3257, 13636, 3259, 13634, 3261, 13632, 3263, 13630, 3265, 13628, 3267, 13626, 3269, 13624, 3271, 13622, 3273, 13620, 3275, 13618, 3277, 13616, 3279, 13614, 3281, 13612, 3283, 13610, 3285, 13608, 3287, 13606, 3289, 13604, 3291, 13602, 3293, 13600, 3295, 13598, 3297, 13596, 3299, 13594, 3301, 13592, 3303, 13590, 3305, 13588, 3307, 13586, 3309, 13584, 3311, 13582, 3313, 13580, 3315, 13578, 3317, 13576, 3319, 13574, 3321, 13572, 3323, 13570, 3325, 13568, 3327, 13566, 3329, 13564, 3331, 13562, 3333, 13560, 3335, 13558, 3337, 13556, 3339, 13554, 3341, 13552, 3343, 13550, 3345, 13548, 3347, 13546, 3349, 13544, 3351, 13542, 3353, 13540, 3355, 13538, 3357, 13536, 3359, 13534, 3361, 13532, 3363, 13530, 3365, 13528, 3367, 13526, 3369, 13524, 3371, 13522, 3373, 13520, 3375, 13518, 3377, 13516, 3379, 13514, 3381, 13512, 3383, 13510, 3385, 13508, 3387, 13506, 3389, 13504, 3391, 13502, 3393, 13500, 3395, 13498, 3397, 13496, 3399, 13494, 3401, 13492, 3403, 13490, 3405, 13488, 3407, 13486, 3409, 13484, 3411, 13482, 3413, 13480, 3415, 13478, 3417, 13476, 3419, 13474, 3421, 13472, 3423, 13470, 3425, 13468, 3427, 13466, 3429, 13464, 3431, 13462, 3433, 13460, 3435, 13458, 3437, 13456, 3439, 13454, 3441, 13452, 3443, 13450, 3445, 13448, 3447, 13446, 3449, 13444, 3451, 13442, 3453, 13440, 3455, 13438, 3457, 13436, 3459, 13434, 3461, 13432, 3463, 13430, 3465, 13428, 3467, 13426, 3469, 13424, 3471, 13422, 3473, 13420, 3475, 13418, 3477, 13416, 3479, 13414, 3481, 13412, 3483, 13410, 3485, 13408, 3487, 13406, 3489, 13404, 3491, 13402, 3493, 13400, 3495, 13398, 3497, 13396, 3499, 13394, 3501, 13392, 3503, 13390, 3505, 13388, 3507, 13386, 3509, 13384, 3511, 13382, 3513, 13380, 3515, 13378, 3517, 13376, 3519, 13374, 3521, 13372, 3523, 13370, 3525, 13368, 3527, 13366, 3529, 13364, 3531, 13362, 3533, 13360, 3535, 13358, 3537, 13356, 3539, 13354, 3541, 13352, 3543, 13350, 3545, 13348, 3547, 13346, 3549, 13344, 3551, 13342, 3553, 13340, 3555, 13338, 3557, 13336, 3559, 13334, 3561, 13332, 3563, 13330, 3565, 13328, 3567, 13326, 3569, 13324, 3571, 13322, 3573, 13320, 3575, 13318, 3577, 13316, 3579, 13314, 3581, 13312, 3583, 13310, 3585, 13308, 3587, 13306, 3589, 13304, 3591, 13302, 3593, 13300, 3595, 13298, 3597, 13296, 3599, 13294, 3601, 13292, 3603, 13290, 3605, 13288, 3607, 13286, 3609, 13284, 3611, 13282, 3613, 13280, 3615, 13278, 3617, 13276, 3619, 13274, 3621, 13272, 3623, 13270, 3625, 13268, 3627, 13266, 3629, 13264, 3631, 13262, 3633, 13260, 3635, 13258, 3637, 13256, 3639, 13254, 3641, 13252, 3643, 13250, 3645, 13248, 3647, 13246, 3649, 13244, 3651, 13242, 3653, 13240, 3655, 13238, 3657, 13236, 3659, 13234, 3661, 13232, 3663, 13230, 3665, 13228, 3667, 13226, 3669, 13224, 3671, 13222, 3673, 13220, 3675, 13218, 3677, 13216, 3679, 13214, 3681, 13212, 3683, 13210, 3685, 13208, 3687, 13206, 3689, 13204, 3691, 13202, 3693, 13200, 3695, 13198, 3697, 13196, 3699, 13194, 3701, 13192, 3703, 13190, 3705, 13188, 3707, 13186, 3709, 13184, 3711, 13182, 3713, 13180, 3715, 13178, 3717, 13176, 3719, 13174, 3721, 13172, 3723, 13170, 3725, 13168, 3727, 13166, 3729, 13164, 3731, 13162, 3733, 13160, 3735, 13158, 3737, 13156, 3739, 13154, 3741, 13152, 3743, 13150, 3745, 13148, 3747, 13146, 3749, 13144, 3751, 13142, 3753, 13140, 3755, 13138, 3757, 13136, 3759, 13134, 3761, 13132, 3763, 13130, 3765, 13128, 3767, 13126, 3769, 13124, 3771, 13122, 3773, 13120, 3775, 13118, 3777, 13116, 3779, 13114, 3781, 13112, 3783, 13110, 3785, 13108, 3787, 13106, 3789, 13104, 3791, 13102, 3793, 13100, 3795, 13098, 3797, 13096, 3799, 13094, 3801, 13092, 3803, 13090, 3805, 13088, 3807, 13086, 3809, 13084, 3811, 13082, 3813, 13080, 3815, 13078, 3817, 13076, 3819, 13074, 3821, 13072, 3823, 13070, 3825, 13068, 3827, 13066, 3829, 13064, 3831, 13062, 3833, 13060, 3835, 13058, 3837, 13056, 3839, 13054, 3841, 13052, 3843, 13050, 3845, 13048, 3847, 13046, 3849, 13044, 3851, 13042, 3853, 13040, 3855, 13038, 3857, 13036, 3859, 13034, 3861, 13032, 3863, 13030, 3865, 13028, 3867, 13026, 3869, 13024, 3871, 13022, 3873, 13020, 3875, 13018, 3877, 13016, 3879, 13014, 3881, 13012, 3883, 13010, 3885, 13008, 3887, 13006, 3889, 13004, 3891, 13002, 3893, 13000, 3895, 12998, 3897, 12996, 3899, 12994, 3901, 12992, 3903, 12990, 3905, 12988, 3907, 12986, 3909, 12984, 3911, 12982, 3913, 12980, 3915, 12978, 3917, 12976, 3919, 12974, 3921, 12972, 3923, 12970, 3925, 12968, 3927, 12966, 3929, 12964, 3931, 12962, 3933, 12960, 3935, 12958, 3937, 12956, 3939, 12954, 3941, 12952, 3943, 12950, 3945, 12948, 3947, 12946, 3949, 12944, 3951, 12942, 3953, 12940, 3955, 12938, 3957, 12936, 3959, 12934, 3961, 12932, 3963, 12930, 3965, 12928, 3967, 12926, 3969, 12924, 3971, 12922, 3973, 12920, 3975, 12918, 3977, 12916, 3979, 12914, 3981, 12912, 3983, 12910, 3985, 12908, 3987, 12906, 3989, 12904, 3991, 12902, 3993, 12900, 3995, 12898, 3997, 12896, 3999, 12894, 4001, 12892, 4003, 12890, 4005, 12888, 4007, 12886, 4009, 12884, 4011, 12882, 4013, 12880, 4015, 12878, 4017, 12876, 4019, 12874, 4021, 12872, 4023, 12870, 4025, 12868, 4027, 12866, 4029, 12864, 4031, 12862, 4033, 12860, 4035, 12858, 4037, 12856, 4039, 12854, 4041, 12852, 4043, 12850, 4045, 12848, 4047, 12846, 4049, 12844, 4051, 12842, 4053, 12840, 4055, 12838, 4057, 12836, 4059, 12834, 4061, 12832, 4063, 12830, 4065, 12828, 4067, 12826, 4069, 12824, 4071, 12822, 4073, 12820, 4075, 12818, 4077, 12816, 4079, 12814, 4081, 12812, 4083, 12810, 4085, 12808, 4087, 12806, 4089, 12804, 4091, 12802, 4093, 12800, 4095, 12798, 4097, 12796, 4099, 12794, 4101, 12792, 4103, 12790, 4105, 12788, 4107, 12786, 4109, 12784, 4111, 12782, 4113, 12780, 4115, 12778, 4117, 12776, 4119, 12774, 4121, 12772, 4123, 12770, 4125, 12768, 4127, 12766, 4129, 12764, 4131, 12762, 4133, 12760, 4135, 12758, 4137, 12756, 4139, 12754, 4141, 12752, 4143, 12750, 4145, 12748, 4147, 12746, 4149, 12744, 4151, 12742, 4153, 12740, 4155, 12738, 4157, 12736, 4159, 12734, 4161, 12732, 4163, 12730, 4165, 12728, 4167, 12726, 4169, 12724, 4171, 12722, 4173, 12720, 4175, 12718, 4177, 12716, 4179, 12714, 4181, 12712, 4183, 12710, 4185, 12708, 4187, 12706, 4189, 12704, 4191, 12702, 4193, 12700, 4195, 12698, 4197, 12696, 4199, 12694, 4201, 12692, 4203, 12690, 4205, 12688, 4207, 12686, 4209, 12684, 4211, 12682, 4213, 12680, 4215, 12678, 4217, 12676, 4219, 12674, 4221, 12672, 4223, 12670, 4225, 12668, 4227, 12666, 4229, 12664, 4231, 12662, 4233, 12660, 4235, 12658, 4237, 12656, 4239, 12654, 4241, 12652, 4243, 12650, 4245, 12648, 4247, 12646, 4249, 12644, 4251, 12642, 4253, 12640, 4255, 12638, 4257, 12636, 4259, 12634, 4261, 12632, 4263, 12630, 4265, 12628, 4267, 12626, 4269, 12624, 4271, 12622, 4273, 12620, 4275, 12618, 4277, 12616, 4279, 12614, 4281, 12612, 4283, 12610, 4285, 12608, 4287, 12606, 4289, 12604, 4291, 12602, 4293, 12600, 4295, 12598, 4297, 12596, 4299, 12594, 4301, 12592, 4303, 12590, 4305, 12588, 4307, 12586, 4309, 12584, 4311, 12582, 4313, 12580, 4315, 12578, 4317, 12576, 4319, 12574, 4321, 12572, 4323, 12570, 4325, 12568, 4327, 12566, 4329, 12564, 4331, 12562, 4333, 12560, 4335, 12558, 4337, 12556, 4339, 12554, 4341, 12552, 4343, 12550, 4345, 12548, 4347, 12546, 4349, 12544, 4351, 12542, 4353, 12540, 4355, 12538, 4357, 12536, 4359, 12534, 4361, 12532, 4363, 12530, 4365, 12528, 4367, 12526, 4369, 12524, 4371, 12522, 4373, 12520, 4375, 12518, 4377, 12516, 4379, 12514, 4381, 12512, 4383, 12510, 4385, 12508, 4387, 12506, 4389, 12504, 4391, 12502, 4393, 12500, 4395, 12498, 4397, 12496, 4399, 12494, 4401, 12492, 4403, 12490, 4405, 12488, 4407, 12486, 4409, 12484, 4411, 12482, 4413, 12480, 4415, 12478, 4417, 12476, 4419, 12474, 4421, 12472, 4423, 12470, 4425, 12468, 4427, 12466, 4429, 12464, 4431, 12462, 4433, 12460, 4435, 12458, 4437, 12456, 4439, 12454, 4441, 12452, 4443, 12450, 4445, 12448, 4447, 12446, 4449, 12444, 4451, 12442, 4453, 12440, 4455, 12438, 4457, 12436, 4459, 12434, 4461, 12432, 4463, 12430, 4465, 12428, 4467, 12426, 4469, 12424, 4471, 12422, 4473, 12420, 4475, 12418, 4477, 12416, 4479, 12414, 4481, 12412, 4483, 12410, 4485, 12408, 4487, 12406, 4489, 12404, 4491, 12402, 4493, 12400, 4495, 12398, 4497, 12396, 4499, 12394, 4501, 12392, 4503, 12390, 4505, 12388, 4507, 12386, 4509, 12384, 4511, 12382, 4513, 12380, 4515, 12378, 4517, 12376, 4519, 12374, 4521, 12372, 4523, 12370, 4525, 12368, 4527, 12366, 4529, 12364, 4531, 12362, 4533, 12360, 4535, 12358, 4537, 12356, 4539, 12354, 4541, 12352, 4543, 12350, 4545, 12348, 4547, 12346, 4549, 12344, 4551, 12342, 4553, 12340, 4555, 12338, 4557, 12336, 4559, 12334, 4561, 12332, 4563, 12330, 4565, 12328, 4567, 12326, 4569, 12324, 4571, 12322, 4573, 12320, 4575, 12318, 4577, 12316, 4579, 12314, 4581, 12312, 4583, 12310, 4585, 12308, 4587, 12306, 4589, 12304, 4591, 12302, 4593, 12300, 4595, 12298, 4597, 12296, 4599, 12294, 4601, 12292, 4603, 12290, 4605, 12288, 4607, 12286, 4609, 12284, 4611, 12282, 4613, 12280, 4615, 12278, 4617, 12276, 4619, 12274, 4621, 12272, 4623, 12270, 4625, 12268, 4627, 12266, 4629, 12264, 4631, 12262, 4633, 12260, 4635, 12258, 4637, 12256, 4639, 12254, 4641, 12252, 4643, 12250, 4645, 12248, 4647, 12246, 4649, 12244, 4651, 12242, 4653, 12240, 4655, 12238, 4657, 12236, 4659, 12234, 4661, 12232, 4663, 12230, 4665, 12228, 4667, 12226, 4669, 12224, 4671, 12222, 4673, 12220, 4675, 12218, 4677, 12216, 4679, 12214, 4681, 12212, 4683, 12210, 4685, 12208, 4687, 12206, 4689, 12204, 4691, 12202, 4693, 12200, 4695, 12198, 4697, 12196, 4699, 12194, 4701, 12192, 4703, 12190, 4705, 12188, 4707, 12186, 4709, 12184, 4711, 12182, 4713, 12180, 4715, 12178, 4717, 12176, 4719, 12174, 4721, 12172, 4723, 12170, 4725, 12168, 4727, 12166, 4729, 12164, 4731, 12162, 4733, 12160, 4735, 12158, 4737, 12156, 4739, 12154, 4741, 12152, 4743, 12150, 4745, 12148, 4747, 12146, 4749, 12144, 4751, 12142, 4753, 12140, 4755, 12138, 4757, 12136, 4759, 12134, 4761, 12132, 4763, 12130, 4765, 12128, 4767, 12126, 4769, 12124, 4771, 12122, 4773, 12120, 4775, 12118, 4777, 12116, 4779, 12114, 4781, 12112, 4783, 12110, 4785, 12108, 4787, 12106, 4789, 12104, 4791, 12102, 4793, 12100, 4795, 12098, 4797, 12096, 4799, 12094, 4801, 12092, 4803, 12090, 4805, 12088, 4807, 12086, 4809, 12084, 4811, 12082, 4813, 12080, 4815, 12078, 4817, 12076, 4819, 12074, 4821, 12072, 4823, 12070, 4825, 12068, 4827, 12066, 4829, 12064, 4831, 12062, 4833, 12060, 4835, 12058, 4837, 12056, 4839, 12054, 4841, 12052, 4843, 12050, 4845, 12048, 4847, 12046, 4849, 12044, 4851, 12042, 4853, 12040, 4855, 12038, 4857, 12036, 4859, 12034, 4861, 12032, 4863, 12030, 4865, 12028, 4867, 12026, 4869, 12024, 4871, 12022, 4873, 12020, 4875, 12018, 4877, 12016, 4879, 12014, 4881, 12012, 4883, 12010, 4885, 12008, 4887, 12006, 4889, 12004, 4891, 12002, 4893, 12000, 4895, 11998, 4897, 11996, 4899, 11994, 4901, 11992, 4903, 11990, 4905, 11988, 4907, 11986, 4909, 11984, 4911, 11982, 4913, 11980, 4915, 11978, 4917, 11976, 4919, 11974, 4921, 11972, 4923, 11970, 4925, 11968, 4927, 11966, 4929, 11964, 4931, 11962, 4933, 11960, 4935, 11958, 4937, 11956, 4939, 11954, 4941, 11952, 4943, 11950, 4945, 11948, 4947, 11946, 4949, 11944, 4951, 11942, 4953, 11940, 4955, 11938, 4957, 11936, 4959, 11934, 4961, 11932, 4963, 11930, 4965, 11928, 4967, 11926, 4969, 11924, 4971, 11922, 4973, 11920, 4975, 11918, 4977, 11916, 4979, 11914, 4981, 11912, 4983, 11910, 4985, 11908, 4987, 11906, 4989, 11904, 4991, 11902, 4993, 11900, 4995, 11898, 4997, 11896, 4999, 11894, 5001, 11892, 5003, 11890, 5005, 11888, 5007, 11886, 5009, 11884, 5011, 11882, 5013, 11880, 5015, 11878, 5017, 11876, 5019, 11874, 5021, 11872, 5023, 11870, 5025, 11868, 5027, 11866, 5029, 11864, 5031, 11862, 5033, 11860, 5035, 11858, 5037, 11856, 5039, 11854, 5041, 11852, 5043, 11850, 5045, 11848, 5047, 11846, 5049, 11844, 5051, 11842, 5053, 11840, 5055, 11838, 5057, 11836, 5059, 11834, 5061, 11832, 5063, 11830, 5065, 11828, 5067, 11826, 5069, 11824, 5071, 11822, 5073, 11820, 5075, 11818, 5077, 11816, 5079, 11814, 5081, 11812, 5083, 11810, 5085, 11808, 5087, 11806, 5089, 11804, 5091, 11802, 5093, 11800, 5095, 11798, 5097, 11796, 5099, 11794, 5101, 11792, 5103, 11790, 5105, 11788, 5107, 11786, 5109, 11784, 5111, 11782, 5113, 11780, 5115, 11778, 5117, 11776, 5119, 11774, 5121, 11772, 5123, 11770, 5125, 11768, 5127, 11766, 5129, 11764, 5131, 11762, 5133, 11760, 5135, 11758, 5137, 11756, 5139, 11754, 5141, 11752, 5143, 11750, 5145, 11748, 5147, 11746, 5149, 11744, 5151, 11742, 5153, 11740, 5155, 11738, 5157, 11736, 5159, 11734, 5161, 11732, 5163, 11730, 5165, 11728, 5167, 11726, 5169, 11724, 5171, 11722, 5173, 11720, 5175, 11718, 5177, 11716, 5179, 11714, 5181, 11712, 5183, 11710, 5185, 11708, 5187, 11706, 5189, 11704, 5191, 11702, 5193, 11700, 5195, 11698, 5197, 11696, 5199, 11694, 5201, 11692, 5203, 11690, 5205, 11688, 5207, 11686, 5209, 11684, 5211, 11682, 5213, 11680, 5215, 11678, 5217, 11676, 5219, 11674, 5221, 11672, 5223, 11670, 5225, 11668, 5227, 11666, 5229, 11664, 5231, 11662, 5233, 11660, 5235, 11658, 5237, 11656, 5239, 11654, 5241, 11652, 5243, 11650, 5245, 11648, 5247, 11646, 5249, 11644, 5251, 11642, 5253, 11640, 5255, 11638, 5257, 11636, 5259, 11634, 5261, 11632, 5263, 11630, 5265, 11628, 5267, 11626, 5269, 11624, 5271, 11622, 5273, 11620, 5275, 11618, 5277, 11616, 5279, 11614, 5281, 11612, 5283, 11610, 5285, 11608, 5287, 11606, 5289, 11604, 5291, 11602, 5293, 11600, 5295, 11598, 5297, 11596, 5299, 11594, 5301, 11592, 5303, 11590, 5305, 11588, 5307, 11586, 5309, 11584, 5311, 11582, 5313, 11580, 5315, 11578, 5317, 11576, 5319, 11574, 5321, 11572, 5323, 11570, 5325, 11568, 5327, 11566, 5329, 11564, 5331, 11562, 5333, 11560, 5335, 11558, 5337, 11556, 5339, 11554, 5341, 11552, 5343, 11550, 5345, 11548, 5347, 11546, 5349, 11544, 5351, 11542, 5353, 11540, 5355, 11538, 5357, 11536, 5359, 11534, 5361, 11532, 5363, 11530, 5365, 11528, 5367, 11526, 5369, 11524, 5371, 11522, 5373, 11520, 5375, 11518, 5377, 11516, 5379, 11514, 5381, 11512, 5383, 11510, 5385, 11508, 5387, 11506, 5389, 11504, 5391, 11502, 5393, 11500, 5395, 11498, 5397, 11496, 5399, 11494, 5401, 11492, 5403, 11490, 5405, 11488, 5407, 11486, 5409, 11484, 5411, 11482, 5413, 11480, 5415, 11478, 5417, 11476, 5419, 11474, 5421, 11472, 5423, 11470, 5425, 11468, 5427, 11466, 5429, 11464, 5431, 11462, 5433, 11460, 5435, 11458, 5437, 11456, 5439, 11454, 5441, 11452, 5443, 11450, 5445, 11448, 5447, 11446, 5449, 11444, 5451, 11442, 5453, 11440, 5455, 11438, 5457, 11436, 5459, 11434, 5461, 11432, 5463, 11430, 5465, 11428, 5467, 11426, 5469, 11424, 5471, 11422, 5473, 11420, 5475, 11418, 5477, 11416, 5479, 11414, 5481, 11412, 5483, 11410, 5485, 11408, 5487, 11406, 5489, 11404, 5491, 11402, 5493, 11400, 5495, 11398, 5497, 11396, 5499, 11394, 5501, 11392, 5503, 11390, 5505, 11388, 5507, 11386, 5509, 11384, 5511, 11382, 5513, 11380, 5515, 11378, 5517, 11376, 5519, 11374, 5521, 11372, 5523, 11370, 5525, 11368, 5527, 11366, 5529, 11364, 5531, 11362, 5533, 11360, 5535, 11358, 5537, 11356, 5539, 11354, 5541, 11352, 5543, 11350, 5545, 11348, 5547, 11346, 5549, 11344, 5551, 11342, 5553, 11340, 5555, 11338, 5557, 11336, 5559, 11334, 5561, 11332, 5563, 11330, 5565, 11328, 5567, 11326, 5569, 11324, 5571, 11322, 5573, 11320, 5575, 11318, 5577, 11316, 5579, 11314, 5581, 11312, 5583, 11310, 5585, 11308, 5587, 11306, 5589, 11304, 5591, 11302, 5593, 11300, 5595, 11298, 5597, 11296, 5599, 11294, 5601, 11292, 5603, 11290, 5605, 11288, 5607, 11286, 5609, 11284, 5611, 11282, 5613, 11280, 5615, 11278, 5617, 11276, 5619, 11274, 5621, 11272, 5623, 11270, 5625, 11268, 5627, 11266, 5629, 11264, 5631, 11262, 5633, 11260, 5635, 11258, 5637, 11256, 5639, 11254, 5641, 11252, 5643, 11250, 5645, 11248, 5647, 11246, 5649, 11244, 5651, 11242, 5653, 11240, 5655, 11238, 5657, 11236, 5659, 11234, 5661, 11232, 5663, 11230, 5665, 11228, 5667, 11226, 5669, 11224, 5671, 11222, 5673, 11220, 5675, 11218, 5677, 11216, 5679, 11214, 5681, 11212, 5683, 11210, 5685, 11208, 5687, 11206, 5689, 11204, 5691, 11202, 5693, 11200, 5695, 11198, 5697, 11196, 5699, 11194, 5701, 11192, 5703, 11190, 5705, 11188, 5707, 11186, 5709, 11184, 5711, 11182, 5713, 11180, 5715, 11178, 5717, 11176, 5719, 11174, 5721, 11172, 5723, 11170, 5725, 11168, 5727, 11166, 5729, 11164, 5731, 11162, 5733, 11160, 5735, 11158, 5737, 11156, 5739, 11154, 5741, 11152, 5743, 11150, 5745, 11148, 5747, 11146, 5749, 11144, 5751, 11142, 5753, 11140, 5755, 11138, 5757, 11136, 5759, 11134, 5761, 11132, 5763, 11130, 5765, 11128, 5767, 11126, 5769, 11124, 5771, 11122, 5773, 11120, 5775, 11118, 5777, 11116, 5779, 11114, 5781, 11112, 5783, 11110, 5785, 11108, 5787, 11106, 5789, 11104, 5791, 11102, 5793, 11100, 5795, 11098, 5797, 11096, 5799, 11094, 5801, 11092, 5803, 11090, 5805, 11088, 5807, 11086, 5809, 11084, 5811, 11082, 5813, 11080, 5815, 11078, 5817, 11076, 5819, 11074, 5821, 11072, 5823, 11070, 5825, 11068, 5827, 11066, 5829, 11064, 5831, 11062, 5833, 11060, 5835, 11058, 5837, 11056, 5839, 11054, 5841, 11052, 5843, 11050, 5845, 11048, 5847, 11046, 5849, 11044, 5851, 11042, 5853, 11040, 5855, 11038, 5857, 11036, 5859, 11034, 5861, 11032, 5863, 11030, 5865, 11028, 5867, 11026, 5869, 11024, 5871, 11022, 5873, 11020, 5875, 11018, 5877, 11016, 5879, 11014, 5881, 11012, 5883, 11010, 5885, 11008, 5887, 11006, 5889, 11004, 5891, 11002, 5893, 11000, 5895, 10998, 5897, 10996, 5899, 10994, 5901, 10992, 5903, 10990, 5905, 10988, 5907, 10986, 5909, 10984, 5911, 10982, 5913, 10980, 5915, 10978, 5917, 10976, 5919, 10974, 5921, 10972, 5923, 10970, 5925, 10968, 5927, 10966, 5929, 10964, 5931, 10962, 5933, 10960, 5935, 10958, 5937, 10956, 5939, 10954, 5941, 10952, 5943, 10950, 5945, 10948, 5947, 10946, 5949, 10944, 5951, 10942, 5953, 10940, 5955, 10938, 5957, 10936, 5959, 10934, 5961, 10932, 5963, 10930, 5965, 10928, 5967, 10926, 5969, 10924, 5971, 10922, 5973, 10920, 5975, 10918, 5977, 10916, 5979, 10914, 5981, 10912, 5983, 10910, 5985, 10908, 5987, 10906, 5989, 10904, 5991, 10902, 5993, 10900, 5995, 10898, 5997, 10896, 5999, 10894, 6001, 10892, 6003, 10890, 6005, 10888, 6007, 10886, 6009, 10884, 6011, 10882, 6013, 10880, 6015, 10878, 6017, 10876, 6019, 10874, 6021, 10872, 6023, 10870, 6025, 10868, 6027, 10866, 6029, 10864, 6031, 10862, 6033, 10860, 6035, 10858, 6037, 10856, 6039, 10854, 6041, 10852, 6043, 10850, 6045, 10848, 6047, 10846, 6049, 10844, 6051, 10842, 6053, 10840, 6055, 10838, 6057, 10836, 6059, 10834, 6061, 10832, 6063, 10830, 6065, 10828, 6067, 10826, 6069, 10824, 6071, 10822, 6073, 10820, 6075, 10818, 6077, 10816, 6079, 10814, 6081, 10812, 6083, 10810, 6085, 10808, 6087, 10806, 6089, 10804, 6091, 10802, 6093, 10800, 6095, 10798, 6097, 10796, 6099, 10794, 6101, 10792, 6103, 10790, 6105, 10788, 6107, 10786, 6109, 10784, 6111, 10782, 6113, 10780, 6115, 10778, 6117, 10776, 6119, 10774, 6121, 10772, 6123, 10770, 6125, 10768, 6127, 10766, 6129, 10764, 6131, 10762, 6133, 10760, 6135, 10758, 6137, 10756, 6139, 10754, 6141, 10752, 6143, 10750, 6145, 10748, 6147, 10746, 6149, 10744, 6151, 10742, 6153, 10740, 6155, 10738, 6157, 10736, 6159, 10734, 6161, 10732, 6163, 10730, 6165, 10728, 6167, 10726, 6169, 10724, 6171, 10722, 6173, 10720, 6175, 10718, 6177, 10716, 6179, 10714, 6181, 10712, 6183, 10710, 6185, 10708, 6187, 10706, 6189, 10704, 6191, 10702, 6193, 10700, 6195, 10698, 6197, 10696, 6199, 10694, 6201, 10692, 6203, 10690, 6205, 10688, 6207, 10686, 6209, 10684, 6211, 10682, 6213, 10680, 6215, 10678, 6217, 10676, 6219, 10674, 6221, 10672, 6223, 10670, 6225, 10668, 6227, 10666, 6229, 10664, 6231, 10662, 6233, 10660, 6235, 10658, 6237, 10656, 6239, 10654, 6241, 10652, 6243, 10650, 6245, 10648, 6247, 10646, 6249, 10644, 6251, 10642, 6253, 10640, 6255, 10638, 6257, 10636, 6259, 10634, 6261, 10632, 6263, 10630, 6265, 10628, 6267, 10626, 6269, 10624, 6271, 10622, 6273, 10620, 6275, 10618, 6277, 10616, 6279, 10614, 6281, 10612, 6283, 10610, 6285, 10608, 6287, 10606, 6289, 10604, 6291, 10602, 6293, 10600, 6295, 10598, 6297, 10596, 6299, 10594, 6301, 10592, 6303, 10590, 6305, 10588, 6307, 10586, 6309, 10584, 6311, 10582, 6313, 10580, 6315, 10578, 6317, 10576, 6319, 10574, 6321, 10572, 6323, 10570, 6325, 10568, 6327, 10566, 6329, 10564, 6331, 10562, 6333, 10560, 6335, 10558, 6337, 10556, 6339, 10554, 6341, 10552, 6343, 10550, 6345, 10548, 6347, 10546, 6349, 10544, 6351, 10542, 6353, 10540, 6355, 10538, 6357, 10536, 6359, 10534, 6361, 10532, 6363, 10530, 6365, 10528, 6367, 10526, 6369, 10524, 6371, 10522, 6373, 10520, 6375, 10518, 6377, 10516, 6379, 10514, 6381, 10512, 6383, 10510, 6385, 10508, 6387, 10506, 6389, 10504, 6391, 10502, 6393, 10500, 6395, 10498, 6397, 10496, 6399, 10494, 6401, 10492, 6403, 10490, 6405, 10488, 6407, 10486, 6409, 10484, 6411, 10482, 6413, 10480, 6415, 10478, 6417, 10476, 6419, 10474, 6421, 10472, 6423, 10470, 6425, 10468, 6427, 10466, 6429, 10464, 6431, 10462, 6433, 10460, 6435, 10458, 6437, 10456, 6439, 10454, 6441, 10452, 6443, 10450, 6445, 10448, 6447, 10446, 6449, 10444, 6451, 10442, 6453, 10440, 6455, 10438, 6457, 10436, 6459, 10434, 6461, 10432, 6463, 10430, 6465, 10428, 6467, 10426, 6469, 10424, 6471, 10422, 6473, 10420, 6475, 10418, 6477, 10416, 6479, 10414, 6481, 10412, 6483, 10410, 6485, 10408, 6487, 10406, 6489, 10404, 6491, 10402, 6493, 10400, 6495, 10398, 6497, 10396, 6499, 10394, 6501, 10392, 6503, 10390, 6505, 10388, 6507, 10386, 6509, 10384, 6511, 10382, 6513, 10380, 6515, 10378, 6517, 10376, 6519, 10374, 6521, 10372, 6523, 10370, 6525, 10368, 6527, 10366, 6529, 10364, 6531, 10362, 6533, 10360, 6535, 10358, 6537, 10356, 6539, 10354, 6541, 10352, 6543, 10350, 6545, 10348, 6547, 10346, 6549, 10344, 6551, 10342, 6553, 10340, 6555, 10338, 6557, 10336, 6559, 10334, 6561, 10332, 6563, 10330, 6565, 10328, 6567, 10326, 6569, 10324, 6571, 10322, 6573, 10320, 6575, 10318, 6577, 10316, 6579, 10314, 6581, 10312, 6583, 10310, 6585, 10308, 6587, 10306, 6589, 10304, 6591, 10302, 6593, 10300, 6595, 10298, 6597, 10296, 6599, 10294, 6601, 10292, 6603, 10290, 6605, 10288, 6607, 10286, 6609, 10284, 6611, 10282, 6613, 10280, 6615, 10278, 6617, 10276, 6619, 10274, 6621, 10272, 6623, 10270, 6625, 10268, 6627, 10266, 6629, 10264, 6631, 10262, 6633, 10260, 6635, 10258, 6637, 10256, 6639, 10254, 6641, 10252, 6643, 10250, 6645, 10248, 6647, 10246, 6649, 10244, 6651, 10242, 6653, 10240, 6655, 10238, 6657, 10236, 6659, 10234, 6661, 10232, 6663, 10230, 6665, 10228, 6667, 10226, 6669, 10224, 6671, 10222, 6673, 10220, 6675, 10218, 6677, 10216, 6679, 10214, 6681, 10212, 6683, 10210, 6685, 10208, 6687, 10206, 6689, 10204, 6691, 10202, 6693, 10200, 6695, 10198, 6697, 10196, 6699, 10194, 6701, 10192, 6703, 10190, 6705, 10188, 6707, 10186, 6709, 10184, 6711, 10182, 6713, 10180, 6715, 10178, 6717, 10176, 6719, 10174, 6721, 10172, 6723, 10170, 6725, 10168, 6727, 10166, 6729, 10164, 6731, 10162, 6733, 10160, 6735, 10158, 6737, 10156, 6739, 10154, 6741, 10152, 6743, 10150, 6745, 10148, 6747, 10146, 6749, 10144, 6751, 10142, 6753, 10140, 6755, 10138, 6757, 10136, 6759, 10134, 6761, 10132, 6763, 10130, 6765, 10128, 6767, 10126, 6769, 10124, 6771, 10122, 6773, 10120, 6775, 10118, 6777, 10116, 6779, 10114, 6781, 10112, 6783, 10110, 6785, 10108, 6787, 10106, 6789, 10104, 6791, 10102, 6793, 10100, 6795, 10098, 6797, 10096, 6799, 10094, 6801, 10092, 6803, 10090, 6805, 10088, 6807, 10086, 6809, 10084, 6811, 10082, 6813, 10080, 6815, 10078, 6817, 10076, 6819, 10074, 6821, 10072, 6823, 10070, 6825, 10068, 6827, 10066, 6829, 10064, 6831, 10062, 6833, 10060, 6835, 10058, 6837, 10056, 6839, 10054, 6841, 10052, 6843, 10050, 6845, 10048, 6847, 10046, 6849, 10044, 6851, 10042, 6853, 10040, 6855, 10038, 6857, 10036, 6859, 10034, 6861, 10032, 6863, 10030, 6865, 10028, 6867, 10026, 6869, 10024, 6871, 10022, 6873, 10020, 6875, 10018, 6877, 10016, 6879, 10014, 6881, 10012, 6883, 10010, 6885, 10008, 6887, 10006, 6889, 10004, 6891, 10002, 6893, 10000, 6895, 9998, 6897, 9996, 6899, 9994, 6901, 9992, 6903, 9990, 6905, 9988, 6907, 9986, 6909, 9984, 6911, 9982, 6913, 9980, 6915, 9978, 6917, 9976, 6919, 9974, 6921, 9972, 6923, 9970, 6925, 9968, 6927, 9966, 6929, 9964, 6931, 9962, 6933, 9960, 6935, 9958, 6937, 9956, 6939, 9954, 6941, 9952, 6943, 9950, 6945, 9948, 6947, 9946, 6949, 9944, 6951, 9942, 6953, 9940, 6955, 9938, 6957, 9936, 6959, 9934, 6961, 9932, 6963, 9930, 6965, 9928, 6967, 9926, 6969, 9924, 6971, 9922, 6973, 9920, 6975, 9918, 6977, 9916, 6979, 9914, 6981, 9912, 6983, 9910, 6985, 9908, 6987, 9906, 6989, 9904, 6991, 9902, 6993, 9900, 6995, 9898, 6997, 9896, 6999, 9894, 7001, 9892, 7003, 9890, 7005, 9888, 7007, 9886, 7009, 9884, 7011, 9882, 7013, 9880, 7015, 9878, 7017, 9876, 7019, 9874, 7021, 9872, 7023, 9870, 7025, 9868, 7027, 9866, 7029, 9864, 7031, 9862, 7033, 9860, 7035, 9858, 7037, 9856, 7039, 9854, 7041, 9852, 7043, 9850, 7045, 9848, 7047, 9846, 7049, 9844, 7051, 9842, 7053, 9840, 7055, 9838, 7057, 9836, 7059, 9834, 7061, 9832, 7063, 9830, 7065, 9828, 7067, 9826, 7069, 9824, 7071, 9822, 7073, 9820, 7075, 9818, 7077, 9816, 7079, 9814, 7081, 9812, 7083, 9810, 7085, 9808, 7087, 9806, 7089, 9804, 7091, 9802, 7093, 9800, 7095, 9798, 7097, 9796, 7099, 9794, 7101, 9792, 7103, 9790, 7105, 9788, 7107, 9786, 7109, 9784, 7111, 9782, 7113, 9780, 7115, 9778, 7117, 9776, 7119, 9774, 7121, 9772, 7123, 9770, 7125, 9768, 7127, 9766, 7129, 9764, 7131, 9762, 7133, 9760, 7135, 9758, 7137, 9756, 7139, 9754, 7141, 9752, 7143, 9750, 7145, 9748, 7147, 9746, 7149, 9744, 7151, 9742, 7153, 9740, 7155, 9738, 7157, 9736, 7159, 9734, 7161, 9732, 7163, 9730, 7165, 9728, 7167, 9726, 7169, 9724, 7171, 9722, 7173, 9720, 7175, 9718, 7177, 9716, 7179, 9714, 7181, 9712, 7183, 9710, 7185, 9708, 7187, 9706, 7189, 9704, 7191, 9702, 7193, 9700, 7195, 9698, 7197, 9696, 7199, 9694, 7201, 9692, 7203, 9690, 7205, 9688, 7207, 9686, 7209, 9684, 7211, 9682, 7213, 9680, 7215, 9678, 7217, 9676, 7219, 9674, 7221, 9672, 7223, 9670, 7225, 9668, 7227, 9666, 7229, 9664, 7231, 9662, 7233, 9660, 7235, 9658, 7237, 9656, 7239, 9654, 7241, 9652, 7243, 9650, 7245, 9648, 7247, 9646, 7249, 9644, 7251, 9642, 7253, 9640, 7255, 9638, 7257, 9636, 7259, 9634, 7261, 9632, 7263, 9630, 7265, 9628, 7267, 9626, 7269, 9624, 7271, 9622, 7273, 9620, 7275, 9618, 7277, 9616, 7279, 9614, 7281, 9612, 7283, 9610, 7285, 9608, 7287, 9606, 7289, 9604, 7291, 9602, 7293, 9600, 7295, 9598, 7297, 9596, 7299, 9594, 7301, 9592, 7303, 9590, 7305, 9588, 7307, 9586, 7309, 9584, 7311, 9582, 7313, 9580, 7315, 9578, 7317, 9576, 7319, 9574, 7321, 9572, 7323, 9570, 7325, 9568, 7327, 9566, 7329, 9564, 7331, 9562, 7333, 9560, 7335, 9558, 7337, 9556, 7339, 9554, 7341, 9552, 7343, 9550, 7345, 9548, 7347, 9546, 7349, 9544, 7351, 9542, 7353, 9540, 7355, 9538, 7357, 9536, 7359, 9534, 7361, 9532, 7363, 9530, 7365, 9528, 7367, 9526, 7369, 9524, 7371, 9522, 7373, 9520, 7375, 9518, 7377, 9516, 7379, 9514, 7381, 9512, 7383, 9510, 7385, 9508, 7387, 9506, 7389, 9504, 7391, 9502, 7393, 9500, 7395, 9498, 7397, 9496, 7399, 9494, 7401, 9492, 7403, 9490, 7405, 9488, 7407, 9486, 7409, 9484, 7411, 9482, 7413, 9480, 7415, 9478, 7417, 9476, 7419, 9474, 7421, 9472, 7423, 9470, 7425, 9468, 7427, 9466, 7429, 9464, 7431, 9462, 7433, 9460, 7435, 9458, 7437, 9456, 7439, 9454, 7441, 9452, 7443, 9450, 7445, 9448, 7447, 9446, 7449, 9444, 7451, 9442, 7453, 9440, 7455, 9438, 7457, 9436, 7459, 9434, 7461, 9432, 7463, 9430, 7465, 9428, 7467, 9426, 7469, 9424, 7471, 9422, 7473, 9420, 7475, 9418, 7477, 9416, 7479, 9414, 7481, 9412, 7483, 9410, 7485, 9408, 7487, 9406, 7489, 9404, 7491, 9402, 7493, 9400, 7495, 9398, 7497, 9396, 7499, 9394, 7501, 9392, 7503, 9390, 7505, 9388, 7507, 9386, 7509, 9384, 7511, 9382, 7513, 9380, 7515, 9378, 7517, 9376, 7519, 9374, 7521, 9372, 7523, 9370, 7525, 9368, 7527, 9366, 7529, 9364, 7531, 9362, 7533, 9360, 7535, 9358, 7537, 9356, 7539, 9354, 7541, 9352, 7543, 9350, 7545, 9348, 7547, 9346, 7549, 9344, 7551, 9342, 7553, 9340, 7555, 9338, 7557, 9336, 7559, 9334, 7561, 9332, 7563, 9330, 7565, 9328, 7567, 9326, 7569, 9324, 7571, 9322, 7573, 9320, 7575, 9318, 7577, 9316, 7579, 9314, 7581, 9312, 7583, 9310, 7585, 9308, 7587, 9306, 7589, 9304, 7591, 9302, 7593, 9300, 7595, 9298, 7597, 9296, 7599, 9294, 7601, 9292, 7603, 9290, 7605, 9288, 7607, 9286, 7609, 9284, 7611, 9282, 7613, 9280, 7615, 9278, 7617, 9276, 7619, 9274, 7621, 9272, 7623, 9270, 7625, 9268, 7627, 9266, 7629, 9264, 7631, 9262, 7633, 9260, 7635, 9258, 7637, 9256, 7639, 9254, 7641, 9252, 7643, 9250, 7645, 9248, 7647, 9246, 7649, 9244, 7651, 9242, 7653, 9240, 7655, 9238, 7657, 9236, 7659, 9234, 7661, 9232, 7663, 9230, 7665, 9228, 7667, 9226, 7669, 9224, 7671, 9222, 7673, 9220, 7675, 9218, 7677, 9216, 7679, 9214, 7681, 9212, 7683, 9210, 7685, 9208, 7687, 9206, 7689, 9204, 7691, 9202, 7693, 9200, 7695, 9198, 7697, 9196, 7699, 9194, 7701, 9192, 7703, 9190, 7705, 9188, 7707, 9186, 7709, 9184, 7711, 9182, 7713, 9180, 7715, 9178, 7717, 9176, 7719, 9174, 7721, 9172, 7723, 9170, 7725, 9168, 7727, 9166, 7729, 9164, 7731, 9162, 7733, 9160, 7735, 9158, 7737, 9156, 7739, 9154, 7741, 9152, 7743, 9150, 7745, 9148, 7747, 9146, 7749, 9144, 7751, 9142, 7753, 9140, 7755, 9138, 7757, 9136, 7759, 9134, 7761, 9132, 7763, 9130, 7765, 9128, 7767, 9126, 7769, 9124, 7771, 9122, 7773, 9120, 7775, 9118, 7777, 9116, 7779, 9114, 7781, 9112, 7783, 9110, 7785, 9108, 7787, 9106, 7789, 9104, 7791, 9102, 7793, 9100, 7795, 9098, 7797, 9096, 7799, 9094, 7801, 9092, 7803, 9090, 7805, 9088, 7807, 9086, 7809, 9084, 7811, 9082, 7813, 9080, 7815, 9078, 7817, 9076, 7819, 9074, 7821, 9072, 7823, 9070, 7825, 9068, 7827, 9066, 7829, 9064, 7831, 9062, 7833, 9060, 7835, 9058, 7837, 9056, 7839, 9054, 7841, 9052, 7843, 9050, 7845, 9048, 7847, 9046, 7849, 9044, 7851, 9042, 7853, 9040, 7855, 9038, 7857, 9036, 7859, 9034, 7861, 9032, 7863, 9030, 7865, 9028, 7867, 9026, 7869, 9024, 7871, 9022, 7873, 9020, 7875, 9018, 7877, 9016, 7879, 9014, 7881, 9012, 7883, 9010, 7885, 9008, 7887, 9006, 7889, 9004, 7891, 9002, 7893, 9000, 7895, 8998, 7897, 8996, 7899, 8994, 7901, 8992, 7903, 8990, 7905, 8988, 7907, 8986, 7909, 8984, 7911, 8982, 7913, 8980, 7915, 8978, 7917, 8976, 7919, 8974, 7921, 8972, 7923, 8970, 7925, 8968, 7927, 8966, 7929, 8964, 7931, 8962, 7933, 8960, 7935, 8958, 7937, 8956, 7939, 8954, 7941, 8952, 7943, 8950, 7945, 8948, 7947, 8946, 7949, 8944, 7951, 8942, 7953, 8940, 7955, 8938, 7957, 8936, 7959, 8934, 7961, 8932, 7963, 8930, 7965, 8928, 7967, 8926, 7969, 8924, 7971, 8922, 7973, 8920, 7975, 8918, 7977, 8916, 7979, 8914, 7981, 8912, 7983, 8910, 7985, 8908, 7987, 8906, 7989, 8904, 7991, 8902, 7993, 8900, 7995, 8898, 7997, 8896, 7999, 8894, 8001, 8892, 8003, 8890, 8005, 8888, 8007, 8886, 8009, 8884, 8011, 8882, 8013, 8880, 8015, 8878, 8017, 8876, 8019, 8874, 8021, 8872, 8023, 8870, 8025, 8868, 8027, 8866, 8029, 8864, 8031, 8862, 8033, 8860, 8035, 8858, 8037, 8856, 8039, 8854, 8041, 8852, 8043, 8850, 8045, 8848, 8047, 8846, 8049, 8844, 8051, 8842, 8053, 8840, 8055, 8838, 8057, 8836, 8059, 8834, 8061, 8832, 8063, 8830, 8065, 8828, 8067, 8826, 8069, 8824, 8071, 8822, 8073, 8820, 8075, 8818, 8077, 8816, 8079, 8814, 8081, 8812, 8083, 8810, 8085, 8808, 8087, 8806, 8089, 8804, 8091, 8802, 8093, 8800, 8095, 8798, 8097, 8796, 8099, 8794, 8101, 8792, 8103, 8790, 8105, 8788, 8107, 8786, 8109, 8784, 8111, 8782, 8113, 8780, 8115, 8778, 8117, 8776, 8119, 8774, 8121, 8772, 8123, 8770, 8125, 8768, 8127, 8766, 8129, 8764, 8131, 8762, 8133, 8760, 8135, 8758, 8137, 8756, 8139, 8754, 8141, 8752, 8143, 8750, 8145, 8748, 8147, 8746, 8149, 8744, 8151, 8742, 8153, 8740, 8155, 8738, 8157, 8736, 8159, 8734, 8161, 8732, 8163, 8730, 8165, 8728, 8167, 8726, 8169, 8724, 8171, 8722, 8173, 8720, 8175, 8718, 8177, 8716, 8179, 8714, 8181, 8712, 8183, 8710, 8185, 8708, 8187, 8706, 8189, 8704, 8191, 8702, 8193, 8700, 8195, 8698, 8197, 8696, 8199, 8694, 8201, 8692, 8203, 8690, 8205, 8688, 8207, 8686, 8209, 8684, 8211, 8682, 8213, 8680, 8215, 8678, 8217, 8676, 8219, 8674, 8221, 8672, 8223, 8670, 8225, 8668, 8227, 8666, 8229, 8664, 8231, 8662, 8233, 8660, 8235, 8658, 8237, 8656, 8239, 8654, 8241, 8652, 8243, 8650, 8245, 8648, 8247, 8646, 8249, 8644, 8251, 8642, 8253, 8640, 8255, 8638, 8257, 8636, 8259, 8634, 8261, 8632, 8263, 8630, 8265, 8628, 8267, 8626, 8269, 8624, 8271, 8622, 8273, 8620, 8275, 8618, 8277, 8616, 8279, 8614, 8281, 8612, 8283, 8610, 8285, 8608, 8287, 8606, 8289, 8604, 8291, 8602, 8293, 8600, 8295, 8598, 8297, 8596, 8299, 8594, 8301, 8592, 8303, 8590, 8305, 8588, 8307, 8586, 8309, 8584, 8311, 8582, 8313, 8580, 8315, 8578, 8317, 8576, 8319, 8574, 8321, 8572, 8323, 8570, 8325, 8568, 8327, 8566, 8329, 8564, 8331, 8562, 8333, 8560, 8335, 8558, 8337, 8556, 8339, 8554, 8341, 8552, 8343, 8550, 8345, 8548, 8347, 8546, 8349, 8544, 8351, 8542, 8353, 8540, 8355, 8538, 8357, 8536, 8359, 8534, 8361, 8532, 8363, 8530, 8365, 8528, 8367, 8526, 8369, 8524, 8371, 8522, 8373, 8520, 8375, 8518, 8377, 8516, 8379, 8514, 8381, 8512, 8383, 8510, 8385, 8508, 8387, 8506, 8389, 8504, 8391, 8502, 8393, 8500, 8395, 8498, 8397, 8496, 8399, 8494, 8401, 8492, 8403, 8490, 8405, 8488, 8407, 8486, 8409, 8484, 8411, 8482, 8413, 8480, 8415, 8478, 8417, 8476, 8419, 8474, 8421, 8472, 8423, 8470, 8425, 8468, 8427, 8466, 8429, 8464, 8431, 8462, 8433, 8460, 8435, 8458, 8437, 8456, 8439, 8454, 8441, 8452, 8443, 8450, 8445, 8448, 8447, 8446, 8449, 8444, 8451, 8442, 8453, 8440, 8455, 8438, 8457, 8436, 8459, 8434, 8461, 8432, 8463, 8430, 8465, 8428, 8467, 8426, 8469, 8424, 8471, 8422, 8473, 8420, 8475, 8418, 8477, 8416, 8479, 8414, 8481, 8412, 8483, 8410, 8485, 8408, 8487, 8406, 8489, 8404, 8491, 8402, 8493, 8400, 8495, 8398, 8497, 8396, 8499, 8394, 8501, 8392, 8503, 8390, 8505, 8388, 8507, 8386, 8509, 8384, 8511, 8382, 8513, 8380, 8515, 8378, 8517, 8376, 8519, 8374, 8521, 8372, 8523, 8370, 8525, 8368, 8527, 8366, 8529, 8364, 8531, 8362, 8533, 8360, 8535, 8358, 8537, 8356, 8539, 8354, 8541, 8352, 8543, 8350, 8545, 8348, 8547, 8346, 8549, 8344, 8551, 8342, 8553, 8340, 8555, 8338, 8557, 8336, 8559, 8334, 8561, 8332, 8563, 8330, 8565, 8328, 8567, 8326, 8569, 8324, 8571, 8322, 8573, 8320, 8575, 8318, 8577, 8316, 8579, 8314, 8581, 8312, 8583, 8310, 8585, 8308, 8587, 8306, 8589, 8304, 8591, 8302, 8593, 8300, 8595, 8298, 8597, 8296, 8599, 8294, 8601, 8292, 8603, 8290, 8605, 8288, 8607, 8286, 8609, 8284, 8611, 8282, 8613, 8280, 8615, 8278, 8617, 8276, 8619, 8274, 8621, 8272, 8623, 8270, 8625, 8268, 8627, 8266, 8629, 8264, 8631, 8262, 8633, 8260, 8635, 8258, 8637, 8256, 8639, 8254, 8641, 8252, 8643, 8250, 8645, 8248, 8647, 8246, 8649, 8244, 8651, 8242, 8653, 8240, 8655, 8238, 8657, 8236, 8659, 8234, 8661, 8232, 8663, 8230, 8665, 8228, 8667, 8226, 8669, 8224, 8671, 8222, 8673, 8220, 8675, 8218, 8677, 8216, 8679, 8214, 8681, 8212, 8683, 8210, 8685, 8208, 8687, 8206, 8689, 8204, 8691, 8202, 8693, 8200, 8695, 8198, 8697, 8196, 8699, 8194, 8701, 8192, 8703, 8190, 8705, 8188, 8707, 8186, 8709, 8184, 8711, 8182, 8713, 8180, 8715, 8178, 8717, 8176, 8719, 8174, 8721, 8172, 8723, 8170, 8725, 8168, 8727, 8166, 8729, 8164, 8731, 8162, 8733, 8160, 8735, 8158, 8737, 8156, 8739, 8154, 8741, 8152, 8743, 8150, 8745, 8148, 8747, 8146, 8749, 8144, 8751, 8142, 8753, 8140, 8755, 8138, 8757, 8136, 8759, 8134, 8761, 8132, 8763, 8130, 8765, 8128, 8767, 8126, 8769, 8124, 8771, 8122, 8773, 8120, 8775, 8118, 8777, 8116, 8779, 8114, 8781, 8112, 8783, 8110, 8785, 8108, 8787, 8106, 8789, 8104, 8791, 8102, 8793, 8100, 8795, 8098, 8797, 8096, 8799, 8094, 8801, 8092, 8803, 8090, 8805, 8088, 8807, 8086, 8809, 8084, 8811, 8082, 8813, 8080, 8815, 8078, 8817, 8076, 8819, 8074, 8821, 8072, 8823, 8070, 8825, 8068, 8827, 8066, 8829, 8064, 8831, 8062, 8833, 8060, 8835, 8058, 8837, 8056, 8839, 8054, 8841, 8052, 8843, 8050, 8845, 8048, 8847, 8046, 8849, 8044, 8851, 8042, 8853, 8040, 8855, 8038, 8857, 8036, 8859, 8034, 8861, 8032, 8863, 8030, 8865, 8028, 8867, 8026, 8869, 8024, 8871, 8022, 8873, 8020, 8875, 8018, 8877, 8016, 8879, 8014, 8881, 8012, 8883, 8010, 8885, 8008, 8887, 8006, 8889, 8004, 8891, 8002, 8893, 8000, 8895, 7998, 8897, 7996, 8899, 7994, 8901, 7992, 8903, 7990, 8905, 7988, 8907, 7986, 8909, 7984, 8911, 7982, 8913, 7980, 8915, 7978, 8917, 7976, 8919, 7974, 8921, 7972, 8923, 7970, 8925, 7968, 8927, 7966, 8929, 7964, 8931, 7962, 8933, 7960, 8935, 7958, 8937, 7956, 8939, 7954, 8941, 7952, 8943, 7950, 8945, 7948, 8947, 7946, 8949, 7944, 8951, 7942, 8953, 7940, 8955, 7938, 8957, 7936, 8959, 7934, 8961, 7932, 8963, 7930, 8965, 7928, 8967, 7926, 8969, 7924, 8971, 7922, 8973, 7920, 8975, 7918, 8977, 7916, 8979, 7914, 8981, 7912, 8983, 7910, 8985, 7908, 8987, 7906, 8989, 7904, 8991, 7902, 8993, 7900, 8995, 7898, 8997, 7896, 8999, 7894, 9001, 7892, 9003, 7890, 9005, 7888, 9007, 7886, 9009, 7884, 9011, 7882, 9013, 7880, 9015, 7878, 9017, 7876, 9019, 7874, 9021, 7872, 9023, 7870, 9025, 7868, 9027, 7866, 9029, 7864, 9031, 7862, 9033, 7860, 9035, 7858, 9037, 7856, 9039, 7854, 9041, 7852, 9043, 7850, 9045, 7848, 9047, 7846, 9049, 7844, 9051, 7842, 9053, 7840, 9055, 7838, 9057, 7836, 9059, 7834, 9061, 7832, 9063, 7830, 9065, 7828, 9067, 7826, 9069, 7824, 9071, 7822, 9073, 7820, 9075, 7818, 9077, 7816, 9079, 7814, 9081, 7812, 9083, 7810, 9085, 7808, 9087, 7806, 9089, 7804, 9091, 7802, 9093, 7800, 9095, 7798, 9097, 7796, 9099, 7794, 9101, 7792, 9103, 7790, 9105, 7788, 9107, 7786, 9109, 7784, 9111, 7782, 9113, 7780, 9115, 7778, 9117, 7776, 9119, 7774, 9121, 7772, 9123, 7770, 9125, 7768, 9127, 7766, 9129, 7764, 9131, 7762, 9133, 7760, 9135, 7758, 9137, 7756, 9139, 7754, 9141, 7752, 9143, 7750, 9145, 7748, 9147, 7746, 9149, 7744, 9151, 7742, 9153, 7740, 9155, 7738, 9157, 7736, 9159, 7734, 9161, 7732, 9163, 7730, 9165, 7728, 9167, 7726, 9169, 7724, 9171, 7722, 9173, 7720, 9175, 7718, 9177, 7716, 9179, 7714, 9181, 7712, 9183, 7710, 9185, 7708, 9187, 7706, 9189, 7704, 9191, 7702, 9193, 7700, 9195, 7698, 9197, 7696, 9199, 7694, 9201, 7692, 9203, 7690, 9205, 7688, 9207, 7686, 9209, 7684, 9211, 7682, 9213, 7680, 9215, 7678, 9217, 7676, 9219, 7674, 9221, 7672, 9223, 7670, 9225, 7668, 9227, 7666, 9229, 7664, 9231, 7662, 9233, 7660, 9235, 7658, 9237, 7656, 9239, 7654, 9241, 7652, 9243, 7650, 9245, 7648, 9247, 7646, 9249, 7644, 9251, 7642, 9253, 7640, 9255, 7638, 9257, 7636, 9259, 7634, 9261, 7632, 9263, 7630, 9265, 7628, 9267, 7626, 9269, 7624, 9271, 7622, 9273, 7620, 9275, 7618, 9277, 7616, 9279, 7614, 9281, 7612, 9283, 7610, 9285, 7608, 9287, 7606, 9289, 7604, 9291, 7602, 9293, 7600, 9295, 7598, 9297, 7596, 9299, 7594, 9301, 7592, 9303, 7590, 9305, 7588, 9307, 7586, 9309, 7584, 9311, 7582, 9313, 7580, 9315, 7578, 9317, 7576, 9319, 7574, 9321, 7572, 9323, 7570, 9325, 7568, 9327, 7566, 9329, 7564, 9331, 7562, 9333, 7560, 9335, 7558, 9337, 7556, 9339, 7554, 9341, 7552, 9343, 7550, 9345, 7548, 9347, 7546, 9349, 7544, 9351, 7542, 9353, 7540, 9355, 7538, 9357, 7536, 9359, 7534, 9361, 7532, 9363, 7530, 9365, 7528, 9367, 7526, 9369, 7524, 9371, 7522, 9373, 7520, 9375, 7518, 9377, 7516, 9379, 7514, 9381, 7512, 9383, 7510, 9385, 7508, 9387, 7506, 9389, 7504, 9391, 7502, 9393, 7500, 9395, 7498, 9397, 7496, 9399, 7494, 9401, 7492, 9403, 7490, 9405, 7488, 9407, 7486, 9409, 7484, 9411, 7482, 9413, 7480, 9415, 7478, 9417, 7476, 9419, 7474, 9421, 7472, 9423, 7470, 9425, 7468, 9427, 7466, 9429, 7464, 9431, 7462, 9433, 7460, 9435, 7458, 9437, 7456, 9439, 7454, 9441, 7452, 9443, 7450, 9445, 7448, 9447, 7446, 9449, 7444, 9451, 7442, 9453, 7440, 9455, 7438, 9457, 7436, 9459, 7434, 9461, 7432, 9463, 7430, 9465, 7428, 9467, 7426, 9469, 7424, 9471, 7422, 9473, 7420, 9475, 7418, 9477, 7416, 9479, 7414, 9481, 7412, 9483, 7410, 9485, 7408, 9487, 7406, 9489, 7404, 9491, 7402, 9493, 7400, 9495, 7398, 9497, 7396, 9499, 7394, 9501, 7392, 9503, 7390, 9505, 7388, 9507, 7386, 9509, 7384, 9511, 7382, 9513, 7380, 9515, 7378, 9517, 7376, 9519, 7374, 9521, 7372, 9523, 7370, 9525, 7368, 9527, 7366, 9529, 7364, 9531, 7362, 9533, 7360, 9535, 7358, 9537, 7356, 9539, 7354, 9541, 7352, 9543, 7350, 9545, 7348, 9547, 7346, 9549, 7344, 9551, 7342, 9553, 7340, 9555, 7338, 9557, 7336, 9559, 7334, 9561, 7332, 9563, 7330, 9565, 7328, 9567, 7326, 9569, 7324, 9571, 7322, 9573, 7320, 9575, 7318, 9577, 7316, 9579, 7314, 9581, 7312, 9583, 7310, 9585, 7308, 9587, 7306, 9589, 7304, 9591, 7302, 9593, 7300, 9595, 7298, 9597, 7296, 9599, 7294, 9601, 7292, 9603, 7290, 9605, 7288, 9607, 7286, 9609, 7284, 9611, 7282, 9613, 7280, 9615, 7278, 9617, 7276, 9619, 7274, 9621, 7272, 9623, 7270, 9625, 7268, 9627, 7266, 9629, 7264, 9631, 7262, 9633, 7260, 9635, 7258, 9637, 7256, 9639, 7254, 9641, 7252, 9643, 7250, 9645, 7248, 9647, 7246, 9649, 7244, 9651, 7242, 9653, 7240, 9655, 7238, 9657, 7236, 9659, 7234, 9661, 7232, 9663, 7230, 9665, 7228, 9667, 7226, 9669, 7224, 9671, 7222, 9673, 7220, 9675, 7218, 9677, 7216, 9679, 7214, 9681, 7212, 9683, 7210, 9685, 7208, 9687, 7206, 9689, 7204, 9691, 7202, 9693, 7200, 9695, 7198, 9697, 7196, 9699, 7194, 9701, 7192, 9703, 7190, 9705, 7188, 9707, 7186, 9709, 7184, 9711, 7182, 9713, 7180, 9715, 7178, 9717, 7176, 9719, 7174, 9721, 7172, 9723, 7170, 9725, 7168, 9727, 7166, 9729, 7164, 9731, 7162, 9733, 7160, 9735, 7158, 9737, 7156, 9739, 7154, 9741, 7152, 9743, 7150, 9745, 7148, 9747, 7146, 9749, 7144, 9751, 7142, 9753, 7140, 9755, 7138, 9757, 7136, 9759, 7134, 9761, 7132, 9763, 7130, 9765, 7128, 9767, 7126, 9769, 7124, 9771, 7122, 9773, 7120, 9775, 7118, 9777, 7116, 9779, 7114, 9781, 7112, 9783, 7110, 9785, 7108, 9787, 7106, 9789, 7104, 9791, 7102, 9793, 7100, 9795, 7098, 9797, 7096, 9799, 7094, 9801, 7092, 9803, 7090, 9805, 7088, 9807, 7086, 9809, 7084, 9811, 7082, 9813, 7080, 9815, 7078, 9817, 7076, 9819, 7074, 9821, 7072, 9823, 7070, 9825, 7068, 9827, 7066, 9829, 7064, 9831, 7062, 9833, 7060, 9835, 7058, 9837, 7056, 9839, 7054, 9841, 7052, 9843, 7050, 9845, 7048, 9847, 7046, 9849, 7044, 9851, 7042, 9853, 7040, 9855, 7038, 9857, 7036, 9859, 7034, 9861, 7032, 9863, 7030, 9865, 7028, 9867, 7026, 9869, 7024, 9871, 7022, 9873, 7020, 9875, 7018, 9877, 7016, 9879, 7014, 9881, 7012, 9883, 7010, 9885, 7008, 9887, 7006, 9889, 7004, 9891, 7002, 9893, 7000, 9895, 6998, 9897, 6996, 9899, 6994, 9901, 6992, 9903, 6990, 9905, 6988, 9907, 6986, 9909, 6984, 9911, 6982, 9913, 6980, 9915, 6978, 9917, 6976, 9919, 6974, 9921, 6972, 9923, 6970, 9925, 6968, 9927, 6966, 9929, 6964, 9931, 6962, 9933, 6960, 9935, 6958, 9937, 6956, 9939, 6954, 9941, 6952, 9943, 6950, 9945, 6948, 9947, 6946, 9949, 6944, 9951, 6942, 9953, 6940, 9955, 6938, 9957, 6936, 9959, 6934, 9961, 6932, 9963, 6930, 9965, 6928, 9967, 6926, 9969, 6924, 9971, 6922, 9973, 6920, 9975, 6918, 9977, 6916, 9979, 6914, 9981, 6912, 9983, 6910, 9985, 6908, 9987, 6906, 9989, 6904, 9991, 6902, 9993, 6900, 9995, 6898, 9997, 6896, 9999, 6894, 10001, 6892, 10003, 6890, 10005, 6888, 10007, 6886, 10009, 6884, 10011, 6882, 10013, 6880, 10015, 6878, 10017, 6876, 10019, 6874, 10021, 6872, 10023, 6870, 10025, 6868, 10027, 6866, 10029, 6864, 10031, 6862, 10033, 6860, 10035, 6858, 10037, 6856, 10039, 6854, 10041, 6852, 10043, 6850, 10045, 6848, 10047, 6846, 10049, 6844, 10051, 6842, 10053, 6840, 10055, 6838, 10057, 6836, 10059, 6834, 10061, 6832, 10063, 6830, 10065, 6828, 10067, 6826, 10069, 6824, 10071, 6822, 10073, 6820, 10075, 6818, 10077, 6816, 10079, 6814, 10081, 6812, 10083, 6810, 10085, 6808, 10087, 6806, 10089, 6804, 10091, 6802, 10093, 6800, 10095, 6798, 10097, 6796, 10099, 6794, 10101, 6792, 10103, 6790, 10105, 6788, 10107, 6786, 10109, 6784, 10111, 6782, 10113, 6780, 10115, 6778, 10117, 6776, 10119, 6774, 10121, 6772, 10123, 6770, 10125, 6768, 10127, 6766, 10129, 6764, 10131, 6762, 10133, 6760, 10135, 6758, 10137, 6756, 10139, 6754, 10141, 6752, 10143, 6750, 10145, 6748, 10147, 6746, 10149, 6744, 10151, 6742, 10153, 6740, 10155, 6738, 10157, 6736, 10159, 6734, 10161, 6732, 10163, 6730, 10165, 6728, 10167, 6726, 10169, 6724, 10171, 6722, 10173, 6720, 10175, 6718, 10177, 6716, 10179, 6714, 10181, 6712, 10183, 6710, 10185, 6708, 10187, 6706, 10189, 6704, 10191, 6702, 10193, 6700, 10195, 6698, 10197, 6696, 10199, 6694, 10201, 6692, 10203, 6690, 10205, 6688, 10207, 6686, 10209, 6684, 10211, 6682, 10213, 6680, 10215, 6678, 10217, 6676, 10219, 6674, 10221, 6672, 10223, 6670, 10225, 6668, 10227, 6666, 10229, 6664, 10231, 6662, 10233, 6660, 10235, 6658, 10237, 6656, 10239, 6654, 10241, 6652, 10243, 6650, 10245, 6648, 10247, 6646, 10249, 6644, 10251, 6642, 10253, 6640, 10255, 6638, 10257, 6636, 10259, 6634, 10261, 6632, 10263, 6630, 10265, 6628, 10267, 6626, 10269, 6624, 10271, 6622, 10273, 6620, 10275, 6618, 10277, 6616, 10279, 6614, 10281, 6612, 10283, 6610, 10285, 6608, 10287, 6606, 10289, 6604, 10291, 6602, 10293, 6600, 10295, 6598, 10297, 6596, 10299, 6594, 10301, 6592, 10303, 6590, 10305, 6588, 10307, 6586, 10309, 6584, 10311, 6582, 10313, 6580, 10315, 6578, 10317, 6576, 10319, 6574, 10321, 6572, 10323, 6570, 10325, 6568, 10327, 6566, 10329, 6564, 10331, 6562, 10333, 6560, 10335, 6558, 10337, 6556, 10339, 6554, 10341, 6552, 10343, 6550, 10345, 6548, 10347, 6546, 10349, 6544, 10351, 6542, 10353, 6540, 10355, 6538, 10357, 6536, 10359, 6534, 10361, 6532, 10363, 6530, 10365, 6528, 10367, 6526, 10369, 6524, 10371, 6522, 10373, 6520, 10375, 6518, 10377, 6516, 10379, 6514, 10381, 6512, 10383, 6510, 10385, 6508, 10387, 6506, 10389, 6504, 10391, 6502, 10393, 6500, 10395, 6498, 10397, 6496, 10399, 6494, 10401, 6492, 10403, 6490, 10405, 6488, 10407, 6486, 10409, 6484, 10411, 6482, 10413, 6480, 10415, 6478, 10417, 6476, 10419, 6474, 10421, 6472, 10423, 6470, 10425, 6468, 10427, 6466, 10429, 6464, 10431, 6462, 10433, 6460, 10435, 6458, 10437, 6456, 10439, 6454, 10441, 6452, 10443, 6450, 10445, 6448, 10447, 6446, 10449, 6444, 10451, 6442, 10453, 6440, 10455, 6438, 10457, 6436, 10459, 6434, 10461, 6432, 10463, 6430, 10465, 6428, 10467, 6426, 10469, 6424, 10471, 6422, 10473, 6420, 10475, 6418, 10477, 6416, 10479, 6414, 10481, 6412, 10483, 6410, 10485, 6408, 10487, 6406, 10489, 6404, 10491, 6402, 10493, 6400, 10495, 6398, 10497, 6396, 10499, 6394, 10501, 6392, 10503, 6390, 10505, 6388, 10507, 6386, 10509, 6384, 10511, 6382, 10513, 6380, 10515, 6378, 10517, 6376, 10519, 6374, 10521, 6372, 10523, 6370, 10525, 6368, 10527, 6366, 10529, 6364, 10531, 6362, 10533, 6360, 10535, 6358, 10537, 6356, 10539, 6354, 10541, 6352, 10543, 6350, 10545, 6348, 10547, 6346, 10549, 6344, 10551, 6342, 10553, 6340, 10555, 6338, 10557, 6336, 10559, 6334, 10561, 6332, 10563, 6330, 10565, 6328, 10567, 6326, 10569, 6324, 10571, 6322, 10573, 6320, 10575, 6318, 10577, 6316, 10579, 6314, 10581, 6312, 10583, 6310, 10585, 6308, 10587, 6306, 10589, 6304, 10591, 6302, 10593, 6300, 10595, 6298, 10597, 6296, 10599, 6294, 10601, 6292, 10603, 6290, 10605, 6288, 10607, 6286, 10609, 6284, 10611, 6282, 10613, 6280, 10615, 6278, 10617, 6276, 10619, 6274, 10621, 6272, 10623, 6270, 10625, 6268, 10627, 6266, 10629, 6264, 10631, 6262, 10633, 6260, 10635, 6258, 10637, 6256, 10639, 6254, 10641, 6252, 10643, 6250, 10645, 6248, 10647, 6246, 10649, 6244, 10651, 6242, 10653, 6240, 10655, 6238, 10657, 6236, 10659, 6234, 10661, 6232, 10663, 6230, 10665, 6228, 10667, 6226, 10669, 6224, 10671, 6222, 10673, 6220, 10675, 6218, 10677, 6216, 10679, 6214, 10681, 6212, 10683, 6210, 10685, 6208, 10687, 6206, 10689, 6204, 10691, 6202, 10693, 6200, 10695, 6198, 10697, 6196, 10699, 6194, 10701, 6192, 10703, 6190, 10705, 6188, 10707, 6186, 10709, 6184, 10711, 6182, 10713, 6180, 10715, 6178, 10717, 6176, 10719, 6174, 10721, 6172, 10723, 6170, 10725, 6168, 10727, 6166, 10729, 6164, 10731, 6162, 10733, 6160, 10735, 6158, 10737, 6156, 10739, 6154, 10741, 6152, 10743, 6150, 10745, 6148, 10747, 6146, 10749, 6144, 10751, 6142, 10753, 6140, 10755, 6138, 10757, 6136, 10759, 6134, 10761, 6132, 10763, 6130, 10765, 6128, 10767, 6126, 10769, 6124, 10771, 6122, 10773, 6120, 10775, 6118, 10777, 6116, 10779, 6114, 10781, 6112, 10783, 6110, 10785, 6108, 10787, 6106, 10789, 6104, 10791, 6102, 10793, 6100, 10795, 6098, 10797, 6096, 10799, 6094, 10801, 6092, 10803, 6090, 10805, 6088, 10807, 6086, 10809, 6084, 10811, 6082, 10813, 6080, 10815, 6078, 10817, 6076, 10819, 6074, 10821, 6072, 10823, 6070, 10825, 6068, 10827, 6066, 10829, 6064, 10831, 6062, 10833, 6060, 10835, 6058, 10837, 6056, 10839, 6054, 10841, 6052, 10843, 6050, 10845, 6048, 10847, 6046, 10849, 6044, 10851, 6042, 10853, 6040, 10855, 6038, 10857, 6036, 10859, 6034, 10861, 6032, 10863, 6030, 10865, 6028, 10867, 6026, 10869, 6024, 10871, 6022, 10873, 6020, 10875, 6018, 10877, 6016, 10879, 6014, 10881, 6012, 10883, 6010, 10885, 6008, 10887, 6006, 10889, 6004, 10891, 6002, 10893, 6000, 10895, 5998, 10897, 5996, 10899, 5994, 10901, 5992, 10903, 5990, 10905, 5988, 10907, 5986, 10909, 5984, 10911, 5982, 10913, 5980, 10915, 5978, 10917, 5976, 10919, 5974, 10921, 5972, 10923, 5970, 10925, 5968, 10927, 5966, 10929, 5964, 10931, 5962, 10933, 5960, 10935, 5958, 10937, 5956, 10939, 5954, 10941, 5952, 10943, 5950, 10945, 5948, 10947, 5946, 10949, 5944, 10951, 5942, 10953, 5940, 10955, 5938, 10957, 5936, 10959, 5934, 10961, 5932, 10963, 5930, 10965, 5928, 10967, 5926, 10969, 5924, 10971, 5922, 10973, 5920, 10975, 5918, 10977, 5916, 10979, 5914, 10981, 5912, 10983, 5910, 10985, 5908, 10987, 5906, 10989, 5904, 10991, 5902, 10993, 5900, 10995, 5898, 10997, 5896, 10999, 5894, 11001, 5892, 11003, 5890, 11005, 5888, 11007, 5886, 11009, 5884, 11011, 5882, 11013, 5880, 11015, 5878, 11017, 5876, 11019, 5874, 11021, 5872, 11023, 5870, 11025, 5868, 11027, 5866, 11029, 5864, 11031, 5862, 11033, 5860, 11035, 5858, 11037, 5856, 11039, 5854, 11041, 5852, 11043, 5850, 11045, 5848, 11047, 5846, 11049, 5844, 11051, 5842, 11053, 5840, 11055, 5838, 11057, 5836, 11059, 5834, 11061, 5832, 11063, 5830, 11065, 5828, 11067, 5826, 11069, 5824, 11071, 5822, 11073, 5820, 11075, 5818, 11077, 5816, 11079, 5814, 11081, 5812, 11083, 5810, 11085, 5808, 11087, 5806, 11089, 5804, 11091, 5802, 11093, 5800, 11095, 5798, 11097, 5796, 11099, 5794, 11101, 5792, 11103, 5790, 11105, 5788, 11107, 5786, 11109, 5784, 11111, 5782, 11113, 5780, 11115, 5778, 11117, 5776, 11119, 5774, 11121, 5772, 11123, 5770, 11125, 5768, 11127, 5766, 11129, 5764, 11131, 5762, 11133, 5760, 11135, 5758, 11137, 5756, 11139, 5754, 11141, 5752, 11143, 5750, 11145, 5748, 11147, 5746, 11149, 5744, 11151, 5742, 11153, 5740, 11155, 5738, 11157, 5736, 11159, 5734, 11161, 5732, 11163, 5730, 11165, 5728, 11167, 5726, 11169, 5724, 11171, 5722, 11173, 5720, 11175, 5718, 11177, 5716, 11179, 5714, 11181, 5712, 11183, 5710, 11185, 5708, 11187, 5706, 11189, 5704, 11191, 5702, 11193, 5700, 11195, 5698, 11197, 5696, 11199, 5694, 11201, 5692, 11203, 5690, 11205, 5688, 11207, 5686, 11209, 5684, 11211, 5682, 11213, 5680, 11215, 5678, 11217, 5676, 11219, 5674, 11221, 5672, 11223, 5670, 11225, 5668, 11227, 5666, 11229, 5664, 11231, 5662, 11233, 5660, 11235, 5658, 11237, 5656, 11239, 5654, 11241, 5652, 11243, 5650, 11245, 5648, 11247, 5646, 11249, 5644, 11251, 5642, 11253, 5640, 11255, 5638, 11257, 5636, 11259, 5634, 11261, 5632, 11263, 5630, 11265, 5628, 11267, 5626, 11269, 5624, 11271, 5622, 11273, 5620, 11275, 5618, 11277, 5616, 11279, 5614, 11281, 5612, 11283, 5610, 11285, 5608, 11287, 5606, 11289, 5604, 11291, 5602, 11293, 5600, 11295, 5598, 11297, 5596, 11299, 5594, 11301, 5592, 11303, 5590, 11305, 5588, 11307, 5586, 11309, 5584, 11311, 5582, 11313, 5580, 11315, 5578, 11317, 5576, 11319, 5574, 11321, 5572, 11323, 5570, 11325, 5568, 11327, 5566, 11329, 5564, 11331, 5562, 11333, 5560, 11335, 5558, 11337, 5556, 11339, 5554, 11341, 5552, 11343, 5550, 11345, 5548, 11347, 5546, 11349, 5544, 11351, 5542, 11353, 5540, 11355, 5538, 11357, 5536, 11359, 5534, 11361, 5532, 11363, 5530, 11365, 5528, 11367, 5526, 11369, 5524, 11371, 5522, 11373, 5520, 11375, 5518, 11377, 5516, 11379, 5514, 11381, 5512, 11383, 5510, 11385, 5508, 11387, 5506, 11389, 5504, 11391, 5502, 11393, 5500, 11395, 5498, 11397, 5496, 11399, 5494, 11401, 5492, 11403, 5490, 11405, 5488, 11407, 5486, 11409, 5484, 11411, 5482, 11413, 5480, 11415, 5478, 11417, 5476, 11419, 5474, 11421, 5472, 11423, 5470, 11425, 5468, 11427, 5466, 11429, 5464, 11431, 5462, 11433, 5460, 11435, 5458, 11437, 5456, 11439, 5454, 11441, 5452, 11443, 5450, 11445, 5448, 11447, 5446, 11449, 5444, 11451, 5442, 11453, 5440, 11455, 5438, 11457, 5436, 11459, 5434, 11461, 5432, 11463, 5430, 11465, 5428, 11467, 5426, 11469, 5424, 11471, 5422, 11473, 5420, 11475, 5418, 11477, 5416, 11479, 5414, 11481, 5412, 11483, 5410, 11485, 5408, 11487, 5406, 11489, 5404, 11491, 5402, 11493, 5400, 11495, 5398, 11497, 5396, 11499, 5394, 11501, 5392, 11503, 5390, 11505, 5388, 11507, 5386, 11509, 5384, 11511, 5382, 11513, 5380, 11515, 5378, 11517, 5376, 11519, 5374, 11521, 5372, 11523, 5370, 11525, 5368, 11527, 5366, 11529, 5364, 11531, 5362, 11533, 5360, 11535, 5358, 11537, 5356, 11539, 5354, 11541, 5352, 11543, 5350, 11545, 5348, 11547, 5346, 11549, 5344, 11551, 5342, 11553, 5340, 11555, 5338, 11557, 5336, 11559, 5334, 11561, 5332, 11563, 5330, 11565, 5328, 11567, 5326, 11569, 5324, 11571, 5322, 11573, 5320, 11575, 5318, 11577, 5316, 11579, 5314, 11581, 5312, 11583, 5310, 11585, 5308, 11587, 5306, 11589, 5304, 11591, 5302, 11593, 5300, 11595, 5298, 11597, 5296, 11599, 5294, 11601, 5292, 11603, 5290, 11605, 5288, 11607, 5286, 11609, 5284, 11611, 5282, 11613, 5280, 11615, 5278, 11617, 5276, 11619, 5274, 11621, 5272, 11623, 5270, 11625, 5268, 11627, 5266, 11629, 5264, 11631, 5262, 11633, 5260, 11635, 5258, 11637, 5256, 11639, 5254, 11641, 5252, 11643, 5250, 11645, 5248, 11647, 5246, 11649, 5244, 11651, 5242, 11653, 5240, 11655, 5238, 11657, 5236, 11659, 5234, 11661, 5232, 11663, 5230, 11665, 5228, 11667, 5226, 11669, 5224, 11671, 5222, 11673, 5220, 11675, 5218, 11677, 5216, 11679, 5214, 11681, 5212, 11683, 5210, 11685, 5208, 11687, 5206, 11689, 5204, 11691, 5202, 11693, 5200, 11695, 5198, 11697, 5196, 11699, 5194, 11701, 5192, 11703, 5190, 11705, 5188, 11707, 5186, 11709, 5184, 11711, 5182, 11713, 5180, 11715, 5178, 11717, 5176, 11719, 5174, 11721, 5172, 11723, 5170, 11725, 5168, 11727, 5166, 11729, 5164, 11731, 5162, 11733, 5160, 11735, 5158, 11737, 5156, 11739, 5154, 11741, 5152, 11743, 5150, 11745, 5148, 11747, 5146, 11749, 5144, 11751, 5142, 11753, 5140, 11755, 5138, 11757, 5136, 11759, 5134, 11761, 5132, 11763, 5130, 11765, 5128, 11767, 5126, 11769, 5124, 11771, 5122, 11773, 5120, 11775, 5118, 11777, 5116, 11779, 5114, 11781, 5112, 11783, 5110, 11785, 5108, 11787, 5106, 11789, 5104, 11791, 5102, 11793, 5100, 11795, 5098, 11797, 5096, 11799, 5094, 11801, 5092, 11803, 5090, 11805, 5088, 11807, 5086, 11809, 5084, 11811, 5082, 11813, 5080, 11815, 5078, 11817, 5076, 11819, 5074, 11821, 5072, 11823, 5070, 11825, 5068, 11827, 5066, 11829, 5064, 11831, 5062, 11833, 5060, 11835, 5058, 11837, 5056, 11839, 5054, 11841, 5052, 11843, 5050, 11845, 5048, 11847, 5046, 11849, 5044, 11851, 5042, 11853, 5040, 11855, 5038, 11857, 5036, 11859, 5034, 11861, 5032, 11863, 5030, 11865, 5028, 11867, 5026, 11869, 5024, 11871, 5022, 11873, 5020, 11875, 5018, 11877, 5016, 11879, 5014, 11881, 5012, 11883, 5010, 11885, 5008, 11887, 5006, 11889, 5004, 11891, 5002, 11893, 5000, 11895, 4998, 11897, 4996, 11899, 4994, 11901, 4992, 11903, 4990, 11905, 4988, 11907, 4986, 11909, 4984, 11911, 4982, 11913, 4980, 11915, 4978, 11917, 4976, 11919, 4974, 11921, 4972, 11923, 4970, 11925, 4968, 11927, 4966, 11929, 4964, 11931, 4962, 11933, 4960, 11935, 4958, 11937, 4956, 11939, 4954, 11941, 4952, 11943, 4950, 11945, 4948, 11947, 4946, 11949, 4944, 11951, 4942, 11953, 4940, 11955, 4938, 11957, 4936, 11959, 4934, 11961, 4932, 11963, 4930, 11965, 4928, 11967, 4926, 11969, 4924, 11971, 4922, 11973, 4920, 11975, 4918, 11977, 4916, 11979, 4914, 11981, 4912, 11983, 4910, 11985, 4908, 11987, 4906, 11989, 4904, 11991, 4902, 11993, 4900, 11995, 4898, 11997, 4896, 11999, 4894, 12001, 4892, 12003, 4890, 12005, 4888, 12007, 4886, 12009, 4884, 12011, 4882, 12013, 4880, 12015, 4878, 12017, 4876, 12019, 4874, 12021, 4872, 12023, 4870, 12025, 4868, 12027, 4866, 12029, 4864, 12031, 4862, 12033, 4860, 12035, 4858, 12037, 4856, 12039, 4854, 12041, 4852, 12043, 4850, 12045, 4848, 12047, 4846, 12049, 4844, 12051, 4842, 12053, 4840, 12055, 4838, 12057, 4836, 12059, 4834, 12061, 4832, 12063, 4830, 12065, 4828, 12067, 4826, 12069, 4824, 12071, 4822, 12073, 4820, 12075, 4818, 12077, 4816, 12079, 4814, 12081, 4812, 12083, 4810, 12085, 4808, 12087, 4806, 12089, 4804, 12091, 4802, 12093, 4800, 12095, 4798, 12097, 4796, 12099, 4794, 12101, 4792, 12103, 4790, 12105, 4788, 12107, 4786, 12109, 4784, 12111, 4782, 12113, 4780, 12115, 4778, 12117, 4776, 12119, 4774, 12121, 4772, 12123, 4770, 12125, 4768, 12127, 4766, 12129, 4764, 12131, 4762, 12133, 4760, 12135, 4758, 12137, 4756, 12139, 4754, 12141, 4752, 12143, 4750, 12145, 4748, 12147, 4746, 12149, 4744, 12151, 4742, 12153, 4740, 12155, 4738, 12157, 4736, 12159, 4734, 12161, 4732, 12163, 4730, 12165, 4728, 12167, 4726, 12169, 4724, 12171, 4722, 12173, 4720, 12175, 4718, 12177, 4716, 12179, 4714, 12181, 4712, 12183, 4710, 12185, 4708, 12187, 4706, 12189, 4704, 12191, 4702, 12193, 4700, 12195, 4698, 12197, 4696, 12199, 4694, 12201, 4692, 12203, 4690, 12205, 4688, 12207, 4686, 12209, 4684, 12211, 4682, 12213, 4680, 12215, 4678, 12217, 4676, 12219, 4674, 12221, 4672, 12223, 4670, 12225, 4668, 12227, 4666, 12229, 4664, 12231, 4662, 12233, 4660, 12235, 4658, 12237, 4656, 12239, 4654, 12241, 4652, 12243, 4650, 12245, 4648, 12247, 4646, 12249, 4644, 12251, 4642, 12253, 4640, 12255, 4638, 12257, 4636, 12259, 4634, 12261, 4632, 12263, 4630, 12265, 4628, 12267, 4626, 12269, 4624, 12271, 4622, 12273, 4620, 12275, 4618, 12277, 4616, 12279, 4614, 12281, 4612, 12283, 4610, 12285, 4608, 12287, 4606, 12289, 4604, 12291, 4602, 12293, 4600, 12295, 4598, 12297, 4596, 12299, 4594, 12301, 4592, 12303, 4590, 12305, 4588, 12307, 4586, 12309, 4584, 12311, 4582, 12313, 4580, 12315, 4578, 12317, 4576, 12319, 4574, 12321, 4572, 12323, 4570, 12325, 4568, 12327, 4566, 12329, 4564, 12331, 4562, 12333, 4560, 12335, 4558, 12337, 4556, 12339, 4554, 12341, 4552, 12343, 4550, 12345, 4548, 12347, 4546, 12349, 4544, 12351, 4542, 12353, 4540, 12355, 4538, 12357, 4536, 12359, 4534, 12361, 4532, 12363, 4530, 12365, 4528, 12367, 4526, 12369, 4524, 12371, 4522, 12373, 4520, 12375, 4518, 12377, 4516, 12379, 4514, 12381, 4512, 12383, 4510, 12385, 4508, 12387, 4506, 12389, 4504, 12391, 4502, 12393, 4500, 12395, 4498, 12397, 4496, 12399, 4494, 12401, 4492, 12403, 4490, 12405, 4488, 12407, 4486, 12409, 4484, 12411, 4482, 12413, 4480, 12415, 4478, 12417, 4476, 12419, 4474, 12421, 4472, 12423, 4470, 12425, 4468, 12427, 4466, 12429, 4464, 12431, 4462, 12433, 4460, 12435, 4458, 12437, 4456, 12439, 4454, 12441, 4452, 12443, 4450, 12445, 4448, 12447, 4446, 12449, 4444, 12451, 4442, 12453, 4440, 12455, 4438, 12457, 4436, 12459, 4434, 12461, 4432, 12463, 4430, 12465, 4428, 12467, 4426, 12469, 4424, 12471, 4422, 12473, 4420, 12475, 4418, 12477, 4416, 12479, 4414, 12481, 4412, 12483, 4410, 12485, 4408, 12487, 4406, 12489, 4404, 12491, 4402, 12493, 4400, 12495, 4398, 12497, 4396, 12499, 4394, 12501, 4392, 12503, 4390, 12505, 4388, 12507, 4386, 12509, 4384, 12511, 4382, 12513, 4380, 12515, 4378, 12517, 4376, 12519, 4374, 12521, 4372, 12523, 4370, 12525, 4368, 12527, 4366, 12529, 4364, 12531, 4362, 12533, 4360, 12535, 4358, 12537, 4356, 12539, 4354, 12541, 4352, 12543, 4350, 12545, 4348, 12547, 4346, 12549, 4344, 12551, 4342, 12553, 4340, 12555, 4338, 12557, 4336, 12559, 4334, 12561, 4332, 12563, 4330, 12565, 4328, 12567, 4326, 12569, 4324, 12571, 4322, 12573, 4320, 12575, 4318, 12577, 4316, 12579, 4314, 12581, 4312, 12583, 4310, 12585, 4308, 12587, 4306, 12589, 4304, 12591, 4302, 12593, 4300, 12595, 4298, 12597, 4296, 12599, 4294, 12601, 4292, 12603, 4290, 12605, 4288, 12607, 4286, 12609, 4284, 12611, 4282, 12613, 4280, 12615, 4278, 12617, 4276, 12619, 4274, 12621, 4272, 12623, 4270, 12625, 4268, 12627, 4266, 12629, 4264, 12631, 4262, 12633, 4260, 12635, 4258, 12637, 4256, 12639, 4254, 12641, 4252, 12643, 4250, 12645, 4248, 12647, 4246, 12649, 4244, 12651, 4242, 12653, 4240, 12655, 4238, 12657, 4236, 12659, 4234, 12661, 4232, 12663, 4230, 12665, 4228, 12667, 4226, 12669, 4224, 12671, 4222, 12673, 4220, 12675, 4218, 12677, 4216, 12679, 4214, 12681, 4212, 12683, 4210, 12685, 4208, 12687, 4206, 12689, 4204, 12691, 4202, 12693, 4200, 12695, 4198, 12697, 4196, 12699, 4194, 12701, 4192, 12703, 4190, 12705, 4188, 12707, 4186, 12709, 4184, 12711, 4182, 12713, 4180, 12715, 4178, 12717, 4176, 12719, 4174, 12721, 4172, 12723, 4170, 12725, 4168, 12727, 4166, 12729, 4164, 12731, 4162, 12733, 4160, 12735, 4158, 12737, 4156, 12739, 4154, 12741, 4152, 12743, 4150, 12745, 4148, 12747, 4146, 12749, 4144, 12751, 4142, 12753, 4140, 12755, 4138, 12757, 4136, 12759, 4134, 12761, 4132, 12763, 4130, 12765, 4128, 12767, 4126, 12769, 4124, 12771, 4122, 12773, 4120, 12775, 4118, 12777, 4116, 12779, 4114, 12781, 4112, 12783, 4110, 12785, 4108, 12787, 4106, 12789, 4104, 12791, 4102, 12793, 4100, 12795, 4098, 12797, 4096, 12799, 4094, 12801, 4092, 12803, 4090, 12805, 4088, 12807, 4086, 12809, 4084, 12811, 4082, 12813, 4080, 12815, 4078, 12817, 4076, 12819, 4074, 12821, 4072, 12823, 4070, 12825, 4068, 12827, 4066, 12829, 4064, 12831, 4062, 12833, 4060, 12835, 4058, 12837, 4056, 12839, 4054, 12841, 4052, 12843, 4050, 12845, 4048, 12847, 4046, 12849, 4044, 12851, 4042, 12853, 4040, 12855, 4038, 12857, 4036, 12859, 4034, 12861, 4032, 12863, 4030, 12865, 4028, 12867, 4026, 12869, 4024, 12871, 4022, 12873, 4020, 12875, 4018, 12877, 4016, 12879, 4014, 12881, 4012, 12883, 4010, 12885, 4008, 12887, 4006, 12889, 4004, 12891, 4002, 12893, 4000, 12895, 3998, 12897, 3996, 12899, 3994, 12901, 3992, 12903, 3990, 12905, 3988, 12907, 3986, 12909, 3984, 12911, 3982, 12913, 3980, 12915, 3978, 12917, 3976, 12919, 3974, 12921, 3972, 12923, 3970, 12925, 3968, 12927, 3966, 12929, 3964, 12931, 3962, 12933, 3960, 12935, 3958, 12937, 3956, 12939, 3954, 12941, 3952, 12943, 3950, 12945, 3948, 12947, 3946, 12949, 3944, 12951, 3942, 12953, 3940, 12955, 3938, 12957, 3936, 12959, 3934, 12961, 3932, 12963, 3930, 12965, 3928, 12967, 3926, 12969, 3924, 12971, 3922, 12973, 3920, 12975, 3918, 12977, 3916, 12979, 3914, 12981, 3912, 12983, 3910, 12985, 3908, 12987, 3906, 12989, 3904, 12991, 3902, 12993, 3900, 12995, 3898, 12997, 3896, 12999, 3894, 13001, 3892, 13003, 3890, 13005, 3888, 13007, 3886, 13009, 3884, 13011, 3882, 13013, 3880, 13015, 3878, 13017, 3876, 13019, 3874, 13021, 3872, 13023, 3870, 13025, 3868, 13027, 3866, 13029, 3864, 13031, 3862, 13033, 3860, 13035, 3858, 13037, 3856, 13039, 3854, 13041, 3852, 13043, 3850, 13045, 3848, 13047, 3846, 13049, 3844, 13051, 3842, 13053, 3840, 13055, 3838, 13057, 3836, 13059, 3834, 13061, 3832, 13063, 3830, 13065, 3828, 13067, 3826, 13069, 3824, 13071, 3822, 13073, 3820, 13075, 3818, 13077, 3816, 13079, 3814, 13081, 3812, 13083, 3810, 13085, 3808, 13087, 3806, 13089, 3804, 13091, 3802, 13093, 3800, 13095, 3798, 13097, 3796, 13099, 3794, 13101, 3792, 13103, 3790, 13105, 3788, 13107, 3786, 13109, 3784, 13111, 3782, 13113, 3780, 13115, 3778, 13117, 3776, 13119, 3774, 13121, 3772, 13123, 3770, 13125, 3768, 13127, 3766, 13129, 3764, 13131, 3762, 13133, 3760, 13135, 3758, 13137, 3756, 13139, 3754, 13141, 3752, 13143, 3750, 13145, 3748, 13147, 3746, 13149, 3744, 13151, 3742, 13153, 3740, 13155, 3738, 13157, 3736, 13159, 3734, 13161, 3732, 13163, 3730, 13165, 3728, 13167, 3726, 13169, 3724, 13171, 3722, 13173, 3720, 13175, 3718, 13177, 3716, 13179, 3714, 13181, 3712, 13183, 3710, 13185, 3708, 13187, 3706, 13189, 3704, 13191, 3702, 13193, 3700, 13195, 3698, 13197, 3696, 13199, 3694, 13201, 3692, 13203, 3690, 13205, 3688, 13207, 3686, 13209, 3684, 13211, 3682, 13213, 3680, 13215, 3678, 13217, 3676, 13219, 3674, 13221, 3672, 13223, 3670, 13225, 3668, 13227, 3666, 13229, 3664, 13231, 3662, 13233, 3660, 13235, 3658, 13237, 3656, 13239, 3654, 13241, 3652, 13243, 3650, 13245, 3648, 13247, 3646, 13249, 3644, 13251, 3642, 13253, 3640, 13255, 3638, 13257, 3636, 13259, 3634, 13261, 3632, 13263, 3630, 13265, 3628, 13267, 3626, 13269, 3624, 13271, 3622, 13273, 3620, 13275, 3618, 13277, 3616, 13279, 3614, 13281, 3612, 13283, 3610, 13285, 3608, 13287, 3606, 13289, 3604, 13291, 3602, 13293, 3600, 13295, 3598, 13297, 3596, 13299, 3594, 13301, 3592, 13303, 3590, 13305, 3588, 13307, 3586, 13309, 3584, 13311, 3582, 13313, 3580, 13315, 3578, 13317, 3576, 13319, 3574, 13321, 3572, 13323, 3570, 13325, 3568, 13327, 3566, 13329, 3564, 13331, 3562, 13333, 3560, 13335, 3558, 13337, 3556, 13339, 3554, 13341, 3552, 13343, 3550, 13345, 3548, 13347, 3546, 13349, 3544, 13351, 3542, 13353, 3540, 13355, 3538, 13357, 3536, 13359, 3534, 13361, 3532, 13363, 3530, 13365, 3528, 13367, 3526, 13369, 3524, 13371, 3522, 13373, 3520, 13375, 3518, 13377, 3516, 13379, 3514, 13381, 3512, 13383, 3510, 13385, 3508, 13387, 3506, 13389, 3504, 13391, 3502, 13393, 3500, 13395, 3498, 13397, 3496, 13399, 3494, 13401, 3492, 13403, 3490, 13405, 3488, 13407, 3486, 13409, 3484, 13411, 3482, 13413, 3480, 13415, 3478, 13417, 3476, 13419, 3474, 13421, 3472, 13423, 3470, 13425, 3468, 13427, 3466, 13429, 3464, 13431, 3462, 13433, 3460, 13435, 3458, 13437, 3456, 13439, 3454, 13441, 3452, 13443, 3450, 13445, 3448, 13447, 3446, 13449, 3444, 13451, 3442, 13453, 3440, 13455, 3438, 13457, 3436, 13459, 3434, 13461, 3432, 13463, 3430, 13465, 3428, 13467, 3426, 13469, 3424, 13471, 3422, 13473, 3420, 13475, 3418, 13477, 3416, 13479, 3414, 13481, 3412, 13483, 3410, 13485, 3408, 13487, 3406, 13489, 3404, 13491, 3402, 13493, 3400, 13495, 3398, 13497, 3396, 13499, 3394, 13501, 3392, 13503, 3390, 13505, 3388, 13507, 3386, 13509, 3384, 13511, 3382, 13513, 3380, 13515, 3378, 13517, 3376, 13519, 3374, 13521, 3372, 13523, 3370, 13525, 3368, 13527, 3366, 13529, 3364, 13531, 3362, 13533, 3360, 13535, 3358, 13537, 3356, 13539, 3354, 13541, 3352, 13543, 3350, 13545, 3348, 13547, 3346, 13549, 3344, 13551, 3342, 13553, 3340, 13555, 3338, 13557, 3336, 13559, 3334, 13561, 3332, 13563, 3330, 13565, 3328, 13567, 3326, 13569, 3324, 13571, 3322, 13573, 3320, 13575, 3318, 13577, 3316, 13579, 3314, 13581, 3312, 13583, 3310, 13585, 3308, 13587, 3306, 13589, 3304, 13591, 3302, 13593, 3300, 13595, 3298, 13597, 3296, 13599, 3294, 13601, 3292, 13603, 3290, 13605, 3288, 13607, 3286, 13609, 3284, 13611, 3282, 13613, 3280, 13615, 3278, 13617, 3276, 13619, 3274, 13621, 3272, 13623, 3270, 13625, 3268, 13627, 3266, 13629, 3264, 13631, 3262, 13633, 3260, 13635, 3258, 13637, 3256, 13639, 3254, 13641, 3252, 13643, 3250, 13645, 3248, 13647, 3246, 13649, 3244, 13651, 3242, 13653, 3240, 13655, 3238, 13657, 3236, 13659, 3234, 13661, 3232, 13663, 3230, 13665, 3228, 13667, 3226, 13669, 3224, 13671, 3222, 13673, 3220, 13675, 3218, 13677, 3216, 13679, 3214, 13681, 3212, 13683, 3210, 13685, 3208, 13687, 3206, 13689, 3204, 13691, 3202, 13693, 3200, 13695, 3198, 13697, 3196, 13699, 3194, 13701, 3192, 13703, 3190, 13705, 3188, 13707, 3186, 13709, 3184, 13711, 3182, 13713, 3180, 13715, 3178, 13717, 3176, 13719, 3174, 13721, 3172, 13723, 3170, 13725, 3168, 13727, 3166, 13729, 3164, 13731, 3162, 13733, 3160, 13735, 3158, 13737, 3156, 13739, 3154, 13741, 3152, 13743, 3150, 13745, 3148, 13747, 3146, 13749, 3144, 13751, 3142, 13753, 3140, 13755, 3138, 13757, 3136, 13759, 3134, 13761, 3132, 13763, 3130, 13765, 3128, 13767, 3126, 13769, 3124, 13771, 3122, 13773, 3120, 13775, 3118, 13777, 3116, 13779, 3114, 13781, 3112, 13783, 3110, 13785, 3108, 13787, 3106, 13789, 3104, 13791, 3102, 13793, 3100, 13795, 3098, 13797, 3096, 13799, 3094, 13801, 3092, 13803, 3090, 13805, 3088, 13807, 3086, 13809, 3084, 13811, 3082, 13813, 3080, 13815, 3078, 13817, 3076, 13819, 3074, 13821, 3072, 13823, 3070, 13825, 3068, 13827, 3066, 13829, 3064, 13831, 3062, 13833, 3060, 13835, 3058, 13837, 3056, 13839, 3054, 13841, 3052, 13843, 3050, 13845, 3048, 13847, 3046, 13849, 3044, 13851, 3042, 13853, 3040, 13855, 3038, 13857, 3036, 13859, 3034, 13861, 3032, 13863, 3030, 13865, 3028, 13867, 3026, 13869, 3024, 13871, 3022, 13873, 3020, 13875, 3018, 13877, 3016, 13879, 3014, 13881, 3012, 13883, 3010, 13885, 3008, 13887, 3006, 13889, 3004, 13891, 3002, 13893, 3000, 13895, 2998, 13897, 2996, 13899, 2994, 13901, 2992, 13903, 2990, 13905, 2988, 13907, 2986, 13909, 2984, 13911, 2982, 13913, 2980, 13915, 2978, 13917, 2976, 13919, 2974, 13921, 2972, 13923, 2970, 13925, 2968, 13927, 2966, 13929, 2964, 13931, 2962, 13933, 2960, 13935, 2958, 13937, 2956, 13939, 2954, 13941, 2952, 13943, 2950, 13945, 2948, 13947, 2946, 13949, 2944, 13951, 2942, 13953, 2940, 13955, 2938, 13957, 2936, 13959, 2934, 13961, 2932, 13963, 2930, 13965, 2928, 13967, 2926, 13969, 2924, 13971, 2922, 13973, 2920, 13975, 2918, 13977, 2916, 13979, 2914, 13981, 2912, 13983, 2910, 13985, 2908, 13987, 2906, 13989, 2904, 13991, 2902, 13993, 2900, 13995, 2898, 13997, 2896, 13999, 2894, 14001, 2892, 14003, 2890, 14005, 2888, 14007, 2886, 14009, 2884, 14011, 2882, 14013, 2880, 14015, 2878, 14017, 2876, 14019, 2874, 14021, 2872, 14023, 2870, 14025, 2868, 14027, 2866, 14029, 2864, 14031, 2862, 14033, 2860, 14035, 2858, 14037, 2856, 14039, 2854, 14041, 2852, 14043, 2850, 14045, 2848, 14047, 2846, 14049, 2844, 14051, 2842, 14053, 2840, 14055, 2838, 14057, 2836, 14059, 2834, 14061, 2832, 14063, 2830, 14065, 2828, 14067, 2826, 14069, 2824, 14071, 2822, 14073, 2820, 14075, 2818, 14077, 2816, 14079, 2814, 14081, 2812, 14083, 2810, 14085, 2808, 14087, 2806, 14089, 2804, 14091, 2802, 14093, 2800, 14095, 2798, 14097, 2796, 14099, 2794, 14101, 2792, 14103, 2790, 14105, 2788, 14107, 2786, 14109, 2784, 14111, 2782, 14113, 2780, 14115, 2778, 14117, 2776, 14119, 2774, 14121, 2772, 14123, 2770, 14125, 2768, 14127, 2766, 14129, 2764, 14131, 2762, 14133, 2760, 14135, 2758, 14137, 2756, 14139, 2754, 14141, 2752, 14143, 2750, 14145, 2748, 14147, 2746, 14149, 2744, 14151, 2742, 14153, 2740, 14155, 2738, 14157, 2736, 14159, 2734, 14161, 2732, 14163, 2730, 14165, 2728, 14167, 2726, 14169, 2724, 14171, 2722, 14173, 2720, 14175, 2718, 14177, 2716, 14179, 2714, 14181, 2712, 14183, 2710, 14185, 2708, 14187, 2706, 14189, 2704, 14191, 2702, 14193, 2700, 14195, 2698, 14197, 2696, 14199, 2694, 14201, 2692, 14203, 2690, 14205, 2688, 14207, 2686, 14209, 2684, 14211, 2682, 14213, 2680, 14215, 2678, 14217, 2676, 14219, 2674, 14221, 2672, 14223, 2670, 14225, 2668, 14227, 2666, 14229, 2664, 14231, 2662, 14233, 2660, 14235, 2658, 14237, 2656, 14239, 2654, 14241, 2652, 14243, 2650, 14245, 2648, 14247, 2646, 14249, 2644, 14251, 2642, 14253, 2640, 14255, 2638, 14257, 2636, 14259, 2634, 14261, 2632, 14263, 2630, 14265, 2628, 14267, 2626, 14269, 2624, 14271, 2622, 14273, 2620, 14275, 2618, 14277, 2616, 14279, 2614, 14281, 2612, 14283, 2610, 14285, 2608, 14287, 2606, 14289, 2604, 14291, 2602, 14293, 2600, 14295, 2598, 14297, 2596, 14299, 2594, 14301, 2592, 14303, 2590, 14305, 2588, 14307, 2586, 14309, 2584, 14311, 2582, 14313, 2580, 14315, 2578, 14317, 2576, 14319, 2574, 14321, 2572, 14323, 2570, 14325, 2568, 14327, 2566, 14329, 2564, 14331, 2562, 14333, 2560, 14335, 2558, 14337, 2556, 14339, 2554, 14341, 2552, 14343, 2550, 14345, 2548, 14347, 2546, 14349, 2544, 14351, 2542, 14353, 2540, 14355, 2538, 14357, 2536, 14359, 2534, 14361, 2532, 14363, 2530, 14365, 2528, 14367, 2526, 14369, 2524, 14371, 2522, 14373, 2520, 14375, 2518, 14377, 2516, 14379, 2514, 14381, 2512, 14383, 2510, 14385, 2508, 14387, 2506, 14389, 2504, 14391, 2502, 14393, 2500, 14395, 2498, 14397, 2496, 14399, 2494, 14401, 2492, 14403, 2490, 14405, 2488, 14407, 2486, 14409, 2484, 14411, 2482, 14413, 2480, 14415, 2478, 14417, 2476, 14419, 2474, 14421, 2472, 14423, 2470, 14425, 2468, 14427, 2466, 14429, 2464, 14431, 2462, 14433, 2460, 14435, 2458, 14437, 2456, 14439, 2454, 14441, 2452, 14443, 2450, 14445, 2448, 14447, 2446, 14449, 2444, 14451, 2442, 14453, 2440, 14455, 2438, 14457, 2436, 14459, 2434, 14461, 2432, 14463, 2430, 14465, 2428, 14467, 2426, 14469, 2424, 14471, 2422, 14473, 2420, 14475, 2418, 14477, 2416, 14479, 2414, 14481, 2412, 14483, 2410, 14485, 2408, 14487, 2406, 14489, 2404, 14491, 2402, 14493, 2400, 14495, 2398, 14497, 2396, 14499, 2394, 14501, 2392, 14503, 2390, 14505, 2388, 14507, 2386, 14509, 2384, 14511, 2382, 14513, 2380, 14515, 2378, 14517, 2376, 14519, 2374, 14521, 2372, 14523, 2370, 14525, 2368, 14527, 2366, 14529, 2364, 14531, 2362, 14533, 2360, 14535, 2358, 14537, 2356, 14539, 2354, 14541, 2352, 14543, 2350, 14545, 2348, 14547, 2346, 14549, 2344, 14551, 2342, 14553, 2340, 14555, 2338, 14557, 2336, 14559, 2334, 14561, 2332, 14563, 2330, 14565, 2328, 14567, 2326, 14569, 2324, 14571, 2322, 14573, 2320, 14575, 2318, 14577, 2316, 14579, 2314, 14581, 2312, 14583, 2310, 14585, 2308, 14587, 2306, 14589, 2304, 14591, 2302, 14593, 2300, 14595, 2298, 14597, 2296, 14599, 2294, 14601, 2292, 14603, 2290, 14605, 2288, 14607, 2286, 14609, 2284, 14611, 2282, 14613, 2280, 14615, 2278, 14617, 2276, 14619, 2274, 14621, 2272, 14623, 2270, 14625, 2268, 14627, 2266, 14629, 2264, 14631, 2262, 14633, 2260, 14635, 2258, 14637, 2256, 14639, 2254, 14641, 2252, 14643, 2250, 14645, 2248, 14647, 2246, 14649, 2244, 14651, 2242, 14653, 2240, 14655, 2238, 14657, 2236, 14659, 2234, 14661, 2232, 14663, 2230, 14665, 2228, 14667, 2226, 14669, 2224, 14671, 2222, 14673, 2220, 14675, 2218, 14677, 2216, 14679, 2214, 14681, 2212, 14683, 2210, 14685, 2208, 14687, 2206, 14689, 2204, 14691, 2202, 14693, 2200, 14695, 2198, 14697, 2196, 14699, 2194, 14701, 2192, 14703, 2190, 14705, 2188, 14707, 2186, 14709, 2184, 14711, 2182, 14713, 2180, 14715, 2178, 14717, 2176, 14719, 2174, 14721, 2172, 14723, 2170, 14725, 2168, 14727, 2166, 14729, 2164, 14731, 2162, 14733, 2160, 14735, 2158, 14737, 2156, 14739, 2154, 14741, 2152, 14743, 2150, 14745, 2148, 14747, 2146, 14749, 2144, 14751, 2142, 14753, 2140, 14755, 2138, 14757, 2136, 14759, 2134, 14761, 2132, 14763, 2130, 14765, 2128, 14767, 2126, 14769, 2124, 14771, 2122, 14773, 2120, 14775, 2118, 14777, 2116, 14779, 2114, 14781, 2112, 14783, 2110, 14785, 2108, 14787, 2106, 14789, 2104, 14791, 2102, 14793, 2100, 14795, 2098, 14797, 2096, 14799, 2094, 14801, 2092, 14803, 2090, 14805, 2088, 14807, 2086, 14809, 2084, 14811, 2082, 14813, 2080, 14815, 2078, 14817, 2076, 14819, 2074, 14821, 2072, 14823, 2070, 14825, 2068, 14827, 2066, 14829, 2064, 14831, 2062, 14833, 2060, 14835, 2058, 14837, 2056, 14839, 2054, 14841, 2052, 14843, 2050, 14845, 2048, 14847, 2046, 14849, 2044, 14851, 2042, 14853, 2040, 14855, 2038, 14857, 2036, 14859, 2034, 14861, 2032, 14863, 2030, 14865, 2028, 14867, 2026, 14869, 2024, 14871, 2022, 14873, 2020, 14875, 2018, 14877, 2016, 14879, 2014, 14881, 2012, 14883, 2010, 14885, 2008, 14887, 2006, 14889, 2004, 14891, 2002, 14893, 2000, 14895, 1998, 14897, 1996, 14899, 1994, 14901, 1992, 14903, 1990, 14905, 1988, 14907, 1986, 14909, 1984, 14911, 1982, 14913, 1980, 14915, 1978, 14917, 1976, 14919, 1974, 14921, 1972, 14923, 1970, 14925, 1968, 14927, 1966, 14929, 1964, 14931, 1962, 14933, 1960, 14935, 1958, 14937, 1956, 14939, 1954, 14941, 1952, 14943, 1950, 14945, 1948, 14947, 1946, 14949, 1944, 14951, 1942, 14953, 1940, 14955, 1938, 14957, 1936, 14959, 1934, 14961, 1932, 14963, 1930, 14965, 1928, 14967, 1926, 14969, 1924, 14971, 1922, 14973, 1920, 14975, 1918, 14977, 1916, 14979, 1914, 14981, 1912, 14983, 1910, 14985, 1908, 14987, 1906, 14989, 1904, 14991, 1902, 14993, 1900, 14995, 1898, 14997, 1896, 14999, 1894, 15001, 1892, 15003, 1890, 15005, 1888, 15007, 1886, 15009, 1884, 15011, 1882, 15013, 1880, 15015, 1878, 15017, 1876, 15019, 1874, 15021, 1872, 15023, 1870, 15025, 1868, 15027, 1866, 15029, 1864, 15031, 1862, 15033, 1860, 15035, 1858, 15037, 1856, 15039, 1854, 15041, 1852, 15043, 1850, 15045, 1848, 15047, 1846, 15049, 1844, 15051, 1842, 15053, 1840, 15055, 1838, 15057, 1836, 15059, 1834, 15061, 1832, 15063, 1830, 15065, 1828, 15067, 1826, 15069, 1824, 15071, 1822, 15073, 1820, 15075, 1818, 15077, 1816, 15079, 1814, 15081, 1812, 15083, 1810, 15085, 1808, 15087, 1806, 15089, 1804, 15091, 1802, 15093, 1800, 15095, 1798, 15097, 1796, 15099, 1794, 15101, 1792, 15103, 1790, 15105, 1788, 15107, 1786, 15109, 1784, 15111, 1782, 15113, 1780, 15115, 1778, 15117, 1776, 15119, 1774, 15121, 1772, 15123, 1770, 15125, 1768, 15127, 1766, 15129, 1764, 15131, 1762, 15133, 1760, 15135, 1758, 15137, 1756, 15139, 1754, 15141, 1752, 15143, 1750, 15145, 1748, 15147, 1746, 15149, 1744, 15151, 1742, 15153, 1740, 15155, 1738, 15157, 1736, 15159, 1734, 15161, 1732, 15163, 1730, 15165, 1728, 15167, 1726, 15169, 1724, 15171, 1722, 15173, 1720, 15175, 1718, 15177, 1716, 15179, 1714, 15181, 1712, 15183, 1710, 15185, 1708, 15187, 1706, 15189, 1704, 15191, 1702, 15193, 1700, 15195, 1698, 15197, 1696, 15199, 1694, 15201, 1692, 15203, 1690, 15205, 1688, 15207, 1686, 15209, 1684, 15211, 1682, 15213, 1680, 15215, 1678, 15217, 1676, 15219, 1674, 15221, 1672, 15223, 1670, 15225, 1668, 15227, 1666, 15229, 1664, 15231, 1662, 15233, 1660, 15235, 1658, 15237, 1656, 15239, 1654, 15241, 1652, 15243, 1650, 15245, 1648, 15247, 1646, 15249, 1644, 15251, 1642, 15253, 1640, 15255, 1638, 15257, 1636, 15259, 1634, 15261, 1632, 15263, 1630, 15265, 1628, 15267, 1626, 15269, 1624, 15271, 1622, 15273, 1620, 15275, 1618, 15277, 1616, 15279, 1614, 15281, 1612, 15283, 1610, 15285, 1608, 15287, 1606, 15289, 1604, 15291, 1602, 15293, 1600, 15295, 1598, 15297, 1596, 15299, 1594, 15301, 1592, 15303, 1590, 15305, 1588, 15307, 1586, 15309, 1584, 15311, 1582, 15313, 1580, 15315, 1578, 15317, 1576, 15319, 1574, 15321, 1572, 15323, 1570, 15325, 1568, 15327, 1566, 15329, 1564, 15331, 1562, 15333, 1560, 15335, 1558, 15337, 1556, 15339, 1554, 15341, 1552, 15343, 1550, 15345, 1548, 15347, 1546, 15349, 1544, 15351, 1542, 15353, 1540, 15355, 1538, 15357, 1536, 15359, 1534, 15361, 1532, 15363, 1530, 15365, 1528, 15367, 1526, 15369, 1524, 15371, 1522, 15373, 1520, 15375, 1518, 15377, 1516, 15379, 1514, 15381, 1512, 15383, 1510, 15385, 1508, 15387, 1506, 15389, 1504, 15391, 1502, 15393, 1500, 15395, 1498, 15397, 1496, 15399, 1494, 15401, 1492, 15403, 1490, 15405, 1488, 15407, 1486, 15409, 1484, 15411, 1482, 15413, 1480, 15415, 1478, 15417, 1476, 15419, 1474, 15421, 1472, 15423, 1470, 15425, 1468, 15427, 1466, 15429, 1464, 15431, 1462, 15433, 1460, 15435, 1458, 15437, 1456, 15439, 1454, 15441, 1452, 15443, 1450, 15445, 1448, 15447, 1446, 15449, 1444, 15451, 1442, 15453, 1440, 15455, 1438, 15457, 1436, 15459, 1434, 15461, 1432, 15463, 1430, 15465, 1428, 15467, 1426, 15469, 1424, 15471, 1422, 15473, 1420, 15475, 1418, 15477, 1416, 15479, 1414, 15481, 1412, 15483, 1410, 15485, 1408, 15487, 1406, 15489, 1404, 15491, 1402, 15493, 1400, 15495, 1398, 15497, 1396, 15499, 1394, 15501, 1392, 15503, 1390, 15505, 1388, 15507, 1386, 15509, 1384, 15511, 1382, 15513, 1380, 15515, 1378, 15517, 1376, 15519, 1374, 15521, 1372, 15523, 1370, 15525, 1368, 15527, 1366, 15529, 1364, 15531, 1362, 15533, 1360, 15535, 1358, 15537, 1356, 15539, 1354, 15541, 1352, 15543, 1350, 15545, 1348, 15547, 1346, 15549, 1344, 15551, 1342, 15553, 1340, 15555, 1338, 15557, 1336, 15559, 1334, 15561, 1332, 15563, 1330, 15565, 1328, 15567, 1326, 15569, 1324, 15571, 1322, 15573, 1320, 15575, 1318, 15577, 1316, 15579, 1314, 15581, 1312, 15583, 1310, 15585, 1308, 15587, 1306, 15589, 1304, 15591, 1302, 15593, 1300, 15595, 1298, 15597, 1296, 15599, 1294, 15601, 1292, 15603, 1290, 15605, 1288, 15607, 1286, 15609, 1284, 15611, 1282, 15613, 1280, 15615, 1278, 15617, 1276, 15619, 1274, 15621, 1272, 15623, 1270, 15625, 1268, 15627, 1266, 15629, 1264, 15631, 1262, 15633, 1260, 15635, 1258, 15637, 1256, 15639, 1254, 15641, 1252, 15643, 1250, 15645, 1248, 15647, 1246, 15649, 1244, 15651, 1242, 15653, 1240, 15655, 1238, 15657, 1236, 15659, 1234, 15661, 1232, 15663, 1230, 15665, 1228, 15667, 1226, 15669, 1224, 15671, 1222, 15673, 1220, 15675, 1218, 15677, 1216, 15679, 1214, 15681, 1212, 15683, 1210, 15685, 1208, 15687, 1206, 15689, 1204, 15691, 1202, 15693, 1200, 15695, 1198, 15697, 1196, 15699, 1194, 15701, 1192, 15703, 1190, 15705, 1188, 15707, 1186, 15709, 1184, 15711, 1182, 15713, 1180, 15715, 1178, 15717, 1176, 15719, 1174, 15721, 1172, 15723, 1170, 15725, 1168, 15727, 1166, 15729, 1164, 15731, 1162, 15733, 1160, 15735, 1158, 15737, 1156, 15739, 1154, 15741, 1152, 15743, 1150, 15745, 1148, 15747, 1146, 15749, 1144, 15751, 1142, 15753, 1140, 15755, 1138, 15757, 1136, 15759, 1134, 15761, 1132, 15763, 1130, 15765, 1128, 15767, 1126, 15769, 1124, 15771, 1122, 15773, 1120, 15775, 1118, 15777, 1116, 15779, 1114, 15781, 1112, 15783, 1110, 15785, 1108, 15787, 1106, 15789, 1104, 15791, 1102, 15793, 1100, 15795, 1098, 15797, 1096, 15799, 1094, 15801, 1092, 15803, 1090, 15805, 1088, 15807, 1086, 15809, 1084, 15811, 1082, 15813, 1080, 15815, 1078, 15817, 1076, 15819, 1074, 15821, 1072, 15823, 1070, 15825, 1068, 15827, 1066, 15829, 1064, 15831, 1062, 15833, 1060, 15835, 1058, 15837, 1056, 15839, 1054, 15841, 1052, 15843, 1050, 15845, 1048, 15847, 1046, 15849, 1044, 15851, 1042, 15853, 1040, 15855, 1038, 15857, 1036, 15859, 1034, 15861, 1032, 15863, 1030, 15865, 1028, 15867, 1026, 15869, 1024, 15871, 1022, 15873, 1020, 15875, 1018, 15877, 1016, 15879, 1014, 15881, 1012, 15883, 1010, 15885, 1008, 15887, 1006, 15889, 1004, 15891, 1002, 15893, 1000, 15895, 998, 15897, 996, 15899, 994, 15901, 992, 15903, 990, 15905, 988, 15907, 986, 15909, 984, 15911, 982, 15913, 980, 15915, 978, 15917, 976, 15919, 974, 15921, 972, 15923, 970, 15925, 968, 15927, 966, 15929, 964, 15931, 962, 15933, 960, 15935, 958, 15937, 956, 15939, 954, 15941, 952, 15943, 950, 15945, 948, 15947, 946, 15949, 944, 15951, 942, 15953, 940, 15955, 938, 15957, 936, 15959, 934, 15961, 932, 15963, 930, 15965, 928, 15967, 926, 15969, 924, 15971, 922, 15973, 920, 15975, 918, 15977, 916, 15979, 914, 15981, 912, 15983, 910, 15985, 908, 15987, 906, 15989, 904, 15991, 902, 15993, 900, 15995, 898, 15997, 896, 15999, 894, 16001, 892, 16003, 890, 16005, 888, 16007, 886, 16009, 884, 16011, 882, 16013, 880, 16015, 878, 16017, 876, 16019, 874, 16021, 872, 16023, 870, 16025, 868, 16027, 866, 16029, 864, 16031, 862, 16033, 860, 16035, 858, 16037, 856, 16039, 854, 16041, 852, 16043, 850, 16045, 848, 16047, 846, 16049, 844, 16051, 842, 16053, 840, 16055, 838, 16057, 836, 16059, 834, 16061, 832, 16063, 830, 16065, 828, 16067, 826, 16069, 824, 16071, 822, 16073, 820, 16075, 818, 16077, 816, 16079, 814, 16081, 812, 16083, 810, 16085, 808, 16087, 806, 16089, 804, 16091, 802, 16093, 800, 16095, 798, 16097, 796, 16099, 794, 16101, 792, 16103, 790, 16105, 788, 16107, 786, 16109, 784, 16111, 782, 16113, 780, 16115, 778, 16117, 776, 16119, 774, 16121, 772, 16123, 770, 16125, 768, 16127, 766, 16129, 764, 16131, 762, 16133, 760, 16135, 758, 16137, 756, 16139, 754, 16141, 752, 16143, 750, 16145, 748, 16147, 746, 16149, 744, 16151, 742, 16153, 740, 16155, 738, 16157, 736, 16159, 734, 16161, 732, 16163, 730, 16165, 728, 16167, 726, 16169, 724, 16171, 722, 16173, 720, 16175, 718, 16177, 716, 16179, 714, 16181, 712, 16183, 710, 16185, 708, 16187, 706, 16189, 704, 16191, 702, 16193, 700, 16195, 698, 16197, 696, 16199, 694, 16201, 692, 16203, 690, 16205, 688, 16207, 686, 16209, 684, 16211, 682, 16213, 680, 16215, 678, 16217, 676, 16219, 674, 16221, 672, 16223, 670, 16225, 668, 16227, 666, 16229, 664, 16231, 662, 16233, 660, 16235, 658, 16237, 656, 16239, 654, 16241, 652, 16243, 650, 16245, 648, 16247, 646, 16249, 644, 16251, 642, 16253, 640, 16255, 638, 16257, 636, 16259, 634, 16261, 632, 16263, 630, 16265, 628, 16267, 626, 16269, 624, 16271, 622, 16273, 620, 16275, 618, 16277, 616, 16279, 614, 16281, 612, 16283, 610, 16285, 608, 16287, 606, 16289, 604, 16291, 602, 16293, 600, 16295, 598, 16297, 596, 16299, 594, 16301, 592, 16303, 590, 16305, 588, 16307, 586, 16309, 584, 16311, 582, 16313, 580, 16315, 578, 16317, 576, 16319, 574, 16321, 572, 16323, 570, 16325, 568, 16327, 566, 16329, 564, 16331, 562, 16333, 560, 16335, 558, 16337, 556, 16339, 554, 16341, 552, 16343, 550, 16345, 548, 16347, 546, 16349, 544, 16351, 542, 16353, 540, 16355, 538, 16357, 536, 16359, 534, 16361, 532, 16363, 530, 16365, 528, 16367, 526, 16369, 524, 16371, 522, 16373, 520, 16375, 518, 16377, 516, 16379, 514, 16381, 512, 16383, 510, 16385, 508, 16387, 506, 16389, 504, 16391, 502, 16393, 500, 16395, 498, 16397, 496, 16399, 494, 16401, 492, 16403, 490, 16405, 488, 16407, 486, 16409, 484, 16411, 482, 16413, 480, 16415, 478, 16417, 476, 16419, 474, 16421, 472, 16423, 470, 16425, 468, 16427, 466, 16429, 464, 16431, 462, 16433, 460, 16435, 458, 16437, 456, 16439, 454, 16441, 452, 16443, 450, 16445, 448, 16447, 446, 16449, 444, 16451, 442, 16453, 440, 16455, 438, 16457, 436, 16459, 434, 16461, 432, 16463, 430, 16465, 428, 16467, 426, 16469, 424, 16471, 422, 16473, 420, 16475, 418, 16477, 416, 16479, 414, 16481, 412, 16483, 410, 16485, 408, 16487, 406, 16489, 404, 16491, 402, 16493, 400, 16495, 398, 16497, 396, 16499, 394, 16501, 392, 16503, 390, 16505, 388, 16507, 386, 16509, 384, 16511, 382, 16513, 380, 16515, 378, 16517, 376, 16519, 374, 16521, 372, 16523, 370, 16525, 368, 16527, 366, 16529, 364, 16531, 362, 16533, 360, 16535, 358, 16537, 356, 16539, 354, 16541, 352, 16543, 350, 16545, 348, 16547, 346, 16549, 344, 16551, 342, 16553, 340, 16555, 338, 16557, 336, 16559, 334, 16561, 332, 16563, 330, 16565, 328, 16567, 326, 16569, 324, 16571, 322, 16573, 320, 16575, 318, 16577, 316, 16579, 314, 16581, 312, 16583, 310, 16585, 308, 16587, 306, 16589, 304, 16591, 302, 16593, 300, 16595, 298, 16597, 296, 16599, 294, 16601, 292, 16603, 290, 16605, 288, 16607, 286, 16609, 284, 16611, 282, 16613, 280, 16615, 278, 16617, 276, 16619, 274, 16621, 272, 16623, 270, 16625, 268, 16627, 266, 16629, 264, 16631, 262, 16633, 260, 16635, 258, 16637, 256, 16639, 254, 16641, 252, 16643, 250, 16645, 248, 16647, 246, 16649, 244, 16651, 242, 16653, 240, 16655, 238, 16657, 236, 16659, 234, 16661, 232, 16663, 230, 16665, 228, 16667, 226, 16669, 224, 16671, 222, 16673, 220, 16675, 218, 16677, 216, 16679, 214, 16681, 212, 16683, 210, 16685, 208, 16687, 206, 16689, 204, 16691, 202, 16693, 200, 16695, 198, 16697, 196, 16699, 194, 16701, 192, 16703, 190, 16705, 188, 16707, 186, 16709, 184, 16711, 182, 16713, 180, 16715, 178, 16717, 176, 16719, 174, 16721, 172, 16723, 170, 16725, 168, 16727, 166, 16729, 164, 16731, 162, 16733, 160, 16735, 158, 16737, 156, 16739, 154, 16741, 152, 16743, 150, 16745, 148, 16747, 146, 16749, 144, 16751, 142, 16753, 140, 16755, 138, 16757, 136, 16759, 134, 16761, 132, 16763, 130, 16765, 128, 16767, 126, 16769, 124, 16771, 122, 16773, 120, 16775, 118, 16777, 116, 16779, 114, 16781, 112, 16783, 110, 16785, 108, 16787, 106, 16789, 104, 16791, 102, 16793, 100, 16795, 98, 16797, 96, 16799, 94, 16801, 92, 16803, 90, 16805, 88, 16807, 86, 16809, 84, 16811, 82, 16813, 80, 16815, 78, 16817, 76, 16819, 74, 16821, 72, 16823, 70, 16825, 68, 16827, 66, 16829, 64, 16831, 62, 16833, 60, 16835, 58, 16837, 56, 16839, 54, 16841, 52, 16843, 50, 16845, 48, 16847, 46, 16849, 44, 16851, 42, 16853, 40, 16855, 38, 16857, 36, 16859, 34, 16861, 32, 16863, 30, 16865, 28, 16867, 26, 16869, 24, 16871, 22, 16873, 20, 16875, 18, 16877, 16, 16879, 14, 16881, 12, 16883, 10, 16885, 8, 16887, 6, 16889, 4, 16891, 2, 16893]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..79664067fd30cc3ebde09afa76ab866525ea6111 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 16894, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s6/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s6/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..574eb70ac8ca541745560c0d766ae94fe111134b --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 24684, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s6/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..953f8be3b0381ba0360074c3f7e5d791f766dc0e --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [24684, 1, 24682, 3, 24680, 5, 24678, 7, 24676, 9, 24674, 11, 24672, 13, 24670, 15, 24668, 17, 24666, 19, 24664, 21, 24662, 23, 24660, 25, 24658, 27, 24656, 29, 24654, 31, 24652, 33, 24650, 35, 24648, 37, 24646, 39, 24644, 41, 24642, 43, 24640, 45, 24638, 47, 24636, 49, 24634, 51, 24632, 53, 24630, 55, 24628, 57, 24626, 59, 24624, 61, 24622, 63, 24620, 65, 24618, 67, 24616, 69, 24614, 71, 24612, 73, 24610, 75, 24608, 77, 24606, 79, 24604, 81, 24602, 83, 24600, 85, 24598, 87, 24596, 89, 24594, 91, 24592, 93, 24590, 95, 24588, 97, 24586, 99, 24584, 101, 24582, 103, 24580, 105, 24578, 107, 24576, 109, 24574, 111, 24572, 113, 24570, 115, 24568, 117, 24566, 119, 24564, 121, 24562, 123, 24560, 125, 24558, 127, 24556, 129, 24554, 131, 24552, 133, 24550, 135, 24548, 137, 24546, 139, 24544, 141, 24542, 143, 24540, 145, 24538, 147, 24536, 149, 24534, 151, 24532, 153, 24530, 155, 24528, 157, 24526, 159, 24524, 161, 24522, 163, 24520, 165, 24518, 167, 24516, 169, 24514, 171, 24512, 173, 24510, 175, 24508, 177, 24506, 179, 24504, 181, 24502, 183, 24500, 185, 24498, 187, 24496, 189, 24494, 191, 24492, 193, 24490, 195, 24488, 197, 24486, 199, 24484, 201, 24482, 203, 24480, 205, 24478, 207, 24476, 209, 24474, 211, 24472, 213, 24470, 215, 24468, 217, 24466, 219, 24464, 221, 24462, 223, 24460, 225, 24458, 227, 24456, 229, 24454, 231, 24452, 233, 24450, 235, 24448, 237, 24446, 239, 24444, 241, 24442, 243, 24440, 245, 24438, 247, 24436, 249, 24434, 251, 24432, 253, 24430, 255, 24428, 257, 24426, 259, 24424, 261, 24422, 263, 24420, 265, 24418, 267, 24416, 269, 24414, 271, 24412, 273, 24410, 275, 24408, 277, 24406, 279, 24404, 281, 24402, 283, 24400, 285, 24398, 287, 24396, 289, 24394, 291, 24392, 293, 24390, 295, 24388, 297, 24386, 299, 24384, 301, 24382, 303, 24380, 305, 24378, 307, 24376, 309, 24374, 311, 24372, 313, 24370, 315, 24368, 317, 24366, 319, 24364, 321, 24362, 323, 24360, 325, 24358, 327, 24356, 329, 24354, 331, 24352, 333, 24350, 335, 24348, 337, 24346, 339, 24344, 341, 24342, 343, 24340, 345, 24338, 347, 24336, 349, 24334, 351, 24332, 353, 24330, 355, 24328, 357, 24326, 359, 24324, 361, 24322, 363, 24320, 365, 24318, 367, 24316, 369, 24314, 371, 24312, 373, 24310, 375, 24308, 377, 24306, 379, 24304, 381, 24302, 383, 24300, 385, 24298, 387, 24296, 389, 24294, 391, 24292, 393, 24290, 395, 24288, 397, 24286, 399, 24284, 401, 24282, 403, 24280, 405, 24278, 407, 24276, 409, 24274, 411, 24272, 413, 24270, 415, 24268, 417, 24266, 419, 24264, 421, 24262, 423, 24260, 425, 24258, 427, 24256, 429, 24254, 431, 24252, 433, 24250, 435, 24248, 437, 24246, 439, 24244, 441, 24242, 443, 24240, 445, 24238, 447, 24236, 449, 24234, 451, 24232, 453, 24230, 455, 24228, 457, 24226, 459, 24224, 461, 24222, 463, 24220, 465, 24218, 467, 24216, 469, 24214, 471, 24212, 473, 24210, 475, 24208, 477, 24206, 479, 24204, 481, 24202, 483, 24200, 485, 24198, 487, 24196, 489, 24194, 491, 24192, 493, 24190, 495, 24188, 497, 24186, 499, 24184, 501, 24182, 503, 24180, 505, 24178, 507, 24176, 509, 24174, 511, 24172, 513, 24170, 515, 24168, 517, 24166, 519, 24164, 521, 24162, 523, 24160, 525, 24158, 527, 24156, 529, 24154, 531, 24152, 533, 24150, 535, 24148, 537, 24146, 539, 24144, 541, 24142, 543, 24140, 545, 24138, 547, 24136, 549, 24134, 551, 24132, 553, 24130, 555, 24128, 557, 24126, 559, 24124, 561, 24122, 563, 24120, 565, 24118, 567, 24116, 569, 24114, 571, 24112, 573, 24110, 575, 24108, 577, 24106, 579, 24104, 581, 24102, 583, 24100, 585, 24098, 587, 24096, 589, 24094, 591, 24092, 593, 24090, 595, 24088, 597, 24086, 599, 24084, 601, 24082, 603, 24080, 605, 24078, 607, 24076, 609, 24074, 611, 24072, 613, 24070, 615, 24068, 617, 24066, 619, 24064, 621, 24062, 623, 24060, 625, 24058, 627, 24056, 629, 24054, 631, 24052, 633, 24050, 635, 24048, 637, 24046, 639, 24044, 641, 24042, 643, 24040, 645, 24038, 647, 24036, 649, 24034, 651, 24032, 653, 24030, 655, 24028, 657, 24026, 659, 24024, 661, 24022, 663, 24020, 665, 24018, 667, 24016, 669, 24014, 671, 24012, 673, 24010, 675, 24008, 677, 24006, 679, 24004, 681, 24002, 683, 24000, 685, 23998, 687, 23996, 689, 23994, 691, 23992, 693, 23990, 695, 23988, 697, 23986, 699, 23984, 701, 23982, 703, 23980, 705, 23978, 707, 23976, 709, 23974, 711, 23972, 713, 23970, 715, 23968, 717, 23966, 719, 23964, 721, 23962, 723, 23960, 725, 23958, 727, 23956, 729, 23954, 731, 23952, 733, 23950, 735, 23948, 737, 23946, 739, 23944, 741, 23942, 743, 23940, 745, 23938, 747, 23936, 749, 23934, 751, 23932, 753, 23930, 755, 23928, 757, 23926, 759, 23924, 761, 23922, 763, 23920, 765, 23918, 767, 23916, 769, 23914, 771, 23912, 773, 23910, 775, 23908, 777, 23906, 779, 23904, 781, 23902, 783, 23900, 785, 23898, 787, 23896, 789, 23894, 791, 23892, 793, 23890, 795, 23888, 797, 23886, 799, 23884, 801, 23882, 803, 23880, 805, 23878, 807, 23876, 809, 23874, 811, 23872, 813, 23870, 815, 23868, 817, 23866, 819, 23864, 821, 23862, 823, 23860, 825, 23858, 827, 23856, 829, 23854, 831, 23852, 833, 23850, 835, 23848, 837, 23846, 839, 23844, 841, 23842, 843, 23840, 845, 23838, 847, 23836, 849, 23834, 851, 23832, 853, 23830, 855, 23828, 857, 23826, 859, 23824, 861, 23822, 863, 23820, 865, 23818, 867, 23816, 869, 23814, 871, 23812, 873, 23810, 875, 23808, 877, 23806, 879, 23804, 881, 23802, 883, 23800, 885, 23798, 887, 23796, 889, 23794, 891, 23792, 893, 23790, 895, 23788, 897, 23786, 899, 23784, 901, 23782, 903, 23780, 905, 23778, 907, 23776, 909, 23774, 911, 23772, 913, 23770, 915, 23768, 917, 23766, 919, 23764, 921, 23762, 923, 23760, 925, 23758, 927, 23756, 929, 23754, 931, 23752, 933, 23750, 935, 23748, 937, 23746, 939, 23744, 941, 23742, 943, 23740, 945, 23738, 947, 23736, 949, 23734, 951, 23732, 953, 23730, 955, 23728, 957, 23726, 959, 23724, 961, 23722, 963, 23720, 965, 23718, 967, 23716, 969, 23714, 971, 23712, 973, 23710, 975, 23708, 977, 23706, 979, 23704, 981, 23702, 983, 23700, 985, 23698, 987, 23696, 989, 23694, 991, 23692, 993, 23690, 995, 23688, 997, 23686, 999, 23684, 1001, 23682, 1003, 23680, 1005, 23678, 1007, 23676, 1009, 23674, 1011, 23672, 1013, 23670, 1015, 23668, 1017, 23666, 1019, 23664, 1021, 23662, 1023, 23660, 1025, 23658, 1027, 23656, 1029, 23654, 1031, 23652, 1033, 23650, 1035, 23648, 1037, 23646, 1039, 23644, 1041, 23642, 1043, 23640, 1045, 23638, 1047, 23636, 1049, 23634, 1051, 23632, 1053, 23630, 1055, 23628, 1057, 23626, 1059, 23624, 1061, 23622, 1063, 23620, 1065, 23618, 1067, 23616, 1069, 23614, 1071, 23612, 1073, 23610, 1075, 23608, 1077, 23606, 1079, 23604, 1081, 23602, 1083, 23600, 1085, 23598, 1087, 23596, 1089, 23594, 1091, 23592, 1093, 23590, 1095, 23588, 1097, 23586, 1099, 23584, 1101, 23582, 1103, 23580, 1105, 23578, 1107, 23576, 1109, 23574, 1111, 23572, 1113, 23570, 1115, 23568, 1117, 23566, 1119, 23564, 1121, 23562, 1123, 23560, 1125, 23558, 1127, 23556, 1129, 23554, 1131, 23552, 1133, 23550, 1135, 23548, 1137, 23546, 1139, 23544, 1141, 23542, 1143, 23540, 1145, 23538, 1147, 23536, 1149, 23534, 1151, 23532, 1153, 23530, 1155, 23528, 1157, 23526, 1159, 23524, 1161, 23522, 1163, 23520, 1165, 23518, 1167, 23516, 1169, 23514, 1171, 23512, 1173, 23510, 1175, 23508, 1177, 23506, 1179, 23504, 1181, 23502, 1183, 23500, 1185, 23498, 1187, 23496, 1189, 23494, 1191, 23492, 1193, 23490, 1195, 23488, 1197, 23486, 1199, 23484, 1201, 23482, 1203, 23480, 1205, 23478, 1207, 23476, 1209, 23474, 1211, 23472, 1213, 23470, 1215, 23468, 1217, 23466, 1219, 23464, 1221, 23462, 1223, 23460, 1225, 23458, 1227, 23456, 1229, 23454, 1231, 23452, 1233, 23450, 1235, 23448, 1237, 23446, 1239, 23444, 1241, 23442, 1243, 23440, 1245, 23438, 1247, 23436, 1249, 23434, 1251, 23432, 1253, 23430, 1255, 23428, 1257, 23426, 1259, 23424, 1261, 23422, 1263, 23420, 1265, 23418, 1267, 23416, 1269, 23414, 1271, 23412, 1273, 23410, 1275, 23408, 1277, 23406, 1279, 23404, 1281, 23402, 1283, 23400, 1285, 23398, 1287, 23396, 1289, 23394, 1291, 23392, 1293, 23390, 1295, 23388, 1297, 23386, 1299, 23384, 1301, 23382, 1303, 23380, 1305, 23378, 1307, 23376, 1309, 23374, 1311, 23372, 1313, 23370, 1315, 23368, 1317, 23366, 1319, 23364, 1321, 23362, 1323, 23360, 1325, 23358, 1327, 23356, 1329, 23354, 1331, 23352, 1333, 23350, 1335, 23348, 1337, 23346, 1339, 23344, 1341, 23342, 1343, 23340, 1345, 23338, 1347, 23336, 1349, 23334, 1351, 23332, 1353, 23330, 1355, 23328, 1357, 23326, 1359, 23324, 1361, 23322, 1363, 23320, 1365, 23318, 1367, 23316, 1369, 23314, 1371, 23312, 1373, 23310, 1375, 23308, 1377, 23306, 1379, 23304, 1381, 23302, 1383, 23300, 1385, 23298, 1387, 23296, 1389, 23294, 1391, 23292, 1393, 23290, 1395, 23288, 1397, 23286, 1399, 23284, 1401, 23282, 1403, 23280, 1405, 23278, 1407, 23276, 1409, 23274, 1411, 23272, 1413, 23270, 1415, 23268, 1417, 23266, 1419, 23264, 1421, 23262, 1423, 23260, 1425, 23258, 1427, 23256, 1429, 23254, 1431, 23252, 1433, 23250, 1435, 23248, 1437, 23246, 1439, 23244, 1441, 23242, 1443, 23240, 1445, 23238, 1447, 23236, 1449, 23234, 1451, 23232, 1453, 23230, 1455, 23228, 1457, 23226, 1459, 23224, 1461, 23222, 1463, 23220, 1465, 23218, 1467, 23216, 1469, 23214, 1471, 23212, 1473, 23210, 1475, 23208, 1477, 23206, 1479, 23204, 1481, 23202, 1483, 23200, 1485, 23198, 1487, 23196, 1489, 23194, 1491, 23192, 1493, 23190, 1495, 23188, 1497, 23186, 1499, 23184, 1501, 23182, 1503, 23180, 1505, 23178, 1507, 23176, 1509, 23174, 1511, 23172, 1513, 23170, 1515, 23168, 1517, 23166, 1519, 23164, 1521, 23162, 1523, 23160, 1525, 23158, 1527, 23156, 1529, 23154, 1531, 23152, 1533, 23150, 1535, 23148, 1537, 23146, 1539, 23144, 1541, 23142, 1543, 23140, 1545, 23138, 1547, 23136, 1549, 23134, 1551, 23132, 1553, 23130, 1555, 23128, 1557, 23126, 1559, 23124, 1561, 23122, 1563, 23120, 1565, 23118, 1567, 23116, 1569, 23114, 1571, 23112, 1573, 23110, 1575, 23108, 1577, 23106, 1579, 23104, 1581, 23102, 1583, 23100, 1585, 23098, 1587, 23096, 1589, 23094, 1591, 23092, 1593, 23090, 1595, 23088, 1597, 23086, 1599, 23084, 1601, 23082, 1603, 23080, 1605, 23078, 1607, 23076, 1609, 23074, 1611, 23072, 1613, 23070, 1615, 23068, 1617, 23066, 1619, 23064, 1621, 23062, 1623, 23060, 1625, 23058, 1627, 23056, 1629, 23054, 1631, 23052, 1633, 23050, 1635, 23048, 1637, 23046, 1639, 23044, 1641, 23042, 1643, 23040, 1645, 23038, 1647, 23036, 1649, 23034, 1651, 23032, 1653, 23030, 1655, 23028, 1657, 23026, 1659, 23024, 1661, 23022, 1663, 23020, 1665, 23018, 1667, 23016, 1669, 23014, 1671, 23012, 1673, 23010, 1675, 23008, 1677, 23006, 1679, 23004, 1681, 23002, 1683, 23000, 1685, 22998, 1687, 22996, 1689, 22994, 1691, 22992, 1693, 22990, 1695, 22988, 1697, 22986, 1699, 22984, 1701, 22982, 1703, 22980, 1705, 22978, 1707, 22976, 1709, 22974, 1711, 22972, 1713, 22970, 1715, 22968, 1717, 22966, 1719, 22964, 1721, 22962, 1723, 22960, 1725, 22958, 1727, 22956, 1729, 22954, 1731, 22952, 1733, 22950, 1735, 22948, 1737, 22946, 1739, 22944, 1741, 22942, 1743, 22940, 1745, 22938, 1747, 22936, 1749, 22934, 1751, 22932, 1753, 22930, 1755, 22928, 1757, 22926, 1759, 22924, 1761, 22922, 1763, 22920, 1765, 22918, 1767, 22916, 1769, 22914, 1771, 22912, 1773, 22910, 1775, 22908, 1777, 22906, 1779, 22904, 1781, 22902, 1783, 22900, 1785, 22898, 1787, 22896, 1789, 22894, 1791, 22892, 1793, 22890, 1795, 22888, 1797, 22886, 1799, 22884, 1801, 22882, 1803, 22880, 1805, 22878, 1807, 22876, 1809, 22874, 1811, 22872, 1813, 22870, 1815, 22868, 1817, 22866, 1819, 22864, 1821, 22862, 1823, 22860, 1825, 22858, 1827, 22856, 1829, 22854, 1831, 22852, 1833, 22850, 1835, 22848, 1837, 22846, 1839, 22844, 1841, 22842, 1843, 22840, 1845, 22838, 1847, 22836, 1849, 22834, 1851, 22832, 1853, 22830, 1855, 22828, 1857, 22826, 1859, 22824, 1861, 22822, 1863, 22820, 1865, 22818, 1867, 22816, 1869, 22814, 1871, 22812, 1873, 22810, 1875, 22808, 1877, 22806, 1879, 22804, 1881, 22802, 1883, 22800, 1885, 22798, 1887, 22796, 1889, 22794, 1891, 22792, 1893, 22790, 1895, 22788, 1897, 22786, 1899, 22784, 1901, 22782, 1903, 22780, 1905, 22778, 1907, 22776, 1909, 22774, 1911, 22772, 1913, 22770, 1915, 22768, 1917, 22766, 1919, 22764, 1921, 22762, 1923, 22760, 1925, 22758, 1927, 22756, 1929, 22754, 1931, 22752, 1933, 22750, 1935, 22748, 1937, 22746, 1939, 22744, 1941, 22742, 1943, 22740, 1945, 22738, 1947, 22736, 1949, 22734, 1951, 22732, 1953, 22730, 1955, 22728, 1957, 22726, 1959, 22724, 1961, 22722, 1963, 22720, 1965, 22718, 1967, 22716, 1969, 22714, 1971, 22712, 1973, 22710, 1975, 22708, 1977, 22706, 1979, 22704, 1981, 22702, 1983, 22700, 1985, 22698, 1987, 22696, 1989, 22694, 1991, 22692, 1993, 22690, 1995, 22688, 1997, 22686, 1999, 22684, 2001, 22682, 2003, 22680, 2005, 22678, 2007, 22676, 2009, 22674, 2011, 22672, 2013, 22670, 2015, 22668, 2017, 22666, 2019, 22664, 2021, 22662, 2023, 22660, 2025, 22658, 2027, 22656, 2029, 22654, 2031, 22652, 2033, 22650, 2035, 22648, 2037, 22646, 2039, 22644, 2041, 22642, 2043, 22640, 2045, 22638, 2047, 22636, 2049, 22634, 2051, 22632, 2053, 22630, 2055, 22628, 2057, 22626, 2059, 22624, 2061, 22622, 2063, 22620, 2065, 22618, 2067, 22616, 2069, 22614, 2071, 22612, 2073, 22610, 2075, 22608, 2077, 22606, 2079, 22604, 2081, 22602, 2083, 22600, 2085, 22598, 2087, 22596, 2089, 22594, 2091, 22592, 2093, 22590, 2095, 22588, 2097, 22586, 2099, 22584, 2101, 22582, 2103, 22580, 2105, 22578, 2107, 22576, 2109, 22574, 2111, 22572, 2113, 22570, 2115, 22568, 2117, 22566, 2119, 22564, 2121, 22562, 2123, 22560, 2125, 22558, 2127, 22556, 2129, 22554, 2131, 22552, 2133, 22550, 2135, 22548, 2137, 22546, 2139, 22544, 2141, 22542, 2143, 22540, 2145, 22538, 2147, 22536, 2149, 22534, 2151, 22532, 2153, 22530, 2155, 22528, 2157, 22526, 2159, 22524, 2161, 22522, 2163, 22520, 2165, 22518, 2167, 22516, 2169, 22514, 2171, 22512, 2173, 22510, 2175, 22508, 2177, 22506, 2179, 22504, 2181, 22502, 2183, 22500, 2185, 22498, 2187, 22496, 2189, 22494, 2191, 22492, 2193, 22490, 2195, 22488, 2197, 22486, 2199, 22484, 2201, 22482, 2203, 22480, 2205, 22478, 2207, 22476, 2209, 22474, 2211, 22472, 2213, 22470, 2215, 22468, 2217, 22466, 2219, 22464, 2221, 22462, 2223, 22460, 2225, 22458, 2227, 22456, 2229, 22454, 2231, 22452, 2233, 22450, 2235, 22448, 2237, 22446, 2239, 22444, 2241, 22442, 2243, 22440, 2245, 22438, 2247, 22436, 2249, 22434, 2251, 22432, 2253, 22430, 2255, 22428, 2257, 22426, 2259, 22424, 2261, 22422, 2263, 22420, 2265, 22418, 2267, 22416, 2269, 22414, 2271, 22412, 2273, 22410, 2275, 22408, 2277, 22406, 2279, 22404, 2281, 22402, 2283, 22400, 2285, 22398, 2287, 22396, 2289, 22394, 2291, 22392, 2293, 22390, 2295, 22388, 2297, 22386, 2299, 22384, 2301, 22382, 2303, 22380, 2305, 22378, 2307, 22376, 2309, 22374, 2311, 22372, 2313, 22370, 2315, 22368, 2317, 22366, 2319, 22364, 2321, 22362, 2323, 22360, 2325, 22358, 2327, 22356, 2329, 22354, 2331, 22352, 2333, 22350, 2335, 22348, 2337, 22346, 2339, 22344, 2341, 22342, 2343, 22340, 2345, 22338, 2347, 22336, 2349, 22334, 2351, 22332, 2353, 22330, 2355, 22328, 2357, 22326, 2359, 22324, 2361, 22322, 2363, 22320, 2365, 22318, 2367, 22316, 2369, 22314, 2371, 22312, 2373, 22310, 2375, 22308, 2377, 22306, 2379, 22304, 2381, 22302, 2383, 22300, 2385, 22298, 2387, 22296, 2389, 22294, 2391, 22292, 2393, 22290, 2395, 22288, 2397, 22286, 2399, 22284, 2401, 22282, 2403, 22280, 2405, 22278, 2407, 22276, 2409, 22274, 2411, 22272, 2413, 22270, 2415, 22268, 2417, 22266, 2419, 22264, 2421, 22262, 2423, 22260, 2425, 22258, 2427, 22256, 2429, 22254, 2431, 22252, 2433, 22250, 2435, 22248, 2437, 22246, 2439, 22244, 2441, 22242, 2443, 22240, 2445, 22238, 2447, 22236, 2449, 22234, 2451, 22232, 2453, 22230, 2455, 22228, 2457, 22226, 2459, 22224, 2461, 22222, 2463, 22220, 2465, 22218, 2467, 22216, 2469, 22214, 2471, 22212, 2473, 22210, 2475, 22208, 2477, 22206, 2479, 22204, 2481, 22202, 2483, 22200, 2485, 22198, 2487, 22196, 2489, 22194, 2491, 22192, 2493, 22190, 2495, 22188, 2497, 22186, 2499, 22184, 2501, 22182, 2503, 22180, 2505, 22178, 2507, 22176, 2509, 22174, 2511, 22172, 2513, 22170, 2515, 22168, 2517, 22166, 2519, 22164, 2521, 22162, 2523, 22160, 2525, 22158, 2527, 22156, 2529, 22154, 2531, 22152, 2533, 22150, 2535, 22148, 2537, 22146, 2539, 22144, 2541, 22142, 2543, 22140, 2545, 22138, 2547, 22136, 2549, 22134, 2551, 22132, 2553, 22130, 2555, 22128, 2557, 22126, 2559, 22124, 2561, 22122, 2563, 22120, 2565, 22118, 2567, 22116, 2569, 22114, 2571, 22112, 2573, 22110, 2575, 22108, 2577, 22106, 2579, 22104, 2581, 22102, 2583, 22100, 2585, 22098, 2587, 22096, 2589, 22094, 2591, 22092, 2593, 22090, 2595, 22088, 2597, 22086, 2599, 22084, 2601, 22082, 2603, 22080, 2605, 22078, 2607, 22076, 2609, 22074, 2611, 22072, 2613, 22070, 2615, 22068, 2617, 22066, 2619, 22064, 2621, 22062, 2623, 22060, 2625, 22058, 2627, 22056, 2629, 22054, 2631, 22052, 2633, 22050, 2635, 22048, 2637, 22046, 2639, 22044, 2641, 22042, 2643, 22040, 2645, 22038, 2647, 22036, 2649, 22034, 2651, 22032, 2653, 22030, 2655, 22028, 2657, 22026, 2659, 22024, 2661, 22022, 2663, 22020, 2665, 22018, 2667, 22016, 2669, 22014, 2671, 22012, 2673, 22010, 2675, 22008, 2677, 22006, 2679, 22004, 2681, 22002, 2683, 22000, 2685, 21998, 2687, 21996, 2689, 21994, 2691, 21992, 2693, 21990, 2695, 21988, 2697, 21986, 2699, 21984, 2701, 21982, 2703, 21980, 2705, 21978, 2707, 21976, 2709, 21974, 2711, 21972, 2713, 21970, 2715, 21968, 2717, 21966, 2719, 21964, 2721, 21962, 2723, 21960, 2725, 21958, 2727, 21956, 2729, 21954, 2731, 21952, 2733, 21950, 2735, 21948, 2737, 21946, 2739, 21944, 2741, 21942, 2743, 21940, 2745, 21938, 2747, 21936, 2749, 21934, 2751, 21932, 2753, 21930, 2755, 21928, 2757, 21926, 2759, 21924, 2761, 21922, 2763, 21920, 2765, 21918, 2767, 21916, 2769, 21914, 2771, 21912, 2773, 21910, 2775, 21908, 2777, 21906, 2779, 21904, 2781, 21902, 2783, 21900, 2785, 21898, 2787, 21896, 2789, 21894, 2791, 21892, 2793, 21890, 2795, 21888, 2797, 21886, 2799, 21884, 2801, 21882, 2803, 21880, 2805, 21878, 2807, 21876, 2809, 21874, 2811, 21872, 2813, 21870, 2815, 21868, 2817, 21866, 2819, 21864, 2821, 21862, 2823, 21860, 2825, 21858, 2827, 21856, 2829, 21854, 2831, 21852, 2833, 21850, 2835, 21848, 2837, 21846, 2839, 21844, 2841, 21842, 2843, 21840, 2845, 21838, 2847, 21836, 2849, 21834, 2851, 21832, 2853, 21830, 2855, 21828, 2857, 21826, 2859, 21824, 2861, 21822, 2863, 21820, 2865, 21818, 2867, 21816, 2869, 21814, 2871, 21812, 2873, 21810, 2875, 21808, 2877, 21806, 2879, 21804, 2881, 21802, 2883, 21800, 2885, 21798, 2887, 21796, 2889, 21794, 2891, 21792, 2893, 21790, 2895, 21788, 2897, 21786, 2899, 21784, 2901, 21782, 2903, 21780, 2905, 21778, 2907, 21776, 2909, 21774, 2911, 21772, 2913, 21770, 2915, 21768, 2917, 21766, 2919, 21764, 2921, 21762, 2923, 21760, 2925, 21758, 2927, 21756, 2929, 21754, 2931, 21752, 2933, 21750, 2935, 21748, 2937, 21746, 2939, 21744, 2941, 21742, 2943, 21740, 2945, 21738, 2947, 21736, 2949, 21734, 2951, 21732, 2953, 21730, 2955, 21728, 2957, 21726, 2959, 21724, 2961, 21722, 2963, 21720, 2965, 21718, 2967, 21716, 2969, 21714, 2971, 21712, 2973, 21710, 2975, 21708, 2977, 21706, 2979, 21704, 2981, 21702, 2983, 21700, 2985, 21698, 2987, 21696, 2989, 21694, 2991, 21692, 2993, 21690, 2995, 21688, 2997, 21686, 2999, 21684, 3001, 21682, 3003, 21680, 3005, 21678, 3007, 21676, 3009, 21674, 3011, 21672, 3013, 21670, 3015, 21668, 3017, 21666, 3019, 21664, 3021, 21662, 3023, 21660, 3025, 21658, 3027, 21656, 3029, 21654, 3031, 21652, 3033, 21650, 3035, 21648, 3037, 21646, 3039, 21644, 3041, 21642, 3043, 21640, 3045, 21638, 3047, 21636, 3049, 21634, 3051, 21632, 3053, 21630, 3055, 21628, 3057, 21626, 3059, 21624, 3061, 21622, 3063, 21620, 3065, 21618, 3067, 21616, 3069, 21614, 3071, 21612, 3073, 21610, 3075, 21608, 3077, 21606, 3079, 21604, 3081, 21602, 3083, 21600, 3085, 21598, 3087, 21596, 3089, 21594, 3091, 21592, 3093, 21590, 3095, 21588, 3097, 21586, 3099, 21584, 3101, 21582, 3103, 21580, 3105, 21578, 3107, 21576, 3109, 21574, 3111, 21572, 3113, 21570, 3115, 21568, 3117, 21566, 3119, 21564, 3121, 21562, 3123, 21560, 3125, 21558, 3127, 21556, 3129, 21554, 3131, 21552, 3133, 21550, 3135, 21548, 3137, 21546, 3139, 21544, 3141, 21542, 3143, 21540, 3145, 21538, 3147, 21536, 3149, 21534, 3151, 21532, 3153, 21530, 3155, 21528, 3157, 21526, 3159, 21524, 3161, 21522, 3163, 21520, 3165, 21518, 3167, 21516, 3169, 21514, 3171, 21512, 3173, 21510, 3175, 21508, 3177, 21506, 3179, 21504, 3181, 21502, 3183, 21500, 3185, 21498, 3187, 21496, 3189, 21494, 3191, 21492, 3193, 21490, 3195, 21488, 3197, 21486, 3199, 21484, 3201, 21482, 3203, 21480, 3205, 21478, 3207, 21476, 3209, 21474, 3211, 21472, 3213, 21470, 3215, 21468, 3217, 21466, 3219, 21464, 3221, 21462, 3223, 21460, 3225, 21458, 3227, 21456, 3229, 21454, 3231, 21452, 3233, 21450, 3235, 21448, 3237, 21446, 3239, 21444, 3241, 21442, 3243, 21440, 3245, 21438, 3247, 21436, 3249, 21434, 3251, 21432, 3253, 21430, 3255, 21428, 3257, 21426, 3259, 21424, 3261, 21422, 3263, 21420, 3265, 21418, 3267, 21416, 3269, 21414, 3271, 21412, 3273, 21410, 3275, 21408, 3277, 21406, 3279, 21404, 3281, 21402, 3283, 21400, 3285, 21398, 3287, 21396, 3289, 21394, 3291, 21392, 3293, 21390, 3295, 21388, 3297, 21386, 3299, 21384, 3301, 21382, 3303, 21380, 3305, 21378, 3307, 21376, 3309, 21374, 3311, 21372, 3313, 21370, 3315, 21368, 3317, 21366, 3319, 21364, 3321, 21362, 3323, 21360, 3325, 21358, 3327, 21356, 3329, 21354, 3331, 21352, 3333, 21350, 3335, 21348, 3337, 21346, 3339, 21344, 3341, 21342, 3343, 21340, 3345, 21338, 3347, 21336, 3349, 21334, 3351, 21332, 3353, 21330, 3355, 21328, 3357, 21326, 3359, 21324, 3361, 21322, 3363, 21320, 3365, 21318, 3367, 21316, 3369, 21314, 3371, 21312, 3373, 21310, 3375, 21308, 3377, 21306, 3379, 21304, 3381, 21302, 3383, 21300, 3385, 21298, 3387, 21296, 3389, 21294, 3391, 21292, 3393, 21290, 3395, 21288, 3397, 21286, 3399, 21284, 3401, 21282, 3403, 21280, 3405, 21278, 3407, 21276, 3409, 21274, 3411, 21272, 3413, 21270, 3415, 21268, 3417, 21266, 3419, 21264, 3421, 21262, 3423, 21260, 3425, 21258, 3427, 21256, 3429, 21254, 3431, 21252, 3433, 21250, 3435, 21248, 3437, 21246, 3439, 21244, 3441, 21242, 3443, 21240, 3445, 21238, 3447, 21236, 3449, 21234, 3451, 21232, 3453, 21230, 3455, 21228, 3457, 21226, 3459, 21224, 3461, 21222, 3463, 21220, 3465, 21218, 3467, 21216, 3469, 21214, 3471, 21212, 3473, 21210, 3475, 21208, 3477, 21206, 3479, 21204, 3481, 21202, 3483, 21200, 3485, 21198, 3487, 21196, 3489, 21194, 3491, 21192, 3493, 21190, 3495, 21188, 3497, 21186, 3499, 21184, 3501, 21182, 3503, 21180, 3505, 21178, 3507, 21176, 3509, 21174, 3511, 21172, 3513, 21170, 3515, 21168, 3517, 21166, 3519, 21164, 3521, 21162, 3523, 21160, 3525, 21158, 3527, 21156, 3529, 21154, 3531, 21152, 3533, 21150, 3535, 21148, 3537, 21146, 3539, 21144, 3541, 21142, 3543, 21140, 3545, 21138, 3547, 21136, 3549, 21134, 3551, 21132, 3553, 21130, 3555, 21128, 3557, 21126, 3559, 21124, 3561, 21122, 3563, 21120, 3565, 21118, 3567, 21116, 3569, 21114, 3571, 21112, 3573, 21110, 3575, 21108, 3577, 21106, 3579, 21104, 3581, 21102, 3583, 21100, 3585, 21098, 3587, 21096, 3589, 21094, 3591, 21092, 3593, 21090, 3595, 21088, 3597, 21086, 3599, 21084, 3601, 21082, 3603, 21080, 3605, 21078, 3607, 21076, 3609, 21074, 3611, 21072, 3613, 21070, 3615, 21068, 3617, 21066, 3619, 21064, 3621, 21062, 3623, 21060, 3625, 21058, 3627, 21056, 3629, 21054, 3631, 21052, 3633, 21050, 3635, 21048, 3637, 21046, 3639, 21044, 3641, 21042, 3643, 21040, 3645, 21038, 3647, 21036, 3649, 21034, 3651, 21032, 3653, 21030, 3655, 21028, 3657, 21026, 3659, 21024, 3661, 21022, 3663, 21020, 3665, 21018, 3667, 21016, 3669, 21014, 3671, 21012, 3673, 21010, 3675, 21008, 3677, 21006, 3679, 21004, 3681, 21002, 3683, 21000, 3685, 20998, 3687, 20996, 3689, 20994, 3691, 20992, 3693, 20990, 3695, 20988, 3697, 20986, 3699, 20984, 3701, 20982, 3703, 20980, 3705, 20978, 3707, 20976, 3709, 20974, 3711, 20972, 3713, 20970, 3715, 20968, 3717, 20966, 3719, 20964, 3721, 20962, 3723, 20960, 3725, 20958, 3727, 20956, 3729, 20954, 3731, 20952, 3733, 20950, 3735, 20948, 3737, 20946, 3739, 20944, 3741, 20942, 3743, 20940, 3745, 20938, 3747, 20936, 3749, 20934, 3751, 20932, 3753, 20930, 3755, 20928, 3757, 20926, 3759, 20924, 3761, 20922, 3763, 20920, 3765, 20918, 3767, 20916, 3769, 20914, 3771, 20912, 3773, 20910, 3775, 20908, 3777, 20906, 3779, 20904, 3781, 20902, 3783, 20900, 3785, 20898, 3787, 20896, 3789, 20894, 3791, 20892, 3793, 20890, 3795, 20888, 3797, 20886, 3799, 20884, 3801, 20882, 3803, 20880, 3805, 20878, 3807, 20876, 3809, 20874, 3811, 20872, 3813, 20870, 3815, 20868, 3817, 20866, 3819, 20864, 3821, 20862, 3823, 20860, 3825, 20858, 3827, 20856, 3829, 20854, 3831, 20852, 3833, 20850, 3835, 20848, 3837, 20846, 3839, 20844, 3841, 20842, 3843, 20840, 3845, 20838, 3847, 20836, 3849, 20834, 3851, 20832, 3853, 20830, 3855, 20828, 3857, 20826, 3859, 20824, 3861, 20822, 3863, 20820, 3865, 20818, 3867, 20816, 3869, 20814, 3871, 20812, 3873, 20810, 3875, 20808, 3877, 20806, 3879, 20804, 3881, 20802, 3883, 20800, 3885, 20798, 3887, 20796, 3889, 20794, 3891, 20792, 3893, 20790, 3895, 20788, 3897, 20786, 3899, 20784, 3901, 20782, 3903, 20780, 3905, 20778, 3907, 20776, 3909, 20774, 3911, 20772, 3913, 20770, 3915, 20768, 3917, 20766, 3919, 20764, 3921, 20762, 3923, 20760, 3925, 20758, 3927, 20756, 3929, 20754, 3931, 20752, 3933, 20750, 3935, 20748, 3937, 20746, 3939, 20744, 3941, 20742, 3943, 20740, 3945, 20738, 3947, 20736, 3949, 20734, 3951, 20732, 3953, 20730, 3955, 20728, 3957, 20726, 3959, 20724, 3961, 20722, 3963, 20720, 3965, 20718, 3967, 20716, 3969, 20714, 3971, 20712, 3973, 20710, 3975, 20708, 3977, 20706, 3979, 20704, 3981, 20702, 3983, 20700, 3985, 20698, 3987, 20696, 3989, 20694, 3991, 20692, 3993, 20690, 3995, 20688, 3997, 20686, 3999, 20684, 4001, 20682, 4003, 20680, 4005, 20678, 4007, 20676, 4009, 20674, 4011, 20672, 4013, 20670, 4015, 20668, 4017, 20666, 4019, 20664, 4021, 20662, 4023, 20660, 4025, 20658, 4027, 20656, 4029, 20654, 4031, 20652, 4033, 20650, 4035, 20648, 4037, 20646, 4039, 20644, 4041, 20642, 4043, 20640, 4045, 20638, 4047, 20636, 4049, 20634, 4051, 20632, 4053, 20630, 4055, 20628, 4057, 20626, 4059, 20624, 4061, 20622, 4063, 20620, 4065, 20618, 4067, 20616, 4069, 20614, 4071, 20612, 4073, 20610, 4075, 20608, 4077, 20606, 4079, 20604, 4081, 20602, 4083, 20600, 4085, 20598, 4087, 20596, 4089, 20594, 4091, 20592, 4093, 20590, 4095, 20588, 4097, 20586, 4099, 20584, 4101, 20582, 4103, 20580, 4105, 20578, 4107, 20576, 4109, 20574, 4111, 20572, 4113, 20570, 4115, 20568, 4117, 20566, 4119, 20564, 4121, 20562, 4123, 20560, 4125, 20558, 4127, 20556, 4129, 20554, 4131, 20552, 4133, 20550, 4135, 20548, 4137, 20546, 4139, 20544, 4141, 20542, 4143, 20540, 4145, 20538, 4147, 20536, 4149, 20534, 4151, 20532, 4153, 20530, 4155, 20528, 4157, 20526, 4159, 20524, 4161, 20522, 4163, 20520, 4165, 20518, 4167, 20516, 4169, 20514, 4171, 20512, 4173, 20510, 4175, 20508, 4177, 20506, 4179, 20504, 4181, 20502, 4183, 20500, 4185, 20498, 4187, 20496, 4189, 20494, 4191, 20492, 4193, 20490, 4195, 20488, 4197, 20486, 4199, 20484, 4201, 20482, 4203, 20480, 4205, 20478, 4207, 20476, 4209, 20474, 4211, 20472, 4213, 20470, 4215, 20468, 4217, 20466, 4219, 20464, 4221, 20462, 4223, 20460, 4225, 20458, 4227, 20456, 4229, 20454, 4231, 20452, 4233, 20450, 4235, 20448, 4237, 20446, 4239, 20444, 4241, 20442, 4243, 20440, 4245, 20438, 4247, 20436, 4249, 20434, 4251, 20432, 4253, 20430, 4255, 20428, 4257, 20426, 4259, 20424, 4261, 20422, 4263, 20420, 4265, 20418, 4267, 20416, 4269, 20414, 4271, 20412, 4273, 20410, 4275, 20408, 4277, 20406, 4279, 20404, 4281, 20402, 4283, 20400, 4285, 20398, 4287, 20396, 4289, 20394, 4291, 20392, 4293, 20390, 4295, 20388, 4297, 20386, 4299, 20384, 4301, 20382, 4303, 20380, 4305, 20378, 4307, 20376, 4309, 20374, 4311, 20372, 4313, 20370, 4315, 20368, 4317, 20366, 4319, 20364, 4321, 20362, 4323, 20360, 4325, 20358, 4327, 20356, 4329, 20354, 4331, 20352, 4333, 20350, 4335, 20348, 4337, 20346, 4339, 20344, 4341, 20342, 4343, 20340, 4345, 20338, 4347, 20336, 4349, 20334, 4351, 20332, 4353, 20330, 4355, 20328, 4357, 20326, 4359, 20324, 4361, 20322, 4363, 20320, 4365, 20318, 4367, 20316, 4369, 20314, 4371, 20312, 4373, 20310, 4375, 20308, 4377, 20306, 4379, 20304, 4381, 20302, 4383, 20300, 4385, 20298, 4387, 20296, 4389, 20294, 4391, 20292, 4393, 20290, 4395, 20288, 4397, 20286, 4399, 20284, 4401, 20282, 4403, 20280, 4405, 20278, 4407, 20276, 4409, 20274, 4411, 20272, 4413, 20270, 4415, 20268, 4417, 20266, 4419, 20264, 4421, 20262, 4423, 20260, 4425, 20258, 4427, 20256, 4429, 20254, 4431, 20252, 4433, 20250, 4435, 20248, 4437, 20246, 4439, 20244, 4441, 20242, 4443, 20240, 4445, 20238, 4447, 20236, 4449, 20234, 4451, 20232, 4453, 20230, 4455, 20228, 4457, 20226, 4459, 20224, 4461, 20222, 4463, 20220, 4465, 20218, 4467, 20216, 4469, 20214, 4471, 20212, 4473, 20210, 4475, 20208, 4477, 20206, 4479, 20204, 4481, 20202, 4483, 20200, 4485, 20198, 4487, 20196, 4489, 20194, 4491, 20192, 4493, 20190, 4495, 20188, 4497, 20186, 4499, 20184, 4501, 20182, 4503, 20180, 4505, 20178, 4507, 20176, 4509, 20174, 4511, 20172, 4513, 20170, 4515, 20168, 4517, 20166, 4519, 20164, 4521, 20162, 4523, 20160, 4525, 20158, 4527, 20156, 4529, 20154, 4531, 20152, 4533, 20150, 4535, 20148, 4537, 20146, 4539, 20144, 4541, 20142, 4543, 20140, 4545, 20138, 4547, 20136, 4549, 20134, 4551, 20132, 4553, 20130, 4555, 20128, 4557, 20126, 4559, 20124, 4561, 20122, 4563, 20120, 4565, 20118, 4567, 20116, 4569, 20114, 4571, 20112, 4573, 20110, 4575, 20108, 4577, 20106, 4579, 20104, 4581, 20102, 4583, 20100, 4585, 20098, 4587, 20096, 4589, 20094, 4591, 20092, 4593, 20090, 4595, 20088, 4597, 20086, 4599, 20084, 4601, 20082, 4603, 20080, 4605, 20078, 4607, 20076, 4609, 20074, 4611, 20072, 4613, 20070, 4615, 20068, 4617, 20066, 4619, 20064, 4621, 20062, 4623, 20060, 4625, 20058, 4627, 20056, 4629, 20054, 4631, 20052, 4633, 20050, 4635, 20048, 4637, 20046, 4639, 20044, 4641, 20042, 4643, 20040, 4645, 20038, 4647, 20036, 4649, 20034, 4651, 20032, 4653, 20030, 4655, 20028, 4657, 20026, 4659, 20024, 4661, 20022, 4663, 20020, 4665, 20018, 4667, 20016, 4669, 20014, 4671, 20012, 4673, 20010, 4675, 20008, 4677, 20006, 4679, 20004, 4681, 20002, 4683, 20000, 4685, 19998, 4687, 19996, 4689, 19994, 4691, 19992, 4693, 19990, 4695, 19988, 4697, 19986, 4699, 19984, 4701, 19982, 4703, 19980, 4705, 19978, 4707, 19976, 4709, 19974, 4711, 19972, 4713, 19970, 4715, 19968, 4717, 19966, 4719, 19964, 4721, 19962, 4723, 19960, 4725, 19958, 4727, 19956, 4729, 19954, 4731, 19952, 4733, 19950, 4735, 19948, 4737, 19946, 4739, 19944, 4741, 19942, 4743, 19940, 4745, 19938, 4747, 19936, 4749, 19934, 4751, 19932, 4753, 19930, 4755, 19928, 4757, 19926, 4759, 19924, 4761, 19922, 4763, 19920, 4765, 19918, 4767, 19916, 4769, 19914, 4771, 19912, 4773, 19910, 4775, 19908, 4777, 19906, 4779, 19904, 4781, 19902, 4783, 19900, 4785, 19898, 4787, 19896, 4789, 19894, 4791, 19892, 4793, 19890, 4795, 19888, 4797, 19886, 4799, 19884, 4801, 19882, 4803, 19880, 4805, 19878, 4807, 19876, 4809, 19874, 4811, 19872, 4813, 19870, 4815, 19868, 4817, 19866, 4819, 19864, 4821, 19862, 4823, 19860, 4825, 19858, 4827, 19856, 4829, 19854, 4831, 19852, 4833, 19850, 4835, 19848, 4837, 19846, 4839, 19844, 4841, 19842, 4843, 19840, 4845, 19838, 4847, 19836, 4849, 19834, 4851, 19832, 4853, 19830, 4855, 19828, 4857, 19826, 4859, 19824, 4861, 19822, 4863, 19820, 4865, 19818, 4867, 19816, 4869, 19814, 4871, 19812, 4873, 19810, 4875, 19808, 4877, 19806, 4879, 19804, 4881, 19802, 4883, 19800, 4885, 19798, 4887, 19796, 4889, 19794, 4891, 19792, 4893, 19790, 4895, 19788, 4897, 19786, 4899, 19784, 4901, 19782, 4903, 19780, 4905, 19778, 4907, 19776, 4909, 19774, 4911, 19772, 4913, 19770, 4915, 19768, 4917, 19766, 4919, 19764, 4921, 19762, 4923, 19760, 4925, 19758, 4927, 19756, 4929, 19754, 4931, 19752, 4933, 19750, 4935, 19748, 4937, 19746, 4939, 19744, 4941, 19742, 4943, 19740, 4945, 19738, 4947, 19736, 4949, 19734, 4951, 19732, 4953, 19730, 4955, 19728, 4957, 19726, 4959, 19724, 4961, 19722, 4963, 19720, 4965, 19718, 4967, 19716, 4969, 19714, 4971, 19712, 4973, 19710, 4975, 19708, 4977, 19706, 4979, 19704, 4981, 19702, 4983, 19700, 4985, 19698, 4987, 19696, 4989, 19694, 4991, 19692, 4993, 19690, 4995, 19688, 4997, 19686, 4999, 19684, 5001, 19682, 5003, 19680, 5005, 19678, 5007, 19676, 5009, 19674, 5011, 19672, 5013, 19670, 5015, 19668, 5017, 19666, 5019, 19664, 5021, 19662, 5023, 19660, 5025, 19658, 5027, 19656, 5029, 19654, 5031, 19652, 5033, 19650, 5035, 19648, 5037, 19646, 5039, 19644, 5041, 19642, 5043, 19640, 5045, 19638, 5047, 19636, 5049, 19634, 5051, 19632, 5053, 19630, 5055, 19628, 5057, 19626, 5059, 19624, 5061, 19622, 5063, 19620, 5065, 19618, 5067, 19616, 5069, 19614, 5071, 19612, 5073, 19610, 5075, 19608, 5077, 19606, 5079, 19604, 5081, 19602, 5083, 19600, 5085, 19598, 5087, 19596, 5089, 19594, 5091, 19592, 5093, 19590, 5095, 19588, 5097, 19586, 5099, 19584, 5101, 19582, 5103, 19580, 5105, 19578, 5107, 19576, 5109, 19574, 5111, 19572, 5113, 19570, 5115, 19568, 5117, 19566, 5119, 19564, 5121, 19562, 5123, 19560, 5125, 19558, 5127, 19556, 5129, 19554, 5131, 19552, 5133, 19550, 5135, 19548, 5137, 19546, 5139, 19544, 5141, 19542, 5143, 19540, 5145, 19538, 5147, 19536, 5149, 19534, 5151, 19532, 5153, 19530, 5155, 19528, 5157, 19526, 5159, 19524, 5161, 19522, 5163, 19520, 5165, 19518, 5167, 19516, 5169, 19514, 5171, 19512, 5173, 19510, 5175, 19508, 5177, 19506, 5179, 19504, 5181, 19502, 5183, 19500, 5185, 19498, 5187, 19496, 5189, 19494, 5191, 19492, 5193, 19490, 5195, 19488, 5197, 19486, 5199, 19484, 5201, 19482, 5203, 19480, 5205, 19478, 5207, 19476, 5209, 19474, 5211, 19472, 5213, 19470, 5215, 19468, 5217, 19466, 5219, 19464, 5221, 19462, 5223, 19460, 5225, 19458, 5227, 19456, 5229, 19454, 5231, 19452, 5233, 19450, 5235, 19448, 5237, 19446, 5239, 19444, 5241, 19442, 5243, 19440, 5245, 19438, 5247, 19436, 5249, 19434, 5251, 19432, 5253, 19430, 5255, 19428, 5257, 19426, 5259, 19424, 5261, 19422, 5263, 19420, 5265, 19418, 5267, 19416, 5269, 19414, 5271, 19412, 5273, 19410, 5275, 19408, 5277, 19406, 5279, 19404, 5281, 19402, 5283, 19400, 5285, 19398, 5287, 19396, 5289, 19394, 5291, 19392, 5293, 19390, 5295, 19388, 5297, 19386, 5299, 19384, 5301, 19382, 5303, 19380, 5305, 19378, 5307, 19376, 5309, 19374, 5311, 19372, 5313, 19370, 5315, 19368, 5317, 19366, 5319, 19364, 5321, 19362, 5323, 19360, 5325, 19358, 5327, 19356, 5329, 19354, 5331, 19352, 5333, 19350, 5335, 19348, 5337, 19346, 5339, 19344, 5341, 19342, 5343, 19340, 5345, 19338, 5347, 19336, 5349, 19334, 5351, 19332, 5353, 19330, 5355, 19328, 5357, 19326, 5359, 19324, 5361, 19322, 5363, 19320, 5365, 19318, 5367, 19316, 5369, 19314, 5371, 19312, 5373, 19310, 5375, 19308, 5377, 19306, 5379, 19304, 5381, 19302, 5383, 19300, 5385, 19298, 5387, 19296, 5389, 19294, 5391, 19292, 5393, 19290, 5395, 19288, 5397, 19286, 5399, 19284, 5401, 19282, 5403, 19280, 5405, 19278, 5407, 19276, 5409, 19274, 5411, 19272, 5413, 19270, 5415, 19268, 5417, 19266, 5419, 19264, 5421, 19262, 5423, 19260, 5425, 19258, 5427, 19256, 5429, 19254, 5431, 19252, 5433, 19250, 5435, 19248, 5437, 19246, 5439, 19244, 5441, 19242, 5443, 19240, 5445, 19238, 5447, 19236, 5449, 19234, 5451, 19232, 5453, 19230, 5455, 19228, 5457, 19226, 5459, 19224, 5461, 19222, 5463, 19220, 5465, 19218, 5467, 19216, 5469, 19214, 5471, 19212, 5473, 19210, 5475, 19208, 5477, 19206, 5479, 19204, 5481, 19202, 5483, 19200, 5485, 19198, 5487, 19196, 5489, 19194, 5491, 19192, 5493, 19190, 5495, 19188, 5497, 19186, 5499, 19184, 5501, 19182, 5503, 19180, 5505, 19178, 5507, 19176, 5509, 19174, 5511, 19172, 5513, 19170, 5515, 19168, 5517, 19166, 5519, 19164, 5521, 19162, 5523, 19160, 5525, 19158, 5527, 19156, 5529, 19154, 5531, 19152, 5533, 19150, 5535, 19148, 5537, 19146, 5539, 19144, 5541, 19142, 5543, 19140, 5545, 19138, 5547, 19136, 5549, 19134, 5551, 19132, 5553, 19130, 5555, 19128, 5557, 19126, 5559, 19124, 5561, 19122, 5563, 19120, 5565, 19118, 5567, 19116, 5569, 19114, 5571, 19112, 5573, 19110, 5575, 19108, 5577, 19106, 5579, 19104, 5581, 19102, 5583, 19100, 5585, 19098, 5587, 19096, 5589, 19094, 5591, 19092, 5593, 19090, 5595, 19088, 5597, 19086, 5599, 19084, 5601, 19082, 5603, 19080, 5605, 19078, 5607, 19076, 5609, 19074, 5611, 19072, 5613, 19070, 5615, 19068, 5617, 19066, 5619, 19064, 5621, 19062, 5623, 19060, 5625, 19058, 5627, 19056, 5629, 19054, 5631, 19052, 5633, 19050, 5635, 19048, 5637, 19046, 5639, 19044, 5641, 19042, 5643, 19040, 5645, 19038, 5647, 19036, 5649, 19034, 5651, 19032, 5653, 19030, 5655, 19028, 5657, 19026, 5659, 19024, 5661, 19022, 5663, 19020, 5665, 19018, 5667, 19016, 5669, 19014, 5671, 19012, 5673, 19010, 5675, 19008, 5677, 19006, 5679, 19004, 5681, 19002, 5683, 19000, 5685, 18998, 5687, 18996, 5689, 18994, 5691, 18992, 5693, 18990, 5695, 18988, 5697, 18986, 5699, 18984, 5701, 18982, 5703, 18980, 5705, 18978, 5707, 18976, 5709, 18974, 5711, 18972, 5713, 18970, 5715, 18968, 5717, 18966, 5719, 18964, 5721, 18962, 5723, 18960, 5725, 18958, 5727, 18956, 5729, 18954, 5731, 18952, 5733, 18950, 5735, 18948, 5737, 18946, 5739, 18944, 5741, 18942, 5743, 18940, 5745, 18938, 5747, 18936, 5749, 18934, 5751, 18932, 5753, 18930, 5755, 18928, 5757, 18926, 5759, 18924, 5761, 18922, 5763, 18920, 5765, 18918, 5767, 18916, 5769, 18914, 5771, 18912, 5773, 18910, 5775, 18908, 5777, 18906, 5779, 18904, 5781, 18902, 5783, 18900, 5785, 18898, 5787, 18896, 5789, 18894, 5791, 18892, 5793, 18890, 5795, 18888, 5797, 18886, 5799, 18884, 5801, 18882, 5803, 18880, 5805, 18878, 5807, 18876, 5809, 18874, 5811, 18872, 5813, 18870, 5815, 18868, 5817, 18866, 5819, 18864, 5821, 18862, 5823, 18860, 5825, 18858, 5827, 18856, 5829, 18854, 5831, 18852, 5833, 18850, 5835, 18848, 5837, 18846, 5839, 18844, 5841, 18842, 5843, 18840, 5845, 18838, 5847, 18836, 5849, 18834, 5851, 18832, 5853, 18830, 5855, 18828, 5857, 18826, 5859, 18824, 5861, 18822, 5863, 18820, 5865, 18818, 5867, 18816, 5869, 18814, 5871, 18812, 5873, 18810, 5875, 18808, 5877, 18806, 5879, 18804, 5881, 18802, 5883, 18800, 5885, 18798, 5887, 18796, 5889, 18794, 5891, 18792, 5893, 18790, 5895, 18788, 5897, 18786, 5899, 18784, 5901, 18782, 5903, 18780, 5905, 18778, 5907, 18776, 5909, 18774, 5911, 18772, 5913, 18770, 5915, 18768, 5917, 18766, 5919, 18764, 5921, 18762, 5923, 18760, 5925, 18758, 5927, 18756, 5929, 18754, 5931, 18752, 5933, 18750, 5935, 18748, 5937, 18746, 5939, 18744, 5941, 18742, 5943, 18740, 5945, 18738, 5947, 18736, 5949, 18734, 5951, 18732, 5953, 18730, 5955, 18728, 5957, 18726, 5959, 18724, 5961, 18722, 5963, 18720, 5965, 18718, 5967, 18716, 5969, 18714, 5971, 18712, 5973, 18710, 5975, 18708, 5977, 18706, 5979, 18704, 5981, 18702, 5983, 18700, 5985, 18698, 5987, 18696, 5989, 18694, 5991, 18692, 5993, 18690, 5995, 18688, 5997, 18686, 5999, 18684, 6001, 18682, 6003, 18680, 6005, 18678, 6007, 18676, 6009, 18674, 6011, 18672, 6013, 18670, 6015, 18668, 6017, 18666, 6019, 18664, 6021, 18662, 6023, 18660, 6025, 18658, 6027, 18656, 6029, 18654, 6031, 18652, 6033, 18650, 6035, 18648, 6037, 18646, 6039, 18644, 6041, 18642, 6043, 18640, 6045, 18638, 6047, 18636, 6049, 18634, 6051, 18632, 6053, 18630, 6055, 18628, 6057, 18626, 6059, 18624, 6061, 18622, 6063, 18620, 6065, 18618, 6067, 18616, 6069, 18614, 6071, 18612, 6073, 18610, 6075, 18608, 6077, 18606, 6079, 18604, 6081, 18602, 6083, 18600, 6085, 18598, 6087, 18596, 6089, 18594, 6091, 18592, 6093, 18590, 6095, 18588, 6097, 18586, 6099, 18584, 6101, 18582, 6103, 18580, 6105, 18578, 6107, 18576, 6109, 18574, 6111, 18572, 6113, 18570, 6115, 18568, 6117, 18566, 6119, 18564, 6121, 18562, 6123, 18560, 6125, 18558, 6127, 18556, 6129, 18554, 6131, 18552, 6133, 18550, 6135, 18548, 6137, 18546, 6139, 18544, 6141, 18542, 6143, 18540, 6145, 18538, 6147, 18536, 6149, 18534, 6151, 18532, 6153, 18530, 6155, 18528, 6157, 18526, 6159, 18524, 6161, 18522, 6163, 18520, 6165, 18518, 6167, 18516, 6169, 18514, 6171, 18512, 6173, 18510, 6175, 18508, 6177, 18506, 6179, 18504, 6181, 18502, 6183, 18500, 6185, 18498, 6187, 18496, 6189, 18494, 6191, 18492, 6193, 18490, 6195, 18488, 6197, 18486, 6199, 18484, 6201, 18482, 6203, 18480, 6205, 18478, 6207, 18476, 6209, 18474, 6211, 18472, 6213, 18470, 6215, 18468, 6217, 18466, 6219, 18464, 6221, 18462, 6223, 18460, 6225, 18458, 6227, 18456, 6229, 18454, 6231, 18452, 6233, 18450, 6235, 18448, 6237, 18446, 6239, 18444, 6241, 18442, 6243, 18440, 6245, 18438, 6247, 18436, 6249, 18434, 6251, 18432, 6253, 18430, 6255, 18428, 6257, 18426, 6259, 18424, 6261, 18422, 6263, 18420, 6265, 18418, 6267, 18416, 6269, 18414, 6271, 18412, 6273, 18410, 6275, 18408, 6277, 18406, 6279, 18404, 6281, 18402, 6283, 18400, 6285, 18398, 6287, 18396, 6289, 18394, 6291, 18392, 6293, 18390, 6295, 18388, 6297, 18386, 6299, 18384, 6301, 18382, 6303, 18380, 6305, 18378, 6307, 18376, 6309, 18374, 6311, 18372, 6313, 18370, 6315, 18368, 6317, 18366, 6319, 18364, 6321, 18362, 6323, 18360, 6325, 18358, 6327, 18356, 6329, 18354, 6331, 18352, 6333, 18350, 6335, 18348, 6337, 18346, 6339, 18344, 6341, 18342, 6343, 18340, 6345, 18338, 6347, 18336, 6349, 18334, 6351, 18332, 6353, 18330, 6355, 18328, 6357, 18326, 6359, 18324, 6361, 18322, 6363, 18320, 6365, 18318, 6367, 18316, 6369, 18314, 6371, 18312, 6373, 18310, 6375, 18308, 6377, 18306, 6379, 18304, 6381, 18302, 6383, 18300, 6385, 18298, 6387, 18296, 6389, 18294, 6391, 18292, 6393, 18290, 6395, 18288, 6397, 18286, 6399, 18284, 6401, 18282, 6403, 18280, 6405, 18278, 6407, 18276, 6409, 18274, 6411, 18272, 6413, 18270, 6415, 18268, 6417, 18266, 6419, 18264, 6421, 18262, 6423, 18260, 6425, 18258, 6427, 18256, 6429, 18254, 6431, 18252, 6433, 18250, 6435, 18248, 6437, 18246, 6439, 18244, 6441, 18242, 6443, 18240, 6445, 18238, 6447, 18236, 6449, 18234, 6451, 18232, 6453, 18230, 6455, 18228, 6457, 18226, 6459, 18224, 6461, 18222, 6463, 18220, 6465, 18218, 6467, 18216, 6469, 18214, 6471, 18212, 6473, 18210, 6475, 18208, 6477, 18206, 6479, 18204, 6481, 18202, 6483, 18200, 6485, 18198, 6487, 18196, 6489, 18194, 6491, 18192, 6493, 18190, 6495, 18188, 6497, 18186, 6499, 18184, 6501, 18182, 6503, 18180, 6505, 18178, 6507, 18176, 6509, 18174, 6511, 18172, 6513, 18170, 6515, 18168, 6517, 18166, 6519, 18164, 6521, 18162, 6523, 18160, 6525, 18158, 6527, 18156, 6529, 18154, 6531, 18152, 6533, 18150, 6535, 18148, 6537, 18146, 6539, 18144, 6541, 18142, 6543, 18140, 6545, 18138, 6547, 18136, 6549, 18134, 6551, 18132, 6553, 18130, 6555, 18128, 6557, 18126, 6559, 18124, 6561, 18122, 6563, 18120, 6565, 18118, 6567, 18116, 6569, 18114, 6571, 18112, 6573, 18110, 6575, 18108, 6577, 18106, 6579, 18104, 6581, 18102, 6583, 18100, 6585, 18098, 6587, 18096, 6589, 18094, 6591, 18092, 6593, 18090, 6595, 18088, 6597, 18086, 6599, 18084, 6601, 18082, 6603, 18080, 6605, 18078, 6607, 18076, 6609, 18074, 6611, 18072, 6613, 18070, 6615, 18068, 6617, 18066, 6619, 18064, 6621, 18062, 6623, 18060, 6625, 18058, 6627, 18056, 6629, 18054, 6631, 18052, 6633, 18050, 6635, 18048, 6637, 18046, 6639, 18044, 6641, 18042, 6643, 18040, 6645, 18038, 6647, 18036, 6649, 18034, 6651, 18032, 6653, 18030, 6655, 18028, 6657, 18026, 6659, 18024, 6661, 18022, 6663, 18020, 6665, 18018, 6667, 18016, 6669, 18014, 6671, 18012, 6673, 18010, 6675, 18008, 6677, 18006, 6679, 18004, 6681, 18002, 6683, 18000, 6685, 17998, 6687, 17996, 6689, 17994, 6691, 17992, 6693, 17990, 6695, 17988, 6697, 17986, 6699, 17984, 6701, 17982, 6703, 17980, 6705, 17978, 6707, 17976, 6709, 17974, 6711, 17972, 6713, 17970, 6715, 17968, 6717, 17966, 6719, 17964, 6721, 17962, 6723, 17960, 6725, 17958, 6727, 17956, 6729, 17954, 6731, 17952, 6733, 17950, 6735, 17948, 6737, 17946, 6739, 17944, 6741, 17942, 6743, 17940, 6745, 17938, 6747, 17936, 6749, 17934, 6751, 17932, 6753, 17930, 6755, 17928, 6757, 17926, 6759, 17924, 6761, 17922, 6763, 17920, 6765, 17918, 6767, 17916, 6769, 17914, 6771, 17912, 6773, 17910, 6775, 17908, 6777, 17906, 6779, 17904, 6781, 17902, 6783, 17900, 6785, 17898, 6787, 17896, 6789, 17894, 6791, 17892, 6793, 17890, 6795, 17888, 6797, 17886, 6799, 17884, 6801, 17882, 6803, 17880, 6805, 17878, 6807, 17876, 6809, 17874, 6811, 17872, 6813, 17870, 6815, 17868, 6817, 17866, 6819, 17864, 6821, 17862, 6823, 17860, 6825, 17858, 6827, 17856, 6829, 17854, 6831, 17852, 6833, 17850, 6835, 17848, 6837, 17846, 6839, 17844, 6841, 17842, 6843, 17840, 6845, 17838, 6847, 17836, 6849, 17834, 6851, 17832, 6853, 17830, 6855, 17828, 6857, 17826, 6859, 17824, 6861, 17822, 6863, 17820, 6865, 17818, 6867, 17816, 6869, 17814, 6871, 17812, 6873, 17810, 6875, 17808, 6877, 17806, 6879, 17804, 6881, 17802, 6883, 17800, 6885, 17798, 6887, 17796, 6889, 17794, 6891, 17792, 6893, 17790, 6895, 17788, 6897, 17786, 6899, 17784, 6901, 17782, 6903, 17780, 6905, 17778, 6907, 17776, 6909, 17774, 6911, 17772, 6913, 17770, 6915, 17768, 6917, 17766, 6919, 17764, 6921, 17762, 6923, 17760, 6925, 17758, 6927, 17756, 6929, 17754, 6931, 17752, 6933, 17750, 6935, 17748, 6937, 17746, 6939, 17744, 6941, 17742, 6943, 17740, 6945, 17738, 6947, 17736, 6949, 17734, 6951, 17732, 6953, 17730, 6955, 17728, 6957, 17726, 6959, 17724, 6961, 17722, 6963, 17720, 6965, 17718, 6967, 17716, 6969, 17714, 6971, 17712, 6973, 17710, 6975, 17708, 6977, 17706, 6979, 17704, 6981, 17702, 6983, 17700, 6985, 17698, 6987, 17696, 6989, 17694, 6991, 17692, 6993, 17690, 6995, 17688, 6997, 17686, 6999, 17684, 7001, 17682, 7003, 17680, 7005, 17678, 7007, 17676, 7009, 17674, 7011, 17672, 7013, 17670, 7015, 17668, 7017, 17666, 7019, 17664, 7021, 17662, 7023, 17660, 7025, 17658, 7027, 17656, 7029, 17654, 7031, 17652, 7033, 17650, 7035, 17648, 7037, 17646, 7039, 17644, 7041, 17642, 7043, 17640, 7045, 17638, 7047, 17636, 7049, 17634, 7051, 17632, 7053, 17630, 7055, 17628, 7057, 17626, 7059, 17624, 7061, 17622, 7063, 17620, 7065, 17618, 7067, 17616, 7069, 17614, 7071, 17612, 7073, 17610, 7075, 17608, 7077, 17606, 7079, 17604, 7081, 17602, 7083, 17600, 7085, 17598, 7087, 17596, 7089, 17594, 7091, 17592, 7093, 17590, 7095, 17588, 7097, 17586, 7099, 17584, 7101, 17582, 7103, 17580, 7105, 17578, 7107, 17576, 7109, 17574, 7111, 17572, 7113, 17570, 7115, 17568, 7117, 17566, 7119, 17564, 7121, 17562, 7123, 17560, 7125, 17558, 7127, 17556, 7129, 17554, 7131, 17552, 7133, 17550, 7135, 17548, 7137, 17546, 7139, 17544, 7141, 17542, 7143, 17540, 7145, 17538, 7147, 17536, 7149, 17534, 7151, 17532, 7153, 17530, 7155, 17528, 7157, 17526, 7159, 17524, 7161, 17522, 7163, 17520, 7165, 17518, 7167, 17516, 7169, 17514, 7171, 17512, 7173, 17510, 7175, 17508, 7177, 17506, 7179, 17504, 7181, 17502, 7183, 17500, 7185, 17498, 7187, 17496, 7189, 17494, 7191, 17492, 7193, 17490, 7195, 17488, 7197, 17486, 7199, 17484, 7201, 17482, 7203, 17480, 7205, 17478, 7207, 17476, 7209, 17474, 7211, 17472, 7213, 17470, 7215, 17468, 7217, 17466, 7219, 17464, 7221, 17462, 7223, 17460, 7225, 17458, 7227, 17456, 7229, 17454, 7231, 17452, 7233, 17450, 7235, 17448, 7237, 17446, 7239, 17444, 7241, 17442, 7243, 17440, 7245, 17438, 7247, 17436, 7249, 17434, 7251, 17432, 7253, 17430, 7255, 17428, 7257, 17426, 7259, 17424, 7261, 17422, 7263, 17420, 7265, 17418, 7267, 17416, 7269, 17414, 7271, 17412, 7273, 17410, 7275, 17408, 7277, 17406, 7279, 17404, 7281, 17402, 7283, 17400, 7285, 17398, 7287, 17396, 7289, 17394, 7291, 17392, 7293, 17390, 7295, 17388, 7297, 17386, 7299, 17384, 7301, 17382, 7303, 17380, 7305, 17378, 7307, 17376, 7309, 17374, 7311, 17372, 7313, 17370, 7315, 17368, 7317, 17366, 7319, 17364, 7321, 17362, 7323, 17360, 7325, 17358, 7327, 17356, 7329, 17354, 7331, 17352, 7333, 17350, 7335, 17348, 7337, 17346, 7339, 17344, 7341, 17342, 7343, 17340, 7345, 17338, 7347, 17336, 7349, 17334, 7351, 17332, 7353, 17330, 7355, 17328, 7357, 17326, 7359, 17324, 7361, 17322, 7363, 17320, 7365, 17318, 7367, 17316, 7369, 17314, 7371, 17312, 7373, 17310, 7375, 17308, 7377, 17306, 7379, 17304, 7381, 17302, 7383, 17300, 7385, 17298, 7387, 17296, 7389, 17294, 7391, 17292, 7393, 17290, 7395, 17288, 7397, 17286, 7399, 17284, 7401, 17282, 7403, 17280, 7405, 17278, 7407, 17276, 7409, 17274, 7411, 17272, 7413, 17270, 7415, 17268, 7417, 17266, 7419, 17264, 7421, 17262, 7423, 17260, 7425, 17258, 7427, 17256, 7429, 17254, 7431, 17252, 7433, 17250, 7435, 17248, 7437, 17246, 7439, 17244, 7441, 17242, 7443, 17240, 7445, 17238, 7447, 17236, 7449, 17234, 7451, 17232, 7453, 17230, 7455, 17228, 7457, 17226, 7459, 17224, 7461, 17222, 7463, 17220, 7465, 17218, 7467, 17216, 7469, 17214, 7471, 17212, 7473, 17210, 7475, 17208, 7477, 17206, 7479, 17204, 7481, 17202, 7483, 17200, 7485, 17198, 7487, 17196, 7489, 17194, 7491, 17192, 7493, 17190, 7495, 17188, 7497, 17186, 7499, 17184, 7501, 17182, 7503, 17180, 7505, 17178, 7507, 17176, 7509, 17174, 7511, 17172, 7513, 17170, 7515, 17168, 7517, 17166, 7519, 17164, 7521, 17162, 7523, 17160, 7525, 17158, 7527, 17156, 7529, 17154, 7531, 17152, 7533, 17150, 7535, 17148, 7537, 17146, 7539, 17144, 7541, 17142, 7543, 17140, 7545, 17138, 7547, 17136, 7549, 17134, 7551, 17132, 7553, 17130, 7555, 17128, 7557, 17126, 7559, 17124, 7561, 17122, 7563, 17120, 7565, 17118, 7567, 17116, 7569, 17114, 7571, 17112, 7573, 17110, 7575, 17108, 7577, 17106, 7579, 17104, 7581, 17102, 7583, 17100, 7585, 17098, 7587, 17096, 7589, 17094, 7591, 17092, 7593, 17090, 7595, 17088, 7597, 17086, 7599, 17084, 7601, 17082, 7603, 17080, 7605, 17078, 7607, 17076, 7609, 17074, 7611, 17072, 7613, 17070, 7615, 17068, 7617, 17066, 7619, 17064, 7621, 17062, 7623, 17060, 7625, 17058, 7627, 17056, 7629, 17054, 7631, 17052, 7633, 17050, 7635, 17048, 7637, 17046, 7639, 17044, 7641, 17042, 7643, 17040, 7645, 17038, 7647, 17036, 7649, 17034, 7651, 17032, 7653, 17030, 7655, 17028, 7657, 17026, 7659, 17024, 7661, 17022, 7663, 17020, 7665, 17018, 7667, 17016, 7669, 17014, 7671, 17012, 7673, 17010, 7675, 17008, 7677, 17006, 7679, 17004, 7681, 17002, 7683, 17000, 7685, 16998, 7687, 16996, 7689, 16994, 7691, 16992, 7693, 16990, 7695, 16988, 7697, 16986, 7699, 16984, 7701, 16982, 7703, 16980, 7705, 16978, 7707, 16976, 7709, 16974, 7711, 16972, 7713, 16970, 7715, 16968, 7717, 16966, 7719, 16964, 7721, 16962, 7723, 16960, 7725, 16958, 7727, 16956, 7729, 16954, 7731, 16952, 7733, 16950, 7735, 16948, 7737, 16946, 7739, 16944, 7741, 16942, 7743, 16940, 7745, 16938, 7747, 16936, 7749, 16934, 7751, 16932, 7753, 16930, 7755, 16928, 7757, 16926, 7759, 16924, 7761, 16922, 7763, 16920, 7765, 16918, 7767, 16916, 7769, 16914, 7771, 16912, 7773, 16910, 7775, 16908, 7777, 16906, 7779, 16904, 7781, 16902, 7783, 16900, 7785, 16898, 7787, 16896, 7789, 16894, 7791, 16892, 7793, 16890, 7795, 16888, 7797, 16886, 7799, 16884, 7801, 16882, 7803, 16880, 7805, 16878, 7807, 16876, 7809, 16874, 7811, 16872, 7813, 16870, 7815, 16868, 7817, 16866, 7819, 16864, 7821, 16862, 7823, 16860, 7825, 16858, 7827, 16856, 7829, 16854, 7831, 16852, 7833, 16850, 7835, 16848, 7837, 16846, 7839, 16844, 7841, 16842, 7843, 16840, 7845, 16838, 7847, 16836, 7849, 16834, 7851, 16832, 7853, 16830, 7855, 16828, 7857, 16826, 7859, 16824, 7861, 16822, 7863, 16820, 7865, 16818, 7867, 16816, 7869, 16814, 7871, 16812, 7873, 16810, 7875, 16808, 7877, 16806, 7879, 16804, 7881, 16802, 7883, 16800, 7885, 16798, 7887, 16796, 7889, 16794, 7891, 16792, 7893, 16790, 7895, 16788, 7897, 16786, 7899, 16784, 7901, 16782, 7903, 16780, 7905, 16778, 7907, 16776, 7909, 16774, 7911, 16772, 7913, 16770, 7915, 16768, 7917, 16766, 7919, 16764, 7921, 16762, 7923, 16760, 7925, 16758, 7927, 16756, 7929, 16754, 7931, 16752, 7933, 16750, 7935, 16748, 7937, 16746, 7939, 16744, 7941, 16742, 7943, 16740, 7945, 16738, 7947, 16736, 7949, 16734, 7951, 16732, 7953, 16730, 7955, 16728, 7957, 16726, 7959, 16724, 7961, 16722, 7963, 16720, 7965, 16718, 7967, 16716, 7969, 16714, 7971, 16712, 7973, 16710, 7975, 16708, 7977, 16706, 7979, 16704, 7981, 16702, 7983, 16700, 7985, 16698, 7987, 16696, 7989, 16694, 7991, 16692, 7993, 16690, 7995, 16688, 7997, 16686, 7999, 16684, 8001, 16682, 8003, 16680, 8005, 16678, 8007, 16676, 8009, 16674, 8011, 16672, 8013, 16670, 8015, 16668, 8017, 16666, 8019, 16664, 8021, 16662, 8023, 16660, 8025, 16658, 8027, 16656, 8029, 16654, 8031, 16652, 8033, 16650, 8035, 16648, 8037, 16646, 8039, 16644, 8041, 16642, 8043, 16640, 8045, 16638, 8047, 16636, 8049, 16634, 8051, 16632, 8053, 16630, 8055, 16628, 8057, 16626, 8059, 16624, 8061, 16622, 8063, 16620, 8065, 16618, 8067, 16616, 8069, 16614, 8071, 16612, 8073, 16610, 8075, 16608, 8077, 16606, 8079, 16604, 8081, 16602, 8083, 16600, 8085, 16598, 8087, 16596, 8089, 16594, 8091, 16592, 8093, 16590, 8095, 16588, 8097, 16586, 8099, 16584, 8101, 16582, 8103, 16580, 8105, 16578, 8107, 16576, 8109, 16574, 8111, 16572, 8113, 16570, 8115, 16568, 8117, 16566, 8119, 16564, 8121, 16562, 8123, 16560, 8125, 16558, 8127, 16556, 8129, 16554, 8131, 16552, 8133, 16550, 8135, 16548, 8137, 16546, 8139, 16544, 8141, 16542, 8143, 16540, 8145, 16538, 8147, 16536, 8149, 16534, 8151, 16532, 8153, 16530, 8155, 16528, 8157, 16526, 8159, 16524, 8161, 16522, 8163, 16520, 8165, 16518, 8167, 16516, 8169, 16514, 8171, 16512, 8173, 16510, 8175, 16508, 8177, 16506, 8179, 16504, 8181, 16502, 8183, 16500, 8185, 16498, 8187, 16496, 8189, 16494, 8191, 16492, 8193, 16490, 8195, 16488, 8197, 16486, 8199, 16484, 8201, 16482, 8203, 16480, 8205, 16478, 8207, 16476, 8209, 16474, 8211, 16472, 8213, 16470, 8215, 16468, 8217, 16466, 8219, 16464, 8221, 16462, 8223, 16460, 8225, 16458, 8227, 16456, 8229, 16454, 8231, 16452, 8233, 16450, 8235, 16448, 8237, 16446, 8239, 16444, 8241, 16442, 8243, 16440, 8245, 16438, 8247, 16436, 8249, 16434, 8251, 16432, 8253, 16430, 8255, 16428, 8257, 16426, 8259, 16424, 8261, 16422, 8263, 16420, 8265, 16418, 8267, 16416, 8269, 16414, 8271, 16412, 8273, 16410, 8275, 16408, 8277, 16406, 8279, 16404, 8281, 16402, 8283, 16400, 8285, 16398, 8287, 16396, 8289, 16394, 8291, 16392, 8293, 16390, 8295, 16388, 8297, 16386, 8299, 16384, 8301, 16382, 8303, 16380, 8305, 16378, 8307, 16376, 8309, 16374, 8311, 16372, 8313, 16370, 8315, 16368, 8317, 16366, 8319, 16364, 8321, 16362, 8323, 16360, 8325, 16358, 8327, 16356, 8329, 16354, 8331, 16352, 8333, 16350, 8335, 16348, 8337, 16346, 8339, 16344, 8341, 16342, 8343, 16340, 8345, 16338, 8347, 16336, 8349, 16334, 8351, 16332, 8353, 16330, 8355, 16328, 8357, 16326, 8359, 16324, 8361, 16322, 8363, 16320, 8365, 16318, 8367, 16316, 8369, 16314, 8371, 16312, 8373, 16310, 8375, 16308, 8377, 16306, 8379, 16304, 8381, 16302, 8383, 16300, 8385, 16298, 8387, 16296, 8389, 16294, 8391, 16292, 8393, 16290, 8395, 16288, 8397, 16286, 8399, 16284, 8401, 16282, 8403, 16280, 8405, 16278, 8407, 16276, 8409, 16274, 8411, 16272, 8413, 16270, 8415, 16268, 8417, 16266, 8419, 16264, 8421, 16262, 8423, 16260, 8425, 16258, 8427, 16256, 8429, 16254, 8431, 16252, 8433, 16250, 8435, 16248, 8437, 16246, 8439, 16244, 8441, 16242, 8443, 16240, 8445, 16238, 8447, 16236, 8449, 16234, 8451, 16232, 8453, 16230, 8455, 16228, 8457, 16226, 8459, 16224, 8461, 16222, 8463, 16220, 8465, 16218, 8467, 16216, 8469, 16214, 8471, 16212, 8473, 16210, 8475, 16208, 8477, 16206, 8479, 16204, 8481, 16202, 8483, 16200, 8485, 16198, 8487, 16196, 8489, 16194, 8491, 16192, 8493, 16190, 8495, 16188, 8497, 16186, 8499, 16184, 8501, 16182, 8503, 16180, 8505, 16178, 8507, 16176, 8509, 16174, 8511, 16172, 8513, 16170, 8515, 16168, 8517, 16166, 8519, 16164, 8521, 16162, 8523, 16160, 8525, 16158, 8527, 16156, 8529, 16154, 8531, 16152, 8533, 16150, 8535, 16148, 8537, 16146, 8539, 16144, 8541, 16142, 8543, 16140, 8545, 16138, 8547, 16136, 8549, 16134, 8551, 16132, 8553, 16130, 8555, 16128, 8557, 16126, 8559, 16124, 8561, 16122, 8563, 16120, 8565, 16118, 8567, 16116, 8569, 16114, 8571, 16112, 8573, 16110, 8575, 16108, 8577, 16106, 8579, 16104, 8581, 16102, 8583, 16100, 8585, 16098, 8587, 16096, 8589, 16094, 8591, 16092, 8593, 16090, 8595, 16088, 8597, 16086, 8599, 16084, 8601, 16082, 8603, 16080, 8605, 16078, 8607, 16076, 8609, 16074, 8611, 16072, 8613, 16070, 8615, 16068, 8617, 16066, 8619, 16064, 8621, 16062, 8623, 16060, 8625, 16058, 8627, 16056, 8629, 16054, 8631, 16052, 8633, 16050, 8635, 16048, 8637, 16046, 8639, 16044, 8641, 16042, 8643, 16040, 8645, 16038, 8647, 16036, 8649, 16034, 8651, 16032, 8653, 16030, 8655, 16028, 8657, 16026, 8659, 16024, 8661, 16022, 8663, 16020, 8665, 16018, 8667, 16016, 8669, 16014, 8671, 16012, 8673, 16010, 8675, 16008, 8677, 16006, 8679, 16004, 8681, 16002, 8683, 16000, 8685, 15998, 8687, 15996, 8689, 15994, 8691, 15992, 8693, 15990, 8695, 15988, 8697, 15986, 8699, 15984, 8701, 15982, 8703, 15980, 8705, 15978, 8707, 15976, 8709, 15974, 8711, 15972, 8713, 15970, 8715, 15968, 8717, 15966, 8719, 15964, 8721, 15962, 8723, 15960, 8725, 15958, 8727, 15956, 8729, 15954, 8731, 15952, 8733, 15950, 8735, 15948, 8737, 15946, 8739, 15944, 8741, 15942, 8743, 15940, 8745, 15938, 8747, 15936, 8749, 15934, 8751, 15932, 8753, 15930, 8755, 15928, 8757, 15926, 8759, 15924, 8761, 15922, 8763, 15920, 8765, 15918, 8767, 15916, 8769, 15914, 8771, 15912, 8773, 15910, 8775, 15908, 8777, 15906, 8779, 15904, 8781, 15902, 8783, 15900, 8785, 15898, 8787, 15896, 8789, 15894, 8791, 15892, 8793, 15890, 8795, 15888, 8797, 15886, 8799, 15884, 8801, 15882, 8803, 15880, 8805, 15878, 8807, 15876, 8809, 15874, 8811, 15872, 8813, 15870, 8815, 15868, 8817, 15866, 8819, 15864, 8821, 15862, 8823, 15860, 8825, 15858, 8827, 15856, 8829, 15854, 8831, 15852, 8833, 15850, 8835, 15848, 8837, 15846, 8839, 15844, 8841, 15842, 8843, 15840, 8845, 15838, 8847, 15836, 8849, 15834, 8851, 15832, 8853, 15830, 8855, 15828, 8857, 15826, 8859, 15824, 8861, 15822, 8863, 15820, 8865, 15818, 8867, 15816, 8869, 15814, 8871, 15812, 8873, 15810, 8875, 15808, 8877, 15806, 8879, 15804, 8881, 15802, 8883, 15800, 8885, 15798, 8887, 15796, 8889, 15794, 8891, 15792, 8893, 15790, 8895, 15788, 8897, 15786, 8899, 15784, 8901, 15782, 8903, 15780, 8905, 15778, 8907, 15776, 8909, 15774, 8911, 15772, 8913, 15770, 8915, 15768, 8917, 15766, 8919, 15764, 8921, 15762, 8923, 15760, 8925, 15758, 8927, 15756, 8929, 15754, 8931, 15752, 8933, 15750, 8935, 15748, 8937, 15746, 8939, 15744, 8941, 15742, 8943, 15740, 8945, 15738, 8947, 15736, 8949, 15734, 8951, 15732, 8953, 15730, 8955, 15728, 8957, 15726, 8959, 15724, 8961, 15722, 8963, 15720, 8965, 15718, 8967, 15716, 8969, 15714, 8971, 15712, 8973, 15710, 8975, 15708, 8977, 15706, 8979, 15704, 8981, 15702, 8983, 15700, 8985, 15698, 8987, 15696, 8989, 15694, 8991, 15692, 8993, 15690, 8995, 15688, 8997, 15686, 8999, 15684, 9001, 15682, 9003, 15680, 9005, 15678, 9007, 15676, 9009, 15674, 9011, 15672, 9013, 15670, 9015, 15668, 9017, 15666, 9019, 15664, 9021, 15662, 9023, 15660, 9025, 15658, 9027, 15656, 9029, 15654, 9031, 15652, 9033, 15650, 9035, 15648, 9037, 15646, 9039, 15644, 9041, 15642, 9043, 15640, 9045, 15638, 9047, 15636, 9049, 15634, 9051, 15632, 9053, 15630, 9055, 15628, 9057, 15626, 9059, 15624, 9061, 15622, 9063, 15620, 9065, 15618, 9067, 15616, 9069, 15614, 9071, 15612, 9073, 15610, 9075, 15608, 9077, 15606, 9079, 15604, 9081, 15602, 9083, 15600, 9085, 15598, 9087, 15596, 9089, 15594, 9091, 15592, 9093, 15590, 9095, 15588, 9097, 15586, 9099, 15584, 9101, 15582, 9103, 15580, 9105, 15578, 9107, 15576, 9109, 15574, 9111, 15572, 9113, 15570, 9115, 15568, 9117, 15566, 9119, 15564, 9121, 15562, 9123, 15560, 9125, 15558, 9127, 15556, 9129, 15554, 9131, 15552, 9133, 15550, 9135, 15548, 9137, 15546, 9139, 15544, 9141, 15542, 9143, 15540, 9145, 15538, 9147, 15536, 9149, 15534, 9151, 15532, 9153, 15530, 9155, 15528, 9157, 15526, 9159, 15524, 9161, 15522, 9163, 15520, 9165, 15518, 9167, 15516, 9169, 15514, 9171, 15512, 9173, 15510, 9175, 15508, 9177, 15506, 9179, 15504, 9181, 15502, 9183, 15500, 9185, 15498, 9187, 15496, 9189, 15494, 9191, 15492, 9193, 15490, 9195, 15488, 9197, 15486, 9199, 15484, 9201, 15482, 9203, 15480, 9205, 15478, 9207, 15476, 9209, 15474, 9211, 15472, 9213, 15470, 9215, 15468, 9217, 15466, 9219, 15464, 9221, 15462, 9223, 15460, 9225, 15458, 9227, 15456, 9229, 15454, 9231, 15452, 9233, 15450, 9235, 15448, 9237, 15446, 9239, 15444, 9241, 15442, 9243, 15440, 9245, 15438, 9247, 15436, 9249, 15434, 9251, 15432, 9253, 15430, 9255, 15428, 9257, 15426, 9259, 15424, 9261, 15422, 9263, 15420, 9265, 15418, 9267, 15416, 9269, 15414, 9271, 15412, 9273, 15410, 9275, 15408, 9277, 15406, 9279, 15404, 9281, 15402, 9283, 15400, 9285, 15398, 9287, 15396, 9289, 15394, 9291, 15392, 9293, 15390, 9295, 15388, 9297, 15386, 9299, 15384, 9301, 15382, 9303, 15380, 9305, 15378, 9307, 15376, 9309, 15374, 9311, 15372, 9313, 15370, 9315, 15368, 9317, 15366, 9319, 15364, 9321, 15362, 9323, 15360, 9325, 15358, 9327, 15356, 9329, 15354, 9331, 15352, 9333, 15350, 9335, 15348, 9337, 15346, 9339, 15344, 9341, 15342, 9343, 15340, 9345, 15338, 9347, 15336, 9349, 15334, 9351, 15332, 9353, 15330, 9355, 15328, 9357, 15326, 9359, 15324, 9361, 15322, 9363, 15320, 9365, 15318, 9367, 15316, 9369, 15314, 9371, 15312, 9373, 15310, 9375, 15308, 9377, 15306, 9379, 15304, 9381, 15302, 9383, 15300, 9385, 15298, 9387, 15296, 9389, 15294, 9391, 15292, 9393, 15290, 9395, 15288, 9397, 15286, 9399, 15284, 9401, 15282, 9403, 15280, 9405, 15278, 9407, 15276, 9409, 15274, 9411, 15272, 9413, 15270, 9415, 15268, 9417, 15266, 9419, 15264, 9421, 15262, 9423, 15260, 9425, 15258, 9427, 15256, 9429, 15254, 9431, 15252, 9433, 15250, 9435, 15248, 9437, 15246, 9439, 15244, 9441, 15242, 9443, 15240, 9445, 15238, 9447, 15236, 9449, 15234, 9451, 15232, 9453, 15230, 9455, 15228, 9457, 15226, 9459, 15224, 9461, 15222, 9463, 15220, 9465, 15218, 9467, 15216, 9469, 15214, 9471, 15212, 9473, 15210, 9475, 15208, 9477, 15206, 9479, 15204, 9481, 15202, 9483, 15200, 9485, 15198, 9487, 15196, 9489, 15194, 9491, 15192, 9493, 15190, 9495, 15188, 9497, 15186, 9499, 15184, 9501, 15182, 9503, 15180, 9505, 15178, 9507, 15176, 9509, 15174, 9511, 15172, 9513, 15170, 9515, 15168, 9517, 15166, 9519, 15164, 9521, 15162, 9523, 15160, 9525, 15158, 9527, 15156, 9529, 15154, 9531, 15152, 9533, 15150, 9535, 15148, 9537, 15146, 9539, 15144, 9541, 15142, 9543, 15140, 9545, 15138, 9547, 15136, 9549, 15134, 9551, 15132, 9553, 15130, 9555, 15128, 9557, 15126, 9559, 15124, 9561, 15122, 9563, 15120, 9565, 15118, 9567, 15116, 9569, 15114, 9571, 15112, 9573, 15110, 9575, 15108, 9577, 15106, 9579, 15104, 9581, 15102, 9583, 15100, 9585, 15098, 9587, 15096, 9589, 15094, 9591, 15092, 9593, 15090, 9595, 15088, 9597, 15086, 9599, 15084, 9601, 15082, 9603, 15080, 9605, 15078, 9607, 15076, 9609, 15074, 9611, 15072, 9613, 15070, 9615, 15068, 9617, 15066, 9619, 15064, 9621, 15062, 9623, 15060, 9625, 15058, 9627, 15056, 9629, 15054, 9631, 15052, 9633, 15050, 9635, 15048, 9637, 15046, 9639, 15044, 9641, 15042, 9643, 15040, 9645, 15038, 9647, 15036, 9649, 15034, 9651, 15032, 9653, 15030, 9655, 15028, 9657, 15026, 9659, 15024, 9661, 15022, 9663, 15020, 9665, 15018, 9667, 15016, 9669, 15014, 9671, 15012, 9673, 15010, 9675, 15008, 9677, 15006, 9679, 15004, 9681, 15002, 9683, 15000, 9685, 14998, 9687, 14996, 9689, 14994, 9691, 14992, 9693, 14990, 9695, 14988, 9697, 14986, 9699, 14984, 9701, 14982, 9703, 14980, 9705, 14978, 9707, 14976, 9709, 14974, 9711, 14972, 9713, 14970, 9715, 14968, 9717, 14966, 9719, 14964, 9721, 14962, 9723, 14960, 9725, 14958, 9727, 14956, 9729, 14954, 9731, 14952, 9733, 14950, 9735, 14948, 9737, 14946, 9739, 14944, 9741, 14942, 9743, 14940, 9745, 14938, 9747, 14936, 9749, 14934, 9751, 14932, 9753, 14930, 9755, 14928, 9757, 14926, 9759, 14924, 9761, 14922, 9763, 14920, 9765, 14918, 9767, 14916, 9769, 14914, 9771, 14912, 9773, 14910, 9775, 14908, 9777, 14906, 9779, 14904, 9781, 14902, 9783, 14900, 9785, 14898, 9787, 14896, 9789, 14894, 9791, 14892, 9793, 14890, 9795, 14888, 9797, 14886, 9799, 14884, 9801, 14882, 9803, 14880, 9805, 14878, 9807, 14876, 9809, 14874, 9811, 14872, 9813, 14870, 9815, 14868, 9817, 14866, 9819, 14864, 9821, 14862, 9823, 14860, 9825, 14858, 9827, 14856, 9829, 14854, 9831, 14852, 9833, 14850, 9835, 14848, 9837, 14846, 9839, 14844, 9841, 14842, 9843, 14840, 9845, 14838, 9847, 14836, 9849, 14834, 9851, 14832, 9853, 14830, 9855, 14828, 9857, 14826, 9859, 14824, 9861, 14822, 9863, 14820, 9865, 14818, 9867, 14816, 9869, 14814, 9871, 14812, 9873, 14810, 9875, 14808, 9877, 14806, 9879, 14804, 9881, 14802, 9883, 14800, 9885, 14798, 9887, 14796, 9889, 14794, 9891, 14792, 9893, 14790, 9895, 14788, 9897, 14786, 9899, 14784, 9901, 14782, 9903, 14780, 9905, 14778, 9907, 14776, 9909, 14774, 9911, 14772, 9913, 14770, 9915, 14768, 9917, 14766, 9919, 14764, 9921, 14762, 9923, 14760, 9925, 14758, 9927, 14756, 9929, 14754, 9931, 14752, 9933, 14750, 9935, 14748, 9937, 14746, 9939, 14744, 9941, 14742, 9943, 14740, 9945, 14738, 9947, 14736, 9949, 14734, 9951, 14732, 9953, 14730, 9955, 14728, 9957, 14726, 9959, 14724, 9961, 14722, 9963, 14720, 9965, 14718, 9967, 14716, 9969, 14714, 9971, 14712, 9973, 14710, 9975, 14708, 9977, 14706, 9979, 14704, 9981, 14702, 9983, 14700, 9985, 14698, 9987, 14696, 9989, 14694, 9991, 14692, 9993, 14690, 9995, 14688, 9997, 14686, 9999, 14684, 10001, 14682, 10003, 14680, 10005, 14678, 10007, 14676, 10009, 14674, 10011, 14672, 10013, 14670, 10015, 14668, 10017, 14666, 10019, 14664, 10021, 14662, 10023, 14660, 10025, 14658, 10027, 14656, 10029, 14654, 10031, 14652, 10033, 14650, 10035, 14648, 10037, 14646, 10039, 14644, 10041, 14642, 10043, 14640, 10045, 14638, 10047, 14636, 10049, 14634, 10051, 14632, 10053, 14630, 10055, 14628, 10057, 14626, 10059, 14624, 10061, 14622, 10063, 14620, 10065, 14618, 10067, 14616, 10069, 14614, 10071, 14612, 10073, 14610, 10075, 14608, 10077, 14606, 10079, 14604, 10081, 14602, 10083, 14600, 10085, 14598, 10087, 14596, 10089, 14594, 10091, 14592, 10093, 14590, 10095, 14588, 10097, 14586, 10099, 14584, 10101, 14582, 10103, 14580, 10105, 14578, 10107, 14576, 10109, 14574, 10111, 14572, 10113, 14570, 10115, 14568, 10117, 14566, 10119, 14564, 10121, 14562, 10123, 14560, 10125, 14558, 10127, 14556, 10129, 14554, 10131, 14552, 10133, 14550, 10135, 14548, 10137, 14546, 10139, 14544, 10141, 14542, 10143, 14540, 10145, 14538, 10147, 14536, 10149, 14534, 10151, 14532, 10153, 14530, 10155, 14528, 10157, 14526, 10159, 14524, 10161, 14522, 10163, 14520, 10165, 14518, 10167, 14516, 10169, 14514, 10171, 14512, 10173, 14510, 10175, 14508, 10177, 14506, 10179, 14504, 10181, 14502, 10183, 14500, 10185, 14498, 10187, 14496, 10189, 14494, 10191, 14492, 10193, 14490, 10195, 14488, 10197, 14486, 10199, 14484, 10201, 14482, 10203, 14480, 10205, 14478, 10207, 14476, 10209, 14474, 10211, 14472, 10213, 14470, 10215, 14468, 10217, 14466, 10219, 14464, 10221, 14462, 10223, 14460, 10225, 14458, 10227, 14456, 10229, 14454, 10231, 14452, 10233, 14450, 10235, 14448, 10237, 14446, 10239, 14444, 10241, 14442, 10243, 14440, 10245, 14438, 10247, 14436, 10249, 14434, 10251, 14432, 10253, 14430, 10255, 14428, 10257, 14426, 10259, 14424, 10261, 14422, 10263, 14420, 10265, 14418, 10267, 14416, 10269, 14414, 10271, 14412, 10273, 14410, 10275, 14408, 10277, 14406, 10279, 14404, 10281, 14402, 10283, 14400, 10285, 14398, 10287, 14396, 10289, 14394, 10291, 14392, 10293, 14390, 10295, 14388, 10297, 14386, 10299, 14384, 10301, 14382, 10303, 14380, 10305, 14378, 10307, 14376, 10309, 14374, 10311, 14372, 10313, 14370, 10315, 14368, 10317, 14366, 10319, 14364, 10321, 14362, 10323, 14360, 10325, 14358, 10327, 14356, 10329, 14354, 10331, 14352, 10333, 14350, 10335, 14348, 10337, 14346, 10339, 14344, 10341, 14342, 10343, 14340, 10345, 14338, 10347, 14336, 10349, 14334, 10351, 14332, 10353, 14330, 10355, 14328, 10357, 14326, 10359, 14324, 10361, 14322, 10363, 14320, 10365, 14318, 10367, 14316, 10369, 14314, 10371, 14312, 10373, 14310, 10375, 14308, 10377, 14306, 10379, 14304, 10381, 14302, 10383, 14300, 10385, 14298, 10387, 14296, 10389, 14294, 10391, 14292, 10393, 14290, 10395, 14288, 10397, 14286, 10399, 14284, 10401, 14282, 10403, 14280, 10405, 14278, 10407, 14276, 10409, 14274, 10411, 14272, 10413, 14270, 10415, 14268, 10417, 14266, 10419, 14264, 10421, 14262, 10423, 14260, 10425, 14258, 10427, 14256, 10429, 14254, 10431, 14252, 10433, 14250, 10435, 14248, 10437, 14246, 10439, 14244, 10441, 14242, 10443, 14240, 10445, 14238, 10447, 14236, 10449, 14234, 10451, 14232, 10453, 14230, 10455, 14228, 10457, 14226, 10459, 14224, 10461, 14222, 10463, 14220, 10465, 14218, 10467, 14216, 10469, 14214, 10471, 14212, 10473, 14210, 10475, 14208, 10477, 14206, 10479, 14204, 10481, 14202, 10483, 14200, 10485, 14198, 10487, 14196, 10489, 14194, 10491, 14192, 10493, 14190, 10495, 14188, 10497, 14186, 10499, 14184, 10501, 14182, 10503, 14180, 10505, 14178, 10507, 14176, 10509, 14174, 10511, 14172, 10513, 14170, 10515, 14168, 10517, 14166, 10519, 14164, 10521, 14162, 10523, 14160, 10525, 14158, 10527, 14156, 10529, 14154, 10531, 14152, 10533, 14150, 10535, 14148, 10537, 14146, 10539, 14144, 10541, 14142, 10543, 14140, 10545, 14138, 10547, 14136, 10549, 14134, 10551, 14132, 10553, 14130, 10555, 14128, 10557, 14126, 10559, 14124, 10561, 14122, 10563, 14120, 10565, 14118, 10567, 14116, 10569, 14114, 10571, 14112, 10573, 14110, 10575, 14108, 10577, 14106, 10579, 14104, 10581, 14102, 10583, 14100, 10585, 14098, 10587, 14096, 10589, 14094, 10591, 14092, 10593, 14090, 10595, 14088, 10597, 14086, 10599, 14084, 10601, 14082, 10603, 14080, 10605, 14078, 10607, 14076, 10609, 14074, 10611, 14072, 10613, 14070, 10615, 14068, 10617, 14066, 10619, 14064, 10621, 14062, 10623, 14060, 10625, 14058, 10627, 14056, 10629, 14054, 10631, 14052, 10633, 14050, 10635, 14048, 10637, 14046, 10639, 14044, 10641, 14042, 10643, 14040, 10645, 14038, 10647, 14036, 10649, 14034, 10651, 14032, 10653, 14030, 10655, 14028, 10657, 14026, 10659, 14024, 10661, 14022, 10663, 14020, 10665, 14018, 10667, 14016, 10669, 14014, 10671, 14012, 10673, 14010, 10675, 14008, 10677, 14006, 10679, 14004, 10681, 14002, 10683, 14000, 10685, 13998, 10687, 13996, 10689, 13994, 10691, 13992, 10693, 13990, 10695, 13988, 10697, 13986, 10699, 13984, 10701, 13982, 10703, 13980, 10705, 13978, 10707, 13976, 10709, 13974, 10711, 13972, 10713, 13970, 10715, 13968, 10717, 13966, 10719, 13964, 10721, 13962, 10723, 13960, 10725, 13958, 10727, 13956, 10729, 13954, 10731, 13952, 10733, 13950, 10735, 13948, 10737, 13946, 10739, 13944, 10741, 13942, 10743, 13940, 10745, 13938, 10747, 13936, 10749, 13934, 10751, 13932, 10753, 13930, 10755, 13928, 10757, 13926, 10759, 13924, 10761, 13922, 10763, 13920, 10765, 13918, 10767, 13916, 10769, 13914, 10771, 13912, 10773, 13910, 10775, 13908, 10777, 13906, 10779, 13904, 10781, 13902, 10783, 13900, 10785, 13898, 10787, 13896, 10789, 13894, 10791, 13892, 10793, 13890, 10795, 13888, 10797, 13886, 10799, 13884, 10801, 13882, 10803, 13880, 10805, 13878, 10807, 13876, 10809, 13874, 10811, 13872, 10813, 13870, 10815, 13868, 10817, 13866, 10819, 13864, 10821, 13862, 10823, 13860, 10825, 13858, 10827, 13856, 10829, 13854, 10831, 13852, 10833, 13850, 10835, 13848, 10837, 13846, 10839, 13844, 10841, 13842, 10843, 13840, 10845, 13838, 10847, 13836, 10849, 13834, 10851, 13832, 10853, 13830, 10855, 13828, 10857, 13826, 10859, 13824, 10861, 13822, 10863, 13820, 10865, 13818, 10867, 13816, 10869, 13814, 10871, 13812, 10873, 13810, 10875, 13808, 10877, 13806, 10879, 13804, 10881, 13802, 10883, 13800, 10885, 13798, 10887, 13796, 10889, 13794, 10891, 13792, 10893, 13790, 10895, 13788, 10897, 13786, 10899, 13784, 10901, 13782, 10903, 13780, 10905, 13778, 10907, 13776, 10909, 13774, 10911, 13772, 10913, 13770, 10915, 13768, 10917, 13766, 10919, 13764, 10921, 13762, 10923, 13760, 10925, 13758, 10927, 13756, 10929, 13754, 10931, 13752, 10933, 13750, 10935, 13748, 10937, 13746, 10939, 13744, 10941, 13742, 10943, 13740, 10945, 13738, 10947, 13736, 10949, 13734, 10951, 13732, 10953, 13730, 10955, 13728, 10957, 13726, 10959, 13724, 10961, 13722, 10963, 13720, 10965, 13718, 10967, 13716, 10969, 13714, 10971, 13712, 10973, 13710, 10975, 13708, 10977, 13706, 10979, 13704, 10981, 13702, 10983, 13700, 10985, 13698, 10987, 13696, 10989, 13694, 10991, 13692, 10993, 13690, 10995, 13688, 10997, 13686, 10999, 13684, 11001, 13682, 11003, 13680, 11005, 13678, 11007, 13676, 11009, 13674, 11011, 13672, 11013, 13670, 11015, 13668, 11017, 13666, 11019, 13664, 11021, 13662, 11023, 13660, 11025, 13658, 11027, 13656, 11029, 13654, 11031, 13652, 11033, 13650, 11035, 13648, 11037, 13646, 11039, 13644, 11041, 13642, 11043, 13640, 11045, 13638, 11047, 13636, 11049, 13634, 11051, 13632, 11053, 13630, 11055, 13628, 11057, 13626, 11059, 13624, 11061, 13622, 11063, 13620, 11065, 13618, 11067, 13616, 11069, 13614, 11071, 13612, 11073, 13610, 11075, 13608, 11077, 13606, 11079, 13604, 11081, 13602, 11083, 13600, 11085, 13598, 11087, 13596, 11089, 13594, 11091, 13592, 11093, 13590, 11095, 13588, 11097, 13586, 11099, 13584, 11101, 13582, 11103, 13580, 11105, 13578, 11107, 13576, 11109, 13574, 11111, 13572, 11113, 13570, 11115, 13568, 11117, 13566, 11119, 13564, 11121, 13562, 11123, 13560, 11125, 13558, 11127, 13556, 11129, 13554, 11131, 13552, 11133, 13550, 11135, 13548, 11137, 13546, 11139, 13544, 11141, 13542, 11143, 13540, 11145, 13538, 11147, 13536, 11149, 13534, 11151, 13532, 11153, 13530, 11155, 13528, 11157, 13526, 11159, 13524, 11161, 13522, 11163, 13520, 11165, 13518, 11167, 13516, 11169, 13514, 11171, 13512, 11173, 13510, 11175, 13508, 11177, 13506, 11179, 13504, 11181, 13502, 11183, 13500, 11185, 13498, 11187, 13496, 11189, 13494, 11191, 13492, 11193, 13490, 11195, 13488, 11197, 13486, 11199, 13484, 11201, 13482, 11203, 13480, 11205, 13478, 11207, 13476, 11209, 13474, 11211, 13472, 11213, 13470, 11215, 13468, 11217, 13466, 11219, 13464, 11221, 13462, 11223, 13460, 11225, 13458, 11227, 13456, 11229, 13454, 11231, 13452, 11233, 13450, 11235, 13448, 11237, 13446, 11239, 13444, 11241, 13442, 11243, 13440, 11245, 13438, 11247, 13436, 11249, 13434, 11251, 13432, 11253, 13430, 11255, 13428, 11257, 13426, 11259, 13424, 11261, 13422, 11263, 13420, 11265, 13418, 11267, 13416, 11269, 13414, 11271, 13412, 11273, 13410, 11275, 13408, 11277, 13406, 11279, 13404, 11281, 13402, 11283, 13400, 11285, 13398, 11287, 13396, 11289, 13394, 11291, 13392, 11293, 13390, 11295, 13388, 11297, 13386, 11299, 13384, 11301, 13382, 11303, 13380, 11305, 13378, 11307, 13376, 11309, 13374, 11311, 13372, 11313, 13370, 11315, 13368, 11317, 13366, 11319, 13364, 11321, 13362, 11323, 13360, 11325, 13358, 11327, 13356, 11329, 13354, 11331, 13352, 11333, 13350, 11335, 13348, 11337, 13346, 11339, 13344, 11341, 13342, 11343, 13340, 11345, 13338, 11347, 13336, 11349, 13334, 11351, 13332, 11353, 13330, 11355, 13328, 11357, 13326, 11359, 13324, 11361, 13322, 11363, 13320, 11365, 13318, 11367, 13316, 11369, 13314, 11371, 13312, 11373, 13310, 11375, 13308, 11377, 13306, 11379, 13304, 11381, 13302, 11383, 13300, 11385, 13298, 11387, 13296, 11389, 13294, 11391, 13292, 11393, 13290, 11395, 13288, 11397, 13286, 11399, 13284, 11401, 13282, 11403, 13280, 11405, 13278, 11407, 13276, 11409, 13274, 11411, 13272, 11413, 13270, 11415, 13268, 11417, 13266, 11419, 13264, 11421, 13262, 11423, 13260, 11425, 13258, 11427, 13256, 11429, 13254, 11431, 13252, 11433, 13250, 11435, 13248, 11437, 13246, 11439, 13244, 11441, 13242, 11443, 13240, 11445, 13238, 11447, 13236, 11449, 13234, 11451, 13232, 11453, 13230, 11455, 13228, 11457, 13226, 11459, 13224, 11461, 13222, 11463, 13220, 11465, 13218, 11467, 13216, 11469, 13214, 11471, 13212, 11473, 13210, 11475, 13208, 11477, 13206, 11479, 13204, 11481, 13202, 11483, 13200, 11485, 13198, 11487, 13196, 11489, 13194, 11491, 13192, 11493, 13190, 11495, 13188, 11497, 13186, 11499, 13184, 11501, 13182, 11503, 13180, 11505, 13178, 11507, 13176, 11509, 13174, 11511, 13172, 11513, 13170, 11515, 13168, 11517, 13166, 11519, 13164, 11521, 13162, 11523, 13160, 11525, 13158, 11527, 13156, 11529, 13154, 11531, 13152, 11533, 13150, 11535, 13148, 11537, 13146, 11539, 13144, 11541, 13142, 11543, 13140, 11545, 13138, 11547, 13136, 11549, 13134, 11551, 13132, 11553, 13130, 11555, 13128, 11557, 13126, 11559, 13124, 11561, 13122, 11563, 13120, 11565, 13118, 11567, 13116, 11569, 13114, 11571, 13112, 11573, 13110, 11575, 13108, 11577, 13106, 11579, 13104, 11581, 13102, 11583, 13100, 11585, 13098, 11587, 13096, 11589, 13094, 11591, 13092, 11593, 13090, 11595, 13088, 11597, 13086, 11599, 13084, 11601, 13082, 11603, 13080, 11605, 13078, 11607, 13076, 11609, 13074, 11611, 13072, 11613, 13070, 11615, 13068, 11617, 13066, 11619, 13064, 11621, 13062, 11623, 13060, 11625, 13058, 11627, 13056, 11629, 13054, 11631, 13052, 11633, 13050, 11635, 13048, 11637, 13046, 11639, 13044, 11641, 13042, 11643, 13040, 11645, 13038, 11647, 13036, 11649, 13034, 11651, 13032, 11653, 13030, 11655, 13028, 11657, 13026, 11659, 13024, 11661, 13022, 11663, 13020, 11665, 13018, 11667, 13016, 11669, 13014, 11671, 13012, 11673, 13010, 11675, 13008, 11677, 13006, 11679, 13004, 11681, 13002, 11683, 13000, 11685, 12998, 11687, 12996, 11689, 12994, 11691, 12992, 11693, 12990, 11695, 12988, 11697, 12986, 11699, 12984, 11701, 12982, 11703, 12980, 11705, 12978, 11707, 12976, 11709, 12974, 11711, 12972, 11713, 12970, 11715, 12968, 11717, 12966, 11719, 12964, 11721, 12962, 11723, 12960, 11725, 12958, 11727, 12956, 11729, 12954, 11731, 12952, 11733, 12950, 11735, 12948, 11737, 12946, 11739, 12944, 11741, 12942, 11743, 12940, 11745, 12938, 11747, 12936, 11749, 12934, 11751, 12932, 11753, 12930, 11755, 12928, 11757, 12926, 11759, 12924, 11761, 12922, 11763, 12920, 11765, 12918, 11767, 12916, 11769, 12914, 11771, 12912, 11773, 12910, 11775, 12908, 11777, 12906, 11779, 12904, 11781, 12902, 11783, 12900, 11785, 12898, 11787, 12896, 11789, 12894, 11791, 12892, 11793, 12890, 11795, 12888, 11797, 12886, 11799, 12884, 11801, 12882, 11803, 12880, 11805, 12878, 11807, 12876, 11809, 12874, 11811, 12872, 11813, 12870, 11815, 12868, 11817, 12866, 11819, 12864, 11821, 12862, 11823, 12860, 11825, 12858, 11827, 12856, 11829, 12854, 11831, 12852, 11833, 12850, 11835, 12848, 11837, 12846, 11839, 12844, 11841, 12842, 11843, 12840, 11845, 12838, 11847, 12836, 11849, 12834, 11851, 12832, 11853, 12830, 11855, 12828, 11857, 12826, 11859, 12824, 11861, 12822, 11863, 12820, 11865, 12818, 11867, 12816, 11869, 12814, 11871, 12812, 11873, 12810, 11875, 12808, 11877, 12806, 11879, 12804, 11881, 12802, 11883, 12800, 11885, 12798, 11887, 12796, 11889, 12794, 11891, 12792, 11893, 12790, 11895, 12788, 11897, 12786, 11899, 12784, 11901, 12782, 11903, 12780, 11905, 12778, 11907, 12776, 11909, 12774, 11911, 12772, 11913, 12770, 11915, 12768, 11917, 12766, 11919, 12764, 11921, 12762, 11923, 12760, 11925, 12758, 11927, 12756, 11929, 12754, 11931, 12752, 11933, 12750, 11935, 12748, 11937, 12746, 11939, 12744, 11941, 12742, 11943, 12740, 11945, 12738, 11947, 12736, 11949, 12734, 11951, 12732, 11953, 12730, 11955, 12728, 11957, 12726, 11959, 12724, 11961, 12722, 11963, 12720, 11965, 12718, 11967, 12716, 11969, 12714, 11971, 12712, 11973, 12710, 11975, 12708, 11977, 12706, 11979, 12704, 11981, 12702, 11983, 12700, 11985, 12698, 11987, 12696, 11989, 12694, 11991, 12692, 11993, 12690, 11995, 12688, 11997, 12686, 11999, 12684, 12001, 12682, 12003, 12680, 12005, 12678, 12007, 12676, 12009, 12674, 12011, 12672, 12013, 12670, 12015, 12668, 12017, 12666, 12019, 12664, 12021, 12662, 12023, 12660, 12025, 12658, 12027, 12656, 12029, 12654, 12031, 12652, 12033, 12650, 12035, 12648, 12037, 12646, 12039, 12644, 12041, 12642, 12043, 12640, 12045, 12638, 12047, 12636, 12049, 12634, 12051, 12632, 12053, 12630, 12055, 12628, 12057, 12626, 12059, 12624, 12061, 12622, 12063, 12620, 12065, 12618, 12067, 12616, 12069, 12614, 12071, 12612, 12073, 12610, 12075, 12608, 12077, 12606, 12079, 12604, 12081, 12602, 12083, 12600, 12085, 12598, 12087, 12596, 12089, 12594, 12091, 12592, 12093, 12590, 12095, 12588, 12097, 12586, 12099, 12584, 12101, 12582, 12103, 12580, 12105, 12578, 12107, 12576, 12109, 12574, 12111, 12572, 12113, 12570, 12115, 12568, 12117, 12566, 12119, 12564, 12121, 12562, 12123, 12560, 12125, 12558, 12127, 12556, 12129, 12554, 12131, 12552, 12133, 12550, 12135, 12548, 12137, 12546, 12139, 12544, 12141, 12542, 12143, 12540, 12145, 12538, 12147, 12536, 12149, 12534, 12151, 12532, 12153, 12530, 12155, 12528, 12157, 12526, 12159, 12524, 12161, 12522, 12163, 12520, 12165, 12518, 12167, 12516, 12169, 12514, 12171, 12512, 12173, 12510, 12175, 12508, 12177, 12506, 12179, 12504, 12181, 12502, 12183, 12500, 12185, 12498, 12187, 12496, 12189, 12494, 12191, 12492, 12193, 12490, 12195, 12488, 12197, 12486, 12199, 12484, 12201, 12482, 12203, 12480, 12205, 12478, 12207, 12476, 12209, 12474, 12211, 12472, 12213, 12470, 12215, 12468, 12217, 12466, 12219, 12464, 12221, 12462, 12223, 12460, 12225, 12458, 12227, 12456, 12229, 12454, 12231, 12452, 12233, 12450, 12235, 12448, 12237, 12446, 12239, 12444, 12241, 12442, 12243, 12440, 12245, 12438, 12247, 12436, 12249, 12434, 12251, 12432, 12253, 12430, 12255, 12428, 12257, 12426, 12259, 12424, 12261, 12422, 12263, 12420, 12265, 12418, 12267, 12416, 12269, 12414, 12271, 12412, 12273, 12410, 12275, 12408, 12277, 12406, 12279, 12404, 12281, 12402, 12283, 12400, 12285, 12398, 12287, 12396, 12289, 12394, 12291, 12392, 12293, 12390, 12295, 12388, 12297, 12386, 12299, 12384, 12301, 12382, 12303, 12380, 12305, 12378, 12307, 12376, 12309, 12374, 12311, 12372, 12313, 12370, 12315, 12368, 12317, 12366, 12319, 12364, 12321, 12362, 12323, 12360, 12325, 12358, 12327, 12356, 12329, 12354, 12331, 12352, 12333, 12350, 12335, 12348, 12337, 12346, 12339, 12344, 12341, 12342, 12343, 12340, 12345, 12338, 12347, 12336, 12349, 12334, 12351, 12332, 12353, 12330, 12355, 12328, 12357, 12326, 12359, 12324, 12361, 12322, 12363, 12320, 12365, 12318, 12367, 12316, 12369, 12314, 12371, 12312, 12373, 12310, 12375, 12308, 12377, 12306, 12379, 12304, 12381, 12302, 12383, 12300, 12385, 12298, 12387, 12296, 12389, 12294, 12391, 12292, 12393, 12290, 12395, 12288, 12397, 12286, 12399, 12284, 12401, 12282, 12403, 12280, 12405, 12278, 12407, 12276, 12409, 12274, 12411, 12272, 12413, 12270, 12415, 12268, 12417, 12266, 12419, 12264, 12421, 12262, 12423, 12260, 12425, 12258, 12427, 12256, 12429, 12254, 12431, 12252, 12433, 12250, 12435, 12248, 12437, 12246, 12439, 12244, 12441, 12242, 12443, 12240, 12445, 12238, 12447, 12236, 12449, 12234, 12451, 12232, 12453, 12230, 12455, 12228, 12457, 12226, 12459, 12224, 12461, 12222, 12463, 12220, 12465, 12218, 12467, 12216, 12469, 12214, 12471, 12212, 12473, 12210, 12475, 12208, 12477, 12206, 12479, 12204, 12481, 12202, 12483, 12200, 12485, 12198, 12487, 12196, 12489, 12194, 12491, 12192, 12493, 12190, 12495, 12188, 12497, 12186, 12499, 12184, 12501, 12182, 12503, 12180, 12505, 12178, 12507, 12176, 12509, 12174, 12511, 12172, 12513, 12170, 12515, 12168, 12517, 12166, 12519, 12164, 12521, 12162, 12523, 12160, 12525, 12158, 12527, 12156, 12529, 12154, 12531, 12152, 12533, 12150, 12535, 12148, 12537, 12146, 12539, 12144, 12541, 12142, 12543, 12140, 12545, 12138, 12547, 12136, 12549, 12134, 12551, 12132, 12553, 12130, 12555, 12128, 12557, 12126, 12559, 12124, 12561, 12122, 12563, 12120, 12565, 12118, 12567, 12116, 12569, 12114, 12571, 12112, 12573, 12110, 12575, 12108, 12577, 12106, 12579, 12104, 12581, 12102, 12583, 12100, 12585, 12098, 12587, 12096, 12589, 12094, 12591, 12092, 12593, 12090, 12595, 12088, 12597, 12086, 12599, 12084, 12601, 12082, 12603, 12080, 12605, 12078, 12607, 12076, 12609, 12074, 12611, 12072, 12613, 12070, 12615, 12068, 12617, 12066, 12619, 12064, 12621, 12062, 12623, 12060, 12625, 12058, 12627, 12056, 12629, 12054, 12631, 12052, 12633, 12050, 12635, 12048, 12637, 12046, 12639, 12044, 12641, 12042, 12643, 12040, 12645, 12038, 12647, 12036, 12649, 12034, 12651, 12032, 12653, 12030, 12655, 12028, 12657, 12026, 12659, 12024, 12661, 12022, 12663, 12020, 12665, 12018, 12667, 12016, 12669, 12014, 12671, 12012, 12673, 12010, 12675, 12008, 12677, 12006, 12679, 12004, 12681, 12002, 12683, 12000, 12685, 11998, 12687, 11996, 12689, 11994, 12691, 11992, 12693, 11990, 12695, 11988, 12697, 11986, 12699, 11984, 12701, 11982, 12703, 11980, 12705, 11978, 12707, 11976, 12709, 11974, 12711, 11972, 12713, 11970, 12715, 11968, 12717, 11966, 12719, 11964, 12721, 11962, 12723, 11960, 12725, 11958, 12727, 11956, 12729, 11954, 12731, 11952, 12733, 11950, 12735, 11948, 12737, 11946, 12739, 11944, 12741, 11942, 12743, 11940, 12745, 11938, 12747, 11936, 12749, 11934, 12751, 11932, 12753, 11930, 12755, 11928, 12757, 11926, 12759, 11924, 12761, 11922, 12763, 11920, 12765, 11918, 12767, 11916, 12769, 11914, 12771, 11912, 12773, 11910, 12775, 11908, 12777, 11906, 12779, 11904, 12781, 11902, 12783, 11900, 12785, 11898, 12787, 11896, 12789, 11894, 12791, 11892, 12793, 11890, 12795, 11888, 12797, 11886, 12799, 11884, 12801, 11882, 12803, 11880, 12805, 11878, 12807, 11876, 12809, 11874, 12811, 11872, 12813, 11870, 12815, 11868, 12817, 11866, 12819, 11864, 12821, 11862, 12823, 11860, 12825, 11858, 12827, 11856, 12829, 11854, 12831, 11852, 12833, 11850, 12835, 11848, 12837, 11846, 12839, 11844, 12841, 11842, 12843, 11840, 12845, 11838, 12847, 11836, 12849, 11834, 12851, 11832, 12853, 11830, 12855, 11828, 12857, 11826, 12859, 11824, 12861, 11822, 12863, 11820, 12865, 11818, 12867, 11816, 12869, 11814, 12871, 11812, 12873, 11810, 12875, 11808, 12877, 11806, 12879, 11804, 12881, 11802, 12883, 11800, 12885, 11798, 12887, 11796, 12889, 11794, 12891, 11792, 12893, 11790, 12895, 11788, 12897, 11786, 12899, 11784, 12901, 11782, 12903, 11780, 12905, 11778, 12907, 11776, 12909, 11774, 12911, 11772, 12913, 11770, 12915, 11768, 12917, 11766, 12919, 11764, 12921, 11762, 12923, 11760, 12925, 11758, 12927, 11756, 12929, 11754, 12931, 11752, 12933, 11750, 12935, 11748, 12937, 11746, 12939, 11744, 12941, 11742, 12943, 11740, 12945, 11738, 12947, 11736, 12949, 11734, 12951, 11732, 12953, 11730, 12955, 11728, 12957, 11726, 12959, 11724, 12961, 11722, 12963, 11720, 12965, 11718, 12967, 11716, 12969, 11714, 12971, 11712, 12973, 11710, 12975, 11708, 12977, 11706, 12979, 11704, 12981, 11702, 12983, 11700, 12985, 11698, 12987, 11696, 12989, 11694, 12991, 11692, 12993, 11690, 12995, 11688, 12997, 11686, 12999, 11684, 13001, 11682, 13003, 11680, 13005, 11678, 13007, 11676, 13009, 11674, 13011, 11672, 13013, 11670, 13015, 11668, 13017, 11666, 13019, 11664, 13021, 11662, 13023, 11660, 13025, 11658, 13027, 11656, 13029, 11654, 13031, 11652, 13033, 11650, 13035, 11648, 13037, 11646, 13039, 11644, 13041, 11642, 13043, 11640, 13045, 11638, 13047, 11636, 13049, 11634, 13051, 11632, 13053, 11630, 13055, 11628, 13057, 11626, 13059, 11624, 13061, 11622, 13063, 11620, 13065, 11618, 13067, 11616, 13069, 11614, 13071, 11612, 13073, 11610, 13075, 11608, 13077, 11606, 13079, 11604, 13081, 11602, 13083, 11600, 13085, 11598, 13087, 11596, 13089, 11594, 13091, 11592, 13093, 11590, 13095, 11588, 13097, 11586, 13099, 11584, 13101, 11582, 13103, 11580, 13105, 11578, 13107, 11576, 13109, 11574, 13111, 11572, 13113, 11570, 13115, 11568, 13117, 11566, 13119, 11564, 13121, 11562, 13123, 11560, 13125, 11558, 13127, 11556, 13129, 11554, 13131, 11552, 13133, 11550, 13135, 11548, 13137, 11546, 13139, 11544, 13141, 11542, 13143, 11540, 13145, 11538, 13147, 11536, 13149, 11534, 13151, 11532, 13153, 11530, 13155, 11528, 13157, 11526, 13159, 11524, 13161, 11522, 13163, 11520, 13165, 11518, 13167, 11516, 13169, 11514, 13171, 11512, 13173, 11510, 13175, 11508, 13177, 11506, 13179, 11504, 13181, 11502, 13183, 11500, 13185, 11498, 13187, 11496, 13189, 11494, 13191, 11492, 13193, 11490, 13195, 11488, 13197, 11486, 13199, 11484, 13201, 11482, 13203, 11480, 13205, 11478, 13207, 11476, 13209, 11474, 13211, 11472, 13213, 11470, 13215, 11468, 13217, 11466, 13219, 11464, 13221, 11462, 13223, 11460, 13225, 11458, 13227, 11456, 13229, 11454, 13231, 11452, 13233, 11450, 13235, 11448, 13237, 11446, 13239, 11444, 13241, 11442, 13243, 11440, 13245, 11438, 13247, 11436, 13249, 11434, 13251, 11432, 13253, 11430, 13255, 11428, 13257, 11426, 13259, 11424, 13261, 11422, 13263, 11420, 13265, 11418, 13267, 11416, 13269, 11414, 13271, 11412, 13273, 11410, 13275, 11408, 13277, 11406, 13279, 11404, 13281, 11402, 13283, 11400, 13285, 11398, 13287, 11396, 13289, 11394, 13291, 11392, 13293, 11390, 13295, 11388, 13297, 11386, 13299, 11384, 13301, 11382, 13303, 11380, 13305, 11378, 13307, 11376, 13309, 11374, 13311, 11372, 13313, 11370, 13315, 11368, 13317, 11366, 13319, 11364, 13321, 11362, 13323, 11360, 13325, 11358, 13327, 11356, 13329, 11354, 13331, 11352, 13333, 11350, 13335, 11348, 13337, 11346, 13339, 11344, 13341, 11342, 13343, 11340, 13345, 11338, 13347, 11336, 13349, 11334, 13351, 11332, 13353, 11330, 13355, 11328, 13357, 11326, 13359, 11324, 13361, 11322, 13363, 11320, 13365, 11318, 13367, 11316, 13369, 11314, 13371, 11312, 13373, 11310, 13375, 11308, 13377, 11306, 13379, 11304, 13381, 11302, 13383, 11300, 13385, 11298, 13387, 11296, 13389, 11294, 13391, 11292, 13393, 11290, 13395, 11288, 13397, 11286, 13399, 11284, 13401, 11282, 13403, 11280, 13405, 11278, 13407, 11276, 13409, 11274, 13411, 11272, 13413, 11270, 13415, 11268, 13417, 11266, 13419, 11264, 13421, 11262, 13423, 11260, 13425, 11258, 13427, 11256, 13429, 11254, 13431, 11252, 13433, 11250, 13435, 11248, 13437, 11246, 13439, 11244, 13441, 11242, 13443, 11240, 13445, 11238, 13447, 11236, 13449, 11234, 13451, 11232, 13453, 11230, 13455, 11228, 13457, 11226, 13459, 11224, 13461, 11222, 13463, 11220, 13465, 11218, 13467, 11216, 13469, 11214, 13471, 11212, 13473, 11210, 13475, 11208, 13477, 11206, 13479, 11204, 13481, 11202, 13483, 11200, 13485, 11198, 13487, 11196, 13489, 11194, 13491, 11192, 13493, 11190, 13495, 11188, 13497, 11186, 13499, 11184, 13501, 11182, 13503, 11180, 13505, 11178, 13507, 11176, 13509, 11174, 13511, 11172, 13513, 11170, 13515, 11168, 13517, 11166, 13519, 11164, 13521, 11162, 13523, 11160, 13525, 11158, 13527, 11156, 13529, 11154, 13531, 11152, 13533, 11150, 13535, 11148, 13537, 11146, 13539, 11144, 13541, 11142, 13543, 11140, 13545, 11138, 13547, 11136, 13549, 11134, 13551, 11132, 13553, 11130, 13555, 11128, 13557, 11126, 13559, 11124, 13561, 11122, 13563, 11120, 13565, 11118, 13567, 11116, 13569, 11114, 13571, 11112, 13573, 11110, 13575, 11108, 13577, 11106, 13579, 11104, 13581, 11102, 13583, 11100, 13585, 11098, 13587, 11096, 13589, 11094, 13591, 11092, 13593, 11090, 13595, 11088, 13597, 11086, 13599, 11084, 13601, 11082, 13603, 11080, 13605, 11078, 13607, 11076, 13609, 11074, 13611, 11072, 13613, 11070, 13615, 11068, 13617, 11066, 13619, 11064, 13621, 11062, 13623, 11060, 13625, 11058, 13627, 11056, 13629, 11054, 13631, 11052, 13633, 11050, 13635, 11048, 13637, 11046, 13639, 11044, 13641, 11042, 13643, 11040, 13645, 11038, 13647, 11036, 13649, 11034, 13651, 11032, 13653, 11030, 13655, 11028, 13657, 11026, 13659, 11024, 13661, 11022, 13663, 11020, 13665, 11018, 13667, 11016, 13669, 11014, 13671, 11012, 13673, 11010, 13675, 11008, 13677, 11006, 13679, 11004, 13681, 11002, 13683, 11000, 13685, 10998, 13687, 10996, 13689, 10994, 13691, 10992, 13693, 10990, 13695, 10988, 13697, 10986, 13699, 10984, 13701, 10982, 13703, 10980, 13705, 10978, 13707, 10976, 13709, 10974, 13711, 10972, 13713, 10970, 13715, 10968, 13717, 10966, 13719, 10964, 13721, 10962, 13723, 10960, 13725, 10958, 13727, 10956, 13729, 10954, 13731, 10952, 13733, 10950, 13735, 10948, 13737, 10946, 13739, 10944, 13741, 10942, 13743, 10940, 13745, 10938, 13747, 10936, 13749, 10934, 13751, 10932, 13753, 10930, 13755, 10928, 13757, 10926, 13759, 10924, 13761, 10922, 13763, 10920, 13765, 10918, 13767, 10916, 13769, 10914, 13771, 10912, 13773, 10910, 13775, 10908, 13777, 10906, 13779, 10904, 13781, 10902, 13783, 10900, 13785, 10898, 13787, 10896, 13789, 10894, 13791, 10892, 13793, 10890, 13795, 10888, 13797, 10886, 13799, 10884, 13801, 10882, 13803, 10880, 13805, 10878, 13807, 10876, 13809, 10874, 13811, 10872, 13813, 10870, 13815, 10868, 13817, 10866, 13819, 10864, 13821, 10862, 13823, 10860, 13825, 10858, 13827, 10856, 13829, 10854, 13831, 10852, 13833, 10850, 13835, 10848, 13837, 10846, 13839, 10844, 13841, 10842, 13843, 10840, 13845, 10838, 13847, 10836, 13849, 10834, 13851, 10832, 13853, 10830, 13855, 10828, 13857, 10826, 13859, 10824, 13861, 10822, 13863, 10820, 13865, 10818, 13867, 10816, 13869, 10814, 13871, 10812, 13873, 10810, 13875, 10808, 13877, 10806, 13879, 10804, 13881, 10802, 13883, 10800, 13885, 10798, 13887, 10796, 13889, 10794, 13891, 10792, 13893, 10790, 13895, 10788, 13897, 10786, 13899, 10784, 13901, 10782, 13903, 10780, 13905, 10778, 13907, 10776, 13909, 10774, 13911, 10772, 13913, 10770, 13915, 10768, 13917, 10766, 13919, 10764, 13921, 10762, 13923, 10760, 13925, 10758, 13927, 10756, 13929, 10754, 13931, 10752, 13933, 10750, 13935, 10748, 13937, 10746, 13939, 10744, 13941, 10742, 13943, 10740, 13945, 10738, 13947, 10736, 13949, 10734, 13951, 10732, 13953, 10730, 13955, 10728, 13957, 10726, 13959, 10724, 13961, 10722, 13963, 10720, 13965, 10718, 13967, 10716, 13969, 10714, 13971, 10712, 13973, 10710, 13975, 10708, 13977, 10706, 13979, 10704, 13981, 10702, 13983, 10700, 13985, 10698, 13987, 10696, 13989, 10694, 13991, 10692, 13993, 10690, 13995, 10688, 13997, 10686, 13999, 10684, 14001, 10682, 14003, 10680, 14005, 10678, 14007, 10676, 14009, 10674, 14011, 10672, 14013, 10670, 14015, 10668, 14017, 10666, 14019, 10664, 14021, 10662, 14023, 10660, 14025, 10658, 14027, 10656, 14029, 10654, 14031, 10652, 14033, 10650, 14035, 10648, 14037, 10646, 14039, 10644, 14041, 10642, 14043, 10640, 14045, 10638, 14047, 10636, 14049, 10634, 14051, 10632, 14053, 10630, 14055, 10628, 14057, 10626, 14059, 10624, 14061, 10622, 14063, 10620, 14065, 10618, 14067, 10616, 14069, 10614, 14071, 10612, 14073, 10610, 14075, 10608, 14077, 10606, 14079, 10604, 14081, 10602, 14083, 10600, 14085, 10598, 14087, 10596, 14089, 10594, 14091, 10592, 14093, 10590, 14095, 10588, 14097, 10586, 14099, 10584, 14101, 10582, 14103, 10580, 14105, 10578, 14107, 10576, 14109, 10574, 14111, 10572, 14113, 10570, 14115, 10568, 14117, 10566, 14119, 10564, 14121, 10562, 14123, 10560, 14125, 10558, 14127, 10556, 14129, 10554, 14131, 10552, 14133, 10550, 14135, 10548, 14137, 10546, 14139, 10544, 14141, 10542, 14143, 10540, 14145, 10538, 14147, 10536, 14149, 10534, 14151, 10532, 14153, 10530, 14155, 10528, 14157, 10526, 14159, 10524, 14161, 10522, 14163, 10520, 14165, 10518, 14167, 10516, 14169, 10514, 14171, 10512, 14173, 10510, 14175, 10508, 14177, 10506, 14179, 10504, 14181, 10502, 14183, 10500, 14185, 10498, 14187, 10496, 14189, 10494, 14191, 10492, 14193, 10490, 14195, 10488, 14197, 10486, 14199, 10484, 14201, 10482, 14203, 10480, 14205, 10478, 14207, 10476, 14209, 10474, 14211, 10472, 14213, 10470, 14215, 10468, 14217, 10466, 14219, 10464, 14221, 10462, 14223, 10460, 14225, 10458, 14227, 10456, 14229, 10454, 14231, 10452, 14233, 10450, 14235, 10448, 14237, 10446, 14239, 10444, 14241, 10442, 14243, 10440, 14245, 10438, 14247, 10436, 14249, 10434, 14251, 10432, 14253, 10430, 14255, 10428, 14257, 10426, 14259, 10424, 14261, 10422, 14263, 10420, 14265, 10418, 14267, 10416, 14269, 10414, 14271, 10412, 14273, 10410, 14275, 10408, 14277, 10406, 14279, 10404, 14281, 10402, 14283, 10400, 14285, 10398, 14287, 10396, 14289, 10394, 14291, 10392, 14293, 10390, 14295, 10388, 14297, 10386, 14299, 10384, 14301, 10382, 14303, 10380, 14305, 10378, 14307, 10376, 14309, 10374, 14311, 10372, 14313, 10370, 14315, 10368, 14317, 10366, 14319, 10364, 14321, 10362, 14323, 10360, 14325, 10358, 14327, 10356, 14329, 10354, 14331, 10352, 14333, 10350, 14335, 10348, 14337, 10346, 14339, 10344, 14341, 10342, 14343, 10340, 14345, 10338, 14347, 10336, 14349, 10334, 14351, 10332, 14353, 10330, 14355, 10328, 14357, 10326, 14359, 10324, 14361, 10322, 14363, 10320, 14365, 10318, 14367, 10316, 14369, 10314, 14371, 10312, 14373, 10310, 14375, 10308, 14377, 10306, 14379, 10304, 14381, 10302, 14383, 10300, 14385, 10298, 14387, 10296, 14389, 10294, 14391, 10292, 14393, 10290, 14395, 10288, 14397, 10286, 14399, 10284, 14401, 10282, 14403, 10280, 14405, 10278, 14407, 10276, 14409, 10274, 14411, 10272, 14413, 10270, 14415, 10268, 14417, 10266, 14419, 10264, 14421, 10262, 14423, 10260, 14425, 10258, 14427, 10256, 14429, 10254, 14431, 10252, 14433, 10250, 14435, 10248, 14437, 10246, 14439, 10244, 14441, 10242, 14443, 10240, 14445, 10238, 14447, 10236, 14449, 10234, 14451, 10232, 14453, 10230, 14455, 10228, 14457, 10226, 14459, 10224, 14461, 10222, 14463, 10220, 14465, 10218, 14467, 10216, 14469, 10214, 14471, 10212, 14473, 10210, 14475, 10208, 14477, 10206, 14479, 10204, 14481, 10202, 14483, 10200, 14485, 10198, 14487, 10196, 14489, 10194, 14491, 10192, 14493, 10190, 14495, 10188, 14497, 10186, 14499, 10184, 14501, 10182, 14503, 10180, 14505, 10178, 14507, 10176, 14509, 10174, 14511, 10172, 14513, 10170, 14515, 10168, 14517, 10166, 14519, 10164, 14521, 10162, 14523, 10160, 14525, 10158, 14527, 10156, 14529, 10154, 14531, 10152, 14533, 10150, 14535, 10148, 14537, 10146, 14539, 10144, 14541, 10142, 14543, 10140, 14545, 10138, 14547, 10136, 14549, 10134, 14551, 10132, 14553, 10130, 14555, 10128, 14557, 10126, 14559, 10124, 14561, 10122, 14563, 10120, 14565, 10118, 14567, 10116, 14569, 10114, 14571, 10112, 14573, 10110, 14575, 10108, 14577, 10106, 14579, 10104, 14581, 10102, 14583, 10100, 14585, 10098, 14587, 10096, 14589, 10094, 14591, 10092, 14593, 10090, 14595, 10088, 14597, 10086, 14599, 10084, 14601, 10082, 14603, 10080, 14605, 10078, 14607, 10076, 14609, 10074, 14611, 10072, 14613, 10070, 14615, 10068, 14617, 10066, 14619, 10064, 14621, 10062, 14623, 10060, 14625, 10058, 14627, 10056, 14629, 10054, 14631, 10052, 14633, 10050, 14635, 10048, 14637, 10046, 14639, 10044, 14641, 10042, 14643, 10040, 14645, 10038, 14647, 10036, 14649, 10034, 14651, 10032, 14653, 10030, 14655, 10028, 14657, 10026, 14659, 10024, 14661, 10022, 14663, 10020, 14665, 10018, 14667, 10016, 14669, 10014, 14671, 10012, 14673, 10010, 14675, 10008, 14677, 10006, 14679, 10004, 14681, 10002, 14683, 10000, 14685, 9998, 14687, 9996, 14689, 9994, 14691, 9992, 14693, 9990, 14695, 9988, 14697, 9986, 14699, 9984, 14701, 9982, 14703, 9980, 14705, 9978, 14707, 9976, 14709, 9974, 14711, 9972, 14713, 9970, 14715, 9968, 14717, 9966, 14719, 9964, 14721, 9962, 14723, 9960, 14725, 9958, 14727, 9956, 14729, 9954, 14731, 9952, 14733, 9950, 14735, 9948, 14737, 9946, 14739, 9944, 14741, 9942, 14743, 9940, 14745, 9938, 14747, 9936, 14749, 9934, 14751, 9932, 14753, 9930, 14755, 9928, 14757, 9926, 14759, 9924, 14761, 9922, 14763, 9920, 14765, 9918, 14767, 9916, 14769, 9914, 14771, 9912, 14773, 9910, 14775, 9908, 14777, 9906, 14779, 9904, 14781, 9902, 14783, 9900, 14785, 9898, 14787, 9896, 14789, 9894, 14791, 9892, 14793, 9890, 14795, 9888, 14797, 9886, 14799, 9884, 14801, 9882, 14803, 9880, 14805, 9878, 14807, 9876, 14809, 9874, 14811, 9872, 14813, 9870, 14815, 9868, 14817, 9866, 14819, 9864, 14821, 9862, 14823, 9860, 14825, 9858, 14827, 9856, 14829, 9854, 14831, 9852, 14833, 9850, 14835, 9848, 14837, 9846, 14839, 9844, 14841, 9842, 14843, 9840, 14845, 9838, 14847, 9836, 14849, 9834, 14851, 9832, 14853, 9830, 14855, 9828, 14857, 9826, 14859, 9824, 14861, 9822, 14863, 9820, 14865, 9818, 14867, 9816, 14869, 9814, 14871, 9812, 14873, 9810, 14875, 9808, 14877, 9806, 14879, 9804, 14881, 9802, 14883, 9800, 14885, 9798, 14887, 9796, 14889, 9794, 14891, 9792, 14893, 9790, 14895, 9788, 14897, 9786, 14899, 9784, 14901, 9782, 14903, 9780, 14905, 9778, 14907, 9776, 14909, 9774, 14911, 9772, 14913, 9770, 14915, 9768, 14917, 9766, 14919, 9764, 14921, 9762, 14923, 9760, 14925, 9758, 14927, 9756, 14929, 9754, 14931, 9752, 14933, 9750, 14935, 9748, 14937, 9746, 14939, 9744, 14941, 9742, 14943, 9740, 14945, 9738, 14947, 9736, 14949, 9734, 14951, 9732, 14953, 9730, 14955, 9728, 14957, 9726, 14959, 9724, 14961, 9722, 14963, 9720, 14965, 9718, 14967, 9716, 14969, 9714, 14971, 9712, 14973, 9710, 14975, 9708, 14977, 9706, 14979, 9704, 14981, 9702, 14983, 9700, 14985, 9698, 14987, 9696, 14989, 9694, 14991, 9692, 14993, 9690, 14995, 9688, 14997, 9686, 14999, 9684, 15001, 9682, 15003, 9680, 15005, 9678, 15007, 9676, 15009, 9674, 15011, 9672, 15013, 9670, 15015, 9668, 15017, 9666, 15019, 9664, 15021, 9662, 15023, 9660, 15025, 9658, 15027, 9656, 15029, 9654, 15031, 9652, 15033, 9650, 15035, 9648, 15037, 9646, 15039, 9644, 15041, 9642, 15043, 9640, 15045, 9638, 15047, 9636, 15049, 9634, 15051, 9632, 15053, 9630, 15055, 9628, 15057, 9626, 15059, 9624, 15061, 9622, 15063, 9620, 15065, 9618, 15067, 9616, 15069, 9614, 15071, 9612, 15073, 9610, 15075, 9608, 15077, 9606, 15079, 9604, 15081, 9602, 15083, 9600, 15085, 9598, 15087, 9596, 15089, 9594, 15091, 9592, 15093, 9590, 15095, 9588, 15097, 9586, 15099, 9584, 15101, 9582, 15103, 9580, 15105, 9578, 15107, 9576, 15109, 9574, 15111, 9572, 15113, 9570, 15115, 9568, 15117, 9566, 15119, 9564, 15121, 9562, 15123, 9560, 15125, 9558, 15127, 9556, 15129, 9554, 15131, 9552, 15133, 9550, 15135, 9548, 15137, 9546, 15139, 9544, 15141, 9542, 15143, 9540, 15145, 9538, 15147, 9536, 15149, 9534, 15151, 9532, 15153, 9530, 15155, 9528, 15157, 9526, 15159, 9524, 15161, 9522, 15163, 9520, 15165, 9518, 15167, 9516, 15169, 9514, 15171, 9512, 15173, 9510, 15175, 9508, 15177, 9506, 15179, 9504, 15181, 9502, 15183, 9500, 15185, 9498, 15187, 9496, 15189, 9494, 15191, 9492, 15193, 9490, 15195, 9488, 15197, 9486, 15199, 9484, 15201, 9482, 15203, 9480, 15205, 9478, 15207, 9476, 15209, 9474, 15211, 9472, 15213, 9470, 15215, 9468, 15217, 9466, 15219, 9464, 15221, 9462, 15223, 9460, 15225, 9458, 15227, 9456, 15229, 9454, 15231, 9452, 15233, 9450, 15235, 9448, 15237, 9446, 15239, 9444, 15241, 9442, 15243, 9440, 15245, 9438, 15247, 9436, 15249, 9434, 15251, 9432, 15253, 9430, 15255, 9428, 15257, 9426, 15259, 9424, 15261, 9422, 15263, 9420, 15265, 9418, 15267, 9416, 15269, 9414, 15271, 9412, 15273, 9410, 15275, 9408, 15277, 9406, 15279, 9404, 15281, 9402, 15283, 9400, 15285, 9398, 15287, 9396, 15289, 9394, 15291, 9392, 15293, 9390, 15295, 9388, 15297, 9386, 15299, 9384, 15301, 9382, 15303, 9380, 15305, 9378, 15307, 9376, 15309, 9374, 15311, 9372, 15313, 9370, 15315, 9368, 15317, 9366, 15319, 9364, 15321, 9362, 15323, 9360, 15325, 9358, 15327, 9356, 15329, 9354, 15331, 9352, 15333, 9350, 15335, 9348, 15337, 9346, 15339, 9344, 15341, 9342, 15343, 9340, 15345, 9338, 15347, 9336, 15349, 9334, 15351, 9332, 15353, 9330, 15355, 9328, 15357, 9326, 15359, 9324, 15361, 9322, 15363, 9320, 15365, 9318, 15367, 9316, 15369, 9314, 15371, 9312, 15373, 9310, 15375, 9308, 15377, 9306, 15379, 9304, 15381, 9302, 15383, 9300, 15385, 9298, 15387, 9296, 15389, 9294, 15391, 9292, 15393, 9290, 15395, 9288, 15397, 9286, 15399, 9284, 15401, 9282, 15403, 9280, 15405, 9278, 15407, 9276, 15409, 9274, 15411, 9272, 15413, 9270, 15415, 9268, 15417, 9266, 15419, 9264, 15421, 9262, 15423, 9260, 15425, 9258, 15427, 9256, 15429, 9254, 15431, 9252, 15433, 9250, 15435, 9248, 15437, 9246, 15439, 9244, 15441, 9242, 15443, 9240, 15445, 9238, 15447, 9236, 15449, 9234, 15451, 9232, 15453, 9230, 15455, 9228, 15457, 9226, 15459, 9224, 15461, 9222, 15463, 9220, 15465, 9218, 15467, 9216, 15469, 9214, 15471, 9212, 15473, 9210, 15475, 9208, 15477, 9206, 15479, 9204, 15481, 9202, 15483, 9200, 15485, 9198, 15487, 9196, 15489, 9194, 15491, 9192, 15493, 9190, 15495, 9188, 15497, 9186, 15499, 9184, 15501, 9182, 15503, 9180, 15505, 9178, 15507, 9176, 15509, 9174, 15511, 9172, 15513, 9170, 15515, 9168, 15517, 9166, 15519, 9164, 15521, 9162, 15523, 9160, 15525, 9158, 15527, 9156, 15529, 9154, 15531, 9152, 15533, 9150, 15535, 9148, 15537, 9146, 15539, 9144, 15541, 9142, 15543, 9140, 15545, 9138, 15547, 9136, 15549, 9134, 15551, 9132, 15553, 9130, 15555, 9128, 15557, 9126, 15559, 9124, 15561, 9122, 15563, 9120, 15565, 9118, 15567, 9116, 15569, 9114, 15571, 9112, 15573, 9110, 15575, 9108, 15577, 9106, 15579, 9104, 15581, 9102, 15583, 9100, 15585, 9098, 15587, 9096, 15589, 9094, 15591, 9092, 15593, 9090, 15595, 9088, 15597, 9086, 15599, 9084, 15601, 9082, 15603, 9080, 15605, 9078, 15607, 9076, 15609, 9074, 15611, 9072, 15613, 9070, 15615, 9068, 15617, 9066, 15619, 9064, 15621, 9062, 15623, 9060, 15625, 9058, 15627, 9056, 15629, 9054, 15631, 9052, 15633, 9050, 15635, 9048, 15637, 9046, 15639, 9044, 15641, 9042, 15643, 9040, 15645, 9038, 15647, 9036, 15649, 9034, 15651, 9032, 15653, 9030, 15655, 9028, 15657, 9026, 15659, 9024, 15661, 9022, 15663, 9020, 15665, 9018, 15667, 9016, 15669, 9014, 15671, 9012, 15673, 9010, 15675, 9008, 15677, 9006, 15679, 9004, 15681, 9002, 15683, 9000, 15685, 8998, 15687, 8996, 15689, 8994, 15691, 8992, 15693, 8990, 15695, 8988, 15697, 8986, 15699, 8984, 15701, 8982, 15703, 8980, 15705, 8978, 15707, 8976, 15709, 8974, 15711, 8972, 15713, 8970, 15715, 8968, 15717, 8966, 15719, 8964, 15721, 8962, 15723, 8960, 15725, 8958, 15727, 8956, 15729, 8954, 15731, 8952, 15733, 8950, 15735, 8948, 15737, 8946, 15739, 8944, 15741, 8942, 15743, 8940, 15745, 8938, 15747, 8936, 15749, 8934, 15751, 8932, 15753, 8930, 15755, 8928, 15757, 8926, 15759, 8924, 15761, 8922, 15763, 8920, 15765, 8918, 15767, 8916, 15769, 8914, 15771, 8912, 15773, 8910, 15775, 8908, 15777, 8906, 15779, 8904, 15781, 8902, 15783, 8900, 15785, 8898, 15787, 8896, 15789, 8894, 15791, 8892, 15793, 8890, 15795, 8888, 15797, 8886, 15799, 8884, 15801, 8882, 15803, 8880, 15805, 8878, 15807, 8876, 15809, 8874, 15811, 8872, 15813, 8870, 15815, 8868, 15817, 8866, 15819, 8864, 15821, 8862, 15823, 8860, 15825, 8858, 15827, 8856, 15829, 8854, 15831, 8852, 15833, 8850, 15835, 8848, 15837, 8846, 15839, 8844, 15841, 8842, 15843, 8840, 15845, 8838, 15847, 8836, 15849, 8834, 15851, 8832, 15853, 8830, 15855, 8828, 15857, 8826, 15859, 8824, 15861, 8822, 15863, 8820, 15865, 8818, 15867, 8816, 15869, 8814, 15871, 8812, 15873, 8810, 15875, 8808, 15877, 8806, 15879, 8804, 15881, 8802, 15883, 8800, 15885, 8798, 15887, 8796, 15889, 8794, 15891, 8792, 15893, 8790, 15895, 8788, 15897, 8786, 15899, 8784, 15901, 8782, 15903, 8780, 15905, 8778, 15907, 8776, 15909, 8774, 15911, 8772, 15913, 8770, 15915, 8768, 15917, 8766, 15919, 8764, 15921, 8762, 15923, 8760, 15925, 8758, 15927, 8756, 15929, 8754, 15931, 8752, 15933, 8750, 15935, 8748, 15937, 8746, 15939, 8744, 15941, 8742, 15943, 8740, 15945, 8738, 15947, 8736, 15949, 8734, 15951, 8732, 15953, 8730, 15955, 8728, 15957, 8726, 15959, 8724, 15961, 8722, 15963, 8720, 15965, 8718, 15967, 8716, 15969, 8714, 15971, 8712, 15973, 8710, 15975, 8708, 15977, 8706, 15979, 8704, 15981, 8702, 15983, 8700, 15985, 8698, 15987, 8696, 15989, 8694, 15991, 8692, 15993, 8690, 15995, 8688, 15997, 8686, 15999, 8684, 16001, 8682, 16003, 8680, 16005, 8678, 16007, 8676, 16009, 8674, 16011, 8672, 16013, 8670, 16015, 8668, 16017, 8666, 16019, 8664, 16021, 8662, 16023, 8660, 16025, 8658, 16027, 8656, 16029, 8654, 16031, 8652, 16033, 8650, 16035, 8648, 16037, 8646, 16039, 8644, 16041, 8642, 16043, 8640, 16045, 8638, 16047, 8636, 16049, 8634, 16051, 8632, 16053, 8630, 16055, 8628, 16057, 8626, 16059, 8624, 16061, 8622, 16063, 8620, 16065, 8618, 16067, 8616, 16069, 8614, 16071, 8612, 16073, 8610, 16075, 8608, 16077, 8606, 16079, 8604, 16081, 8602, 16083, 8600, 16085, 8598, 16087, 8596, 16089, 8594, 16091, 8592, 16093, 8590, 16095, 8588, 16097, 8586, 16099, 8584, 16101, 8582, 16103, 8580, 16105, 8578, 16107, 8576, 16109, 8574, 16111, 8572, 16113, 8570, 16115, 8568, 16117, 8566, 16119, 8564, 16121, 8562, 16123, 8560, 16125, 8558, 16127, 8556, 16129, 8554, 16131, 8552, 16133, 8550, 16135, 8548, 16137, 8546, 16139, 8544, 16141, 8542, 16143, 8540, 16145, 8538, 16147, 8536, 16149, 8534, 16151, 8532, 16153, 8530, 16155, 8528, 16157, 8526, 16159, 8524, 16161, 8522, 16163, 8520, 16165, 8518, 16167, 8516, 16169, 8514, 16171, 8512, 16173, 8510, 16175, 8508, 16177, 8506, 16179, 8504, 16181, 8502, 16183, 8500, 16185, 8498, 16187, 8496, 16189, 8494, 16191, 8492, 16193, 8490, 16195, 8488, 16197, 8486, 16199, 8484, 16201, 8482, 16203, 8480, 16205, 8478, 16207, 8476, 16209, 8474, 16211, 8472, 16213, 8470, 16215, 8468, 16217, 8466, 16219, 8464, 16221, 8462, 16223, 8460, 16225, 8458, 16227, 8456, 16229, 8454, 16231, 8452, 16233, 8450, 16235, 8448, 16237, 8446, 16239, 8444, 16241, 8442, 16243, 8440, 16245, 8438, 16247, 8436, 16249, 8434, 16251, 8432, 16253, 8430, 16255, 8428, 16257, 8426, 16259, 8424, 16261, 8422, 16263, 8420, 16265, 8418, 16267, 8416, 16269, 8414, 16271, 8412, 16273, 8410, 16275, 8408, 16277, 8406, 16279, 8404, 16281, 8402, 16283, 8400, 16285, 8398, 16287, 8396, 16289, 8394, 16291, 8392, 16293, 8390, 16295, 8388, 16297, 8386, 16299, 8384, 16301, 8382, 16303, 8380, 16305, 8378, 16307, 8376, 16309, 8374, 16311, 8372, 16313, 8370, 16315, 8368, 16317, 8366, 16319, 8364, 16321, 8362, 16323, 8360, 16325, 8358, 16327, 8356, 16329, 8354, 16331, 8352, 16333, 8350, 16335, 8348, 16337, 8346, 16339, 8344, 16341, 8342, 16343, 8340, 16345, 8338, 16347, 8336, 16349, 8334, 16351, 8332, 16353, 8330, 16355, 8328, 16357, 8326, 16359, 8324, 16361, 8322, 16363, 8320, 16365, 8318, 16367, 8316, 16369, 8314, 16371, 8312, 16373, 8310, 16375, 8308, 16377, 8306, 16379, 8304, 16381, 8302, 16383, 8300, 16385, 8298, 16387, 8296, 16389, 8294, 16391, 8292, 16393, 8290, 16395, 8288, 16397, 8286, 16399, 8284, 16401, 8282, 16403, 8280, 16405, 8278, 16407, 8276, 16409, 8274, 16411, 8272, 16413, 8270, 16415, 8268, 16417, 8266, 16419, 8264, 16421, 8262, 16423, 8260, 16425, 8258, 16427, 8256, 16429, 8254, 16431, 8252, 16433, 8250, 16435, 8248, 16437, 8246, 16439, 8244, 16441, 8242, 16443, 8240, 16445, 8238, 16447, 8236, 16449, 8234, 16451, 8232, 16453, 8230, 16455, 8228, 16457, 8226, 16459, 8224, 16461, 8222, 16463, 8220, 16465, 8218, 16467, 8216, 16469, 8214, 16471, 8212, 16473, 8210, 16475, 8208, 16477, 8206, 16479, 8204, 16481, 8202, 16483, 8200, 16485, 8198, 16487, 8196, 16489, 8194, 16491, 8192, 16493, 8190, 16495, 8188, 16497, 8186, 16499, 8184, 16501, 8182, 16503, 8180, 16505, 8178, 16507, 8176, 16509, 8174, 16511, 8172, 16513, 8170, 16515, 8168, 16517, 8166, 16519, 8164, 16521, 8162, 16523, 8160, 16525, 8158, 16527, 8156, 16529, 8154, 16531, 8152, 16533, 8150, 16535, 8148, 16537, 8146, 16539, 8144, 16541, 8142, 16543, 8140, 16545, 8138, 16547, 8136, 16549, 8134, 16551, 8132, 16553, 8130, 16555, 8128, 16557, 8126, 16559, 8124, 16561, 8122, 16563, 8120, 16565, 8118, 16567, 8116, 16569, 8114, 16571, 8112, 16573, 8110, 16575, 8108, 16577, 8106, 16579, 8104, 16581, 8102, 16583, 8100, 16585, 8098, 16587, 8096, 16589, 8094, 16591, 8092, 16593, 8090, 16595, 8088, 16597, 8086, 16599, 8084, 16601, 8082, 16603, 8080, 16605, 8078, 16607, 8076, 16609, 8074, 16611, 8072, 16613, 8070, 16615, 8068, 16617, 8066, 16619, 8064, 16621, 8062, 16623, 8060, 16625, 8058, 16627, 8056, 16629, 8054, 16631, 8052, 16633, 8050, 16635, 8048, 16637, 8046, 16639, 8044, 16641, 8042, 16643, 8040, 16645, 8038, 16647, 8036, 16649, 8034, 16651, 8032, 16653, 8030, 16655, 8028, 16657, 8026, 16659, 8024, 16661, 8022, 16663, 8020, 16665, 8018, 16667, 8016, 16669, 8014, 16671, 8012, 16673, 8010, 16675, 8008, 16677, 8006, 16679, 8004, 16681, 8002, 16683, 8000, 16685, 7998, 16687, 7996, 16689, 7994, 16691, 7992, 16693, 7990, 16695, 7988, 16697, 7986, 16699, 7984, 16701, 7982, 16703, 7980, 16705, 7978, 16707, 7976, 16709, 7974, 16711, 7972, 16713, 7970, 16715, 7968, 16717, 7966, 16719, 7964, 16721, 7962, 16723, 7960, 16725, 7958, 16727, 7956, 16729, 7954, 16731, 7952, 16733, 7950, 16735, 7948, 16737, 7946, 16739, 7944, 16741, 7942, 16743, 7940, 16745, 7938, 16747, 7936, 16749, 7934, 16751, 7932, 16753, 7930, 16755, 7928, 16757, 7926, 16759, 7924, 16761, 7922, 16763, 7920, 16765, 7918, 16767, 7916, 16769, 7914, 16771, 7912, 16773, 7910, 16775, 7908, 16777, 7906, 16779, 7904, 16781, 7902, 16783, 7900, 16785, 7898, 16787, 7896, 16789, 7894, 16791, 7892, 16793, 7890, 16795, 7888, 16797, 7886, 16799, 7884, 16801, 7882, 16803, 7880, 16805, 7878, 16807, 7876, 16809, 7874, 16811, 7872, 16813, 7870, 16815, 7868, 16817, 7866, 16819, 7864, 16821, 7862, 16823, 7860, 16825, 7858, 16827, 7856, 16829, 7854, 16831, 7852, 16833, 7850, 16835, 7848, 16837, 7846, 16839, 7844, 16841, 7842, 16843, 7840, 16845, 7838, 16847, 7836, 16849, 7834, 16851, 7832, 16853, 7830, 16855, 7828, 16857, 7826, 16859, 7824, 16861, 7822, 16863, 7820, 16865, 7818, 16867, 7816, 16869, 7814, 16871, 7812, 16873, 7810, 16875, 7808, 16877, 7806, 16879, 7804, 16881, 7802, 16883, 7800, 16885, 7798, 16887, 7796, 16889, 7794, 16891, 7792, 16893, 7790, 16895, 7788, 16897, 7786, 16899, 7784, 16901, 7782, 16903, 7780, 16905, 7778, 16907, 7776, 16909, 7774, 16911, 7772, 16913, 7770, 16915, 7768, 16917, 7766, 16919, 7764, 16921, 7762, 16923, 7760, 16925, 7758, 16927, 7756, 16929, 7754, 16931, 7752, 16933, 7750, 16935, 7748, 16937, 7746, 16939, 7744, 16941, 7742, 16943, 7740, 16945, 7738, 16947, 7736, 16949, 7734, 16951, 7732, 16953, 7730, 16955, 7728, 16957, 7726, 16959, 7724, 16961, 7722, 16963, 7720, 16965, 7718, 16967, 7716, 16969, 7714, 16971, 7712, 16973, 7710, 16975, 7708, 16977, 7706, 16979, 7704, 16981, 7702, 16983, 7700, 16985, 7698, 16987, 7696, 16989, 7694, 16991, 7692, 16993, 7690, 16995, 7688, 16997, 7686, 16999, 7684, 17001, 7682, 17003, 7680, 17005, 7678, 17007, 7676, 17009, 7674, 17011, 7672, 17013, 7670, 17015, 7668, 17017, 7666, 17019, 7664, 17021, 7662, 17023, 7660, 17025, 7658, 17027, 7656, 17029, 7654, 17031, 7652, 17033, 7650, 17035, 7648, 17037, 7646, 17039, 7644, 17041, 7642, 17043, 7640, 17045, 7638, 17047, 7636, 17049, 7634, 17051, 7632, 17053, 7630, 17055, 7628, 17057, 7626, 17059, 7624, 17061, 7622, 17063, 7620, 17065, 7618, 17067, 7616, 17069, 7614, 17071, 7612, 17073, 7610, 17075, 7608, 17077, 7606, 17079, 7604, 17081, 7602, 17083, 7600, 17085, 7598, 17087, 7596, 17089, 7594, 17091, 7592, 17093, 7590, 17095, 7588, 17097, 7586, 17099, 7584, 17101, 7582, 17103, 7580, 17105, 7578, 17107, 7576, 17109, 7574, 17111, 7572, 17113, 7570, 17115, 7568, 17117, 7566, 17119, 7564, 17121, 7562, 17123, 7560, 17125, 7558, 17127, 7556, 17129, 7554, 17131, 7552, 17133, 7550, 17135, 7548, 17137, 7546, 17139, 7544, 17141, 7542, 17143, 7540, 17145, 7538, 17147, 7536, 17149, 7534, 17151, 7532, 17153, 7530, 17155, 7528, 17157, 7526, 17159, 7524, 17161, 7522, 17163, 7520, 17165, 7518, 17167, 7516, 17169, 7514, 17171, 7512, 17173, 7510, 17175, 7508, 17177, 7506, 17179, 7504, 17181, 7502, 17183, 7500, 17185, 7498, 17187, 7496, 17189, 7494, 17191, 7492, 17193, 7490, 17195, 7488, 17197, 7486, 17199, 7484, 17201, 7482, 17203, 7480, 17205, 7478, 17207, 7476, 17209, 7474, 17211, 7472, 17213, 7470, 17215, 7468, 17217, 7466, 17219, 7464, 17221, 7462, 17223, 7460, 17225, 7458, 17227, 7456, 17229, 7454, 17231, 7452, 17233, 7450, 17235, 7448, 17237, 7446, 17239, 7444, 17241, 7442, 17243, 7440, 17245, 7438, 17247, 7436, 17249, 7434, 17251, 7432, 17253, 7430, 17255, 7428, 17257, 7426, 17259, 7424, 17261, 7422, 17263, 7420, 17265, 7418, 17267, 7416, 17269, 7414, 17271, 7412, 17273, 7410, 17275, 7408, 17277, 7406, 17279, 7404, 17281, 7402, 17283, 7400, 17285, 7398, 17287, 7396, 17289, 7394, 17291, 7392, 17293, 7390, 17295, 7388, 17297, 7386, 17299, 7384, 17301, 7382, 17303, 7380, 17305, 7378, 17307, 7376, 17309, 7374, 17311, 7372, 17313, 7370, 17315, 7368, 17317, 7366, 17319, 7364, 17321, 7362, 17323, 7360, 17325, 7358, 17327, 7356, 17329, 7354, 17331, 7352, 17333, 7350, 17335, 7348, 17337, 7346, 17339, 7344, 17341, 7342, 17343, 7340, 17345, 7338, 17347, 7336, 17349, 7334, 17351, 7332, 17353, 7330, 17355, 7328, 17357, 7326, 17359, 7324, 17361, 7322, 17363, 7320, 17365, 7318, 17367, 7316, 17369, 7314, 17371, 7312, 17373, 7310, 17375, 7308, 17377, 7306, 17379, 7304, 17381, 7302, 17383, 7300, 17385, 7298, 17387, 7296, 17389, 7294, 17391, 7292, 17393, 7290, 17395, 7288, 17397, 7286, 17399, 7284, 17401, 7282, 17403, 7280, 17405, 7278, 17407, 7276, 17409, 7274, 17411, 7272, 17413, 7270, 17415, 7268, 17417, 7266, 17419, 7264, 17421, 7262, 17423, 7260, 17425, 7258, 17427, 7256, 17429, 7254, 17431, 7252, 17433, 7250, 17435, 7248, 17437, 7246, 17439, 7244, 17441, 7242, 17443, 7240, 17445, 7238, 17447, 7236, 17449, 7234, 17451, 7232, 17453, 7230, 17455, 7228, 17457, 7226, 17459, 7224, 17461, 7222, 17463, 7220, 17465, 7218, 17467, 7216, 17469, 7214, 17471, 7212, 17473, 7210, 17475, 7208, 17477, 7206, 17479, 7204, 17481, 7202, 17483, 7200, 17485, 7198, 17487, 7196, 17489, 7194, 17491, 7192, 17493, 7190, 17495, 7188, 17497, 7186, 17499, 7184, 17501, 7182, 17503, 7180, 17505, 7178, 17507, 7176, 17509, 7174, 17511, 7172, 17513, 7170, 17515, 7168, 17517, 7166, 17519, 7164, 17521, 7162, 17523, 7160, 17525, 7158, 17527, 7156, 17529, 7154, 17531, 7152, 17533, 7150, 17535, 7148, 17537, 7146, 17539, 7144, 17541, 7142, 17543, 7140, 17545, 7138, 17547, 7136, 17549, 7134, 17551, 7132, 17553, 7130, 17555, 7128, 17557, 7126, 17559, 7124, 17561, 7122, 17563, 7120, 17565, 7118, 17567, 7116, 17569, 7114, 17571, 7112, 17573, 7110, 17575, 7108, 17577, 7106, 17579, 7104, 17581, 7102, 17583, 7100, 17585, 7098, 17587, 7096, 17589, 7094, 17591, 7092, 17593, 7090, 17595, 7088, 17597, 7086, 17599, 7084, 17601, 7082, 17603, 7080, 17605, 7078, 17607, 7076, 17609, 7074, 17611, 7072, 17613, 7070, 17615, 7068, 17617, 7066, 17619, 7064, 17621, 7062, 17623, 7060, 17625, 7058, 17627, 7056, 17629, 7054, 17631, 7052, 17633, 7050, 17635, 7048, 17637, 7046, 17639, 7044, 17641, 7042, 17643, 7040, 17645, 7038, 17647, 7036, 17649, 7034, 17651, 7032, 17653, 7030, 17655, 7028, 17657, 7026, 17659, 7024, 17661, 7022, 17663, 7020, 17665, 7018, 17667, 7016, 17669, 7014, 17671, 7012, 17673, 7010, 17675, 7008, 17677, 7006, 17679, 7004, 17681, 7002, 17683, 7000, 17685, 6998, 17687, 6996, 17689, 6994, 17691, 6992, 17693, 6990, 17695, 6988, 17697, 6986, 17699, 6984, 17701, 6982, 17703, 6980, 17705, 6978, 17707, 6976, 17709, 6974, 17711, 6972, 17713, 6970, 17715, 6968, 17717, 6966, 17719, 6964, 17721, 6962, 17723, 6960, 17725, 6958, 17727, 6956, 17729, 6954, 17731, 6952, 17733, 6950, 17735, 6948, 17737, 6946, 17739, 6944, 17741, 6942, 17743, 6940, 17745, 6938, 17747, 6936, 17749, 6934, 17751, 6932, 17753, 6930, 17755, 6928, 17757, 6926, 17759, 6924, 17761, 6922, 17763, 6920, 17765, 6918, 17767, 6916, 17769, 6914, 17771, 6912, 17773, 6910, 17775, 6908, 17777, 6906, 17779, 6904, 17781, 6902, 17783, 6900, 17785, 6898, 17787, 6896, 17789, 6894, 17791, 6892, 17793, 6890, 17795, 6888, 17797, 6886, 17799, 6884, 17801, 6882, 17803, 6880, 17805, 6878, 17807, 6876, 17809, 6874, 17811, 6872, 17813, 6870, 17815, 6868, 17817, 6866, 17819, 6864, 17821, 6862, 17823, 6860, 17825, 6858, 17827, 6856, 17829, 6854, 17831, 6852, 17833, 6850, 17835, 6848, 17837, 6846, 17839, 6844, 17841, 6842, 17843, 6840, 17845, 6838, 17847, 6836, 17849, 6834, 17851, 6832, 17853, 6830, 17855, 6828, 17857, 6826, 17859, 6824, 17861, 6822, 17863, 6820, 17865, 6818, 17867, 6816, 17869, 6814, 17871, 6812, 17873, 6810, 17875, 6808, 17877, 6806, 17879, 6804, 17881, 6802, 17883, 6800, 17885, 6798, 17887, 6796, 17889, 6794, 17891, 6792, 17893, 6790, 17895, 6788, 17897, 6786, 17899, 6784, 17901, 6782, 17903, 6780, 17905, 6778, 17907, 6776, 17909, 6774, 17911, 6772, 17913, 6770, 17915, 6768, 17917, 6766, 17919, 6764, 17921, 6762, 17923, 6760, 17925, 6758, 17927, 6756, 17929, 6754, 17931, 6752, 17933, 6750, 17935, 6748, 17937, 6746, 17939, 6744, 17941, 6742, 17943, 6740, 17945, 6738, 17947, 6736, 17949, 6734, 17951, 6732, 17953, 6730, 17955, 6728, 17957, 6726, 17959, 6724, 17961, 6722, 17963, 6720, 17965, 6718, 17967, 6716, 17969, 6714, 17971, 6712, 17973, 6710, 17975, 6708, 17977, 6706, 17979, 6704, 17981, 6702, 17983, 6700, 17985, 6698, 17987, 6696, 17989, 6694, 17991, 6692, 17993, 6690, 17995, 6688, 17997, 6686, 17999, 6684, 18001, 6682, 18003, 6680, 18005, 6678, 18007, 6676, 18009, 6674, 18011, 6672, 18013, 6670, 18015, 6668, 18017, 6666, 18019, 6664, 18021, 6662, 18023, 6660, 18025, 6658, 18027, 6656, 18029, 6654, 18031, 6652, 18033, 6650, 18035, 6648, 18037, 6646, 18039, 6644, 18041, 6642, 18043, 6640, 18045, 6638, 18047, 6636, 18049, 6634, 18051, 6632, 18053, 6630, 18055, 6628, 18057, 6626, 18059, 6624, 18061, 6622, 18063, 6620, 18065, 6618, 18067, 6616, 18069, 6614, 18071, 6612, 18073, 6610, 18075, 6608, 18077, 6606, 18079, 6604, 18081, 6602, 18083, 6600, 18085, 6598, 18087, 6596, 18089, 6594, 18091, 6592, 18093, 6590, 18095, 6588, 18097, 6586, 18099, 6584, 18101, 6582, 18103, 6580, 18105, 6578, 18107, 6576, 18109, 6574, 18111, 6572, 18113, 6570, 18115, 6568, 18117, 6566, 18119, 6564, 18121, 6562, 18123, 6560, 18125, 6558, 18127, 6556, 18129, 6554, 18131, 6552, 18133, 6550, 18135, 6548, 18137, 6546, 18139, 6544, 18141, 6542, 18143, 6540, 18145, 6538, 18147, 6536, 18149, 6534, 18151, 6532, 18153, 6530, 18155, 6528, 18157, 6526, 18159, 6524, 18161, 6522, 18163, 6520, 18165, 6518, 18167, 6516, 18169, 6514, 18171, 6512, 18173, 6510, 18175, 6508, 18177, 6506, 18179, 6504, 18181, 6502, 18183, 6500, 18185, 6498, 18187, 6496, 18189, 6494, 18191, 6492, 18193, 6490, 18195, 6488, 18197, 6486, 18199, 6484, 18201, 6482, 18203, 6480, 18205, 6478, 18207, 6476, 18209, 6474, 18211, 6472, 18213, 6470, 18215, 6468, 18217, 6466, 18219, 6464, 18221, 6462, 18223, 6460, 18225, 6458, 18227, 6456, 18229, 6454, 18231, 6452, 18233, 6450, 18235, 6448, 18237, 6446, 18239, 6444, 18241, 6442, 18243, 6440, 18245, 6438, 18247, 6436, 18249, 6434, 18251, 6432, 18253, 6430, 18255, 6428, 18257, 6426, 18259, 6424, 18261, 6422, 18263, 6420, 18265, 6418, 18267, 6416, 18269, 6414, 18271, 6412, 18273, 6410, 18275, 6408, 18277, 6406, 18279, 6404, 18281, 6402, 18283, 6400, 18285, 6398, 18287, 6396, 18289, 6394, 18291, 6392, 18293, 6390, 18295, 6388, 18297, 6386, 18299, 6384, 18301, 6382, 18303, 6380, 18305, 6378, 18307, 6376, 18309, 6374, 18311, 6372, 18313, 6370, 18315, 6368, 18317, 6366, 18319, 6364, 18321, 6362, 18323, 6360, 18325, 6358, 18327, 6356, 18329, 6354, 18331, 6352, 18333, 6350, 18335, 6348, 18337, 6346, 18339, 6344, 18341, 6342, 18343, 6340, 18345, 6338, 18347, 6336, 18349, 6334, 18351, 6332, 18353, 6330, 18355, 6328, 18357, 6326, 18359, 6324, 18361, 6322, 18363, 6320, 18365, 6318, 18367, 6316, 18369, 6314, 18371, 6312, 18373, 6310, 18375, 6308, 18377, 6306, 18379, 6304, 18381, 6302, 18383, 6300, 18385, 6298, 18387, 6296, 18389, 6294, 18391, 6292, 18393, 6290, 18395, 6288, 18397, 6286, 18399, 6284, 18401, 6282, 18403, 6280, 18405, 6278, 18407, 6276, 18409, 6274, 18411, 6272, 18413, 6270, 18415, 6268, 18417, 6266, 18419, 6264, 18421, 6262, 18423, 6260, 18425, 6258, 18427, 6256, 18429, 6254, 18431, 6252, 18433, 6250, 18435, 6248, 18437, 6246, 18439, 6244, 18441, 6242, 18443, 6240, 18445, 6238, 18447, 6236, 18449, 6234, 18451, 6232, 18453, 6230, 18455, 6228, 18457, 6226, 18459, 6224, 18461, 6222, 18463, 6220, 18465, 6218, 18467, 6216, 18469, 6214, 18471, 6212, 18473, 6210, 18475, 6208, 18477, 6206, 18479, 6204, 18481, 6202, 18483, 6200, 18485, 6198, 18487, 6196, 18489, 6194, 18491, 6192, 18493, 6190, 18495, 6188, 18497, 6186, 18499, 6184, 18501, 6182, 18503, 6180, 18505, 6178, 18507, 6176, 18509, 6174, 18511, 6172, 18513, 6170, 18515, 6168, 18517, 6166, 18519, 6164, 18521, 6162, 18523, 6160, 18525, 6158, 18527, 6156, 18529, 6154, 18531, 6152, 18533, 6150, 18535, 6148, 18537, 6146, 18539, 6144, 18541, 6142, 18543, 6140, 18545, 6138, 18547, 6136, 18549, 6134, 18551, 6132, 18553, 6130, 18555, 6128, 18557, 6126, 18559, 6124, 18561, 6122, 18563, 6120, 18565, 6118, 18567, 6116, 18569, 6114, 18571, 6112, 18573, 6110, 18575, 6108, 18577, 6106, 18579, 6104, 18581, 6102, 18583, 6100, 18585, 6098, 18587, 6096, 18589, 6094, 18591, 6092, 18593, 6090, 18595, 6088, 18597, 6086, 18599, 6084, 18601, 6082, 18603, 6080, 18605, 6078, 18607, 6076, 18609, 6074, 18611, 6072, 18613, 6070, 18615, 6068, 18617, 6066, 18619, 6064, 18621, 6062, 18623, 6060, 18625, 6058, 18627, 6056, 18629, 6054, 18631, 6052, 18633, 6050, 18635, 6048, 18637, 6046, 18639, 6044, 18641, 6042, 18643, 6040, 18645, 6038, 18647, 6036, 18649, 6034, 18651, 6032, 18653, 6030, 18655, 6028, 18657, 6026, 18659, 6024, 18661, 6022, 18663, 6020, 18665, 6018, 18667, 6016, 18669, 6014, 18671, 6012, 18673, 6010, 18675, 6008, 18677, 6006, 18679, 6004, 18681, 6002, 18683, 6000, 18685, 5998, 18687, 5996, 18689, 5994, 18691, 5992, 18693, 5990, 18695, 5988, 18697, 5986, 18699, 5984, 18701, 5982, 18703, 5980, 18705, 5978, 18707, 5976, 18709, 5974, 18711, 5972, 18713, 5970, 18715, 5968, 18717, 5966, 18719, 5964, 18721, 5962, 18723, 5960, 18725, 5958, 18727, 5956, 18729, 5954, 18731, 5952, 18733, 5950, 18735, 5948, 18737, 5946, 18739, 5944, 18741, 5942, 18743, 5940, 18745, 5938, 18747, 5936, 18749, 5934, 18751, 5932, 18753, 5930, 18755, 5928, 18757, 5926, 18759, 5924, 18761, 5922, 18763, 5920, 18765, 5918, 18767, 5916, 18769, 5914, 18771, 5912, 18773, 5910, 18775, 5908, 18777, 5906, 18779, 5904, 18781, 5902, 18783, 5900, 18785, 5898, 18787, 5896, 18789, 5894, 18791, 5892, 18793, 5890, 18795, 5888, 18797, 5886, 18799, 5884, 18801, 5882, 18803, 5880, 18805, 5878, 18807, 5876, 18809, 5874, 18811, 5872, 18813, 5870, 18815, 5868, 18817, 5866, 18819, 5864, 18821, 5862, 18823, 5860, 18825, 5858, 18827, 5856, 18829, 5854, 18831, 5852, 18833, 5850, 18835, 5848, 18837, 5846, 18839, 5844, 18841, 5842, 18843, 5840, 18845, 5838, 18847, 5836, 18849, 5834, 18851, 5832, 18853, 5830, 18855, 5828, 18857, 5826, 18859, 5824, 18861, 5822, 18863, 5820, 18865, 5818, 18867, 5816, 18869, 5814, 18871, 5812, 18873, 5810, 18875, 5808, 18877, 5806, 18879, 5804, 18881, 5802, 18883, 5800, 18885, 5798, 18887, 5796, 18889, 5794, 18891, 5792, 18893, 5790, 18895, 5788, 18897, 5786, 18899, 5784, 18901, 5782, 18903, 5780, 18905, 5778, 18907, 5776, 18909, 5774, 18911, 5772, 18913, 5770, 18915, 5768, 18917, 5766, 18919, 5764, 18921, 5762, 18923, 5760, 18925, 5758, 18927, 5756, 18929, 5754, 18931, 5752, 18933, 5750, 18935, 5748, 18937, 5746, 18939, 5744, 18941, 5742, 18943, 5740, 18945, 5738, 18947, 5736, 18949, 5734, 18951, 5732, 18953, 5730, 18955, 5728, 18957, 5726, 18959, 5724, 18961, 5722, 18963, 5720, 18965, 5718, 18967, 5716, 18969, 5714, 18971, 5712, 18973, 5710, 18975, 5708, 18977, 5706, 18979, 5704, 18981, 5702, 18983, 5700, 18985, 5698, 18987, 5696, 18989, 5694, 18991, 5692, 18993, 5690, 18995, 5688, 18997, 5686, 18999, 5684, 19001, 5682, 19003, 5680, 19005, 5678, 19007, 5676, 19009, 5674, 19011, 5672, 19013, 5670, 19015, 5668, 19017, 5666, 19019, 5664, 19021, 5662, 19023, 5660, 19025, 5658, 19027, 5656, 19029, 5654, 19031, 5652, 19033, 5650, 19035, 5648, 19037, 5646, 19039, 5644, 19041, 5642, 19043, 5640, 19045, 5638, 19047, 5636, 19049, 5634, 19051, 5632, 19053, 5630, 19055, 5628, 19057, 5626, 19059, 5624, 19061, 5622, 19063, 5620, 19065, 5618, 19067, 5616, 19069, 5614, 19071, 5612, 19073, 5610, 19075, 5608, 19077, 5606, 19079, 5604, 19081, 5602, 19083, 5600, 19085, 5598, 19087, 5596, 19089, 5594, 19091, 5592, 19093, 5590, 19095, 5588, 19097, 5586, 19099, 5584, 19101, 5582, 19103, 5580, 19105, 5578, 19107, 5576, 19109, 5574, 19111, 5572, 19113, 5570, 19115, 5568, 19117, 5566, 19119, 5564, 19121, 5562, 19123, 5560, 19125, 5558, 19127, 5556, 19129, 5554, 19131, 5552, 19133, 5550, 19135, 5548, 19137, 5546, 19139, 5544, 19141, 5542, 19143, 5540, 19145, 5538, 19147, 5536, 19149, 5534, 19151, 5532, 19153, 5530, 19155, 5528, 19157, 5526, 19159, 5524, 19161, 5522, 19163, 5520, 19165, 5518, 19167, 5516, 19169, 5514, 19171, 5512, 19173, 5510, 19175, 5508, 19177, 5506, 19179, 5504, 19181, 5502, 19183, 5500, 19185, 5498, 19187, 5496, 19189, 5494, 19191, 5492, 19193, 5490, 19195, 5488, 19197, 5486, 19199, 5484, 19201, 5482, 19203, 5480, 19205, 5478, 19207, 5476, 19209, 5474, 19211, 5472, 19213, 5470, 19215, 5468, 19217, 5466, 19219, 5464, 19221, 5462, 19223, 5460, 19225, 5458, 19227, 5456, 19229, 5454, 19231, 5452, 19233, 5450, 19235, 5448, 19237, 5446, 19239, 5444, 19241, 5442, 19243, 5440, 19245, 5438, 19247, 5436, 19249, 5434, 19251, 5432, 19253, 5430, 19255, 5428, 19257, 5426, 19259, 5424, 19261, 5422, 19263, 5420, 19265, 5418, 19267, 5416, 19269, 5414, 19271, 5412, 19273, 5410, 19275, 5408, 19277, 5406, 19279, 5404, 19281, 5402, 19283, 5400, 19285, 5398, 19287, 5396, 19289, 5394, 19291, 5392, 19293, 5390, 19295, 5388, 19297, 5386, 19299, 5384, 19301, 5382, 19303, 5380, 19305, 5378, 19307, 5376, 19309, 5374, 19311, 5372, 19313, 5370, 19315, 5368, 19317, 5366, 19319, 5364, 19321, 5362, 19323, 5360, 19325, 5358, 19327, 5356, 19329, 5354, 19331, 5352, 19333, 5350, 19335, 5348, 19337, 5346, 19339, 5344, 19341, 5342, 19343, 5340, 19345, 5338, 19347, 5336, 19349, 5334, 19351, 5332, 19353, 5330, 19355, 5328, 19357, 5326, 19359, 5324, 19361, 5322, 19363, 5320, 19365, 5318, 19367, 5316, 19369, 5314, 19371, 5312, 19373, 5310, 19375, 5308, 19377, 5306, 19379, 5304, 19381, 5302, 19383, 5300, 19385, 5298, 19387, 5296, 19389, 5294, 19391, 5292, 19393, 5290, 19395, 5288, 19397, 5286, 19399, 5284, 19401, 5282, 19403, 5280, 19405, 5278, 19407, 5276, 19409, 5274, 19411, 5272, 19413, 5270, 19415, 5268, 19417, 5266, 19419, 5264, 19421, 5262, 19423, 5260, 19425, 5258, 19427, 5256, 19429, 5254, 19431, 5252, 19433, 5250, 19435, 5248, 19437, 5246, 19439, 5244, 19441, 5242, 19443, 5240, 19445, 5238, 19447, 5236, 19449, 5234, 19451, 5232, 19453, 5230, 19455, 5228, 19457, 5226, 19459, 5224, 19461, 5222, 19463, 5220, 19465, 5218, 19467, 5216, 19469, 5214, 19471, 5212, 19473, 5210, 19475, 5208, 19477, 5206, 19479, 5204, 19481, 5202, 19483, 5200, 19485, 5198, 19487, 5196, 19489, 5194, 19491, 5192, 19493, 5190, 19495, 5188, 19497, 5186, 19499, 5184, 19501, 5182, 19503, 5180, 19505, 5178, 19507, 5176, 19509, 5174, 19511, 5172, 19513, 5170, 19515, 5168, 19517, 5166, 19519, 5164, 19521, 5162, 19523, 5160, 19525, 5158, 19527, 5156, 19529, 5154, 19531, 5152, 19533, 5150, 19535, 5148, 19537, 5146, 19539, 5144, 19541, 5142, 19543, 5140, 19545, 5138, 19547, 5136, 19549, 5134, 19551, 5132, 19553, 5130, 19555, 5128, 19557, 5126, 19559, 5124, 19561, 5122, 19563, 5120, 19565, 5118, 19567, 5116, 19569, 5114, 19571, 5112, 19573, 5110, 19575, 5108, 19577, 5106, 19579, 5104, 19581, 5102, 19583, 5100, 19585, 5098, 19587, 5096, 19589, 5094, 19591, 5092, 19593, 5090, 19595, 5088, 19597, 5086, 19599, 5084, 19601, 5082, 19603, 5080, 19605, 5078, 19607, 5076, 19609, 5074, 19611, 5072, 19613, 5070, 19615, 5068, 19617, 5066, 19619, 5064, 19621, 5062, 19623, 5060, 19625, 5058, 19627, 5056, 19629, 5054, 19631, 5052, 19633, 5050, 19635, 5048, 19637, 5046, 19639, 5044, 19641, 5042, 19643, 5040, 19645, 5038, 19647, 5036, 19649, 5034, 19651, 5032, 19653, 5030, 19655, 5028, 19657, 5026, 19659, 5024, 19661, 5022, 19663, 5020, 19665, 5018, 19667, 5016, 19669, 5014, 19671, 5012, 19673, 5010, 19675, 5008, 19677, 5006, 19679, 5004, 19681, 5002, 19683, 5000, 19685, 4998, 19687, 4996, 19689, 4994, 19691, 4992, 19693, 4990, 19695, 4988, 19697, 4986, 19699, 4984, 19701, 4982, 19703, 4980, 19705, 4978, 19707, 4976, 19709, 4974, 19711, 4972, 19713, 4970, 19715, 4968, 19717, 4966, 19719, 4964, 19721, 4962, 19723, 4960, 19725, 4958, 19727, 4956, 19729, 4954, 19731, 4952, 19733, 4950, 19735, 4948, 19737, 4946, 19739, 4944, 19741, 4942, 19743, 4940, 19745, 4938, 19747, 4936, 19749, 4934, 19751, 4932, 19753, 4930, 19755, 4928, 19757, 4926, 19759, 4924, 19761, 4922, 19763, 4920, 19765, 4918, 19767, 4916, 19769, 4914, 19771, 4912, 19773, 4910, 19775, 4908, 19777, 4906, 19779, 4904, 19781, 4902, 19783, 4900, 19785, 4898, 19787, 4896, 19789, 4894, 19791, 4892, 19793, 4890, 19795, 4888, 19797, 4886, 19799, 4884, 19801, 4882, 19803, 4880, 19805, 4878, 19807, 4876, 19809, 4874, 19811, 4872, 19813, 4870, 19815, 4868, 19817, 4866, 19819, 4864, 19821, 4862, 19823, 4860, 19825, 4858, 19827, 4856, 19829, 4854, 19831, 4852, 19833, 4850, 19835, 4848, 19837, 4846, 19839, 4844, 19841, 4842, 19843, 4840, 19845, 4838, 19847, 4836, 19849, 4834, 19851, 4832, 19853, 4830, 19855, 4828, 19857, 4826, 19859, 4824, 19861, 4822, 19863, 4820, 19865, 4818, 19867, 4816, 19869, 4814, 19871, 4812, 19873, 4810, 19875, 4808, 19877, 4806, 19879, 4804, 19881, 4802, 19883, 4800, 19885, 4798, 19887, 4796, 19889, 4794, 19891, 4792, 19893, 4790, 19895, 4788, 19897, 4786, 19899, 4784, 19901, 4782, 19903, 4780, 19905, 4778, 19907, 4776, 19909, 4774, 19911, 4772, 19913, 4770, 19915, 4768, 19917, 4766, 19919, 4764, 19921, 4762, 19923, 4760, 19925, 4758, 19927, 4756, 19929, 4754, 19931, 4752, 19933, 4750, 19935, 4748, 19937, 4746, 19939, 4744, 19941, 4742, 19943, 4740, 19945, 4738, 19947, 4736, 19949, 4734, 19951, 4732, 19953, 4730, 19955, 4728, 19957, 4726, 19959, 4724, 19961, 4722, 19963, 4720, 19965, 4718, 19967, 4716, 19969, 4714, 19971, 4712, 19973, 4710, 19975, 4708, 19977, 4706, 19979, 4704, 19981, 4702, 19983, 4700, 19985, 4698, 19987, 4696, 19989, 4694, 19991, 4692, 19993, 4690, 19995, 4688, 19997, 4686, 19999, 4684, 20001, 4682, 20003, 4680, 20005, 4678, 20007, 4676, 20009, 4674, 20011, 4672, 20013, 4670, 20015, 4668, 20017, 4666, 20019, 4664, 20021, 4662, 20023, 4660, 20025, 4658, 20027, 4656, 20029, 4654, 20031, 4652, 20033, 4650, 20035, 4648, 20037, 4646, 20039, 4644, 20041, 4642, 20043, 4640, 20045, 4638, 20047, 4636, 20049, 4634, 20051, 4632, 20053, 4630, 20055, 4628, 20057, 4626, 20059, 4624, 20061, 4622, 20063, 4620, 20065, 4618, 20067, 4616, 20069, 4614, 20071, 4612, 20073, 4610, 20075, 4608, 20077, 4606, 20079, 4604, 20081, 4602, 20083, 4600, 20085, 4598, 20087, 4596, 20089, 4594, 20091, 4592, 20093, 4590, 20095, 4588, 20097, 4586, 20099, 4584, 20101, 4582, 20103, 4580, 20105, 4578, 20107, 4576, 20109, 4574, 20111, 4572, 20113, 4570, 20115, 4568, 20117, 4566, 20119, 4564, 20121, 4562, 20123, 4560, 20125, 4558, 20127, 4556, 20129, 4554, 20131, 4552, 20133, 4550, 20135, 4548, 20137, 4546, 20139, 4544, 20141, 4542, 20143, 4540, 20145, 4538, 20147, 4536, 20149, 4534, 20151, 4532, 20153, 4530, 20155, 4528, 20157, 4526, 20159, 4524, 20161, 4522, 20163, 4520, 20165, 4518, 20167, 4516, 20169, 4514, 20171, 4512, 20173, 4510, 20175, 4508, 20177, 4506, 20179, 4504, 20181, 4502, 20183, 4500, 20185, 4498, 20187, 4496, 20189, 4494, 20191, 4492, 20193, 4490, 20195, 4488, 20197, 4486, 20199, 4484, 20201, 4482, 20203, 4480, 20205, 4478, 20207, 4476, 20209, 4474, 20211, 4472, 20213, 4470, 20215, 4468, 20217, 4466, 20219, 4464, 20221, 4462, 20223, 4460, 20225, 4458, 20227, 4456, 20229, 4454, 20231, 4452, 20233, 4450, 20235, 4448, 20237, 4446, 20239, 4444, 20241, 4442, 20243, 4440, 20245, 4438, 20247, 4436, 20249, 4434, 20251, 4432, 20253, 4430, 20255, 4428, 20257, 4426, 20259, 4424, 20261, 4422, 20263, 4420, 20265, 4418, 20267, 4416, 20269, 4414, 20271, 4412, 20273, 4410, 20275, 4408, 20277, 4406, 20279, 4404, 20281, 4402, 20283, 4400, 20285, 4398, 20287, 4396, 20289, 4394, 20291, 4392, 20293, 4390, 20295, 4388, 20297, 4386, 20299, 4384, 20301, 4382, 20303, 4380, 20305, 4378, 20307, 4376, 20309, 4374, 20311, 4372, 20313, 4370, 20315, 4368, 20317, 4366, 20319, 4364, 20321, 4362, 20323, 4360, 20325, 4358, 20327, 4356, 20329, 4354, 20331, 4352, 20333, 4350, 20335, 4348, 20337, 4346, 20339, 4344, 20341, 4342, 20343, 4340, 20345, 4338, 20347, 4336, 20349, 4334, 20351, 4332, 20353, 4330, 20355, 4328, 20357, 4326, 20359, 4324, 20361, 4322, 20363, 4320, 20365, 4318, 20367, 4316, 20369, 4314, 20371, 4312, 20373, 4310, 20375, 4308, 20377, 4306, 20379, 4304, 20381, 4302, 20383, 4300, 20385, 4298, 20387, 4296, 20389, 4294, 20391, 4292, 20393, 4290, 20395, 4288, 20397, 4286, 20399, 4284, 20401, 4282, 20403, 4280, 20405, 4278, 20407, 4276, 20409, 4274, 20411, 4272, 20413, 4270, 20415, 4268, 20417, 4266, 20419, 4264, 20421, 4262, 20423, 4260, 20425, 4258, 20427, 4256, 20429, 4254, 20431, 4252, 20433, 4250, 20435, 4248, 20437, 4246, 20439, 4244, 20441, 4242, 20443, 4240, 20445, 4238, 20447, 4236, 20449, 4234, 20451, 4232, 20453, 4230, 20455, 4228, 20457, 4226, 20459, 4224, 20461, 4222, 20463, 4220, 20465, 4218, 20467, 4216, 20469, 4214, 20471, 4212, 20473, 4210, 20475, 4208, 20477, 4206, 20479, 4204, 20481, 4202, 20483, 4200, 20485, 4198, 20487, 4196, 20489, 4194, 20491, 4192, 20493, 4190, 20495, 4188, 20497, 4186, 20499, 4184, 20501, 4182, 20503, 4180, 20505, 4178, 20507, 4176, 20509, 4174, 20511, 4172, 20513, 4170, 20515, 4168, 20517, 4166, 20519, 4164, 20521, 4162, 20523, 4160, 20525, 4158, 20527, 4156, 20529, 4154, 20531, 4152, 20533, 4150, 20535, 4148, 20537, 4146, 20539, 4144, 20541, 4142, 20543, 4140, 20545, 4138, 20547, 4136, 20549, 4134, 20551, 4132, 20553, 4130, 20555, 4128, 20557, 4126, 20559, 4124, 20561, 4122, 20563, 4120, 20565, 4118, 20567, 4116, 20569, 4114, 20571, 4112, 20573, 4110, 20575, 4108, 20577, 4106, 20579, 4104, 20581, 4102, 20583, 4100, 20585, 4098, 20587, 4096, 20589, 4094, 20591, 4092, 20593, 4090, 20595, 4088, 20597, 4086, 20599, 4084, 20601, 4082, 20603, 4080, 20605, 4078, 20607, 4076, 20609, 4074, 20611, 4072, 20613, 4070, 20615, 4068, 20617, 4066, 20619, 4064, 20621, 4062, 20623, 4060, 20625, 4058, 20627, 4056, 20629, 4054, 20631, 4052, 20633, 4050, 20635, 4048, 20637, 4046, 20639, 4044, 20641, 4042, 20643, 4040, 20645, 4038, 20647, 4036, 20649, 4034, 20651, 4032, 20653, 4030, 20655, 4028, 20657, 4026, 20659, 4024, 20661, 4022, 20663, 4020, 20665, 4018, 20667, 4016, 20669, 4014, 20671, 4012, 20673, 4010, 20675, 4008, 20677, 4006, 20679, 4004, 20681, 4002, 20683, 4000, 20685, 3998, 20687, 3996, 20689, 3994, 20691, 3992, 20693, 3990, 20695, 3988, 20697, 3986, 20699, 3984, 20701, 3982, 20703, 3980, 20705, 3978, 20707, 3976, 20709, 3974, 20711, 3972, 20713, 3970, 20715, 3968, 20717, 3966, 20719, 3964, 20721, 3962, 20723, 3960, 20725, 3958, 20727, 3956, 20729, 3954, 20731, 3952, 20733, 3950, 20735, 3948, 20737, 3946, 20739, 3944, 20741, 3942, 20743, 3940, 20745, 3938, 20747, 3936, 20749, 3934, 20751, 3932, 20753, 3930, 20755, 3928, 20757, 3926, 20759, 3924, 20761, 3922, 20763, 3920, 20765, 3918, 20767, 3916, 20769, 3914, 20771, 3912, 20773, 3910, 20775, 3908, 20777, 3906, 20779, 3904, 20781, 3902, 20783, 3900, 20785, 3898, 20787, 3896, 20789, 3894, 20791, 3892, 20793, 3890, 20795, 3888, 20797, 3886, 20799, 3884, 20801, 3882, 20803, 3880, 20805, 3878, 20807, 3876, 20809, 3874, 20811, 3872, 20813, 3870, 20815, 3868, 20817, 3866, 20819, 3864, 20821, 3862, 20823, 3860, 20825, 3858, 20827, 3856, 20829, 3854, 20831, 3852, 20833, 3850, 20835, 3848, 20837, 3846, 20839, 3844, 20841, 3842, 20843, 3840, 20845, 3838, 20847, 3836, 20849, 3834, 20851, 3832, 20853, 3830, 20855, 3828, 20857, 3826, 20859, 3824, 20861, 3822, 20863, 3820, 20865, 3818, 20867, 3816, 20869, 3814, 20871, 3812, 20873, 3810, 20875, 3808, 20877, 3806, 20879, 3804, 20881, 3802, 20883, 3800, 20885, 3798, 20887, 3796, 20889, 3794, 20891, 3792, 20893, 3790, 20895, 3788, 20897, 3786, 20899, 3784, 20901, 3782, 20903, 3780, 20905, 3778, 20907, 3776, 20909, 3774, 20911, 3772, 20913, 3770, 20915, 3768, 20917, 3766, 20919, 3764, 20921, 3762, 20923, 3760, 20925, 3758, 20927, 3756, 20929, 3754, 20931, 3752, 20933, 3750, 20935, 3748, 20937, 3746, 20939, 3744, 20941, 3742, 20943, 3740, 20945, 3738, 20947, 3736, 20949, 3734, 20951, 3732, 20953, 3730, 20955, 3728, 20957, 3726, 20959, 3724, 20961, 3722, 20963, 3720, 20965, 3718, 20967, 3716, 20969, 3714, 20971, 3712, 20973, 3710, 20975, 3708, 20977, 3706, 20979, 3704, 20981, 3702, 20983, 3700, 20985, 3698, 20987, 3696, 20989, 3694, 20991, 3692, 20993, 3690, 20995, 3688, 20997, 3686, 20999, 3684, 21001, 3682, 21003, 3680, 21005, 3678, 21007, 3676, 21009, 3674, 21011, 3672, 21013, 3670, 21015, 3668, 21017, 3666, 21019, 3664, 21021, 3662, 21023, 3660, 21025, 3658, 21027, 3656, 21029, 3654, 21031, 3652, 21033, 3650, 21035, 3648, 21037, 3646, 21039, 3644, 21041, 3642, 21043, 3640, 21045, 3638, 21047, 3636, 21049, 3634, 21051, 3632, 21053, 3630, 21055, 3628, 21057, 3626, 21059, 3624, 21061, 3622, 21063, 3620, 21065, 3618, 21067, 3616, 21069, 3614, 21071, 3612, 21073, 3610, 21075, 3608, 21077, 3606, 21079, 3604, 21081, 3602, 21083, 3600, 21085, 3598, 21087, 3596, 21089, 3594, 21091, 3592, 21093, 3590, 21095, 3588, 21097, 3586, 21099, 3584, 21101, 3582, 21103, 3580, 21105, 3578, 21107, 3576, 21109, 3574, 21111, 3572, 21113, 3570, 21115, 3568, 21117, 3566, 21119, 3564, 21121, 3562, 21123, 3560, 21125, 3558, 21127, 3556, 21129, 3554, 21131, 3552, 21133, 3550, 21135, 3548, 21137, 3546, 21139, 3544, 21141, 3542, 21143, 3540, 21145, 3538, 21147, 3536, 21149, 3534, 21151, 3532, 21153, 3530, 21155, 3528, 21157, 3526, 21159, 3524, 21161, 3522, 21163, 3520, 21165, 3518, 21167, 3516, 21169, 3514, 21171, 3512, 21173, 3510, 21175, 3508, 21177, 3506, 21179, 3504, 21181, 3502, 21183, 3500, 21185, 3498, 21187, 3496, 21189, 3494, 21191, 3492, 21193, 3490, 21195, 3488, 21197, 3486, 21199, 3484, 21201, 3482, 21203, 3480, 21205, 3478, 21207, 3476, 21209, 3474, 21211, 3472, 21213, 3470, 21215, 3468, 21217, 3466, 21219, 3464, 21221, 3462, 21223, 3460, 21225, 3458, 21227, 3456, 21229, 3454, 21231, 3452, 21233, 3450, 21235, 3448, 21237, 3446, 21239, 3444, 21241, 3442, 21243, 3440, 21245, 3438, 21247, 3436, 21249, 3434, 21251, 3432, 21253, 3430, 21255, 3428, 21257, 3426, 21259, 3424, 21261, 3422, 21263, 3420, 21265, 3418, 21267, 3416, 21269, 3414, 21271, 3412, 21273, 3410, 21275, 3408, 21277, 3406, 21279, 3404, 21281, 3402, 21283, 3400, 21285, 3398, 21287, 3396, 21289, 3394, 21291, 3392, 21293, 3390, 21295, 3388, 21297, 3386, 21299, 3384, 21301, 3382, 21303, 3380, 21305, 3378, 21307, 3376, 21309, 3374, 21311, 3372, 21313, 3370, 21315, 3368, 21317, 3366, 21319, 3364, 21321, 3362, 21323, 3360, 21325, 3358, 21327, 3356, 21329, 3354, 21331, 3352, 21333, 3350, 21335, 3348, 21337, 3346, 21339, 3344, 21341, 3342, 21343, 3340, 21345, 3338, 21347, 3336, 21349, 3334, 21351, 3332, 21353, 3330, 21355, 3328, 21357, 3326, 21359, 3324, 21361, 3322, 21363, 3320, 21365, 3318, 21367, 3316, 21369, 3314, 21371, 3312, 21373, 3310, 21375, 3308, 21377, 3306, 21379, 3304, 21381, 3302, 21383, 3300, 21385, 3298, 21387, 3296, 21389, 3294, 21391, 3292, 21393, 3290, 21395, 3288, 21397, 3286, 21399, 3284, 21401, 3282, 21403, 3280, 21405, 3278, 21407, 3276, 21409, 3274, 21411, 3272, 21413, 3270, 21415, 3268, 21417, 3266, 21419, 3264, 21421, 3262, 21423, 3260, 21425, 3258, 21427, 3256, 21429, 3254, 21431, 3252, 21433, 3250, 21435, 3248, 21437, 3246, 21439, 3244, 21441, 3242, 21443, 3240, 21445, 3238, 21447, 3236, 21449, 3234, 21451, 3232, 21453, 3230, 21455, 3228, 21457, 3226, 21459, 3224, 21461, 3222, 21463, 3220, 21465, 3218, 21467, 3216, 21469, 3214, 21471, 3212, 21473, 3210, 21475, 3208, 21477, 3206, 21479, 3204, 21481, 3202, 21483, 3200, 21485, 3198, 21487, 3196, 21489, 3194, 21491, 3192, 21493, 3190, 21495, 3188, 21497, 3186, 21499, 3184, 21501, 3182, 21503, 3180, 21505, 3178, 21507, 3176, 21509, 3174, 21511, 3172, 21513, 3170, 21515, 3168, 21517, 3166, 21519, 3164, 21521, 3162, 21523, 3160, 21525, 3158, 21527, 3156, 21529, 3154, 21531, 3152, 21533, 3150, 21535, 3148, 21537, 3146, 21539, 3144, 21541, 3142, 21543, 3140, 21545, 3138, 21547, 3136, 21549, 3134, 21551, 3132, 21553, 3130, 21555, 3128, 21557, 3126, 21559, 3124, 21561, 3122, 21563, 3120, 21565, 3118, 21567, 3116, 21569, 3114, 21571, 3112, 21573, 3110, 21575, 3108, 21577, 3106, 21579, 3104, 21581, 3102, 21583, 3100, 21585, 3098, 21587, 3096, 21589, 3094, 21591, 3092, 21593, 3090, 21595, 3088, 21597, 3086, 21599, 3084, 21601, 3082, 21603, 3080, 21605, 3078, 21607, 3076, 21609, 3074, 21611, 3072, 21613, 3070, 21615, 3068, 21617, 3066, 21619, 3064, 21621, 3062, 21623, 3060, 21625, 3058, 21627, 3056, 21629, 3054, 21631, 3052, 21633, 3050, 21635, 3048, 21637, 3046, 21639, 3044, 21641, 3042, 21643, 3040, 21645, 3038, 21647, 3036, 21649, 3034, 21651, 3032, 21653, 3030, 21655, 3028, 21657, 3026, 21659, 3024, 21661, 3022, 21663, 3020, 21665, 3018, 21667, 3016, 21669, 3014, 21671, 3012, 21673, 3010, 21675, 3008, 21677, 3006, 21679, 3004, 21681, 3002, 21683, 3000, 21685, 2998, 21687, 2996, 21689, 2994, 21691, 2992, 21693, 2990, 21695, 2988, 21697, 2986, 21699, 2984, 21701, 2982, 21703, 2980, 21705, 2978, 21707, 2976, 21709, 2974, 21711, 2972, 21713, 2970, 21715, 2968, 21717, 2966, 21719, 2964, 21721, 2962, 21723, 2960, 21725, 2958, 21727, 2956, 21729, 2954, 21731, 2952, 21733, 2950, 21735, 2948, 21737, 2946, 21739, 2944, 21741, 2942, 21743, 2940, 21745, 2938, 21747, 2936, 21749, 2934, 21751, 2932, 21753, 2930, 21755, 2928, 21757, 2926, 21759, 2924, 21761, 2922, 21763, 2920, 21765, 2918, 21767, 2916, 21769, 2914, 21771, 2912, 21773, 2910, 21775, 2908, 21777, 2906, 21779, 2904, 21781, 2902, 21783, 2900, 21785, 2898, 21787, 2896, 21789, 2894, 21791, 2892, 21793, 2890, 21795, 2888, 21797, 2886, 21799, 2884, 21801, 2882, 21803, 2880, 21805, 2878, 21807, 2876, 21809, 2874, 21811, 2872, 21813, 2870, 21815, 2868, 21817, 2866, 21819, 2864, 21821, 2862, 21823, 2860, 21825, 2858, 21827, 2856, 21829, 2854, 21831, 2852, 21833, 2850, 21835, 2848, 21837, 2846, 21839, 2844, 21841, 2842, 21843, 2840, 21845, 2838, 21847, 2836, 21849, 2834, 21851, 2832, 21853, 2830, 21855, 2828, 21857, 2826, 21859, 2824, 21861, 2822, 21863, 2820, 21865, 2818, 21867, 2816, 21869, 2814, 21871, 2812, 21873, 2810, 21875, 2808, 21877, 2806, 21879, 2804, 21881, 2802, 21883, 2800, 21885, 2798, 21887, 2796, 21889, 2794, 21891, 2792, 21893, 2790, 21895, 2788, 21897, 2786, 21899, 2784, 21901, 2782, 21903, 2780, 21905, 2778, 21907, 2776, 21909, 2774, 21911, 2772, 21913, 2770, 21915, 2768, 21917, 2766, 21919, 2764, 21921, 2762, 21923, 2760, 21925, 2758, 21927, 2756, 21929, 2754, 21931, 2752, 21933, 2750, 21935, 2748, 21937, 2746, 21939, 2744, 21941, 2742, 21943, 2740, 21945, 2738, 21947, 2736, 21949, 2734, 21951, 2732, 21953, 2730, 21955, 2728, 21957, 2726, 21959, 2724, 21961, 2722, 21963, 2720, 21965, 2718, 21967, 2716, 21969, 2714, 21971, 2712, 21973, 2710, 21975, 2708, 21977, 2706, 21979, 2704, 21981, 2702, 21983, 2700, 21985, 2698, 21987, 2696, 21989, 2694, 21991, 2692, 21993, 2690, 21995, 2688, 21997, 2686, 21999, 2684, 22001, 2682, 22003, 2680, 22005, 2678, 22007, 2676, 22009, 2674, 22011, 2672, 22013, 2670, 22015, 2668, 22017, 2666, 22019, 2664, 22021, 2662, 22023, 2660, 22025, 2658, 22027, 2656, 22029, 2654, 22031, 2652, 22033, 2650, 22035, 2648, 22037, 2646, 22039, 2644, 22041, 2642, 22043, 2640, 22045, 2638, 22047, 2636, 22049, 2634, 22051, 2632, 22053, 2630, 22055, 2628, 22057, 2626, 22059, 2624, 22061, 2622, 22063, 2620, 22065, 2618, 22067, 2616, 22069, 2614, 22071, 2612, 22073, 2610, 22075, 2608, 22077, 2606, 22079, 2604, 22081, 2602, 22083, 2600, 22085, 2598, 22087, 2596, 22089, 2594, 22091, 2592, 22093, 2590, 22095, 2588, 22097, 2586, 22099, 2584, 22101, 2582, 22103, 2580, 22105, 2578, 22107, 2576, 22109, 2574, 22111, 2572, 22113, 2570, 22115, 2568, 22117, 2566, 22119, 2564, 22121, 2562, 22123, 2560, 22125, 2558, 22127, 2556, 22129, 2554, 22131, 2552, 22133, 2550, 22135, 2548, 22137, 2546, 22139, 2544, 22141, 2542, 22143, 2540, 22145, 2538, 22147, 2536, 22149, 2534, 22151, 2532, 22153, 2530, 22155, 2528, 22157, 2526, 22159, 2524, 22161, 2522, 22163, 2520, 22165, 2518, 22167, 2516, 22169, 2514, 22171, 2512, 22173, 2510, 22175, 2508, 22177, 2506, 22179, 2504, 22181, 2502, 22183, 2500, 22185, 2498, 22187, 2496, 22189, 2494, 22191, 2492, 22193, 2490, 22195, 2488, 22197, 2486, 22199, 2484, 22201, 2482, 22203, 2480, 22205, 2478, 22207, 2476, 22209, 2474, 22211, 2472, 22213, 2470, 22215, 2468, 22217, 2466, 22219, 2464, 22221, 2462, 22223, 2460, 22225, 2458, 22227, 2456, 22229, 2454, 22231, 2452, 22233, 2450, 22235, 2448, 22237, 2446, 22239, 2444, 22241, 2442, 22243, 2440, 22245, 2438, 22247, 2436, 22249, 2434, 22251, 2432, 22253, 2430, 22255, 2428, 22257, 2426, 22259, 2424, 22261, 2422, 22263, 2420, 22265, 2418, 22267, 2416, 22269, 2414, 22271, 2412, 22273, 2410, 22275, 2408, 22277, 2406, 22279, 2404, 22281, 2402, 22283, 2400, 22285, 2398, 22287, 2396, 22289, 2394, 22291, 2392, 22293, 2390, 22295, 2388, 22297, 2386, 22299, 2384, 22301, 2382, 22303, 2380, 22305, 2378, 22307, 2376, 22309, 2374, 22311, 2372, 22313, 2370, 22315, 2368, 22317, 2366, 22319, 2364, 22321, 2362, 22323, 2360, 22325, 2358, 22327, 2356, 22329, 2354, 22331, 2352, 22333, 2350, 22335, 2348, 22337, 2346, 22339, 2344, 22341, 2342, 22343, 2340, 22345, 2338, 22347, 2336, 22349, 2334, 22351, 2332, 22353, 2330, 22355, 2328, 22357, 2326, 22359, 2324, 22361, 2322, 22363, 2320, 22365, 2318, 22367, 2316, 22369, 2314, 22371, 2312, 22373, 2310, 22375, 2308, 22377, 2306, 22379, 2304, 22381, 2302, 22383, 2300, 22385, 2298, 22387, 2296, 22389, 2294, 22391, 2292, 22393, 2290, 22395, 2288, 22397, 2286, 22399, 2284, 22401, 2282, 22403, 2280, 22405, 2278, 22407, 2276, 22409, 2274, 22411, 2272, 22413, 2270, 22415, 2268, 22417, 2266, 22419, 2264, 22421, 2262, 22423, 2260, 22425, 2258, 22427, 2256, 22429, 2254, 22431, 2252, 22433, 2250, 22435, 2248, 22437, 2246, 22439, 2244, 22441, 2242, 22443, 2240, 22445, 2238, 22447, 2236, 22449, 2234, 22451, 2232, 22453, 2230, 22455, 2228, 22457, 2226, 22459, 2224, 22461, 2222, 22463, 2220, 22465, 2218, 22467, 2216, 22469, 2214, 22471, 2212, 22473, 2210, 22475, 2208, 22477, 2206, 22479, 2204, 22481, 2202, 22483, 2200, 22485, 2198, 22487, 2196, 22489, 2194, 22491, 2192, 22493, 2190, 22495, 2188, 22497, 2186, 22499, 2184, 22501, 2182, 22503, 2180, 22505, 2178, 22507, 2176, 22509, 2174, 22511, 2172, 22513, 2170, 22515, 2168, 22517, 2166, 22519, 2164, 22521, 2162, 22523, 2160, 22525, 2158, 22527, 2156, 22529, 2154, 22531, 2152, 22533, 2150, 22535, 2148, 22537, 2146, 22539, 2144, 22541, 2142, 22543, 2140, 22545, 2138, 22547, 2136, 22549, 2134, 22551, 2132, 22553, 2130, 22555, 2128, 22557, 2126, 22559, 2124, 22561, 2122, 22563, 2120, 22565, 2118, 22567, 2116, 22569, 2114, 22571, 2112, 22573, 2110, 22575, 2108, 22577, 2106, 22579, 2104, 22581, 2102, 22583, 2100, 22585, 2098, 22587, 2096, 22589, 2094, 22591, 2092, 22593, 2090, 22595, 2088, 22597, 2086, 22599, 2084, 22601, 2082, 22603, 2080, 22605, 2078, 22607, 2076, 22609, 2074, 22611, 2072, 22613, 2070, 22615, 2068, 22617, 2066, 22619, 2064, 22621, 2062, 22623, 2060, 22625, 2058, 22627, 2056, 22629, 2054, 22631, 2052, 22633, 2050, 22635, 2048, 22637, 2046, 22639, 2044, 22641, 2042, 22643, 2040, 22645, 2038, 22647, 2036, 22649, 2034, 22651, 2032, 22653, 2030, 22655, 2028, 22657, 2026, 22659, 2024, 22661, 2022, 22663, 2020, 22665, 2018, 22667, 2016, 22669, 2014, 22671, 2012, 22673, 2010, 22675, 2008, 22677, 2006, 22679, 2004, 22681, 2002, 22683, 2000, 22685, 1998, 22687, 1996, 22689, 1994, 22691, 1992, 22693, 1990, 22695, 1988, 22697, 1986, 22699, 1984, 22701, 1982, 22703, 1980, 22705, 1978, 22707, 1976, 22709, 1974, 22711, 1972, 22713, 1970, 22715, 1968, 22717, 1966, 22719, 1964, 22721, 1962, 22723, 1960, 22725, 1958, 22727, 1956, 22729, 1954, 22731, 1952, 22733, 1950, 22735, 1948, 22737, 1946, 22739, 1944, 22741, 1942, 22743, 1940, 22745, 1938, 22747, 1936, 22749, 1934, 22751, 1932, 22753, 1930, 22755, 1928, 22757, 1926, 22759, 1924, 22761, 1922, 22763, 1920, 22765, 1918, 22767, 1916, 22769, 1914, 22771, 1912, 22773, 1910, 22775, 1908, 22777, 1906, 22779, 1904, 22781, 1902, 22783, 1900, 22785, 1898, 22787, 1896, 22789, 1894, 22791, 1892, 22793, 1890, 22795, 1888, 22797, 1886, 22799, 1884, 22801, 1882, 22803, 1880, 22805, 1878, 22807, 1876, 22809, 1874, 22811, 1872, 22813, 1870, 22815, 1868, 22817, 1866, 22819, 1864, 22821, 1862, 22823, 1860, 22825, 1858, 22827, 1856, 22829, 1854, 22831, 1852, 22833, 1850, 22835, 1848, 22837, 1846, 22839, 1844, 22841, 1842, 22843, 1840, 22845, 1838, 22847, 1836, 22849, 1834, 22851, 1832, 22853, 1830, 22855, 1828, 22857, 1826, 22859, 1824, 22861, 1822, 22863, 1820, 22865, 1818, 22867, 1816, 22869, 1814, 22871, 1812, 22873, 1810, 22875, 1808, 22877, 1806, 22879, 1804, 22881, 1802, 22883, 1800, 22885, 1798, 22887, 1796, 22889, 1794, 22891, 1792, 22893, 1790, 22895, 1788, 22897, 1786, 22899, 1784, 22901, 1782, 22903, 1780, 22905, 1778, 22907, 1776, 22909, 1774, 22911, 1772, 22913, 1770, 22915, 1768, 22917, 1766, 22919, 1764, 22921, 1762, 22923, 1760, 22925, 1758, 22927, 1756, 22929, 1754, 22931, 1752, 22933, 1750, 22935, 1748, 22937, 1746, 22939, 1744, 22941, 1742, 22943, 1740, 22945, 1738, 22947, 1736, 22949, 1734, 22951, 1732, 22953, 1730, 22955, 1728, 22957, 1726, 22959, 1724, 22961, 1722, 22963, 1720, 22965, 1718, 22967, 1716, 22969, 1714, 22971, 1712, 22973, 1710, 22975, 1708, 22977, 1706, 22979, 1704, 22981, 1702, 22983, 1700, 22985, 1698, 22987, 1696, 22989, 1694, 22991, 1692, 22993, 1690, 22995, 1688, 22997, 1686, 22999, 1684, 23001, 1682, 23003, 1680, 23005, 1678, 23007, 1676, 23009, 1674, 23011, 1672, 23013, 1670, 23015, 1668, 23017, 1666, 23019, 1664, 23021, 1662, 23023, 1660, 23025, 1658, 23027, 1656, 23029, 1654, 23031, 1652, 23033, 1650, 23035, 1648, 23037, 1646, 23039, 1644, 23041, 1642, 23043, 1640, 23045, 1638, 23047, 1636, 23049, 1634, 23051, 1632, 23053, 1630, 23055, 1628, 23057, 1626, 23059, 1624, 23061, 1622, 23063, 1620, 23065, 1618, 23067, 1616, 23069, 1614, 23071, 1612, 23073, 1610, 23075, 1608, 23077, 1606, 23079, 1604, 23081, 1602, 23083, 1600, 23085, 1598, 23087, 1596, 23089, 1594, 23091, 1592, 23093, 1590, 23095, 1588, 23097, 1586, 23099, 1584, 23101, 1582, 23103, 1580, 23105, 1578, 23107, 1576, 23109, 1574, 23111, 1572, 23113, 1570, 23115, 1568, 23117, 1566, 23119, 1564, 23121, 1562, 23123, 1560, 23125, 1558, 23127, 1556, 23129, 1554, 23131, 1552, 23133, 1550, 23135, 1548, 23137, 1546, 23139, 1544, 23141, 1542, 23143, 1540, 23145, 1538, 23147, 1536, 23149, 1534, 23151, 1532, 23153, 1530, 23155, 1528, 23157, 1526, 23159, 1524, 23161, 1522, 23163, 1520, 23165, 1518, 23167, 1516, 23169, 1514, 23171, 1512, 23173, 1510, 23175, 1508, 23177, 1506, 23179, 1504, 23181, 1502, 23183, 1500, 23185, 1498, 23187, 1496, 23189, 1494, 23191, 1492, 23193, 1490, 23195, 1488, 23197, 1486, 23199, 1484, 23201, 1482, 23203, 1480, 23205, 1478, 23207, 1476, 23209, 1474, 23211, 1472, 23213, 1470, 23215, 1468, 23217, 1466, 23219, 1464, 23221, 1462, 23223, 1460, 23225, 1458, 23227, 1456, 23229, 1454, 23231, 1452, 23233, 1450, 23235, 1448, 23237, 1446, 23239, 1444, 23241, 1442, 23243, 1440, 23245, 1438, 23247, 1436, 23249, 1434, 23251, 1432, 23253, 1430, 23255, 1428, 23257, 1426, 23259, 1424, 23261, 1422, 23263, 1420, 23265, 1418, 23267, 1416, 23269, 1414, 23271, 1412, 23273, 1410, 23275, 1408, 23277, 1406, 23279, 1404, 23281, 1402, 23283, 1400, 23285, 1398, 23287, 1396, 23289, 1394, 23291, 1392, 23293, 1390, 23295, 1388, 23297, 1386, 23299, 1384, 23301, 1382, 23303, 1380, 23305, 1378, 23307, 1376, 23309, 1374, 23311, 1372, 23313, 1370, 23315, 1368, 23317, 1366, 23319, 1364, 23321, 1362, 23323, 1360, 23325, 1358, 23327, 1356, 23329, 1354, 23331, 1352, 23333, 1350, 23335, 1348, 23337, 1346, 23339, 1344, 23341, 1342, 23343, 1340, 23345, 1338, 23347, 1336, 23349, 1334, 23351, 1332, 23353, 1330, 23355, 1328, 23357, 1326, 23359, 1324, 23361, 1322, 23363, 1320, 23365, 1318, 23367, 1316, 23369, 1314, 23371, 1312, 23373, 1310, 23375, 1308, 23377, 1306, 23379, 1304, 23381, 1302, 23383, 1300, 23385, 1298, 23387, 1296, 23389, 1294, 23391, 1292, 23393, 1290, 23395, 1288, 23397, 1286, 23399, 1284, 23401, 1282, 23403, 1280, 23405, 1278, 23407, 1276, 23409, 1274, 23411, 1272, 23413, 1270, 23415, 1268, 23417, 1266, 23419, 1264, 23421, 1262, 23423, 1260, 23425, 1258, 23427, 1256, 23429, 1254, 23431, 1252, 23433, 1250, 23435, 1248, 23437, 1246, 23439, 1244, 23441, 1242, 23443, 1240, 23445, 1238, 23447, 1236, 23449, 1234, 23451, 1232, 23453, 1230, 23455, 1228, 23457, 1226, 23459, 1224, 23461, 1222, 23463, 1220, 23465, 1218, 23467, 1216, 23469, 1214, 23471, 1212, 23473, 1210, 23475, 1208, 23477, 1206, 23479, 1204, 23481, 1202, 23483, 1200, 23485, 1198, 23487, 1196, 23489, 1194, 23491, 1192, 23493, 1190, 23495, 1188, 23497, 1186, 23499, 1184, 23501, 1182, 23503, 1180, 23505, 1178, 23507, 1176, 23509, 1174, 23511, 1172, 23513, 1170, 23515, 1168, 23517, 1166, 23519, 1164, 23521, 1162, 23523, 1160, 23525, 1158, 23527, 1156, 23529, 1154, 23531, 1152, 23533, 1150, 23535, 1148, 23537, 1146, 23539, 1144, 23541, 1142, 23543, 1140, 23545, 1138, 23547, 1136, 23549, 1134, 23551, 1132, 23553, 1130, 23555, 1128, 23557, 1126, 23559, 1124, 23561, 1122, 23563, 1120, 23565, 1118, 23567, 1116, 23569, 1114, 23571, 1112, 23573, 1110, 23575, 1108, 23577, 1106, 23579, 1104, 23581, 1102, 23583, 1100, 23585, 1098, 23587, 1096, 23589, 1094, 23591, 1092, 23593, 1090, 23595, 1088, 23597, 1086, 23599, 1084, 23601, 1082, 23603, 1080, 23605, 1078, 23607, 1076, 23609, 1074, 23611, 1072, 23613, 1070, 23615, 1068, 23617, 1066, 23619, 1064, 23621, 1062, 23623, 1060, 23625, 1058, 23627, 1056, 23629, 1054, 23631, 1052, 23633, 1050, 23635, 1048, 23637, 1046, 23639, 1044, 23641, 1042, 23643, 1040, 23645, 1038, 23647, 1036, 23649, 1034, 23651, 1032, 23653, 1030, 23655, 1028, 23657, 1026, 23659, 1024, 23661, 1022, 23663, 1020, 23665, 1018, 23667, 1016, 23669, 1014, 23671, 1012, 23673, 1010, 23675, 1008, 23677, 1006, 23679, 1004, 23681, 1002, 23683, 1000, 23685, 998, 23687, 996, 23689, 994, 23691, 992, 23693, 990, 23695, 988, 23697, 986, 23699, 984, 23701, 982, 23703, 980, 23705, 978, 23707, 976, 23709, 974, 23711, 972, 23713, 970, 23715, 968, 23717, 966, 23719, 964, 23721, 962, 23723, 960, 23725, 958, 23727, 956, 23729, 954, 23731, 952, 23733, 950, 23735, 948, 23737, 946, 23739, 944, 23741, 942, 23743, 940, 23745, 938, 23747, 936, 23749, 934, 23751, 932, 23753, 930, 23755, 928, 23757, 926, 23759, 924, 23761, 922, 23763, 920, 23765, 918, 23767, 916, 23769, 914, 23771, 912, 23773, 910, 23775, 908, 23777, 906, 23779, 904, 23781, 902, 23783, 900, 23785, 898, 23787, 896, 23789, 894, 23791, 892, 23793, 890, 23795, 888, 23797, 886, 23799, 884, 23801, 882, 23803, 880, 23805, 878, 23807, 876, 23809, 874, 23811, 872, 23813, 870, 23815, 868, 23817, 866, 23819, 864, 23821, 862, 23823, 860, 23825, 858, 23827, 856, 23829, 854, 23831, 852, 23833, 850, 23835, 848, 23837, 846, 23839, 844, 23841, 842, 23843, 840, 23845, 838, 23847, 836, 23849, 834, 23851, 832, 23853, 830, 23855, 828, 23857, 826, 23859, 824, 23861, 822, 23863, 820, 23865, 818, 23867, 816, 23869, 814, 23871, 812, 23873, 810, 23875, 808, 23877, 806, 23879, 804, 23881, 802, 23883, 800, 23885, 798, 23887, 796, 23889, 794, 23891, 792, 23893, 790, 23895, 788, 23897, 786, 23899, 784, 23901, 782, 23903, 780, 23905, 778, 23907, 776, 23909, 774, 23911, 772, 23913, 770, 23915, 768, 23917, 766, 23919, 764, 23921, 762, 23923, 760, 23925, 758, 23927, 756, 23929, 754, 23931, 752, 23933, 750, 23935, 748, 23937, 746, 23939, 744, 23941, 742, 23943, 740, 23945, 738, 23947, 736, 23949, 734, 23951, 732, 23953, 730, 23955, 728, 23957, 726, 23959, 724, 23961, 722, 23963, 720, 23965, 718, 23967, 716, 23969, 714, 23971, 712, 23973, 710, 23975, 708, 23977, 706, 23979, 704, 23981, 702, 23983, 700, 23985, 698, 23987, 696, 23989, 694, 23991, 692, 23993, 690, 23995, 688, 23997, 686, 23999, 684, 24001, 682, 24003, 680, 24005, 678, 24007, 676, 24009, 674, 24011, 672, 24013, 670, 24015, 668, 24017, 666, 24019, 664, 24021, 662, 24023, 660, 24025, 658, 24027, 656, 24029, 654, 24031, 652, 24033, 650, 24035, 648, 24037, 646, 24039, 644, 24041, 642, 24043, 640, 24045, 638, 24047, 636, 24049, 634, 24051, 632, 24053, 630, 24055, 628, 24057, 626, 24059, 624, 24061, 622, 24063, 620, 24065, 618, 24067, 616, 24069, 614, 24071, 612, 24073, 610, 24075, 608, 24077, 606, 24079, 604, 24081, 602, 24083, 600, 24085, 598, 24087, 596, 24089, 594, 24091, 592, 24093, 590, 24095, 588, 24097, 586, 24099, 584, 24101, 582, 24103, 580, 24105, 578, 24107, 576, 24109, 574, 24111, 572, 24113, 570, 24115, 568, 24117, 566, 24119, 564, 24121, 562, 24123, 560, 24125, 558, 24127, 556, 24129, 554, 24131, 552, 24133, 550, 24135, 548, 24137, 546, 24139, 544, 24141, 542, 24143, 540, 24145, 538, 24147, 536, 24149, 534, 24151, 532, 24153, 530, 24155, 528, 24157, 526, 24159, 524, 24161, 522, 24163, 520, 24165, 518, 24167, 516, 24169, 514, 24171, 512, 24173, 510, 24175, 508, 24177, 506, 24179, 504, 24181, 502, 24183, 500, 24185, 498, 24187, 496, 24189, 494, 24191, 492, 24193, 490, 24195, 488, 24197, 486, 24199, 484, 24201, 482, 24203, 480, 24205, 478, 24207, 476, 24209, 474, 24211, 472, 24213, 470, 24215, 468, 24217, 466, 24219, 464, 24221, 462, 24223, 460, 24225, 458, 24227, 456, 24229, 454, 24231, 452, 24233, 450, 24235, 448, 24237, 446, 24239, 444, 24241, 442, 24243, 440, 24245, 438, 24247, 436, 24249, 434, 24251, 432, 24253, 430, 24255, 428, 24257, 426, 24259, 424, 24261, 422, 24263, 420, 24265, 418, 24267, 416, 24269, 414, 24271, 412, 24273, 410, 24275, 408, 24277, 406, 24279, 404, 24281, 402, 24283, 400, 24285, 398, 24287, 396, 24289, 394, 24291, 392, 24293, 390, 24295, 388, 24297, 386, 24299, 384, 24301, 382, 24303, 380, 24305, 378, 24307, 376, 24309, 374, 24311, 372, 24313, 370, 24315, 368, 24317, 366, 24319, 364, 24321, 362, 24323, 360, 24325, 358, 24327, 356, 24329, 354, 24331, 352, 24333, 350, 24335, 348, 24337, 346, 24339, 344, 24341, 342, 24343, 340, 24345, 338, 24347, 336, 24349, 334, 24351, 332, 24353, 330, 24355, 328, 24357, 326, 24359, 324, 24361, 322, 24363, 320, 24365, 318, 24367, 316, 24369, 314, 24371, 312, 24373, 310, 24375, 308, 24377, 306, 24379, 304, 24381, 302, 24383, 300, 24385, 298, 24387, 296, 24389, 294, 24391, 292, 24393, 290, 24395, 288, 24397, 286, 24399, 284, 24401, 282, 24403, 280, 24405, 278, 24407, 276, 24409, 274, 24411, 272, 24413, 270, 24415, 268, 24417, 266, 24419, 264, 24421, 262, 24423, 260, 24425, 258, 24427, 256, 24429, 254, 24431, 252, 24433, 250, 24435, 248, 24437, 246, 24439, 244, 24441, 242, 24443, 240, 24445, 238, 24447, 236, 24449, 234, 24451, 232, 24453, 230, 24455, 228, 24457, 226, 24459, 224, 24461, 222, 24463, 220, 24465, 218, 24467, 216, 24469, 214, 24471, 212, 24473, 210, 24475, 208, 24477, 206, 24479, 204, 24481, 202, 24483, 200, 24485, 198, 24487, 196, 24489, 194, 24491, 192, 24493, 190, 24495, 188, 24497, 186, 24499, 184, 24501, 182, 24503, 180, 24505, 178, 24507, 176, 24509, 174, 24511, 172, 24513, 170, 24515, 168, 24517, 166, 24519, 164, 24521, 162, 24523, 160, 24525, 158, 24527, 156, 24529, 154, 24531, 152, 24533, 150, 24535, 148, 24537, 146, 24539, 144, 24541, 142, 24543, 140, 24545, 138, 24547, 136, 24549, 134, 24551, 132, 24553, 130, 24555, 128, 24557, 126, 24559, 124, 24561, 122, 24563, 120, 24565, 118, 24567, 116, 24569, 114, 24571, 112, 24573, 110, 24575, 108, 24577, 106, 24579, 104, 24581, 102, 24583, 100, 24585, 98, 24587, 96, 24589, 94, 24591, 92, 24593, 90, 24595, 88, 24597, 86, 24599, 84, 24601, 82, 24603, 80, 24605, 78, 24607, 76, 24609, 74, 24611, 72, 24613, 70, 24615, 68, 24617, 66, 24619, 64, 24621, 62, 24623, 60, 24625, 58, 24627, 56, 24629, 54, 24631, 52, 24633, 50, 24635, 48, 24637, 46, 24639, 44, 24641, 42, 24643, 40, 24645, 38, 24647, 36, 24649, 34, 24651, 32, 24653, 30, 24655, 28, 24657, 26, 24659, 24, 24661, 22, 24663, 20, 24665, 18, 24667, 16, 24669, 14, 24671, 12, 24673, 10, 24675, 8, 24677, 6, 24679, 4, 24681, 2, 24683]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..574eb70ac8ca541745560c0d766ae94fe111134b --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 24684, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s1/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s1/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..05528dfe0db462fa31b8f898546b235999bf2049 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 91, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s1/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f1b27fe0ff9ab1d9b8ded7d23920fbd19222702c --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..05528dfe0db462fa31b8f898546b235999bf2049 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 91, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s6/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s6/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..519bb73d9f68538a68e24df6745ca39154ea1136 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 59, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s6/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c453d27bd758c66001b174379a5976327cc74535 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..519bb73d9f68538a68e24df6745ca39154ea1136 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 59, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s8/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s8/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3aac54c4b47e5a553da672f86ee79871d6bc00e --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s8/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1d43abcb43134ca5ebc55cc99e7449588e09fdf --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3aac54c4b47e5a553da672f86ee79871d6bc00e --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l1-s1/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l1-s1/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..066775365a6fc3a6a86631f80992f0565f62ebd4 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"W": [5, 1, 5, 4], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s1/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1b17ba12d8c252233a8436665b7150ff1a424866 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["0112", "1000", "1201", "0210"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l1-s1/tests/check.py b/tasks/construct-rlve-round-robin-scores-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s1/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l1-s1/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..066775365a6fc3a6a86631f80992f0565f62ebd4 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"W": [5, 1, 5, 4], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s1/tests/run.py b/tasks/construct-rlve-round-robin-scores-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l1-s1/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l1-s8/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l1-s8/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f91ae4eed2092edd6127afe140ea8c238533944a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"W": [6, 6, 6, 0], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s8/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1b04a98767b0e90d7c5f529a497694a3fa2fc05 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["0202", "0022", "2002", "0000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l1-s8/tests/check.py b/tasks/construct-rlve-round-robin-scores-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s8/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l1-s8/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f91ae4eed2092edd6127afe140ea8c238533944a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"W": [6, 6, 6, 0], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s8/tests/run.py b/tasks/construct-rlve-round-robin-scores-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l1-s8/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l5-s0/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l5-s0/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b9b73056ac3fde7261609ab465c0f80aeb4cbbed --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"W": [16, 17, 22, 20, 20, 19, 17, 23, 16, 27, 20, 19, 19, 16, 19, 17, 21, 20], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s0/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e8e714a0457cabe4500a5060c8912be031d624f --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["011111101011111210", "101111111211011011", "110101121211121111", "111011110121111121", "112101211111111011", "111110111021111201", "111101011110111211", "210111101011211221", "111211110011101110", "200112122021221100", "111010111002121112", "111111211100111012", "121111101011011112", "110111112001101111", "111111111111110211", "021120001112110001", "111012101211111201", "211111112200011110"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l5-s0/tests/check.py b/tasks/construct-rlve-round-robin-scores-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s0/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l5-s0/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b9b73056ac3fde7261609ab465c0f80aeb4cbbed --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"W": [16, 17, 22, 20, 20, 19, 17, 23, 16, 27, 20, 19, 19, 16, 19, 17, 21, 20], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s0/tests/run.py b/tasks/construct-rlve-round-robin-scores-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l5-s0/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l5-s7/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l5-s7/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..662290ad074b93c01547010674ed60b951057b6f --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"W": [17, 15, 19, 23, 15, 16, 18, 16, 16, 19, 20, 19, 19, 16, 17, 19, 16, 19], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s7/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e4b4c280253d6226f615ee6ce4f3dc3f9dcbb827 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["011111111111111111", "101101111101111111", "110121111111111111", "111011112121111121", "120101111011011110", "111110111101111111", "111111021111111011", "111111001111111111", "111011110111111111", "111121111011111111", "121012111101111111", "111111111110121111", "111121111111011111", "111111111110101111", "111111111111110111", "111111211111111011", "111011111111111101", "111121111111111110"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l5-s7/tests/check.py b/tasks/construct-rlve-round-robin-scores-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s7/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l5-s7/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..662290ad074b93c01547010674ed60b951057b6f --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"W": [17, 15, 19, 23, 15, 16, 18, 16, 16, 19, 20, 19, 19, 16, 17, 19, 16, 19], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s7/tests/run.py b/tasks/construct-rlve-round-robin-scores-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l5-s7/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l5-s9/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l5-s9/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..250769e787918b2e0db2bf9615b40af23f7abdf4 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"W": [20, 19, 21, 19, 14, 23, 16, 17, 21, 19, 23, 27, 19, 23, 20, 25, 22, 17], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s9/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9e3bc424cafd389864203db9ef725c652bdbe3b4 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["021111121020111110", "001110111212120110", "110111110101121212", "111022101101011102", "111001111111011110", "121010111201211112", "111111021110100111", "011211002010110012", "112111100120001221", "201110121011101012", "012212110101121111", "201111222110211102", "111220112110001011", "100111212201202011", "121111221111100001", "110111120211222011", "111211110112112101", "220020101010111110"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l5-s9/tests/check.py b/tasks/construct-rlve-round-robin-scores-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s9/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l5-s9/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..250769e787918b2e0db2bf9615b40af23f7abdf4 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"W": [20, 19, 21, 19, 14, 23, 16, 17, 21, 19, 23, 27, 19, 23, 20, 25, 22, 17], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s9/tests/run.py b/tasks/construct-rlve-round-robin-scores-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l5-s9/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-shortest-path-count-l2-s2/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-shortest-path-count-l2-s2/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..18160237d955eee6982b82e4ddb39424c87a44b9 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"K": 396, "n_max": 57, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s2/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..33c4be888e20491c760dc1993e4bbaf89fd270ec --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"n": 27, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNYNNNNNN", "NNYYNNYYNNNNNNNNNNNNYNNNNNN", "NNNNYYNNYYNNNNNNNNNNNYNNNNN", "NNNNYYNNYYNNNNNNNNNNNYNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNYN", "NNNNNNNNNNNNYYNNYYNNNNNNNYN", "NNNNNNNNNNNNNNYYNNNNNNNNNNY", "NNNNNNNNNNNNNNYYNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNYYNNNNNNNNNNNNNYNYNNNNN", "NNNNNNYYNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNYYNNNNNNNNYNY", "NYNNNNNNNNNNNNNNYYNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l2-s2/tests/check.py b/tasks/construct-rlve-shortest-path-count-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s2/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l2-s2/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..18160237d955eee6982b82e4ddb39424c87a44b9 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"K": 396, "n_max": 57, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s2/tests/run.py b/tasks/construct-rlve-shortest-path-count-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-shortest-path-count-l2-s2/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-shortest-path-count-l2-s5/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-shortest-path-count-l2-s5/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e572d0a74a437b6ef79698b5e836b9956dbfbf2f --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"K": 112, "n_max": 45, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s5/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c055a52585ac8d818b7e5d09a50da681d156bba7 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"n": 21, "adj": ["NNYYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNYNN", "NNNNNNYYNNYYNNNNNNYNN", "NNNNNNNNYYNNYYNNNNNYN", "NNNNNNNNYYNNYYNNNNNYN", "NNNNNNNNNNYYNNNNNNNNY", "NNNNNNNNNNYYNNNNNNNNY", "NNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNYYNNNNNNNYNYN", "NNNNNNNNNNYYNNNNNNYNY", "NYNNNNNNNNNNYYNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l2-s5/tests/check.py b/tasks/construct-rlve-shortest-path-count-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s5/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l2-s5/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e572d0a74a437b6ef79698b5e836b9956dbfbf2f --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"K": 112, "n_max": 45, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s5/tests/run.py b/tasks/construct-rlve-shortest-path-count-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-shortest-path-count-l2-s5/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-shortest-path-count-l6-s3/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-shortest-path-count-l6-s3/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..18c487b9755de938b2f7153f82558a8d40cc4c2b --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"K": 229668606702905079, "n_max": 351, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s3/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8d62c6f0f7561ae3460dc3013bfe1ca561f40706 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"n": 174, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l6-s3/tests/check.py b/tasks/construct-rlve-shortest-path-count-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s3/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l6-s3/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..18c487b9755de938b2f7153f82558a8d40cc4c2b --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"K": 229668606702905079, "n_max": 351, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s3/tests/run.py b/tasks/construct-rlve-shortest-path-count-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-shortest-path-count-l6-s3/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-shortest-path-count-l6-s4/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b7385382052ffde35fbc823bb1265e281ea72ebd --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"K": 187789265141101595, "n_max": 351, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a47ff3d32da6289ac87f8e7415bc8ea49a41b042 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"points": [[2, 8], [5, 8], [6, 3], [8, 3]], "r_opt": 3.905124837953327, "r2_num": 61, "r2_den": 4, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..70eceb3cde1d0b7b077433a455a70e749a7fdf34 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 5.0, "y": 5.5, "r": 3.905124838953327} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a47ff3d32da6289ac87f8e7415bc8ea49a41b042 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"points": [[2, 8], [5, 8], [6, 3], [8, 3]], "r_opt": 3.905124837953327, "r2_num": 61, "r2_den": 4, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7562c6bd94c1f000ec76837117094fddd9a6c7ca --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"points": [[5, 3], [7, 4], [7, 5], [8, 4]], "r_opt": 1.5811388300841898, "r2_num": 5, "r2_den": 2, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..574d902cdb90bb808f7a420ebb8bc4d2f28184f2 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 6.5, "y": 3.5, "r": 1.5811388310841898} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7562c6bd94c1f000ec76837117094fddd9a6c7ca --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"points": [[5, 3], [7, 4], [7, 5], [8, 4]], "r_opt": 1.5811388300841898, "r2_num": 5, "r2_den": 2, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4c2db3e8c57cc3e9d4795860d4e6bac02cd2b1ff --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 3], [0, 8], [3, 4], [7, 4]], "r_opt": 4.072055089639778, "r2_num": 1625, "r2_den": 98, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed6deefa4c789b694fa09060ef9d19e1aeb18768 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 3.2142857142857144, "y": 5.5, "r": 4.072055090639778} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4c2db3e8c57cc3e9d4795860d4e6bac02cd2b1ff --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 3], [0, 8], [3, 4], [7, 4]], "r_opt": 4.072055089639778, "r2_num": 1625, "r2_den": 98, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2127c35672344f056d0b55d15f58d46d687e0055 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"points": [[2, 90], [4, 87], [9, 12], [9, 28], [10, 34], [10, 114], [12, 45], [13, 79], [15, 20], [18, 17], [19, 63], [21, 63], [21, 73], [30, 88], [36, 43], [37, 56], [39, 112], [40, 3], [41, 75], [43, 31], [43, 66], [45, 104], [47, 94], [48, 38], [49, 116], [50, 17], [52, 38], [55, 3], [55, 79], [58, 41], [58, 53], [60, 36], [60, 98], [62, 49], [64, 23], [66, 19], [75, 47], [75, 82], [77, 71], [78, 44], [84, 15], [85, 2], [88, 36], [89, 14], [91, 89], [93, 8], [93, 52], [103, 65], [105, 59], [108, 107], [111, 24], [112, 33], [112, 74], [113, 89], [113, 97], [114, 44], [115, 96], [116, 24], [116, 46], [118, 10]], "r_opt": 74.96665925596525, "r2_num": 5620, "r2_den": 1, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ecdc5a17fb192f78dcbf5fce04167003afe7c9e --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 64.0, "y": 62.0, "r": 74.96665925696526} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2127c35672344f056d0b55d15f58d46d687e0055 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"points": [[2, 90], [4, 87], [9, 12], [9, 28], [10, 34], [10, 114], [12, 45], [13, 79], [15, 20], [18, 17], [19, 63], [21, 63], [21, 73], [30, 88], [36, 43], [37, 56], [39, 112], [40, 3], [41, 75], [43, 31], [43, 66], [45, 104], [47, 94], [48, 38], [49, 116], [50, 17], [52, 38], [55, 3], [55, 79], [58, 41], [58, 53], [60, 36], [60, 98], [62, 49], [64, 23], [66, 19], [75, 47], [75, 82], [77, 71], [78, 44], [84, 15], [85, 2], [88, 36], [89, 14], [91, 89], [93, 8], [93, 52], [103, 65], [105, 59], [108, 107], [111, 24], [112, 33], [112, 74], [113, 89], [113, 97], [114, 44], [115, 96], [116, 24], [116, 46], [118, 10]], "r_opt": 74.96665925596525, "r2_num": 5620, "r2_den": 1, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..060a2d338571331248ba43fa366d860d03866e13 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 2], [1, 28], [2, 105], [4, 46], [7, 104], [9, 92], [13, 60], [15, 31], [18, 112], [27, 2], [32, 40], [32, 56], [33, 95], [34, 42], [34, 50], [38, 108], [39, 80], [40, 10], [42, 62], [45, 90], [49, 120], [50, 29], [50, 83], [52, 40], [53, 90], [54, 15], [55, 118], [56, 100], [56, 103], [58, 29], [61, 82], [63, 64], [63, 116], [67, 58], [71, 47], [72, 44], [72, 53], [74, 56], [75, 100], [78, 39], [78, 85], [79, 107], [82, 11], [83, 21], [85, 55], [87, 22], [88, 84], [90, 28], [92, 103], [95, 110], [97, 0], [100, 105], [104, 17], [107, 15], [108, 20], [110, 49], [111, 91], [112, 26], [114, 82], [115, 95]], "r_opt": 73.78876583264255, "r2_num": 164189458225, "r2_den": 30155378, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98449abcc2d1ab763449ac83aad056d6c53f9381 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 54.33955704352305, "y": 52.98699459181046, "r": 73.78876583364256} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..060a2d338571331248ba43fa366d860d03866e13 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 2], [1, 28], [2, 105], [4, 46], [7, 104], [9, 92], [13, 60], [15, 31], [18, 112], [27, 2], [32, 40], [32, 56], [33, 95], [34, 42], [34, 50], [38, 108], [39, 80], [40, 10], [42, 62], [45, 90], [49, 120], [50, 29], [50, 83], [52, 40], [53, 90], [54, 15], [55, 118], [56, 100], [56, 103], [58, 29], [61, 82], [63, 64], [63, 116], [67, 58], [71, 47], [72, 44], [72, 53], [74, 56], [75, 100], [78, 39], [78, 85], [79, 107], [82, 11], [83, 21], [85, 55], [87, 22], [88, 84], [90, 28], [92, 103], [95, 110], [97, 0], [100, 105], [104, 17], [107, 15], [108, 20], [110, 49], [111, 91], [112, 26], [114, 82], [115, 95]], "r_opt": 73.78876583264255, "r2_num": 164189458225, "r2_den": 30155378, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8757a838946f83bd12172c2bac9659f64d9043f9 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"points": [[3, 77], [3, 89], [10, 8], [17, 17], [17, 83], [19, 69], [22, 102], [28, 1], [28, 111], [29, 100], [30, 41], [31, 5], [32, 58], [33, 54], [35, 99], [37, 86], [38, 59], [41, 71], [41, 110], [45, 118], [46, 43], [48, 57], [49, 99], [49, 117], [50, 56], [55, 96], [56, 101], [58, 51], [60, 0], [61, 64], [65, 65], [67, 50], [68, 103], [70, 4], [73, 46], [76, 23], [76, 26], [79, 7], [80, 43], [89, 27], [91, 72], [92, 64], [93, 111], [94, 71], [95, 65], [98, 54], [99, 62], [99, 83], [102, 24], [104, 119], [105, 81], [105, 113], [106, 5], [107, 9], [109, 78], [110, 106], [111, 7], [114, 27], [118, 92], [118, 104]], "r_opt": 72.91783103805402, "r2_num": 27735917249, "r2_den": 5216450, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..df568d04bb6a3f2f812076c62fe84aa044a94a25 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 61.02074303405573, "y": 60.09504643962848, "r": 72.91783103905402} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8757a838946f83bd12172c2bac9659f64d9043f9 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"points": [[3, 77], [3, 89], [10, 8], [17, 17], [17, 83], [19, 69], [22, 102], [28, 1], [28, 111], [29, 100], [30, 41], [31, 5], [32, 58], [33, 54], [35, 99], [37, 86], [38, 59], [41, 71], [41, 110], [45, 118], [46, 43], [48, 57], [49, 99], [49, 117], [50, 56], [55, 96], [56, 101], [58, 51], [60, 0], [61, 64], [65, 65], [67, 50], [68, 103], [70, 4], [73, 46], [76, 23], [76, 26], [79, 7], [80, 43], [89, 27], [91, 72], [92, 64], [93, 111], [94, 71], [95, 65], [98, 54], [99, 62], [99, 83], [102, 24], [104, 119], [105, 81], [105, 113], [106, 5], [107, 9], [109, 78], [110, 106], [111, 7], [114, 27], [118, 92], [118, 104]], "r_opt": 72.91783103805402, "r2_num": 27735917249, "r2_den": 5216450, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n130/environment/Dockerfile b/tasks/optimize-ae-p41-sphere-max-volume-n130/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n130/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n130/environment/instance.json b/tasks/optimize-ae-p41-sphere-max-volume-n130/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e82ebbe1139d63f65a81e4d62ebf36446fe3ffd4 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n130/environment/instance.json @@ -0,0 +1 @@ +{"n": 130, "direction": "maximize", "family": "ae_p41_sphere_max_volume", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n130/solution/solve.sh b/tasks/optimize-ae-p41-sphere-max-volume-n130/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d6e86a4037ea7a520ca709a1bdbc4ad0b0e8aef2 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n130/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"points": [[0.067678452861949, -0.154416790974392, 0.985685082408872], [-0.140389683293606, 0.070017334735906, 0.98761749157313], [0.24367428359603, 0.115628440286606, 0.962939721535491], [-0.199193245186616, -0.284707491985651, 0.937690617996824], [-0.050286563438099, 0.35863645289415, 0.932121856944192], [0.341855379546773, -0.244967823559927, 0.907262732010549], [-0.441158873984376, -0.040253285157649, 0.896525806064083], [0.278152600884239, 0.396732531232811, 0.874776788262549], [0.064623879282472, -0.470037128673165, 0.880277712937895], [-0.373300573539877, 0.30959137021654, 0.87452836733993], [0.531322404450174, -0.006140998652874, 0.847147443285307], [-0.442990521974867, -0.36422937956629, 0.81920470976502], [0.06696158186586, 0.596133551404475, 0.800088079803662], [0.36311132466954, -0.539100917631652, 0.759947607737167], [-0.646526853948015, 0.158904733795509, 0.746158369718829], [0.563535808197766, 0.304961196470483, 0.767740881760365], [-0.229565525525717, -0.617480772048724, 0.752341123188287], [-0.256407086714663, 0.621388253667979, 0.740359401970393], [0.633379865222178, -0.300442598907717, 0.713136867012716], [-0.689350966355894, -0.204921041806379, 0.694839990076265], [0.375199354907514, 0.633777701303865, 0.676425361297885], [0.103452925617389, -0.731790008321787, 0.673632597119233], [-0.579227954815895, 0.477108326480161, 0.660955839041532], [0.765529702893141, 0.040919070338329, 0.642098048331394], [-0.552377585055498, -0.55681240038112, 0.620353894410337], [0.029250778240835, 0.797186836849557, 0.603023663819342], [0.573713544569672, -0.592506650450069, 0.565498574666411], [-0.83418250342054, 0.051694718165731, 0.549060294595053], [0.652833118125121, 0.5216472241306, 0.549265958744824], [-0.143918181130911, -0.83758330943711, 0.527012103174442], [-0.465312587104557, 0.722204040869345, 0.511767056026523], [0.843566201527123, -0.216972976531931, 0.49124209011034], [-0.777630812646637, -0.413355744202178, 0.473737636205521], [0.295721816669868, 0.838548163385364, 0.457586696516086], [0.352093332627435, -0.797454164776399, 0.48999708182813], [-0.806274354881878, 0.354166157361011, 0.473801643770837], [0.834007381751671, 0.28681393511057, 0.471348548114994], [-0.429327714086633, -0.782344190179594, 0.451237500668309], [-0.215067543872864, 0.87410450030263, 0.435531025442715], [0.769186283151856, -0.496967149711749, 0.401716459606041], [-0.910722697518383, -0.153898741115811, 0.383274504380096], [0.573334157481062, 0.731259044527788, 0.369524226082388], [0.075303774649123, -0.930047884730165, 0.359639088020949], [-0.688496728923442, 0.638884938730255, 0.343217553929513], [0.945660145493824, -0.002328956003874, 0.325148374113315], [-0.704368724106842, -0.640741694428272, 0.305474682291815], [0.085406653799515, 0.953569277293351, 0.288810209114924], [0.582082584732973, -0.765494223844968, 0.274223372108526], [-0.951002204929685, 0.172061207292337, 0.25688469624324], [0.820441966132999, 0.516120518086495, 0.245956481959609], [-0.256411775405548, -0.939654339653571, 0.226501045038617], [-0.448043196223439, 0.869149240183677, 0.209372616657534], [0.923569059549434, -0.334222711065675, 0.187923845349346], [-0.909737184579838, -0.378732818133304, 0.170116746564105], [0.414959516128158, 0.895876981928168, 0.158786124160654], [0.30273030005736, -0.939571870052996, 0.159872031426065], [-0.860348888968675, 0.489380335541684, 0.142501496256972], [0.966260170800034, 0.223220680020242, 0.128506071205953], [-0.56256850459082, -0.819426649650899, 0.109802748072862], [-0.140451911489764, 0.985783518927632, 0.092217755175052], [0.770380565178627, -0.633351647362544, 0.073344908331874], [-0.997017376602735, -0.053621427283029, 0.05550759667227], [0.700897946284415, 0.712024337774469, 0.041992991214231], [-0.03282116943613, -0.999078931754819, 0.027641616459522], [-0.651106719727844, 0.758924708258534, 0.009660575549413], [0.99325255611692, -0.115568304682813, -0.009660575549411], [-0.810015966387559, -0.585755986086983, -0.027641616459526], [0.198517165604991, 0.979197387480707, -0.041992991214228], [0.512931429308863, -0.85663309271755, -0.055507596672271], [-0.95581733284214, 0.284664277106081, -0.073344908331873], [0.89586205240871, 0.434657415310642, -0.092217755175048], [-0.364901666239484, -0.924548609047299, -0.109802748072869], [-0.355116780375395, 0.925947224175884, -0.128506071205949], [0.886744109023562, -0.43974789217975, -0.142501496256972], [-0.948269676043945, -0.274272774921636, -0.159872031426067], [0.510810800159186, 0.844901942958335, -0.158786124160652], [0.194577596573047, -0.966022697171396, -0.170116746564108], [-0.793442225996731, 0.578907645790301, -0.187923845349343], [0.971118589892986, 0.114419367933217, -0.209372616657531], [-0.635745233267412, -0.737919558606612, -0.226501045038622], [-0.03074432569332, 0.968793164416284, -0.245956481959605], [0.674326205600824, -0.69231092817896, -0.256884696243241], [-0.960111038095645, 0.054665681339678, -0.274223372108526], [0.7428842780149, 0.603913580398119, -0.288810209114922], [-0.137474322398058, -0.942223980357063, -0.30547468229182], [-0.530609823312184, 0.782771837904305, -0.32514837411331], [0.914627333516522, -0.213678617224793, -0.343217553929512], [-0.813228461216758, -0.457514148671364, -0.35963908802095], [0.285780760672309, 0.884183919310779, -0.369524226082384], [0.381544915774239, -0.84114453665171, -0.383274504380098], [-0.842069374295373, 0.359920900970461, -0.40171645960604], [0.844980247850297, 0.310356418686113, -0.435531025442712], [-0.408644861822564, -0.793343617165116, -0.451237500668314], [-0.228452821999036, 0.851844970819554, -0.471348548114991], [0.744403370661088, -0.470505711026405, -0.473801643770838], [-0.858032619659602, -0.153892441009943, -0.489997081828129], [0.529938621344711, 0.713988426221856, -0.457586696516086], [0.09201562178586, -0.875845749769766, -0.473737636205525], [-0.651500885849984, 0.578124385094343, -0.491242090110339], [0.858936714775148, 0.017949940869624, -0.511767056026521], [-0.614005662156639, -0.587584283271122, -0.527012103174443], [0.067541082707652, 0.832913626200707, -0.549265958744821], [0.509217926198065, -0.662744216525299, -0.549060294595055], [-0.812003317561447, 0.144436748507645, -0.565498574666411], [0.644617514785936, 0.469926292630135, -0.60302366381934], [-0.1528579996315, -0.769282443344823, -0.62035389441034], [-0.394048292986781, 0.657598691546158, -0.642098048331393], [0.719406143252067, -0.213523253740883, -0.660955839041531], [-0.664584195032305, -0.323337241609532, -0.673632597119233], [0.315725028321187, 0.665406971021956, -0.676425361297883], [0.21548124224433, -0.686123328878747, -0.694839990076268], [-0.603201594203206, 0.357188529572266, -0.713136867012717], [0.658557183562839, 0.134797596016478, -0.740359401970394], [-0.383630528051133, -0.535546872184867, -0.752341123188288], [-0.062197126268184, 0.637734628162689, -0.767740881760361], [0.493198432761563, -0.447216942009217, -0.74615836971883], [-0.649984253175971, -0.000322672948756, -0.759947607737168], [0.456835964068087, 0.388792960957465, -0.800088079803661], [-0.054335618789218, -0.570921434200539, -0.819204709765021], [-0.302131690052364, 0.437101419811549, -0.847147443285306], [0.465387707208031, -0.136434660909191, -0.874528367339931], [-0.425849713128526, -0.209196486426468, -0.880277712937896], [0.173438860691213, 0.452420747003495, -0.874776788262545], [0.213258224899481, -0.388281352338568, -0.896525806064084], [-0.394226791755958, 0.146490858986349, -0.90726273201055], [0.325468837982245, 0.158804531765938, -0.932121856944192], [-0.124698553581322, -0.324324799630648, -0.937690617996825], [-0.040357199480302, 0.2666803126203, -0.96293972153549], [0.13653934183933, -0.077257352199522, -0.98761749157313], [-0.16586755245448, -0.030213794190334, -0.985685082408872]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/check.py b/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..58b6521809868700c39ccbae7ef07cd7c99c8d83 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/check.py @@ -0,0 +1,23 @@ +"""n points on the unit sphere maximizing the volume of their convex hull (AlphaEvolve problem 41). + +Upstream bug fixed: the notebook summed |det|/6 of origin-pyramids over (QJ-joggled) hull facets, which +over-counts whenever the origin lies outside the hull (e.g. all points in one hemisphere). We use the exact +hull volume (scipy ConvexHull.volume) of the normalized points, without joggling.""" +import numpy as np +from scipy.spatial import ConvexHull + +from run import Invalid, float_matrix + + +def check(inst, ans): + n = inst["n"] + p = np.array(float_matrix(ans.get("points"), n, 3, "points")) + nr = np.linalg.norm(p, axis=1) + if (nr < 1e-9).any() or (nr > 1e9).any(): + raise Invalid("every point needs a non-zero, finite norm (it is projected to the unit sphere)") + p = p / nr[:, None] + try: + v = ConvexHull(p).volume + except Exception as e: # degenerate (coplanar) input + raise Invalid(f"degenerate hull: {type(e).__name__}") + return float(v), {} diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/instance.json b/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fea1d871f53151177566ed70da8c1c5197eed433 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/instance.json @@ -0,0 +1 @@ +{"n": 130, "direction": "maximize", "best_known": 4.01365550877, "baseline": 2.0935541046365023, "family": "ae_p41_sphere_max_volume", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/run.py b/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/test.sh b/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n130/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ea-two-deletion-code-n16/environment/Dockerfile b/tasks/optimize-ea-two-deletion-code-n16/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ea-two-deletion-code-n16/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ea-two-deletion-code-n16/environment/instance.json b/tasks/optimize-ea-two-deletion-code-n16/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f643ee5172daf3962f729f2064cc903f466fb911 --- /dev/null +++ b/tasks/optimize-ea-two-deletion-code-n16/environment/instance.json @@ -0,0 +1 @@ +{"length": 16, "max_words": 16384, "direction": "maximize", "family": "ea_two_deletion_code_16", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-two-deletion-code-n16/solution/solve.sh b/tasks/optimize-ea-two-deletion-code-n16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b05e26409e09395cadac77f6364d5f0cb22dc81a --- /dev/null +++ b/tasks/optimize-ea-two-deletion-code-n16/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"words": ["1001001111100101", "1000111000011100", "0100001110111110", "0100000010110101", "1101011101110100", "0001111100000110", "0000111100001111", "0010000001000110", "0000110010001001", "0000010000110001", "0101111000100100", "1111100110000011", "1110000111011100", "1000010001000000", "1011100111000000", "0000000000000111", "1100100001010011", "1110001111000111", "1101001100000000", "1110111000001100", "1111010101010111", "0011100001100101", "1011111111110011", "0001011111110010", "1111100000000001", "0100100100100100", "0100111010101111", "0011111111110000", "0110000010111100", "1000000000101100", "1110111111000011", "0101010111111111", "0100010000010111", "1100011001111000", "0110001001111111", "0101000111111001", "1101111101101101", "0000010111100011", "0100011011000000", "1100110000011110", "0111110000111010", "1101000001100100", "0111001010011110", "1100110011100111", "1111100011111101", "0010101010110111", "0001110011001000", "1010101000001010", "0001100001001110", "1111000001011001", "0110101010101010", "1100101011000010", "1010100010101110", "0001001111100000", "1111011011110010", "1110110100010101", "0011111111111110", "0110101111100010", "1011111001000111", "0000000111111111", "1100111010001000", "1111000000111111", "1010010101011001", "0000011010101100", "0111111100011001", "0011100001011111", "1000110011010101", "0000110001110011", "1011100001010000", "1110000010000000", "1010000010011111", "1111111001001010", "0111111100000000", "0010101000101001", "1110110001110001", "1001010101111100", "1110000111111111", "0111100111100001", "0011010000001100", "1110011111001100", "0000000110001011", "0000000101110000", "0000110011111100", "1111111110001000", "1101000011110101", "1000010011100001", "0110110111001000", "1011100011111000", "0100010111101000", "1001000110111111", "0001111110101100", "1010100111000110", "0101100111011010", "0111111001101000", "1010101111000001", "0010001001110010", "1010011111110000", "0001110000000000", "0010100010001111", "0001100111101111", "1001111000101101", "0010100001100000", "1011100011101011", "0000001110000000", "0111101011111100", "0000001011101110", "0010001010100001", "0101101111001011", "1000100110011110", "1011001000011101", "0011001100001010", "0101110101010001", "1011101100101100", "1111111000101111", "0000010100001110", "0000111100101010", "1111011111001111", "1100010010001100", "0011100010000011", "0010001110011011", "0110110001101111", "1000111000100010", "1000001110100111", "0110110000000111", "0001010000000101", "1111101110101001", "1001101110100100", "0101100100101011", "1111110100111100", "1110110011010110", "0000010010101111", "1111111101111111", "1000000011111001", "1100111101010011", "1000001111110100", "0111111001110111", "1111000110001010", "1010010110001011", "0101011011110110", "0000100011010100", "0111010100001000", "0110100110001001", "1110010010000111", "1101110010110010", "1001100011001100", "0011111011001111", "1000111011110011", "1111100001100111", "1011000001100011", "1110111111111000", "1011111011000010", "0110000000010010", "1010000000100001", "0000101101110101", "1010101001101000", "1001111011011000", "0110000111100110", "0011111110100011", "1100001010101000", "0110001010100111", "0110101110000111", "0100110101000110", "0000111111110111", "0000000000000000", "1010110100011111", "0000111101100001", "1101101011111011", "1110011101011101", "0110010001110000", "0010010000111110", "0110011011011100", "0001010110010011", "0011101111110101", "0111010110110011", "1110010110010001", "1011100111111110", "1100111101111110", "1111001010110100", "1000001101100010", "1110110101010000", "0011111010000001", "1111101110001110", "1110000000111000", "1101111000000101", "0110110001000000", "1001011110101110", "0001101001111101", "1100000000001111", "0011110011100110", "1110100110011111", "0001011100011000", "0001110011000111", "0100001110000101", "1100010001110110", "0011001011101001", "0011011000111100", "1110000111100000", "1001100100000001", "1100001101011011", "1110100000000110", "0101010110011101", "1100011010000011", "1000010001001101", "0010110101110000", "0010011100000011", "0001000001111011", "0111010000011011", "1000111110011111"]} +RLMATH_EOF diff --git a/tasks/optimize-ea-two-deletion-code-n16/tests/check.py b/tasks/optimize-ea-two-deletion-code-n16/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8259bab2ac57ef62d4b41d965b91d357c71a9c9c --- /dev/null +++ b/tasks/optimize-ea-two-deletion-code-n16/tests/check.py @@ -0,0 +1,28 @@ +"""Binary two-deletion-correcting code of length 16 (EinsteinArena two-deletion-code-16, MIT). + +Audit: upstream verifier (disjointness of the sets of length-14 subsequences) is exact; sound. +Same check re-implemented.""" +from run import Invalid + + +def _desc(w, L): + return {w[:i] + w[i + 1:j] + w[j + 1:] for i in range(L - 1) for j in range(i + 1, L)} + + +def check(inst, ans): + L, cap = inst["length"], inst["max_words"] + words = ans.get("words") + if not isinstance(words, list) or not 1 <= len(words) <= cap: + raise Invalid(f"words must be a list of 1..{cap} strings") + seen, used = set(), set() + for w in words: + if not isinstance(w, str) or len(w) != L or any(c not in "01" for c in w): + raise Invalid(f"every codeword must be a string of exactly {L} characters 0/1") + if w in seen: + raise Invalid("codewords must be distinct") + seen.add(w) + d = _desc(w, L) + if not used.isdisjoint(d): + raise Invalid(f"codeword {w} shares a two-deletion subsequence with an earlier codeword") + used |= d + return float(len(words)), {} diff --git a/tasks/optimize-ea-two-deletion-code-n16/tests/instance.json b/tasks/optimize-ea-two-deletion-code-n16/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0e66a8ae603de125b696caf5030b154cf4f1f021 --- /dev/null +++ b/tasks/optimize-ea-two-deletion-code-n16/tests/instance.json @@ -0,0 +1 @@ +{"length": 16, "max_words": 16384, "direction": "maximize", "best_known": 215, "baseline": 6.0, "family": "ea_two_deletion_code_16", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-two-deletion-code-n16/tests/run.py b/tasks/optimize-ea-two-deletion-code-n16/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ea-two-deletion-code-n16/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ea-two-deletion-code-n16/tests/test.sh b/tasks/optimize-ea-two-deletion-code-n16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ea-two-deletion-code-n16/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-fs-admissible-set-n12-w7/environment/Dockerfile b/tasks/optimize-fs-admissible-set-n12-w7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-fs-admissible-set-n12-w7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-fs-admissible-set-n12-w7/environment/instance.json b/tasks/optimize-fs-admissible-set-n12-w7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d5795ad5327ae42497cec1d25ae4fcfe80cd2d82 --- /dev/null +++ b/tasks/optimize-fs-admissible-set-n12-w7/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "w": 7, "direction": "maximize", "family": "fs_admissible_set", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-fs-admissible-set-n12-w7/solution/solve.sh b/tasks/optimize-fs-admissible-set-n12-w7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..957f8c69c569ac8b031a29fa3932f6792d9c2472 --- /dev/null +++ b/tasks/optimize-fs-admissible-set-n12-w7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"vectors": [[2, 1, 1, 0, 0, 0, 0, 2, 0, 2, 2, 1], [0, 0, 0, 2, 0, 2, 2, 1, 2, 1, 1, 0], [0, 0, 0, 1, 0, 2, 2, 0, 2, 1, 1, 2], [0, 0, 1, 1, 0, 2, 0, 0, 2, 1, 2, 2], [0, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 1], [2, 2, 2, 2, 0, 1, 1, 1, 0, 0, 0, 0], [2, 2, 2, 1, 0, 1, 1, 0, 0, 0, 0, 2], [0, 0, 1, 1, 2, 2, 0, 0, 0, 1, 2, 2], [0, 1, 0, 0, 2, 0, 2, 2, 0, 2, 1, 1], [0, 1, 2, 1, 0, 0, 1, 0, 2, 2, 0, 2], [2, 0, 1, 0, 0, 2, 0, 2, 0, 1, 2, 1], [2, 1, 0, 0, 0, 0, 2, 2, 0, 2, 1, 1], [2, 1, 2, 2, 0, 0, 1, 1, 0, 2, 0, 0], [0, 0, 2, 0, 2, 2, 1, 2, 0, 1, 0, 1], [0, 0, 1, 0, 2, 2, 0, 2, 0, 1, 2, 1], [0, 1, 1, 1, 2, 0, 0, 0, 0, 2, 2, 2], [0, 2, 1, 2, 2, 1, 0, 1, 0, 0, 2, 0], [0, 1, 0, 1, 0, 0, 2, 0, 2, 2, 1, 2], [0, 2, 1, 0, 0, 1, 0, 2, 2, 0, 2, 1], [2, 0, 2, 0, 0, 2, 1, 2, 0, 1, 0, 1], [0, 0, 2, 1, 2, 2, 1, 0, 0, 1, 0, 2], [2, 0, 1, 1, 0, 2, 0, 0, 0, 1, 2, 2], [0, 2, 0, 1, 2, 1, 2, 0, 0, 0, 1, 2], [0, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2], [0, 1, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1], [2, 1, 1, 2, 0, 0, 0, 1, 0, 2, 2, 0], [0, 2, 0, 2, 0, 1, 2, 1, 2, 0, 1, 0], [0, 2, 2, 0, 2, 1, 1, 2, 0, 0, 0, 1], [0, 0, 1, 2, 0, 2, 0, 1, 2, 1, 2, 0], [0, 0, 0, 1, 2, 2, 2, 0, 0, 1, 1, 2], [0, 2, 0, 2, 2, 1, 2, 1, 0, 0, 1, 0], [0, 0, 1, 2, 2, 2, 0, 1, 0, 1, 2, 0], [2, 1, 2, 0, 0, 0, 1, 2, 0, 2, 0, 1], [0, 2, 1, 0, 2, 1, 0, 2, 0, 0, 2, 1], [0, 0, 2, 2, 2, 2, 1, 1, 0, 1, 0, 0], [0, 2, 0, 0, 2, 1, 2, 2, 0, 0, 1, 1], [2, 2, 0, 1, 0, 1, 2, 0, 0, 0, 1, 2], [0, 2, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0], [0, 1, 2, 2, 2, 0, 1, 1, 0, 2, 0, 0], [0, 0, 2, 2, 0, 2, 1, 1, 2, 1, 0, 0], [2, 0, 2, 2, 0, 2, 1, 1, 0, 1, 0, 0], [2, 0, 0, 2, 0, 2, 2, 1, 0, 1, 1, 0], [0, 2, 0, 0, 0, 1, 2, 2, 2, 0, 1, 1], [0, 1, 0, 1, 2, 0, 2, 0, 0, 2, 1, 2], [0, 2, 1, 1, 0, 1, 0, 0, 2, 0, 2, 2], [0, 0, 0, 0, 2, 2, 2, 2, 0, 1, 1, 1], [0, 1, 2, 1, 2, 0, 1, 0, 0, 2, 0, 2], [2, 2, 2, 0, 0, 1, 1, 2, 0, 0, 0, 1], [2, 2, 1, 2, 0, 1, 0, 1, 0, 0, 2, 0], [0, 1, 2, 0, 2, 0, 1, 2, 0, 2, 0, 1], [2, 1, 1, 1, 0, 0, 0, 0, 0, 2, 2, 2], [0, 0, 1, 0, 0, 2, 0, 2, 2, 1, 2, 1], [0, 1, 0, 2, 0, 0, 2, 1, 2, 2, 1, 0], [0, 2, 2, 1, 0, 1, 1, 0, 2, 0, 0, 2], [0, 0, 0, 2, 2, 2, 2, 1, 0, 1, 1, 0], [0, 1, 0, 2, 2, 0, 2, 1, 0, 2, 1, 0], [2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 1, 0], [0, 1, 1, 2, 2, 0, 0, 1, 0, 2, 2, 0], [2, 2, 0, 2, 0, 1, 2, 1, 0, 0, 1, 0], [2, 0, 1, 2, 0, 2, 0, 1, 0, 1, 2, 0], [0, 2, 2, 2, 0, 1, 1, 1, 2, 0, 0, 0], [0, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0], [0, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1], [2, 0, 2, 1, 0, 2, 1, 0, 0, 1, 0, 2], [0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 1], [0, 2, 0, 1, 0, 1, 2, 0, 2, 0, 1, 2], [0, 2, 1, 2, 0, 1, 0, 1, 2, 0, 2, 0], [2, 2, 1, 1, 0, 1, 0, 0, 0, 0, 2, 2], [2, 1, 2, 1, 0, 0, 1, 0, 0, 2, 0, 2], [2, 1, 0, 1, 0, 0, 2, 0, 0, 2, 1, 2], [0, 1, 1, 2, 0, 0, 0, 1, 2, 2, 2, 0], [2, 0, 0, 1, 0, 2, 2, 0, 0, 1, 1, 2], [0, 2, 1, 1, 2, 1, 0, 0, 0, 0, 2, 2], [0, 0, 2, 0, 0, 2, 1, 2, 2, 1, 0, 1], [2, 2, 1, 0, 0, 1, 0, 2, 0, 0, 2, 1], [0, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2], [2, 0, 0, 0, 0, 2, 2, 2, 0, 1, 1, 1], [0, 1, 1, 0, 2, 0, 0, 2, 0, 2, 2, 1], [0, 1, 2, 0, 0, 0, 1, 2, 2, 2, 0, 1], [0, 2, 2, 1, 2, 1, 1, 0, 0, 0, 0, 2], [2, 2, 0, 0, 0, 1, 2, 2, 0, 0, 1, 1], [0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 1], [1, 0, 1, 2, 0, 2, 0, 1, 2, 0, 2, 0], [1, 2, 2, 2, 0, 0, 1, 1, 2, 0, 0, 0], [0, 0, 2, 0, 2, 2, 1, 2, 1, 0, 0, 1], [1, 0, 0, 0, 0, 2, 2, 2, 2, 0, 1, 1], [0, 0, 1, 1, 2, 0, 0, 0, 1, 2, 2, 2], [0, 0, 2, 2, 2, 2, 1, 1, 1, 0, 0, 0], [0, 2, 2, 0, 2, 0, 1, 2, 1, 0, 0, 1], [0, 0, 0, 0, 2, 0, 2, 2, 1, 2, 1, 1], [2, 0, 2, 2, 1, 2, 1, 1, 0, 0, 0, 0], [1, 2, 2, 0, 0, 0, 1, 2, 2, 0, 0, 1], [0, 2, 2, 1, 2, 0, 1, 0, 1, 0, 0, 2], [2, 0, 2, 0, 1, 2, 1, 2, 0, 0, 0, 1], [0, 0, 0, 1, 2, 2, 2, 0, 1, 0, 1, 2], [0, 0, 0, 2, 2, 2, 2, 1, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1], [0, 0, 0, 2, 2, 0, 2, 1, 1, 2, 1, 0], [1, 2, 0, 1, 0, 0, 2, 0, 2, 0, 1, 2], [0, 0, 0, 1, 2, 0, 2, 0, 1, 2, 1, 2], [0, 0, 2, 1, 2, 0, 1, 0, 1, 2, 0, 2], [2, 0, 1, 2, 1, 2, 0, 1, 0, 0, 2, 0], [2, 0, 2, 2, 1, 0, 1, 1, 0, 2, 0, 0], [0, 0, 2, 1, 2, 2, 1, 0, 1, 0, 0, 2], [1, 0, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2], [0, 0, 1, 0, 2, 0, 0, 2, 1, 2, 2, 1], [0, 0, 1, 0, 2, 2, 0, 2, 1, 0, 2, 1], [1, 2, 0, 2, 0, 0, 2, 1, 2, 0, 1, 0], [2, 0, 2, 0, 1, 0, 1, 2, 0, 2, 0, 1], [2, 0, 1, 1, 1, 2, 0, 0, 0, 0, 2, 2], [2, 0, 1, 0, 1, 0, 0, 2, 0, 2, 2, 1], [1, 0, 0, 1, 0, 2, 2, 0, 2, 0, 1, 2], [1, 0, 2, 2, 0, 2, 1, 1, 2, 0, 0, 0], [2, 2, 0, 0, 1, 0, 2, 2, 0, 0, 1, 1], [2, 0, 1, 0, 1, 2, 0, 2, 0, 0, 2, 1], [1, 2, 1, 1, 0, 0, 0, 0, 2, 0, 2, 2], [1, 0, 0, 1, 0, 0, 2, 0, 2, 2, 1, 2], [0, 0, 1, 1, 2, 2, 0, 0, 1, 0, 2, 2], [0, 2, 0, 0, 2, 0, 2, 2, 1, 0, 1, 1], [2, 2, 1, 0, 1, 0, 0, 2, 0, 0, 2, 1], [2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 2, 2], [1, 0, 0, 2, 0, 0, 2, 1, 2, 2, 1, 0], [1, 0, 2, 0, 0, 0, 1, 2, 2, 2, 0, 1], [2, 0, 0, 0, 1, 0, 2, 2, 0, 2, 1, 1], [2, 2, 2, 1, 1, 0, 1, 0, 0, 0, 0, 2], [0, 2, 0, 1, 2, 0, 2, 0, 1, 0, 1, 2], [2, 2, 0, 1, 1, 0, 2, 0, 0, 0, 1, 2], [2, 2, 2, 2, 1, 0, 1, 1, 0, 0, 0, 0], [1, 2, 2, 1, 0, 0, 1, 0, 2, 0, 0, 2], [0, 2, 0, 2, 2, 0, 2, 1, 1, 0, 1, 0], [0, 0, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0], [2, 0, 2, 1, 1, 2, 1, 0, 0, 0, 0, 2], [1, 0, 2, 0, 0, 2, 1, 2, 2, 0, 0, 1], [2, 0, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0], [2, 0, 0, 2, 1, 2, 2, 1, 0, 0, 1, 0], [1, 2, 1, 0, 0, 0, 0, 2, 2, 0, 2, 1], [2, 0, 0, 1, 1, 2, 2, 0, 0, 0, 1, 2], [1, 0, 1, 0, 0, 2, 0, 2, 2, 0, 2, 1], [1, 0, 1, 1, 0, 2, 0, 0, 2, 0, 2, 2], [1, 2, 1, 2, 0, 0, 0, 1, 2, 0, 2, 0], [0, 2, 1, 1, 2, 0, 0, 0, 1, 0, 2, 2], [2, 0, 2, 1, 1, 0, 1, 0, 0, 2, 0, 2], [0, 2, 1, 2, 2, 0, 0, 1, 1, 0, 2, 0], [1, 0, 1, 0, 0, 0, 0, 2, 2, 2, 2, 1], [1, 0, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0], [2, 2, 1, 2, 1, 0, 0, 1, 0, 0, 2, 0], [1, 0, 0, 2, 0, 2, 2, 1, 2, 0, 1, 0], [2, 2, 2, 0, 1, 0, 1, 2, 0, 0, 0, 1], [0, 0, 1, 2, 2, 2, 0, 1, 1, 0, 2, 0], [0, 0, 2, 0, 2, 0, 1, 2, 1, 2, 0, 1], [1, 0, 2, 1, 0, 2, 1, 0, 2, 0, 0, 2], [1, 0, 1, 2, 0, 0, 0, 1, 2, 2, 2, 0], [1, 2, 0, 0, 0, 0, 2, 2, 2, 0, 1, 1], [1, 0, 2, 1, 0, 0, 1, 0, 2, 2, 0, 2], [0, 2, 2, 2, 2, 0, 1, 1, 1, 0, 0, 0], [0, 0, 2, 2, 2, 0, 1, 1, 1, 2, 0, 0], [2, 0, 1, 2, 1, 0, 0, 1, 0, 2, 2, 0], [2, 2, 0, 2, 1, 0, 2, 1, 0, 0, 1, 0], [2, 0, 0, 0, 1, 2, 2, 2, 0, 0, 1, 1], [2, 0, 0, 1, 1, 0, 2, 0, 0, 2, 1, 2], [0, 0, 0, 0, 2, 2, 2, 2, 1, 0, 1, 1], [2, 0, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2], [2, 2, 2, 0, 0, 1, 0, 2, 1, 0, 0, 1], [2, 2, 0, 1, 0, 1, 2, 0, 1, 0, 0, 2], [1, 2, 0, 0, 2, 1, 2, 2, 0, 0, 0, 1], [0, 1, 0, 2, 1, 0, 0, 1, 2, 2, 2, 0], [0, 2, 0, 2, 1, 1, 0, 1, 2, 0, 2, 0], [1, 2, 0, 2, 2, 1, 0, 1, 0, 0, 2, 0], [1, 1, 0, 0, 2, 0, 2, 2, 0, 2, 0, 1], [2, 0, 2, 0, 0, 2, 0, 2, 1, 1, 0, 1], [0, 1, 2, 0, 1, 0, 0, 2, 2, 2, 0, 1], [0, 1, 2, 1, 1, 0, 0, 0, 2, 2, 0, 2], [2, 0, 2, 2, 0, 2, 0, 1, 1, 1, 0, 0], [0, 0, 2, 0, 1, 2, 0, 2, 2, 1, 0, 1], [0, 1, 0, 0, 1, 0, 0, 2, 2, 2, 2, 1], [1, 0, 0, 2, 2, 2, 0, 1, 0, 1, 2, 0], [2, 0, 0, 0, 0, 2, 0, 2, 1, 1, 2, 1], [2, 0, 0, 1, 0, 2, 2, 0, 1, 1, 0, 2], [2, 2, 2, 2, 0, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 2, 0, 0, 2, 1, 2, 2], [1, 2, 2, 1, 2, 1, 0, 0, 0, 0, 0, 2], [1, 1, 0, 1, 2, 0, 2, 0, 0, 2, 0, 2], [2, 1, 0, 0, 0, 0, 2, 2, 1, 2, 0, 1], [2, 0, 0, 2, 0, 2, 0, 1, 1, 1, 2, 0], [0, 1, 0, 0, 1, 0, 2, 2, 2, 2, 0, 1], [2, 0, 0, 1, 0, 2, 0, 0, 1, 1, 2, 2], [0, 2, 2, 2, 1, 1, 0, 1, 2, 0, 0, 0], [1, 1, 2, 1, 2, 0, 0, 0, 0, 2, 0, 2], [1, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1], [2, 1, 0, 2, 0, 0, 0, 1, 1, 2, 2, 0], [2, 1, 0, 2, 0, 0, 2, 1, 1, 2, 0, 0], [1, 0, 2, 0, 2, 2, 0, 2, 0, 1, 0, 1], [1, 0, 0, 1, 2, 2, 0, 0, 0, 1, 2, 2], [0, 0, 0, 2, 1, 2, 0, 1, 2, 1, 2, 0], [2, 1, 0, 0, 0, 0, 0, 2, 1, 2, 2, 1], [1, 1, 0, 0, 2, 0, 0, 2, 0, 2, 2, 1], [2, 0, 0, 2, 0, 2, 2, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 2, 2, 0, 2, 1, 0, 2], [2, 1, 2, 1, 0, 0, 0, 0, 1, 2, 0, 2], [0, 1, 2, 2, 1, 0, 0, 1, 2, 2, 0, 0], [0, 2, 0, 2, 1, 1, 2, 1, 2, 0, 0, 0], [0, 0, 0, 0, 1, 2, 2, 2, 2, 1, 0, 1], [2, 1, 2, 2, 0, 0, 0, 1, 1, 2, 0, 0], [1, 1, 2, 2, 2, 0, 0, 1, 0, 2, 0, 0], [2, 2, 0, 0, 0, 1, 0, 2, 1, 0, 2, 1], [1, 2, 0, 2, 2, 1, 2, 1, 0, 0, 0, 0], [0, 2, 0, 0, 1, 1, 2, 2, 2, 0, 0, 1], [2, 0, 0, 0, 0, 2, 2, 2, 1, 1, 0, 1], [0, 1, 0, 2, 1, 0, 2, 1, 2, 2, 0, 0], [1, 0, 0, 0, 2, 2, 2, 2, 0, 1, 0, 1], [0, 2, 2, 0, 1, 1, 0, 2, 2, 0, 0, 1], [0, 0, 0, 0, 1, 2, 0, 2, 2, 1, 2, 1], [0, 0, 2, 1, 1, 2, 0, 0, 2, 1, 0, 2], [0, 2, 0, 1, 1, 1, 0, 0, 2, 0, 2, 2], [1, 0, 0, 2, 2, 2, 2, 1, 0, 1, 0, 0], [2, 1, 2, 0, 0, 0, 0, 2, 1, 2, 0, 1], [2, 2, 0, 0, 0, 1, 2, 2, 1, 0, 0, 1], [0, 2, 2, 1, 1, 1, 0, 0, 2, 0, 0, 2], [0, 1, 0, 1, 1, 0, 2, 0, 2, 2, 0, 2], [0, 2, 0, 0, 1, 1, 0, 2, 2, 0, 2, 1], [1, 1, 2, 0, 2, 0, 0, 2, 0, 2, 0, 1], [1, 0, 0, 0, 2, 2, 0, 2, 0, 1, 2, 1], [0, 0, 0, 2, 1, 2, 2, 1, 2, 1, 0, 0], [1, 0, 2, 2, 2, 2, 0, 1, 0, 1, 0, 0], [0, 2, 0, 1, 1, 1, 2, 0, 2, 0, 0, 2], [2, 2, 0, 2, 0, 1, 0, 1, 1, 0, 2, 0], [1, 1, 0, 2, 2, 0, 0, 1, 0, 2, 2, 0], [2, 1, 0, 1, 0, 0, 2, 0, 1, 2, 0, 2], [2, 2, 0, 2, 0, 1, 2, 1, 1, 0, 0, 0], [2, 1, 0, 1, 0, 0, 0, 0, 1, 2, 2, 2], [2, 0, 2, 1, 0, 2, 0, 0, 1, 1, 0, 2], [0, 1, 0, 1, 1, 0, 0, 0, 2, 2, 2, 2], [1, 0, 0, 1, 2, 2, 2, 0, 0, 1, 0, 2], [1, 0, 2, 1, 2, 2, 0, 0, 0, 1, 0, 2], [2, 2, 2, 1, 0, 1, 0, 0, 1, 0, 0, 2], [1, 1, 0, 1, 2, 0, 0, 0, 0, 2, 2, 2], [1, 2, 2, 2, 2, 1, 0, 1, 0, 0, 0, 0], [1, 2, 0, 1, 2, 1, 2, 0, 0, 0, 0, 2], [1, 2, 0, 1, 2, 1, 0, 0, 0, 0, 2, 2], [2, 2, 0, 1, 0, 1, 0, 0, 1, 0, 2, 2], [1, 1, 0, 2, 2, 0, 2, 1, 0, 2, 0, 0], [0, 0, 2, 2, 1, 2, 0, 1, 2, 1, 0, 0], [1, 2, 2, 0, 2, 1, 0, 2, 0, 0, 0, 1], [0, 2, 0, 2, 2, 0, 2, 0, 1, 1, 1, 0], [1, 0, 1, 0, 0, 1, 0, 0, 2, 2, 2, 2], [1, 2, 0, 0, 0, 0, 2, 0, 2, 1, 1, 2], [0, 1, 2, 0, 2, 2, 1, 2, 1, 0, 0, 0], [1, 1, 2, 2, 0, 2, 1, 0, 2, 0, 0, 0], [1, 0, 2, 2, 0, 1, 1, 0, 2, 2, 0, 0], [1, 0, 0, 0, 0, 1, 2, 2, 2, 2, 1, 0], [0, 1, 1, 2, 2, 2, 0, 0, 1, 0, 2, 0], [0, 1, 1, 0, 2, 2, 0, 2, 1, 0, 2, 0], [1, 1, 1, 0, 0, 2, 0, 0, 2, 0, 2, 2], [0, 0, 2, 2, 2, 1, 1, 0, 1, 2, 0, 0], [0, 0, 2, 0, 2, 1, 1, 0, 1, 2, 0, 2], [0, 0, 0, 0, 2, 1, 2, 0, 1, 2, 1, 2], [1, 2, 2, 2, 0, 0, 1, 0, 2, 1, 0, 0], [1, 2, 1, 2, 0, 0, 0, 0, 2, 1, 2, 0], [1, 0, 0, 2, 0, 1, 2, 0, 2, 2, 1, 0], [0, 2, 1, 0, 2, 0, 0, 2, 1, 1, 2, 0], [2, 2, 2, 2, 1, 0, 1, 0, 0, 1, 0, 0], [2, 2, 0, 0, 1, 0, 2, 0, 0, 1, 1, 2], [2, 1, 2, 2, 1, 2, 1, 0, 0, 0, 0, 0], [2, 0, 1, 0, 1, 1, 0, 2, 0, 2, 2, 0], [2, 0, 2, 0, 1, 1, 1, 2, 0, 2, 0, 0], [1, 0, 1, 0, 0, 1, 0, 2, 2, 2, 2, 0], [0, 2, 1, 2, 2, 0, 0, 0, 1, 1, 2, 0], [2, 0, 2, 2, 1, 1, 1, 0, 0, 2, 0, 0], [2, 2, 1, 2, 1, 0, 0, 0, 0, 1, 2, 0], [1, 2, 2, 0, 0, 0, 1, 2, 2, 1, 0, 0], [0, 2, 0, 0, 2, 0, 2, 0, 1, 1, 1, 2], [2, 1, 0, 2, 1, 2, 2, 0, 0, 0, 1, 0], [2, 0, 2, 0, 1, 1, 1, 0, 0, 2, 0, 2], [1, 1, 1, 2, 0, 2, 0, 0, 2, 0, 2, 0], [0, 2, 2, 0, 2, 0, 1, 2, 1, 1, 0, 0], [2, 2, 0, 2, 1, 0, 2, 0, 0, 1, 1, 0], [0, 0, 0, 0, 2, 1, 2, 2, 1, 2, 1, 0], [1, 0, 0, 0, 0, 1, 2, 0, 2, 2, 1, 2], [0, 1, 1, 0, 2, 2, 0, 0, 1, 0, 2, 2], [1, 1, 0, 0, 0, 2, 2, 2, 2, 0, 1, 0], [2, 0, 0, 0, 1, 1, 2, 2, 0, 2, 1, 0], [1, 1, 2, 0, 0, 2, 1, 2, 2, 0, 0, 0], [0, 2, 2, 2, 2, 0, 1, 0, 1, 1, 0, 0], [2, 2, 1, 0, 1, 0, 0, 2, 0, 1, 2, 0], [2, 2, 0, 0, 1, 0, 2, 2, 0, 1, 1, 0], [2, 1, 2, 0, 1, 2, 1, 0, 0, 0, 0, 2], [0, 1, 0, 0, 2, 2, 2, 0, 1, 0, 1, 2], [2, 1, 1, 0, 1, 2, 0, 0, 0, 0, 2, 2], [0, 0, 2, 0, 2, 1, 1, 2, 1, 2, 0, 0], [2, 1, 2, 0, 1, 2, 1, 2, 0, 0, 0, 0], [0, 2, 2, 0, 2, 0, 1, 0, 1, 1, 0, 2], [0, 0, 0, 2, 2, 1, 2, 0, 1, 2, 1, 0], [0, 0, 1, 0, 2, 1, 0, 0, 1, 2, 2, 2], [1, 2, 1, 0, 0, 0, 0, 2, 2, 1, 2, 0], [1, 1, 0, 2, 0, 2, 2, 0, 2, 0, 1, 0], [2, 0, 0, 0, 1, 1, 2, 0, 0, 2, 1, 2], [0, 1, 2, 0, 2, 2, 1, 0, 1, 0, 0, 2], [1, 0, 2, 0, 0, 1, 1, 2, 2, 2, 0, 0], [2, 1, 1, 0, 1, 2, 0, 2, 0, 0, 2, 0], [1, 2, 1, 0, 0, 0, 0, 0, 2, 1, 2, 2], [0, 1, 0, 0, 2, 2, 2, 2, 1, 0, 1, 0], [2, 1, 0, 0, 1, 2, 2, 0, 0, 0, 1, 2], [0, 0, 1, 0, 2, 1, 0, 2, 1, 2, 2, 0], [0, 0, 1, 2, 2, 1, 0, 0, 1, 2, 2, 0], [0, 2, 0, 0, 2, 0, 2, 2, 1, 1, 1, 0], [2, 0, 1, 2, 1, 1, 0, 0, 0, 2, 2, 0], [0, 2, 1, 0, 2, 0, 0, 0, 1, 1, 2, 2], [1, 2, 0, 0, 0, 0, 2, 2, 2, 1, 1, 0], [1, 0, 2, 0, 0, 1, 1, 0, 2, 2, 0, 2], [2, 1, 0, 0, 1, 2, 2, 2, 0, 0, 1, 0], [1, 2, 2, 0, 0, 0, 1, 0, 2, 1, 0, 2], [2, 2, 1, 0, 1, 0, 0, 0, 0, 1, 2, 2], [1, 1, 0, 0, 0, 2, 2, 0, 2, 0, 1, 2], [0, 1, 0, 2, 2, 2, 2, 0, 1, 0, 1, 0], [1, 0, 1, 2, 0, 1, 0, 0, 2, 2, 2, 0], [2, 1, 1, 2, 1, 2, 0, 0, 0, 0, 2, 0], [2, 0, 0, 2, 1, 1, 2, 0, 0, 2, 1, 0], [1, 1, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2], [2, 2, 2, 0, 1, 0, 1, 2, 0, 1, 0, 0], [2, 0, 1, 0, 1, 1, 0, 0, 0, 2, 2, 2], [1, 2, 0, 2, 0, 0, 2, 0, 2, 1, 1, 0], [0, 1, 2, 2, 2, 2, 1, 0, 1, 0, 0, 0], [1, 1, 1, 0, 0, 2, 0, 2, 2, 0, 2, 0], [2, 2, 2, 0, 1, 0, 1, 0, 0, 1, 0, 2], [2, 0, 0, 0, 2, 0, 2, 2, 2, 2, 0, 1], [2, 2, 0, 2, 2, 0, 0, 1, 2, 0, 2, 0], [2, 0, 2, 1, 2, 2, 0, 0, 2, 0, 0, 2], [2, 0, 0, 2, 2, 0, 2, 1, 2, 2, 0, 0], [2, 0, 0, 2, 2, 2, 2, 1, 2, 0, 0, 0], [2, 0, 2, 1, 2, 0, 0, 0, 2, 2, 0, 2], [2, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 1], [2, 2, 2, 1, 2, 0, 0, 0, 2, 0, 0, 2], [2, 0, 0, 1, 2, 2, 2, 0, 2, 0, 0, 2], [2, 0, 0, 1, 2, 0, 2, 0, 2, 2, 0, 2], [2, 2, 0, 1, 2, 0, 0, 0, 2, 0, 2, 2], [2, 0, 2, 0, 2, 2, 0, 2, 2, 0, 0, 1], [2, 0, 2, 2, 2, 0, 0, 1, 2, 2, 0, 0], [2, 0, 2, 0, 2, 0, 0, 2, 2, 2, 0, 1], [2, 2, 2, 2, 2, 0, 0, 1, 2, 0, 0, 0], [2, 0, 0, 1, 2, 2, 0, 0, 2, 0, 2, 2], [2, 2, 0, 0, 2, 0, 2, 2, 2, 0, 0, 1], [2, 2, 0, 0, 2, 0, 0, 2, 2, 0, 2, 1], [2, 0, 0, 1, 2, 0, 0, 0, 2, 2, 2, 2], [2, 0, 2, 2, 2, 2, 0, 1, 2, 0, 0, 0], [2, 0, 0, 2, 2, 2, 0, 1, 2, 0, 2, 0], [2, 2, 0, 2, 2, 0, 2, 1, 2, 0, 0, 0], [2, 0, 0, 2, 2, 0, 0, 1, 2, 2, 2, 0], [2, 2, 0, 1, 2, 0, 2, 0, 2, 0, 0, 2], [2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 1], [2, 0, 0, 0, 2, 2, 0, 2, 2, 0, 2, 1], [2, 2, 2, 0, 2, 0, 0, 2, 2, 0, 0, 1], [0, 2, 2, 2, 2, 2, 0, 1, 0, 2, 0, 0], [0, 2, 0, 1, 0, 2, 2, 0, 2, 2, 0, 2], [2, 2, 2, 2, 0, 2, 0, 1, 0, 2, 0, 0], [0, 2, 0, 0, 2, 2, 2, 2, 0, 2, 0, 1], [2, 2, 0, 2, 0, 2, 2, 1, 0, 2, 0, 0], [0, 2, 0, 1, 2, 2, 0, 0, 0, 2, 2, 2], [0, 2, 2, 0, 2, 2, 0, 2, 0, 2, 0, 1], [0, 2, 2, 2, 0, 2, 0, 1, 2, 2, 0, 0], [2, 2, 0, 2, 0, 2, 0, 1, 0, 2, 2, 0], [2, 2, 2, 1, 0, 2, 0, 0, 0, 2, 0, 2], [0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 1], [0, 2, 2, 1, 0, 2, 0, 0, 2, 2, 0, 2], [0, 2, 0, 2, 2, 2, 2, 1, 0, 2, 0, 0], [2, 2, 0, 1, 0, 2, 0, 0, 0, 2, 2, 2], [2, 2, 0, 1, 0, 2, 2, 0, 0, 2, 0, 2], [2, 2, 2, 0, 0, 2, 0, 2, 0, 2, 0, 1], [0, 2, 0, 0, 2, 2, 0, 2, 0, 2, 2, 1], [2, 2, 0, 0, 0, 2, 2, 2, 0, 2, 0, 1], [0, 2, 2, 1, 2, 2, 0, 0, 0, 2, 0, 2], [0, 2, 0, 1, 0, 2, 0, 0, 2, 2, 2, 2], [0, 2, 2, 0, 0, 2, 0, 2, 2, 2, 0, 1], [2, 2, 0, 0, 0, 2, 0, 2, 0, 2, 2, 1], [0, 2, 0, 0, 0, 2, 0, 2, 2, 2, 2, 1], [0, 2, 0, 2, 0, 2, 0, 1, 2, 2, 2, 0], [0, 2, 0, 2, 2, 2, 0, 1, 0, 2, 2, 0], [0, 2, 0, 1, 2, 2, 2, 0, 0, 2, 0, 2], [0, 2, 0, 2, 0, 2, 2, 1, 2, 2, 0, 0], [0, 0, 2, 2, 2, 0, 2, 1, 0, 2, 2, 0], [0, 0, 2, 1, 0, 2, 2, 0, 2, 0, 2, 2], [2, 0, 2, 1, 0, 0, 2, 0, 0, 2, 2, 2], [0, 2, 2, 2, 0, 0, 2, 1, 2, 0, 2, 0], [0, 2, 2, 1, 0, 0, 2, 0, 2, 0, 2, 2], [0, 2, 2, 1, 2, 0, 2, 0, 0, 0, 2, 2], [0, 0, 2, 2, 2, 2, 2, 1, 0, 0, 2, 0], [2, 2, 2, 2, 0, 0, 2, 1, 0, 0, 2, 0], [2, 0, 2, 1, 0, 2, 2, 0, 0, 0, 2, 2], [0, 0, 2, 1, 2, 2, 2, 0, 0, 0, 2, 2], [0, 0, 2, 0, 2, 2, 2, 2, 0, 0, 2, 1], [0, 0, 2, 0, 2, 0, 2, 2, 0, 2, 2, 1], [0, 0, 2, 0, 0, 2, 2, 2, 2, 0, 2, 1], [2, 2, 2, 0, 0, 0, 2, 2, 0, 0, 2, 1], [0, 0, 2, 2, 0, 0, 2, 1, 2, 2, 2, 0], [2, 0, 2, 2, 0, 2, 2, 1, 0, 0, 2, 0], [2, 2, 2, 1, 0, 0, 2, 0, 0, 0, 2, 2], [2, 0, 2, 2, 0, 0, 2, 1, 0, 2, 2, 0], [0, 0, 2, 2, 0, 2, 2, 1, 2, 0, 2, 0], [2, 0, 2, 0, 0, 2, 2, 2, 0, 0, 2, 1], [0, 2, 2, 0, 0, 0, 2, 2, 2, 0, 2, 1], [0, 0, 2, 1, 2, 0, 2, 0, 0, 2, 2, 2], [2, 0, 2, 0, 0, 0, 2, 2, 0, 2, 2, 1], [0, 2, 2, 0, 2, 0, 2, 2, 0, 0, 2, 1], [0, 0, 2, 1, 0, 0, 2, 0, 2, 2, 2, 2], [0, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 1], [0, 2, 2, 2, 2, 0, 2, 1, 0, 0, 2, 0], [2, 0, 2, 2, 0, 0, 1, 2, 0, 2, 0, 2], [2, 0, 0, 2, 0, 2, 2, 2, 0, 0, 1, 2], [2, 0, 1, 2, 0, 0, 0, 2, 0, 2, 2, 2], [0, 2, 2, 2, 2, 0, 1, 2, 0, 0, 0, 2], [0, 0, 2, 2, 2, 0, 1, 2, 0, 2, 0, 2], [0, 2, 1, 2, 0, 0, 0, 2, 2, 0, 2, 2], [0, 0, 2, 2, 0, 2, 1, 2, 2, 0, 0, 2], [0, 0, 1, 2, 0, 2, 0, 2, 2, 0, 2, 2], [2, 0, 1, 2, 0, 2, 0, 2, 0, 0, 2, 2], [0, 2, 1, 2, 2, 0, 0, 2, 0, 0, 2, 2], [0, 0, 2, 2, 2, 2, 1, 2, 0, 0, 0, 2], [0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 1, 2], [2, 2, 2, 2, 0, 0, 1, 2, 0, 0, 0, 2], [2, 2, 0, 2, 0, 0, 2, 2, 0, 0, 1, 2], [0, 2, 0, 2, 2, 0, 2, 2, 0, 0, 1, 2], [0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 1, 2], [0, 2, 0, 2, 0, 0, 2, 2, 2, 0, 1, 2], [2, 0, 2, 2, 0, 2, 1, 2, 0, 0, 0, 2], [0, 0, 1, 2, 2, 2, 0, 2, 0, 0, 2, 2], [0, 0, 2, 2, 0, 0, 1, 2, 2, 2, 0, 2], [0, 0, 1, 2, 2, 0, 0, 2, 0, 2, 2, 2], [0, 0, 1, 2, 0, 0, 0, 2, 2, 2, 2, 2], [0, 2, 2, 2, 0, 0, 1, 2, 2, 0, 0, 2], [2, 0, 0, 2, 0, 0, 2, 2, 0, 2, 1, 2], [0, 0, 0, 2, 0, 2, 2, 2, 2, 0, 1, 2], [2, 2, 1, 2, 0, 0, 0, 2, 0, 0, 2, 2], [0, 0, 0, 2, 2, 0, 2, 2, 0, 2, 1, 2], [2, 2, 2, 0, 1, 2, 0, 2, 0, 2, 0, 0], [1, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0], [0, 2, 2, 0, 2, 2, 0, 0, 1, 2, 0, 2], [2, 2, 2, 0, 1, 2, 0, 0, 0, 2, 0, 2], [2, 2, 0, 2, 1, 2, 2, 0, 0, 2, 0, 0], [0, 2, 2, 0, 2, 2, 0, 2, 1, 2, 0, 0], [0, 2, 0, 0, 2, 2, 0, 0, 1, 2, 2, 2], [2, 2, 0, 2, 1, 2, 0, 0, 0, 2, 2, 0], [0, 2, 0, 0, 2, 2, 0, 2, 1, 2, 2, 0], [1, 2, 0, 0, 0, 2, 2, 0, 2, 2, 0, 2], [1, 2, 2, 0, 0, 2, 0, 2, 2, 2, 0, 0], [0, 2, 0, 2, 2, 2, 2, 0, 1, 2, 0, 0], [0, 2, 0, 0, 2, 2, 2, 0, 1, 2, 0, 2], [0, 2, 2, 2, 2, 2, 0, 0, 1, 2, 0, 0], [1, 2, 2, 0, 0, 2, 0, 0, 2, 2, 0, 2], [1, 2, 2, 2, 0, 2, 0, 0, 2, 2, 0, 0], [2, 2, 0, 0, 1, 2, 0, 2, 0, 2, 2, 0], [2, 2, 0, 0, 1, 2, 2, 0, 0, 2, 0, 2], [1, 2, 0, 0, 0, 2, 0, 2, 2, 2, 2, 0], [2, 2, 0, 0, 1, 2, 2, 2, 0, 2, 0, 0], [2, 2, 0, 0, 1, 2, 0, 0, 0, 2, 2, 2], [1, 2, 0, 2, 0, 2, 2, 0, 2, 2, 0, 0], [0, 2, 0, 2, 2, 2, 0, 0, 1, 2, 2, 0], [1, 2, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2], [1, 2, 0, 2, 0, 2, 0, 0, 2, 2, 2, 0], [0, 2, 0, 0, 2, 2, 2, 2, 1, 2, 0, 0], [2, 2, 2, 2, 1, 2, 0, 0, 0, 2, 0, 0], [2, 2, 1, 2, 2, 0, 2, 0, 2, 0, 0, 0], [2, 0, 2, 0, 2, 0, 0, 2, 2, 2, 1, 0], [2, 0, 1, 0, 2, 2, 2, 0, 2, 0, 0, 2], [2, 2, 2, 0, 2, 0, 0, 2, 2, 0, 1, 0], [2, 2, 0, 0, 2, 0, 1, 0, 2, 0, 2, 2], [2, 2, 0, 0, 2, 0, 1, 2, 2, 0, 2, 0], [2, 0, 1, 0, 2, 0, 2, 2, 2, 2, 0, 0], [2, 0, 0, 2, 2, 2, 1, 0, 2, 0, 2, 0], [2, 0, 0, 0, 2, 2, 1, 0, 2, 0, 2, 2], [2, 0, 2, 0, 2, 0, 0, 0, 2, 2, 1, 2], [2, 0, 2, 2, 2, 2, 0, 0, 2, 0, 1, 0], [2, 0, 0, 0, 2, 0, 1, 2, 2, 2, 2, 0], [2, 0, 1, 0, 2, 0, 2, 0, 2, 2, 0, 2], [2, 0, 2, 0, 2, 2, 0, 2, 2, 0, 1, 0], [2, 0, 0, 0, 2, 0, 1, 0, 2, 2, 2, 2], [2, 0, 0, 2, 2, 0, 1, 0, 2, 2, 2, 0], [2, 2, 1, 0, 2, 0, 2, 0, 2, 0, 0, 2], [2, 0, 1, 0, 2, 2, 2, 2, 2, 0, 0, 0], [2, 2, 1, 0, 2, 0, 2, 2, 2, 0, 0, 0], [2, 0, 1, 2, 2, 2, 2, 0, 2, 0, 0, 0], [2, 0, 0, 0, 2, 2, 1, 2, 2, 0, 2, 0], [2, 2, 2, 2, 2, 0, 0, 0, 2, 0, 1, 0], [2, 2, 2, 0, 2, 0, 0, 0, 2, 0, 1, 2], [2, 0, 1, 2, 2, 0, 2, 0, 2, 2, 0, 0], [2, 0, 2, 2, 2, 0, 0, 0, 2, 2, 1, 0], [2, 2, 0, 2, 2, 0, 1, 0, 2, 0, 2, 0], [2, 0, 2, 0, 2, 2, 0, 0, 2, 0, 1, 2], [2, 1, 2, 0, 1, 0, 2, 0, 0, 2, 2, 0], [2, 2, 2, 0, 1, 1, 2, 0, 0, 0, 2, 0], [0, 0, 2, 0, 2, 2, 2, 0, 1, 1, 2, 0], [0, 2, 2, 0, 2, 1, 2, 0, 1, 0, 2, 0], [1, 2, 2, 0, 0, 1, 2, 0, 2, 0, 2, 0], [1, 0, 2, 0, 0, 2, 2, 0, 2, 1, 2, 0], [2, 0, 2, 0, 1, 2, 2, 0, 0, 1, 2, 0], [1, 1, 2, 0, 0, 0, 2, 0, 2, 2, 2, 0], [0, 1, 2, 0, 2, 0, 2, 0, 1, 2, 2, 0], [2, 2, 2, 0, 2, 0, 0, 0, 2, 1, 0, 2], [2, 1, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0], [2, 0, 0, 2, 2, 1, 0, 0, 2, 2, 2, 0], [2, 0, 0, 0, 2, 1, 0, 2, 2, 2, 2, 0], [2, 2, 0, 2, 2, 0, 0, 0, 2, 1, 2, 0], [2, 1, 2, 0, 2, 2, 0, 2, 2, 0, 0, 0], [2, 2, 2, 0, 2, 0, 0, 2, 2, 1, 0, 0], [2, 2, 0, 2, 2, 0, 2, 0, 2, 1, 0, 0], [2, 0, 2, 0, 2, 1, 0, 2, 2, 2, 0, 0], [2, 0, 0, 0, 2, 1, 2, 2, 2, 2, 0, 0], [2, 1, 0, 2, 2, 2, 2, 0, 2, 0, 0, 0], [2, 2, 2, 2, 2, 0, 0, 0, 2, 1, 0, 0], [2, 1, 0, 2, 2, 2, 0, 0, 2, 0, 2, 0], [2, 1, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0], [2, 1, 0, 0, 2, 2, 0, 0, 2, 0, 2, 2], [2, 2, 0, 0, 2, 0, 2, 2, 2, 1, 0, 0], [2, 1, 0, 0, 2, 2, 0, 2, 2, 0, 2, 0], [2, 0, 0, 2, 2, 1, 2, 0, 2, 2, 0, 0], [2, 2, 0, 0, 2, 0, 0, 2, 2, 1, 2, 0], [2, 0, 0, 0, 2, 1, 2, 0, 2, 2, 0, 2], [2, 2, 0, 0, 2, 0, 2, 0, 2, 1, 0, 2], [2, 0, 0, 0, 2, 1, 0, 0, 2, 2, 2, 2], [2, 2, 0, 0, 2, 0, 0, 0, 2, 1, 2, 2], [2, 1, 2, 0, 2, 2, 0, 0, 2, 0, 0, 2], [2, 1, 0, 0, 2, 2, 2, 0, 2, 0, 0, 2], [2, 0, 2, 2, 2, 1, 0, 0, 2, 2, 0, 0], [2, 0, 2, 0, 2, 1, 0, 0, 2, 2, 0, 2], [1, 1, 0, 2, 0, 0, 0, 2, 2, 2, 0, 2], [0, 0, 0, 2, 2, 2, 0, 2, 1, 1, 0, 2], [0, 2, 0, 2, 2, 1, 0, 2, 1, 0, 0, 2], [1, 2, 0, 2, 0, 1, 0, 2, 2, 0, 0, 2], [2, 0, 0, 2, 1, 2, 0, 2, 0, 1, 0, 2], [2, 1, 0, 2, 1, 0, 0, 2, 0, 2, 0, 2], [0, 1, 0, 2, 2, 0, 0, 2, 1, 2, 0, 2], [2, 2, 0, 2, 1, 1, 0, 2, 0, 0, 0, 2], [1, 0, 0, 2, 0, 2, 0, 2, 2, 1, 0, 2], [2, 1, 0, 1, 0, 0, 2, 1, 0, 2, 0, 1], [0, 2, 0, 1, 0, 1, 0, 1, 2, 0, 2, 1], [2, 0, 0, 1, 0, 2, 0, 1, 0, 1, 2, 1], [2, 2, 0, 1, 0, 1, 0, 1, 0, 0, 2, 1], [0, 2, 2, 1, 2, 1, 0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 0, 2, 1, 2, 2, 0, 1], [0, 2, 2, 1, 0, 1, 0, 1, 2, 0, 0, 1], [2, 0, 0, 1, 0, 2, 2, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 2, 2, 1, 2, 1, 0, 1], [0, 0, 0, 1, 2, 2, 2, 1, 0, 1, 0, 1], [0, 2, 0, 1, 2, 1, 2, 1, 0, 0, 0, 1], [2, 2, 2, 1, 0, 1, 0, 1, 0, 0, 0, 1], [0, 0, 2, 1, 0, 2, 0, 1, 2, 1, 0, 1], [2, 1, 2, 1, 0, 0, 0, 1, 0, 2, 0, 1], [2, 0, 2, 1, 0, 2, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 2, 0, 0, 1, 0, 2, 2, 1], [0, 1, 0, 1, 0, 0, 0, 1, 2, 2, 2, 1], [0, 0, 0, 1, 0, 2, 0, 1, 2, 1, 2, 1], [2, 2, 0, 1, 0, 1, 2, 1, 0, 0, 0, 1], [0, 2, 0, 1, 0, 1, 2, 1, 2, 0, 0, 1], [2, 1, 0, 1, 0, 0, 0, 1, 0, 2, 2, 1], [0, 1, 2, 1, 0, 0, 0, 1, 2, 2, 0, 1], [0, 0, 0, 1, 2, 2, 0, 1, 0, 1, 2, 1], [0, 2, 0, 1, 2, 1, 0, 1, 0, 0, 2, 1], [0, 0, 2, 1, 2, 2, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 2, 0, 2, 1, 0, 2, 0, 1], [0, 1, 2, 1, 2, 0, 0, 1, 0, 2, 0, 1], [0, 2, 2, 0, 0, 2, 0, 1, 2, 2, 1, 0], [0, 2, 1, 1, 2, 2, 2, 0, 0, 2, 0, 0], [0, 2, 0, 1, 0, 2, 1, 0, 2, 2, 2, 0], [2, 2, 0, 0, 0, 2, 1, 0, 0, 2, 2, 1], [0, 2, 2, 0, 2, 2, 0, 0, 0, 2, 1, 1], [0, 2, 1, 0, 0, 2, 2, 0, 2, 2, 0, 1], [2, 2, 1, 0, 0, 2, 2, 0, 0, 2, 0, 1], [0, 2, 1, 1, 0, 2, 2, 0, 2, 2, 0, 0], [0, 2, 2, 1, 2, 2, 0, 0, 0, 2, 1, 0], [0, 2, 2, 0, 0, 2, 0, 0, 2, 2, 1, 1], [2, 2, 1, 0, 0, 2, 2, 1, 0, 2, 0, 0], [0, 2, 1, 0, 2, 2, 2, 0, 0, 2, 0, 1], [0, 2, 0, 0, 2, 2, 1, 1, 0, 2, 2, 0], [2, 2, 2, 0, 0, 2, 0, 0, 0, 2, 1, 1], [2, 2, 0, 1, 0, 2, 1, 0, 0, 2, 2, 0], [0, 2, 0, 1, 2, 2, 1, 0, 0, 2, 2, 0], [0, 2, 0, 0, 0, 2, 1, 0, 2, 2, 2, 1], [0, 2, 2, 0, 2, 2, 0, 1, 0, 2, 1, 0], [2, 2, 2, 0, 0, 2, 0, 1, 0, 2, 1, 0], [2, 2, 1, 1, 0, 2, 2, 0, 0, 2, 0, 0], [2, 2, 2, 1, 0, 2, 0, 0, 0, 2, 1, 0], [0, 2, 1, 0, 2, 2, 2, 1, 0, 2, 0, 0], [0, 2, 0, 0, 0, 2, 1, 1, 2, 2, 2, 0], [2, 2, 0, 0, 0, 2, 1, 1, 0, 2, 2, 0], [0, 2, 1, 0, 0, 2, 2, 1, 2, 2, 0, 0], [0, 2, 0, 0, 2, 2, 1, 0, 0, 2, 2, 1], [0, 2, 2, 1, 0, 2, 0, 0, 2, 2, 1, 0], [2, 0, 2, 0, 0, 0, 2, 0, 1, 2, 2, 2], [0, 0, 2, 0, 1, 2, 2, 2, 2, 0, 2, 0], [2, 2, 2, 0, 0, 0, 2, 0, 1, 0, 2, 2], [0, 2, 2, 0, 1, 0, 2, 0, 2, 0, 2, 2], [1, 2, 2, 2, 2, 0, 2, 0, 0, 0, 2, 0], [0, 0, 2, 0, 1, 0, 2, 0, 2, 2, 2, 2], [0, 2, 2, 0, 1, 0, 2, 2, 2, 0, 2, 0], [1, 0, 2, 0, 2, 2, 2, 0, 0, 0, 2, 2], [0, 0, 2, 0, 1, 0, 2, 2, 2, 2, 2, 0], [0, 0, 2, 2, 1, 0, 2, 0, 2, 2, 2, 0], [2, 0, 2, 0, 0, 2, 2, 0, 1, 0, 2, 2], [1, 2, 2, 0, 2, 0, 2, 2, 0, 0, 2, 0], [2, 2, 2, 0, 0, 0, 2, 2, 1, 0, 2, 0], [2, 0, 2, 2, 0, 2, 2, 0, 1, 0, 2, 0], [2, 2, 2, 2, 0, 0, 2, 0, 1, 0, 2, 0], [2, 0, 2, 0, 0, 0, 2, 2, 1, 2, 2, 0], [2, 0, 2, 0, 0, 2, 2, 2, 1, 0, 2, 0], [0, 0, 2, 2, 1, 2, 2, 0, 2, 0, 2, 0], [1, 0, 2, 0, 2, 0, 2, 2, 0, 2, 2, 0], [0, 0, 2, 0, 1, 2, 2, 0, 2, 0, 2, 2], [1, 0, 2, 0, 2, 0, 2, 0, 0, 2, 2, 2], [1, 0, 2, 2, 2, 0, 2, 0, 0, 2, 2, 0], [1, 0, 2, 0, 2, 2, 2, 2, 0, 0, 2, 0], [2, 0, 2, 2, 0, 0, 2, 0, 1, 2, 2, 0], [0, 2, 2, 2, 1, 0, 2, 0, 2, 0, 2, 0], [1, 0, 2, 2, 2, 2, 2, 0, 0, 0, 2, 0], [1, 2, 2, 0, 2, 0, 2, 0, 0, 0, 2, 2], [2, 2, 2, 0, 2, 1, 0, 0, 2, 0, 1, 0], [2, 0, 1, 0, 2, 2, 2, 0, 2, 1, 0, 0], [2, 0, 0, 0, 2, 2, 1, 0, 2, 1, 2, 0], [2, 2, 0, 0, 2, 1, 1, 0, 2, 0, 2, 0], [2, 1, 2, 0, 2, 0, 0, 0, 2, 2, 1, 0], [2, 2, 1, 0, 2, 1, 2, 0, 2, 0, 0, 0], [2, 1, 0, 0, 2, 0, 1, 0, 2, 2, 2, 0], [2, 0, 2, 0, 2, 2, 0, 0, 2, 1, 1, 0], [2, 1, 1, 0, 2, 0, 2, 0, 2, 2, 0, 0], [2, 1, 2, 0, 0, 2, 2, 0, 0, 0, 2, 1], [0, 1, 2, 0, 2, 2, 2, 1, 0, 0, 2, 0], [0, 1, 2, 0, 0, 2, 2, 0, 2, 0, 2, 1], [0, 2, 2, 1, 2, 0, 2, 0, 0, 1, 2, 0], [0, 0, 2, 0, 2, 1, 2, 0, 0, 2, 2, 1], [0, 0, 2, 1, 2, 1, 2, 0, 0, 2, 2, 0], [2, 2, 2, 0, 0, 0, 2, 1, 0, 1, 2, 0], [0, 0, 2, 0, 2, 1, 2, 1, 0, 2, 2, 0], [2, 1, 2, 1, 0, 2, 2, 0, 0, 0, 2, 0], [0, 1, 2, 0, 2, 2, 2, 0, 0, 0, 2, 1], [0, 1, 2, 0, 0, 2, 2, 1, 2, 0, 2, 0], [0, 2, 2, 0, 0, 0, 2, 1, 2, 1, 2, 0], [2, 0, 2, 0, 0, 1, 2, 0, 0, 2, 2, 1], [0, 2, 2, 0, 2, 0, 2, 0, 0, 1, 2, 1], [0, 1, 2, 1, 0, 2, 2, 0, 2, 0, 2, 0], [2, 0, 2, 1, 0, 1, 2, 0, 0, 2, 2, 0], [0, 2, 2, 0, 0, 0, 2, 0, 2, 1, 2, 1], [2, 2, 2, 1, 0, 0, 2, 0, 0, 1, 2, 0], [0, 2, 2, 0, 2, 0, 2, 1, 0, 1, 2, 0], [0, 0, 2, 0, 0, 1, 2, 1, 2, 2, 2, 0], [2, 2, 2, 0, 0, 0, 2, 0, 0, 1, 2, 1], [2, 1, 2, 0, 0, 2, 2, 1, 0, 0, 2, 0], [2, 0, 2, 0, 0, 1, 2, 1, 0, 2, 2, 0], [0, 2, 2, 1, 0, 0, 2, 0, 2, 1, 2, 0], [0, 1, 2, 1, 2, 2, 2, 0, 0, 0, 2, 0], [0, 0, 2, 0, 0, 1, 2, 0, 2, 2, 2, 1], [0, 0, 2, 1, 0, 1, 2, 0, 2, 2, 2, 0], [0, 2, 0, 1, 2, 2, 0, 2, 1, 2, 0, 0], [0, 2, 0, 2, 2, 2, 0, 0, 1, 2, 0, 1], [1, 2, 0, 0, 0, 2, 0, 1, 2, 2, 0, 2], [0, 2, 0, 0, 2, 2, 0, 1, 1, 2, 0, 2], [1, 2, 0, 1, 0, 2, 0, 2, 2, 2, 0, 0], [2, 2, 0, 1, 1, 2, 0, 2, 0, 2, 0, 0], [1, 2, 0, 2, 0, 2, 0, 0, 2, 2, 0, 1], [2, 2, 0, 2, 1, 2, 0, 0, 0, 2, 0, 1], [2, 2, 0, 0, 1, 2, 0, 1, 0, 2, 0, 2], [2, 2, 2, 0, 1, 2, 0, 0, 0, 2, 1, 0], [2, 2, 1, 0, 1, 2, 2, 0, 0, 2, 0, 0], [0, 2, 1, 0, 2, 2, 2, 0, 1, 2, 0, 0], [2, 2, 0, 0, 1, 2, 1, 0, 0, 2, 2, 0], [1, 2, 2, 0, 0, 2, 0, 0, 2, 2, 1, 0], [0, 2, 0, 0, 2, 2, 1, 0, 1, 2, 2, 0], [1, 2, 0, 0, 0, 2, 1, 0, 2, 2, 2, 0], [1, 2, 1, 0, 0, 2, 2, 0, 2, 2, 0, 0], [0, 2, 2, 0, 2, 2, 0, 0, 1, 2, 1, 0], [2, 0, 1, 1, 1, 2, 0, 1, 0, 0, 0, 1], [0, 0, 1, 1, 2, 2, 0, 1, 1, 0, 0, 1], [0, 2, 1, 1, 2, 0, 0, 1, 1, 0, 0, 1], [1, 2, 0, 1, 0, 0, 0, 1, 2, 0, 1, 1], [2, 2, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1], [2, 0, 0, 1, 1, 0, 0, 1, 0, 2, 1, 1], [2, 0, 1, 1, 1, 0, 0, 1, 0, 2, 0, 1], [1, 0, 1, 1, 0, 2, 0, 1, 2, 0, 0, 1], [0, 0, 0, 1, 2, 2, 0, 1, 1, 0, 1, 1], [1, 0, 1, 1, 0, 0, 0, 1, 2, 2, 0, 1], [1, 2, 0, 1, 0, 0, 1, 1, 2, 0, 0, 1], [2, 2, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1], [1, 0, 0, 1, 0, 0, 0, 1, 2, 2, 1, 1], [2, 0, 0, 1, 1, 0, 1, 1, 0, 2, 0, 1], [1, 0, 0, 1, 0, 0, 1, 1, 2, 2, 0, 1], [2, 0, 0, 1, 1, 2, 0, 1, 0, 0, 1, 1], [0, 2, 0, 1, 2, 0, 0, 1, 1, 0, 1, 1], [0, 0, 0, 1, 2, 0, 0, 1, 1, 2, 1, 1], [1, 2, 1, 1, 0, 0, 0, 1, 2, 0, 0, 1], [0, 0, 1, 1, 2, 0, 0, 1, 1, 2, 0, 1], [0, 2, 0, 1, 2, 0, 1, 1, 1, 0, 0, 1], [2, 2, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 1, 2, 0, 1, 1, 1, 2, 0, 1], [0, 0, 0, 1, 2, 2, 1, 1, 1, 0, 0, 1], [2, 0, 0, 1, 1, 2, 1, 1, 0, 0, 0, 1], [1, 0, 0, 1, 0, 2, 1, 1, 2, 0, 0, 1], [1, 0, 0, 1, 0, 2, 0, 1, 2, 0, 1, 1], [0, 2, 1, 2, 0, 1, 1, 1, 0, 0, 1, 0], [0, 0, 1, 2, 0, 2, 1, 1, 0, 1, 1, 0], [0, 1, 1, 2, 0, 0, 1, 1, 0, 2, 1, 0], [0, 1, 1, 0, 0, 0, 1, 2, 0, 2, 1, 1], [0, 2, 1, 0, 0, 1, 1, 2, 0, 0, 1, 1], [0, 2, 1, 1, 0, 1, 1, 0, 0, 0, 1, 2], [0, 0, 1, 1, 0, 2, 1, 0, 0, 1, 1, 2], [0, 0, 1, 0, 0, 2, 1, 2, 0, 1, 1, 1], [0, 1, 1, 1, 0, 0, 1, 0, 0, 2, 1, 2], [0, 0, 2, 2, 1, 0, 1, 2, 2, 0, 0, 2], [1, 0, 2, 2, 2, 0, 1, 2, 0, 0, 0, 2], [1, 0, 0, 2, 2, 0, 2, 2, 0, 0, 1, 2], [2, 0, 2, 2, 0, 0, 1, 2, 1, 0, 0, 2], [0, 0, 0, 2, 1, 0, 2, 2, 2, 0, 1, 2], [2, 0, 0, 2, 0, 0, 2, 2, 1, 0, 1, 2], [1, 0, 1, 2, 2, 0, 0, 2, 0, 0, 2, 2], [2, 0, 1, 2, 0, 0, 0, 2, 1, 0, 2, 2], [0, 0, 1, 2, 1, 0, 0, 2, 2, 0, 2, 2], [0, 1, 0, 2, 0, 1, 2, 1, 0, 1, 1, 0], [0, 1, 0, 0, 0, 1, 2, 2, 0, 1, 1, 1], [0, 1, 2, 2, 0, 1, 1, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 2, 2], [0, 1, 2, 0, 0, 1, 1, 2, 0, 1, 0, 1], [0, 1, 1, 2, 0, 1, 0, 1, 0, 1, 2, 0], [0, 1, 1, 0, 0, 1, 0, 2, 0, 1, 2, 1], [0, 1, 0, 1, 0, 1, 2, 0, 0, 1, 1, 2], [0, 1, 2, 1, 0, 1, 1, 0, 0, 1, 0, 2], [2, 0, 0, 1, 2, 1, 0, 2, 2, 2, 0, 0], [2, 1, 0, 2, 2, 2, 0, 0, 2, 0, 0, 1], [2, 0, 0, 0, 2, 1, 0, 1, 2, 2, 0, 2], [2, 1, 0, 0, 2, 2, 0, 1, 2, 0, 0, 2], [2, 2, 0, 2, 2, 0, 0, 0, 2, 1, 0, 1], [2, 2, 0, 0, 2, 0, 0, 1, 2, 1, 0, 2], [2, 1, 0, 1, 2, 2, 0, 2, 2, 0, 0, 0], [2, 0, 0, 2, 2, 1, 0, 0, 2, 2, 0, 1], [2, 2, 0, 1, 2, 0, 0, 2, 2, 1, 0, 0], [1, 0, 2, 0, 1, 0, 1, 2, 1, 0, 0, 1], [1, 0, 2, 2, 1, 0, 1, 1, 1, 0, 0, 0], [1, 0, 0, 1, 1, 0, 2, 0, 1, 0, 1, 2], [1, 0, 0, 0, 1, 0, 2, 2, 1, 0, 1, 1], [1, 0, 2, 1, 1, 0, 1, 0, 1, 0, 0, 2], [1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 2, 2], [1, 0, 1, 2, 1, 0, 0, 1, 1, 0, 2, 0], [1, 0, 1, 0, 1, 0, 0, 2, 1, 0, 2, 1], [1, 0, 0, 2, 1, 0, 2, 1, 1, 0, 1, 0], [0, 1, 1, 1, 0, 0, 2, 1, 0, 2, 0, 1], [0, 2, 0, 1, 0, 1, 1, 1, 0, 0, 2, 1], [0, 2, 2, 1, 0, 1, 0, 1, 0, 0, 1, 1], [0, 0, 0, 1, 0, 2, 1, 1, 0, 1, 2, 1], [0, 1, 2, 1, 0, 0, 0, 1, 0, 2, 1, 1], [0, 1, 0, 1, 0, 0, 1, 1, 0, 2, 2, 1], [0, 0, 2, 1, 0, 2, 0, 1, 0, 1, 1, 1], [0, 0, 1, 1, 0, 2, 2, 1, 0, 1, 0, 1], [0, 2, 1, 1, 0, 1, 2, 1, 0, 0, 0, 1], [0, 0, 2, 1, 1, 0, 2, 2, 2, 0, 2, 0], [2, 0, 2, 2, 0, 0, 2, 0, 1, 0, 2, 1], [1, 0, 2, 1, 2, 0, 2, 2, 0, 0, 2, 0], [0, 0, 2, 0, 1, 0, 2, 1, 2, 0, 2, 2], [1, 0, 2, 2, 2, 0, 2, 0, 0, 0, 2, 1], [2, 0, 2, 0, 0, 0, 2, 1, 1, 0, 2, 2], [1, 0, 2, 0, 2, 0, 2, 1, 0, 0, 2, 2], [0, 0, 2, 2, 1, 0, 2, 0, 2, 0, 2, 1], [2, 0, 2, 1, 0, 0, 2, 2, 1, 0, 2, 0], [2, 0, 0, 2, 2, 0, 0, 2, 2, 1, 0, 2], [2, 1, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2], [2, 0, 0, 2, 2, 1, 0, 2, 2, 0, 0, 2], [0, 0, 2, 1, 0, 2, 2, 1, 0, 0, 2, 1], [0, 2, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1], [0, 0, 2, 1, 0, 0, 2, 1, 0, 2, 2, 1], [2, 0, 1, 0, 2, 0, 1, 0, 2, 2, 1, 0], [2, 0, 1, 0, 2, 2, 1, 0, 2, 0, 1, 0], [2, 2, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0], [2, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2], [0, 0, 1, 2, 2, 0, 1, 2, 0, 0, 1, 2], [0, 0, 1, 2, 0, 0, 1, 2, 2, 0, 1, 2], [0, 2, 1, 1, 0, 2, 1, 0, 0, 2, 1, 0], [0, 2, 1, 0, 0, 2, 1, 1, 0, 2, 1, 0], [0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 1], [2, 1, 0, 0, 2, 1, 2, 0, 2, 1, 0, 0], [2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 2, 0], [2, 1, 2, 0, 2, 1, 0, 0, 2, 1, 0, 0], [1, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0], [0, 2, 1, 0, 0, 2, 1, 0, 1, 2, 1, 0], [0, 2, 1, 0, 1, 2, 1, 0, 0, 2, 1, 0], [1, 2, 0, 2, 1, 2, 0, 0, 1, 2, 0, 0], [1, 2, 0, 0, 1, 2, 0, 2, 1, 2, 0, 0], [1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 2], [1, 0, 2, 0, 1, 0, 2, 2, 1, 0, 2, 0], [1, 0, 2, 2, 1, 0, 2, 0, 1, 0, 2, 0], [1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 2], [0, 1, 0, 2, 0, 1, 1, 2, 0, 1, 0, 2], [0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 1, 2], [0, 1, 1, 2, 0, 1, 0, 2, 0, 1, 0, 2], [0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 0, 1], [2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 2, 1, 0, 1], [1, 0, 2, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 2, 1], [1, 0, 0, 1, 1, 0, 2, 1, 1, 0, 0, 1]]} +RLMATH_EOF diff --git a/tasks/optimize-fs-admissible-set-n12-w7/tests/check.py b/tasks/optimize-fs-admissible-set-n12-w7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..6eaa074538d9d4504dfa5d25e028ba7b477ba196 --- /dev/null +++ b/tasks/optimize-fs-admissible-set-n12-w7/tests/check.py @@ -0,0 +1,56 @@ +"""Constant-weight admissible set A(n, w) (FunSearch / Tyrrell 2022). Score = number of vectors. + +A subset of {0,1,2}^n is admissible (with weight w) if every vector has exactly w nonzero entries, no two +vectors have the same support, and every three distinct vectors u, v, x have a coordinate i where the +multiset {u_i, v_i, x_i} is {0,0,1}, {0,0,2} or {0,1,2}. + +Triple check: for a pair (u, v) the set of "blocking" third vectors is a product set (per coordinate the +values that do NOT complete a good multiset; table from the FunSearch skeleton's block_children). We AND +per-coordinate bitsets over the answer's vectors, so a check is O(N^2 * n * N/64) word ops (3003 vectors: +~3 s). Given constant weight and distinct supports, u and v are never in their own blocking set. +""" +import math + +import numpy as np + +from run import Invalid, int_list + +INVALID = {(0, 0): (0,), (0, 1): (1,), (0, 2): (2,), (1, 0): (1,), (1, 1): (0, 1, 2), (1, 2): (1, 2), + (2, 0): (2,), (2, 1): (1, 2), (2, 2): (0, 1, 2)} + + +def check(inst, ans): + n, w = inst["n"], inst["w"] + vecs = ans.get("vectors") + if not isinstance(vecs, list) or not vecs or len(vecs) > math.comb(n, w): + raise Invalid(f"vectors must be a non-empty list of at most C({n},{w}) vectors") + sups = set() + for v in vecs: + int_list(v, n, 0, 2, "vector") + s = tuple(i for i in range(n) if v[i]) + if len(s) != w: + raise Invalid(f"vector {v} does not have weight {w}") + if s in sups: + raise Invalid(f"two vectors share the support {list(s)}") + sups.add(s) + A = np.array(vecs, dtype=np.int64) + N = len(A) + W = (N + 63) // 64 + + def pack(mask): + b = np.packbits(mask, bitorder="little") + return np.concatenate([b, np.zeros(W * 8 - len(b), np.uint8)]).view(np.uint64) + + U = np.zeros((n, 3, 3, W), np.uint64) + for i in range(n): + for (p, q), vals in INVALID.items(): + U[i, p, q] = pack(np.isin(A[:, i], vals)) + for a in range(N - 1): + B = A[a + 1:] + acc = U[0, A[a, 0]][B[:, 0]] + for i in range(1, n): + acc &= U[i, A[a, i]][B[:, i]] + if acc.any(): + b = a + 1 + int(np.nonzero(acc.any(axis=1))[0][0]) + raise Invalid(f"vectors {vecs[a]} and {vecs[b]} form a bad triple with another vector") + return float(N), {"size": N} diff --git a/tasks/optimize-fs-admissible-set-n12-w7/tests/instance.json b/tasks/optimize-fs-admissible-set-n12-w7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5dbc7451fcfa63f90e5f1e38bf0b9eb018c99028 --- /dev/null +++ b/tasks/optimize-fs-admissible-set-n12-w7/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "w": 7, "direction": "maximize", "best_known": 792, "baseline": 548.0, "family": "fs_admissible_set", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-fs-admissible-set-n12-w7/tests/run.py b/tasks/optimize-fs-admissible-set-n12-w7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-fs-admissible-set-n12-w7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-fs-admissible-set-n12-w7/tests/test.sh b/tasks/optimize-fs-admissible-set-n12-w7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-fs-admissible-set-n12-w7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt